@earthview/core 0.2.2 → 0.2.6
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/dist/index.d.ts +5 -0
- package/dist/index.js +473 -355
- package/dist/index.mjs +3096 -2880
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class $h{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)}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 It=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 En={PROPERTYCHANGE:"propertychange"};function kn(s){for(const t in s)delete s[t]}function Wi(s){let t;for(t in s)return!1;return!t}function ft(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 pr(s,t,e,i){return ft(s,t,e,i,!0)}function Tt(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),kn(s))}const nt={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class Es{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Kd(s,t,e){let i,n;e=e||ai;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 ai(s,t){return s>t?1:s<t?-1:0}function qd(s,t){return s<t?1:s>t?-1:0}function _a(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 Jd(s,t,e){for(;t<e;){const i=s[t];s[t]=s[e],s[e]=i,++t,--e}}function je(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 ui(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 Qd(s,t,e){const i=t||ai;return s.every(function(n,r){if(r===0)return!0;const o=i(s[r-1],n);return!(o>0||o===0)})}function vn(){return!0}function Rn(){return!1}function cs(){}function Nh(s){let t,e,i;return function(){const n=Array.prototype.slice.call(arguments);return(!e||this!==i||!ui(n,e))&&(i=this,e=n,t=s.apply(this,arguments)),t}}function tu(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 qe{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Fr extends Es{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 qe(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,cs);delete o[i]}return l}disposeInternal(){this.listeners_&&kn(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]=cs,++this.pendingRemovals_[t]):(i.splice(n,1),i.length===0&&delete this.listeners_[t]))}}class vs extends Fr{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(nt.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]=ft(this,t[r],e);return n}return ft(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]=pr(this,t[r],e)}else i=pr(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)Gh(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)}}vs.prototype.on;vs.prototype.once;vs.prototype.un;function Gh(s){if(Array.isArray(s))for(let t=0,e=s.length;t<e;++t)Tt(s[t]);else Tt(s)}function Q(){throw new Error("Unimplemented abstract method.")}let eu=0;function K(s){return s.ol_uid||(s.ol_uid=String(++eu))}class Rl extends qe{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class $e extends vs{constructor(t){super(),this.on,this.once,this.un,K(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new Rl(i,t,e)),i=En.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new Rl(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],Wi(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}function gt(s,t){if(!s)throw new Error(t)}class V extends $e{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 V,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_&&(Tt(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=ft(t,nt.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?iu(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 iu(s){if(typeof s=="function")return s;let t;return Array.isArray(s)?t=s:(gt(typeof s.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[s]),function(){return t}}const Xt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function mr(s){const t=oe();for(let e=0,i=s.length;e<i;++e)rs(t,s[e]);return t}function An(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 Bh(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s.slice()}function Xi(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 Tn(s,t){return wa(s,t[0],t[1])}function Yn(s,t){return s[0]<=t[0]&&t[2]<=s[2]&&s[1]<=t[1]&&t[3]<=s[3]}function wa(s,t,e){return s[0]<=t&&t<=s[2]&&s[1]<=e&&e<=s[3]}function Vo(s,t){const e=s[0],i=s[1],n=s[2],r=s[3],o=t[0],a=t[1];let l=Xt.UNKNOWN;return o<e?l=l|Xt.LEFT:o>n&&(l=l|Xt.RIGHT),a<i?l=l|Xt.BELOW:a>r&&(l=l|Xt.ABOVE),l===Xt.UNKNOWN&&(l=Xt.INTERSECTING),l}function oe(){return[1/0,1/0,-1/0,-1/0]}function di(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 Ts(s){return di(1/0,1/0,-1/0,-1/0,s)}function xa(s,t){const e=s[0],i=s[1];return di(e,i,e,i,t)}function Ca(s,t,e,i,n){const r=Ts(n);return Wh(r,s,t,e,i)}function bn(s,t){return s[0]==t[0]&&s[2]==t[2]&&s[1]==t[1]&&s[3]==t[3]}function ss(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 rs(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 Wh(s,t,e,i,n){for(;e<i;e+=n)nu(s,t[e],t[e+1]);return s}function nu(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 Ea(s,t){let e;return e=t(Or(s)),e||(e=t(zr(s)),e)||(e=t($r(s)),e)||(e=t(ji(s)),e)?e:!1}function Ho(s){let t=0;return bs(s)||(t=Et(s)*he(s)),t}function Or(s){return[s[0],s[1]]}function zr(s){return[s[2],s[1]]}function be(s){return[(s[0]+s[2])/2,(s[1]+s[3])/2]}function su(s,t){let e;if(t==="bottom-left")e=Or(s);else if(t==="bottom-right")e=zr(s);else if(t==="top-left")e=ji(s);else if(t==="top-right")e=$r(s);else throw new Error("Invalid corner");return e}function Xo(s,t,e,i,n){const[r,o,a,l,h,c,d,u]=Uh(s,t,e,i);return di(Math.min(r,a,h,d),Math.min(o,l,c,u),Math.max(r,a,h,d),Math.max(o,l,c,u),n)}function Uh(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,d=r*a,u=s[0],f=s[1];return[u-l+d,f-h-c,u-l-d,f-h+c,u+l-d,f+h+c,u+l+d,f+h-c,u-l+d,f-h-c]}function he(s){return s[3]-s[1]}function Ni(s,t,e){const i=e||oe();return le(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]):Ts(i),i}function ji(s){return[s[0],s[3]]}function $r(s){return[s[2],s[3]]}function Et(s){return s[2]-s[0]}function le(s,t){return s[0]<=t[2]&&s[2]>=t[0]&&s[1]<=t[3]&&s[3]>=t[1]}function bs(s){return s[2]<s[0]||s[3]<s[1]}function ru(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s}function ou(s,t,e){let i=!1;const n=Vo(s,t),r=Vo(s,e);if(n===Xt.INTERSECTING||r===Xt.INTERSECTING)i=!0;else{const o=s[0],a=s[1],l=s[2],h=s[3],c=t[0],d=t[1],u=e[0],f=e[1],g=(f-d)/(u-c);let p,m;r&Xt.ABOVE&&!(n&Xt.ABOVE)&&(p=u-(f-h)/g,i=p>=o&&p<=l),!i&&r&Xt.RIGHT&&!(n&Xt.RIGHT)&&(m=f-(u-l)*g,i=m>=a&&m<=h),!i&&r&Xt.BELOW&&!(n&Xt.BELOW)&&(p=u-(f-a)/g,i=p>=o&&p<=l),!i&&r&Xt.LEFT&&!(n&Xt.LEFT)&&(m=f-(u-o)*g,i=m>=a&&m<=h)}return i}function Vh(s,t){const e=t.getExtent(),i=be(s);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const n=Et(e),o=Math.floor((i[0]-e[0])/n)*n;s[0]-=o,s[2]-=o}return s}function Hh(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]]];Vh(s,t);const n=Et(i);if(Et(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 Xh(...s){console.warn(...s)}function Pt(s,t,e){return Math.min(Math.max(s,t),e)}function au(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 li(s,t,e,i)}function li(s,t,e,i){const n=e-s,r=i-t;return n*n+r*r}function lu(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 Al(s){return s*180/Math.PI}function Fe(s){return s*Math.PI/180}function Gi(s,t){const e=s%t;return e*t<0?e+t:e}function ye(s,t,e){return s+e*(t-s)}function Ss(s,t){const e=Math.pow(10,t);return Math.round(s*e)/e}function Gs(s,t){return Math.floor(Ss(s,t))}function Bs(s,t){return Math.ceil(Ss(s,t))}function jo(s,t,e){if(s>=t&&s<e)return s;const i=e-t;return((s-t)%i+i)%i+t}function jh(s,t){return s[0]+=+t[0],s[1]+=+t[1],s}function yr(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 va(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 Yh(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 Kh(s,t){return Math.sqrt(Zh(s,t))}function qh(s,t){if(t.canWrapX()){const e=Et(t.getExtent()),i=hu(s,t,e);i&&(s[0]-=i*e)}return s}function hu(s,t,e){const i=t.getExtent();let n=0;return t.canWrapX()&&(s[0]<i[0]||s[0]>i[2])&&(e=e||Et(i),n=Math.floor((s[0]-i[0])/e)),n}function cu(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 Ta={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class ba{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_||Ta[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 Ps=6378137,fn=Math.PI*Ps,du=[-fn,-fn,fn,fn],uu=[-180,-85,180,85],Ws=Ps*Math.log(Math.tan(Math.PI/2));class Ji extends ba{constructor(t){super({code:t,units:"m",extent:du,global:!0,worldExtent:uu,getPointResolution:function(e,i){return e/Math.cosh(i[1]/Ps)}})}}const Ml=[new Ji("EPSG:3857"),new Ji("EPSG:102100"),new Ji("EPSG:102113"),new Ji("EPSG:900913"),new Ji("http://www.opengis.net/def/crs/EPSG/0/3857"),new Ji("http://www.opengis.net/gml/srs/epsg.xml#3857")];function fu(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]=fn*s[r]/180;let o=Ps*Math.log(Math.tan(Math.PI*(+s[r+1]+90)/360));o>Ws?o=Ws:o<-Ws&&(o=-Ws),t[r+1]=o}return t}function gu(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]/fn,t[r+1]=360*Math.atan(Math.exp(s[r+1]/Ps))/Math.PI-90;return t}const pu=6378137,Fl=[-180,-90,180,90],mu=Math.PI*pu/180;class Di extends ba{constructor(t,e){super({code:t,units:"degrees",extent:Fl,axisOrientation:e,global:!0,metersPerUnit:mu,worldExtent:Fl})}}const Ol=[new Di("CRS:84"),new Di("EPSG:4326","neu"),new Di("urn:ogc:def:crs:OGC:1.3:CRS84"),new Di("urn:ogc:def:crs:OGC:2:84"),new Di("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Di("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Di("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Yo={};function yu(s){return Yo[s]||Yo[s.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function _u(s,t){Yo[s]=t}let wn={};function ds(s,t,e){const i=s.getCode(),n=t.getCode();i in wn||(wn[i]={}),wn[i][n]=e}function oo(s,t){return s in wn&&t in wn[s]?wn[s][t]:null}const _r=.9996,Se=.00669438,Nr=Se*Se,Gr=Nr*Se,Mi=Se/(1-Se),zl=Math.sqrt(1-Se),Sn=(1-zl)/(1+zl),Jh=Sn*Sn,Sa=Jh*Sn,Pa=Sa*Sn,Qh=Pa*Sn,tc=1-Se/4-3*Nr/64-5*Gr/256,wu=3*Se/8+3*Nr/32+45*Gr/1024,xu=15*Nr/256+45*Gr/1024,Cu=35*Gr/3072,Eu=3/2*Sn-27/32*Sa+269/512*Qh,vu=21/16*Jh-55/32*Pa,Tu=151/96*Sa-417/128*Qh,bu=1097/512*Pa,wr=6378137;function Su(s,t,e){const i=s-5e5,o=(e.north?t:t-1e7)/_r/(wr*tc),a=o+Eu*Math.sin(2*o)+vu*Math.sin(4*o)+Tu*Math.sin(6*o)+bu*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),d=l/c,u=d*d,f=u*u,g=1-Se*h,p=Math.sqrt(1-Se*h),m=wr/p,y=(1-Se)/g,w=Mi*c**2,E=w*w,x=i/(m*_r),C=x*x,T=C*x,_=T*x,b=_*x,S=b*x,P=a-d/y*(C/2-_/24*(5+3*u+10*w-4*E-9*Mi))+S/720*(61+90*u+298*w+45*f-252*Mi-3*E);let L=(x-T/6*(1+2*u+w)+b/120*(5-2*w+28*u-3*E+8*Mi+24*f))/c;return L=jo(L+Fe(ec(e.number)),-Math.PI,Math.PI),[Al(L),Al(P)]}const $l=-80,Nl=84,Pu=-180,Iu=180;function Lu(s,t,e){s=jo(s,Pu,Iu),t<$l?t=$l:t>Nl&&(t=Nl);const i=Fe(t),n=Math.sin(i),r=Math.cos(i),o=n/r,a=o*o,l=a*a,h=Fe(s),c=ec(e.number),d=Fe(c),u=wr/Math.sqrt(1-Se*n**2),f=Mi*r**2,g=r*jo(h-d,-Math.PI,Math.PI),p=g*g,m=p*g,y=m*g,w=y*g,E=w*g,x=wr*(tc*i-wu*Math.sin(2*i)+xu*Math.sin(4*i)-Cu*Math.sin(6*i)),C=_r*u*(g+m/6*(1-a+f)+w/120*(5-18*a+l+72*f-58*Mi))+5e5;let T=_r*(x+u*o*(p/2+y/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Mi)));return e.north||(T+=1e7),[C,T]}function ec(s){return(s-1)*6-180+3}const Du=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function ic(s){let t=0;for(const n of Du){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 Gl(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 ku(s){return ic(s)?new ba({code:s,units:"m"}):null}function Ru(s){const t=ic(s.getCode());return t?{forward:Gl(Lu,t),inverse:Gl(Su,t)}:null}const Ia=63710088e-1;function Zo(s,t,e){e=e||Ia;const i=Fe(s[1]),n=Fe(t[1]),r=(n-i)/2,o=Fe(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 ao(s,t){let e=0;for(let i=0,n=s.length;i<n-1;++i)e+=Zo(s[i],s[i+1],t);return e}function nc(s,t){t=t||{};const e=t.radius||Ia,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,d;switch(n){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=s.getCoordinates(),r=ao(o,e);break}case"MultiLineString":case"Polygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)r+=ao(o[l],e);break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,d=a.length;c<d;++c)r+=ao(a[c],e);break}case"GeometryCollection":{const u=s.getGeometries();for(l=0,h=u.length;l<h;++l)r+=nc(u[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}function Us(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+=Fe(a-n)*(2+Math.sin(Fe(r))+Math.sin(Fe(l))),n=a,r=l}return e*t*t/2}function sc(s,t){t=t||{};const e=t.radius||Ia,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,d;switch(n){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=s.getCoordinates(),r=Math.abs(Us(o[0],e)),l=1,h=o.length;l<h;++l)r-=Math.abs(Us(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(Us(a[0],e)),c=1,d=a.length;c<d;++c)r-=Math.abs(Us(a[c],e));break}case"GeometryCollection":{const u=s.getGeometries();for(l=0,h=u.length;l<h;++l)r+=sc(u[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}const Au=[Ru],Mu=[ku];let Ko=!0;function rc(s){Ko=!1}function La(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 qo(s){_u(s.getCode(),s),ds(s,s,La)}function Fu(s){s.forEach(qo)}function Ft(s){if(typeof s!="string")return s;const t=yu(s);if(t)return t;for(const e of Mu){const i=e(s);if(i)return i}return null}function Bl(s,t,e,i){s=Ft(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=ka(s,Ft("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=Zo(h.slice(0,2),h.slice(2,4)),d=Zo(h.slice(4,6),h.slice(6,8));n=(c+d)/2}const l=s.getMetersPerUnit();l!==void 0&&(n/=l)}}return n}function Wl(s){Fu(s),s.forEach(function(t){s.forEach(function(e){t!==e&&ds(t,e,La)})})}function Ou(s,t,e,i){s.forEach(function(n){t.forEach(function(r){ds(n,r,e),ds(r,n,i)})})}function Da(s,t){return s?typeof s=="string"?Ft(s):s:Ft(t)}function zu(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 ut(s,t){return rc(),Br(s,"EPSG:4326","EPSG:3857")}function U(s,t){const e=Br(s,"EPSG:3857","EPSG:4326"),i=e[0];return(i<-180||i>180)&&(e[0]=Gi(i+180,360)-180),e}function os(s,t){if(s===t)return!0;const e=s.getUnits()===t.getUnits();return(s.getCode()===t.getCode()||ka(s,t)===La)&&e}function ka(s,t){const e=s.getCode(),i=t.getCode();let n=oo(e,i);if(n)return n;let r=null,o=null;for(const l of Au)r||(r=l(s)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)n=lo(r.inverse,o.forward);else{const l=oo(e,a);l&&(n=lo(l,o.forward))}else{const l=oo(a,i);l&&(n=lo(r.inverse,l))}return n&&(qo(s),qo(t),ds(s,t,n)),n}function lo(s,t){return function(e,i,n,r){return i=s(e,i,n,r),t(i,i,n,r)}}function us(s,t){const e=Ft(s),i=Ft(t);return ka(e,i)}function Br(s,t,e){const i=us(t,e);if(!i){const n=Ft(t).getCode(),r=Ft(e).getCode();throw new Error(`No transform available between ${n} and ${r}`)}return i(s,void 0,s.length)}function Jo(s,t){return s}function Re(s,t){return Ko&&!yr(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(Ko=!1,Xh("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function oc(s,t){return s}function Fi(s,t){return s}function $u(){Wl(Ml),Wl(Ol),Ou(Ol,Ml,fu,gu)}$u();const Nu=new Array(6);function Ut(){return[1,0,0,1,0,0]}function ac(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],d=t[3],u=t[4],f=t[5];return s[0]=e*l+n*h,s[1]=i*l+r*h,s[2]=e*c+n*d,s[3]=i*c+r*d,s[4]=e*u+n*f+o,s[5]=i*u+r*f+a,s}function Gu(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 lc(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 zt(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 Bu(s,t,e){return ac(s,Gu(Nu,1,0,0,1,t,e))}function Pe(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 Wr(s,t){const e=Wu(t);gt(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 Wu(s){return s[0]*s[3]-s[1]*s[2]}const Uu=[1e5,1e5,1e5,1e5,2,2];function Vu(s){return"matrix("+s.join(", ")+")"}function Qo(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function Hu(s,t){const e=Qo(s),i=Qo(t);for(let n=0;n<6;++n)if(Math.round((e[n]-i[n])*Uu[n])!==0)return!1;return!0}function Ye(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 d=2;d<o;d++)r[a++]=s[l+d]}return r&&r.length!=a&&(r.length=a),r}function Ra(s,t,e,i,n,r,o){o=o||[];const a=Math.cos(n),l=Math.sin(n),h=r[0],c=r[1];let d=0;for(let u=t;u<e;u+=i){const f=s[u]-h,g=s[u+1]-c;o[d++]=h+f*a-g*l,o[d++]=c+f*l+g*a;for(let p=u+2;p<u+i;++p)o[d++]=s[p]}return o&&o.length!=d&&(o.length=d),o}function Xu(s,t,e,i,n,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let d=t;d<e;d+=i){const u=s[d]-l,f=s[d+1]-h;a[c++]=l+n*u,a[c++]=h+r*f;for(let g=d+2;g<d+i;++g)a[c++]=s[g]}return a&&a.length!=c&&(a.length=c),a}function ju(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 Ul=Ut(),Yu=[NaN,NaN];class hc extends $e{constructor(){super(),this.extent_=oe(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Nh((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 Q()}closestPointXY(t,e,i,n){return Q()}containsXY(t,e){return this.closestPointXY(t,e,Yu,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 Q()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Ts(e),this.extentRevision_=this.getRevision()}return ru(this.extent_,t)}rotate(t,e){Q()}scale(t,e,i){Q()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return Q()}getType(){return Q()}applyTransform(t){Q()}intersectsExtent(t){return Q()}translate(t,e){Q()}transform(t,e){const i=Ft(t),n=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=he(h)/he(l);Pe(Ul,h[0],h[3],c,-c,0,0,0);const d=Ye(r,0,r.length,a,Ul,o),u=us(i,e);return u?u(d,d,a):d}:us(i,e);return this.applyTransform(n),this}}class Pi extends hc{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 Q()}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=xr(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){Q()}setLayout(t,e,i){let n;if(t)n=xr(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=Yi(n)}this.layout=t,this.stride=n}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();Ra(i,0,i.length,n,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=be(this.getExtent()));const n=this.getFlatCoordinates();if(n){const r=this.getStride();Xu(n,0,n.length,r,t,e,i,n),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();ju(i,0,i.length,n,t,e,i),this.changed()}}}function Yi(s){let t;return s==2?t="XY":s==3?t="XYZ":s==4&&(t="XYZM"),t}function xr(s){let t;return s=="XY"?t=2:s=="XYZ"||s=="XYM"?t=3:s=="XYZM"&&(t=4),t}function Zu(s,t,e){const i=s.getFlatCoordinates();if(!i)return null;const n=s.getStride();return Ye(i,0,i.length,n,t,e)}function Vl(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 d;if(h===0&&c===0)d=t;else{const u=((n-a)*h+(r-l)*c)/(h*h+c*c);if(u>1)d=e;else if(u>0){for(let f=0;f<i;++f)o[f]=ye(s[t+f],s[e+f],u);o.length=i;return}else d=t}for(let u=0;u<i;++u)o[u]=s[d+u];o.length=i}function Aa(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=li(r,o,a,l);h>n&&(n=h),r=a,o=l}return n}function Ma(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}return n}function Ku(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[a.length-1]}return n}function Fa(s,t,e,i,n,r,o,a,l,h,c){if(t==e)return h;let d,u;if(n===0){if(u=li(o,a,s[t],s[t+1]),u<h){for(d=0;d<i;++d)l[d]=s[t+d];return l.length=i,u}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(Vl(s,f-i,f,i,o,a,c),u=li(o,a,c[0],c[1]),u<h){for(h=u,d=0;d<i;++d)l[d]=c[d];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(u)-Math.sqrt(h))/n|0,1);if(r&&(Vl(s,e-i,t,i,o,a,c),u=li(o,a,c[0],c[1]),u<h)){for(h=u,d=0;d<i;++d)l[d]=c[d];l.length=i}return h}function Oa(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let d=0,u=e.length;d<u;++d){const f=e[d];h=Fa(s,t,f,i,n,r,o,a,l,h,c),t=f}return h}function qu(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let d=0,u=e.length;d<u;++d){const f=e[d];h=Oa(s,t,f,i,n,r,o,a,l,h,c),t=f[f.length-1]}return h}function cc(s,t,e,i){for(let n=0,r=e.length;n<r;++n)s[t++]=e[n];return t}function Ur(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 Is(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=Ur(s,t,e[o],i);n[r++]=l,t=l}return n.length=r,n}function dc(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=Is(s,t,e[o],i,n[r]);l.length===0&&(l[0]=t),n[r++]=l,t=l[l.length-1]}return n.length=r,n}function vi(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 fs(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++]=vi(s,t,l,i,n[r]),t=l}return n.length=r,n}function ta(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?[]:fs(s,t,l,i,n[r]),t=l[l.length-1]}return n.length=r,n}function Cr(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],d=s[t+1],u=0;const f=[0];for(let m=t+i;m<e;m+=i){const y=s[m],w=s[m+1];u+=Math.sqrt((y-c)*(y-c)+(w-d)*(w-d)),f.push(u),c=y,d=w}const g=n*u,p=Kd(f,g);p<0?(l=(g-f[-p-2])/(f[-p-1]-f[-p-2]),a=t+(-p-2)*i):a=t+p*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]:ye(s[a+c],s[a+i+c],l);return r}function ea(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 u=a+l>>1;n<s[(u+1)*i-1]?l=u:a=u+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],d=(n-h)/(c-h);o=[];for(let u=0;u<i-1;++u)o.push(ye(s[(a-1)*i+u],s[a*i+u],d));return o.push(n),o}function Ju(s,t,e,i,n,r,o){if(o)return ea(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 ea(s,t,c,i,n,!1);t=c}}return null}function Qu(s,t,e,i,n){return!Ea(n,function(o){return!Oi(s,t,e,i,o[0],o[1])})}function Oi(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 za(s,t,e,i,n,r){if(e.length===0||!Oi(s,t,e[0],i,n,r))return!1;for(let o=1,a=e.length;o<a;++o)if(Oi(s,e[o-1],e[o],i,n,r))return!1;return!0}function tf(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(za(s,t,l,i,n,r))return!0;t=l[l.length-1]}return!1}function uc(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 Vr(s,t,e,i,n,r){return r=r??Wh(oe(),s,t,e,i),le(n,r)?r[0]>=n[0]&&r[2]<=n[2]||r[1]>=n[1]&&r[3]<=n[3]?!0:uc(s,t,e,i,function(o,a){return ou(n,o,a)}):!1}function ef(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){if(Vr(s,t,e[r],i,n))return!0;t=e[r]}return!1}function fc(s,t,e,i,n){return!!(Vr(s,t,e,i,n)||Oi(s,t,e,i,n[0],n[1])||Oi(s,t,e,i,n[0],n[3])||Oi(s,t,e,i,n[2],n[1])||Oi(s,t,e,i,n[2],n[3]))}function gc(s,t,e,i,n){if(!fc(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(Qu(s,e[r-1],e[r],i,n)&&!Vr(s,e[r-1],e[r],i,n))return!1;return!0}function nf(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(gc(s,t,a,i,n))return!0;t=a[a.length-1]}return!1}function $a(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 Hr(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 d=h.pop(),u=h.pop();let f=0;const g=s[u],p=s[u+1],m=s[d],y=s[d+1];for(let w=u+i;w<d;w+=i){const E=s[w],x=s[w+1],C=au(E,x,g,p,m,y);C>f&&(c=w,f=C)}f>n&&(l[(c-t)/i]=1,u+i<c&&h.push(u,c),c+i<d&&h.push(c,d))}for(let d=0;d<a;++d)l[d]&&(r[o++]=s[t+d*i],r[o++]=s[t+d*i+1]);return o}function pc(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Hr(s,t,c,i,n,r,o),a.push(o),t=c}return o}function Ri(s,t){return t*Math.round(s/t)}function sf(s,t,e,i,n,r,o){if(t==e)return o;let a=Ri(s[t],n),l=Ri(s[t+1],n);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=Ri(s[t],n),c=Ri(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 d=Ri(s[t],n),u=Ri(s[t+1],n);if(t+=i,d==h&&u==c)continue;const f=h-a,g=c-l,p=d-a,m=u-l;if(f*m==g*p&&(f<0&&p<f||f==p||f>0&&p>f)&&(g<0&&m<g||g==m||g>0&&m>g)){h=d,c=u;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=d,c=u}return r[o++]=h,r[o++]=c,o}function Na(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=sf(s,t,c,i,n,r,o),a.push(o),t=c}return o}function rf(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l],d=[];o=Na(s,t,c,i,n,r,o,d),a.push(d),t=c[c.length-1]}return o}class pt extends Pi{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){je(this.flatCoordinates,t),this.changed()}clone(){const t=new pt(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Aa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Fa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,n))}forEachSegment(t){return uc(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,ea(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return vi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return Cr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return $a(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=Hr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new pt(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return Vr(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=Ur(this.flatCoordinates,0,t,this.stride),this.changed()}}function mc(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 yc(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=mc(s,t,a,i),t=a}return n}function of(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=yc(s,t,a,i),t=a[a.length-1]}return n}class gs extends Pi{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 gs(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Aa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Fa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,n))}getArea(){return mc(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return vi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=Hr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new gs(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ur(this.flatCoordinates,0,t,this.stride),this.changed()}}class rt extends Pi{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new rt(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,o=li(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 xa(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return wa(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=cc(this.flatCoordinates,0,t,this.stride),this.changed()}}function Ga(s,t,e,i,n,r,o){let a,l,h,c,d,u,f;const g=n[r+1],p=[];for(let w=0,E=e.length;w<E;++w){const x=e[w];for(c=s[x-i],u=s[x-i+1],a=t;a<x;a+=i)d=s[a],f=s[a+1],(g<=u&&f<=g||u<=g&&g<=f)&&(h=(g-u)/(f-u)*(d-c)+c,p.push(h)),c=d,u=f}let m=NaN,y=-1/0;for(p.sort(ai),c=p[0],a=1,l=p.length;a<l;++a){d=p[a];const w=Math.abs(d-c);w>y&&(h=(c+d)/2,za(s,t,e,i,h,g)&&(m=h,y=w)),c=d}return isNaN(m)&&(m=n[r]),o?(o.push(m,g,y),o):[m,g,y]}function _c(s,t,e,i,n){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Ga(s,t,l,i,n,2*o,r),t=l[l.length-1]}return r}function af(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 Ba(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 Wa(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=Ba(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 wc(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(!Wa(s,t,a,i,n))return!1;a.length&&(t=a[a.length-1])}return!0}function Er(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=Ba(s,t,a,i);(r===0?n&&l||!n&&!l:n&&!l||!n&&l)&&af(s,t,a,i),t=a}return t}function ia(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r)t=Er(s,t,e[r],i,n);return t}function xc(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=Ba(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 it extends Pi{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?je(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new it(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ma(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Oa(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return za(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return yc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Er(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,fs(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=be(this.getExtent());this.flatInteriorPoint_=Ga(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new rt(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new gs(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 gs(e.slice(r,l),t);n.push(h),r=l}return n}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Wa(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Er(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Na(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new it(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return gc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Is(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function gn(s){if(bs(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 it(r,"XY",[r.length])}const jt={ANIMATING:0,INTERACTING:1},Ui=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",lf=Ui.includes("safari")&&!Ui.includes("chrom"),hf=lf&&(Ui.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Ui)),cf=Ui.includes("webkit")&&!Ui.includes("edge"),Cc=Ui.includes("macintosh"),df=typeof devicePixelRatio<"u"?devicePixelRatio:1,Ee=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Ec=typeof Image<"u"&&Image.prototype.decode,vc=(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 $t(s,t,e,i){let n;return e&&e.length?n=e.shift():Ee?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 ho;function vr(){return ho||(ho=$t(1,1)),ho}function Xr(s){const t=s.canvas;t.width=1,t.height=1,s.clearRect(0,0,1,1)}function Hl(s,t){const e=t.parentNode;e&&e.replaceChild(s,t)}function uf(s){for(;s.lastChild;)s.lastChild.remove()}function ff(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 Tc(){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 Ti(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}const Yt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},at={IDLE:0,LOADING:1,LOADED:2,ERROR:3},Ua=[NaN,NaN,NaN,0];let co;function gf(){return co||(co=$t(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),co}const pf=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,mf=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,yf=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,_f=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Vs(s,t){return s.endsWith("%")?Number(s.substring(0,s.length-1))/t:Number(s)}function as(s){throw new Error('failed to parse "'+s+'" as color')}function bc(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(mf)||s.match(pf)||s.match(yf);if(r){const o=r[4],a=100/255;return[Pt(Vs(r[1],a)+.5|0,0,255),Pt(Vs(r[2],a)+.5|0,0,255),Pt(Vs(r[3],a)+.5|0,0,255),o!==void 0?Pt(Vs(o,100),0,1):1]}as(s)}if(s.startsWith("#")){if(_f.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}as(s)}const t=gf();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&&as(s));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return bc(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]=Ss(n[3]/255,3),n}function wf(s){return typeof s=="string"?s:Ha(s)}const xf=1024,Wn={};let uo=0;function Cf(s){if(s.length===4)return s;const t=s.slice();return t[3]=1,t}function fo(s){return s>.0031308?Math.pow(s,1/2.4)*269.025-14.025:s*3294.6}function go(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function po(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function mo(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Xl(s){const t=po(s[0]),e=po(s[1]),i=po(s[2]),n=mo(t*.222488403+e*.716873169+i*.06060791),r=500*(mo(t*.452247074+e*.399439023+i*.148375274)-n),o=200*(n-mo(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 Ef(s){const t=(s[0]+16)/116,e=s[1],i=s[2]*Math.PI/180,n=go(t),r=go(t+e/500*Math.cos(i)),o=go(t-e/200*Math.sin(i)),a=fo(r*3.021973625-n*1.617392459-o*.404875592),l=fo(r*-.943766287+n*1.916279586+o*.027607165),h=fo(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 Va(s){if(s==="none")return Ua;if(Wn.hasOwnProperty(s))return Wn[s];if(uo>=xf){let e=0;for(const i in Wn)(e++&3)===0&&(delete Wn[i],--uo)}const t=bc(s);t.length!==4&&as(s);for(const e of t)isNaN(e)&&as(s);return Wn[s]=t,++uo,t}function Ie(s){return Array.isArray(s)?s:Va(s)}function Ha(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 vf(s,t,e){const i=s;let n=!0,r=!1,o=!1;const a=[pr(i,nt.LOAD,function(){o=!0,r||t()})];return i.src&&Ec?(r=!0,i.decode().then(function(){n&&t()}).catch(function(l){n&&(o?t():e())})):a.push(pr(i,nt.ERROR,e)),function(){n=!1,a.forEach(Tt)}}function Tf(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 bf(s,t){return t&&(s.src=t),s.src&&Ec?new Promise((e,i)=>s.decode().then(()=>e(s)).catch(n=>s.complete&&s.width?e(s):i(n))):Tf(s)}class Sf{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=yo(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){const i=yo(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,n){const r=yo(t,e),o=r in this.cache_;this.cache_[r]=i,n&&(i.getImageState()===at.IDLE&&i.load(),i.getImageState()===at.LOADING?i.ready().then(()=>{this.patternCache_[r]=vr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[r]=vr().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function yo(s,t){const e=t?Ie(t):"null";return s+":"+e}const ve=new Sf;let Un=null;class Sc extends Fr{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?at.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_===at.LOADED){Un||(Un=$t(1,1,void 0,{willReadFrequently:!0})),Un.drawImage(this.image_,0,0);try{Un.getImageData(0,0,1,1),this.tainted_=!1}catch{Un=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(nt.CHANGE)}handleImageError_(){this.imageState_=at.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=at.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=$t(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_===at.IDLE){this.image_||this.initializeImage_(),this.imageState_=at.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&bf(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_!==at.LOADED)return;const e=this.image_,i=$t(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=wf(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_===at.LOADED||this.imageState_===at.ERROR)t();else{const e=()=>{(this.imageState_===at.LOADED||this.imageState_===at.ERROR)&&(this.removeEventListener(nt.CHANGE,e),t())};this.addEventListener(nt.CHANGE,e)}})),this.ready_}}function ls(s,t,e,i,n,r){let o=t===void 0?void 0:ve.get(t,n);return o||(o=new Sc(s,s&&"src"in s?s.src||void 0:t,e,i,n),ve.set(t,n,o,r)),r&&o&&!ve.getPattern(t,n)&&ve.set(t,n,o,r),o}function Xe(s){return s?Array.isArray(s)?Ha(s):typeof s=="object"&&"src"in s?Pf(s):s:null}function Pf(s){if(!s.offset||!s.size)return ve.getPattern(s.src,s.color);const t=s.src+":"+s.offset,e=ve.getPattern(t,s.color);if(e)return e;const i=ve.get(s.src,null);if(i.getImageState()!==at.LOADED)return null;const n=$t(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]),ls(n.canvas,t,void 0,at.LOADED,s.color,!0),ve.getPattern(t,s.color)}class Pc{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 Hs="ol-hidden",jr="ol-unselectable",Xa="ol-control",jl="ol-collapsed",If=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"),Yl=["style","variant","weight","size","lineHeight","family"],na={normal:400,bold:700},sa=function(s){const t=s.match(If);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,n=Yl.length;i<n;++i){const r=t[i+1];r!==void 0&&(e[Yl[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in na&&(e.weight=na[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e},Ic="10px sans-serif",ue="#000",Pn="round",hi=[],ci=0,In="round",ps=10,Lf=0,Ze="#000",ms="center",Tr="middle",zi=[0,0,0,0],ys=1,hn=new $e;let Vn=null,Zl;const ra={},Df=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function kf(s,t,e){return`${s} ${t} 16px "${e}"`}const Rf=(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=sa(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const d=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),u=na[c.weight]||c.weight;return d===l&&c.style===a.style&&u==h})}async function n(){await e.ready;let r=!0;const o=hn.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)?(kn(ra),hn.set(h,100)):(c+=10,hn.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(n,100))}return async function(r){e||(e=Ee?self.fonts:document.fonts);const o=sa(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(Df.has(h))continue;const c=kf(o.style,o.weight,h);hn.get(c)===void 0&&(hn.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(n,100))}})(),Af=(function(){let s;return function(t){let e=ra[t];if(e==null){if(Ee){const i=sa(t),n=Lc(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);ra[t]=e}return e}})();function Lc(s,t){return Vn||(Vn=$t(1,1)),s!=Zl&&(Vn.font=s,Zl=Vn.font),Vn.measureText(t)}function Dc(s,t){return Lc(s,t).width}function Kl(s,t,e){if(t in e)return e[t];const i=t.split(`
|
|
2
|
-
`).reduce((n,r)=>Math.max(n,
|
|
3
|
-
`||h===c){r=Math.max(r,o),n.push(o),o=0,a+=l,l=0;continue}const u=t[h+1]||s.font,f=Dc(u,d);e.push(f),o+=f;const g=Af(u);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:n}}function Ff(s,t,e,i,n,r,o,a,l,h,c){s.save(),e!==1&&(s.globalAlpha===void 0?s.globalAlpha=d=>d.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 W={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},Xs=[W.FILL],bi=[W.STROKE],$i=[W.BEGIN_PATH],ql=[W.CLOSE_PATH];class Ls extends Pc{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],Tn(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],d=t[e+1];const u=this.tmpCoordinate_;let f=!0,g,p,m;for(g=e+n;g<i;g+=n)u[0]=t[g],u[1]=t[g+1],m=Vo(h,u),m!==p?(f&&(a[l++]=c,a[l++]=d,f=!1),a[l++]=u[0],a[l++]=u[1]):m===Xt.INTERSECTING?(a[l++]=u[0],a[l++]=u[1],f=!1):f=!0,c=u[0],d=u[1],p=m;return(r&&f||g===e+n)&&(a[l++]=c,a[l++]=d),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,d,u,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),u=[];const g=t.getEndss();f=0;for(let p=0,m=g.length;p<m;++p){const y=[];f=this.drawCustomCoordinates_(h,f,g[p],a,y),u.push(y)}this.instructions.push([W.CUSTOM,l,u,t,i,ta,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,u,t,n||i,ta,r]);break;case"Polygon":case"MultiLineString":d=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,d),this.instructions.push([W.CUSTOM,l,d,t,i,fs,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,d,t,n||i,fs,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([W.CUSTOM,l,c,t,i,vi,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,c,t,n||i,vi,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([W.CUSTOM,l,c,t,i,vi,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,c,t,n||i,vi,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([W.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,c,t,n||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[W.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[W.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==W.END_GEOMETRY?o=e:r==W.BEGIN_GEOMETRY&&(n[2]=e,Jd(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=Xe(i||ue)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=Xe(i||Ze);const n=t.getLineCap();e.lineCap=n!==void 0?n:Pn;const r=t.getLineDash();e.lineDash=r?r.slice():hi;const o=t.getLineDashOffset();e.lineDashOffset=o||ci;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:In;const l=t.getWidth();e.lineWidth=l!==void 0?l:ys;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:ps;const c=t.getOffset();e.strokeOffset=c??Lf,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=[W.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[W.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&&!ui(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=[W.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Bh(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;An(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class zf extends Ls{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&&!Tn(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([W.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([W.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||Tn(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([W.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([W.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 $f extends Ls{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([W.MOVE_TO_LINE_TO,o,a,r*this.pixelRatio]),this.hitDetectionInstructions.push([W.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([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci],$i);const l=t.getFlatCoordinates(),h=t.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push(bi),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([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci],$i);const l=t.getEnds(),h=t.getFlatCoordinates(),c=t.getStride();let d=0;for(let u=0,f=l.length;u<f;++u)d=this.drawFlatCoordinates_(h,d,l[u],c,a);this.hitDetectionInstructions.push(bi),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(bi),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(bi),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push($i)}}class Jl extends Ls{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($i),this.hitDetectionInstructions.push($i);for(let c=0;c<h;++c){const d=i[c],u=this.coordinates.length,f=this.appendFlatLineCoordinates(t,e,d,n,!0,!l);this.instructions.push([W.MOVE_TO_LINE_TO,u,f,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([W.MOVE_TO_LINE_TO,u,f,r,!0]),l&&(this.instructions.push(ql),this.hitDetectionInstructions.push(ql)),e=d}return a&&(this.instructions.push(Xs),this.hitDetectionInstructions.push(Xs)),l&&(this.instructions.push(bi),this.hitDetectionInstructions.push(bi)),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([W.SET_FILL_STYLE,ue]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci]);const l=t.getFlatCoordinates(),h=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);const d=[W.CIRCLE,c,a];this.instructions.push($i,d),this.hitDetectionInstructions.push($i,d),n.fillStyle!==void 0&&(this.instructions.push(Xs),this.hitDetectionInstructions.push(Xs)),n.strokeStyle!==void 0&&(this.instructions.push(bi),this.hitDetectionInstructions.push(bi)),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([W.SET_FILL_STYLE,ue]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci]);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([W.SET_FILL_STYLE,ue]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci]);const l=t.getEndss(),h=t.getOrientedFlatCoordinates(),c=t.getStride();let d=0;for(let u=0,f=l.length;u<f;++u)d=this.drawFlatCoordinatess_(h,d,l[u],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]=Ri(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 Nf(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),d=t[o+n],u=t[o+n+1],f=Math.sqrt((d-h)*(d-h)+(u-c)*(u-c));if(a+=f,a>=s){const g=(s-a+f)/f,p=ye(h,d,g),m=ye(c,u,g);l.push(p,m),r.push(l),l=[p,m],a==s&&(o+=n),a=0}else if(a<s)l.push(t[o+n],t[o+n+1]),o+=n;else{const g=f-a,p=ye(h,d,g/f),m=ye(c,u,g/f);l.push(p,m),r.push(l),l=[p,m],a=0,o+=n}}return a>0&&r.push(l),r}function Gf(s,t,e,i,n){let r=e,o=e,a=0,l=0,h=e,c,d,u,f,g,p,m,y,w,E;for(d=e;d<i;d+=n){const x=t[d],C=t[d+1];g!==void 0&&(w=x-g,E=C-p,f=Math.sqrt(w*w+E*E),m!==void 0&&(l+=u,c=Math.acos((m*w+y*E)/(u*f)),c>s&&(l>a&&(a=l,r=h,o=d),l=0,h=d-n)),u=f,m=w,y=E),g=x,p=C}return l+=f,l>a?[h,d]:[r,o]}const br={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Bf extends Ls{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[ue]={fillStyle:ue},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,d=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!le(this.maxExtent,t.getExtent()))return;let u;if(c=t.getFlatCoordinates(),h=="LineString")u=[c.length];else if(h=="MultiLineString")u=t.getEnds();else if(h=="Polygon")u=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const m=t.getEndss();u=[];for(let y=0,w=m.length;y<w;++y)u.push(m[y][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let p=0;for(let m=0,y=u.length;m<y;++m){let w;f?w=Nf(f*this.resolution,c,p,u[m],d):w=[c.slice(p,u[m])];for(let E=0,x=w.length;E<x;++E){const C=w[E];let T=0,_=C.length;if(g==null){const S=Gf(o.maxAngle,C,0,C.length,2);T=S[0],_=S[1]}for(let S=T;S<_;S+=d)a.push(C[S],C[S+1]);const b=a.length;p=u[m],this.drawChars_(l,b),l=b}}this.endGeometry(e)}else{let u=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(),d=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||u.push(c[2]/this.resolution),d=3;break;case"MultiPolygon":const x=t.getFlatInteriorPoints();c=[];for(let C=0,T=x.length;C<T;C+=3)o.overflow||u.push(x[C+2]/this.resolution),c.push(x[C],x[C+1]);if(c.length===0)return;d=2;break}const f=this.appendFlatPointCoordinates(c,d);if(f===l)return;if(u&&(f-l)/2!==c.length/d){let x=l/2;u=u.filter((C,T)=>{const _=a[(x+T)*2]===c[T*d]&&a[(x+T)*2+1]===c[T*d+1];return _||--x,_})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,p=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let m=o.padding;if(m!=zi&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],C=o.padding[1],T=o.padding[2],_=o.padding[3];o.scale[0]<0&&(C=-C,_=-_),o.scale[1]<0&&(x=-x,T=-T),m=[x,C,T,_]}const y=this.pixelRatio;this.instructions.push([W.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,m==zi?zi:m.map(function(x){return x*y}),g,p,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,u]);const w=1/y,E=g?g.slice(0):null;E&&(E[1]=ue),this.hitDetectionInstructions.push([W.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[w,w],NaN,this.declutterMode_,this.declutterImageWithText_,m,E,p,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ue:this.fillKey_,this.textOffsetX_,this.textOffsetY_,u]),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||ms,justify:e.justify,textBaseline:e.textBaseline||Tr,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=br[n.textBaseline],c=this.textOffsetY_*l,d=this.text_,u=i?i.lineWidth*Math.abs(n.scale[0])/2:0;this.instructions.push([W.DRAW_CHARS,t,e,h,n.overflow,a,n.maxAngle,l,c,r,u*l,d,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([W.DRAW_CHARS,t,e,h,n.overflow,a&&ue,n.maxAngle,l,c,r,u*l,d,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,n,r;if(!t)this.text_="";else{const o=t.getFill();o?(n=this.textFillState_,n||(n={},this.textFillState_=n),n.fillStyle=Xe(o.getColor()||ue)):(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 p=a.getLineDash(),m=a.getLineDashOffset(),y=a.getWidth(),w=a.getMiterLimit();r.lineCap=a.getLineCap()||Pn,r.lineDash=p?p.slice():hi,r.lineDashOffset=m===void 0?ci:m,r.lineJoin=a.getLineJoin()||In,r.lineWidth=y===void 0?ys:y,r.miterLimit=w===void 0?ps:w,r.strokeStyle=Xe(a.getColor()||Ze)}i=this.textState_;const l=t.getFont()||Ic;Rf(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()||Tr,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||zi,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),d=t.getOffsetY(),u=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=d===void 0?0:d,this.textRotateWithView_=u===void 0?!1:u,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:K(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=n&&n.fillStyle?typeof n.fillStyle=="string"?n.fillStyle:"|"+K(n.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const Wf={Circle:Jl,Default:Ls,Image:zf,LineString:$f,Polygon:Jl,Text:Bf};class Uf{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=Wf[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),n[e]=r}return r}}function kc(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],d=s[e-2*i+1];let u,f,g,p,m,y,w,E,x=0;for(let C=t;C<e;C+=i){g=u,p=f,m=void 0,y=void 0,C+i<e&&(m=s[C+i],y=s[C+i+1]),r&&C===t&&(g=c,p=d),r&&C===e-i&&(m=l,y=h),u=s[C],f=s[C+1],[w,E]=Vf(u,f,g,p,m,y,n),o[x++]=w,o[x++]=E;for(let T=2;T<a;T++)o[x++]=s[C+T]}return o.length!=x&&(o.length=x),o}function Vf(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,d=l/h;if(a=-d,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 u=cu([s,t],[e,i],[n,r]);if(Math.cos(u)>.998)return[s+c*o,t+d*o];const f=Math.cos(u/2),g=Math.sin(u/2),p=g*a+f*l,m=-f*a+g*l,y=p*(1/g),w=m*(1/g);return[s+y*o,t+w*o]}function Rc(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],d=s[n+t],u=s[n+t+1],f=(u-c)*(a-r)-(d-h)*(l-o);if(f===0)continue;const g=((d-h)*(o-c)-(u-c)*(r-h))/f,p=((a-r)*(o-c)-(l-o)*(r-h))/f;if(g>0&&g<1&&p>0&&p<1){const m=r+g*(a-r),y=o+g*(l-o);s[e+t]=m,s[e+t+1]=y,s.splice(e+2*t,n-e-t);break}}return s}function Hf(s,t,e,i,n,r,o,a,l,h,c,d,u=!0){let f=s[t],g=s[t+1],p=0,m=0,y=0,w=0;function E(){p=f,m=g,t+=i,f=s[t],g=s[t+1],w+=y,y=Math.sqrt((f-p)*(f-p)+(g-m)*(g-m))}do E();while(t<e-i&&w+y<r);let x=y===0?0:(r-w)/y;const C=ye(p,f,x),T=ye(m,g,x),_=t-i,b=w,S=r+a*l(h,n,c);for(;t<e-i&&w+y<S;)E();x=y===0?0:(S-w)/y;const P=ye(p,f,x),L=ye(m,g,x);let k=!1;if(u)if(d){const D=[C,T,P,L];Ra(D,0,4,2,d,D,D),k=D[0]>D[2]}else k=C>P;const F=Math.PI,O=[],R=_+i===t;t=_,y=0,w=b,f=s[t],g=s[t+1];let B;if(R){E(),B=Math.atan2(g-m,f-p),k&&(B+=B>0?-F:F);const D=(P+C)/2,z=(L+T)/2;return O[0]=[D,z,(S-r)/2,B,n],O}n=n.replace(/\n/g," ");for(let D=0,z=n.length;D<z;){E();let N=Math.atan2(g-m,f-p);if(k&&(N+=N>0?-F:F),B!==void 0){let xt=N-B;if(xt+=xt>F?-2*F:xt<-F?2*F:0,Math.abs(xt)>o)return null}B=N;const tt=D;let et=0;for(;D<z;++D){const xt=k?z-D-1:D,yt=a*l(h,n[xt],c);if(t+i<e&&w+y<r+et+yt/2)break;et+=yt}if(D===tt)continue;const ht=k?n.substring(z-tt,z-D):n.substring(tt,D);x=y===0?0:(r+et/2-w)/y;const ot=ye(p,f,x),I=ye(m,g,x);O.push([ot,I,et/2,N,ht]),r+=et}return O}class Ac{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(vr(),{get:(t,e)=>{if(typeof vr()[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 Qi=oe(),pi=[],ei=[],ii=[],mi=[];function Ql(s){return s[3].declutterBox}const th=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function _o(s,t){return t==="start"?t=th.test(s)?"right":"left":t==="end"&&(t=th.test(s)?"left":"right"),br[t]}function Xf(s,t,e){return e>0&&s.push(`
|
|
4
|
-
`,""),s.push(t,""),s}function
|
|
5
|
-
`).reduce(
|
|
6
|
-
`){F+=k,k=0,S=d*E+b*u,++R;continue}const tt=f[D+1]||l.font;tt!==B&&(n&&P.push("font",tt),i&&L.push("font",tt),B=tt),k=Math.max(k,y[O]);const et=[N,S+b*m[O]+d*(m[O]-w[R]),.5*(u+k)+F];S+=m[O],n&&P.push("strokeText",et),i&&L.push("fillText",et),++O}return Array.prototype.push.apply(x,P),Array.prototype.push.apply(x,L),this.labels_[r]=_,_}replayTextBackground_(t,e,i,n,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,n),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,n,r,o,a,l,h,c,d,u,f,g,p,m){a*=u[0],l*=u[1];let y=i-a,w=n-l;const E=r+h>t?t-h:r,x=o+c>e?e-c:o,C=g[3]+E*u[0]+g[1],T=g[0]+x*u[1]+g[2],_=y-g[3],b=w-g[0];(p||d!==0)&&(pi[0]=_,mi[0]=_,pi[1]=b,ei[1]=b,ei[0]=_+C,ii[0]=ei[0],ii[1]=b+T,mi[1]=ii[1]);let S;return d!==0?(S=Pe(Ut(),i,n,1,1,d,-i,-n),zt(S,pi),zt(S,ei),zt(S,ii),zt(S,mi),di(Math.min(pi[0],ei[0],ii[0],mi[0]),Math.min(pi[1],ei[1],ii[1],mi[1]),Math.max(pi[0],ei[0],ii[0],mi[0]),Math.max(pi[1],ei[1],ii[1],mi[1]),Qi)):di(Math.min(_,_+C),Math.min(b,b+T),Math.max(_,_+C),Math.max(b,b+T),Qi),f&&(y=Math.round(y),w=Math.round(w)),{drawImageX:y,drawImageY:w,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:Qi[0],minY:Qi[1],maxX:Qi[2],maxY:Qi[3],value:m},canvasTransform:S,scale:u}}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,pi,ei,ii,mi,o,a),Ff(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=zt(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=_o(Array.isArray(t)?t[0]:t,r.textAlign||ms),c=br[r.textBaseline||Tr],d=a&&a.lineWidth?a.lineWidth:0,u=o.width/l-2*r.scale[0],f=h*u+2*(.5-h)*d,g=c*o.height/l+2*(.5-c)*d;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,n,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&ui(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Ye(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),lc(this.renderedTransform_,i));let d=0;const u=n.length;let f=0,g;const p=[];let m,y,w,E,x,C,T,_,b,S,P,L,k,F=0,O=0;const R=this.coordinateCache_,B=this.viewRotation_,D=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,z={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:B},N=this.instructions!=n||this.overlaps?0:200;let tt,et,ht,ot;for(;d<u;){const I=n[d];switch(I[0]){case W.BEGIN_GEOMETRY:tt=I[1],ot=I[3],tt.getGeometry()?a!==void 0&&!le(a,ot.getExtent())?d=I[2]+1:++d:d=I[2],h&&(h.zIndex=I[4]);break;case W.BEGIN_PATH:F>N&&(this.fill_(t),F=0),O>N&&(t.stroke(),O=0),!F&&!O&&(t.beginPath(),x=NaN,C=NaN),++d;break;case W.CIRCLE:f=I[1],w=I[2]??0;const yt=c[f],Ot=c[f+1],ie=c[f+2]-w,Ne=c[f+3]-w,St=ie-yt,vt=Ne-Ot,Dt=Math.sqrt(St*St+vt*vt);t.moveTo(yt+Dt,Ot),t.arc(yt,Ot,Dt,0,2*Math.PI,!0),++d;break;case W.CLOSE_PATH:t.closePath(),++d;break;case W.CUSTOM:f=I[1],g=I[2];const Kt=I[3],kt=I[4],Ht=I[5];z.geometry=Kt,z.feature=tt,d in R||(R[d]=[]);const de=R[d];Ht?Ht(c,f,g,2,de):(de[0]=c[f],de[1]=c[f+1],de.length=2),h&&(h.zIndex=I[6]),kt(de,z),++d;break;case W.DRAW_IMAGE:f=I[1],g=I[2],b=I[3],m=I[4],y=I[5];let gi=I[6];const Ms=I[7],On=I[8],qi=I[9],Fs=I[10];let ne=I[11];const Vd=I[12];let Os=I[13];E=I[14]||"declutter";const zn=I[15];if(!b&&I.length>=20){S=I[19],P=I[20],L=I[21],k=I[22];const Nt=this.drawLabelWithPointPlacement_(S,P,L,k);b=Nt.label,I[3]=b;const Li=I[23];m=(Nt.anchorX-Li)*this.pixelRatio,I[4]=m;const we=I[24];y=(Nt.anchorY-we)*this.pixelRatio,I[5]=y,gi=b.height,I[6]=gi,Os=b.width,I[13]=Os}let eo;I.length>25&&(eo=I[25]);let io,zs,$s;I.length>17?(io=I[16],zs=I[17],$s=I[18]):(io=zi,zs=null,$s=null),Fs&&D?ne+=B:!Fs&&!D&&(ne-=B);let Hd=0;for(;f<g;f+=2){if(eo&&eo[Hd++]<Os/this.pixelRatio)continue;const Nt=this.calculateImageOrLabelDimensions_(b.width,b.height,c[f],c[f+1],Os,gi,m,y,On,qi,ne,Vd,r,io,!!zs||!!$s,tt),Li=[t,e,b,Nt,Ms,zs,$s];if(l){let we,Ge,xe;if(zn){const At=g-f;if(!zn[At]){zn[At]={args:Li,declutterMode:E};continue}const ae=zn[At];we=ae.args,Ge=ae.declutterMode,delete zn[At],xe=Ql(we)}let Je,Qe;if(we&&(Ge!=="declutter"||!l.collides(xe))&&(Je=!0),(E!=="declutter"||!l.collides(Nt.declutterBox))&&(Qe=!0),Ge==="declutter"&&E==="declutter"){const At=Je&&Qe;Je=At,Qe=At}Je&&(Ge!=="none"&&l.insert(xe),this.replayImageOrLabel_.apply(this,we)),Qe&&(E!=="none"&&l.insert(Nt.declutterBox),this.replayImageOrLabel_.apply(this,Li))}else this.replayImageOrLabel_.apply(this,Li)}++d;break;case W.DRAW_CHARS:const bl=I[1],Sl=I[2],no=I[3],Xd=I[4];k=I[5];const jd=I[6],Pl=I[7],Il=I[8];L=I[9];const so=I[10];S=I[11],Array.isArray(S)&&(S=S.reduce(jf,"")),P=I[12];const Ll=[I[13],I[13]];E=I[14]||"declutter";const Yd=I[15],ro=this.textStates[P],$n=ro.font,Nn=[ro.scale[0]*Pl,ro.scale[1]*Pl];let Gn;$n in this.widths_?Gn=this.widths_[$n]:(Gn={},this.widths_[$n]=Gn);const Dl=$a(c,bl,Sl,2),kl=Math.abs(Nn[0])*Kl($n,S,Gn);if(Xd||kl<=Dl){const Nt=this.textStates[P].textAlign,Li=(Dl-kl)*_o(S,Nt),we=Hf(c,bl,Sl,2,S,Li,jd,Math.abs(Nn[0]),Kl,$n,Gn,D?0:this.viewRotation_,Yd);t:if(we){const Ge=[];let xe,Je,Qe,At,ae;if(L)for(xe=0,Je=we.length;xe<Je;++xe){ae=we[xe],Qe=ae[4],At=this.createLabel(Qe,P,"",L),m=ae[2]+(Nn[0]<0?-so:so),y=no*At.height+(.5-no)*2*so*Nn[1]/Nn[0]-Il;const ti=this.calculateImageOrLabelDimensions_(At.width,At.height,ae[0],ae[1],At.width,At.height,m,y,0,0,ae[3],Ll,!1,zi,!1,tt);if(l&&E==="declutter"&&l.collides(ti.declutterBox))break t;Ge.push([t,e,At,ti,1,null,null])}if(k)for(xe=0,Je=we.length;xe<Je;++xe){ae=we[xe],Qe=ae[4],At=this.createLabel(Qe,P,k,""),m=ae[2],y=no*At.height-Il;const ti=this.calculateImageOrLabelDimensions_(At.width,At.height,ae[0],ae[1],At.width,At.height,m,y,0,0,ae[3],Ll,!1,zi,!1,tt);if(l&&E==="declutter"&&l.collides(ti.declutterBox))break t;Ge.push([t,e,At,ti,1,null,null])}l&&E!=="none"&&l.load(Ge.map(Ql));for(let ti=0,Zd=Ge.length;ti<Zd;++ti)this.replayImageOrLabel_.apply(this,Ge[ti])}}++d;break;case W.END_GEOMETRY:if(o!==void 0){tt=I[1];const Nt=o(tt,ot,E);if(Nt)return Nt}++d;break;case W.FILL:N?F++:this.fill_(t),++d;break;case W.MOVE_TO_LINE_TO:f=I[1],g=I[2],w=I[3];let Ii,Bn,Ns;if(w){const Nt=I[4]??!1;kc(c,f,g,2,w,Nt,p),Rc(p,2),Ii=p,Bn=0,Ns=Ii.length}else Ii=c,Bn=f,Ns=g;et=Ii[Bn],ht=Ii[Bn+1],t.moveTo(et,ht),x=et+.5|0,C=ht+.5|0;for(let Nt=Bn+2;Nt<Ns;Nt+=2)et=Ii[Nt],ht=Ii[Nt+1],T=et+.5|0,_=ht+.5|0,(Nt==Ns-2||T!==x||_!==C)&&(t.lineTo(et,ht),x=T,C=_);++d;break;case W.SET_FILL_STYLE:this.alignAndScaleFill_=I[2],F?(this.fill_(t),F=0,O&&(t.stroke(),O=0)):O&&I[1]&&(t.stroke(),O=0),t.fillStyle=I[1],++d;break;case W.SET_STROKE_STYLE:F&&I[1]&&(this.fill_(t),F=0),O&&(t.stroke(),O=0),this.setStrokeStyle_(t,I),++d;break;case W.STROKE:N?O++:t.stroke(),++d;break;default:++d;break}}F&&this.fill_(t),O&&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 Ai=["Polygon","Circle","LineString","Image","Text","Default"],Mc=["Image","Text"],Zf=Ai.filter(s=>!Mc.includes(s));let Fc=!1,Oc=!1;function Kf(){let s=0;const t=i=>{const n=$t(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};Fc={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[s],Oc=!0}class qf{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_=Ut(),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 Yf(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){Oc===!1&&Kf(),n=Math.round(n);const a=n*2+1,l=Pe(this.hitDetectionTransform_,n+.5,n+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=$t(a,a,null,{willReadFrequently:Fc}));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 d;this.renderBuffer_!==void 0&&(d=oe(),rs(d,t),An(d,e*(this.renderBuffer_+n),d));const u=Jf(n);let f;function g(C,T,_){const b=c.getImageData(0,0,a,a).data;for(let S=0,P=u.length;S<P;S++)if(b[u[S]]>0){if(!o||_==="none"||f!=="Image"&&f!=="Text"||o.includes(C)){const L=(u[S]-3)/4,k=n-L%a,F=n-(L/a|0),O=r(C,T,k*k+F*F);if(O)return O}c.clearRect(0,0,a,a);break}}const p=Object.keys(this.executorsByZIndex_).map(Number);p.sort(ai);let m,y,w,E,x;for(m=p.length-1;m>=0;--m){const C=p[m].toString();for(w=this.executorsByZIndex_[C],y=Ai.length-1;y>=0;--y)if(f=Ai[y],E=w[f],E!==void 0&&(x=E.executeHitDetection(c,l,i,g,d),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 Ye(a,0,8,2,t,a),a}isEmpty(){return Wi(this.executorsByZIndex_)}execute(t,e,i,n,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?qd:ai),o=o||Ai;const h=Ai.length;for(let c=0,d=l.length;c<d;++c){const u=l[c].toString(),f=this.executorsByZIndex_[u];for(let g=0,p=o.length;g<p;++g){const m=o[g],y=f[m];if(y!==void 0){const w=a===null?void 0:y.getZIndexContext(),E=w?w.getContext():t,x=this.maxExtent_&&m!=="Image"&&m!=="Text";if(x&&(E.save(),this.clip(E,i)),!w||m==="Text"||m==="Image"?y.execute(E,e,i,n,r,a):w.pushFunction(C=>y.execute(C,e,i,n,r,a)),x&&E.restore(),w){w.offset();const C=l[c]*h+Ai.indexOf(m);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].push(w)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ai);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 wo={};function Jf(s){if(wo[s]!==void 0)return wo[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 wo[s]=n,n}function eh(s){return s[0]>0&&s[1]>0}function Qf(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 ce(s,t){return Array.isArray(s)?s:(t===void 0?t=[s,s]:(t[0]=s,t[1]=s),t)}class Yr{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=ce(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Yr({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 Q()}getImage(t){return Q()}getHitDetectionImage(){return Q()}getPixelRatio(t){return 1}getImageState(){return Q()}getImageSize(){return Q()}getOrigin(){return Q()}getSize(){return Q()}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_=ce(t)}listenImageChange(t){Q()}load(){Q()}unlistenImageChange(t){Q()}ready(){return Promise.resolve()}}function ih(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 Vi extends Yr{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;gt(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||K(o)),gt(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),gt(!((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=at.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?at.LOADED:at.IDLE:l=at.LOADING:l=at.LOADED),this.color_=t.color!==void 0?Ie(t.color):null,this.iconImage_=ls(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 d=this.getImage(1);if(d.width&&d.height)h=d.width,c=d.height;else if(d instanceof HTMLImageElement){this.initialOptions_=t;const u=()=>{if(this.unlistenImageChange(u),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(ih(f[0],f[1],t.width,t.height))};this.listenImageChange(u);return}}h!==void 0&&this.setScale(ih(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 Vi({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?Ie(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?at.IDLE:this.iconImage_.getImageState();this.iconImage_=ls(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_=ls(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},at.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()==at.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()==at.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(nt.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(nt.CHANGE,t)}ready(){return this.iconImage_.ready()}}class tg extends Pc{constructor(t,e,i,n,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?Ss(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_=Ut()}drawImages_(t,e,i,n){if(!this.image_)return;const r=Ye(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,d=r.length;c<d;c+=2){const u=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=u+this.imageAnchorX_,p=f+this.imageAnchorY_;Pe(a,g,p,1,1,h,-g,-p),o.save(),o.transform.apply(o,a),o.translate(g,p),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_,u,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=Ye(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=Ye(t,e,i,n,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(l=kc(l,0,l.length,2,o,r,l),Rc(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_)),!!le(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=Zu(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_)),!!le(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(le(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_)),!!le(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_)),!!le(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),ui(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:ms;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=n&&(i.textAlign=n,e.textAlign=n),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=n,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:n,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:Xe(i||ue)}}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||hi,d=e.getOffset();this.strokeState_={lineCap:n!==void 0?n:Pn,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||ci)*this.pixelRatio_,lineJoin:a!==void 0?a:In,lineWidth:(l!==void 0?l:ys)*this.pixelRatio_,miterLimit:h!==void 0?h:ps,strokeStyle:Xe(i||Ze),strokeOffset:(d??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:Xe(f||ue)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),p=i.getLineDash(),m=i.getLineDashOffset(),y=i.getLineJoin(),w=i.getWidth(),E=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Pn,lineDash:p||hi,lineDashOffset:m||ci,lineJoin:y!==void 0?y:In,lineWidth:w!==void 0?w:ys,miterLimit:E!==void 0?E:ps,strokeStyle:Xe(f||Ze)}}const n=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),d=t.getTextAlign(),u=t.getTextBaseline();this.textState_={font:n!==void 0?n:Ic,textAlign:d!==void 0?d:ms,textBaseline:u!==void 0?u:Tr},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,p)=>f+=p%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 Ve=.5;function eg(s,t,e,i,n,r,o,a,l){const h=n,c=s[0]*Ve,d=s[1]*Ve,u=$t(c,d);u.imageSmoothingEnabled=!1;const f=u.canvas,g=new tg(u,Ve,n,null,o,a,null),p=e.length,m=Math.floor((256*256*256-1)/p),y={};for(let E=1;E<=p;++E){const x=e[E-1],C=x.getStyleFunction()||i;if(!C)continue;let T=C(x,r);if(!T)continue;Array.isArray(T)||(T=[T]);const b=(E*m).toString(16).padStart(7,"#00000");for(let S=0,P=T.length;S<P;++S){const L=T[S],k=L.getGeometryFunction()(x);if(!k||!le(h,k.getExtent()))continue;const F=L.clone(),O=F.getFill();O&&O.setColor(b);const R=F.getStroke();R&&(R.setColor(b),R.setLineDash(null)),F.setText(void 0);const B=L.getImage();if(B){const tt=B.getImageSize();if(!tt)continue;const et=$t(tt[0],tt[1],void 0,{alpha:!1}),ht=et.canvas;et.fillStyle=b,et.fillRect(0,0,ht.width,ht.height),F.setImage(new Vi({img:ht,anchor:B.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:B.getOrigin(),opacity:1,size:B.getSize(),scale:B.getScale(),rotation:B.getRotation(),rotateWithView:B.getRotateWithView()}))}const D=F.getZIndex()||0;let z=y[D];z||(z={},y[D]=z,z.Polygon=[],z.Circle=[],z.LineString=[],z.Point=[]);const N=k.getType();if(N==="GeometryCollection"){const tt=k.getGeometriesArrayRecursive();for(let et=0,ht=tt.length;et<ht;++et){const ot=tt[et];z[ot.getType().replace("Multi","")].push(ot,F)}}else z[N.replace("Multi","")].push(k,F)}}const w=Object.keys(y).map(Number).sort(ai);for(let E=0,x=w.length;E<x;++E){const C=y[w[E]];for(const T in C){const _=C[T];for(let b=0,S=_.length;b<S;b+=2){g.setStyle(_[b+1]);for(let P=0,L=t.length;P<L;++P)g.setTransform(t[P]),g.drawGeometry(_[b])}}}return u.getImageData(0,0,f.width,f.height)}function ig(s,t,e){const i=[];if(e){const n=Math.floor(Math.round(s[0])*Ve),r=Math.floor(Math.round(s[1])*Ve),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),d=Math.floor((256*256*256-1)/t.length);c&&c%d===0&&i.push(t[c/d-1])}return i}const ng=.5,zc={Point:dg,LineString:lg,Polygon:fg,MultiPoint:ug,MultiLineString:hg,MultiPolygon:cg,GeometryCollection:ag,Circle:rg};function sg(s,t){return parseInt(K(s),10)-parseInt(K(t),10)}function nh(s,t){const e=$c(s,t);return e*e}function $c(s,t){return ng*s/t}function rg(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 sh(s,t,e,i,n,r,o,a){const l=[],h=e.getImage();if(h){let u=!0;const f=h.getImageState();f==at.LOADED||f==at.ERROR?u=!1:f==at.IDLE&&h.load(),u&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const d=l.length>0;return d&&Promise.all(l).then(()=>n(null)),og(s,t,e,i,r,o,a),d}function og(s,t,e,i,n,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,n);if(e.getRenderer())Nc(s,l,e,t,o);else{const c=zc[l.getType()];c(s,l,e,t,o,r)}}function Nc(s,t,e,i,n){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)Nc(s,o[a],e,i,n);return}s.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),n)}function ag(s,t,e,i,n,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=zc[o[a].getType()];h(s,o[a],e,i,n,r)}}function lg(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 hg(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 cg(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 dg(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()!=at.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 ug(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()!=at.LOADED)return;const d=s.getBuilder(e.getZIndex(),"Image");d.setImageStyle(o,c),d.drawMultiPoint(t,i,n)}if(h){const d=s.getBuilder(e.getZIndex(),"Text");d.setTextStyle(l,c),d.drawText(t,i,n)}}function fg(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 hs extends qe{constructor(t,e,i,n){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=n}}const gg=5;class Gc extends vs{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=gg}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return Q()}getData(t){return null}prepareFrame(t){return Q()}renderFrame(t,e){return Q()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===at.LOADED||e.getState()===at.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=at.LOADED&&e!=at.ERROR&&t.addEventListener(nt.CHANGE,this.boundHandleImageChange_),e==at.IDLE&&(t.load(),e=t.getState()),e==at.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const rh=[];let cn=null;function pg(){cn=$t(1,1,void 0,{willReadFrequently:!0})}class Bc extends Gc{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Ut(),this.pixelTransform=Ut(),this.inversePixelTransform=Ut(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){cn||pg(),cn.clearRect(0,0,1,1);let n;try{cn.drawImage(t,e,i,1,1,0,0,1,1),n=cn.getImageData(0,0,1,1).data}catch{return cn=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&&ui(Ie(t.style.backgroundColor),Ie(i)))){const a=t.firstElementChild;Ti(a)&&(o=a.getContext("2d"))}if(o&&Hu(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=Ee?Tc():document.createElement("div"),r.className=n;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=$t();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=ji(i),r=$r(i),o=zr(i),a=Or(i);zt(e.coordinateToPixelTransform,n),zt(e.coordinateToPixelTransform,r),zt(e.coordinateToPixelTransform,o),zt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;zt(l,n),zt(l,r),zt(l,o),zt(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(Et(i)/n*o),l=Math.round(he(i)/n*o);Pe(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Wr(this.inversePixelTransform,this.pixelTransform);const h=Vu(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 hs(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Yt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Yt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Ac),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Yt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Yt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,n,r,o,a){const l=r/2,h=o/2,c=n/e,d=-c,u=-t[0]+a,f=-t[1];return Pe(this.tempTransform,l,h,c,d,-i,u,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class mg extends Bc{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_=oe(),this.wrappedRenderedExtent_=oe(),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(),d=this.getLayer().getSource(),u=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,p=!(g[jt.ANIMATING]||g[jt.INTERACTING]),m=this.context,y=Math.round(Et(n)/a*f),w=Math.round(he(n)/a*f),E=d.getWrapX()&&l.canWrapX(),x=E?Et(c):null,C=E?Math.ceil((n[2]-c[2])/x)+(this.extendX_?2:1):1;let T=E?Math.floor((n[0]-c[0])/x)-(this.extendX_?1:0):0;do{let _=this.getRenderTransform(o,a,0,f,y,w,T*x);e.declutter&&(_=_.slice(0)),t.execute(m,[m.canvas.width,m.canvas.height],_,h,p,i===void 0?Ai:i?Mc:Zf,i?u&&e.declutter[u]:void 0)}while(++T<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=$t(this.context.canvas.width,this.context.canvas.height,rh))}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,Xr(this.context),rh.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(Yt.PRERENDER)||this.getLayer().hasListener(Yt.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=Fi(i.extent);a=le(h,t.extent),a&&!Yn(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=[],d=i[0]*Ve,u=i[1]*Ve;c.push(this.getRenderTransform(n,r,o,Ve,d,u,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Yn(g,l)){let p=l[0];const m=Et(g);let y=0,w;for(;p<g[0];)--y,w=m*y,c.push(this.getRenderTransform(n,r,o,Ve,d,u,w).slice()),p+=m;for(y=0,p=l[2];p>g[2];)++y,w=m*y,c.push(this.getRenderTransform(n,r,o,Ve,d,u,w).slice()),p-=m}this.hitDetectionImageData_=eg(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,nh(r,this.renderedPixelRatio_))}e(ig(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(u,f,g){const p=K(u),m=h[p];if(m){if(m!==!0&&g<m.distanceSq){if(g===0)return h[p]=!0,r.splice(r.lastIndexOf(m),1),n(u,l,f);m.geometry=f,m.distanceSq=g}}else{if(g===0)return h[p]=!0,n(u,l,f);r.push(h[p]={feature:u,layer:l,geometry:f,distanceSq:g,callback:n})}},d=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,d?e.declutter?.[d]?.all().map(u=>u.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[jt.ANIMATING],r=t.viewHints[jt.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,d=h.resolution,u=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let p=e.getRenderOrder();p===void 0&&(p=sg);const m=h.center.slice(),y=An(l,g*d),w=y.slice(),E=[y.slice()],x=c.getExtent(),C=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,C){const R=i.getExtent();R&&!bs(R)&&(this.extendX_=R[0]<x[0]||R[2]>x[2])}if(C&&(!Yn(x,t.extent)||this.extendX_)){const R=Et(x),B=Math.max(Et(y)/2,R);let D=x[0],z=x[2];this.extendX_&&(D-=R,z+=R),y[0]=D-B,y[2]=z+B,qh(m,c);const N=Vh(E[0],c);N[0]<x[0]&&N[2]<x[2]?E.push([N[0]+R,N[1],N[2]+R,N[3]]):N[0]>x[0]&&N[2]>x[2]&&E.push([N[0]-R,N[1],N[2]-R,N[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===u&&this.renderedRevision_==f&&this.renderedRenderOrder_==p&&this.renderedFrameDeclutter_===!!t.declutter&&Yn(this.wrappedRenderedExtent_,y))return ui(this.renderedExtent_,w)||(this.hitDetectionImageData_=null,this.renderedExtent_=w),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const T=new Uf($c(d,u),y,d,u);let _;for(let R=0,B=E.length;R<B;++R)i.loadFeatures(E[R],d,c);const b=nh(d,u);let S=!0;const P=(R,B)=>{let D;const z=R.getStyleFunction()||e.getStyleFunction();if(z&&(D=z(R,d)),D){const N=this.renderFeature(R,b,D,T,_,this.getLayer().getDeclutter(),B);S=S&&!N}},L=oc(y),k=i.getFeaturesInExtent(L);p&&k.sort(p);for(let R=0,B=k.length;R<B;++R)P(k[R],R);this.renderedFeatures_=k,this.ready=S;const F=T.finish(),O=new qf(y,d,u,i.getOverlaps(),F,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=d,this.renderedRevision_=f,this.renderedRenderOrder_=p,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=w,this.wrappedRenderedExtent_=y,this.renderedCenter_=m,this.renderedProjection_=c,this.renderedPixelRatio_=u,this.replayGroup_=O,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=sh(n,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=sh(n,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}function Wc(s,t,e=0,i=s.length-1,n=yg){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),d=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*d*(l-d)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*d/l+u)),g=Math.min(i,Math.floor(t+(l-h)*d/l+u));Wc(s,t,f,g,n)}const r=s[t];let o=e,a=i;for(Hn(s,e,t),n(s[i],r)>0&&Hn(s,e,i);o<a;){for(Hn(s,o,a),o++,a--;n(s[o],r)<0;)o++;for(;n(s[a],r)>0;)a--}n(s[e],r)===0?Hn(s,e,a):(a++,Hn(s,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Hn(s,t,e){const i=s[t];s[t]=s[e],s[e]=i}function yg(s,t){return s<t?-1:s>t?1:0}let Uc=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(!Ys(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;Ys(t,l)&&(e.leaf?i.push(a):Co(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!Ys(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(Ys(t,o)){if(e.leaf||Co(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=dn([]),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=_g(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Co(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=dn(t.slice(e,i+1)),tn(a,this.toBBox),a;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),a=dn([]),a.leaf=!1,a.height=n;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));oh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const d=Math.min(c+h-1,i);oh(t,c,d,l,this.compareMinY);for(let u=c;u<=d;u+=l){const f=Math.min(u+l-1,d);a.children.push(this._build(t,u,f,n-1))}}return tn(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=xo(h),d=Cg(t,h)-c;d<o?(o=d,r=c<r?c:r,a=h):d===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),Kn(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=dn(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,tn(i,this.toBBox),tn(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=dn([t,e]),this.data.height=t.height+1,this.data.leaf=!1,tn(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=Zn(t,0,a,this.toBBox),h=Zn(t,a,i,this.toBBox),c=Eg(l,h),d=xo(l)+xo(h);c<r?(r=c,n=a,o=d<o?d:o):c===r&&d<o&&(o=d,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:wg,r=t.leaf?this.compareMinY:xg,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=Zn(t,0,e,r),a=Zn(t,i-e,i,r);let l=js(o)+js(a);for(let h=e;h<i-e;h++){const c=t.children[h];Kn(o,t.leaf?r(c):c),l+=js(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];Kn(a,t.leaf?r(c):c),l+=js(a)}return l}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Kn(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():tn(t[e],this.toBBox)}};function _g(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 tn(s,t){Zn(s,0,s.children.length,t,s)}function Zn(s,t,e,i,n){n||(n=dn(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];Kn(n,s.leaf?i(o):o)}return n}function Kn(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 wg(s,t){return s.minX-t.minX}function xg(s,t){return s.minY-t.minY}function xo(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function js(s){return s.maxX-s.minX+(s.maxY-s.minY)}function Cg(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 Eg(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 Co(s,t){return s.minX<=t.minX&&s.minY<=t.minY&&t.maxX<=s.maxX&&t.maxY<=s.maxY}function Ys(s,t){return t.minX<=s.maxX&&t.minY<=s.maxY&&t.maxX>=s.minX&&t.maxY>=s.minY}function dn(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function oh(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;Wc(s,o,t,e,n),r.push(t,o,o,e)}}let Zi=0;const Gt=1<<Zi++,$=1<<Zi++,Wt=1<<Zi++,Rt=1<<Zi++,me=1<<Zi++,Te=1<<Zi++,Zs=Math.pow(2,Zi)-1,ja={[Gt]:"boolean",[$]:"number",[Wt]:"string",[Rt]:"color",[me]:"number[]",[Te]:"size"},vg=Object.keys(ja).map(Number).sort(ai);function Tg(s){return s in ja}function pn(s){const t=[];for(const e of vg)qn(s,e)&&t.push(ja[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function qn(s,t){return(s&t)===t}function Ue(s,t){return s===t}class Bt{constructor(t,e){if(!Tg(t))throw new Error(`literal expressions must have a specific type, got ${pn(t)}`);this.type=t,this.value=e}}class Vc{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function Ds(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function Zt(s,t,e){switch(typeof s){case"boolean":{if(Ue(t,Wt))return new Bt(Wt,s?"true":"false");if(!qn(t,Gt))throw new Error(`got a boolean, but expected ${pn(t)}`);return new Bt(Gt,s)}case"number":{if(Ue(t,Te))return new Bt(Te,ce(s));if(Ue(t,Gt))return new Bt(Gt,!!s);if(Ue(t,Wt))return new Bt(Wt,s.toString());if(!qn(t,$))throw new Error(`got a number, but expected ${pn(t)}`);return new Bt($,s)}case"string":{if(Ue(t,Rt))return new Bt(Rt,Va(s));if(Ue(t,Gt))return new Bt(Gt,!!s);if(!qn(t,Wt))throw new Error(`got a string, but expected ${pn(t)}`);return new Bt(Wt,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 Og(s,t,e);for(const i of s)if(typeof i!="number")throw new Error("expected an array of numbers");if(Ue(t,Te)){if(s.length!==2)throw new Error(`expected an array of two values for a size, got ${s.length}`);return new Bt(Te,s)}if(Ue(t,Rt)){if(s.length===3)return new Bt(Rt,[...s,1]);if(s.length===4)return new Bt(Rt,s);throw new Error(`expected an array of 3 or 4 values for a color, got ${s.length}`)}if(!qn(t,me))throw new Error(`got an array of numbers, but expected ${pn(t)}`);return new Bt(me,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"},bg={[v.Get]:q(lt(1,1/0),ah),[v.Var]:q(lt(1,1),Sg),[v.Has]:q(lt(1,1/0),ah),[v.Id]:q(Pg,en),[v.Concat]:q(lt(2,1/0),_t(Wt)),[v.GeometryType]:q(Ig,en),[v.LineMetric]:q(Lg,en),[v.Resolution]:q(Eo,en),[v.Zoom]:q(Eo,en),[v.Time]:q(Eo,en),[v.Any]:q(lt(2,1/0),_t(Gt)),[v.All]:q(lt(2,1/0),_t(Gt)),[v.Not]:q(lt(1,1),_t(Gt)),[v.Equal]:q(lt(2,2),_t(Zs)),[v.NotEqual]:q(lt(2,2),_t(Zs)),[v.GreaterThan]:q(lt(2,2),_t($)),[v.GreaterThanOrEqualTo]:q(lt(2,2),_t($)),[v.LessThan]:q(lt(2,2),_t($)),[v.LessThanOrEqualTo]:q(lt(2,2),_t($)),[v.Multiply]:q(lt(2,1/0),lh),[v.Coalesce]:q(lt(2,1/0),lh),[v.Divide]:q(lt(2,2),_t($)),[v.Add]:q(lt(2,1/0),_t($)),[v.Subtract]:q(lt(2,2),_t($)),[v.Clamp]:q(lt(3,3),_t($)),[v.Mod]:q(lt(2,2),_t($)),[v.Pow]:q(lt(2,2),_t($)),[v.Abs]:q(lt(1,1),_t($)),[v.Floor]:q(lt(1,1),_t($)),[v.Ceil]:q(lt(1,1),_t($)),[v.Round]:q(lt(1,1),_t($)),[v.Sin]:q(lt(1,1),_t($)),[v.Cos]:q(lt(1,1),_t($)),[v.Atan]:q(lt(1,2),_t($)),[v.Sqrt]:q(lt(1,1),_t($)),[v.Match]:q(lt(4,1/0),hh,kg),[v.Between]:q(lt(3,3),_t($)),[v.Interpolate]:q(lt(6,1/0),hh,Rg),[v.Case]:q(lt(3,1/0),Dg,Ag),[v.In]:q(lt(2,2),Mg),[v.Number]:q(lt(1,1/0),_t(Zs)),[v.String]:q(lt(1,1/0),_t(Zs)),[v.Array]:q(lt(1,1/0),_t($)),[v.Color]:q(lt(1,4),_t($)),[v.Band]:q(lt(1,3),_t($)),[v.Palette]:q(lt(2,2),Fg),[v.ToString]:q(lt(1,1),_t(Gt|$|Wt|Rt))};function ah(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 Bt($,o);break}case"string":{n[r]=new Bt(Wt,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 Sg(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 Bt(Wt,i)]}function Pg(s,t,e){e.featureId=!0}function Ig(s,t,e){e.geometryType=!0}function Lg(s,t,e){e.mCoordinate=!0}function Eo(s,t,e){e.mapState=!0}function en(s,t,e){const i=s[0];if(s.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function lt(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 lh(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;r<i;++r){const o=Zt(s[r+1],t,e);n[r]=o}return n}function _t(s){return function(t,e,i){const n=t.length-1,r=new Array(n);for(let o=0;o<n;++o){const a=Zt(t[o+1],s,i);r[o]=a}return r}}function Dg(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 hh(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 kg(s,t,e){const i=s.length-1,n=Wt|$|Gt,r=Zt(s[1],n,e),o=Zt(s[s.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=Zt(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=Zt(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 Rg(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 Bt($,n);let o;try{o=Zt(s[2],$,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=Zt(s[l+3],$,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=Zt(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 Ag(s,t,e){const i=Zt(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=Zt(s[r+1],Gt,e);n[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=Zt(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 Mg(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=Wt:n=$;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=Zt(i[a],n,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Zt(s[1],n,e),...r]}function Fg(s,t,e){let i;try{i=Zt(s[1],$,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=Zt(n[o],Rt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof Bt))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function q(...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 Vc(e,n,...r)}}function Og(s,t,e){const i=s[0],n=bg[i];if(!n)throw new Error(`unknown operator: ${i}`);return n(s,t,e)}function Ya(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 Ya(s.getGeometries()[0]);default:return""}}function Hc(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Ke(s,t,e){const i=Zt(s,t,e);return ze(i)}function ze(s,t){if(s instanceof Bt){if(s.type===Rt&&typeof s.value=="string"){const i=Va(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 zg(s);case v.Get:case v.Var:case v.Has:return $g(s);case v.Id:return i=>i.featureId;case v.GeometryType:return i=>i.geometryType;case v.Concat:{const i=s.args.map(n=>ze(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 Gg(s);case v.Equal:case v.NotEqual:case v.LessThan:case v.LessThanOrEqualTo:case v.GreaterThan:case v.GreaterThanOrEqualTo:return Ng(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 Bg(s);case v.Case:return Wg(s);case v.Match:return Ug(s);case v.Interpolate:return Vg(s);case v.ToString:return Hg(s);default:throw new Error(`Unsupported operator ${e}`)}}function zg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=ze(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 $g(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 Ng(s,t){const e=s.operator,i=ze(s.args[0]),n=ze(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 Gg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=ze(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 Bg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=ze(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 Wg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=ze(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 Ug(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=ze(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 Vg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=ze(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 d=i[h+1](n);const u=Array.isArray(d);if(u&&(d=Cf(d)),c>=o)return h===2?d:u?Xg(r,o,a,l,c,d):Jn(r,o,a,l,c,d);a=c,l=d}return l}}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]=ze(s.args[r]);if(e===v.ToString)return r=>{const o=n[0](r);return s.args[0].type===Rt?Ha(o):o.toString()};throw new Error(`Unsupported convert operator ${e}`)}function Jn(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 Xg(s,t,e,i,n,r){if(n-e===0)return i;const a=Xl(i),l=Xl(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[Jn(s,t,e,a[0],n,l[0]),Jn(s,t,e,a[1],n,l[1]),a[2]+Jn(s,t,e,0,n,h),Jn(s,t,e,i[3],n,r[3])];return Ef(c)}class Bi extends Yr{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()?at.LOADING:at.LOADED,this.imageState_===at.LOADING&&this.ready().then(()=>this.imageState_=at.LOADED),this.render()}clone(){const t=this.getScale(),e=new Bi({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=ve.get(i,null)?.getImage(1);if(!n){const r=this.renderOptions_,o=Math.ceil(r.size*t),a=$t(o,o);this.draw_(r,a,t),n=a.canvas;const l=new Sc(n,void 0,null,at.LOADED,null);ve.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 T=n;n=r,r=T}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,d=Math.sqrt(l*l+c*c),u=d/l;if(t==="miter"&&u<=i)return u*e;const f=e/2/u,g=e/2*(c/d),m=Math.sqrt((n+f)*(n+f)+g*g)-n;if(this.radius2_===void 0||t==="bevel")return m*2;const y=n*Math.sin(a),w=Math.sqrt(n*n-y*y),E=r-w,C=Math.sqrt(y*y+E*E)/y;if(C<=i){const T=C*e/2-r-n;return 2*Math.max(m,T)}return m*2}createRenderOptions(){let t=Pn,e=In,i=0,n=null,r=0,o,a=0;this.stroke_&&(o=Xe(this.stroke_.getColor()??Ze),a=this.stroke_.getWidth()??ys,n=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??In,t=this.stroke_.getLineCap()??Pn,i=this.stroke_.getMiterLimit()??ps);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=ue),e.fillStyle=Xe(n),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),n=0;typeof i=="string"&&(i=Ie(i)),i===null?n=1:Array.isArray(i)&&(n=i.length===4?i[3]:1),n===0&&(e=$t(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=ue,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 Le extends Bi{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 Le({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 j{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 j({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=ls(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()===at.IDLE&&e.load(),e.getImageState()===at.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?K(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:Ie(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class G{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 G({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 A{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=ch,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 A({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_=ch,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function jg(s){let t;if(typeof s=="function")t=s;else{let e;Array.isArray(s)?e=s:(gt(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[s]),t=function(){return e}}return t}let vo=null;function Xc(s,t){if(!vo){const e=new j({color:"rgba(255,255,255,0.4)"}),i=new G({color:"#3399CC",width:1.25});vo=[new A({image:new Le({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return vo}function Yg(){const s={},t=[255,255,255,1],e=[0,153,255,1],i=3;return s.Polygon=[new A({fill:new j({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new A({stroke:new G({color:t,width:i+2})}),new A({stroke:new G({color:e,width:i})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new A({image:new Le({radius:i*2,fill:new j({color:e}),stroke:new G({color:t,width:i/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function ch(s){return s.getGeometry()}const Zg="#333";class te{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_=ce(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 j({color:Zg}),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 te({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 j?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_=ce(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 Kg(s){return!0}function qg(s){const t=Ds(),e=Jg(s,t),i=Hc();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=Ya(n.getGeometry())),e(i)}}function dh(s){const t=Ds(),e=s.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=oa(s[o],t);const n=Hc(),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 Jg(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?Ke(r.filter,Gt,t):Kg;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]=oa(r.style[h],t)}else a=[oa(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 oa(s,t){const e=_s(s,"",t),i=ws(s,"",t),n=Qg(s,t),r=tp(s,t),o=Qt(s,"z-index",t);if(!e&&!i&&!n&&!r&&!Wi(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));const a=new A;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 _s(s,t,e){let i;if(t+"fill-pattern-src"in s)i=sp(s,t+"fill-",e);else{if(s[t+"fill-color"]==="none")return r=>null;i=Zr(s,t+"fill-color",e)}if(!i)return null;const n=new j;return function(r){const o=i(r);return o===Ua?null:(n.setColor(o),n)}}function ws(s,t,e){const i=Qt(s,t+"stroke-width",e),n=Zr(s,t+"stroke-color",e);if(!i&&!n)return null;const r=ri(s,t+"stroke-line-cap",e),o=ri(s,t+"stroke-line-join",e),a=jc(s,t+"stroke-line-dash",e),l=Qt(s,t+"stroke-line-dash-offset",e),h=Qt(s,t+"stroke-miter-limit",e),c=Qt(s,t+"stroke-offset",e),d=new G;return function(u){if(n){const f=n(u);if(f===Ua)return null;d.setColor(f)}if(i&&d.setWidth(i(u)),r){const f=r(u);if(f!=="butt"&&f!=="round"&&f!=="square")throw new Error("Expected butt, round, or square line cap");d.setLineCap(f)}if(o){const f=o(u);if(f!=="bevel"&&f!=="round"&&f!=="miter")throw new Error("Expected bevel, round, or miter line join");d.setLineJoin(f)}return a&&d.setLineDash(a(u)),l&&d.setLineDashOffset(l(u)),h&&d.setMiterLimit(h(u)),c&&d.setOffset(c(u)),d}}function Qg(s,t){const e="text-",i=ri(s,e+"value",t);if(!i)return null;const n=_s(s,e,t),r=_s(s,e+"background-",t),o=ws(s,e,t),a=ws(s,e+"background-",t),l=ri(s,e+"font",t),h=Qt(s,e+"max-angle",t),c=Qt(s,e+"offset-x",t),d=Qt(s,e+"offset-y",t),u=xn(s,e+"overflow",t),f=ri(s,e+"placement",t),g=Qt(s,e+"repeat",t),p=Kr(s,e+"scale",t),m=xn(s,e+"rotate-with-view",t),y=Qt(s,e+"rotation",t),w=ri(s,e+"align",t),E=ri(s,e+"justify",t),x=ri(s,e+"baseline",t),C=xn(s,e+"keep-upright",t),T=jc(s,e+"padding",t),_=qr(s,e+"declutter-mode"),b=new te({declutterMode:_});return function(S){if(b.setText(i(S)),n&&b.setFill(n(S)),r&&b.setBackgroundFill(r(S)),o&&b.setStroke(o(S)),a&&b.setBackgroundStroke(a(S)),l&&b.setFont(l(S)),h&&b.setMaxAngle(h(S)),c&&b.setOffsetX(c(S)),d&&b.setOffsetY(d(S)),u&&b.setOverflow(u(S)),f){const P=f(S);if(P!=="point"&&P!=="line")throw new Error("Expected point or line for text-placement");b.setPlacement(P)}if(g&&b.setRepeat(g(S)),p&&b.setScale(p(S)),m&&b.setRotateWithView(m(S)),y&&b.setRotation(y(S)),w){const P=w(S);if(P!=="left"&&P!=="center"&&P!=="right"&&P!=="end"&&P!=="start")throw new Error("Expected left, right, center, start, or end for text-align");b.setTextAlign(P)}if(E){const P=E(S);if(P!=="left"&&P!=="right"&&P!=="center")throw new Error("Expected left, right, or center for text-justify");b.setJustify(P)}if(x){const P=x(S);if(P!=="bottom"&&P!=="top"&&P!=="middle"&&P!=="alphabetic"&&P!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");b.setTextBaseline(P)}return T&&b.setPadding(T(S)),C&&b.setKeepUpright(C(S)),b}}function tp(s,t){return"icon-src"in s?ep(s,t):"shape-points"in s?ip(s,t):"circle-radius"in s?np(s,t):null}function ep(s,t){const e="icon-",i=e+"src",n=Yc(s[i],i),r=Sr(s,e+"anchor",t),o=Kr(s,e+"scale",t),a=Qt(s,e+"opacity",t),l=Sr(s,e+"displacement",t),h=Qt(s,e+"rotation",t),c=xn(s,e+"rotate-with-view",t),d=fh(s,e+"anchor-origin"),u=gh(s,e+"anchor-x-units"),f=gh(s,e+"anchor-y-units"),g=fi(s,e+"color");let p,m=null;g!==void 0&&(Array.isArray(g)&&g.length>0&&typeof g[0]=="string"?m=Zr(s,e+"color",t):p=Zc(g,e+"color"));const y=op(s,e+"cross-origin"),w=ap(s,e+"offset"),E=fh(s,e+"offset-origin"),x=aa(s,e+"width"),C=aa(s,e+"height"),T=rp(s,e+"size"),_=qr(s,e+"declutter-mode"),b={src:n,anchorOrigin:d,anchorXUnits:u,anchorYUnits:f,crossOrigin:y,offset:w,offsetOrigin:E,height:C,width:x,size:T,declutterMode:_};let S=null;return function(P){if(S)m&&S.setColor(m(P));else{const L=m?m(P):p;S=new Vi(L!==void 0?Object.assign({},b,{color:L}):Object.assign({},b))}return a&&S.setOpacity(a(P)),l&&S.setDisplacement(l(P)),h&&S.setRotation(h(P)),c&&S.setRotateWithView(c(P)),o&&S.setScale(o(P)),r&&S.setAnchor(r(P)),S}}function ip(s,t){const e="shape-",i=e+"points",n=e+"radius",r=Za(s[i],i);if(!(n in s))throw new Error(`Expected a number for ${n}`);const o=Qt(s,n,t),a=typeof s[n]=="number"?s[n]:5,l=e+"radius2",h=Qt(s,l,t),c=typeof s[l]=="number"?s[l]:void 0,d=_s(s,e,t),u=ws(s,e,t),f=Kr(s,e+"scale",t),g=Sr(s,e+"displacement",t),p=Qt(s,e+"rotation",t),m=xn(s,e+"rotate-with-view",t),y=aa(s,e+"angle"),w=qr(s,e+"declutter-mode"),E=new Bi({points:r,radius:a,radius2:c,angle:y,declutterMode:w});return function(x){return o&&E.setRadius(o(x)),h&&E.setRadius2(h(x)),d&&E.setFill(d(x)),u&&E.setStroke(u(x)),g&&E.setDisplacement(g(x)),p&&E.setRotation(p(x)),m&&E.setRotateWithView(m(x)),f&&E.setScale(f(x)),E}}function np(s,t){const e="circle-",i=_s(s,e,t),n=ws(s,e,t),r=Qt(s,e+"radius",t),o=Kr(s,e+"scale",t),a=Sr(s,e+"displacement",t),l=Qt(s,e+"rotation",t),h=xn(s,e+"rotate-with-view",t),c=qr(s,e+"declutter-mode"),d=new Le({radius:5,declutterMode:c});return function(u){return r&&d.setRadius(r(u)),i&&d.setFill(i(u)),n&&d.setStroke(n(u)),a&&d.setDisplacement(a(u)),l&&d.setRotation(l(u)),h&&d.setRotateWithView(h(u)),o&&d.setScale(o(u)),d}}function fi(s,t){if(!(t in s))return;const e=s[t];return e===void 0?void 0:e}function Qt(s,t,e){const i=fi(s,t);if(i===void 0)return;const n=Ke(i,$,e);return function(r){return Za(n(r),t)}}function ri(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,Wt,e);return function(r){return Yc(n(r),t)}}function sp(s,t,e){const i=ri(s,t+"pattern-src",e),n=uh(s,t+"pattern-offset",e),r=uh(s,t+"pattern-size",e),o=Zr(s,t+"color",e);return function(a){return{src:i(a),offset:n&&n(a),size:r&&r(a),color:o&&o(a)}}}function xn(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,Gt,e);return function(r){const o=n(r);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${t}`);return o}}function Zr(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,Rt,e);return function(r){return Zc(n(r),t)}}function jc(s,t,e){const i=fi(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=Ke(o,$,e);return function(h){return Za(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=Ke(i,me,e);return function(r){return ks(n(r),t)}}function Sr(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,me,e);return function(r){const o=ks(n(r),t);if(o.length!==2)throw new Error(`Expected two numbers for ${t}`);return o}}function uh(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,me,e);return function(r){return Kc(n(r),t)}}function Kr(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,me|$,e);return function(r){return lp(n(r),t)}}function aa(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 rp(s,t){const e=s[t];if(e!==void 0){if(typeof e=="number")return ce(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 op(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 fh(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 gh(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 ap(s,t){const e=s[t];if(e!==void 0)return ks(e,t)}function qr(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 ks(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 Yc(s,t){if(typeof s!="string")throw new Error(`Expected a string for ${t}`);return s}function Za(s,t){if(typeof s!="number")throw new Error(`Expected a number for ${t}`);return s}function Zc(s,t){if(typeof s=="string")return s;const e=ks(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 Kc(s,t){const e=ks(s,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function lp(s,t){return typeof s=="number"?s:Kc(s,t)}const De={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function ph(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,d=a?a[1]:0;let u=s[0]+l/2+c,f=s[2]-l/2+c,g=s[1]+h/2+d,p=s[3]-h/2+d;u>f&&(u=(f+u)/2,f=u),g>p&&(g=(p+g)/2,p=g);let m=Pt(i[0],u,f),y=Pt(i[1],g,p);if(o&&e&&n){const w=30*n;m+=-w*Math.log(1+Math.max(0,u-i[0])/w)+w*Math.log(1+Math.max(0,i[0]-f)/w),y+=-w*Math.log(1+Math.max(0,g-i[1])/w)+w*Math.log(1+Math.max(0,i[1]-p)/w)}return[m,y]})}function hp(s){return s}function qc(s){return Math.pow(s,3)}function Mn(s){return 1-qc(1-s)}function cp(s){return 3*s*s-2*s*s*s}function dp(s){return s}function Ka(s,t,e,i){const n=Et(t)/e[0],r=he(t)/e[1];return i?Math.min(s,Math.max(n,r)):Math.min(s,Math.min(n,r))}function qa(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 up(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?Ka(l,e,o,i):l;if(a)return t?qa(n,c,h):Pt(n,h,c);const d=Math.min(c,n),u=Math.floor(_a(s,d,r));return s[u]>c&&u<s.length-1?s[u+1]:s[u]}})}function fp(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?Ka(t,n,l,r):t;if(h)return i?qa(o,c,e):Pt(o,e,c);const d=1e-9,u=Math.ceil(Math.log(t/c)/Math.log(s)-d),f=-a*(.5-d)+.5,g=Math.min(c,o),p=Math.floor(Math.log(t/g)/Math.log(s)+f),m=Math.max(u,p),y=t/Math.pow(s,m);return Pt(y,e,c)}})}function mh(s,t,e,i,n){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?Ka(s,i,a,n):s;return!e||!l?Pt(r,t,h):qa(r,h,t)}})}function Ja(s){if(s!==void 0)return 0}function yh(s){if(s!==void 0)return s}function gp(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 pp(s){const t=Fe(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const mp=42,Qa=256,To=0;class He extends $e{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Da(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&&rc(),t.center&&(t.center=Re(t.center,this.projection_)),t.extent&&(t.extent=Fi(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in De)delete e[a];this.setProperties(e,!0);const i=_p(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=yp(t),r=i.constraint,o=wp(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=Re(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=Re(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&&Ks(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],d={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||cp,callback:i};if(c.center&&(d.sourceCenter=o,d.targetCenter=c.center.slice(),o=d.targetCenter),c.zoom!==void 0?(d.sourceResolution=a,d.targetResolution=this.getResolutionForZoom(c.zoom),a=d.targetResolution):c.resolution&&(d.sourceResolution=a,d.targetResolution=c.resolution,a=d.targetResolution),c.rotation!==void 0){d.sourceRotation=l;const u=Gi(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;d.targetRotation=l+u,l=d.targetRotation}xp(d)?d.complete=!0:r+=d.duration,h.push(d)}this.animations_.push(h),this.setHint(jt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[jt.ANIMATING]>0}getInteracting(){return this.hints_[jt.INTERACTING]>0}cancelAnimations(){this.setHint(jt.ANIMATING,-this.hints_[jt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const n=this.animations_[e];if(n[0].callback&&Ks(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 d=l.easing(c);if(l.sourceCenter){const u=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],p=l.targetCenter[1];this.nextCenter_=l.targetCenter;const m=u+d*(g-u),y=f+d*(p-f);this.targetCenter_=[m,y]}if(l.sourceResolution&&l.targetResolution){const u=d===1?l.targetResolution:l.sourceResolution+d*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(u,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=u,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const u=d===1?Gi(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+d*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(u,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=u}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(jt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=n[0].callback;o&&Ks(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]],va(i,t-this.getRotation()),jh(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&&Jo(t,this.getProjection())}getCenterInternal(){return this.get(De.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 oc(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();gt(e,"The view center is not defined");const i=this.getResolution();gt(i!==void 0,"The view resolution is not defined");const n=this.getRotation();return gt(n!==void 0,"The view rotation is not defined"),Xo(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(De.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Fi(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=Et(t)/e[0],n=he(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(De.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=bo(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=_a(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(gt(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){gt(!bs(t),"Cannot fit empty extent provided as `geometry`");const n=Fi(t,this.getProjection());i=gn(n)}else if(t.getType()==="Circle"){const n=Fi(t.getExtent(),this.getProjection());i=gn(n),i.rotate(this.getRotation(),be(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 d=0,u=r.length;d<u;d+=o){const f=r[d]*i-r[d+1]*n,g=r[d]*n+r[d+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),d=Math.cos(h),u=be(a);u[0]+=(n[1]-n[3])/2*l,u[1]+=(n[0]-n[2])/2*l;const f=u[0]*d-u[1]*c,g=u[1]*d+u[0]*c,p=this.getConstrainedCenter([f,g],l),m=e.callback?e.callback:cs;e.duration!==void 0?this.animateInternal({resolution:l,center:p,duration:e.duration,easing:e.easing},m):(this.targetResolution_=l,this.targetCenter_=p,this.applyTargetState_(!1,!0),Ks(m,!0))}centerOn(t,e,i){this.centerOnInternal(Re(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(bo(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=bo(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=Jo(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&&Re(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=Re(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&&Re(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(De.ROTATION)!==n&&this.set(De.ROTATION,n),this.get(De.RESOLUTION)!==o&&(this.set(De.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(De.CENTER)||!yr(this.get(De.CENTER),a))&&this.set(De.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()||!yr(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:Mn,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(jt.INTERACTING,1)}endInteraction(t,e,i){i=i&&Re(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(jt.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 Ks(s,t){setTimeout(function(){s(t)},0)}function yp(s){if(s.extent!==void 0){const e=s.smoothExtentConstraint!==void 0?s.smoothExtentConstraint:!0;return ph(s.extent,s.constrainOnlyCenter,e)}const t=Da(s.projection,"EPSG:3857");if(s.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,ph(e,!1,!1)}return hp}function _p(s){let t,e,i,o=s.minZoom!==void 0?s.minZoom:To,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,d=s.showFullExtent!==void 0?s.showFullExtent:!1,u=Da(s.projection,"EPSG:3857"),f=u.getExtent();let g=s.constrainOnlyCenter,p=s.extent;if(!h&&!p&&u.isGlobal()&&(g=!1,p=f),s.resolutions!==void 0){const m=s.resolutions;e=m[o],i=m[a]!==void 0?m[a]:m[m.length-1],s.constrainResolution?t=up(m,c,!g&&p,d):t=mh(e,i,c,!g&&p,d)}else{const y=(f?Math.max(Et(f),he(f)):360*Ta.degrees/u.getMetersPerUnit())/Qa/Math.pow(2,To),w=y/Math.pow(2,28-To);e=s.maxResolution,e!==void 0?o=0:e=y/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=y/Math.pow(l,a):i=w),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),s.constrainResolution?t=fp(l,e,i,c,!g&&p,d):t=mh(e,i,c,!g&&p,d)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function wp(s){if(s.enableRotation!==void 0?s.enableRotation:!0){const e=s.constrainRotation;return e===void 0||e===!0?pp():e===!1?yh:typeof e=="number"?gp(e):yh}return Ja}function xp(s){return!(s.sourceCenter&&s.targetCenter&&!yr(s.sourceCenter,s.targetCenter)||s.sourceResolution!==s.targetResolution||s.sourceRotation!==s.targetRotation)}function bo(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 wt={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 Jc extends $e{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[wt.OPACITY]=t.opacity!==void 0?t.opacity:1,gt(typeof e[wt.OPACITY]=="number","Layer opacity must be a number"),e[wt.VISIBLE]=t.visible!==void 0?t.visible:!0,e[wt.Z_INDEX]=t.zIndex,e[wt.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[wt.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[wt.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[wt.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 Q()}getLayerStatesArray(t){return Q()}getExtent(){return this.get(wt.EXTENT)}getMaxResolution(){return this.get(wt.MAX_RESOLUTION)}getMinResolution(){return this.get(wt.MIN_RESOLUTION)}getMinZoom(){return this.get(wt.MIN_ZOOM)}getMaxZoom(){return this.get(wt.MAX_ZOOM)}getOpacity(){return this.get(wt.OPACITY)}getSourceState(){return Q()}getVisible(){return this.get(wt.VISIBLE)}getZIndex(){return this.get(wt.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(wt.EXTENT,t)}setMaxResolution(t){this.set(wt.MAX_RESOLUTION,t)}setMinResolution(t){this.set(wt.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(wt.MAX_ZOOM,t)}setMinZoom(t){this.set(wt.MIN_ZOOM,t)}setOpacity(t){gt(typeof t=="number","Layer opacity must be a number"),this.set(wt.OPACITY,t)}setVisible(t){this.set(wt.VISIBLE,t)}setZIndex(t){this.set(wt.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}class Jr extends Jc{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(wt.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(wt.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_&&(Tt(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=ft(t,nt.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 He?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 tl(n,e.viewState)&&(!r||le(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof He?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(wt.MAP,t)}getMapInternal(){return this.get(wt.MAP)}setMap(t){this.mapPrecomposeKey_&&(Tt(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(Tt(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=ft(t,Yt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=ft(this,nt.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);gt(!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(wt.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 tl(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 _h={RENDER_ORDER:"renderOrder"};class Qr extends Jr{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(_h.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 Uc(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(_h.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Xc:t;const e=Cp(t);this.styleFunction_=t===null?void 0:jg(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function Cp(s){if(s===void 0)return Xc;if(!s)return null;if(typeof s=="function"||s instanceof A)return s;if(!Array.isArray(s))return dh([s]);if(s.length===0)return[];const t=s.length,e=s[0];if(e instanceof A){const n=new Array(t);for(let r=0;r<t;++r){const o=s[r];if(!(o instanceof A))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 qg(n)}return dh(s)}class bt extends Qr{constructor(t){super(t)}createRenderer(){return new mg(this)}}const fe={ADD:"add",REMOVE:"remove"},wh={LENGTH:"length"};class qs extends qe{constructor(t,e,i){super(t),this.element=e,this.index=i}}class pe extends $e{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(wh.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 qs(fe.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 qs(fe.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 qs(fe.REMOVE,n,t)),this.dispatchEvent(new qs(fe.ADD,e,t))}updateLength_(){this.set(wh.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 Ep=!1;function vp(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=Ep,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 xh(s,t){return function(e,i,n,r,o){vp(s,t,e,i,n,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Tp(s,t){return[[-1/0,-1/0,1/0,1/0]]}class Ln extends Pi{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];je(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){je(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Ln(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ma(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Oa(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,Ju(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return fs(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new pt(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 pt(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+=$a(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=Cr(e,i,l,r,.5);je(t,h),i=l}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=pc(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new Ln(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return ef(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Is(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}class Rs extends Pi{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){je(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new Rs(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<Xi(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=li(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 vi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new rt(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 rt(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(wa(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ur(this.flatCoordinates,0,t,this.stride),this.changed()}}function Qc(s,t,e,i){const n=[];let r=oe();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 Dn extends Pi{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,d=h.getEnds();for(let u=0,f=d.length;u<f;++u)d[u]+=c;je(r,h.getFlatCoordinates()),o.push(d)}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;je(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 Dn(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ku(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),qu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return tf(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return of(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),ia(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,ta(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=Qc(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=_c(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Rs(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;wc(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=ia(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=rf(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new Dn(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 it(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 d=0,u=l.length;d<u;++d)l[d]-=r;const c=new it(e.slice(r,h),t,l);n.push(c),r=h}return n}getType(){return"MultiPolygon"}intersectsExtent(t){return nf(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=dc(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 Ch=Ut();class ge{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"?xa(this.flatCoordinates_):Ca(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=be(this.getExtent());this.flatInteriorPoints_=Ga(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=xc(this.flatCoordinates_,this.ends_),e=Qc(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=_c(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Cr(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=Cr(t,e,o,this.stride_,.5);je(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=Ft(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const n=he(i)/he(e);Pe(Ch,i[0],i[3],n,-n,0,0,0),Ye(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,Ch,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new ge(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Nh((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=Hr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=pc(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=Na(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n);break}return n&&(this.simplifiedGeometry_=new ge(this.type_,i,n,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}ge.prototype.getFlatCoordinates=ge.prototype.getOrientedFlatCoordinates;class Eh{constructor(t){this.rbush_=new Uc(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[K(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;n<r;n++){const o=t[n],a=e[n],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[n]=l,this.items_[K(a)]=l}this.rbush_.load(i)}remove(t){const e=K(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[K(e)],n=[i.minX,i.minY,i.maxX,i.maxY];bn(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 Wi(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return di(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 td extends $e{constructor(t){super(),this.projection=Ft(t.projection),this.attributions_=vh(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_=vh(t),this.changed()}setState(t){this.state_=t,this.changed()}}function vh(s){return s?typeof s=="function"?s:(Array.isArray(s)||(s=[s]),t=>s):null}const re={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class yi extends qe{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class Y extends td{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_=cs,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&&(gt(this.format_,"`format` must be set when `url` is set"),this.loader_=xh(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:Tp;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new Eh:null,this.loadedExtentsRtree_=new Eh,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 pe(n)),n!==void 0&&this.addFeaturesInternal(n),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=K(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const n=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new yi(re.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof ge||(this.featureChangeKeys_[t]=[ft(e,nt.CHANGE,this.handleFeatureChange_,this),ft(e,En.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 ge){const r=this.idIndex_[n];r instanceof ge?Array.isArray(r)?r.push(e):this.idIndex_[n]=[r,e]:i=!1}else i=!1}return i&&(gt(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],n=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=K(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=K(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),n.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,n),this.hasListener(re.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new yi(re.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(re.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(re.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(fe.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(fe.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(Tt);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 yi(re.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 ge||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 ge||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(),Wi(this.nullGeometryFeatures_)||je(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=Hh(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||vn,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),d=a;if(a=c instanceof ge?0:c.closestPointXY(i,n,o,a),a<d){r=h;const u=Math.sqrt(a);l[0]=i-u,l[1]=n-u,l[2]=i+u,l[3]=n+u}}}),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=K(e),n=e.getGeometry();if(!n)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=n.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new yi(re.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:K(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Wi(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 Yn(c.extent,l)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new yi(re.FEATURESLOADSTART));const c=g=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new yi(re.FEATURESLOADEND,void 0,g))},d=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new yi(re.FEATURESLOADERROR))};let u=!1;const f=this.loader_.call(this,l,e,i,g=>u||c(g),()=>u||d());f instanceof Promise?(u=!0,f.then(g=>{this.addFeatures(g),c(g)}).catch(d)):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(bn(n.extent,t))return n});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;i<n;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=K(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(Tt),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(re.REMOVEFEATURE)&&this.dispatchEvent(new yi(re.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){gt(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(xh(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}class un extends qe{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class si extends un{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 Ct={SINGLECLICK:"singleclick",CLICK:nt.CLICK,DBLCLICK:nt.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};function la(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 bp=function(s){const t=s.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Sp=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)},ed=function(s){const t=s.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?Sp(s):!0},hr=vn,id=function(s){const t=s.originalEvent;return"pointerId"in t&&t.button==0&&!(cf&&Cc&&t.ctrlKey)},Pp=Rn,el=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},Ip=function(s){const t=s.originalEvent;return Cc?t.metaKey:t.ctrlKey},ha=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},nd=function(s){const t=s.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},So=function(s){const t=s.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},Lp=function(s){const t=s.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};class Me extends Pi{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 Me(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 di(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(le(t,e)){const i=this.getCenter();return t[0]<=i[0]&&t[2]>=i[0]||t[1]<=i[1]&&t[3]>=i[1]?!0:Ea(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=cc(n,0,t,this.stride);n[r++]=n[0]+e;for(let o=1,a=this.stride;o<a;++o)n[r++]=n[o];n.length=r,this.changed()}getCoordinates(){return null}setCoordinates(t,e){}setRadius(t){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+t,this.changed()}rotate(t,e){const i=this.getCenter(),n=this.getStride();this.setCenter(Ra(i,0,i.length,n,t,e,i)),this.changed()}}Me.prototype.transform;const ca={ACTIVE:"active"};class As extends $e{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(ca.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(ca.ACTIVE,t)}setMap(t){this.map_=t}}function Dp(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:dp,center:s.getConstrainedCenter(n)})}}function il(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:Mn})}class Ki extends As{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==Ct.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Ct.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==Ct.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==Ct.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 nl(s){const t=s.length;let e=0,i=0;for(let n=0;n<t;n++)e+=s[n].clientX,i+=s[n].clientY;return{clientX:e/t,clientY:i/t}}class xs extends hc{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(Tt),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,i=t.length;e<i;++e)this.changeEventsKeys_.push(ft(t[e],nt.CHANGE,this.changed,this))}clone(){const t=new xs(Po(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<Xi(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){Ts(t);const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)ss(t,e[i].getExtent());return t}getGeometries(){return Po(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 xs(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=be(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(Po(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 Po(s){return s.map(t=>t.clone())}function mn(s,t){const e=s.length;return t<0?s[t+e]:t>=e?s[t-e]:s[t]}function yn(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,d=h[1]-l;return[a+c*n,l+d*n]}const Js={index:-1,endIndex:NaN,closestTargetDistance:1/0};function kp(s,t,e,i){const n=s[0],r=s[1];let o=1/0,a=-1,l=NaN;for(let d=0;d<t.targets.length;++d){const u=t.targets[d],f=u.coordinates;let g=1/0,p;for(let m=0;m<f.length-1;++m){const y=f[m],w=f[m+1],E=rd(n,r,y,w);E.squaredDistance<g&&(g=E.squaredDistance,p=m+E.along)}g<o&&(o=g,u.ring&&t.targetIndex===d&&(u.endIndex>u.startIndex?p<u.startIndex&&(p+=f.length):u.endIndex<u.startIndex&&p>u.startIndex&&(p-=f.length)),l=p,a=d)}const h=t.targets[a];let c=h.ring;if(t.targetIndex===a&&c){const d=yn(h.coordinates,l),u=e.getPixelFromCoordinate(d),f=e.getPixelFromCoordinate(t.startCoord);Kh(u,f)>i&&(c=!1)}if(c){const d=h.coordinates,u=d.length,f=h.startIndex,g=l;if(f<g){const p=er(d,f,g);er(d,f,g-u)<p&&(l-=u)}else{const p=er(d,f,g);er(d,f,g+u)<p&&(l+=u)}}return Js.index=a,Js.endIndex=l,Js.closestTargetDistance=o,Js}function Rp(s,t){const e=[];for(let i=0;i<t.length;++i){const r=t[i].getGeometry();sd(s,r,e)}return e}function sd(s,t,e){if(t instanceof pt){Qs(s,t.getCoordinates(),!1,e);return}if(t instanceof Ln){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)Qs(s,i[n],!1,e);return}if(t instanceof it){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)Qs(s,i[n],!0,e);return}if(t instanceof Dn){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)Qs(s,o[a],!0,e)}return}if(t instanceof xs){const i=t.getGeometries();for(let n=0;n<i.length;++n)sd(s,i[n],e);return}}function Qs(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=rd(n,r,l,h);if(c.squaredDistance===0){const d=o+c.along;i.push({coordinates:t,ring:e,startIndex:d,endIndex:d});return}}}function tr(s,t){return li(s[0],s[1],t[0],t[1])}function er(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=yn(s,i),h=yn(s,n);return tr(l,h)}let a=0;if(i<r){const l=yn(s,i),h=mn(s,r);a+=tr(l,h)}if(o<n){const l=mn(s,o),h=yn(s,n);a+=tr(l,h)}for(let l=r;l<o-1;++l){const h=mn(s,l),c=mn(s,l+1);a+=tr(h,c)}return a}const Io={along:0,squaredDistance:0};function rd(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,d=n,u=r;return(l!==0||h!==0)&&(c=Pt(((s-n)*l+(t-r)*h)/(l*l+h*h),0,1),d+=l*c,u+=h*c),Io.along=c,Io.squaredDistance=Ss(li(s,t,d,u),10),Io}const ir={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class nr extends qe{constructor(t,e){super(t),this.feature=e}}class ee extends Ki{constructor(t){const e=t;e.stopDown||(e.stopDown=Rn),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_=Mp(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:vn,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 Me([NaN,NaN]),h=Re(r[0]),c=Zh(h,Re(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;n==="Point"?r=rt:n==="LineString"?r=pt:n==="Polygon"&&(r=it),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 bt({source:new Y({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:Ap(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:el,this.freehandCondition_,t.freehand?this.freehandCondition_=hr:this.freehandCondition_=t.freehandCondition?t.freehandCondition:ha,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(ca.ACTIVE,this.updateState_)}setTrace(t){let e;t?t===!0?e=hr:e=t:e=Pp,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=hr:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:ha}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){t.originalEvent.type===nt.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(t);let e=t.type===Ct.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&t.type===Ct.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===Ct.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===Ct.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===Ct.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===Ct.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===Ct.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 si(Ct.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=mr([i,n]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=Rp(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(mn(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(mn(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(Kh(a,t.pixel)<this.snapTolerance_)return}const i=kp(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=yn(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],d=a.getPixelFromCoordinate(c),u=t[0]-d[0],f=t[1]-d[1],g=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(u*u+f*f)<=g,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new V(new rt(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new V);const e=t.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),i.changed()):(i=new pt(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(t){const e=this.getMap().getView().getProjection(),i=xr(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 V(new pt(this.sketchLineCoords_)));const n=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new V,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(n),this.updateSketchFeatures_(),this.dispatchEvent(new nr(ir.DRAWSTART,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),i=this.sketchFeature_.getGeometry(),n=e.getView().getProjection(),r=xr(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 Rs([e])):this.type_==="MultiLineString"?t.setGeometry(new Ln([e])):this.type_==="MultiPolygon"&&t.setGeometry(new Dn([e])),this.dispatchEvent(new nr(ir.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 nr(ir.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 V(new rt(n)),this.updateSketchFeatures_(),this.dispatchEvent(new nr(ir.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 Ap(){const s=Yg();return function(t,e){return s[t.getGeometry().getType()]}}function Mp(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 da={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class Fp extends Fr{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_=ft(i,da.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=ft(i,da.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(nt.TOUCHMOVE,this.boundHandleTouchMove_,vc?{passive:!1}:!1)}emulateClick_(t){let e=new si(Ct.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new si(Ct.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new si(Ct.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==Ct.POINTERUP||e.type==Ct.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==Ct.POINTERDOWN||e.type==Ct.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new si(Ct.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(Tt),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 si(Ct.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(ft(i,Ct.POINTERMOVE,this.handlePointerMove_,this),ft(i,Ct.POINTERUP,this.handlePointerUp_,this),ft(this.element_,Ct.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(ft(this.element_.getRootNode(),Ct.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new si(Ct.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 si(Ct.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_&&(Tt(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(nt.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(Tt(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(Tt),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Ci={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},se={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},X={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},Pr=1/0;class Op{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,kn(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){gt(!(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!=Pr?(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==Pr?delete this.queuedElements_[this.keyFunction_(o)]:(i[n]=l,e[n++]=o);e.length=n,i.length=n,this.heapify_()}}class zp extends Op{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(nt.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===X.LOADED||i===X.ERROR||i===X.EMPTY){i!==X.ERROR&&e.removeEventListener(nt.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()===X.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,n.load())}}}function $p(s,t,e,i,n){if(!s||!(e in s.wantedTiles)||!s.wantedTiles[e][t.getKey()])return Pr;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 sl extends $e{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)Tt(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!==cs&&this.listenerKeys.push(ft(t,Ci.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Np extends sl{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(nt.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+jr+" "+Xa+(this.collapsed_&&this.collapsible_?" "+jl:"")+(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=>tu(()=>n))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!ui(e,this.renderedAttributions_)){uf(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(jl),this.collapsed_?Hl(this.collapseLabel_,this.label_):Hl(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 Gp extends sl{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(nt.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+jr+" "+Xa,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(Hs)}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:Mn}):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(Hs);!r&&i===0?this.element.classList.add(Hs):r&&i!==0&&this.element.classList.remove(Hs)}this.label_.style.transform=n}this.rotation_=i}}class Bp extends sl{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(nt.CLICK,this.handleClick_.bind(this,i),!1);const d=document.createElement("button");d.className=r,d.setAttribute("type","button"),d.title=h,d.appendChild(typeof a=="string"?document.createTextNode(a):a),d.addEventListener(nt.CLICK,this.handleClick_.bind(this,-i),!1);const u=e+" "+jr+" "+Xa,f=this.element;f.className=u,f.appendChild(c),f.appendChild(d),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:Mn})):i.setZoom(r)}}}function Wp(s){s=s||{};const t=new pe;return(s.zoom===void 0||s.zoom)&&t.push(new Bp(s.zoomOptions)),(s.rotate===void 0||s.rotate)&&t.push(new Gp(s.rotateOptions)),(s.attribution===void 0||s.attribution)&&t.push(new Np(s.attributionOptions)),t}class Up{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 Vp extends As{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==Ct.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=n.getView();il(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}class Hp extends Ki{constructor(t){super({stopDown:Rn}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:la(el,Lp);this.condition_=t.onFocusOnly?la(ed,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(nl(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();Yh(r,a.getResolution()),va(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:Mn})}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 Xp extends Ki{constructor(t){t=t||{},super({stopDown:Rn}),this.condition_=t.condition?t.condition:bp,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!So(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===Ja)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 So(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return So(t)&&id(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class jp extends Es{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 it([n])}getGeometry(){return this.geometry_}}const nn={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Xn extends qe{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class Yp extends Ki{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new jp(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??id,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 Xn(nn.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 Xn(e?nn.BOXEND:nn.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 Xn(nn.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Xn(nn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Xn(nn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class Zp extends Yp{constructor(t){t=t||{};const e=t.condition?t.condition:ha;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:Mn})}}const ki={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class Kp extends As{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return el(e)&&nd(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==nt.KEYDOWN){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==ki.DOWN||n==ki.LEFT||n==ki.RIGHT||n==ki.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;n==ki.DOWN?h=-a:n==ki.LEFT?l=-a:n==ki.RIGHT?l=a:h=a;const c=[l,h];va(c,o.getRotation()),Dp(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class qp extends As{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!Ip(e)&&nd(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==nt.KEYDOWN||t.type==nt.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();il(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const Jp=40,Qp=300,tm=3;class em extends As{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:hr;this.condition_=t.onFocusOnly?la(ed,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(Tt),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){const e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push(ft(e,"keydown",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!0)}),ft(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!==nt.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*=Jp;break;case WheelEvent.DOM_DELTA_PAGE:o*=Qp;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*tm),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),il(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 im extends Ki{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Rn),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!==Ja&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(nl(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 nm extends Ki{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Rn),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(nl(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 od(s){s=s||{};const t=new pe,e=new Up(-.005,.05,100);return(s.altShiftDragRotate===void 0||s.altShiftDragRotate)&&t.push(new Xp),(s.doubleClickZoom===void 0||s.doubleClickZoom)&&t.push(new Vp({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan===void 0||s.dragPan)&&t.push(new Hp({onFocusOnly:s.onFocusOnly,kinetic:e})),(s.pinchRotate===void 0||s.pinchRotate)&&t.push(new im),(s.pinchZoom===void 0||s.pinchZoom)&&t.push(new nm({duration:s.zoomDuration})),(s.keyboard===void 0||s.keyboard)&&(t.push(new Kp),t.push(new qp({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom===void 0||s.mouseWheelZoom)&&t.push(new em({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom===void 0||s.shiftDragZoom)&&t.push(new Zp({duration:s.zoomDuration})),t}const _i={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class Ei extends qe{constructor(t,e){super(t),this.layer=e}}const Lo={LAYERS:"layers"};class Fn extends Jc{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(Lo.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new pe(i.slice(),{unique:!0}):gt(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new pe(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(Tt),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(ft(t,fe.ADD,this.handleLayersAdd_,this),ft(t,fe.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(Tt);kn(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 Ei(_i.ADDLAYER,r))}this.changed()}registerLayerListeners_(t){const e=[ft(t,En.PROPERTYCHANGE,this.handleLayerChange_,this),ft(t,nt.CHANGE,this.handleLayerChange_,this)];t instanceof Fn&&e.push(ft(t,_i.ADDLAYER,this.handleLayerGroupAdd_,this),ft(t,_i.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[K(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Ei(_i.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Ei(_i.REMOVELAYER,t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Ei(_i.ADDLAYER,e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=K(e);this.listenerKeys_[i].forEach(Tt),delete this.listenerKeys_[i],this.dispatchEvent(new Ei(_i.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(Lo.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 Ei(_i.REMOVELAYER,i[n]))}this.set(Lo.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=Ni(l.extent,n.extent):l.extent=n.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}class sm extends Es{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){Q()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,n=t.pixelToCoordinateTransform;Pe(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Wr(n,i)}forEachFeatureAtCoordinate(t,e,i,n,r,o,a,l){let h;const c=e.viewState;function d(x,C,T,_){return r.call(o,C,x?T:null,_)}const u=c.projection,f=qh(t.slice(),u),g=[[0,0]];if(u.canWrapX()&&n){const x=u.getExtent(),C=Et(x);g.push([-C,0],[C,0])}const p=e.layerStatesArray,m=p.length,y=[],w=[];for(let x=0;x<g.length;x++)for(let C=m-1;C>=0;--C){const T=p[C],_=T.layer;if(_.hasRenderer()&&tl(T,c)&&a.call(l,_)){const b=_.getRenderer(),S=_.getSource();if(b&&S){const P=S.getWrapX()?f:t,L=d.bind(null,T.managed);w[0]=P[0]+g[x][0],w[1]=P[1]+g[x][1],h=b.forEachFeatureAtCoordinate(w,e,i,L,y)}if(h)return h}}if(y.length===0)return;const E=1/y.length;return y.forEach((x,C)=>x.distanceSq+=C*E),y.sort((x,C)=>x.distanceSq-C.distanceSq),y.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,vn,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){Q()}scheduleExpireIconCache(t){ve.canExpireCache()&&t.postRenderFunctions.push(rm)}}function rm(s,t){ve.expire()}class om extends sm{constructor(t){super(t),this.fontChangeListenerKey_=ft(hn,En.PROPERTYCHANGE,t.redrawText,t),this.element_=Ee?Tc():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=jr+" 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 hs(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){Tt(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(Yt.PRECOMPOSE,t);const e=t.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);e.some(h=>h.layer instanceof Qr&&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 d=e[h];t.layerIndex=h;const u=d.layer,f=u.getSourceState();if(!tl(d,n)||f!="ready"&&f!="undefined"){u.unrender();continue}const g=u.render(t,o);g&&(g!==o&&(this.children_.push(g),o=g),r.push(d))}this.declutter(t,r),ff(this.element_,this.children_);const l=this.getMap().getTargetElement();if(Ti(l)){const h=l.getContext("2d");for(const c of this.children_){const d=c.firstElementChild||c,u=c.style.backgroundColor;if(u&&(!Ti(d)||d.width>0)&&(h.fillStyle=u,h.fillRect(0,0,l.width,l.height)),Ti(d)&&d.width>0){h.save();const f=c.style.opacity||d.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=d.style.transform;if(g)h.transform(...Qo(g));else{const p=parseFloat(d.style.width)/d.width,m=parseFloat(d.style.height)/d.height;h.transform(p,0,0,m,0,0)}h.drawImage(d,0,0),h.restore()}}}this.dispatchRenderEvent(Yt.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 ad(s){if(s instanceof Jr){s.setMapInternal(null);return}s instanceof Fn&&s.getLayers().forEach(ad)}function ld(s,t){if(s instanceof Jr){s.setMapInternal(t);return}if(s instanceof Fn){const e=s.getLayers().getArray();for(let i=0,n=e.length;i<n;++i)ld(e[i],t)}}let hd=class extends $e{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=am(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:df,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Ut(),this.pixelToCoordinateTransform_=Ut(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,Ee||(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,Ee||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(Ee?new pe:Wp()),this.interactions=e.interactions||(Ee?new pe:od({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new zp(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(se.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(se.VIEW,this.handleViewChanged_),this.addChangeListener(se.SIZE,this.handleSizeChanged_),this.addChangeListener(se.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof He)&&t.view.then(function(n){i.setView(new He(n))}),this.controls.addEventListener(fe.ADD,n=>{n.element.setMap(this)}),this.controls.addEventListener(fe.REMOVE,n=>{n.element.setMap(null)}),this.interactions.addEventListener(fe.ADD,n=>{n.element.setMap(this)}),this.interactions.addEventListener(fe.REMOVE,n=>{n.element.setMap(null)}),this.overlays_.addEventListener(fe.ADD,n=>{this.addOverlayInternal_(n.element)}),this.overlays_.addEventListener(fe.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){ld(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:vn,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 Fn?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:vn,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(se.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Jo(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?zt(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(se.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof pe){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=Re(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?zt(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(se.SIZE)}getView(){return this.get(se.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 $p(this.frameState_,t,e,i,n)}handleBrowserEvent(t,e){e=e||t.type;const i=new si(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===da.POINTERDOWN||i===nt.WHEEL||i===nt.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[jt.ANIMATING]||o[jt.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(Yt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Yt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new un(Ci.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new un(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)Tt(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(nt.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(nt.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!Ti(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(Ti(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new om(this)),!Ti(e)){this.mapBrowserEventHandler_=new Fp(this,this.moveTolerance_);for(const n in Ct)this.mapBrowserEventHandler_.addEventListener(Ct[n],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(nt.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(nt.WHEEL,this.boundHandleBrowserEvent_,vc?{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_=[ft(i,nt.KEYDOWN,this.handleBrowserEvent,this),ft(i,nt.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_&&(Tt(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(Tt(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=ft(t,En.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=ft(t,nt.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(Tt),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Ei("addlayer",t)),this.layerGroupPropertyListenerKeys_=[ft(t,En.PROPERTYCHANGE,this.render,this),ft(t,nt.CHANGE,this.render,this),ft(t,"addlayer",this.handleLayerAdd_,this),ft(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){ad(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&&eh(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:Xo(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:K(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=Xo(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_||!bs(this.previousExtent_)&&!bn(r.extent,this.previousExtent_))&&(this.dispatchEvent(new un(Ci.MOVESTART,this,n)),this.previousExtent_=Ts(this.previousExtent_)),this.previousExtent_&&!r.viewHints[jt.ANIMATING]&&!r.viewHints[jt.INTERACTING]&&!bn(r.extent,this.previousExtent_)&&(this.dispatchEvent(new un(Ci.MOVEEND,this,r)),Bh(r.extent,this.previousExtent_))),this.dispatchEvent(new un(Ci.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Ci.LOADSTART)||this.hasListener(Ci.LOADEND)||this.hasListener(Yt.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 Ei("removelayer",e)),this.set(se.LAYERGROUP,t)}setSize(t){this.set(se.SIZE,t)}setTarget(t){this.set(se.TARGET,t)}setView(t){if(!t||t instanceof He){this.set(se.VIEW,t);return}this.set(se.VIEW,new He);const e=this;t.then(function(i){e.setView(new He(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,r;if(Ti(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)],!eh(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Xh("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!ui(e,i))&&(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};function am(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 Fn({layers:s.layers});e[se.LAYERGROUP]=i,e[se.TARGET]=s.target,e[se.VIEW]=s.view instanceof He?s.view:new He;let n;s.controls!==void 0&&(Array.isArray(s.controls)?n=new pe(s.controls.slice()):(gt(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 pe(s.interactions.slice()):(gt(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 pe(s.overlays.slice()):(gt(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new pe,{controls:n,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}var lm=class extends $e{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}},rl=class extends lm{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}},hm=class extends rl{constructor(t){t=t||{},super(t),this.element.className=("ol-ext-toggle-switch "+(t.className||"")).trim()}},cm=class extends rl{constructor(t){t=t||{},super(t),this.element.className=("ol-ext-check ol-ext-radio "+(t.className||"")).trim()}},st={};st.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)st.create("OPTION",{html:n,value:t.options[n],parent:e});break}case"style":{st.setStyle(e,t.style);break}case"change":case"click":{st.addListener(e,i,t[i]);break}case"on":{for(var r in t.on)st.addListener(e,r,t.on[r]);break}case"checked":{e.checked=!!t.checked;break}default:{e.setAttribute(i,t[i]);break}}}return e};st.createSwitch=function(s){var t=st.create("INPUT",{type:"checkbox",on:s.on,click:s.click,change:s.change,parent:s.parent}),e=Object.assign({input:t},s||{});return new hm(e),t};st.createCheck=function(s){var t=st.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 cm(e):new rl(e),t};st.setHTML=function(s,t){t instanceof Element?s.appendChild(t):t!==void 0&&(s.innerHTML=t)};st.appendText=function(s,t){s.appendChild(document.createTextNode(t||""))};st.addListener=function(s,t,e,i){typeof t=="string"&&(t=t.split(" ")),t.forEach(function(n){s.addEventListener(n,e,i)})};st.removeListener=function(s,t,e){typeof t=="string"&&(t=t.split(" ")),t.forEach(function(i){s.removeEventListener(i,e)})};st.show=function(s){s.style.display=""};st.hide=function(s){s.style.display="none"};st.hidden=function(s){return st.getStyle(s,"display")==="none"};st.toggle=function(s){s.style.display=s.style.display==="none"?"":"none"};st.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]}};st.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};st.outerHeight=function(s){return s.offsetHeight+st.getStyle(s,"marginBottom")};st.outerWidth=function(s){return s.offsetWidth+st.getStyle(s,"marginLeft")};st.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}};st.getFixedOffset=function(s){var t={left:0,top:0},e=function(i){if(!i)return t;if(st.getStyle(i,"position")==="absolute"&&st.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)};st.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)};st.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,d,u=0,f=function(){E&&(u++,setTimeout(g))},g=function(){if(E){if(u--,u)return;var _=s.clientHeight,b=s.scrollHeight;c=_/b,E.style.height=c*100+"%",E.style.top=s.scrollTop/b*100+"%",w.style.height=_+"px",_>b-.5?w.classList.add("ol-100pc"):w.classList.remove("ol-100pc")}},p=function(_){_.target.classList.contains("ol-noscroll")||(h=!1,e=_[a],r=new Date,s.classList.add("ol-move"),_.preventDefault(),window.addEventListener("pointermove",m),st.addListener(window,["pointerup","pointercancel"],C))},m=function(_){if(e!==!1){var b=(d?-1/c:1)*(e-_[a]);h=h||Math.round(b),s[l]+=b,n=new Date,n-r&&(i=(i+b/(n-r))/2),e=_[a],r=n,b&&o(!0)}else h=!0},y=function(_){var b=_>0?Math.min(100,_/2):Math.max(-100,_/2);_-=b,s[l]+=b,-1<_&&_<1?(h?setTimeout(function(){s.classList.remove("ol-move")}):s.classList.remove("ol-move"),h=!1,o(!1)):setTimeout(function(){y(_)},40)},w,E;if(t.vertical&&t.minibar){var x=function(_){s.removeEventListener("pointermove",x),s.parentNode.classList.add("ol-miniscroll"),E=st.create("DIV"),w=st.create("DIV",{className:"ol-scroll",html:E}),s.parentNode.insertBefore(w,s),E.addEventListener("pointerdown",function(b){d=!0,p(b)}),t.mousewheel&&(st.addListener(w,["mousewheel","DOMMouseScroll","onmousewheel"],function(b){T(b)}),st.addListener(E,["mousewheel","DOMMouseScroll","onmousewheel"],function(b){T(b)})),s.parentNode.addEventListener("pointerenter",f),window.addEventListener("resize",f),_!==!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"),st.addListener(s,["pointerdown"],function(_){d=!1,p(_)}),s.addEventListener("click",function(_){s.classList.contains("ol-move")&&(_.preventDefault(),_.stopPropagation())},!0);var C=function(_){r=new Date-r,r>100||d?i=0:r>0&&(i=((i||0)+(e-_[a])/r)/2),y(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)),d=!1,window.removeEventListener("pointermove",m),st.removeListener(window,["pointerup","pointercancel"],C)},T=function(_){var b=Math.max(-1,Math.min(1,_.wheelDelta||-_.detail));return s.classList.add("ol-move"),s[l]-=b*30,s.classList.remove("ol-move"),!1};return t.mousewheel&&st.addListener(s,["mousewheel","DOMMouseScroll","onmousewheel"],T),{refresh:f}};st.dispatchEvent=function(s,t){var e;try{e=new CustomEvent(s)}catch{e=document.createEvent("CustomEvent"),e.initCustomEvent(s,!0,!0,{})}t.dispatchEvent(e)};st.setCursor=function(s,t){s instanceof hd&&(s=s.getTargetElement()),!("ontouchstart"in window)&&s instanceof Element&&(s.style.cursor=t)};var _e=class extends Ki{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 pe,this.handles_=new pe,this.overlayLayer_=new bt({source:new Y({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_&&st.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 G({color:[255,0,0,1],width:1}),i=t.stroke||new G({color:[255,0,0,1],width:1,lineDash:[4,4]}),n=t.fill||new j({color:[255,0,0,.01]}),r=t.pointFill||new j({color:[255,255,255,.8]}),o=new Bi({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 Bi({fill:r,stroke:e,radius:this.isTouch?16:8,points:4,angle:Math.PI/4}),l=new Bi({fill:r,stroke:e,radius:this.isTouch?12:6,points:4,angle:Math.PI/4});function h(c,d,u){return[new A({image:c,stroke:d,fill:u})]}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=An(a,this.get("buffer")),this.selection_.forEach((function(p){var m=this.getGeometryRotateToZero_(p).getExtent();ss(a,m)}).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 V({geometry:new rt(this.center_),handle:"rotate0"})),n=gn(a),this.get("enableRotatedTransform")&&o!==0&&n.rotate(o,this.getMap().getView().getCenter()),i=this.bbox_=new V(n),this.overlayLayer_.getSource().addFeature(i));else{if(this.ispt_){var c=this.getMap().getPixelFromCoordinate(be(a));if(c){var d=h&&h[0]||10,u=h&&h[1]||10;a=mr([this.getMap().getCoordinateFromPixel([c[0]-d,c[1]-u]),this.getMap().getCoordinateFromPixel([c[0]+d,c[1]+u])])}}n=r?new it([l]):gn(a),this.get("enableRotatedTransform")&&o!==0&&n.rotate(o,this.getMap().getView().getCenter()),i=this.bbox_=new V(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 V({geometry:new rt([(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 V({geometry:new rt(g[e]),handle:"scale",option:e}),f.push(i);this.get("translate")&&!this.get("translateFeature")&&(i=new V({geometry:new rt([(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 V({geometry:new rt(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){Gh(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=oe(),o=oe();this.hasChanged_=!1;for(var a=0,l;l=this.selection_.item(a);a++)if(this.geoms_.push(l.getGeometry().clone()),r=ss(r,l.getGeometry().getExtent()),this.get("enableRotatedTransform")&&n!==0){var h=this.getGeometryRotateToZero_(l,!0);this.rotatedGeoms_.push(h),o=ss(o,h.getExtent())}if(this.extent_=gn(r).getCoordinates()[0],this.get("enableRotatedTransform")&&n!==0&&(this.rotatedExtent_=gn(o).getCoordinates()[0]),this.mode_==="rotate"){this.center_=this.getCenter()||be(r);var c=t.map.getTargetElement();st.setCursor(c,this.Cursors.rotate0),this.previousCursor_=c.style.cursor}else this.center_=be(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 d=this.selection_.getArray().indexOf(i);d<0?this.selection_.push(i):this.selection_.removeAt(d)}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],d=l[1]-a[1];for(i=0,r;r=this.selection_.item(i);i++)r.getGeometry().translate(c,d);this.handles_.forEach(function(P){P.getGeometry().translate(c,d)}),this.coordinate_=t.coordinate,this.dispatchEvent({type:"translating",feature:this.selection_.item(0),features:this.selection_,delta:[c,d],pixel:t.pixel,coordinate:t.coordinate});break}case"scale":{var u=this.center_;if(this.get("modifyCenter")(t)){var f=this.extent_;this.get("enableRotatedTransform")&&e!==0&&(f=this.rotatedExtent_),u=f[(Number(this.opt_)+2)%4]}var g=this.geoms_.length==1&&this._isRectangle(this.geoms_[0]),p=this.constraint_,m=this.opt_,y=this.coordinate_,w=t.coordinate;if(this.get("enableRotatedTransform")&&e!==0){var E=new rt(this.coordinate_);E.rotate(e*-1,u),y=E.getCoordinates();var x=new rt(t.coordinate);x.rotate(e*-1,u),w=x.getCoordinates()}var C=(w[0]-u[0])/(y[0]-u[0]),T=(w[1]-u[1])/(y[1]-u[1]),_=[w[0]-y[0],w[1]-y[1]];if(this.get("enableRotatedTransform")&&e!==0){var b=new rt(u);b.rotate(e*-1,this.getMap().getView().getCenter()),u=b.getCoordinates()}this.get("noFlip")&&(C<0&&(C=-C),T<0&&(T=-T)),this.constraint_?this.constraint_=="h"?C=1:T=1:this.get("keepAspectRatio")(t)&&(C=T=Math.min(C,T));var S=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(P,L,k){if(k<2)return L;if(g){var F=[[6],[0,8],[2],[4]],O=[P[0],P[1]],R=[P[2],P[3]],B=[P[4],P[5]],D=[P[6],P[7]],z=[P[8],P[9]];if(p){var N=m%2===0?this._countVector(O,R):this._countVector(D,O),tt=this._projectVectorOnVector(_,N),et=m+1<F.length?m+1:0,ht=[...F[m],...F[et]];for(n=0;n<P.length;n+=k)L[n]=ht.includes(n)?P[n]+tt[0]:P[n],L[n+1]=ht.includes(n)?P[n+1]+tt[1]:P[n+1]}else{var ot,I,xt;switch(m){case 0:S?(xt=this._snapToDiagonal(D,R,w),_=this._countVector(D,xt)):_=this._countVector(D,w),ot=this._projectVectorOnVector(_,this._countVector(B,D)),I=this._projectVectorOnVector(_,this._countVector(O,D)),[L[0],L[1]]=this._movePoint(O,ot),[L[4],L[5]]=this._movePoint(B,I),[L[6],L[7]]=this._movePoint(D,_),[L[8],L[9]]=this._movePoint(z,ot);break;case 1:S?(xt=this._snapToDiagonal(O,B,w),_=this._countVector(O,xt)):_=this._countVector(O,w),ot=this._projectVectorOnVector(_,this._countVector(D,O)),I=this._projectVectorOnVector(_,this._countVector(R,O)),[L[0],L[1]]=this._movePoint(O,_),[L[2],L[3]]=this._movePoint(R,ot),[L[6],L[7]]=this._movePoint(D,I),[L[8],L[9]]=this._movePoint(z,_);break;case 2:S?(xt=this._snapToDiagonal(R,D,w),_=this._countVector(R,xt)):_=this._countVector(R,w),ot=this._projectVectorOnVector(_,this._countVector(O,R)),I=this._projectVectorOnVector(_,this._countVector(B,R)),[L[0],L[1]]=this._movePoint(O,I),[L[2],L[3]]=this._movePoint(R,_),[L[4],L[5]]=this._movePoint(B,ot),[L[8],L[9]]=this._movePoint(z,I);break;case 3:S?(xt=this._snapToDiagonal(B,O,w),_=this._countVector(B,xt)):_=this._countVector(B,w),ot=this._projectVectorOnVector(_,this._countVector(R,B)),I=this._projectVectorOnVector(_,this._countVector(D,B)),[L[2],L[3]]=this._movePoint(R,I),[L[4],L[5]]=this._movePoint(B,_),[L[6],L[7]]=this._movePoint(D,ot);break}}}else for(n=0;n<P.length;n+=k)C!=1&&(L[n]=u[0]+(P[n]-u[0])*C),T!=1&&(L[n+1]=u[1]+(P[n+1]-u[1])*T);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:[C,T],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),st.setCursor(i,n)}else this.previousCursor_!==void 0&&st.setCursor(i,this.previousCursor_),this.previousCursor_=void 0}}handleUpEvent_(t){if(this.mode_==="rotate"){var e=t.map.getTargetElement();st.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]}};_e.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"};var Oe=(s=>(s.WGS84="wgs84",s.GCJ02="gcj02",s.BD09="bd09",s.WEB_MERCATOR="web_mercator",s))(Oe||{}),dt=(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.CUSTOMIZE="customize",s))(dt||{}),Z=(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.FREEHAND_DRAW="freehand-draw",s.ELLIPSE_DRAW="ellipse-draw",s.MARKER_DRAW="marker-draw",s.TEXT_DRAW="text-draw",s.IMAGE_DRAW="image-draw",s.ARROW_DRAW="arrow-draw",s.LINE_DRAW="line-draw",s.BEZIER_DRAW="bezier-draw",s.SECTOR_DRAW="sector-draw",s.POINT_COORDINATE_PICK="point-coordinate-pick",s.LINE_COORDINATE_PICK="line-coordinate-pick",s.POLYGON_COORDINATE_PICK="polygon-coordinate-pick",s))(Z||{}),qt=(s=>(s.DATA_LAYER="data_layer",s.DRAW_LAYER="draw_layer",s.TOOL_LAYER="tool_layer",s))(qt||{}),H=(s=>(s.SQUARE="square",s.CIRCLE="circle",s.TRIANGLE="triangle",s.PENTAGRAM="pentagram",s.TEXT="text",s.DIAMOND="diamond",s.CROSS="cross",s.X_SHAPE="x_shape",s.HEXAGON="hexagon",s.FLAG="flag",s.HOUSE="house",s.ARROW="arrow",s.TENT="tent",s.BUNKER="bunker",s.LANDMINE="landmine",s.TANK="tank",s.PLANE="plane",s.SHIP="ship",s.RADAR="radar",s.MISSILE="missile",s.FIRE_HYDRANT="fire_hydrant",s.FIRST_AID="first_aid",s.WATER_TOWER="water_tower",s.GENERATOR="generator",s.MEGAPHONE="megaphone",s.STREET_LAMP="street_lamp",s.PARKING="parking",s.GAS_STATION="gas_station",s.TUNNEL="tunnel",s.BRIDGE="bridge",s.TRAFFIC_LIGHT="traffic_light",s.CAMERA="camera",s.TOILET="toilet",s.TRASH_CAN="trash_can",s.BUS_STOP="bus_stop",s.SUBWAY="subway",s.SCHOOL="school",s.HOSPITAL="hospital",s.TREE="tree",s.WATER_SOURCE="water_source",s.MOUNTAIN="mountain",s.MINE="mine",s.HEART="heart",s.STAR="star",s.CLOUD="cloud",s.GEAR="gear",s.LIGHTNING="lightning",s.PIN="pin",s.COMPASS="compass",s.ANCHOR="anchor",s))(H||{}),_n=(s=>(s.PULSE="pulse",s.FLASHING="flashing",s.BREATHING="breathing",s.LIGHT="light",s))(_n||{});function Vt(s=""){return`${s}${Date.now()}_${Math.random().toString(36).substr(2,8)}`}function M(s){return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]??1})`}const dm={linePick:{default_name:"线拾取",label_prefix:"线",highlight_text:"● 线拾取 ●"},pointPick:{default_name:"点拾取",label_text:"坐标拾取"},polygonPick:{default_name:"面拾取",label_prefix:"面",highlight_text:"● 面拾取 ●"},featureType:"要素类型",properties:"属性",freehandDrawLayer:"手绘线图层",ellipseDrawLayer:"椭圆绘制图层",markerDrawLayer:"标记点图层",textDrawLayer:"文字标注图层",imageDrawLayer:"图片标注图层",arrowDrawLayer:"箭头绘制图层",lineDrawLayer:"线段绘制图层",bezierDrawLayer:"贝塞尔曲线图层",sectorDrawLayer:"扇形绘制图层",pointPickLayer:"点坐标拾取图层",linePickLayer:"线坐标拾取图层",polygonPickLayer:"面坐标拾取图层",dataLayers:"数据图层",drawLayers:"绘图图层",toolLayers:"工具图层",pleaseEnterText:"请输入文字",longitude:"经度",latitude:"纬度",confirm:"确定",addImage:"添加图片",imageUrl:"图片URL",uploadImage:"上传图片",width:"宽度",height:"高度",opacity:"透明度",delete:"删除",drawImage:"图片标注",drawCoordinatePick:"坐标拾取",coordinatePick:"坐标拾取",coordinateList:"坐标列表",noCoordinates:"暂无拾取坐标",clearAll:"清空全部",drawLine:"线段",drawBezier:"贝塞尔曲线",drawSector:"扇形",drawFreehandLine:"手绘线",drawFreehandPolygon:"手绘多边形",drawEllipse:"椭圆",drawMarker:"标记点",drawText:"文字标注",drawArrow:"箭头",circleDrawLayer:"圆形绘制图层",rectangleDrawLayer:"矩形绘制图层",triangleDrawLayer:"三角形绘制图层",distanceMeasurementLayer:"距离测量图层",areaMeasurementLayer:"面积测量图层",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:"暂无测量数据",cancel:"取消",drawRectangle:"绘制矩形",drawTriangle:"绘制三角形",editShape:"编辑图形",pointData:"点数据",lineData:"线数据",polygonData:"面数据",coordinateData:"坐标数据",details:"详情",copyCoordinates:"复制坐标",locateOnMap:"在地图上定位",startPoint:"起点坐标",endPoint:"终点坐标",vertexCount:"顶点数量",createdTime:"创建时间",noDataAvailable:"暂无数据",pleaseUseCoordinatePickTool:"暂无数据,请先使用坐标拾取工具",coordinatesCopied:"已复制坐标到剪贴板",locatedToPoint:"已定位到",locatedToLine:"已定位到线,包含",locatedToPolygon:"已定位到面,包含",allCoordinatesCleared:"已清除所有坐标拾取数据",noCoordinateData:"暂无拾取坐标数据",copyAllPointCoordinates:"点击确定复制全部点坐标",pointPickSuccess:"已拾取点坐标",linePickSuccess:"已拾取线坐标,共",polygonPickSuccess:"已拾取面坐标,共",drawingStatusCancelHint:"按 ESC 取消绘制",editingText:"编辑文字",fontSize:"字号",color:"颜色",bold:"粗体",italic:"斜体",imagePreview:"预览",noImage:"暂无图片",imageLoadFailed:"图片加载失败",image:"图片",cancelDrawing:"取消绘制",drawingRectangle:"正在绘制矩形",drawingTriangle:"正在绘制三角形",drawingFreehand:"正在手绘线",drawingFreehandPolygon:"正在手绘多边形",drawingEllipse:"正在绘制椭圆",addingMarker:"添加标记点",addingText:"添加文字标注",drawingArrow:"正在绘制箭头",drawingLine:"正在绘制线段",drawingBezier:"正在绘制贝塞尔曲线",drawingSector:"正在绘制扇形",drawing:"正在绘制",pressEscToCancel:" (按 ESC 取消绘制)",clickMapToPickPoint:"点击地图拾取点坐标 (单击完成拾取)",clickMapToDrawLine:"点击地图绘制线 (双击完成拾取)",clickMapToDrawPolygon:"点击地图绘制面 (双击完成拾取)",doubleClickToFinishPick:"双击完成拾取",editText:"编辑文字",strokeWidth:"线宽",strokeStyle:"线型",dragToMove:"拖动移动",noImagePreview:"暂无图片",uploadFromComputer:"从电脑上传",enterImageUrl:"输入图片URL",deleteImage:"删除图片",cancelEdit:"取消编辑",save:"保存",ok:"确定",lineTool:"线段",arrowTool:"箭头",bezierTool:"贝塞尔曲线",ellipseTool:"椭圆",rectangleTool:"矩形",triangleTool:"三角形",sectorTool:"扇形",freehandTool:"手绘线",freehandPolygonTool:"手绘多边形",markerTool:"标记点",textTool:"文字标注",imageTool:"图片标注",points:"个点",pointsCount:"个",featureNotFound:"未找到要素",cannotGetMapTarget:"无法获取地图容器元素",cannotGetPixelFromCoordinate:"无法从坐标获取像素位置",bezierFeatureNotFound:"未找到贝塞尔曲线要素",noSourceAvailable:"没有可用的数据源"},um={linePick:{default_name:"Line Pick",label_prefix:"Line",highlight_text:"● Line Pick ●"},pointPick:{default_name:"Point Pick",label_text:"Coordinate Pick"},polygonPick:{default_name:"Polygon Pick",label_prefix:"Polygon",highlight_text:"● Polygon Pick ●"},featureType:"Feature Type",properties:"Properties",freehandDrawLayer:"Freehand Draw Layer",ellipseDrawLayer:"Ellipse Draw Layer",markerDrawLayer:"Marker Draw Layer",textDrawLayer:"Text Draw Layer",imageDrawLayer:"Image Draw Layer",arrowDrawLayer:"Arrow Draw Layer",lineDrawLayer:"Line Draw Layer",bezierDrawLayer:"Bezier Curve Layer",sectorDrawLayer:"Sector Draw Layer",pointPickLayer:"Point Pick Layer",linePickLayer:"Line Pick Layer",polygonPickLayer:"Polygon Pick Layer",dataLayers:"Data Layers",drawLayers:"Draw Layers",toolLayers:"Tool Layers",pleaseEnterText:"Please enter text",longitude:"Longitude",latitude:"Latitude",confirm:"OK",addImage:"Add Image",imageUrl:"Image URL",uploadImage:"Upload Image",width:"Width",height:"Height",opacity:"Opacity",delete:"Delete",drawImage:"Image",drawCoordinatePick:"Coordinate Pick",coordinatePick:"Coordinate Pick",coordinateList:"Coordinate List",noCoordinates:"No coordinates picked",clearAll:"Clear All",drawLine:"Line",drawBezier:"Bezier Curve",drawSector:"Sector",drawFreehandLine:"Freehand Line",drawFreehandPolygon:"Freehand Polygon",drawEllipse:"Ellipse",drawMarker:"Marker",drawText:"Text Label",drawArrow:"Arrow",circleDrawLayer:"Circle Draw Layer",rectangleDrawLayer:"Rectangle Draw Layer",triangleDrawLayer:"Triangle Draw Layer",distanceMeasurementLayer:"Distance Measurement Layer",areaMeasurementLayer:"Area Measurement Layer",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",cancel:"Cancel",drawRectangle:"Draw Rectangle",drawTriangle:"Draw Triangle",editShape:"Edit Shape",pointData:"Points",lineData:"Lines",polygonData:"Polygons",coordinateData:"Coordinate Data",details:"Details",copyCoordinates:"Copy Coordinates",locateOnMap:"Locate on Map",startPoint:"Start Point",endPoint:"End Point",vertexCount:"Vertex Count",createdTime:"Created Time",noDataAvailable:"No data available",pleaseUseCoordinatePickTool:"No data available, please use coordinate pick tool first",coordinatesCopied:"Coordinates copied to clipboard",locatedToPoint:"Located to",locatedToLine:"Located to line with",locatedToPolygon:"Located to polygon with",allCoordinatesCleared:"All coordinate picks cleared",noCoordinateData:"No coordinate data",copyAllPointCoordinates:"Click OK to copy all point coordinates",pointPickSuccess:"Point picked",linePickSuccess:"Line picked with",polygonPickSuccess:"Polygon picked with",drawingStatusCancelHint:"Press ESC to cancel drawing",editingText:"Edit Text",fontSize:"Font Size",color:"Color",bold:"Bold",italic:"Italic",imagePreview:"Preview",noImage:"No image",imageLoadFailed:"Image load failed",image:"Image",cancelDrawing:"Cancel Drawing",drawingRectangle:"Drawing Rectangle",drawingTriangle:"Drawing Triangle",drawingFreehand:"Drawing Freehand Line",drawingFreehandPolygon:"Drawing Freehand Polygon",drawingEllipse:"Drawing Ellipse",addingMarker:"Adding Marker",addingText:"Adding Text Label",drawingArrow:"Drawing Arrow",drawingLine:"Drawing Line",drawingBezier:"Drawing Bezier Curve",drawingSector:"Drawing Sector",drawing:"Drawing",pressEscToCancel:" (Press ESC to cancel)",clickMapToPickPoint:"Click map to pick point (Click to finish)",clickMapToDrawLine:"Click map to draw line (Double click to finish)",clickMapToDrawPolygon:"Click map to draw polygon (Double click to finish)",doubleClickToFinishPick:"Double click to finish",editText:"Edit Text",strokeWidth:"Stroke Width",strokeStyle:"Stroke Style",dragToMove:"Drag to move",noImagePreview:"No image preview",uploadFromComputer:"Upload from computer",enterImageUrl:"Enter image URL",deleteImage:"Delete image",cancelEdit:"Cancel",save:"Save",ok:"OK",lineTool:"Line",arrowTool:"Arrow",bezierTool:"Bezier Curve",ellipseTool:"Ellipse",rectangleTool:"Rectangle",triangleTool:"Triangle",sectorTool:"Sector",freehandTool:"Freehand Line",freehandPolygonTool:"Freehand Polygon",markerTool:"Marker",textTool:"Text",imageTool:"Image",points:"points",pointsCount:"",featureNotFound:"Feature not found",cannotGetMapTarget:"Cannot get map target element",cannotGetPixelFromCoordinate:"Cannot get pixel from coordinate",bezierFeatureNotFound:"Bezier feature not found",noSourceAvailable:"No source available"},Hi=s=>s==="zh"?dm:um;class fm extends It{constructor(t,e,i,n){super(t,e,Z.FREEHAND_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||[76,175,80,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[76,175,80,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||3,this.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:r=>this.getStyleForFeature(r),properties:{id:t,name:e,type:Z.FREEHAND_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t}getStyleForFeature(t){const e=t?.get("isPolygon")||!1,i=t?.get("fillColor")||this.defaultFillColor,n=t?.get("outlineColor")||this.defaultOutlineColor,r=t?.get("outlineWidth")||this.defaultOutlineWidth,a=(t?.get("outlineStyle")||this.defaultOutlineStyle)==="dashed"?[10,10]:void 0;return e?new A({fill:new j({color:M(i)}),stroke:new G({color:M(n),width:r,lineDash:a})}):new A({stroke:new G({color:M(n),width:r,lineDash:a})})}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startDraw(t,e){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=e||null;const i=new Y,n=new A({stroke:new G({color:M(this.defaultOutlineColor),width:this.defaultOutlineWidth,lineDash:this.defaultOutlineStyle==="dashed"?[10,10]:void 0}),fill:new j({color:M(this.defaultFillColor)})});this.drawInteraction=new ee({source:i,type:t?"Polygon":"LineString",style:n}),this.drawInteraction.on("drawend",r=>{const o=r.feature.clone(),a=o.getGeometry(),l=Vt("freehand_"),h=a instanceof it;let c=[];if(a instanceof pt){const d=a.getCoordinates();for(let u=0;u<d.length;u++){const[f,g]=U(d[u]);c.push([f,g])}}else if(a instanceof it){const d=a.getCoordinates()[0];for(let u=0;u<d.length-1;u++){const[f,g]=U(d[u]);c.push([f,g])}}i.clear(),o.setId(l),o.set("id",l),o.set("isPolygon",h),o.set("points",c),o.set("fillColor",this.defaultFillColor),o.set("outlineColor",this.defaultOutlineColor),o.set("outlineWidth",this.defaultOutlineWidth),o.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(o),this.features.set(l,o),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:l,points:c,isPolygon:h,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle}),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.warn(this.t.featureNotFound,t);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(!a)return;let l=[];const h=i.get("isPolygon");if(a instanceof pt){const d=a.getCoordinates();for(let u=0;u<d.length;u++){const[f,g]=U(d[u]);l.push([f,g])}}else if(a instanceof it){const d=a.getCoordinates()[0];for(let u=0;u<d.length-1;u++){const[f,g]=U(d[u]);l.push([f,g])}}i.set("points",l),i.changed();const c=i.get("id");this.onEditCompleteCallback&&c&&this.onEditCompleteCallback({id:c,points:l,isPolygon:h,fillColor:i.get("fillColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth"),outlineStyle:i.get("outlineStyle")}),this.mapView?.render()};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addFreehand(t){if(!this.source){console.error(this.t.noSourceAvailable);return}const e=[];for(let r=0;r<t.points.length;r++){const o=t.points[r],[a,l]=ut(o);e.push([a,l])}let i;const n=t.id||Vt("freehand_");if(t.isPolygon&&e.length>=3){const r=[...e,e[0]],o=new it([r]);i=new V({geometry:o,id:n,isPolygon:!0,points:t.points})}else{const r=new pt(e);i=new V({geometry:r,id:n,isPolygon:!1,points:t.points})}i.set("fillColor",t.fillColor||this.defaultFillColor),i.set("outlineColor",t.outlineColor||this.defaultOutlineColor),i.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),i.set("outlineStyle",t.outlineStyle||this.defaultOutlineStyle),this.source.addFeature(i),this.features.set(n,i)}removeFreehand(t){const e=this.layer?.getSource();if(!e){console.error(this.t.noSourceAvailable);return}let i=this.features.get(t);i||(i=e.getFeatures().find(r=>r.get("id")===t)||null),i&&(e.removeFeature(i),this.features.delete(t),this.editingFeature===i&&this.stopEdit()),this.layer?.changed(),this.mapView&&this.mapView.render()}getAllFreehands(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,points:e.get("points"),isPolygon:e.get("isPolygon"),fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")})}),t}getFreehand(t){const e=this.features.get(t);if(!e)return;let i=e.get("points");if(!i||!Array.isArray(i)){const n=e.getGeometry();n instanceof pt?i=n.getCoordinates().map(o=>{const[a,l]=U(o);return[a,l]}):n instanceof it&&(i=n.getCoordinates()[0].slice(0,-1).map(o=>{const[a,l]=U(o);return[a,l]}))}return{id:t,points:i||[],isPolygon:e.get("isPolygon")||!1,fillColor:e.get("fillColor")||this.defaultFillColor,outlineColor:e.get("outlineColor")||this.defaultOutlineColor,outlineWidth:e.get("outlineWidth")||this.defaultOutlineWidth,outlineStyle:e.get("outlineStyle")||this.defaultOutlineStyle}}updateFreehandStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r),o.setStyle(void 0),o.changed(),this.mapView&&this.mapView.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.freehands&&(this.clearAll(),t.freehands.forEach(e=>this.addFreehand(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class gm extends It{constructor(t,e,i){super(t,e,Z.ELLIPSE_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||[156,39,176,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[156,39,176,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.ELLIPSE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("fillColor")||this.defaultFillColor,i=t?.get("outlineColor")||this.defaultOutlineColor,n=t?.get("outlineWidth")||this.defaultOutlineWidth,o=(t?.get("outlineStyle")||this.defaultOutlineStyle)==="dashed"?[10,10]:void 0;return new A({fill:new j({color:M(e)}),stroke:new G({color:M(i),width:n,lineDash:o})})}createEllipsePoints(t,e,i,n,r=64){const o=[];for(let a=0;a<=r;a++){const l=a/r*Math.PI*2,h=t[0]+e*Math.cos(l),c=t[1]+i*Math.sin(l),d=Math.cos(n),u=Math.sin(n),f=t[0]+(h-t[0])*d-(c-t[1])*u,g=t[1]+(h-t[0])*u+(c-t[1])*d;o.push([f,g])}return o}createEllipseGeometry(t,e,i,n){const r=this.createEllipsePoints(t,e,i,n);return new it([r])}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 Y;let i=null,n=null;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:2,geometryFunction:(r,o)=>{if(r.length===0)return i=null,n=null,o;if(r.length===1)return i=r[0],n=null,o||(o=new it([[[0,0],[0,0],[0,0],[0,0]]])),o;if(r.length>=2){i=r[0],n=r[1];const a=n[0]-i[0],l=n[1]-i[1],h=Math.abs(a)/2,c=Math.abs(l)/2,d=(i[0]+n[0])/2,u=(i[1]+n[1])/2,f=this.createEllipsePoints([d,u],h,c,0);o?o.setCoordinates([f]):o=new it([f])}return o},style:this.getStyleForFeature()}),this.drawInteraction.on("drawend",r=>{const o=r.feature.getGeometry(),a=Vt("ellipse_");if(o instanceof it&&i&&n){const l=n[0]-i[0],h=n[1]-i[1],c=Math.abs(l)/2,d=Math.abs(h)/2,u=(i[0]+n[0])/2,f=(i[1]+n[1])/2,[g,p]=U([u,f]),m=new V({geometry:o.clone(),id:a,center:[g,p],radiusX:c,radiusY:d,rotation:0});m.set("fillColor",this.defaultFillColor),m.set("outlineColor",this.defaultOutlineColor),m.set("outlineWidth",this.defaultOutlineWidth),m.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(m),this.features.set(a,m),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:a,center:[g,p],radiusX:c,radiusY:d,rotation:0,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}i=null,n=null,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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof it){const l=a.getExtent(),h=(l[0]+l[2])/2,c=(l[1]+l[3])/2,d=(l[2]-l[0])/2,u=(l[3]-l[1])/2,[f,g]=U([h,c]),p=i.get("id");this.onEditCompleteCallback&&p&&this.onEditCompleteCallback({id:p,center:[f,g],radiusX:d,radiusY:u,rotation:0})}};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addEllipse(t){const e=ut(t.center),i=[e[0],e[1]],n=this.createEllipsePoints(i,t.radiusX,t.radiusY,t.rotation),r=new it([n]),o=new V({geometry:r,id:t.id,center:t.center,radiusX:t.radiusX,radiusY:t.radiusY,rotation:t.rotation});o.set("fillColor",t.fillColor||this.defaultFillColor),o.set("outlineColor",t.outlineColor||this.defaultOutlineColor),o.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),o.set("outlineStyle",t.outlineStyle||this.defaultOutlineStyle),this.source?.addFeature(o),this.features.set(t.id,o)}removeEllipse(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllEllipses(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,center:e.get("center"),radiusX:e.get("radiusX"),radiusY:e.get("radiusY"),rotation:e.get("rotation")||0,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")})}),t}getEllipse(t){const e=this.features.get(t);if(e)return{id:t,center:e.get("center"),radiusX:e.get("radiusX"),radiusY:e.get("radiusY"),rotation:e.get("rotation")||0,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")}}updateEllipseStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r),o.setStyle(this.getStyleForFeature(o)),o.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.ellipses&&(this.clearAll(),t.ellipses.forEach(e=>this.addEllipse(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class pm extends It{constructor(t,e,i){super(t,e,Z.MARKER_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.defaultColor=i?.defaultColor||[255,87,34,1],this.defaultSize=i?.defaultSize||10,this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.MARKER_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("color")||this.defaultColor,i=t?.get("size")||this.defaultSize;return new A({image:new Le({radius:i/2,fill:new j({color:M(e)}),stroke:new G({color:"#fff",width:2})})})}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 Y;this.drawInteraction=new ee({source:e,type:"Point"}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry(),r=Vt("marker_");if(n instanceof rt){const[o,a]=n.getCoordinates(),[l,h]=U([o,a]),c=new V({geometry:n.clone(),id:r,position:[l,h]});c.set("color",this.defaultColor),c.set("size",this.defaultSize),this.source?.addFeature(c),this.features.set(r,c),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:r,position:[l,h],color:this.defaultColor,size:this.defaultSize})}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!1,rotate:!1}),this.transformInteraction.setActive(!0),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof rt){const[a,l]=o.getCoordinates(),[h,c]=U([a,l]),d=i.get("id");this.onEditCompleteCallback&&d&&this.onEditCompleteCallback({id:d,position:[h,c]}),i.set("position",[h,c])}}),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addMarker(t){const e=ut(t.position),i=new V({geometry:new rt(e),id:t.id,position:t.position});i.set("color",t.color||this.defaultColor),i.set("size",t.size||this.defaultSize),i.set("title",t.title||""),i.set("description",t.description||""),this.source?.addFeature(i),this.features.set(t.id,i)}removeMarker(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllMarkers(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,position:e.get("position"),title:e.get("title"),description:e.get("description"),color:e.get("color"),size:e.get("size")})}),t}getMarker(t){const e=this.features.get(t);if(e)return{id:t,position:e.get("position"),title:e.get("title"),description:e.get("description"),color:e.get("color"),size:e.get("size")}}updateMarkerStyle(t,e,i){const n=this.features.get(t);n&&(n.set("color",e),n.set("size",i),n.changed(),this.mapView?.render())}updateMarkerInfo(t,e,i){const n=this.features.get(t);n&&(n.set("title",e),n.set("description",i))}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.markers&&(this.clearAll(),t.markers.forEach(e=>this.addMarker(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class mm{constructor(t,e){this.isBold=!1,this.isItalic=!1,this.PRESET_FONT_SIZES=[12,14,16,18,20,24,28,32,36,42],this.options=t,this.currentColor=t.initialColor||[255,255,255,1],this.isBold=t.initialFontWeight==="bold",this.isItalic=t.initialFontStyle==="italic",this.overlay=this.createOverlay(),this.element=this.createElement(),document.body.appendChild(this.overlay),document.body.appendChild(this.element),e?this.setPosition(e):this.centerModal(),this.textarea=this.element.querySelector(".text-input-modal-textarea"),this.fontSizeSelect=this.element.querySelector(".text-input-modal-font-size"),this.colorPreview=this.element.querySelector(".text-input-modal-color-preview"),this.colorPicker=this.element.querySelector(".text-input-modal-color-picker"),this.boldBtn=this.element.querySelector(".text-input-modal-bold"),this.italicBtn=this.element.querySelector(".text-input-modal-italic"),this.confirmBtn=this.element.querySelector(".text-input-modal-confirm"),this.cancelBtn=this.element.querySelector(".text-input-modal-cancel"),this.deleteBtn=this.element.querySelector(".text-input-modal-delete"),this.header=this.element.querySelector(".text-input-modal-header"),this.toolbar=this.element.querySelector(".text-input-modal-toolbar"),this.footer=this.element.querySelector(".text-input-modal-footer"),this.bindEvents(),this.updateColorPreview(),this.updateStyleButtons(),this.updateTextareaStyle(),this.focusTextarea()}createOverlay(){const t=document.createElement("div");return t.className="text-input-modal-overlay",t.style.cssText=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Gh{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)}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 It=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 En={PROPERTYCHANGE:"propertychange"};function kn(s){for(const t in s)delete s[t]}function Wi(s){let t;for(t in s)return!1;return!t}function ft(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 mr(s,t,e,i){return ft(s,t,e,i,!0)}function Tt(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),kn(s))}const nt={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class vs{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Jd(s,t,e){let i,n;e=e||ai;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 ai(s,t){return s>t?1:s<t?-1:0}function Qd(s,t){return s<t?1:s>t?-1:0}function xa(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 tu(s,t,e){for(;t<e;){const i=s[t];s[t]=s[e],s[e]=i,++t,--e}}function je(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 ui(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 eu(s,t,e){const i=t||ai;return s.every(function(n,r){if(r===0)return!0;const o=i(s[r-1],n);return!(o>0||o===0)})}function vn(){return!0}function Rn(){return!1}function ds(){}function Bh(s){let t,e,i;return function(){const n=Array.prototype.slice.call(arguments);return(!e||this!==i||!ui(n,e))&&(i=this,e=n,t=s.apply(this,arguments)),t}}function iu(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 qe{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Or extends vs{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 qe(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,ds);delete o[i]}return l}disposeInternal(){this.listeners_&&kn(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]=ds,++this.pendingRemovals_[t]):(i.splice(n,1),i.length===0&&delete this.listeners_[t]))}}class Ts extends Or{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(nt.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]=ft(this,t[r],e);return n}return ft(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]=mr(this,t[r],e)}else i=mr(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)Wh(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)}}Ts.prototype.on;Ts.prototype.once;Ts.prototype.un;function Wh(s){if(Array.isArray(s))for(let t=0,e=s.length;t<e;++t)Tt(s[t]);else Tt(s)}function Q(){throw new Error("Unimplemented abstract method.")}let nu=0;function K(s){return s.ol_uid||(s.ol_uid=String(++nu))}class Ml extends qe{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class $e extends Ts{constructor(t){super(),this.on,this.once,this.un,K(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new Ml(i,t,e)),i=En.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new Ml(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],Wi(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}function gt(s,t){if(!s)throw new Error(t)}class V extends $e{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 V,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_&&(Tt(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=ft(t,nt.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?su(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 su(s){if(typeof s=="function")return s;let t;return Array.isArray(s)?t=s:(gt(typeof s.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[s]),function(){return t}}const Xt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function yr(s){const t=oe();for(let e=0,i=s.length;e<i;++e)rs(t,s[e]);return t}function An(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 Uh(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s.slice()}function Xi(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 Tn(s,t){return Ca(s,t[0],t[1])}function Yn(s,t){return s[0]<=t[0]&&t[2]<=s[2]&&s[1]<=t[1]&&t[3]<=s[3]}function Ca(s,t,e){return s[0]<=t&&t<=s[2]&&s[1]<=e&&e<=s[3]}function Ho(s,t){const e=s[0],i=s[1],n=s[2],r=s[3],o=t[0],a=t[1];let l=Xt.UNKNOWN;return o<e?l=l|Xt.LEFT:o>n&&(l=l|Xt.RIGHT),a<i?l=l|Xt.BELOW:a>r&&(l=l|Xt.ABOVE),l===Xt.UNKNOWN&&(l=Xt.INTERSECTING),l}function oe(){return[1/0,1/0,-1/0,-1/0]}function di(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 bs(s){return di(1/0,1/0,-1/0,-1/0,s)}function Ea(s,t){const e=s[0],i=s[1];return di(e,i,e,i,t)}function va(s,t,e,i,n){const r=bs(n);return Vh(r,s,t,e,i)}function bn(s,t){return s[0]==t[0]&&s[2]==t[2]&&s[1]==t[1]&&s[3]==t[3]}function ss(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 rs(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 Vh(s,t,e,i,n){for(;e<i;e+=n)ru(s,t[e],t[e+1]);return s}function ru(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 Ta(s,t){let e;return e=t(zr(s)),e||(e=t($r(s)),e)||(e=t(Nr(s)),e)||(e=t(ji(s)),e)?e:!1}function Xo(s){let t=0;return Ss(s)||(t=Et(s)*he(s)),t}function zr(s){return[s[0],s[1]]}function $r(s){return[s[2],s[1]]}function be(s){return[(s[0]+s[2])/2,(s[1]+s[3])/2]}function ou(s,t){let e;if(t==="bottom-left")e=zr(s);else if(t==="bottom-right")e=$r(s);else if(t==="top-left")e=ji(s);else if(t==="top-right")e=Nr(s);else throw new Error("Invalid corner");return e}function jo(s,t,e,i,n){const[r,o,a,l,h,c,d,u]=Hh(s,t,e,i);return di(Math.min(r,a,h,d),Math.min(o,l,c,u),Math.max(r,a,h,d),Math.max(o,l,c,u),n)}function Hh(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,d=r*a,u=s[0],f=s[1];return[u-l+d,f-h-c,u-l-d,f-h+c,u+l-d,f+h+c,u+l+d,f+h-c,u-l+d,f-h-c]}function he(s){return s[3]-s[1]}function Ni(s,t,e){const i=e||oe();return le(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]):bs(i),i}function ji(s){return[s[0],s[3]]}function Nr(s){return[s[2],s[3]]}function Et(s){return s[2]-s[0]}function le(s,t){return s[0]<=t[2]&&s[2]>=t[0]&&s[1]<=t[3]&&s[3]>=t[1]}function Ss(s){return s[2]<s[0]||s[3]<s[1]}function au(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s}function lu(s,t,e){let i=!1;const n=Ho(s,t),r=Ho(s,e);if(n===Xt.INTERSECTING||r===Xt.INTERSECTING)i=!0;else{const o=s[0],a=s[1],l=s[2],h=s[3],c=t[0],d=t[1],u=e[0],f=e[1],g=(f-d)/(u-c);let p,m;r&Xt.ABOVE&&!(n&Xt.ABOVE)&&(p=u-(f-h)/g,i=p>=o&&p<=l),!i&&r&Xt.RIGHT&&!(n&Xt.RIGHT)&&(m=f-(u-l)*g,i=m>=a&&m<=h),!i&&r&Xt.BELOW&&!(n&Xt.BELOW)&&(p=u-(f-a)/g,i=p>=o&&p<=l),!i&&r&Xt.LEFT&&!(n&Xt.LEFT)&&(m=f-(u-o)*g,i=m>=a&&m<=h)}return i}function Xh(s,t){const e=t.getExtent(),i=be(s);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const n=Et(e),o=Math.floor((i[0]-e[0])/n)*n;s[0]-=o,s[2]-=o}return s}function jh(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]]];Xh(s,t);const n=Et(i);if(Et(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 Yh(...s){console.warn(...s)}function Pt(s,t,e){return Math.min(Math.max(s,t),e)}function hu(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 li(s,t,e,i)}function li(s,t,e,i){const n=e-s,r=i-t;return n*n+r*r}function cu(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 Fl(s){return s*180/Math.PI}function Fe(s){return s*Math.PI/180}function Gi(s,t){const e=s%t;return e*t<0?e+t:e}function ye(s,t,e){return s+e*(t-s)}function Ps(s,t){const e=Math.pow(10,t);return Math.round(s*e)/e}function Bs(s,t){return Math.floor(Ps(s,t))}function Ws(s,t){return Math.ceil(Ps(s,t))}function Yo(s,t,e){if(s>=t&&s<e)return s;const i=e-t;return((s-t)%i+i)%i+t}function Zh(s,t){return s[0]+=+t[0],s[1]+=+t[1],s}function _r(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 ba(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 Kh(s,t){return s[0]*=t,s[1]*=t,s}function qh(s,t){const e=s[0]-t[0],i=s[1]-t[1];return e*e+i*i}function Jh(s,t){return Math.sqrt(qh(s,t))}function Qh(s,t){if(t.canWrapX()){const e=Et(t.getExtent()),i=du(s,t,e);i&&(s[0]-=i*e)}return s}function du(s,t,e){const i=t.getExtent();let n=0;return t.canWrapX()&&(s[0]<i[0]||s[0]>i[2])&&(e=e||Et(i),n=Math.floor((s[0]-i[0])/e)),n}function uu(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 Sa={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Pa{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_||Sa[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 Is=6378137,fn=Math.PI*Is,fu=[-fn,-fn,fn,fn],gu=[-180,-85,180,85],Us=Is*Math.log(Math.tan(Math.PI/2));class Ji extends Pa{constructor(t){super({code:t,units:"m",extent:fu,global:!0,worldExtent:gu,getPointResolution:function(e,i){return e/Math.cosh(i[1]/Is)}})}}const Ol=[new Ji("EPSG:3857"),new Ji("EPSG:102100"),new Ji("EPSG:102113"),new Ji("EPSG:900913"),new Ji("http://www.opengis.net/def/crs/EPSG/0/3857"),new Ji("http://www.opengis.net/gml/srs/epsg.xml#3857")];function pu(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]=fn*s[r]/180;let o=Is*Math.log(Math.tan(Math.PI*(+s[r+1]+90)/360));o>Us?o=Us:o<-Us&&(o=-Us),t[r+1]=o}return t}function mu(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]/fn,t[r+1]=360*Math.atan(Math.exp(s[r+1]/Is))/Math.PI-90;return t}const yu=6378137,zl=[-180,-90,180,90],_u=Math.PI*yu/180;class Di extends Pa{constructor(t,e){super({code:t,units:"degrees",extent:zl,axisOrientation:e,global:!0,metersPerUnit:_u,worldExtent:zl})}}const $l=[new Di("CRS:84"),new Di("EPSG:4326","neu"),new Di("urn:ogc:def:crs:OGC:1.3:CRS84"),new Di("urn:ogc:def:crs:OGC:2:84"),new Di("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Di("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Di("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Zo={};function wu(s){return Zo[s]||Zo[s.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function xu(s,t){Zo[s]=t}let wn={};function us(s,t,e){const i=s.getCode(),n=t.getCode();i in wn||(wn[i]={}),wn[i][n]=e}function ao(s,t){return s in wn&&t in wn[s]?wn[s][t]:null}const wr=.9996,Se=.00669438,Gr=Se*Se,Br=Gr*Se,Mi=Se/(1-Se),Nl=Math.sqrt(1-Se),Sn=(1-Nl)/(1+Nl),tc=Sn*Sn,Ia=tc*Sn,La=Ia*Sn,ec=La*Sn,ic=1-Se/4-3*Gr/64-5*Br/256,Cu=3*Se/8+3*Gr/32+45*Br/1024,Eu=15*Gr/256+45*Br/1024,vu=35*Br/3072,Tu=3/2*Sn-27/32*Ia+269/512*ec,bu=21/16*tc-55/32*La,Su=151/96*Ia-417/128*ec,Pu=1097/512*La,xr=6378137;function Iu(s,t,e){const i=s-5e5,o=(e.north?t:t-1e7)/wr/(xr*ic),a=o+Tu*Math.sin(2*o)+bu*Math.sin(4*o)+Su*Math.sin(6*o)+Pu*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),d=l/c,u=d*d,f=u*u,g=1-Se*h,p=Math.sqrt(1-Se*h),m=xr/p,y=(1-Se)/g,x=Mi*c**2,E=x*x,w=i/(m*wr),C=w*w,v=C*w,_=v*w,b=_*w,S=b*w,P=a-d/y*(C/2-_/24*(5+3*u+10*x-4*E-9*Mi))+S/720*(61+90*u+298*x+45*f-252*Mi-3*E);let L=(w-v/6*(1+2*u+x)+b/120*(5-2*x+28*u-3*E+8*Mi+24*f))/c;return L=Yo(L+Fe(nc(e.number)),-Math.PI,Math.PI),[Fl(L),Fl(P)]}const Gl=-80,Bl=84,Lu=-180,Du=180;function ku(s,t,e){s=Yo(s,Lu,Du),t<Gl?t=Gl:t>Bl&&(t=Bl);const i=Fe(t),n=Math.sin(i),r=Math.cos(i),o=n/r,a=o*o,l=a*a,h=Fe(s),c=nc(e.number),d=Fe(c),u=xr/Math.sqrt(1-Se*n**2),f=Mi*r**2,g=r*Yo(h-d,-Math.PI,Math.PI),p=g*g,m=p*g,y=m*g,x=y*g,E=x*g,w=xr*(ic*i-Cu*Math.sin(2*i)+Eu*Math.sin(4*i)-vu*Math.sin(6*i)),C=wr*u*(g+m/6*(1-a+f)+x/120*(5-18*a+l+72*f-58*Mi))+5e5;let v=wr*(w+u*o*(p/2+y/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Mi)));return e.north||(v+=1e7),[C,v]}function nc(s){return(s-1)*6-180+3}const Ru=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function sc(s){let t=0;for(const n of Ru){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 Wl(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 Au(s){return sc(s)?new Pa({code:s,units:"m"}):null}function Mu(s){const t=sc(s.getCode());return t?{forward:Wl(ku,t),inverse:Wl(Iu,t)}:null}const Da=63710088e-1;function Ko(s,t,e){e=e||Da;const i=Fe(s[1]),n=Fe(t[1]),r=(n-i)/2,o=Fe(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 lo(s,t){let e=0;for(let i=0,n=s.length;i<n-1;++i)e+=Ko(s[i],s[i+1],t);return e}function rc(s,t){t=t||{};const e=t.radius||Da,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,d;switch(n){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=s.getCoordinates(),r=lo(o,e);break}case"MultiLineString":case"Polygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)r+=lo(o[l],e);break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,d=a.length;c<d;++c)r+=lo(a[c],e);break}case"GeometryCollection":{const u=s.getGeometries();for(l=0,h=u.length;l<h;++l)r+=rc(u[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}function Vs(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+=Fe(a-n)*(2+Math.sin(Fe(r))+Math.sin(Fe(l))),n=a,r=l}return e*t*t/2}function oc(s,t){t=t||{};const e=t.radius||Da,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,d;switch(n){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=s.getCoordinates(),r=Math.abs(Vs(o[0],e)),l=1,h=o.length;l<h;++l)r-=Math.abs(Vs(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(Vs(a[0],e)),c=1,d=a.length;c<d;++c)r-=Math.abs(Vs(a[c],e));break}case"GeometryCollection":{const u=s.getGeometries();for(l=0,h=u.length;l<h;++l)r+=oc(u[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}const Fu=[Mu],Ou=[Au];let qo=!0;function ac(s){qo=!1}function ka(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 Jo(s){xu(s.getCode(),s),us(s,s,ka)}function zu(s){s.forEach(Jo)}function Ft(s){if(typeof s!="string")return s;const t=wu(s);if(t)return t;for(const e of Ou){const i=e(s);if(i)return i}return null}function Ul(s,t,e,i){s=Ft(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=Aa(s,Ft("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=Ko(h.slice(0,2),h.slice(2,4)),d=Ko(h.slice(4,6),h.slice(6,8));n=(c+d)/2}const l=s.getMetersPerUnit();l!==void 0&&(n/=l)}}return n}function Vl(s){zu(s),s.forEach(function(t){s.forEach(function(e){t!==e&&us(t,e,ka)})})}function $u(s,t,e,i){s.forEach(function(n){t.forEach(function(r){us(n,r,e),us(r,n,i)})})}function Ra(s,t){return s?typeof s=="string"?Ft(s):s:Ft(t)}function Nu(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 ut(s,t){return ac(),Wr(s,"EPSG:4326","EPSG:3857")}function U(s,t){const e=Wr(s,"EPSG:3857","EPSG:4326"),i=e[0];return(i<-180||i>180)&&(e[0]=Gi(i+180,360)-180),e}function os(s,t){if(s===t)return!0;const e=s.getUnits()===t.getUnits();return(s.getCode()===t.getCode()||Aa(s,t)===ka)&&e}function Aa(s,t){const e=s.getCode(),i=t.getCode();let n=ao(e,i);if(n)return n;let r=null,o=null;for(const l of Fu)r||(r=l(s)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)n=ho(r.inverse,o.forward);else{const l=ao(e,a);l&&(n=ho(l,o.forward))}else{const l=ao(a,i);l&&(n=ho(r.inverse,l))}return n&&(Jo(s),Jo(t),us(s,t,n)),n}function ho(s,t){return function(e,i,n,r){return i=s(e,i,n,r),t(i,i,n,r)}}function fs(s,t){const e=Ft(s),i=Ft(t);return Aa(e,i)}function Wr(s,t,e){const i=fs(t,e);if(!i){const n=Ft(t).getCode(),r=Ft(e).getCode();throw new Error(`No transform available between ${n} and ${r}`)}return i(s,void 0,s.length)}function Qo(s,t){return s}function Re(s,t){return qo&&!_r(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(qo=!1,Yh("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function lc(s,t){return s}function Fi(s,t){return s}function Gu(){Vl(Ol),Vl($l),$u($l,Ol,pu,mu)}Gu();const Bu=new Array(6);function Ut(){return[1,0,0,1,0,0]}function hc(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],d=t[3],u=t[4],f=t[5];return s[0]=e*l+n*h,s[1]=i*l+r*h,s[2]=e*c+n*d,s[3]=i*c+r*d,s[4]=e*u+n*f+o,s[5]=i*u+r*f+a,s}function Wu(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 cc(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 zt(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 Uu(s,t,e){return hc(s,Wu(Bu,1,0,0,1,t,e))}function Pe(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 Ur(s,t){const e=Vu(t);gt(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 Vu(s){return s[0]*s[3]-s[1]*s[2]}const Hu=[1e5,1e5,1e5,1e5,2,2];function Xu(s){return"matrix("+s.join(", ")+")"}function ta(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function ju(s,t){const e=ta(s),i=ta(t);for(let n=0;n<6;++n)if(Math.round((e[n]-i[n])*Hu[n])!==0)return!1;return!0}function Ye(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 d=2;d<o;d++)r[a++]=s[l+d]}return r&&r.length!=a&&(r.length=a),r}function Ma(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 d=0;for(let u=t;u<e;u+=i){const f=s[u]-h,g=s[u+1]-c;o[d++]=h+f*a-g*l,o[d++]=c+f*l+g*a;for(let p=u+2;p<u+i;++p)o[d++]=s[p]}return o&&o.length!=d&&(o.length=d),o}function Yu(s,t,e,i,n,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let d=t;d<e;d+=i){const u=s[d]-l,f=s[d+1]-h;a[c++]=l+n*u,a[c++]=h+r*f;for(let g=d+2;g<d+i;++g)a[c++]=s[g]}return a&&a.length!=c&&(a.length=c),a}function Zu(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 Hl=Ut(),Ku=[NaN,NaN];class dc extends $e{constructor(){super(),this.extent_=oe(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Bh((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 Q()}closestPointXY(t,e,i,n){return Q()}containsXY(t,e){return this.closestPointXY(t,e,Ku,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 Q()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&bs(e),this.extentRevision_=this.getRevision()}return au(this.extent_,t)}rotate(t,e){Q()}scale(t,e,i){Q()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return Q()}getType(){return Q()}applyTransform(t){Q()}intersectsExtent(t){return Q()}translate(t,e){Q()}transform(t,e){const i=Ft(t),n=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=he(h)/he(l);Pe(Hl,h[0],h[3],c,-c,0,0,0);const d=Ye(r,0,r.length,a,Hl,o),u=fs(i,e);return u?u(d,d,a):d}:fs(i,e);return this.applyTransform(n),this}}class Pi extends dc{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return va(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return Q()}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=Cr(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){Q()}setLayout(t,e,i){let n;if(t)n=Cr(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=Yi(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();Ma(i,0,i.length,n,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=be(this.getExtent()));const n=this.getFlatCoordinates();if(n){const r=this.getStride();Yu(n,0,n.length,r,t,e,i,n),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();Zu(i,0,i.length,n,t,e,i),this.changed()}}}function Yi(s){let t;return s==2?t="XY":s==3?t="XYZ":s==4&&(t="XYZM"),t}function Cr(s){let t;return s=="XY"?t=2:s=="XYZ"||s=="XYM"?t=3:s=="XYZM"&&(t=4),t}function qu(s,t,e){const i=s.getFlatCoordinates();if(!i)return null;const n=s.getStride();return Ye(i,0,i.length,n,t,e)}function Xl(s,t,e,i,n,r,o){const a=s[t],l=s[t+1],h=s[e]-a,c=s[e+1]-l;let d;if(h===0&&c===0)d=t;else{const u=((n-a)*h+(r-l)*c)/(h*h+c*c);if(u>1)d=e;else if(u>0){for(let f=0;f<i;++f)o[f]=ye(s[t+f],s[e+f],u);o.length=i;return}else d=t}for(let u=0;u<i;++u)o[u]=s[d+u];o.length=i}function Fa(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=li(r,o,a,l);h>n&&(n=h),r=a,o=l}return n}function Oa(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];n=Fa(s,t,a,i,n),t=a}return n}function Ju(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];n=Oa(s,t,a,i,n),t=a[a.length-1]}return n}function za(s,t,e,i,n,r,o,a,l,h,c){if(t==e)return h;let d,u;if(n===0){if(u=li(o,a,s[t],s[t+1]),u<h){for(d=0;d<i;++d)l[d]=s[t+d];return l.length=i,u}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(Xl(s,f-i,f,i,o,a,c),u=li(o,a,c[0],c[1]),u<h){for(h=u,d=0;d<i;++d)l[d]=c[d];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(u)-Math.sqrt(h))/n|0,1);if(r&&(Xl(s,e-i,t,i,o,a,c),u=li(o,a,c[0],c[1]),u<h)){for(h=u,d=0;d<i;++d)l[d]=c[d];l.length=i}return h}function $a(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let d=0,u=e.length;d<u;++d){const f=e[d];h=za(s,t,f,i,n,r,o,a,l,h,c),t=f}return h}function Qu(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let d=0,u=e.length;d<u;++d){const f=e[d];h=$a(s,t,f,i,n,r,o,a,l,h,c),t=f[f.length-1]}return h}function uc(s,t,e,i){for(let n=0,r=e.length;n<r;++n)s[t++]=e[n];return t}function Vr(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 Ls(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=Vr(s,t,e[o],i);n[r++]=l,t=l}return n.length=r,n}function fc(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=Ls(s,t,e[o],i,n[r]);l.length===0&&(l[0]=t),n[r++]=l,t=l[l.length-1]}return n.length=r,n}function vi(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 gs(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++]=vi(s,t,l,i,n[r]),t=l}return n.length=r,n}function ea(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?[]:gs(s,t,l,i,n[r]),t=l[l.length-1]}return n.length=r,n}function Er(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],d=s[t+1],u=0;const f=[0];for(let m=t+i;m<e;m+=i){const y=s[m],x=s[m+1];u+=Math.sqrt((y-c)*(y-c)+(x-d)*(x-d)),f.push(u),c=y,d=x}const g=n*u,p=Jd(f,g);p<0?(l=(g-f[-p-2])/(f[-p-1]-f[-p-2]),a=t+(-p-2)*i):a=t+p*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]:ye(s[a+c],s[a+i+c],l);return r}function ia(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 u=a+l>>1;n<s[(u+1)*i-1]?l=u:a=u+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],d=(n-h)/(c-h);o=[];for(let u=0;u<i-1;++u)o.push(ye(s[(a-1)*i+u],s[a*i+u],d));return o.push(n),o}function tf(s,t,e,i,n,r,o){if(o)return ia(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 ia(s,t,c,i,n,!1);t=c}}return null}function ef(s,t,e,i,n){return!Ta(n,function(o){return!Oi(s,t,e,i,o[0],o[1])})}function Oi(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 Na(s,t,e,i,n,r){if(e.length===0||!Oi(s,t,e[0],i,n,r))return!1;for(let o=1,a=e.length;o<a;++o)if(Oi(s,e[o-1],e[o],i,n,r))return!1;return!0}function nf(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(Na(s,t,l,i,n,r))return!0;t=l[l.length-1]}return!1}function gc(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 Hr(s,t,e,i,n,r){return r=r??Vh(oe(),s,t,e,i),le(n,r)?r[0]>=n[0]&&r[2]<=n[2]||r[1]>=n[1]&&r[3]<=n[3]?!0:gc(s,t,e,i,function(o,a){return lu(n,o,a)}):!1}function sf(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){if(Hr(s,t,e[r],i,n))return!0;t=e[r]}return!1}function pc(s,t,e,i,n){return!!(Hr(s,t,e,i,n)||Oi(s,t,e,i,n[0],n[1])||Oi(s,t,e,i,n[0],n[3])||Oi(s,t,e,i,n[2],n[1])||Oi(s,t,e,i,n[2],n[3]))}function mc(s,t,e,i,n){if(!pc(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(ef(s,e[r-1],e[r],i,n)&&!Hr(s,e[r-1],e[r],i,n))return!1;return!0}function rf(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(mc(s,t,a,i,n))return!0;t=a[a.length-1]}return!1}function Ga(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 Xr(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 d=h.pop(),u=h.pop();let f=0;const g=s[u],p=s[u+1],m=s[d],y=s[d+1];for(let x=u+i;x<d;x+=i){const E=s[x],w=s[x+1],C=hu(E,w,g,p,m,y);C>f&&(c=x,f=C)}f>n&&(l[(c-t)/i]=1,u+i<c&&h.push(u,c),c+i<d&&h.push(c,d))}for(let d=0;d<a;++d)l[d]&&(r[o++]=s[t+d*i],r[o++]=s[t+d*i+1]);return o}function yc(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Xr(s,t,c,i,n,r,o),a.push(o),t=c}return o}function Ri(s,t){return t*Math.round(s/t)}function of(s,t,e,i,n,r,o){if(t==e)return o;let a=Ri(s[t],n),l=Ri(s[t+1],n);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=Ri(s[t],n),c=Ri(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 d=Ri(s[t],n),u=Ri(s[t+1],n);if(t+=i,d==h&&u==c)continue;const f=h-a,g=c-l,p=d-a,m=u-l;if(f*m==g*p&&(f<0&&p<f||f==p||f>0&&p>f)&&(g<0&&m<g||g==m||g>0&&m>g)){h=d,c=u;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=d,c=u}return r[o++]=h,r[o++]=c,o}function Ba(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=of(s,t,c,i,n,r,o),a.push(o),t=c}return o}function af(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l],d=[];o=Ba(s,t,c,i,n,r,o,d),a.push(d),t=c[c.length-1]}return o}class pt extends Pi{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){je(this.flatCoordinates,t),this.changed()}clone(){const t=new pt(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Fa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),za(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,n))}forEachSegment(t){return gc(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,ia(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return vi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return Er(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Ga(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=Xr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new pt(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return Hr(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=Vr(this.flatCoordinates,0,t,this.stride),this.changed()}}function _c(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 wc(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=_c(s,t,a,i),t=a}return n}function lf(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=wc(s,t,a,i),t=a[a.length-1]}return n}class ps extends Pi{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 ps(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Fa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),za(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,n))}getArea(){return _c(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return vi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=Xr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new ps(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Vr(this.flatCoordinates,0,t,this.stride),this.changed()}}class rt extends Pi{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new rt(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,o=li(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 Ea(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Ca(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=uc(this.flatCoordinates,0,t,this.stride),this.changed()}}function Wa(s,t,e,i,n,r,o){let a,l,h,c,d,u,f;const g=n[r+1],p=[];for(let x=0,E=e.length;x<E;++x){const w=e[x];for(c=s[w-i],u=s[w-i+1],a=t;a<w;a+=i)d=s[a],f=s[a+1],(g<=u&&f<=g||u<=g&&g<=f)&&(h=(g-u)/(f-u)*(d-c)+c,p.push(h)),c=d,u=f}let m=NaN,y=-1/0;for(p.sort(ai),c=p[0],a=1,l=p.length;a<l;++a){d=p[a];const x=Math.abs(d-c);x>y&&(h=(c+d)/2,Na(s,t,e,i,h,g)&&(m=h,y=x)),c=d}return isNaN(m)&&(m=n[r]),o?(o.push(m,g,y),o):[m,g,y]}function xc(s,t,e,i,n){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Wa(s,t,l,i,n,2*o,r),t=l[l.length-1]}return r}function hf(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 Ua(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 Va(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=Ua(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 Cc(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(!Va(s,t,a,i,n))return!1;a.length&&(t=a[a.length-1])}return!0}function vr(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=Ua(s,t,a,i);(r===0?n&&l||!n&&!l:n&&!l||!n&&l)&&hf(s,t,a,i),t=a}return t}function na(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r)t=vr(s,t,e[r],i,n);return t}function Ec(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=Ua(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 it extends Pi{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?je(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new it(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Oa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),$a(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return Na(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return wc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),vr(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,gs(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=be(this.getExtent());this.flatInteriorPoint_=Wa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new rt(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new ps(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 ps(e.slice(r,l),t);n.push(h),r=l}return n}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Va(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=vr(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Ba(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new it(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return mc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Ls(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function gn(s){if(Ss(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 it(r,"XY",[r.length])}const jt={ANIMATING:0,INTERACTING:1},Ui=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",cf=Ui.includes("safari")&&!Ui.includes("chrom"),df=cf&&(Ui.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Ui)),uf=Ui.includes("webkit")&&!Ui.includes("edge"),vc=Ui.includes("macintosh"),ff=typeof devicePixelRatio<"u"?devicePixelRatio:1,Ee=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Tc=typeof Image<"u"&&Image.prototype.decode,bc=(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 $t(s,t,e,i){let n;return e&&e.length?n=e.shift():Ee?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 co;function Tr(){return co||(co=$t(1,1)),co}function jr(s){const t=s.canvas;t.width=1,t.height=1,s.clearRect(0,0,1,1)}function jl(s,t){const e=t.parentNode;e&&e.replaceChild(s,t)}function gf(s){for(;s.lastChild;)s.lastChild.remove()}function pf(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 Sc(){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 Ti(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}const Yt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},at={IDLE:0,LOADING:1,LOADED:2,ERROR:3},Ha=[NaN,NaN,NaN,0];let uo;function mf(){return uo||(uo=$t(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),uo}const yf=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,_f=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,wf=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,xf=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Hs(s,t){return s.endsWith("%")?Number(s.substring(0,s.length-1))/t:Number(s)}function as(s){throw new Error('failed to parse "'+s+'" as color')}function Pc(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(_f)||s.match(yf)||s.match(wf);if(r){const o=r[4],a=100/255;return[Pt(Hs(r[1],a)+.5|0,0,255),Pt(Hs(r[2],a)+.5|0,0,255),Pt(Hs(r[3],a)+.5|0,0,255),o!==void 0?Pt(Hs(o,100),0,1):1]}as(s)}if(s.startsWith("#")){if(xf.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}as(s)}const t=mf();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&&as(s));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Pc(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]=Ps(n[3]/255,3),n}function Cf(s){return typeof s=="string"?s:ja(s)}const Ef=1024,Wn={};let fo=0;function vf(s){if(s.length===4)return s;const t=s.slice();return t[3]=1,t}function go(s){return s>.0031308?Math.pow(s,1/2.4)*269.025-14.025:s*3294.6}function po(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function mo(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function yo(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Yl(s){const t=mo(s[0]),e=mo(s[1]),i=mo(s[2]),n=yo(t*.222488403+e*.716873169+i*.06060791),r=500*(yo(t*.452247074+e*.399439023+i*.148375274)-n),o=200*(n-yo(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 Tf(s){const t=(s[0]+16)/116,e=s[1],i=s[2]*Math.PI/180,n=po(t),r=po(t+e/500*Math.cos(i)),o=po(t-e/200*Math.sin(i)),a=go(r*3.021973625-n*1.617392459-o*.404875592),l=go(r*-.943766287+n*1.916279586+o*.027607165),h=go(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 Xa(s){if(s==="none")return Ha;if(Wn.hasOwnProperty(s))return Wn[s];if(fo>=Ef){let e=0;for(const i in Wn)(e++&3)===0&&(delete Wn[i],--fo)}const t=Pc(s);t.length!==4&&as(s);for(const e of t)isNaN(e)&&as(s);return Wn[s]=t,++fo,t}function Ie(s){return Array.isArray(s)?s:Xa(s)}function ja(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 bf(s,t,e){const i=s;let n=!0,r=!1,o=!1;const a=[mr(i,nt.LOAD,function(){o=!0,r||t()})];return i.src&&Tc?(r=!0,i.decode().then(function(){n&&t()}).catch(function(l){n&&(o?t():e())})):a.push(mr(i,nt.ERROR,e)),function(){n=!1,a.forEach(Tt)}}function Sf(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 Pf(s,t){return t&&(s.src=t),s.src&&Tc?new Promise((e,i)=>s.decode().then(()=>e(s)).catch(n=>s.complete&&s.width?e(s):i(n))):Sf(s)}class If{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=_o(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){const i=_o(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,n){const r=_o(t,e),o=r in this.cache_;this.cache_[r]=i,n&&(i.getImageState()===at.IDLE&&i.load(),i.getImageState()===at.LOADING?i.ready().then(()=>{this.patternCache_[r]=Tr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[r]=Tr().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function _o(s,t){const e=t?Ie(t):"null";return s+":"+e}const ve=new If;let Un=null;class Ic extends Or{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?at.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_===at.LOADED){Un||(Un=$t(1,1,void 0,{willReadFrequently:!0})),Un.drawImage(this.image_,0,0);try{Un.getImageData(0,0,1,1),this.tainted_=!1}catch{Un=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(nt.CHANGE)}handleImageError_(){this.imageState_=at.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=at.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=$t(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_===at.IDLE){this.image_||this.initializeImage_(),this.imageState_=at.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Pf(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_!==at.LOADED)return;const e=this.image_,i=$t(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=Cf(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_===at.LOADED||this.imageState_===at.ERROR)t();else{const e=()=>{(this.imageState_===at.LOADED||this.imageState_===at.ERROR)&&(this.removeEventListener(nt.CHANGE,e),t())};this.addEventListener(nt.CHANGE,e)}})),this.ready_}}function ls(s,t,e,i,n,r){let o=t===void 0?void 0:ve.get(t,n);return o||(o=new Ic(s,s&&"src"in s?s.src||void 0:t,e,i,n),ve.set(t,n,o,r)),r&&o&&!ve.getPattern(t,n)&&ve.set(t,n,o,r),o}function Xe(s){return s?Array.isArray(s)?ja(s):typeof s=="object"&&"src"in s?Lf(s):s:null}function Lf(s){if(!s.offset||!s.size)return ve.getPattern(s.src,s.color);const t=s.src+":"+s.offset,e=ve.getPattern(t,s.color);if(e)return e;const i=ve.get(s.src,null);if(i.getImageState()!==at.LOADED)return null;const n=$t(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]),ls(n.canvas,t,void 0,at.LOADED,s.color,!0),ve.getPattern(t,s.color)}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 Xs="ol-hidden",Yr="ol-unselectable",Ya="ol-control",Zl="ol-collapsed",Df=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"),Kl=["style","variant","weight","size","lineHeight","family"],sa={normal:400,bold:700},ra=function(s){const t=s.match(Df);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,n=Kl.length;i<n;++i){const r=t[i+1];r!==void 0&&(e[Kl[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in sa&&(e.weight=sa[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e},Dc="10px sans-serif",ue="#000",Pn="round",hi=[],ci=0,In="round",ms=10,kf=0,Ze="#000",ys="center",br="middle",zi=[0,0,0,0],_s=1,hn=new $e;let Vn=null,ql;const oa={},Rf=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Af(s,t,e){return`${s} ${t} 16px "${e}"`}const Mf=(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=ra(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const d=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),u=sa[c.weight]||c.weight;return d===l&&c.style===a.style&&u==h})}async function n(){await e.ready;let r=!0;const o=hn.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)?(kn(oa),hn.set(h,100)):(c+=10,hn.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(n,100))}return async function(r){e||(e=Ee?self.fonts:document.fonts);const o=ra(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(Rf.has(h))continue;const c=Af(o.style,o.weight,h);hn.get(c)===void 0&&(hn.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(n,100))}})(),Ff=(function(){let s;return function(t){let e=oa[t];if(e==null){if(Ee){const i=ra(t),n=kc(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);oa[t]=e}return e}})();function kc(s,t){return Vn||(Vn=$t(1,1)),s!=ql&&(Vn.font=s,ql=Vn.font),Vn.measureText(t)}function Rc(s,t){return kc(s,t).width}function Jl(s,t,e){if(t in e)return e[t];const i=t.split(`
|
|
2
|
+
`).reduce((n,r)=>Math.max(n,Rc(s,r)),0);return e[t]=i,i}function Of(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 d=t[h];if(d===`
|
|
3
|
+
`||h===c){r=Math.max(r,o),n.push(o),o=0,a+=l,l=0;continue}const u=t[h+1]||s.font,f=Rc(u,d);e.push(f),o+=f;const g=Ff(u);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:n}}function zf(s,t,e,i,n,r,o,a,l,h,c){s.save(),e!==1&&(s.globalAlpha===void 0?s.globalAlpha=d=>d.globalAlpha*=e:s.globalAlpha*=e),t&&s.transform.apply(s,t),i.contextInstructions?(s.translate(l,h),s.scale(c[0],c[1]),$f(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 $f(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 W={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},js=[W.FILL],bi=[W.STROKE],$i=[W.BEGIN_PATH],Ql=[W.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],Tn(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],d=t[e+1];const u=this.tmpCoordinate_;let f=!0,g,p,m;for(g=e+n;g<i;g+=n)u[0]=t[g],u[1]=t[g+1],m=Ho(h,u),m!==p?(f&&(a[l++]=c,a[l++]=d,f=!1),a[l++]=u[0],a[l++]=u[1]):m===Xt.INTERSECTING?(a[l++]=u[0],a[l++]=u[1],f=!1):f=!0,c=u[0],d=u[1],p=m;return(r&&f||g===e+n)&&(a[l++]=c,a[l++]=d),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,d,u,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),u=[];const g=t.getEndss();f=0;for(let p=0,m=g.length;p<m;++p){const y=[];f=this.drawCustomCoordinates_(h,f,g[p],a,y),u.push(y)}this.instructions.push([W.CUSTOM,l,u,t,i,ea,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,u,t,n||i,ea,r]);break;case"Polygon":case"MultiLineString":d=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,d),this.instructions.push([W.CUSTOM,l,d,t,i,gs,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,d,t,n||i,gs,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([W.CUSTOM,l,c,t,i,vi,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,c,t,n||i,vi,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([W.CUSTOM,l,c,t,i,vi,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,c,t,n||i,vi,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([W.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([W.CUSTOM,l,c,t,n||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[W.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[W.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==W.END_GEOMETRY?o=e:r==W.BEGIN_GEOMETRY&&(n[2]=e,tu(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=Xe(i||ue)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=Xe(i||Ze);const n=t.getLineCap();e.lineCap=n!==void 0?n:Pn;const r=t.getLineDash();e.lineDash=r?r.slice():hi;const o=t.getLineDashOffset();e.lineDashOffset=o||ci;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:In;const l=t.getWidth();e.lineWidth=l!==void 0?l:_s;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:ms;const c=t.getOffset();e.strokeOffset=c??kf,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=[W.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[W.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&&!ui(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=[W.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Uh(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;An(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Nf 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&&!Tn(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([W.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([W.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||Tn(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([W.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([W.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 Gf 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([W.MOVE_TO_LINE_TO,o,a,r*this.pixelRatio]),this.hitDetectionInstructions.push([W.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([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci],$i);const l=t.getFlatCoordinates(),h=t.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push(bi),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([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci],$i);const l=t.getEnds(),h=t.getFlatCoordinates(),c=t.getStride();let d=0;for(let u=0,f=l.length;u<f;++u)d=this.drawFlatCoordinates_(h,d,l[u],c,a);this.hitDetectionInstructions.push(bi),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(bi),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(bi),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push($i)}}class th 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($i),this.hitDetectionInstructions.push($i);for(let c=0;c<h;++c){const d=i[c],u=this.coordinates.length,f=this.appendFlatLineCoordinates(t,e,d,n,!0,!l);this.instructions.push([W.MOVE_TO_LINE_TO,u,f,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([W.MOVE_TO_LINE_TO,u,f,r,!0]),l&&(this.instructions.push(Ql),this.hitDetectionInstructions.push(Ql)),e=d}return a&&(this.instructions.push(js),this.hitDetectionInstructions.push(js)),l&&(this.instructions.push(bi),this.hitDetectionInstructions.push(bi)),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([W.SET_FILL_STYLE,ue]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci]);const l=t.getFlatCoordinates(),h=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);const d=[W.CIRCLE,c,a];this.instructions.push($i,d),this.hitDetectionInstructions.push($i,d),n.fillStyle!==void 0&&(this.instructions.push(js),this.hitDetectionInstructions.push(js)),n.strokeStyle!==void 0&&(this.instructions.push(bi),this.hitDetectionInstructions.push(bi)),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([W.SET_FILL_STYLE,ue]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci]);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([W.SET_FILL_STYLE,ue]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([W.SET_STROKE_STYLE,Ze,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,hi,ci]);const l=t.getEndss(),h=t.getOrientedFlatCoordinates(),c=t.getStride();let d=0;for(let u=0,f=l.length;u<f;++u)d=this.drawFlatCoordinatess_(h,d,l[u],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]=Ri(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 Bf(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),d=t[o+n],u=t[o+n+1],f=Math.sqrt((d-h)*(d-h)+(u-c)*(u-c));if(a+=f,a>=s){const g=(s-a+f)/f,p=ye(h,d,g),m=ye(c,u,g);l.push(p,m),r.push(l),l=[p,m],a==s&&(o+=n),a=0}else if(a<s)l.push(t[o+n],t[o+n+1]),o+=n;else{const g=f-a,p=ye(h,d,g/f),m=ye(c,u,g/f);l.push(p,m),r.push(l),l=[p,m],a=0,o+=n}}return a>0&&r.push(l),r}function Wf(s,t,e,i,n){let r=e,o=e,a=0,l=0,h=e,c,d,u,f,g,p,m,y,x,E;for(d=e;d<i;d+=n){const w=t[d],C=t[d+1];g!==void 0&&(x=w-g,E=C-p,f=Math.sqrt(x*x+E*E),m!==void 0&&(l+=u,c=Math.acos((m*x+y*E)/(u*f)),c>s&&(l>a&&(a=l,r=h,o=d),l=0,h=d-n)),u=f,m=x,y=E),g=w,p=C}return l+=f,l>a?[h,d]:[r,o]}const Sr={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Uf 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[ue]={fillStyle:ue},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,d=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!le(this.maxExtent,t.getExtent()))return;let u;if(c=t.getFlatCoordinates(),h=="LineString")u=[c.length];else if(h=="MultiLineString")u=t.getEnds();else if(h=="Polygon")u=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const m=t.getEndss();u=[];for(let y=0,x=m.length;y<x;++y)u.push(m[y][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let p=0;for(let m=0,y=u.length;m<y;++m){let x;f?x=Bf(f*this.resolution,c,p,u[m],d):x=[c.slice(p,u[m])];for(let E=0,w=x.length;E<w;++E){const C=x[E];let v=0,_=C.length;if(g==null){const S=Wf(o.maxAngle,C,0,C.length,2);v=S[0],_=S[1]}for(let S=v;S<_;S+=d)a.push(C[S],C[S+1]);const b=a.length;p=u[m],this.drawChars_(l,b),l=b}}this.endGeometry(e)}else{let u=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(),d=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||u.push(c[2]/this.resolution),d=3;break;case"MultiPolygon":const w=t.getFlatInteriorPoints();c=[];for(let C=0,v=w.length;C<v;C+=3)o.overflow||u.push(w[C+2]/this.resolution),c.push(w[C],w[C+1]);if(c.length===0)return;d=2;break}const f=this.appendFlatPointCoordinates(c,d);if(f===l)return;if(u&&(f-l)/2!==c.length/d){let w=l/2;u=u.filter((C,v)=>{const _=a[(w+v)*2]===c[v*d]&&a[(w+v)*2+1]===c[v*d+1];return _||--w,_})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,p=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let m=o.padding;if(m!=zi&&(o.scale[0]<0||o.scale[1]<0)){let w=o.padding[0],C=o.padding[1],v=o.padding[2],_=o.padding[3];o.scale[0]<0&&(C=-C,_=-_),o.scale[1]<0&&(w=-w,v=-v),m=[w,C,v,_]}const y=this.pixelRatio;this.instructions.push([W.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,m==zi?zi:m.map(function(w){return w*y}),g,p,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,u]);const x=1/y,E=g?g.slice(0):null;E&&(E[1]=ue),this.hitDetectionInstructions.push([W.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[x,x],NaN,this.declutterMode_,this.declutterImageWithText_,m,E,p,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ue:this.fillKey_,this.textOffsetX_,this.textOffsetY_,u]),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||ys,justify:e.justify,textBaseline:e.textBaseline||br,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=Sr[n.textBaseline],c=this.textOffsetY_*l,d=this.text_,u=i?i.lineWidth*Math.abs(n.scale[0])/2:0;this.instructions.push([W.DRAW_CHARS,t,e,h,n.overflow,a,n.maxAngle,l,c,r,u*l,d,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([W.DRAW_CHARS,t,e,h,n.overflow,a&&ue,n.maxAngle,l,c,r,u*l,d,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,n,r;if(!t)this.text_="";else{const o=t.getFill();o?(n=this.textFillState_,n||(n={},this.textFillState_=n),n.fillStyle=Xe(o.getColor()||ue)):(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 p=a.getLineDash(),m=a.getLineDashOffset(),y=a.getWidth(),x=a.getMiterLimit();r.lineCap=a.getLineCap()||Pn,r.lineDash=p?p.slice():hi,r.lineDashOffset=m===void 0?ci:m,r.lineJoin=a.getLineJoin()||In,r.lineWidth=y===void 0?_s:y,r.miterLimit=x===void 0?ms:x,r.strokeStyle=Xe(a.getColor()||Ze)}i=this.textState_;const l=t.getFont()||Dc;Mf(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()||br,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||zi,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),d=t.getOffsetY(),u=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=d===void 0?0:d,this.textRotateWithView_=u===void 0?!1:u,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:K(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=n&&n.fillStyle?typeof n.fillStyle=="string"?n.fillStyle:"|"+K(n.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const Vf={Circle:th,Default:Ds,Image:Nf,LineString:Gf,Polygon:th,Text:Uf};class Hf{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=Vf[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),n[e]=r}return r}}function Ac(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],d=s[e-2*i+1];let u,f,g,p,m,y,x,E,w=0;for(let C=t;C<e;C+=i){g=u,p=f,m=void 0,y=void 0,C+i<e&&(m=s[C+i],y=s[C+i+1]),r&&C===t&&(g=c,p=d),r&&C===e-i&&(m=l,y=h),u=s[C],f=s[C+1],[x,E]=Xf(u,f,g,p,m,y,n),o[w++]=x,o[w++]=E;for(let v=2;v<a;v++)o[w++]=s[C+v]}return o.length!=w&&(o.length=w),o}function Xf(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,d=l/h;if(a=-d,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 u=uu([s,t],[e,i],[n,r]);if(Math.cos(u)>.998)return[s+c*o,t+d*o];const f=Math.cos(u/2),g=Math.sin(u/2),p=g*a+f*l,m=-f*a+g*l,y=p*(1/g),x=m*(1/g);return[s+y*o,t+x*o]}function Mc(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],d=s[n+t],u=s[n+t+1],f=(u-c)*(a-r)-(d-h)*(l-o);if(f===0)continue;const g=((d-h)*(o-c)-(u-c)*(r-h))/f,p=((a-r)*(o-c)-(l-o)*(r-h))/f;if(g>0&&g<1&&p>0&&p<1){const m=r+g*(a-r),y=o+g*(l-o);s[e+t]=m,s[e+t+1]=y,s.splice(e+2*t,n-e-t);break}}return s}function jf(s,t,e,i,n,r,o,a,l,h,c,d,u=!0){let f=s[t],g=s[t+1],p=0,m=0,y=0,x=0;function E(){p=f,m=g,t+=i,f=s[t],g=s[t+1],x+=y,y=Math.sqrt((f-p)*(f-p)+(g-m)*(g-m))}do E();while(t<e-i&&x+y<r);let w=y===0?0:(r-x)/y;const C=ye(p,f,w),v=ye(m,g,w),_=t-i,b=x,S=r+a*l(h,n,c);for(;t<e-i&&x+y<S;)E();w=y===0?0:(S-x)/y;const P=ye(p,f,w),L=ye(m,g,w);let k=!1;if(u)if(d){const D=[C,v,P,L];Ma(D,0,4,2,d,D,D),k=D[0]>D[2]}else k=C>P;const F=Math.PI,O=[],R=_+i===t;t=_,y=0,x=b,f=s[t],g=s[t+1];let B;if(R){E(),B=Math.atan2(g-m,f-p),k&&(B+=B>0?-F:F);const D=(P+C)/2,z=(L+v)/2;return O[0]=[D,z,(S-r)/2,B,n],O}n=n.replace(/\n/g," ");for(let D=0,z=n.length;D<z;){E();let N=Math.atan2(g-m,f-p);if(k&&(N+=N>0?-F:F),B!==void 0){let xt=N-B;if(xt+=xt>F?-2*F:xt<-F?2*F:0,Math.abs(xt)>o)return null}B=N;const tt=D;let et=0;for(;D<z;++D){const xt=k?z-D-1:D,yt=a*l(h,n[xt],c);if(t+i<e&&x+y<r+et+yt/2)break;et+=yt}if(D===tt)continue;const ht=k?n.substring(z-tt,z-D):n.substring(tt,D);w=y===0?0:(r+et/2-x)/y;const ot=ye(p,f,w),I=ye(m,g,w);O.push([ot,I,et/2,N,ht]),r+=et}return O}class Fc{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Tr(),{get:(t,e)=>{if(typeof Tr()[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 Qi=oe(),pi=[],ei=[],ii=[],mi=[];function eh(s){return s[3].declutterBox}const ih=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function wo(s,t){return t==="start"?t=ih.test(s)?"right":"left":t==="end"&&(t=ih.test(s)?"left":"right"),Sr[t]}function Yf(s,t,e){return e>0&&s.push(`
|
|
4
|
+
`,""),s.push(t,""),s}function Zf(s,t,e){return e%2===0&&(s+=t),s}class Kf{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_=Ut(),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 Fc: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],d=l.justify?Sr[l.justify]:wo(Array.isArray(t)?t[0]:t,l.textAlign||ys),u=n&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(`
|
|
5
|
+
`).reduce(Yf,[]),{width:g,height:p,widths:m,heights:y,lineWidths:x}=Of(l,f),E=g+u,w=[],C=(E+2)*c[0],v=(p+u)*c[1],_={width:C<0?Math.floor(C):Math.ceil(C),height:v<0?Math.floor(v):Math.ceil(v),contextInstructions:w};(c[0]!=1||c[1]!=1)&&w.push("scale",c),n&&(w.push("strokeStyle",o.strokeStyle),w.push("lineWidth",u),w.push("lineCap",o.lineCap),w.push("lineJoin",o.lineJoin),w.push("miterLimit",o.miterLimit),w.push("setLineDash",[o.lineDash]),w.push("lineDashOffset",o.lineDashOffset)),i&&w.push("fillStyle",a.fillStyle),w.push("textBaseline","middle"),w.push("textAlign","center");const b=.5-d;let S=d*E+b*u;const P=[],L=[];let k=0,F=0,O=0,R=0,B;for(let D=0,z=f.length;D<z;D+=2){const N=f[D];if(N===`
|
|
6
|
+
`){F+=k,k=0,S=d*E+b*u,++R;continue}const tt=f[D+1]||l.font;tt!==B&&(n&&P.push("font",tt),i&&L.push("font",tt),B=tt),k=Math.max(k,y[O]);const et=[N,S+b*m[O]+d*(m[O]-x[R]),.5*(u+k)+F];S+=m[O],n&&P.push("strokeText",et),i&&L.push("fillText",et),++O}return Array.prototype.push.apply(w,P),Array.prototype.push.apply(w,L),this.labels_[r]=_,_}replayTextBackground_(t,e,i,n,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,n),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,n,r,o,a,l,h,c,d,u,f,g,p,m){a*=u[0],l*=u[1];let y=i-a,x=n-l;const E=r+h>t?t-h:r,w=o+c>e?e-c:o,C=g[3]+E*u[0]+g[1],v=g[0]+w*u[1]+g[2],_=y-g[3],b=x-g[0];(p||d!==0)&&(pi[0]=_,mi[0]=_,pi[1]=b,ei[1]=b,ei[0]=_+C,ii[0]=ei[0],ii[1]=b+v,mi[1]=ii[1]);let S;return d!==0?(S=Pe(Ut(),i,n,1,1,d,-i,-n),zt(S,pi),zt(S,ei),zt(S,ii),zt(S,mi),di(Math.min(pi[0],ei[0],ii[0],mi[0]),Math.min(pi[1],ei[1],ii[1],mi[1]),Math.max(pi[0],ei[0],ii[0],mi[0]),Math.max(pi[1],ei[1],ii[1],mi[1]),Qi)):di(Math.min(_,_+C),Math.min(b,b+v),Math.max(_,_+C),Math.max(b,b+v),Qi),f&&(y=Math.round(y),x=Math.round(x)),{drawImageX:y,drawImageY:x,drawImageW:E,drawImageH:w,originX:h,originY:c,declutterBox:{minX:Qi[0],minY:Qi[1],maxX:Qi[2],maxY:Qi[3],value:m},canvasTransform:S,scale:u}}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,pi,ei,ii,mi,o,a),zf(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=zt(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=wo(Array.isArray(t)?t[0]:t,r.textAlign||ys),c=Sr[r.textBaseline||br],d=a&&a.lineWidth?a.lineWidth:0,u=o.width/l-2*r.scale[0],f=h*u+2*(.5-h)*d,g=c*o.height/l+2*(.5-c)*d;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,n,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&ui(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Ye(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),cc(this.renderedTransform_,i));let d=0;const u=n.length;let f=0,g;const p=[];let m,y,x,E,w,C,v,_,b,S,P,L,k,F=0,O=0;const R=this.coordinateCache_,B=this.viewRotation_,D=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,z={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:B},N=this.instructions!=n||this.overlaps?0:200;let tt,et,ht,ot;for(;d<u;){const I=n[d];switch(I[0]){case W.BEGIN_GEOMETRY:tt=I[1],ot=I[3],tt.getGeometry()?a!==void 0&&!le(a,ot.getExtent())?d=I[2]+1:++d:d=I[2],h&&(h.zIndex=I[4]);break;case W.BEGIN_PATH:F>N&&(this.fill_(t),F=0),O>N&&(t.stroke(),O=0),!F&&!O&&(t.beginPath(),w=NaN,C=NaN),++d;break;case W.CIRCLE:f=I[1],x=I[2]??0;const yt=c[f],Ot=c[f+1],ie=c[f+2]-x,Ne=c[f+3]-x,St=ie-yt,vt=Ne-Ot,Dt=Math.sqrt(St*St+vt*vt);t.moveTo(yt+Dt,Ot),t.arc(yt,Ot,Dt,0,2*Math.PI,!0),++d;break;case W.CLOSE_PATH:t.closePath(),++d;break;case W.CUSTOM:f=I[1],g=I[2];const Kt=I[3],kt=I[4],Ht=I[5];z.geometry=Kt,z.feature=tt,d in R||(R[d]=[]);const de=R[d];Ht?Ht(c,f,g,2,de):(de[0]=c[f],de[1]=c[f+1],de.length=2),h&&(h.zIndex=I[6]),kt(de,z),++d;break;case W.DRAW_IMAGE:f=I[1],g=I[2],b=I[3],m=I[4],y=I[5];let gi=I[6];const Fs=I[7],On=I[8],qi=I[9],Os=I[10];let ne=I[11];const Xd=I[12];let zs=I[13];E=I[14]||"declutter";const zn=I[15];if(!b&&I.length>=20){S=I[19],P=I[20],L=I[21],k=I[22];const Nt=this.drawLabelWithPointPlacement_(S,P,L,k);b=Nt.label,I[3]=b;const Li=I[23];m=(Nt.anchorX-Li)*this.pixelRatio,I[4]=m;const we=I[24];y=(Nt.anchorY-we)*this.pixelRatio,I[5]=y,gi=b.height,I[6]=gi,zs=b.width,I[13]=zs}let io;I.length>25&&(io=I[25]);let no,$s,Ns;I.length>17?(no=I[16],$s=I[17],Ns=I[18]):(no=zi,$s=null,Ns=null),Os&&D?ne+=B:!Os&&!D&&(ne-=B);let jd=0;for(;f<g;f+=2){if(io&&io[jd++]<zs/this.pixelRatio)continue;const Nt=this.calculateImageOrLabelDimensions_(b.width,b.height,c[f],c[f+1],zs,gi,m,y,On,qi,ne,Xd,r,no,!!$s||!!Ns,tt),Li=[t,e,b,Nt,Fs,$s,Ns];if(l){let we,Ge,xe;if(zn){const At=g-f;if(!zn[At]){zn[At]={args:Li,declutterMode:E};continue}const ae=zn[At];we=ae.args,Ge=ae.declutterMode,delete zn[At],xe=eh(we)}let Je,Qe;if(we&&(Ge!=="declutter"||!l.collides(xe))&&(Je=!0),(E!=="declutter"||!l.collides(Nt.declutterBox))&&(Qe=!0),Ge==="declutter"&&E==="declutter"){const At=Je&&Qe;Je=At,Qe=At}Je&&(Ge!=="none"&&l.insert(xe),this.replayImageOrLabel_.apply(this,we)),Qe&&(E!=="none"&&l.insert(Nt.declutterBox),this.replayImageOrLabel_.apply(this,Li))}else this.replayImageOrLabel_.apply(this,Li)}++d;break;case W.DRAW_CHARS:const Pl=I[1],Il=I[2],so=I[3],Yd=I[4];k=I[5];const Zd=I[6],Ll=I[7],Dl=I[8];L=I[9];const ro=I[10];S=I[11],Array.isArray(S)&&(S=S.reduce(Zf,"")),P=I[12];const kl=[I[13],I[13]];E=I[14]||"declutter";const Kd=I[15],oo=this.textStates[P],$n=oo.font,Nn=[oo.scale[0]*Ll,oo.scale[1]*Ll];let Gn;$n in this.widths_?Gn=this.widths_[$n]:(Gn={},this.widths_[$n]=Gn);const Rl=Ga(c,Pl,Il,2),Al=Math.abs(Nn[0])*Jl($n,S,Gn);if(Yd||Al<=Rl){const Nt=this.textStates[P].textAlign,Li=(Rl-Al)*wo(S,Nt),we=jf(c,Pl,Il,2,S,Li,Zd,Math.abs(Nn[0]),Jl,$n,Gn,D?0:this.viewRotation_,Kd);t:if(we){const Ge=[];let xe,Je,Qe,At,ae;if(L)for(xe=0,Je=we.length;xe<Je;++xe){ae=we[xe],Qe=ae[4],At=this.createLabel(Qe,P,"",L),m=ae[2]+(Nn[0]<0?-ro:ro),y=so*At.height+(.5-so)*2*ro*Nn[1]/Nn[0]-Dl;const ti=this.calculateImageOrLabelDimensions_(At.width,At.height,ae[0],ae[1],At.width,At.height,m,y,0,0,ae[3],kl,!1,zi,!1,tt);if(l&&E==="declutter"&&l.collides(ti.declutterBox))break t;Ge.push([t,e,At,ti,1,null,null])}if(k)for(xe=0,Je=we.length;xe<Je;++xe){ae=we[xe],Qe=ae[4],At=this.createLabel(Qe,P,k,""),m=ae[2],y=so*At.height-Dl;const ti=this.calculateImageOrLabelDimensions_(At.width,At.height,ae[0],ae[1],At.width,At.height,m,y,0,0,ae[3],kl,!1,zi,!1,tt);if(l&&E==="declutter"&&l.collides(ti.declutterBox))break t;Ge.push([t,e,At,ti,1,null,null])}l&&E!=="none"&&l.load(Ge.map(eh));for(let ti=0,qd=Ge.length;ti<qd;++ti)this.replayImageOrLabel_.apply(this,Ge[ti])}}++d;break;case W.END_GEOMETRY:if(o!==void 0){tt=I[1];const Nt=o(tt,ot,E);if(Nt)return Nt}++d;break;case W.FILL:N?F++:this.fill_(t),++d;break;case W.MOVE_TO_LINE_TO:f=I[1],g=I[2],x=I[3];let Ii,Bn,Gs;if(x){const Nt=I[4]??!1;Ac(c,f,g,2,x,Nt,p),Mc(p,2),Ii=p,Bn=0,Gs=Ii.length}else Ii=c,Bn=f,Gs=g;et=Ii[Bn],ht=Ii[Bn+1],t.moveTo(et,ht),w=et+.5|0,C=ht+.5|0;for(let Nt=Bn+2;Nt<Gs;Nt+=2)et=Ii[Nt],ht=Ii[Nt+1],v=et+.5|0,_=ht+.5|0,(Nt==Gs-2||v!==w||_!==C)&&(t.lineTo(et,ht),w=v,C=_);++d;break;case W.SET_FILL_STYLE:this.alignAndScaleFill_=I[2],F?(this.fill_(t),F=0,O&&(t.stroke(),O=0)):O&&I[1]&&(t.stroke(),O=0),t.fillStyle=I[1],++d;break;case W.SET_STROKE_STYLE:F&&I[1]&&(this.fill_(t),F=0),O&&(t.stroke(),O=0),this.setStrokeStyle_(t,I),++d;break;case W.STROKE:N?O++:t.stroke(),++d;break;default:++d;break}}F&&this.fill_(t),O&&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 Ai=["Polygon","Circle","LineString","Image","Text","Default"],Oc=["Image","Text"],qf=Ai.filter(s=>!Oc.includes(s));let zc=!1,$c=!1;function Jf(){let s=0;const t=i=>{const n=$t(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};zc={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[s],$c=!0}class Qf{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_=Ut(),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 Kf(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){$c===!1&&Jf(),n=Math.round(n);const a=n*2+1,l=Pe(this.hitDetectionTransform_,n+.5,n+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=$t(a,a,null,{willReadFrequently:zc}));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 d;this.renderBuffer_!==void 0&&(d=oe(),rs(d,t),An(d,e*(this.renderBuffer_+n),d));const u=tg(n);let f;function g(C,v,_){const b=c.getImageData(0,0,a,a).data;for(let S=0,P=u.length;S<P;S++)if(b[u[S]]>0){if(!o||_==="none"||f!=="Image"&&f!=="Text"||o.includes(C)){const L=(u[S]-3)/4,k=n-L%a,F=n-(L/a|0),O=r(C,v,k*k+F*F);if(O)return O}c.clearRect(0,0,a,a);break}}const p=Object.keys(this.executorsByZIndex_).map(Number);p.sort(ai);let m,y,x,E,w;for(m=p.length-1;m>=0;--m){const C=p[m].toString();for(x=this.executorsByZIndex_[C],y=Ai.length-1;y>=0;--y)if(f=Ai[y],E=x[f],E!==void 0&&(w=E.executeHitDetection(c,l,i,g,d),w))return w}}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 Ye(a,0,8,2,t,a),a}isEmpty(){return Wi(this.executorsByZIndex_)}execute(t,e,i,n,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?Qd:ai),o=o||Ai;const h=Ai.length;for(let c=0,d=l.length;c<d;++c){const u=l[c].toString(),f=this.executorsByZIndex_[u];for(let g=0,p=o.length;g<p;++g){const m=o[g],y=f[m];if(y!==void 0){const x=a===null?void 0:y.getZIndexContext(),E=x?x.getContext():t,w=this.maxExtent_&&m!=="Image"&&m!=="Text";if(w&&(E.save(),this.clip(E,i)),!x||m==="Text"||m==="Image"?y.execute(E,e,i,n,r,a):x.pushFunction(C=>y.execute(C,e,i,n,r,a)),w&&E.restore(),x){x.offset();const C=l[c]*h+Ai.indexOf(m);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].push(x)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ai);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 xo={};function tg(s){if(xo[s]!==void 0)return xo[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 xo[s]=n,n}function nh(s){return s[0]>0&&s[1]>0}function eg(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 ce(s,t){return Array.isArray(s)?s:(t===void 0?t=[s,s]:(t[0]=s,t[1]=s),t)}class Zr{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=ce(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Zr({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 Q()}getImage(t){return Q()}getHitDetectionImage(){return Q()}getPixelRatio(t){return 1}getImageState(){return Q()}getImageSize(){return Q()}getOrigin(){return Q()}getSize(){return Q()}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_=ce(t)}listenImageChange(t){Q()}load(){Q()}unlistenImageChange(t){Q()}ready(){return Promise.resolve()}}function sh(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 Vi extends Zr{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;gt(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||K(o)),gt(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),gt(!((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=at.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?at.LOADED:at.IDLE:l=at.LOADING:l=at.LOADED),this.color_=t.color!==void 0?Ie(t.color):null,this.iconImage_=ls(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 d=this.getImage(1);if(d.width&&d.height)h=d.width,c=d.height;else if(d instanceof HTMLImageElement){this.initialOptions_=t;const u=()=>{if(this.unlistenImageChange(u),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(sh(f[0],f[1],t.width,t.height))};this.listenImageChange(u);return}}h!==void 0&&this.setScale(sh(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 Vi({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?Ie(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?at.IDLE:this.iconImage_.getImageState();this.iconImage_=ls(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_=ls(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},at.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()==at.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()==at.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(nt.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(nt.CHANGE,t)}ready(){return this.iconImage_.ready()}}class ig 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?Ps(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_=Ut()}drawImages_(t,e,i,n){if(!this.image_)return;const r=Ye(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,d=r.length;c<d;c+=2){const u=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=u+this.imageAnchorX_,p=f+this.imageAnchorY_;Pe(a,g,p,1,1,h,-g,-p),o.save(),o.transform.apply(o,a),o.translate(g,p),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_,u,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=Ye(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=Ye(t,e,i,n,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(l=Ac(l,0,l.length,2,o,r,l),Mc(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_)),!!le(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=qu(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_)),!!le(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(le(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_)),!!le(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_)),!!le(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),ui(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:ys;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=n&&(i.textAlign=n,e.textAlign=n),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=n,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:n,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:Xe(i||ue)}}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||hi,d=e.getOffset();this.strokeState_={lineCap:n!==void 0?n:Pn,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||ci)*this.pixelRatio_,lineJoin:a!==void 0?a:In,lineWidth:(l!==void 0?l:_s)*this.pixelRatio_,miterLimit:h!==void 0?h:ms,strokeStyle:Xe(i||Ze),strokeOffset:(d??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:Xe(f||ue)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),p=i.getLineDash(),m=i.getLineDashOffset(),y=i.getLineJoin(),x=i.getWidth(),E=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Pn,lineDash:p||hi,lineDashOffset:m||ci,lineJoin:y!==void 0?y:In,lineWidth:x!==void 0?x:_s,miterLimit:E!==void 0?E:ms,strokeStyle:Xe(f||Ze)}}const n=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),d=t.getTextAlign(),u=t.getTextBaseline();this.textState_={font:n!==void 0?n:Dc,textAlign:d!==void 0?d:ys,textBaseline:u!==void 0?u:br},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,p)=>f+=p%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 Ve=.5;function ng(s,t,e,i,n,r,o,a,l){const h=n,c=s[0]*Ve,d=s[1]*Ve,u=$t(c,d);u.imageSmoothingEnabled=!1;const f=u.canvas,g=new ig(u,Ve,n,null,o,a,null),p=e.length,m=Math.floor((256*256*256-1)/p),y={};for(let E=1;E<=p;++E){const w=e[E-1],C=w.getStyleFunction()||i;if(!C)continue;let v=C(w,r);if(!v)continue;Array.isArray(v)||(v=[v]);const b=(E*m).toString(16).padStart(7,"#00000");for(let S=0,P=v.length;S<P;++S){const L=v[S],k=L.getGeometryFunction()(w);if(!k||!le(h,k.getExtent()))continue;const F=L.clone(),O=F.getFill();O&&O.setColor(b);const R=F.getStroke();R&&(R.setColor(b),R.setLineDash(null)),F.setText(void 0);const B=L.getImage();if(B){const tt=B.getImageSize();if(!tt)continue;const et=$t(tt[0],tt[1],void 0,{alpha:!1}),ht=et.canvas;et.fillStyle=b,et.fillRect(0,0,ht.width,ht.height),F.setImage(new Vi({img:ht,anchor:B.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:B.getOrigin(),opacity:1,size:B.getSize(),scale:B.getScale(),rotation:B.getRotation(),rotateWithView:B.getRotateWithView()}))}const D=F.getZIndex()||0;let z=y[D];z||(z={},y[D]=z,z.Polygon=[],z.Circle=[],z.LineString=[],z.Point=[]);const N=k.getType();if(N==="GeometryCollection"){const tt=k.getGeometriesArrayRecursive();for(let et=0,ht=tt.length;et<ht;++et){const ot=tt[et];z[ot.getType().replace("Multi","")].push(ot,F)}}else z[N.replace("Multi","")].push(k,F)}}const x=Object.keys(y).map(Number).sort(ai);for(let E=0,w=x.length;E<w;++E){const C=y[x[E]];for(const v in C){const _=C[v];for(let b=0,S=_.length;b<S;b+=2){g.setStyle(_[b+1]);for(let P=0,L=t.length;P<L;++P)g.setTransform(t[P]),g.drawGeometry(_[b])}}}return u.getImageData(0,0,f.width,f.height)}function sg(s,t,e){const i=[];if(e){const n=Math.floor(Math.round(s[0])*Ve),r=Math.floor(Math.round(s[1])*Ve),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),d=Math.floor((256*256*256-1)/t.length);c&&c%d===0&&i.push(t[c/d-1])}return i}const rg=.5,Nc={Point:fg,LineString:cg,Polygon:pg,MultiPoint:gg,MultiLineString:dg,MultiPolygon:ug,GeometryCollection:hg,Circle:ag};function og(s,t){return parseInt(K(s),10)-parseInt(K(t),10)}function rh(s,t){const e=Gc(s,t);return e*e}function Gc(s,t){return rg*s/t}function ag(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 oh(s,t,e,i,n,r,o,a){const l=[],h=e.getImage();if(h){let u=!0;const f=h.getImageState();f==at.LOADED||f==at.ERROR?u=!1:f==at.IDLE&&h.load(),u&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const d=l.length>0;return d&&Promise.all(l).then(()=>n(null)),lg(s,t,e,i,r,o,a),d}function lg(s,t,e,i,n,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,n);if(e.getRenderer())Bc(s,l,e,t,o);else{const c=Nc[l.getType()];c(s,l,e,t,o,r)}}function Bc(s,t,e,i,n){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)Bc(s,o[a],e,i,n);return}s.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),n)}function hg(s,t,e,i,n,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=Nc[o[a].getType()];h(s,o[a],e,i,n,r)}}function cg(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 dg(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 ug(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 fg(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()!=at.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 gg(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()!=at.LOADED)return;const d=s.getBuilder(e.getZIndex(),"Image");d.setImageStyle(o,c),d.drawMultiPoint(t,i,n)}if(h){const d=s.getBuilder(e.getZIndex(),"Text");d.setTextStyle(l,c),d.drawText(t,i,n)}}function pg(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 hs extends qe{constructor(t,e,i,n){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=n}}const mg=5;class Wc extends Ts{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=mg}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return Q()}getData(t){return null}prepareFrame(t){return Q()}renderFrame(t,e){return Q()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===at.LOADED||e.getState()===at.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=at.LOADED&&e!=at.ERROR&&t.addEventListener(nt.CHANGE,this.boundHandleImageChange_),e==at.IDLE&&(t.load(),e=t.getState()),e==at.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const ah=[];let cn=null;function yg(){cn=$t(1,1,void 0,{willReadFrequently:!0})}class Uc extends Wc{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Ut(),this.pixelTransform=Ut(),this.inversePixelTransform=Ut(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){cn||yg(),cn.clearRect(0,0,1,1);let n;try{cn.drawImage(t,e,i,1,1,0,0,1,1),n=cn.getImageData(0,0,1,1).data}catch{return cn=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&&ui(Ie(t.style.backgroundColor),Ie(i)))){const a=t.firstElementChild;Ti(a)&&(o=a.getContext("2d"))}if(o&&ju(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=Ee?Sc():document.createElement("div"),r.className=n;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=$t();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=ji(i),r=Nr(i),o=$r(i),a=zr(i);zt(e.coordinateToPixelTransform,n),zt(e.coordinateToPixelTransform,r),zt(e.coordinateToPixelTransform,o),zt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;zt(l,n),zt(l,r),zt(l,o),zt(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(Et(i)/n*o),l=Math.round(he(i)/n*o);Pe(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Ur(this.inversePixelTransform,this.pixelTransform);const h=Xu(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 hs(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Yt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Yt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Fc),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Yt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Yt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,n,r,o,a){const l=r/2,h=o/2,c=n/e,d=-c,u=-t[0]+a,f=-t[1];return Pe(this.tempTransform,l,h,c,d,-i,u,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class _g extends Uc{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_=oe(),this.wrappedRenderedExtent_=oe(),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(),d=this.getLayer().getSource(),u=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,p=!(g[jt.ANIMATING]||g[jt.INTERACTING]),m=this.context,y=Math.round(Et(n)/a*f),x=Math.round(he(n)/a*f),E=d.getWrapX()&&l.canWrapX(),w=E?Et(c):null,C=E?Math.ceil((n[2]-c[2])/w)+(this.extendX_?2:1):1;let v=E?Math.floor((n[0]-c[0])/w)-(this.extendX_?1:0):0;do{let _=this.getRenderTransform(o,a,0,f,y,x,v*w);e.declutter&&(_=_.slice(0)),t.execute(m,[m.canvas.width,m.canvas.height],_,h,p,i===void 0?Ai:i?Oc:qf,i?u&&e.declutter[u]:void 0)}while(++v<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=$t(this.context.canvas.width,this.context.canvas.height,ah))}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,jr(this.context),ah.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(Yt.PRERENDER)||this.getLayer().hasListener(Yt.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=Fi(i.extent);a=le(h,t.extent),a&&!Yn(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=[],d=i[0]*Ve,u=i[1]*Ve;c.push(this.getRenderTransform(n,r,o,Ve,d,u,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Yn(g,l)){let p=l[0];const m=Et(g);let y=0,x;for(;p<g[0];)--y,x=m*y,c.push(this.getRenderTransform(n,r,o,Ve,d,u,x).slice()),p+=m;for(y=0,p=l[2];p>g[2];)++y,x=m*y,c.push(this.getRenderTransform(n,r,o,Ve,d,u,x).slice()),p-=m}this.hitDetectionImageData_=ng(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,rh(r,this.renderedPixelRatio_))}e(sg(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(u,f,g){const p=K(u),m=h[p];if(m){if(m!==!0&&g<m.distanceSq){if(g===0)return h[p]=!0,r.splice(r.lastIndexOf(m),1),n(u,l,f);m.geometry=f,m.distanceSq=g}}else{if(g===0)return h[p]=!0,n(u,l,f);r.push(h[p]={feature:u,layer:l,geometry:f,distanceSq:g,callback:n})}},d=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,d?e.declutter?.[d]?.all().map(u=>u.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[jt.ANIMATING],r=t.viewHints[jt.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,d=h.resolution,u=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let p=e.getRenderOrder();p===void 0&&(p=og);const m=h.center.slice(),y=An(l,g*d),x=y.slice(),E=[y.slice()],w=c.getExtent(),C=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,C){const R=i.getExtent();R&&!Ss(R)&&(this.extendX_=R[0]<w[0]||R[2]>w[2])}if(C&&(!Yn(w,t.extent)||this.extendX_)){const R=Et(w),B=Math.max(Et(y)/2,R);let D=w[0],z=w[2];this.extendX_&&(D-=R,z+=R),y[0]=D-B,y[2]=z+B,Qh(m,c);const N=Xh(E[0],c);N[0]<w[0]&&N[2]<w[2]?E.push([N[0]+R,N[1],N[2]+R,N[3]]):N[0]>w[0]&&N[2]>w[2]&&E.push([N[0]-R,N[1],N[2]-R,N[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===u&&this.renderedRevision_==f&&this.renderedRenderOrder_==p&&this.renderedFrameDeclutter_===!!t.declutter&&Yn(this.wrappedRenderedExtent_,y))return ui(this.renderedExtent_,x)||(this.hitDetectionImageData_=null,this.renderedExtent_=x),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const v=new Hf(Gc(d,u),y,d,u);let _;for(let R=0,B=E.length;R<B;++R)i.loadFeatures(E[R],d,c);const b=rh(d,u);let S=!0;const P=(R,B)=>{let D;const z=R.getStyleFunction()||e.getStyleFunction();if(z&&(D=z(R,d)),D){const N=this.renderFeature(R,b,D,v,_,this.getLayer().getDeclutter(),B);S=S&&!N}},L=lc(y),k=i.getFeaturesInExtent(L);p&&k.sort(p);for(let R=0,B=k.length;R<B;++R)P(k[R],R);this.renderedFeatures_=k,this.ready=S;const F=v.finish(),O=new Qf(y,d,u,i.getOverlaps(),F,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=d,this.renderedRevision_=f,this.renderedRenderOrder_=p,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=x,this.wrappedRenderedExtent_=y,this.renderedCenter_=m,this.renderedProjection_=c,this.renderedPixelRatio_=u,this.replayGroup_=O,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=oh(n,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=oh(n,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}function Vc(s,t,e=0,i=s.length-1,n=wg){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),d=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*d*(l-d)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*d/l+u)),g=Math.min(i,Math.floor(t+(l-h)*d/l+u));Vc(s,t,f,g,n)}const r=s[t];let o=e,a=i;for(Hn(s,e,t),n(s[i],r)>0&&Hn(s,e,i);o<a;){for(Hn(s,o,a),o++,a--;n(s[o],r)<0;)o++;for(;n(s[a],r)>0;)a--}n(s[e],r)===0?Hn(s,e,a):(a++,Hn(s,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Hn(s,t,e){const i=s[t];s[t]=s[e],s[e]=i}function wg(s,t){return s<t?-1:s>t?1:0}let Hc=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(!Zs(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;Zs(t,l)&&(e.leaf?i.push(a):Eo(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!Zs(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(Zs(t,o)){if(e.leaf||Eo(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=dn([]),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=xg(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Eo(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=dn(t.slice(e,i+1)),tn(a,this.toBBox),a;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),a=dn([]),a.leaf=!1,a.height=n;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));lh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const d=Math.min(c+h-1,i);lh(t,c,d,l,this.compareMinY);for(let u=c;u<=d;u+=l){const f=Math.min(u+l-1,d);a.children.push(this._build(t,u,f,n-1))}}return tn(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=Co(h),d=vg(t,h)-c;d<o?(o=d,r=c<r?c:r,a=h):d===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),Kn(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=dn(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,tn(i,this.toBBox),tn(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=dn([t,e]),this.data.height=t.height+1,this.data.leaf=!1,tn(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=Zn(t,0,a,this.toBBox),h=Zn(t,a,i,this.toBBox),c=Tg(l,h),d=Co(l)+Co(h);c<r?(r=c,n=a,o=d<o?d:o):c===r&&d<o&&(o=d,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:Cg,r=t.leaf?this.compareMinY:Eg,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=Zn(t,0,e,r),a=Zn(t,i-e,i,r);let l=Ys(o)+Ys(a);for(let h=e;h<i-e;h++){const c=t.children[h];Kn(o,t.leaf?r(c):c),l+=Ys(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];Kn(a,t.leaf?r(c):c),l+=Ys(a)}return l}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Kn(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():tn(t[e],this.toBBox)}};function xg(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 tn(s,t){Zn(s,0,s.children.length,t,s)}function Zn(s,t,e,i,n){n||(n=dn(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];Kn(n,s.leaf?i(o):o)}return n}function Kn(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 Cg(s,t){return s.minX-t.minX}function Eg(s,t){return s.minY-t.minY}function Co(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function Ys(s){return s.maxX-s.minX+(s.maxY-s.minY)}function vg(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 Tg(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 Eo(s,t){return s.minX<=t.minX&&s.minY<=t.minY&&t.maxX<=s.maxX&&t.maxY<=s.maxY}function Zs(s,t){return t.minX<=s.maxX&&t.minY<=s.maxY&&t.maxX>=s.minX&&t.maxY>=s.minY}function dn(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function lh(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;Vc(s,o,t,e,n),r.push(t,o,o,e)}}let Zi=0;const Gt=1<<Zi++,$=1<<Zi++,Wt=1<<Zi++,Rt=1<<Zi++,me=1<<Zi++,Te=1<<Zi++,Ks=Math.pow(2,Zi)-1,Za={[Gt]:"boolean",[$]:"number",[Wt]:"string",[Rt]:"color",[me]:"number[]",[Te]:"size"},bg=Object.keys(Za).map(Number).sort(ai);function Sg(s){return s in Za}function pn(s){const t=[];for(const e of bg)qn(s,e)&&t.push(Za[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function qn(s,t){return(s&t)===t}function Ue(s,t){return s===t}class Bt{constructor(t,e){if(!Sg(t))throw new Error(`literal expressions must have a specific type, got ${pn(t)}`);this.type=t,this.value=e}}class Xc{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function ks(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function Zt(s,t,e){switch(typeof s){case"boolean":{if(Ue(t,Wt))return new Bt(Wt,s?"true":"false");if(!qn(t,Gt))throw new Error(`got a boolean, but expected ${pn(t)}`);return new Bt(Gt,s)}case"number":{if(Ue(t,Te))return new Bt(Te,ce(s));if(Ue(t,Gt))return new Bt(Gt,!!s);if(Ue(t,Wt))return new Bt(Wt,s.toString());if(!qn(t,$))throw new Error(`got a number, but expected ${pn(t)}`);return new Bt($,s)}case"string":{if(Ue(t,Rt))return new Bt(Rt,Xa(s));if(Ue(t,Gt))return new Bt(Gt,!!s);if(!qn(t,Wt))throw new Error(`got a string, but expected ${pn(t)}`);return new Bt(Wt,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 $g(s,t,e);for(const i of s)if(typeof i!="number")throw new Error("expected an array of numbers");if(Ue(t,Te)){if(s.length!==2)throw new Error(`expected an array of two values for a size, got ${s.length}`);return new Bt(Te,s)}if(Ue(t,Rt)){if(s.length===3)return new Bt(Rt,[...s,1]);if(s.length===4)return new Bt(Rt,s);throw new Error(`expected an array of 3 or 4 values for a color, got ${s.length}`)}if(!qn(t,me))throw new Error(`got an array of numbers, but expected ${pn(t)}`);return new Bt(me,s)}const T={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"},Pg={[T.Get]:q(lt(1,1/0),hh),[T.Var]:q(lt(1,1),Ig),[T.Has]:q(lt(1,1/0),hh),[T.Id]:q(Lg,en),[T.Concat]:q(lt(2,1/0),_t(Wt)),[T.GeometryType]:q(Dg,en),[T.LineMetric]:q(kg,en),[T.Resolution]:q(vo,en),[T.Zoom]:q(vo,en),[T.Time]:q(vo,en),[T.Any]:q(lt(2,1/0),_t(Gt)),[T.All]:q(lt(2,1/0),_t(Gt)),[T.Not]:q(lt(1,1),_t(Gt)),[T.Equal]:q(lt(2,2),_t(Ks)),[T.NotEqual]:q(lt(2,2),_t(Ks)),[T.GreaterThan]:q(lt(2,2),_t($)),[T.GreaterThanOrEqualTo]:q(lt(2,2),_t($)),[T.LessThan]:q(lt(2,2),_t($)),[T.LessThanOrEqualTo]:q(lt(2,2),_t($)),[T.Multiply]:q(lt(2,1/0),ch),[T.Coalesce]:q(lt(2,1/0),ch),[T.Divide]:q(lt(2,2),_t($)),[T.Add]:q(lt(2,1/0),_t($)),[T.Subtract]:q(lt(2,2),_t($)),[T.Clamp]:q(lt(3,3),_t($)),[T.Mod]:q(lt(2,2),_t($)),[T.Pow]:q(lt(2,2),_t($)),[T.Abs]:q(lt(1,1),_t($)),[T.Floor]:q(lt(1,1),_t($)),[T.Ceil]:q(lt(1,1),_t($)),[T.Round]:q(lt(1,1),_t($)),[T.Sin]:q(lt(1,1),_t($)),[T.Cos]:q(lt(1,1),_t($)),[T.Atan]:q(lt(1,2),_t($)),[T.Sqrt]:q(lt(1,1),_t($)),[T.Match]:q(lt(4,1/0),dh,Ag),[T.Between]:q(lt(3,3),_t($)),[T.Interpolate]:q(lt(6,1/0),dh,Mg),[T.Case]:q(lt(3,1/0),Rg,Fg),[T.In]:q(lt(2,2),Og),[T.Number]:q(lt(1,1/0),_t(Ks)),[T.String]:q(lt(1,1/0),_t(Ks)),[T.Array]:q(lt(1,1/0),_t($)),[T.Color]:q(lt(1,4),_t($)),[T.Band]:q(lt(1,3),_t($)),[T.Palette]:q(lt(2,2),zg),[T.ToString]:q(lt(1,1),_t(Gt|$|Wt|Rt))};function hh(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 Bt($,o);break}case"string":{n[r]=new Bt(Wt,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 Ig(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 Bt(Wt,i)]}function Lg(s,t,e){e.featureId=!0}function Dg(s,t,e){e.geometryType=!0}function kg(s,t,e){e.mCoordinate=!0}function vo(s,t,e){e.mapState=!0}function en(s,t,e){const i=s[0];if(s.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function lt(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 ch(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;r<i;++r){const o=Zt(s[r+1],t,e);n[r]=o}return n}function _t(s){return function(t,e,i){const n=t.length-1,r=new Array(n);for(let o=0;o<n;++o){const a=Zt(t[o+1],s,i);r[o]=a}return r}}function Rg(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 dh(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 Ag(s,t,e){const i=s.length-1,n=Wt|$|Gt,r=Zt(s[1],n,e),o=Zt(s[s.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=Zt(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=Zt(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 Mg(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 Bt($,n);let o;try{o=Zt(s[2],$,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=Zt(s[l+3],$,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=Zt(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 Fg(s,t,e){const i=Zt(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=Zt(s[r+1],Gt,e);n[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=Zt(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=Wt:n=$;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=Zt(i[a],n,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Zt(s[1],n,e),...r]}function zg(s,t,e){let i;try{i=Zt(s[1],$,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=Zt(n[o],Rt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof Bt))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function q(...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 Xc(e,n,...r)}}function $g(s,t,e){const i=s[0],n=Pg[i];if(!n)throw new Error(`unknown operator: ${i}`);return n(s,t,e)}function Ka(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 Ka(s.getGeometries()[0]);default:return""}}function jc(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Ke(s,t,e){const i=Zt(s,t,e);return ze(i)}function ze(s,t){if(s instanceof Bt){if(s.type===Rt&&typeof s.value=="string"){const i=Xa(s.value);return function(){return i}}return function(){return s.value}}const e=s.operator;switch(e){case T.Number:case T.String:case T.Coalesce:return Ng(s);case T.Get:case T.Var:case T.Has:return Gg(s);case T.Id:return i=>i.featureId;case T.GeometryType:return i=>i.geometryType;case T.Concat:{const i=s.args.map(n=>ze(n));return n=>"".concat(...i.map(r=>r(n).toString()))}case T.Resolution:return i=>i.resolution;case T.Any:case T.All:case T.Between:case T.In:case T.Not:return Wg(s);case T.Equal:case T.NotEqual:case T.LessThan:case T.LessThanOrEqualTo:case T.GreaterThan:case T.GreaterThanOrEqualTo:return Bg(s);case T.Multiply:case T.Divide:case T.Add:case T.Subtract:case T.Clamp:case T.Mod:case T.Pow:case T.Abs:case T.Floor:case T.Ceil:case T.Round:case T.Sin:case T.Cos:case T.Atan:case T.Sqrt:return Ug(s);case T.Case:return Vg(s);case T.Match:return Hg(s);case T.Interpolate:return Xg(s);case T.ToString:return jg(s);default:throw new Error(`Unsupported operator ${e}`)}}function Ng(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=ze(s.args[r]);switch(e){case T.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 T.Number:case T.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 Gg(s,t){const i=s.args[0].value;switch(s.operator){case T.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 T.Var:return n=>n.variables[i];case T.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 Bg(s,t){const e=s.operator,i=ze(s.args[0]),n=ze(s.args[1]);switch(e){case T.Equal:return r=>i(r)===n(r);case T.NotEqual:return r=>i(r)!==n(r);case T.LessThan:return r=>i(r)<n(r);case T.LessThanOrEqualTo:return r=>i(r)<=n(r);case T.GreaterThan:return r=>i(r)>n(r);case T.GreaterThanOrEqualTo:return r=>i(r)>=n(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function Wg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=ze(s.args[r]);switch(e){case T.Any:return r=>{for(let o=0;o<i;++o)if(n[o](r))return!0;return!1};case T.All:return r=>{for(let o=0;o<i;++o)if(!n[o](r))return!1;return!0};case T.Between:return r=>{const o=n[0](r),a=n[1](r),l=n[2](r);return o>=a&&o<=l};case T.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 T.Not:return r=>!n[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function Ug(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=ze(s.args[r]);switch(e){case T.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=n[a](r);return o};case T.Divide:return r=>n[0](r)/n[1](r);case T.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=n[a](r);return o};case T.Subtract:return r=>n[0](r)-n[1](r);case T.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 T.Mod:return r=>n[0](r)%n[1](r);case T.Pow:return r=>Math.pow(n[0](r),n[1](r));case T.Abs:return r=>Math.abs(n[0](r));case T.Floor:return r=>Math.floor(n[0](r));case T.Ceil:return r=>Math.ceil(n[0](r));case T.Round:return r=>Math.round(n[0](r));case T.Sin:return r=>Math.sin(n[0](r));case T.Cos:return r=>Math.cos(n[0](r));case T.Atan:return i===2?r=>Math.atan2(n[0](r),n[1](r)):r=>Math.atan(n[0](r));case T.Sqrt:return r=>Math.sqrt(n[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function Vg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=ze(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 Hg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=ze(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 Xg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=ze(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 d=i[h+1](n);const u=Array.isArray(d);if(u&&(d=vf(d)),c>=o)return h===2?d:u?Yg(r,o,a,l,c,d):Jn(r,o,a,l,c,d);a=c,l=d}return l}}function jg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=ze(s.args[r]);if(e===T.ToString)return r=>{const o=n[0](r);return s.args[0].type===Rt?ja(o):o.toString()};throw new Error(`Unsupported convert operator ${e}`)}function Jn(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=Yl(i),l=Yl(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[Jn(s,t,e,a[0],n,l[0]),Jn(s,t,e,a[1],n,l[1]),a[2]+Jn(s,t,e,0,n,h),Jn(s,t,e,i[3],n,r[3])];return Tf(c)}class Bi extends Zr{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()?at.LOADING:at.LOADED,this.imageState_===at.LOADING&&this.ready().then(()=>this.imageState_=at.LOADED),this.render()}clone(){const t=this.getScale(),e=new Bi({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=ve.get(i,null)?.getImage(1);if(!n){const r=this.renderOptions_,o=Math.ceil(r.size*t),a=$t(o,o);this.draw_(r,a,t),n=a.canvas;const l=new Ic(n,void 0,null,at.LOADED,null);ve.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 v=n;n=r,r=v}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=n-h,d=Math.sqrt(l*l+c*c),u=d/l;if(t==="miter"&&u<=i)return u*e;const f=e/2/u,g=e/2*(c/d),m=Math.sqrt((n+f)*(n+f)+g*g)-n;if(this.radius2_===void 0||t==="bevel")return m*2;const y=n*Math.sin(a),x=Math.sqrt(n*n-y*y),E=r-x,C=Math.sqrt(y*y+E*E)/y;if(C<=i){const v=C*e/2-r-n;return 2*Math.max(m,v)}return m*2}createRenderOptions(){let t=Pn,e=In,i=0,n=null,r=0,o,a=0;this.stroke_&&(o=Xe(this.stroke_.getColor()??Ze),a=this.stroke_.getWidth()??_s,n=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??In,t=this.stroke_.getLineCap()??Pn,i=this.stroke_.getMiterLimit()??ms);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=ue),e.fillStyle=Xe(n),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),n=0;typeof i=="string"&&(i=Ie(i)),i===null?n=1:Array.isArray(i)&&(n=i.length===4?i[3]:1),n===0&&(e=$t(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=ue,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 Le extends Bi{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 Le({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 j{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 j({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=ls(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()===at.IDLE&&e.load(),e.getImageState()===at.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?K(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:Ie(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class G{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 G({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 A{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=uh,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 A({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_=uh,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function Zg(s){let t;if(typeof s=="function")t=s;else{let e;Array.isArray(s)?e=s:(gt(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[s]),t=function(){return e}}return t}let To=null;function Yc(s,t){if(!To){const e=new j({color:"rgba(255,255,255,0.4)"}),i=new G({color:"#3399CC",width:1.25});To=[new A({image:new Le({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return To}function Kg(){const s={},t=[255,255,255,1],e=[0,153,255,1],i=3;return s.Polygon=[new A({fill:new j({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new A({stroke:new G({color:t,width:i+2})}),new A({stroke:new G({color:e,width:i})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new A({image:new Le({radius:i*2,fill:new j({color:e}),stroke:new G({color:t,width:i/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function uh(s){return s.getGeometry()}const qg="#333";class te{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_=ce(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 j({color:qg}),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 te({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 j?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_=ce(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 Jg(s){return!0}function Qg(s){const t=ks(),e=tp(s,t),i=jc();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=Ka(n.getGeometry())),e(i)}}function fh(s){const t=ks(),e=s.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=aa(s[o],t);const n=jc(),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 tp(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?Ke(r.filter,Gt,t):Jg;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]=aa(r.style[h],t)}else a=[aa(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 aa(s,t){const e=ws(s,"",t),i=xs(s,"",t),n=ep(s,t),r=ip(s,t),o=Qt(s,"z-index",t);if(!e&&!i&&!n&&!r&&!Wi(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));const a=new A;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 ws(s,t,e){let i;if(t+"fill-pattern-src"in s)i=op(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 j;return function(r){const o=i(r);return o===Ha?null:(n.setColor(o),n)}}function xs(s,t,e){const i=Qt(s,t+"stroke-width",e),n=Kr(s,t+"stroke-color",e);if(!i&&!n)return null;const r=ri(s,t+"stroke-line-cap",e),o=ri(s,t+"stroke-line-join",e),a=Zc(s,t+"stroke-line-dash",e),l=Qt(s,t+"stroke-line-dash-offset",e),h=Qt(s,t+"stroke-miter-limit",e),c=Qt(s,t+"stroke-offset",e),d=new G;return function(u){if(n){const f=n(u);if(f===Ha)return null;d.setColor(f)}if(i&&d.setWidth(i(u)),r){const f=r(u);if(f!=="butt"&&f!=="round"&&f!=="square")throw new Error("Expected butt, round, or square line cap");d.setLineCap(f)}if(o){const f=o(u);if(f!=="bevel"&&f!=="round"&&f!=="miter")throw new Error("Expected bevel, round, or miter line join");d.setLineJoin(f)}return a&&d.setLineDash(a(u)),l&&d.setLineDashOffset(l(u)),h&&d.setMiterLimit(h(u)),c&&d.setOffset(c(u)),d}}function ep(s,t){const e="text-",i=ri(s,e+"value",t);if(!i)return null;const n=ws(s,e,t),r=ws(s,e+"background-",t),o=xs(s,e,t),a=xs(s,e+"background-",t),l=ri(s,e+"font",t),h=Qt(s,e+"max-angle",t),c=Qt(s,e+"offset-x",t),d=Qt(s,e+"offset-y",t),u=xn(s,e+"overflow",t),f=ri(s,e+"placement",t),g=Qt(s,e+"repeat",t),p=qr(s,e+"scale",t),m=xn(s,e+"rotate-with-view",t),y=Qt(s,e+"rotation",t),x=ri(s,e+"align",t),E=ri(s,e+"justify",t),w=ri(s,e+"baseline",t),C=xn(s,e+"keep-upright",t),v=Zc(s,e+"padding",t),_=Jr(s,e+"declutter-mode"),b=new te({declutterMode:_});return function(S){if(b.setText(i(S)),n&&b.setFill(n(S)),r&&b.setBackgroundFill(r(S)),o&&b.setStroke(o(S)),a&&b.setBackgroundStroke(a(S)),l&&b.setFont(l(S)),h&&b.setMaxAngle(h(S)),c&&b.setOffsetX(c(S)),d&&b.setOffsetY(d(S)),u&&b.setOverflow(u(S)),f){const P=f(S);if(P!=="point"&&P!=="line")throw new Error("Expected point or line for text-placement");b.setPlacement(P)}if(g&&b.setRepeat(g(S)),p&&b.setScale(p(S)),m&&b.setRotateWithView(m(S)),y&&b.setRotation(y(S)),x){const P=x(S);if(P!=="left"&&P!=="center"&&P!=="right"&&P!=="end"&&P!=="start")throw new Error("Expected left, right, center, start, or end for text-align");b.setTextAlign(P)}if(E){const P=E(S);if(P!=="left"&&P!=="right"&&P!=="center")throw new Error("Expected left, right, or center for text-justify");b.setJustify(P)}if(w){const P=w(S);if(P!=="bottom"&&P!=="top"&&P!=="middle"&&P!=="alphabetic"&&P!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");b.setTextBaseline(P)}return v&&b.setPadding(v(S)),C&&b.setKeepUpright(C(S)),b}}function ip(s,t){return"icon-src"in s?np(s,t):"shape-points"in s?sp(s,t):"circle-radius"in s?rp(s,t):null}function np(s,t){const e="icon-",i=e+"src",n=Kc(s[i],i),r=Pr(s,e+"anchor",t),o=qr(s,e+"scale",t),a=Qt(s,e+"opacity",t),l=Pr(s,e+"displacement",t),h=Qt(s,e+"rotation",t),c=xn(s,e+"rotate-with-view",t),d=ph(s,e+"anchor-origin"),u=mh(s,e+"anchor-x-units"),f=mh(s,e+"anchor-y-units"),g=fi(s,e+"color");let p,m=null;g!==void 0&&(Array.isArray(g)&&g.length>0&&typeof g[0]=="string"?m=Kr(s,e+"color",t):p=qc(g,e+"color"));const y=lp(s,e+"cross-origin"),x=hp(s,e+"offset"),E=ph(s,e+"offset-origin"),w=la(s,e+"width"),C=la(s,e+"height"),v=ap(s,e+"size"),_=Jr(s,e+"declutter-mode"),b={src:n,anchorOrigin:d,anchorXUnits:u,anchorYUnits:f,crossOrigin:y,offset:x,offsetOrigin:E,height:C,width:w,size:v,declutterMode:_};let S=null;return function(P){if(S)m&&S.setColor(m(P));else{const L=m?m(P):p;S=new Vi(L!==void 0?Object.assign({},b,{color:L}):Object.assign({},b))}return a&&S.setOpacity(a(P)),l&&S.setDisplacement(l(P)),h&&S.setRotation(h(P)),c&&S.setRotateWithView(c(P)),o&&S.setScale(o(P)),r&&S.setAnchor(r(P)),S}}function sp(s,t){const e="shape-",i=e+"points",n=e+"radius",r=qa(s[i],i);if(!(n in s))throw new Error(`Expected a number for ${n}`);const o=Qt(s,n,t),a=typeof s[n]=="number"?s[n]:5,l=e+"radius2",h=Qt(s,l,t),c=typeof s[l]=="number"?s[l]:void 0,d=ws(s,e,t),u=xs(s,e,t),f=qr(s,e+"scale",t),g=Pr(s,e+"displacement",t),p=Qt(s,e+"rotation",t),m=xn(s,e+"rotate-with-view",t),y=la(s,e+"angle"),x=Jr(s,e+"declutter-mode"),E=new Bi({points:r,radius:a,radius2:c,angle:y,declutterMode:x});return function(w){return o&&E.setRadius(o(w)),h&&E.setRadius2(h(w)),d&&E.setFill(d(w)),u&&E.setStroke(u(w)),g&&E.setDisplacement(g(w)),p&&E.setRotation(p(w)),m&&E.setRotateWithView(m(w)),f&&E.setScale(f(w)),E}}function rp(s,t){const e="circle-",i=ws(s,e,t),n=xs(s,e,t),r=Qt(s,e+"radius",t),o=qr(s,e+"scale",t),a=Pr(s,e+"displacement",t),l=Qt(s,e+"rotation",t),h=xn(s,e+"rotate-with-view",t),c=Jr(s,e+"declutter-mode"),d=new Le({radius:5,declutterMode:c});return function(u){return r&&d.setRadius(r(u)),i&&d.setFill(i(u)),n&&d.setStroke(n(u)),a&&d.setDisplacement(a(u)),l&&d.setRotation(l(u)),h&&d.setRotateWithView(h(u)),o&&d.setScale(o(u)),d}}function fi(s,t){if(!(t in s))return;const e=s[t];return e===void 0?void 0:e}function Qt(s,t,e){const i=fi(s,t);if(i===void 0)return;const n=Ke(i,$,e);return function(r){return qa(n(r),t)}}function ri(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,Wt,e);return function(r){return Kc(n(r),t)}}function op(s,t,e){const i=ri(s,t+"pattern-src",e),n=gh(s,t+"pattern-offset",e),r=gh(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 xn(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,Gt,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=fi(s,t);if(i===void 0)return null;const n=Ke(i,Rt,e);return function(r){return qc(n(r),t)}}function Zc(s,t,e){const i=fi(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=Ke(o,$,e);return function(h){return qa(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=Ke(i,me,e);return function(r){return Rs(n(r),t)}}function Pr(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,me,e);return function(r){const o=Rs(n(r),t);if(o.length!==2)throw new Error(`Expected two numbers for ${t}`);return o}}function gh(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,me,e);return function(r){return Jc(n(r),t)}}function qr(s,t,e){const i=fi(s,t);if(i===void 0)return null;const n=Ke(i,me|$,e);return function(r){return cp(n(r),t)}}function la(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 ap(s,t){const e=s[t];if(e!==void 0){if(typeof e=="number")return ce(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 lp(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 ph(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 mh(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 hp(s,t){const e=s[t];if(e!==void 0)return Rs(e,t)}function Jr(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 Rs(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 Kc(s,t){if(typeof s!="string")throw new Error(`Expected a string for ${t}`);return s}function qa(s,t){if(typeof s!="number")throw new Error(`Expected a number for ${t}`);return s}function qc(s,t){if(typeof s=="string")return s;const e=Rs(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 Jc(s,t){const e=Rs(s,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function cp(s,t){return typeof s=="number"?s:Jc(s,t)}const De={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function yh(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,d=a?a[1]:0;let u=s[0]+l/2+c,f=s[2]-l/2+c,g=s[1]+h/2+d,p=s[3]-h/2+d;u>f&&(u=(f+u)/2,f=u),g>p&&(g=(p+g)/2,p=g);let m=Pt(i[0],u,f),y=Pt(i[1],g,p);if(o&&e&&n){const x=30*n;m+=-x*Math.log(1+Math.max(0,u-i[0])/x)+x*Math.log(1+Math.max(0,i[0]-f)/x),y+=-x*Math.log(1+Math.max(0,g-i[1])/x)+x*Math.log(1+Math.max(0,i[1]-p)/x)}return[m,y]})}function dp(s){return s}function Qc(s){return Math.pow(s,3)}function Mn(s){return 1-Qc(1-s)}function up(s){return 3*s*s-2*s*s*s}function fp(s){return s}function Ja(s,t,e,i){const n=Et(t)/e[0],r=he(t)/e[1];return i?Math.min(s,Math.max(n,r)):Math.min(s,Math.min(n,r))}function Qa(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 gp(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?Ja(l,e,o,i):l;if(a)return t?Qa(n,c,h):Pt(n,h,c);const d=Math.min(c,n),u=Math.floor(xa(s,d,r));return s[u]>c&&u<s.length-1?s[u+1]:s[u]}})}function pp(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?Ja(t,n,l,r):t;if(h)return i?Qa(o,c,e):Pt(o,e,c);const d=1e-9,u=Math.ceil(Math.log(t/c)/Math.log(s)-d),f=-a*(.5-d)+.5,g=Math.min(c,o),p=Math.floor(Math.log(t/g)/Math.log(s)+f),m=Math.max(u,p),y=t/Math.pow(s,m);return Pt(y,e,c)}})}function _h(s,t,e,i,n){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?Ja(s,i,a,n):s;return!e||!l?Pt(r,t,h):Qa(r,h,t)}})}function tl(s){if(s!==void 0)return 0}function wh(s){if(s!==void 0)return s}function mp(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 yp(s){const t=Fe(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const _p=42,el=256,bo=0;class He extends $e{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Ra(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&&ac(),t.center&&(t.center=Re(t.center,this.projection_)),t.extent&&(t.extent=Fi(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in De)delete e[a];this.setProperties(e,!0);const i=xp(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=wp(t),r=i.constraint,o=Cp(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=Re(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=Re(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&&qs(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],d={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||up,callback:i};if(c.center&&(d.sourceCenter=o,d.targetCenter=c.center.slice(),o=d.targetCenter),c.zoom!==void 0?(d.sourceResolution=a,d.targetResolution=this.getResolutionForZoom(c.zoom),a=d.targetResolution):c.resolution&&(d.sourceResolution=a,d.targetResolution=c.resolution,a=d.targetResolution),c.rotation!==void 0){d.sourceRotation=l;const u=Gi(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;d.targetRotation=l+u,l=d.targetRotation}Ep(d)?d.complete=!0:r+=d.duration,h.push(d)}this.animations_.push(h),this.setHint(jt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[jt.ANIMATING]>0}getInteracting(){return this.hints_[jt.INTERACTING]>0}cancelAnimations(){this.setHint(jt.ANIMATING,-this.hints_[jt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const n=this.animations_[e];if(n[0].callback&&qs(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 d=l.easing(c);if(l.sourceCenter){const u=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],p=l.targetCenter[1];this.nextCenter_=l.targetCenter;const m=u+d*(g-u),y=f+d*(p-f);this.targetCenter_=[m,y]}if(l.sourceResolution&&l.targetResolution){const u=d===1?l.targetResolution:l.sourceResolution+d*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(u,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=u,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const u=d===1?Gi(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+d*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(u,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=u}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(jt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=n[0].callback;o&&qs(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]],ba(i,t-this.getRotation()),Zh(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&&Qo(t,this.getProjection())}getCenterInternal(){return this.get(De.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 lc(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();gt(e,"The view center is not defined");const i=this.getResolution();gt(i!==void 0,"The view resolution is not defined");const n=this.getRotation();return gt(n!==void 0,"The view rotation is not defined"),jo(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(De.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Fi(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=Et(t)/e[0],n=he(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(De.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=So(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=xa(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(gt(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){gt(!Ss(t),"Cannot fit empty extent provided as `geometry`");const n=Fi(t,this.getProjection());i=gn(n)}else if(t.getType()==="Circle"){const n=Fi(t.getExtent(),this.getProjection());i=gn(n),i.rotate(this.getRotation(),be(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 d=0,u=r.length;d<u;d+=o){const f=r[d]*i-r[d+1]*n,g=r[d]*n+r[d+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),d=Math.cos(h),u=be(a);u[0]+=(n[1]-n[3])/2*l,u[1]+=(n[0]-n[2])/2*l;const f=u[0]*d-u[1]*c,g=u[1]*d+u[0]*c,p=this.getConstrainedCenter([f,g],l),m=e.callback?e.callback:ds;e.duration!==void 0?this.animateInternal({resolution:l,center:p,duration:e.duration,easing:e.easing},m):(this.targetResolution_=l,this.targetCenter_=p,this.applyTargetState_(!1,!0),qs(m,!0))}centerOn(t,e,i){this.centerOnInternal(Re(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(So(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=So(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=Qo(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&&Re(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=Re(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&&Re(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(De.ROTATION)!==n&&this.set(De.ROTATION,n),this.get(De.RESOLUTION)!==o&&(this.set(De.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(De.CENTER)||!_r(this.get(De.CENTER),a))&&this.set(De.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()||!_r(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:Mn,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(jt.INTERACTING,1)}endInteraction(t,e,i){i=i&&Re(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(jt.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 qs(s,t){setTimeout(function(){s(t)},0)}function wp(s){if(s.extent!==void 0){const e=s.smoothExtentConstraint!==void 0?s.smoothExtentConstraint:!0;return yh(s.extent,s.constrainOnlyCenter,e)}const t=Ra(s.projection,"EPSG:3857");if(s.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,yh(e,!1,!1)}return dp}function xp(s){let t,e,i,o=s.minZoom!==void 0?s.minZoom:bo,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,d=s.showFullExtent!==void 0?s.showFullExtent:!1,u=Ra(s.projection,"EPSG:3857"),f=u.getExtent();let g=s.constrainOnlyCenter,p=s.extent;if(!h&&!p&&u.isGlobal()&&(g=!1,p=f),s.resolutions!==void 0){const m=s.resolutions;e=m[o],i=m[a]!==void 0?m[a]:m[m.length-1],s.constrainResolution?t=gp(m,c,!g&&p,d):t=_h(e,i,c,!g&&p,d)}else{const y=(f?Math.max(Et(f),he(f)):360*Sa.degrees/u.getMetersPerUnit())/el/Math.pow(2,bo),x=y/Math.pow(2,28-bo);e=s.maxResolution,e!==void 0?o=0:e=y/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=y/Math.pow(l,a):i=x),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),s.constrainResolution?t=pp(l,e,i,c,!g&&p,d):t=_h(e,i,c,!g&&p,d)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function Cp(s){if(s.enableRotation!==void 0?s.enableRotation:!0){const e=s.constrainRotation;return e===void 0||e===!0?yp():e===!1?wh:typeof e=="number"?mp(e):wh}return tl}function Ep(s){return!(s.sourceCenter&&s.targetCenter&&!_r(s.sourceCenter,s.targetCenter)||s.sourceResolution!==s.targetResolution||s.sourceRotation!==s.targetRotation)}function So(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 wt={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 td extends $e{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[wt.OPACITY]=t.opacity!==void 0?t.opacity:1,gt(typeof e[wt.OPACITY]=="number","Layer opacity must be a number"),e[wt.VISIBLE]=t.visible!==void 0?t.visible:!0,e[wt.Z_INDEX]=t.zIndex,e[wt.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[wt.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[wt.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[wt.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 Q()}getLayerStatesArray(t){return Q()}getExtent(){return this.get(wt.EXTENT)}getMaxResolution(){return this.get(wt.MAX_RESOLUTION)}getMinResolution(){return this.get(wt.MIN_RESOLUTION)}getMinZoom(){return this.get(wt.MIN_ZOOM)}getMaxZoom(){return this.get(wt.MAX_ZOOM)}getOpacity(){return this.get(wt.OPACITY)}getSourceState(){return Q()}getVisible(){return this.get(wt.VISIBLE)}getZIndex(){return this.get(wt.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(wt.EXTENT,t)}setMaxResolution(t){this.set(wt.MAX_RESOLUTION,t)}setMinResolution(t){this.set(wt.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(wt.MAX_ZOOM,t)}setMinZoom(t){this.set(wt.MIN_ZOOM,t)}setOpacity(t){gt(typeof t=="number","Layer opacity must be a number"),this.set(wt.OPACITY,t)}setVisible(t){this.set(wt.VISIBLE,t)}setZIndex(t){this.set(wt.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}class Qr extends td{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(wt.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(wt.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_&&(Tt(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=ft(t,nt.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 He?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 il(n,e.viewState)&&(!r||le(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof He?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(wt.MAP,t)}getMapInternal(){return this.get(wt.MAP)}setMap(t){this.mapPrecomposeKey_&&(Tt(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(Tt(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=ft(t,Yt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=ft(this,nt.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);gt(!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(wt.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 il(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 xh={RENDER_ORDER:"renderOrder"};class to extends Qr{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(xh.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 Hc(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(xh.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Yc:t;const e=vp(t);this.styleFunction_=t===null?void 0:Zg(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function vp(s){if(s===void 0)return Yc;if(!s)return null;if(typeof s=="function"||s instanceof A)return s;if(!Array.isArray(s))return fh([s]);if(s.length===0)return[];const t=s.length,e=s[0];if(e instanceof A){const n=new Array(t);for(let r=0;r<t;++r){const o=s[r];if(!(o instanceof A))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 Qg(n)}return fh(s)}class bt extends to{constructor(t){super(t)}createRenderer(){return new _g(this)}}const fe={ADD:"add",REMOVE:"remove"},Ch={LENGTH:"length"};class Js extends qe{constructor(t,e,i){super(t),this.element=e,this.index=i}}class pe extends $e{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(Ch.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 Js(fe.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 Js(fe.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 Js(fe.REMOVE,n,t)),this.dispatchEvent(new Js(fe.ADD,e,t))}updateLength_(){this.set(Ch.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 Tp=!1;function bp(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=Tp,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 Eh(s,t){return function(e,i,n,r,o){bp(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]]}class Ln extends Pi{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];je(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){je(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Ln(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Oa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),$a(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,tf(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return gs(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new pt(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 pt(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+=Ga(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=Er(e,i,l,r,.5);je(t,h),i=l}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=yc(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new Ln(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return sf(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Ls(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}class As extends Pi{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){je(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new As(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<Xi(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=li(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 vi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new rt(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 rt(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(Ca(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Vr(this.flatCoordinates,0,t,this.stride),this.changed()}}function ed(s,t,e,i){const n=[];let r=oe();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=va(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 Dn extends Pi{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,d=h.getEnds();for(let u=0,f=d.length;u<f;++u)d[u]+=c;je(r,h.getFlatCoordinates()),o.push(d)}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;je(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 Dn(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,n){return n<Xi(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ju(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Qu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return nf(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return lf(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),na(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,ea(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=ed(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=xc(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new As(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Cc(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=na(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=af(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new Dn(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 it(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 d=0,u=l.length;d<u;++d)l[d]-=r;const c=new it(e.slice(r,h),t,l);n.push(c),r=h}return n}getType(){return"MultiPolygon"}intersectsExtent(t){return rf(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=fc(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 vh=Ut();class ge{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"?Ea(this.flatCoordinates_):va(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=be(this.getExtent());this.flatInteriorPoints_=Wa(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=Ec(this.flatCoordinates_,this.ends_),e=ed(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=xc(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Er(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=Er(t,e,o,this.stride_,.5);je(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=Ft(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const n=he(i)/he(e);Pe(vh,i[0],i[3],n,-n,0,0,0),Ye(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,vh,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new ge(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Bh((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=Xr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=yc(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=Ba(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n);break}return n&&(this.simplifiedGeometry_=new ge(this.type_,i,n,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}ge.prototype.getFlatCoordinates=ge.prototype.getOrientedFlatCoordinates;class Th{constructor(t){this.rbush_=new Hc(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[K(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;n<r;n++){const o=t[n],a=e[n],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[n]=l,this.items_[K(a)]=l}this.rbush_.load(i)}remove(t){const e=K(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[K(e)],n=[i.minX,i.minY,i.maxX,i.maxY];bn(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 Wi(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return di(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 id extends $e{constructor(t){super(),this.projection=Ft(t.projection),this.attributions_=bh(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_=bh(t),this.changed()}setState(t){this.state_=t,this.changed()}}function bh(s){return s?typeof s=="function"?s:(Array.isArray(s)||(s=[s]),t=>s):null}const re={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class yi extends qe{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class Y extends id{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_=ds,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&&(gt(this.format_,"`format` must be set when `url` is set"),this.loader_=Eh(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 Th:null,this.loadedExtentsRtree_=new Th,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 pe(n)),n!==void 0&&this.addFeaturesInternal(n),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=K(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const n=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new yi(re.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof ge||(this.featureChangeKeys_[t]=[ft(e,nt.CHANGE,this.handleFeatureChange_,this),ft(e,En.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 ge){const r=this.idIndex_[n];r instanceof ge?Array.isArray(r)?r.push(e):this.idIndex_[n]=[r,e]:i=!1}else i=!1}return i&&(gt(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],n=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=K(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=K(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),n.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,n),this.hasListener(re.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new yi(re.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(re.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(re.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(fe.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(fe.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(Tt);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 yi(re.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 ge||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 ge||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(),Wi(this.nullGeometryFeatures_)||je(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=jh(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||vn,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),d=a;if(a=c instanceof ge?0:c.closestPointXY(i,n,o,a),a<d){r=h;const u=Math.sqrt(a);l[0]=i-u,l[1]=n-u,l[2]=i+u,l[3]=n+u}}}),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=K(e),n=e.getGeometry();if(!n)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=n.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new yi(re.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:K(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Wi(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 Yn(c.extent,l)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new yi(re.FEATURESLOADSTART));const c=g=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new yi(re.FEATURESLOADEND,void 0,g))},d=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new yi(re.FEATURESLOADERROR))};let u=!1;const f=this.loader_.call(this,l,e,i,g=>u||c(g),()=>u||d());f instanceof Promise?(u=!0,f.then(g=>{this.addFeatures(g),c(g)}).catch(d)):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(bn(n.extent,t))return n});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;i<n;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=K(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(Tt),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(re.REMOVEFEATURE)&&this.dispatchEvent(new yi(re.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){gt(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Eh(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}class un extends qe{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class si extends un{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 Ct={SINGLECLICK:"singleclick",CLICK:nt.CLICK,DBLCLICK:nt.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};function ha(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 Pp=function(s){const t=s.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Ip=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)},nd=function(s){const t=s.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?Ip(s):!0},cr=vn,sd=function(s){const t=s.originalEvent;return"pointerId"in t&&t.button==0&&!(uf&&vc&&t.ctrlKey)},Lp=Rn,nl=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},Dp=function(s){const t=s.originalEvent;return vc?t.metaKey:t.ctrlKey},ca=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},rd=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"},kp=function(s){const t=s.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};class Me extends Pi{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 Me(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 di(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(le(t,e)){const i=this.getCenter();return t[0]<=i[0]&&t[2]>=i[0]||t[1]<=i[1]&&t[3]>=i[1]?!0:Ta(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=uc(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(Ma(i,0,i.length,n,t,e,i)),this.changed()}}Me.prototype.transform;const da={ACTIVE:"active"};class Ms extends $e{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(da.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(da.ACTIVE,t)}setMap(t){this.map_=t}}function Rp(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:fp,center:s.getConstrainedCenter(n)})}}function sl(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:Mn})}class Ki 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==Ct.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Ct.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==Ct.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==Ct.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 rl(s){const t=s.length;let e=0,i=0;for(let n=0;n<t;n++)e+=s[n].clientX,i+=s[n].clientY;return{clientX:e/t,clientY:i/t}}class Cs extends dc{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(Tt),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,i=t.length;e<i;++e)this.changeEventsKeys_.push(ft(t[e],nt.CHANGE,this.changed,this))}clone(){const t=new Cs(Io(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<Xi(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){bs(t);const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)ss(t,e[i].getExtent());return t}getGeometries(){return Io(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 Cs(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=be(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(Io(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 Io(s){return s.map(t=>t.clone())}function mn(s,t){const e=s.length;return t<0?s[t+e]:t>=e?s[t-e]:s[t]}function yn(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,d=h[1]-l;return[a+c*n,l+d*n]}const Qs={index:-1,endIndex:NaN,closestTargetDistance:1/0};function Ap(s,t,e,i){const n=s[0],r=s[1];let o=1/0,a=-1,l=NaN;for(let d=0;d<t.targets.length;++d){const u=t.targets[d],f=u.coordinates;let g=1/0,p;for(let m=0;m<f.length-1;++m){const y=f[m],x=f[m+1],E=ad(n,r,y,x);E.squaredDistance<g&&(g=E.squaredDistance,p=m+E.along)}g<o&&(o=g,u.ring&&t.targetIndex===d&&(u.endIndex>u.startIndex?p<u.startIndex&&(p+=f.length):u.endIndex<u.startIndex&&p>u.startIndex&&(p-=f.length)),l=p,a=d)}const h=t.targets[a];let c=h.ring;if(t.targetIndex===a&&c){const d=yn(h.coordinates,l),u=e.getPixelFromCoordinate(d),f=e.getPixelFromCoordinate(t.startCoord);Jh(u,f)>i&&(c=!1)}if(c){const d=h.coordinates,u=d.length,f=h.startIndex,g=l;if(f<g){const p=ir(d,f,g);ir(d,f,g-u)<p&&(l-=u)}else{const p=ir(d,f,g);ir(d,f,g+u)<p&&(l+=u)}}return Qs.index=a,Qs.endIndex=l,Qs.closestTargetDistance=o,Qs}function Mp(s,t){const e=[];for(let i=0;i<t.length;++i){const r=t[i].getGeometry();od(s,r,e)}return e}function od(s,t,e){if(t instanceof pt){tr(s,t.getCoordinates(),!1,e);return}if(t instanceof Ln){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)tr(s,i[n],!1,e);return}if(t instanceof it){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)tr(s,i[n],!0,e);return}if(t instanceof Dn){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)tr(s,o[a],!0,e)}return}if(t instanceof Cs){const i=t.getGeometries();for(let n=0;n<i.length;++n)od(s,i[n],e);return}}function tr(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=ad(n,r,l,h);if(c.squaredDistance===0){const d=o+c.along;i.push({coordinates:t,ring:e,startIndex:d,endIndex:d});return}}}function er(s,t){return li(s[0],s[1],t[0],t[1])}function ir(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=yn(s,i),h=yn(s,n);return er(l,h)}let a=0;if(i<r){const l=yn(s,i),h=mn(s,r);a+=er(l,h)}if(o<n){const l=mn(s,o),h=yn(s,n);a+=er(l,h)}for(let l=r;l<o-1;++l){const h=mn(s,l),c=mn(s,l+1);a+=er(h,c)}return a}const Lo={along:0,squaredDistance:0};function ad(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,d=n,u=r;return(l!==0||h!==0)&&(c=Pt(((s-n)*l+(t-r)*h)/(l*l+h*h),0,1),d+=l*c,u+=h*c),Lo.along=c,Lo.squaredDistance=Ps(li(s,t,d,u),10),Lo}const nr={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class sr extends qe{constructor(t,e){super(t),this.feature=e}}class ee extends Ki{constructor(t){const e=t;e.stopDown||(e.stopDown=Rn),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_=Op(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:vn,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 Me([NaN,NaN]),h=Re(r[0]),c=qh(h,Re(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;n==="Point"?r=rt:n==="LineString"?r=pt:n==="Polygon"&&(r=it),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 bt({source:new Y({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:Fp(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:nl,this.freehandCondition_,t.freehand?this.freehandCondition_=cr:this.freehandCondition_=t.freehandCondition?t.freehandCondition:ca,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(da.ACTIVE,this.updateState_)}setTrace(t){let e;t?t===!0?e=cr:e=t:e=Lp,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=cr:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:ca}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){t.originalEvent.type===nt.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(t);let e=t.type===Ct.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&t.type===Ct.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===Ct.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===Ct.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===Ct.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===Ct.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===Ct.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 si(Ct.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=yr([i,n]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=Mp(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(mn(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(mn(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(Jh(a,t.pixel)<this.snapTolerance_)return}const i=Ap(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=yn(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],d=a.getPixelFromCoordinate(c),u=t[0]-d[0],f=t[1]-d[1],g=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(u*u+f*f)<=g,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new V(new rt(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new V);const e=t.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),i.changed()):(i=new pt(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(t){const e=this.getMap().getView().getProjection(),i=Cr(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 V(new pt(this.sketchLineCoords_)));const n=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new V,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(n),this.updateSketchFeatures_(),this.dispatchEvent(new sr(nr.DRAWSTART,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),i=this.sketchFeature_.getGeometry(),n=e.getView().getProjection(),r=Cr(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 As([e])):this.type_==="MultiLineString"?t.setGeometry(new Ln([e])):this.type_==="MultiPolygon"&&t.setGeometry(new Dn([e])),this.dispatchEvent(new sr(nr.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 sr(nr.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 V(new rt(n)),this.updateSketchFeatures_(),this.dispatchEvent(new sr(nr.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 Fp(){const s=Kg();return function(t,e){return s[t.getGeometry().getType()]}}function Op(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 ua={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class zp extends Or{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_=ft(i,ua.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=ft(i,ua.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(nt.TOUCHMOVE,this.boundHandleTouchMove_,bc?{passive:!1}:!1)}emulateClick_(t){let e=new si(Ct.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new si(Ct.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new si(Ct.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==Ct.POINTERUP||e.type==Ct.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==Ct.POINTERDOWN||e.type==Ct.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new si(Ct.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(Tt),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 si(Ct.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(ft(i,Ct.POINTERMOVE,this.handlePointerMove_,this),ft(i,Ct.POINTERUP,this.handlePointerUp_,this),ft(this.element_,Ct.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(ft(this.element_.getRootNode(),Ct.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new si(Ct.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 si(Ct.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_&&(Tt(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(nt.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(Tt(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(Tt),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Ci={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},se={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},X={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},Ir=1/0;class $p{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,kn(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){gt(!(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!=Ir?(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==Ir?delete this.queuedElements_[this.keyFunction_(o)]:(i[n]=l,e[n++]=o);e.length=n,i.length=n,this.heapify_()}}class Np extends $p{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(nt.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===X.LOADED||i===X.ERROR||i===X.EMPTY){i!==X.ERROR&&e.removeEventListener(nt.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()===X.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,n.load())}}}function Gp(s,t,e,i,n){if(!s||!(e in s.wantedTiles)||!s.wantedTiles[e][t.getKey()])return Ir;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 ol extends $e{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)Tt(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!==ds&&this.listenerKeys.push(ft(t,Ci.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Bp extends ol{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(nt.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+Yr+" "+Ya+(this.collapsed_&&this.collapsible_?" "+Zl:"")+(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=>iu(()=>n))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!ui(e,this.renderedAttributions_)){gf(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(Zl),this.collapsed_?jl(this.collapseLabel_,this.label_):jl(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 Wp extends ol{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(nt.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+Yr+" "+Ya,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(Xs)}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:Mn}):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(Xs);!r&&i===0?this.element.classList.add(Xs):r&&i!==0&&this.element.classList.remove(Xs)}this.label_.style.transform=n}this.rotation_=i}}class Up extends ol{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(nt.CLICK,this.handleClick_.bind(this,i),!1);const d=document.createElement("button");d.className=r,d.setAttribute("type","button"),d.title=h,d.appendChild(typeof a=="string"?document.createTextNode(a):a),d.addEventListener(nt.CLICK,this.handleClick_.bind(this,-i),!1);const u=e+" "+Yr+" "+Ya,f=this.element;f.className=u,f.appendChild(c),f.appendChild(d),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:Mn})):i.setZoom(r)}}}function Vp(s){s=s||{};const t=new pe;return(s.zoom===void 0||s.zoom)&&t.push(new Up(s.zoomOptions)),(s.rotate===void 0||s.rotate)&&t.push(new Wp(s.rotateOptions)),(s.attribution===void 0||s.attribution)&&t.push(new Bp(s.attributionOptions)),t}class Hp{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 Xp 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==Ct.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=n.getView();sl(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}class jp extends Ki{constructor(t){super({stopDown:Rn}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:ha(nl,kp);this.condition_=t.onFocusOnly?ha(nd,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(rl(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();Kh(r,a.getResolution()),ba(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:Mn})}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 Yp extends Ki{constructor(t){t=t||{},super({stopDown:Rn}),this.condition_=t.condition?t.condition:Pp,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===tl)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)&&sd(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class Zp extends vs{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 it([n])}getGeometry(){return this.geometry_}}const nn={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Xn extends qe{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class Kp extends Ki{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new Zp(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??sd,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 Xn(nn.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 Xn(e?nn.BOXEND:nn.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 Xn(nn.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Xn(nn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Xn(nn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class qp extends Kp{constructor(t){t=t||{};const e=t.condition?t.condition:ca;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:Mn})}}const ki={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class Jp extends Ms{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return nl(e)&&rd(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==nt.KEYDOWN){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==ki.DOWN||n==ki.LEFT||n==ki.RIGHT||n==ki.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;n==ki.DOWN?h=-a:n==ki.LEFT?l=-a:n==ki.RIGHT?l=a:h=a;const c=[l,h];ba(c,o.getRotation()),Rp(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class Qp extends Ms{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!Dp(e)&&rd(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==nt.KEYDOWN||t.type==nt.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();sl(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const tm=40,em=300,im=3;class nm 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:cr;this.condition_=t.onFocusOnly?ha(nd,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(Tt),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){const e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push(ft(e,"keydown",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!0)}),ft(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!==nt.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*=tm;break;case WheelEvent.DOM_DELTA_PAGE:o*=em;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*im),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),sl(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 sm extends Ki{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Rn),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!==tl&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(rl(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 rm extends Ki{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Rn),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(rl(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 ld(s){s=s||{};const t=new pe,e=new Hp(-.005,.05,100);return(s.altShiftDragRotate===void 0||s.altShiftDragRotate)&&t.push(new Yp),(s.doubleClickZoom===void 0||s.doubleClickZoom)&&t.push(new Xp({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan===void 0||s.dragPan)&&t.push(new jp({onFocusOnly:s.onFocusOnly,kinetic:e})),(s.pinchRotate===void 0||s.pinchRotate)&&t.push(new sm),(s.pinchZoom===void 0||s.pinchZoom)&&t.push(new rm({duration:s.zoomDuration})),(s.keyboard===void 0||s.keyboard)&&(t.push(new Jp),t.push(new Qp({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom===void 0||s.mouseWheelZoom)&&t.push(new nm({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom===void 0||s.shiftDragZoom)&&t.push(new qp({duration:s.zoomDuration})),t}const _i={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class Ei extends qe{constructor(t,e){super(t),this.layer=e}}const Do={LAYERS:"layers"};class Fn extends td{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(Do.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new pe(i.slice(),{unique:!0}):gt(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new pe(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(Tt),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(ft(t,fe.ADD,this.handleLayersAdd_,this),ft(t,fe.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(Tt);kn(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 Ei(_i.ADDLAYER,r))}this.changed()}registerLayerListeners_(t){const e=[ft(t,En.PROPERTYCHANGE,this.handleLayerChange_,this),ft(t,nt.CHANGE,this.handleLayerChange_,this)];t instanceof Fn&&e.push(ft(t,_i.ADDLAYER,this.handleLayerGroupAdd_,this),ft(t,_i.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[K(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Ei(_i.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Ei(_i.REMOVELAYER,t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Ei(_i.ADDLAYER,e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=K(e);this.listenerKeys_[i].forEach(Tt),delete this.listenerKeys_[i],this.dispatchEvent(new Ei(_i.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(Do.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 Ei(_i.REMOVELAYER,i[n]))}this.set(Do.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=Ni(l.extent,n.extent):l.extent=n.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}class om extends vs{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){Q()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,n=t.pixelToCoordinateTransform;Pe(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Ur(n,i)}forEachFeatureAtCoordinate(t,e,i,n,r,o,a,l){let h;const c=e.viewState;function d(w,C,v,_){return r.call(o,C,w?v:null,_)}const u=c.projection,f=Qh(t.slice(),u),g=[[0,0]];if(u.canWrapX()&&n){const w=u.getExtent(),C=Et(w);g.push([-C,0],[C,0])}const p=e.layerStatesArray,m=p.length,y=[],x=[];for(let w=0;w<g.length;w++)for(let C=m-1;C>=0;--C){const v=p[C],_=v.layer;if(_.hasRenderer()&&il(v,c)&&a.call(l,_)){const b=_.getRenderer(),S=_.getSource();if(b&&S){const P=S.getWrapX()?f:t,L=d.bind(null,v.managed);x[0]=P[0]+g[w][0],x[1]=P[1]+g[w][1],h=b.forEachFeatureAtCoordinate(x,e,i,L,y)}if(h)return h}}if(y.length===0)return;const E=1/y.length;return y.forEach((w,C)=>w.distanceSq+=C*E),y.sort((w,C)=>w.distanceSq-C.distanceSq),y.some(w=>h=w.callback(w.feature,w.layer,w.geometry)),h}hasFeatureAtCoordinate(t,e,i,n,r,o){return this.forEachFeatureAtCoordinate(t,e,i,n,vn,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){Q()}scheduleExpireIconCache(t){ve.canExpireCache()&&t.postRenderFunctions.push(am)}}function am(s,t){ve.expire()}class lm extends om{constructor(t){super(t),this.fontChangeListenerKey_=ft(hn,En.PROPERTYCHANGE,t.redrawText,t),this.element_=Ee?Sc():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Yr+" 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 hs(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){Tt(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(Yt.PRECOMPOSE,t);const e=t.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);e.some(h=>h.layer instanceof to&&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 d=e[h];t.layerIndex=h;const u=d.layer,f=u.getSourceState();if(!il(d,n)||f!="ready"&&f!="undefined"){u.unrender();continue}const g=u.render(t,o);g&&(g!==o&&(this.children_.push(g),o=g),r.push(d))}this.declutter(t,r),pf(this.element_,this.children_);const l=this.getMap().getTargetElement();if(Ti(l)){const h=l.getContext("2d");for(const c of this.children_){const d=c.firstElementChild||c,u=c.style.backgroundColor;if(u&&(!Ti(d)||d.width>0)&&(h.fillStyle=u,h.fillRect(0,0,l.width,l.height)),Ti(d)&&d.width>0){h.save();const f=c.style.opacity||d.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=d.style.transform;if(g)h.transform(...ta(g));else{const p=parseFloat(d.style.width)/d.width,m=parseFloat(d.style.height)/d.height;h.transform(p,0,0,m,0,0)}h.drawImage(d,0,0),h.restore()}}}this.dispatchRenderEvent(Yt.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 hd(s){if(s instanceof Qr){s.setMapInternal(null);return}s instanceof Fn&&s.getLayers().forEach(hd)}function cd(s,t){if(s instanceof Qr){s.setMapInternal(t);return}if(s instanceof Fn){const e=s.getLayers().getArray();for(let i=0,n=e.length;i<n;++i)cd(e[i],t)}}let dd=class extends $e{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=hm(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:ff,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Ut(),this.pixelToCoordinateTransform_=Ut(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,Ee||(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,Ee||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(Ee?new pe:Vp()),this.interactions=e.interactions||(Ee?new pe:ld({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Np(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(se.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(se.VIEW,this.handleViewChanged_),this.addChangeListener(se.SIZE,this.handleSizeChanged_),this.addChangeListener(se.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof He)&&t.view.then(function(n){i.setView(new He(n))}),this.controls.addEventListener(fe.ADD,n=>{n.element.setMap(this)}),this.controls.addEventListener(fe.REMOVE,n=>{n.element.setMap(null)}),this.interactions.addEventListener(fe.ADD,n=>{n.element.setMap(this)}),this.interactions.addEventListener(fe.REMOVE,n=>{n.element.setMap(null)}),this.overlays_.addEventListener(fe.ADD,n=>{this.addOverlayInternal_(n.element)}),this.overlays_.addEventListener(fe.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){cd(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:vn,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 Fn?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:vn,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(se.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Qo(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?zt(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(se.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof pe){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=Re(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?zt(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(se.SIZE)}getView(){return this.get(se.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 Gp(this.frameState_,t,e,i,n)}handleBrowserEvent(t,e){e=e||t.type;const i=new si(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===ua.POINTERDOWN||i===nt.WHEEL||i===nt.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[jt.ANIMATING]||o[jt.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(Yt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Yt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new un(Ci.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new un(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)Tt(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(nt.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(nt.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!Ti(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(Ti(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new lm(this)),!Ti(e)){this.mapBrowserEventHandler_=new zp(this,this.moveTolerance_);for(const n in Ct)this.mapBrowserEventHandler_.addEventListener(Ct[n],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(nt.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(nt.WHEEL,this.boundHandleBrowserEvent_,bc?{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_=[ft(i,nt.KEYDOWN,this.handleBrowserEvent,this),ft(i,nt.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_&&(Tt(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(Tt(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=ft(t,En.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=ft(t,nt.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(Tt),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Ei("addlayer",t)),this.layerGroupPropertyListenerKeys_=[ft(t,En.PROPERTYCHANGE,this.render,this),ft(t,nt.CHANGE,this.render,this),ft(t,"addlayer",this.handleLayerAdd_,this),ft(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){hd(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&&nh(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:jo(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:K(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=jo(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_||!Ss(this.previousExtent_)&&!bn(r.extent,this.previousExtent_))&&(this.dispatchEvent(new un(Ci.MOVESTART,this,n)),this.previousExtent_=bs(this.previousExtent_)),this.previousExtent_&&!r.viewHints[jt.ANIMATING]&&!r.viewHints[jt.INTERACTING]&&!bn(r.extent,this.previousExtent_)&&(this.dispatchEvent(new un(Ci.MOVEEND,this,r)),Uh(r.extent,this.previousExtent_))),this.dispatchEvent(new un(Ci.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Ci.LOADSTART)||this.hasListener(Ci.LOADEND)||this.hasListener(Yt.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 Ei("removelayer",e)),this.set(se.LAYERGROUP,t)}setSize(t){this.set(se.SIZE,t)}setTarget(t){this.set(se.TARGET,t)}setView(t){if(!t||t instanceof He){this.set(se.VIEW,t);return}this.set(se.VIEW,new He);const e=this;t.then(function(i){e.setView(new He(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,r;if(Ti(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)],!nh(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Yh("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!ui(e,i))&&(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};function hm(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 Fn({layers:s.layers});e[se.LAYERGROUP]=i,e[se.TARGET]=s.target,e[se.VIEW]=s.view instanceof He?s.view:new He;let n;s.controls!==void 0&&(Array.isArray(s.controls)?n=new pe(s.controls.slice()):(gt(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 pe(s.interactions.slice()):(gt(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 pe(s.overlays.slice()):(gt(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new pe,{controls:n,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}var cm=class extends $e{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}},al=class extends cm{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}},dm=class extends al{constructor(t){t=t||{},super(t),this.element.className=("ol-ext-toggle-switch "+(t.className||"")).trim()}},um=class extends al{constructor(t){t=t||{},super(t),this.element.className=("ol-ext-check ol-ext-radio "+(t.className||"")).trim()}},st={};st.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)st.create("OPTION",{html:n,value:t.options[n],parent:e});break}case"style":{st.setStyle(e,t.style);break}case"change":case"click":{st.addListener(e,i,t[i]);break}case"on":{for(var r in t.on)st.addListener(e,r,t.on[r]);break}case"checked":{e.checked=!!t.checked;break}default:{e.setAttribute(i,t[i]);break}}}return e};st.createSwitch=function(s){var t=st.create("INPUT",{type:"checkbox",on:s.on,click:s.click,change:s.change,parent:s.parent}),e=Object.assign({input:t},s||{});return new dm(e),t};st.createCheck=function(s){var t=st.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 um(e):new al(e),t};st.setHTML=function(s,t){t instanceof Element?s.appendChild(t):t!==void 0&&(s.innerHTML=t)};st.appendText=function(s,t){s.appendChild(document.createTextNode(t||""))};st.addListener=function(s,t,e,i){typeof t=="string"&&(t=t.split(" ")),t.forEach(function(n){s.addEventListener(n,e,i)})};st.removeListener=function(s,t,e){typeof t=="string"&&(t=t.split(" ")),t.forEach(function(i){s.removeEventListener(i,e)})};st.show=function(s){s.style.display=""};st.hide=function(s){s.style.display="none"};st.hidden=function(s){return st.getStyle(s,"display")==="none"};st.toggle=function(s){s.style.display=s.style.display==="none"?"":"none"};st.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]}};st.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};st.outerHeight=function(s){return s.offsetHeight+st.getStyle(s,"marginBottom")};st.outerWidth=function(s){return s.offsetWidth+st.getStyle(s,"marginLeft")};st.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}};st.getFixedOffset=function(s){var t={left:0,top:0},e=function(i){if(!i)return t;if(st.getStyle(i,"position")==="absolute"&&st.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)};st.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)};st.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,d,u=0,f=function(){E&&(u++,setTimeout(g))},g=function(){if(E){if(u--,u)return;var _=s.clientHeight,b=s.scrollHeight;c=_/b,E.style.height=c*100+"%",E.style.top=s.scrollTop/b*100+"%",x.style.height=_+"px",_>b-.5?x.classList.add("ol-100pc"):x.classList.remove("ol-100pc")}},p=function(_){_.target.classList.contains("ol-noscroll")||(h=!1,e=_[a],r=new Date,s.classList.add("ol-move"),_.preventDefault(),window.addEventListener("pointermove",m),st.addListener(window,["pointerup","pointercancel"],C))},m=function(_){if(e!==!1){var b=(d?-1/c:1)*(e-_[a]);h=h||Math.round(b),s[l]+=b,n=new Date,n-r&&(i=(i+b/(n-r))/2),e=_[a],r=n,b&&o(!0)}else h=!0},y=function(_){var b=_>0?Math.min(100,_/2):Math.max(-100,_/2);_-=b,s[l]+=b,-1<_&&_<1?(h?setTimeout(function(){s.classList.remove("ol-move")}):s.classList.remove("ol-move"),h=!1,o(!1)):setTimeout(function(){y(_)},40)},x,E;if(t.vertical&&t.minibar){var w=function(_){s.removeEventListener("pointermove",w),s.parentNode.classList.add("ol-miniscroll"),E=st.create("DIV"),x=st.create("DIV",{className:"ol-scroll",html:E}),s.parentNode.insertBefore(x,s),E.addEventListener("pointerdown",function(b){d=!0,p(b)}),t.mousewheel&&(st.addListener(x,["mousewheel","DOMMouseScroll","onmousewheel"],function(b){v(b)}),st.addListener(E,["mousewheel","DOMMouseScroll","onmousewheel"],function(b){v(b)})),s.parentNode.addEventListener("pointerenter",f),window.addEventListener("resize",f),_!==!1&&f()};s.parentNode?w(!1):s.addEventListener("pointermove",w),s.addEventListener("scroll",function(){f()})}s.style["touch-action"]="none",s.style.overflow="hidden",s.classList.add("ol-scrolldiv"),st.addListener(s,["pointerdown"],function(_){d=!1,p(_)}),s.addEventListener("click",function(_){s.classList.contains("ol-move")&&(_.preventDefault(),_.stopPropagation())},!0);var C=function(_){r=new Date-r,r>100||d?i=0:r>0&&(i=((i||0)+(e-_[a])/r)/2),y(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)),d=!1,window.removeEventListener("pointermove",m),st.removeListener(window,["pointerup","pointercancel"],C)},v=function(_){var b=Math.max(-1,Math.min(1,_.wheelDelta||-_.detail));return s.classList.add("ol-move"),s[l]-=b*30,s.classList.remove("ol-move"),!1};return t.mousewheel&&st.addListener(s,["mousewheel","DOMMouseScroll","onmousewheel"],v),{refresh:f}};st.dispatchEvent=function(s,t){var e;try{e=new CustomEvent(s)}catch{e=document.createEvent("CustomEvent"),e.initCustomEvent(s,!0,!0,{})}t.dispatchEvent(e)};st.setCursor=function(s,t){s instanceof dd&&(s=s.getTargetElement()),!("ontouchstart"in window)&&s instanceof Element&&(s.style.cursor=t)};var _e=class extends Ki{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 pe,this.handles_=new pe,this.overlayLayer_=new bt({source:new Y({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_&&st.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 G({color:[255,0,0,1],width:1}),i=t.stroke||new G({color:[255,0,0,1],width:1,lineDash:[4,4]}),n=t.fill||new j({color:[255,0,0,.01]}),r=t.pointFill||new j({color:[255,255,255,.8]}),o=new Bi({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 Bi({fill:r,stroke:e,radius:this.isTouch?16:8,points:4,angle:Math.PI/4}),l=new Bi({fill:r,stroke:e,radius:this.isTouch?12:6,points:4,angle:Math.PI/4});function h(c,d,u){return[new A({image:c,stroke:d,fill:u})]}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=An(a,this.get("buffer")),this.selection_.forEach((function(p){var m=this.getGeometryRotateToZero_(p).getExtent();ss(a,m)}).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 V({geometry:new rt(this.center_),handle:"rotate0"})),n=gn(a),this.get("enableRotatedTransform")&&o!==0&&n.rotate(o,this.getMap().getView().getCenter()),i=this.bbox_=new V(n),this.overlayLayer_.getSource().addFeature(i));else{if(this.ispt_){var c=this.getMap().getPixelFromCoordinate(be(a));if(c){var d=h&&h[0]||10,u=h&&h[1]||10;a=yr([this.getMap().getCoordinateFromPixel([c[0]-d,c[1]-u]),this.getMap().getCoordinateFromPixel([c[0]+d,c[1]+u])])}}n=r?new it([l]):gn(a),this.get("enableRotatedTransform")&&o!==0&&n.rotate(o,this.getMap().getView().getCenter()),i=this.bbox_=new V(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 V({geometry:new rt([(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 V({geometry:new rt(g[e]),handle:"scale",option:e}),f.push(i);this.get("translate")&&!this.get("translateFeature")&&(i=new V({geometry:new rt([(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 V({geometry:new rt(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){Wh(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=oe(),o=oe();this.hasChanged_=!1;for(var a=0,l;l=this.selection_.item(a);a++)if(this.geoms_.push(l.getGeometry().clone()),r=ss(r,l.getGeometry().getExtent()),this.get("enableRotatedTransform")&&n!==0){var h=this.getGeometryRotateToZero_(l,!0);this.rotatedGeoms_.push(h),o=ss(o,h.getExtent())}if(this.extent_=gn(r).getCoordinates()[0],this.get("enableRotatedTransform")&&n!==0&&(this.rotatedExtent_=gn(o).getCoordinates()[0]),this.mode_==="rotate"){this.center_=this.getCenter()||be(r);var c=t.map.getTargetElement();st.setCursor(c,this.Cursors.rotate0),this.previousCursor_=c.style.cursor}else this.center_=be(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 d=this.selection_.getArray().indexOf(i);d<0?this.selection_.push(i):this.selection_.removeAt(d)}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],d=l[1]-a[1];for(i=0,r;r=this.selection_.item(i);i++)r.getGeometry().translate(c,d);this.handles_.forEach(function(P){P.getGeometry().translate(c,d)}),this.coordinate_=t.coordinate,this.dispatchEvent({type:"translating",feature:this.selection_.item(0),features:this.selection_,delta:[c,d],pixel:t.pixel,coordinate:t.coordinate});break}case"scale":{var u=this.center_;if(this.get("modifyCenter")(t)){var f=this.extent_;this.get("enableRotatedTransform")&&e!==0&&(f=this.rotatedExtent_),u=f[(Number(this.opt_)+2)%4]}var g=this.geoms_.length==1&&this._isRectangle(this.geoms_[0]),p=this.constraint_,m=this.opt_,y=this.coordinate_,x=t.coordinate;if(this.get("enableRotatedTransform")&&e!==0){var E=new rt(this.coordinate_);E.rotate(e*-1,u),y=E.getCoordinates();var w=new rt(t.coordinate);w.rotate(e*-1,u),x=w.getCoordinates()}var C=(x[0]-u[0])/(y[0]-u[0]),v=(x[1]-u[1])/(y[1]-u[1]),_=[x[0]-y[0],x[1]-y[1]];if(this.get("enableRotatedTransform")&&e!==0){var b=new rt(u);b.rotate(e*-1,this.getMap().getView().getCenter()),u=b.getCoordinates()}this.get("noFlip")&&(C<0&&(C=-C),v<0&&(v=-v)),this.constraint_?this.constraint_=="h"?C=1:v=1:this.get("keepAspectRatio")(t)&&(C=v=Math.min(C,v));var S=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(P,L,k){if(k<2)return L;if(g){var F=[[6],[0,8],[2],[4]],O=[P[0],P[1]],R=[P[2],P[3]],B=[P[4],P[5]],D=[P[6],P[7]],z=[P[8],P[9]];if(p){var N=m%2===0?this._countVector(O,R):this._countVector(D,O),tt=this._projectVectorOnVector(_,N),et=m+1<F.length?m+1:0,ht=[...F[m],...F[et]];for(n=0;n<P.length;n+=k)L[n]=ht.includes(n)?P[n]+tt[0]:P[n],L[n+1]=ht.includes(n)?P[n+1]+tt[1]:P[n+1]}else{var ot,I,xt;switch(m){case 0:S?(xt=this._snapToDiagonal(D,R,x),_=this._countVector(D,xt)):_=this._countVector(D,x),ot=this._projectVectorOnVector(_,this._countVector(B,D)),I=this._projectVectorOnVector(_,this._countVector(O,D)),[L[0],L[1]]=this._movePoint(O,ot),[L[4],L[5]]=this._movePoint(B,I),[L[6],L[7]]=this._movePoint(D,_),[L[8],L[9]]=this._movePoint(z,ot);break;case 1:S?(xt=this._snapToDiagonal(O,B,x),_=this._countVector(O,xt)):_=this._countVector(O,x),ot=this._projectVectorOnVector(_,this._countVector(D,O)),I=this._projectVectorOnVector(_,this._countVector(R,O)),[L[0],L[1]]=this._movePoint(O,_),[L[2],L[3]]=this._movePoint(R,ot),[L[6],L[7]]=this._movePoint(D,I),[L[8],L[9]]=this._movePoint(z,_);break;case 2:S?(xt=this._snapToDiagonal(R,D,x),_=this._countVector(R,xt)):_=this._countVector(R,x),ot=this._projectVectorOnVector(_,this._countVector(O,R)),I=this._projectVectorOnVector(_,this._countVector(B,R)),[L[0],L[1]]=this._movePoint(O,I),[L[2],L[3]]=this._movePoint(R,_),[L[4],L[5]]=this._movePoint(B,ot),[L[8],L[9]]=this._movePoint(z,I);break;case 3:S?(xt=this._snapToDiagonal(B,O,x),_=this._countVector(B,xt)):_=this._countVector(B,x),ot=this._projectVectorOnVector(_,this._countVector(R,B)),I=this._projectVectorOnVector(_,this._countVector(D,B)),[L[2],L[3]]=this._movePoint(R,I),[L[4],L[5]]=this._movePoint(B,_),[L[6],L[7]]=this._movePoint(D,ot);break}}}else for(n=0;n<P.length;n+=k)C!=1&&(L[n]=u[0]+(P[n]-u[0])*C),v!=1&&(L[n+1]=u[1]+(P[n+1]-u[1])*v);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:[C,v],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),st.setCursor(i,n)}else this.previousCursor_!==void 0&&st.setCursor(i,this.previousCursor_),this.previousCursor_=void 0}}handleUpEvent_(t){if(this.mode_==="rotate"){var e=t.map.getTargetElement();st.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]}};_e.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"};var Oe=(s=>(s.WGS84="wgs84",s.GCJ02="gcj02",s.BD09="bd09",s.WEB_MERCATOR="web_mercator",s))(Oe||{}),dt=(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.CUSTOMIZE="customize",s))(dt||{}),Z=(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.FREEHAND_DRAW="freehand-draw",s.ELLIPSE_DRAW="ellipse-draw",s.MARKER_DRAW="marker-draw",s.TEXT_DRAW="text-draw",s.IMAGE_DRAW="image-draw",s.ARROW_DRAW="arrow-draw",s.LINE_DRAW="line-draw",s.BEZIER_DRAW="bezier-draw",s.SECTOR_DRAW="sector-draw",s.POINT_COORDINATE_PICK="point-coordinate-pick",s.LINE_COORDINATE_PICK="line-coordinate-pick",s.POLYGON_COORDINATE_PICK="polygon-coordinate-pick",s))(Z||{}),qt=(s=>(s.DATA_LAYER="data_layer",s.DRAW_LAYER="draw_layer",s.TOOL_LAYER="tool_layer",s))(qt||{}),H=(s=>(s.SQUARE="square",s.CIRCLE="circle",s.TRIANGLE="triangle",s.PENTAGRAM="pentagram",s.TEXT="text",s.DIAMOND="diamond",s.CROSS="cross",s.X_SHAPE="x_shape",s.HEXAGON="hexagon",s.FLAG="flag",s.HOUSE="house",s.ARROW="arrow",s.TENT="tent",s.BUNKER="bunker",s.LANDMINE="landmine",s.TANK="tank",s.PLANE="plane",s.SHIP="ship",s.RADAR="radar",s.MISSILE="missile",s.FIRE_HYDRANT="fire_hydrant",s.FIRST_AID="first_aid",s.WATER_TOWER="water_tower",s.GENERATOR="generator",s.MEGAPHONE="megaphone",s.STREET_LAMP="street_lamp",s.PARKING="parking",s.GAS_STATION="gas_station",s.TUNNEL="tunnel",s.BRIDGE="bridge",s.TRAFFIC_LIGHT="traffic_light",s.CAMERA="camera",s.TOILET="toilet",s.TRASH_CAN="trash_can",s.BUS_STOP="bus_stop",s.SUBWAY="subway",s.SCHOOL="school",s.HOSPITAL="hospital",s.TREE="tree",s.WATER_SOURCE="water_source",s.MOUNTAIN="mountain",s.MINE="mine",s.HEART="heart",s.STAR="star",s.CLOUD="cloud",s.GEAR="gear",s.LIGHTNING="lightning",s.PIN="pin",s.COMPASS="compass",s.ANCHOR="anchor",s))(H||{}),_n=(s=>(s.PULSE="pulse",s.FLASHING="flashing",s.BREATHING="breathing",s.LIGHT="light",s))(_n||{});function Vt(s=""){return`${s}${Date.now()}_${Math.random().toString(36).substr(2,8)}`}function M(s){return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]??1})`}const fm={topScroll:"Top Scroll",bottomScroll:"Bottom Scroll",linePick:{default_name:"线拾取",label_prefix:"线",highlight_text:"● 线拾取 ●"},pointPick:{default_name:"点拾取",label_text:"坐标拾取"},polygonPick:{default_name:"面拾取",label_prefix:"面",highlight_text:"● 面拾取 ●"},featureType:"要素类型",properties:"属性",freehandDrawLayer:"手绘线图层",ellipseDrawLayer:"椭圆绘制图层",markerDrawLayer:"标记点图层",textDrawLayer:"文字标注图层",imageDrawLayer:"图片标注图层",arrowDrawLayer:"箭头绘制图层",lineDrawLayer:"线段绘制图层",bezierDrawLayer:"贝塞尔曲线图层",sectorDrawLayer:"扇形绘制图层",pointPickLayer:"点坐标拾取图层",linePickLayer:"线坐标拾取图层",polygonPickLayer:"面坐标拾取图层",dataLayers:"数据图层",drawLayers:"绘图图层",toolLayers:"工具图层",pleaseEnterText:"请输入文字",longitude:"经度",latitude:"纬度",confirm:"确定",addImage:"添加图片",imageUrl:"图片URL",uploadImage:"上传图片",width:"宽度",height:"高度",opacity:"透明度",delete:"删除",drawImage:"图片标注",drawCoordinatePick:"坐标拾取",coordinatePick:"坐标拾取",coordinateList:"坐标列表",noCoordinates:"暂无拾取坐标",clearAll:"清空全部",drawLine:"线段",drawBezier:"贝塞尔曲线",drawSector:"扇形",drawFreehandLine:"手绘线",drawFreehandPolygon:"手绘多边形",drawEllipse:"椭圆",drawMarker:"标记点",drawText:"文字标注",drawArrow:"箭头",circleDrawLayer:"圆形绘制图层",rectangleDrawLayer:"矩形绘制图层",triangleDrawLayer:"三角形绘制图层",distanceMeasurementLayer:"距离测量图层",areaMeasurementLayer:"面积测量图层",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:"暂无测量数据",cancel:"取消",drawRectangle:"绘制矩形",drawTriangle:"绘制三角形",editShape:"编辑图形",pointData:"点数据",lineData:"线数据",polygonData:"面数据",coordinateData:"坐标数据",details:"详情",copyCoordinates:"复制坐标",locateOnMap:"在地图上定位",startPoint:"起点坐标",endPoint:"终点坐标",vertexCount:"顶点数量",createdTime:"创建时间",noDataAvailable:"暂无数据",pleaseUseCoordinatePickTool:"暂无数据,请先使用坐标拾取工具",coordinatesCopied:"已复制坐标到剪贴板",locatedToPoint:"已定位到",locatedToLine:"已定位到线,包含",locatedToPolygon:"已定位到面,包含",allCoordinatesCleared:"已清除所有坐标拾取数据",noCoordinateData:"暂无拾取坐标数据",copyAllPointCoordinates:"点击确定复制全部点坐标",pointPickSuccess:"已拾取点坐标",linePickSuccess:"已拾取线坐标,共",polygonPickSuccess:"已拾取面坐标,共",drawingStatusCancelHint:"按 ESC 取消绘制",editingText:"编辑文字",fontSize:"字号",color:"颜色",bold:"粗体",italic:"斜体",imagePreview:"预览",noImage:"暂无图片",imageLoadFailed:"图片加载失败",image:"图片",cancelDrawing:"取消绘制",drawingRectangle:"正在绘制矩形",drawingTriangle:"正在绘制三角形",drawingFreehand:"正在手绘线",drawingFreehandPolygon:"正在手绘多边形",drawingEllipse:"正在绘制椭圆",addingMarker:"添加标记点",addingText:"添加文字标注",drawingArrow:"正在绘制箭头",drawingLine:"正在绘制线段",drawingBezier:"正在绘制贝塞尔曲线",drawingSector:"正在绘制扇形",drawing:"正在绘制",pressEscToCancel:" (按 ESC 取消绘制)",clickMapToPickPoint:"点击地图拾取点坐标 (单击完成拾取)",clickMapToDrawLine:"点击地图绘制线 (双击完成拾取)",clickMapToDrawPolygon:"点击地图绘制面 (双击完成拾取)",doubleClickToFinishPick:"双击完成拾取",editText:"编辑文字",strokeWidth:"线宽",strokeStyle:"线型",dragToMove:"拖动移动",noImagePreview:"暂无图片",uploadFromComputer:"从电脑上传",enterImageUrl:"输入图片URL",deleteImage:"删除图片",cancelEdit:"取消编辑",save:"保存",ok:"确定",lineTool:"线段",arrowTool:"箭头",bezierTool:"贝塞尔曲线",ellipseTool:"椭圆",rectangleTool:"矩形",triangleTool:"三角形",sectorTool:"扇形",freehandTool:"手绘线",freehandPolygonTool:"手绘多边形",markerTool:"标记点",textTool:"文字标注",imageTool:"图片标注",points:"个点",pointsCount:"个",featureNotFound:"未找到要素",cannotGetMapTarget:"无法获取地图容器元素",cannotGetPixelFromCoordinate:"无法从坐标获取像素位置",bezierFeatureNotFound:"未找到贝塞尔曲线要素",noSourceAvailable:"没有可用的数据源"},gm={topScroll:"向上滚动",bottomScroll:"向下滚动",linePick:{default_name:"Line Pick",label_prefix:"Line",highlight_text:"● Line Pick ●"},pointPick:{default_name:"Point Pick",label_text:"Coordinate Pick"},polygonPick:{default_name:"Polygon Pick",label_prefix:"Polygon",highlight_text:"● Polygon Pick ●"},featureType:"Feature Type",properties:"Properties",freehandDrawLayer:"Freehand Draw Layer",ellipseDrawLayer:"Ellipse Draw Layer",markerDrawLayer:"Marker Draw Layer",textDrawLayer:"Text Draw Layer",imageDrawLayer:"Image Draw Layer",arrowDrawLayer:"Arrow Draw Layer",lineDrawLayer:"Line Draw Layer",bezierDrawLayer:"Bezier Curve Layer",sectorDrawLayer:"Sector Draw Layer",pointPickLayer:"Point Pick Layer",linePickLayer:"Line Pick Layer",polygonPickLayer:"Polygon Pick Layer",dataLayers:"Data Layers",drawLayers:"Draw Layers",toolLayers:"Tool Layers",pleaseEnterText:"Please enter text",longitude:"Longitude",latitude:"Latitude",confirm:"OK",addImage:"Add Image",imageUrl:"Image URL",uploadImage:"Upload Image",width:"Width",height:"Height",opacity:"Opacity",delete:"Delete",drawImage:"Image",drawCoordinatePick:"Coordinate Pick",coordinatePick:"Coordinate Pick",coordinateList:"Coordinate List",noCoordinates:"No coordinates picked",clearAll:"Clear All",drawLine:"Line",drawBezier:"Bezier Curve",drawSector:"Sector",drawFreehandLine:"Freehand Line",drawFreehandPolygon:"Freehand Polygon",drawEllipse:"Ellipse",drawMarker:"Marker",drawText:"Text Label",drawArrow:"Arrow",circleDrawLayer:"Circle Draw Layer",rectangleDrawLayer:"Rectangle Draw Layer",triangleDrawLayer:"Triangle Draw Layer",distanceMeasurementLayer:"Distance Measurement Layer",areaMeasurementLayer:"Area Measurement Layer",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",cancel:"Cancel",drawRectangle:"Draw Rectangle",drawTriangle:"Draw Triangle",editShape:"Edit Shape",pointData:"Points",lineData:"Lines",polygonData:"Polygons",coordinateData:"Coordinate Data",details:"Details",copyCoordinates:"Copy Coordinates",locateOnMap:"Locate on Map",startPoint:"Start Point",endPoint:"End Point",vertexCount:"Vertex Count",createdTime:"Created Time",noDataAvailable:"No data available",pleaseUseCoordinatePickTool:"No data available, please use coordinate pick tool first",coordinatesCopied:"Coordinates copied to clipboard",locatedToPoint:"Located to",locatedToLine:"Located to line with",locatedToPolygon:"Located to polygon with",allCoordinatesCleared:"All coordinate picks cleared",noCoordinateData:"No coordinate data",copyAllPointCoordinates:"Click OK to copy all point coordinates",pointPickSuccess:"Point picked",linePickSuccess:"Line picked with",polygonPickSuccess:"Polygon picked with",drawingStatusCancelHint:"Press ESC to cancel drawing",editingText:"Edit Text",fontSize:"Font Size",color:"Color",bold:"Bold",italic:"Italic",imagePreview:"Preview",noImage:"No image",imageLoadFailed:"Image load failed",image:"Image",cancelDrawing:"Cancel Drawing",drawingRectangle:"Drawing Rectangle",drawingTriangle:"Drawing Triangle",drawingFreehand:"Drawing Freehand Line",drawingFreehandPolygon:"Drawing Freehand Polygon",drawingEllipse:"Drawing Ellipse",addingMarker:"Adding Marker",addingText:"Adding Text Label",drawingArrow:"Drawing Arrow",drawingLine:"Drawing Line",drawingBezier:"Drawing Bezier Curve",drawingSector:"Drawing Sector",drawing:"Drawing",pressEscToCancel:" (Press ESC to cancel)",clickMapToPickPoint:"Click map to pick point (Click to finish)",clickMapToDrawLine:"Click map to draw line (Double click to finish)",clickMapToDrawPolygon:"Click map to draw polygon (Double click to finish)",doubleClickToFinishPick:"Double click to finish",editText:"Edit Text",strokeWidth:"Stroke Width",strokeStyle:"Stroke Style",dragToMove:"Drag to move",noImagePreview:"No image preview",uploadFromComputer:"Upload from computer",enterImageUrl:"Enter image URL",deleteImage:"Delete image",cancelEdit:"Cancel",save:"Save",ok:"OK",lineTool:"Line",arrowTool:"Arrow",bezierTool:"Bezier Curve",ellipseTool:"Ellipse",rectangleTool:"Rectangle",triangleTool:"Triangle",sectorTool:"Sector",freehandTool:"Freehand Line",freehandPolygonTool:"Freehand Polygon",markerTool:"Marker",textTool:"Text",imageTool:"Image",points:"points",pointsCount:"",featureNotFound:"Feature not found",cannotGetMapTarget:"Cannot get map target element",cannotGetPixelFromCoordinate:"Cannot get pixel from coordinate",bezierFeatureNotFound:"Bezier feature not found",noSourceAvailable:"No source available"},Hi=s=>s==="zh"?fm:gm;class pm extends It{constructor(t,e,i,n){super(t,e,Z.FREEHAND_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||[76,175,80,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[76,175,80,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||3,this.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:r=>this.getStyleForFeature(r),properties:{id:t,name:e,type:Z.FREEHAND_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t}getStyleForFeature(t){const e=t?.get("isPolygon")||!1,i=t?.get("fillColor")||this.defaultFillColor,n=t?.get("outlineColor")||this.defaultOutlineColor,r=t?.get("outlineWidth")||this.defaultOutlineWidth,a=(t?.get("outlineStyle")||this.defaultOutlineStyle)==="dashed"?[10,10]:void 0;return e?new A({fill:new j({color:M(i)}),stroke:new G({color:M(n),width:r,lineDash:a})}):new A({stroke:new G({color:M(n),width:r,lineDash:a})})}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startDraw(t,e){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=e||null;const i=new Y,n=new A({stroke:new G({color:M(this.defaultOutlineColor),width:this.defaultOutlineWidth,lineDash:this.defaultOutlineStyle==="dashed"?[10,10]:void 0}),fill:new j({color:M(this.defaultFillColor)})});this.drawInteraction=new ee({source:i,type:t?"Polygon":"LineString",style:n}),this.drawInteraction.on("drawend",r=>{const o=r.feature.clone(),a=o.getGeometry(),l=Vt("freehand_"),h=a instanceof it;let c=[];if(a instanceof pt){const d=a.getCoordinates();for(let u=0;u<d.length;u++){const[f,g]=U(d[u]);c.push([f,g])}}else if(a instanceof it){const d=a.getCoordinates()[0];for(let u=0;u<d.length-1;u++){const[f,g]=U(d[u]);c.push([f,g])}}i.clear(),o.setId(l),o.set("id",l),o.set("isPolygon",h),o.set("points",c),o.set("fillColor",this.defaultFillColor),o.set("outlineColor",this.defaultOutlineColor),o.set("outlineWidth",this.defaultOutlineWidth),o.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(o),this.features.set(l,o),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:l,points:c,isPolygon:h,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle}),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.warn(this.t.featureNotFound,t);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(!a)return;let l=[];const h=i.get("isPolygon");if(a instanceof pt){const d=a.getCoordinates();for(let u=0;u<d.length;u++){const[f,g]=U(d[u]);l.push([f,g])}}else if(a instanceof it){const d=a.getCoordinates()[0];for(let u=0;u<d.length-1;u++){const[f,g]=U(d[u]);l.push([f,g])}}i.set("points",l),i.changed();const c=i.get("id");this.onEditCompleteCallback&&c&&this.onEditCompleteCallback({id:c,points:l,isPolygon:h,fillColor:i.get("fillColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth"),outlineStyle:i.get("outlineStyle")}),this.mapView?.render()};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addFreehand(t){if(!this.source){console.error(this.t.noSourceAvailable);return}const e=[];for(let r=0;r<t.points.length;r++){const o=t.points[r],[a,l]=ut(o);e.push([a,l])}let i;const n=t.id||Vt("freehand_");if(t.isPolygon&&e.length>=3){const r=[...e,e[0]],o=new it([r]);i=new V({geometry:o,id:n,isPolygon:!0,points:t.points})}else{const r=new pt(e);i=new V({geometry:r,id:n,isPolygon:!1,points:t.points})}i.set("fillColor",t.fillColor||this.defaultFillColor),i.set("outlineColor",t.outlineColor||this.defaultOutlineColor),i.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),i.set("outlineStyle",t.outlineStyle||this.defaultOutlineStyle),this.source.addFeature(i),this.features.set(n,i)}removeFreehand(t){const e=this.layer?.getSource();if(!e){console.error(this.t.noSourceAvailable);return}let i=this.features.get(t);i||(i=e.getFeatures().find(r=>r.get("id")===t)||null),i&&(e.removeFeature(i),this.features.delete(t),this.editingFeature===i&&this.stopEdit()),this.layer?.changed(),this.mapView&&this.mapView.render()}getAllFreehands(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,points:e.get("points"),isPolygon:e.get("isPolygon"),fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")})}),t}getFreehand(t){const e=this.features.get(t);if(!e)return;let i=e.get("points");if(!i||!Array.isArray(i)){const n=e.getGeometry();n instanceof pt?i=n.getCoordinates().map(o=>{const[a,l]=U(o);return[a,l]}):n instanceof it&&(i=n.getCoordinates()[0].slice(0,-1).map(o=>{const[a,l]=U(o);return[a,l]}))}return{id:t,points:i||[],isPolygon:e.get("isPolygon")||!1,fillColor:e.get("fillColor")||this.defaultFillColor,outlineColor:e.get("outlineColor")||this.defaultOutlineColor,outlineWidth:e.get("outlineWidth")||this.defaultOutlineWidth,outlineStyle:e.get("outlineStyle")||this.defaultOutlineStyle}}updateFreehandStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r),o.setStyle(void 0),o.changed(),this.mapView&&this.mapView.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.freehands&&(this.clearAll(),t.freehands.forEach(e=>this.addFreehand(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class mm extends It{constructor(t,e,i){super(t,e,Z.ELLIPSE_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||[156,39,176,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[156,39,176,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.ELLIPSE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("fillColor")||this.defaultFillColor,i=t?.get("outlineColor")||this.defaultOutlineColor,n=t?.get("outlineWidth")||this.defaultOutlineWidth,o=(t?.get("outlineStyle")||this.defaultOutlineStyle)==="dashed"?[10,10]:void 0;return new A({fill:new j({color:M(e)}),stroke:new G({color:M(i),width:n,lineDash:o})})}createEllipsePoints(t,e,i,n,r=64){const o=[];for(let a=0;a<=r;a++){const l=a/r*Math.PI*2,h=t[0]+e*Math.cos(l),c=t[1]+i*Math.sin(l),d=Math.cos(n),u=Math.sin(n),f=t[0]+(h-t[0])*d-(c-t[1])*u,g=t[1]+(h-t[0])*u+(c-t[1])*d;o.push([f,g])}return o}createEllipseGeometry(t,e,i,n){const r=this.createEllipsePoints(t,e,i,n);return new it([r])}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 Y;let i=null,n=null;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:2,geometryFunction:(r,o)=>{if(r.length===0)return i=null,n=null,o;if(r.length===1)return i=r[0],n=null,o||(o=new it([[[0,0],[0,0],[0,0],[0,0]]])),o;if(r.length>=2){i=r[0],n=r[1];const a=n[0]-i[0],l=n[1]-i[1],h=Math.abs(a)/2,c=Math.abs(l)/2,d=(i[0]+n[0])/2,u=(i[1]+n[1])/2,f=this.createEllipsePoints([d,u],h,c,0);o?o.setCoordinates([f]):o=new it([f])}return o},style:this.getStyleForFeature()}),this.drawInteraction.on("drawend",r=>{const o=r.feature.getGeometry(),a=Vt("ellipse_");if(o instanceof it&&i&&n){const l=n[0]-i[0],h=n[1]-i[1],c=Math.abs(l)/2,d=Math.abs(h)/2,u=(i[0]+n[0])/2,f=(i[1]+n[1])/2,[g,p]=U([u,f]),m=new V({geometry:o.clone(),id:a,center:[g,p],radiusX:c,radiusY:d,rotation:0});m.set("fillColor",this.defaultFillColor),m.set("outlineColor",this.defaultOutlineColor),m.set("outlineWidth",this.defaultOutlineWidth),m.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(m),this.features.set(a,m),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:a,center:[g,p],radiusX:c,radiusY:d,rotation:0,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}i=null,n=null,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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof it){const l=a.getExtent(),h=(l[0]+l[2])/2,c=(l[1]+l[3])/2,d=(l[2]-l[0])/2,u=(l[3]-l[1])/2,[f,g]=U([h,c]),p=i.get("id");this.onEditCompleteCallback&&p&&this.onEditCompleteCallback({id:p,center:[f,g],radiusX:d,radiusY:u,rotation:0})}};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addEllipse(t){const e=ut(t.center),i=[e[0],e[1]],n=this.createEllipsePoints(i,t.radiusX,t.radiusY,t.rotation),r=new it([n]),o=new V({geometry:r,id:t.id,center:t.center,radiusX:t.radiusX,radiusY:t.radiusY,rotation:t.rotation});o.set("fillColor",t.fillColor||this.defaultFillColor),o.set("outlineColor",t.outlineColor||this.defaultOutlineColor),o.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),o.set("outlineStyle",t.outlineStyle||this.defaultOutlineStyle),this.source?.addFeature(o),this.features.set(t.id,o)}removeEllipse(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllEllipses(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,center:e.get("center"),radiusX:e.get("radiusX"),radiusY:e.get("radiusY"),rotation:e.get("rotation")||0,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")})}),t}getEllipse(t){const e=this.features.get(t);if(e)return{id:t,center:e.get("center"),radiusX:e.get("radiusX"),radiusY:e.get("radiusY"),rotation:e.get("rotation")||0,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")}}updateEllipseStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r),o.setStyle(this.getStyleForFeature(o)),o.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.ellipses&&(this.clearAll(),t.ellipses.forEach(e=>this.addEllipse(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class ym extends It{constructor(t,e,i){super(t,e,Z.MARKER_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.defaultColor=i?.defaultColor||[255,87,34,1],this.defaultSize=i?.defaultSize||10,this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.MARKER_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("color")||this.defaultColor,i=t?.get("size")||this.defaultSize;return new A({image:new Le({radius:i/2,fill:new j({color:M(e)}),stroke:new G({color:"#fff",width:2})})})}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 Y;this.drawInteraction=new ee({source:e,type:"Point"}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry(),r=Vt("marker_");if(n instanceof rt){const[o,a]=n.getCoordinates(),[l,h]=U([o,a]),c=new V({geometry:n.clone(),id:r,position:[l,h]});c.set("color",this.defaultColor),c.set("size",this.defaultSize),this.source?.addFeature(c),this.features.set(r,c),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:r,position:[l,h],color:this.defaultColor,size:this.defaultSize})}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!1,rotate:!1}),this.transformInteraction.setActive(!0),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof rt){const[a,l]=o.getCoordinates(),[h,c]=U([a,l]),d=i.get("id");this.onEditCompleteCallback&&d&&this.onEditCompleteCallback({id:d,position:[h,c]}),i.set("position",[h,c])}}),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addMarker(t){const e=ut(t.position),i=new V({geometry:new rt(e),id:t.id,position:t.position});i.set("color",t.color||this.defaultColor),i.set("size",t.size||this.defaultSize),i.set("title",t.title||""),i.set("description",t.description||""),this.source?.addFeature(i),this.features.set(t.id,i)}removeMarker(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllMarkers(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,position:e.get("position"),title:e.get("title"),description:e.get("description"),color:e.get("color"),size:e.get("size")})}),t}getMarker(t){const e=this.features.get(t);if(e)return{id:t,position:e.get("position"),title:e.get("title"),description:e.get("description"),color:e.get("color"),size:e.get("size")}}updateMarkerStyle(t,e,i){const n=this.features.get(t);n&&(n.set("color",e),n.set("size",i),n.changed(),this.mapView?.render())}updateMarkerInfo(t,e,i){const n=this.features.get(t);n&&(n.set("title",e),n.set("description",i))}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.markers&&(this.clearAll(),t.markers.forEach(e=>this.addMarker(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class _m{constructor(t,e){this.isBold=!1,this.isItalic=!1,this.PRESET_FONT_SIZES=[12,14,16,18,20,24,28,32,36,42],this.options=t,this.currentColor=t.initialColor||[255,255,255,1],this.isBold=t.initialFontWeight==="bold",this.isItalic=t.initialFontStyle==="italic",this.containerEl=t.container||document.body,this.overlay=this.createOverlay(),this.element=this.createElement(),this.containerEl.appendChild(this.overlay),this.containerEl.appendChild(this.element),e?this.setPosition(e):this.centerModal(),this.textarea=this.element.querySelector(".text-input-modal-textarea"),this.fontSizeSelect=this.element.querySelector(".text-input-modal-font-size"),this.colorPreview=this.element.querySelector(".text-input-modal-color-preview"),this.colorPicker=this.element.querySelector(".text-input-modal-color-picker"),this.boldBtn=this.element.querySelector(".text-input-modal-bold"),this.italicBtn=this.element.querySelector(".text-input-modal-italic"),this.confirmBtn=this.element.querySelector(".text-input-modal-confirm"),this.cancelBtn=this.element.querySelector(".text-input-modal-cancel"),this.deleteBtn=this.element.querySelector(".text-input-modal-delete"),this.header=this.element.querySelector(".text-input-modal-header"),this.toolbar=this.element.querySelector(".text-input-modal-toolbar"),this.footer=this.element.querySelector(".text-input-modal-footer"),this.bindEvents(),this.updateColorPreview(),this.updateStyleButtons(),this.updateTextareaStyle(),this.focusTextarea()}createOverlay(){const t=document.createElement("div");return t.className="text-input-modal-overlay",t.style.cssText=`
|
|
7
7
|
position: fixed;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
bottom: 0;
|
|
12
12
|
background: transparent;
|
|
13
13
|
z-index: 10000;
|
|
14
|
-
|
|
14
|
+
pointer-events: auto;
|
|
15
|
+
`,t.onclick=e=>{e.stopPropagation(),this.options.onCancel(),this.destroy()},t}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.userSelect="none",e.className="text-input-modal-container",e.style.cssText=`
|
|
15
16
|
position: fixed;
|
|
16
17
|
z-index: 10001;
|
|
17
18
|
width: 280px;
|
|
@@ -136,7 +137,7 @@
|
|
|
136
137
|
color: ${e?"#ccc":"#666"};
|
|
137
138
|
border: 1px solid ${e?"#555":"#ddd"};
|
|
138
139
|
`}
|
|
139
|
-
`,n?(r.onmouseenter=()=>{r.style.background="#d32f2f"},r.onmouseleave=()=>{r.style.background="#f44336"}):i?(r.onmouseenter=()=>{r.style.background="#0088cc"},r.onmouseleave=()=>{r.style.background="#00aaff"}):(r.onmouseenter=()=>{r.style.background=e?"#4a4a4a":"#e0e0e0"},r.onmouseleave=()=>{r.style.background=e?"#3d3d3d":"#e8e8e8"}),r}rgbaToHex(t){const e=Math.round(t[0]),i=Math.round(t[1]),n=Math.round(t[2]);return`#${((1<<24)+(e<<16)+(i<<8)+n).toString(16).slice(1)}`}hexToRgba(t){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return[e,i,n,1]}updateColorPreview(){this.colorPreview.style.backgroundColor=`rgba(${this.currentColor[0]}, ${this.currentColor[1]}, ${this.currentColor[2]}, ${this.currentColor[3]||1})`}updateStyleButtons(){const t=this.options.theme==="dark";this.boldBtn.style.background=this.isBold?"#00aaff":t?"#3d3d3d":"#e8e8e8",this.boldBtn.style.color=this.isBold?"#fff":t?"#ccc":"#666",this.italicBtn.style.background=this.isItalic?"#00aaff":t?"#3d3d3d":"#e8e8e8",this.italicBtn.style.color=this.isItalic?"#fff":t?"#ccc":"#666"}updateTextareaStyle(){const t=parseInt(this.fontSizeSelect.value);this.textarea.style.fontSize=`${t}px`,this.textarea.style.fontWeight=this.isBold?"bold":"normal",this.textarea.style.fontStyle=this.isItalic?"italic":"normal",this.textarea.style.color=`rgba(${this.currentColor[0]}, ${this.currentColor[1]}, ${this.currentColor[2]}, ${this.currentColor[3]||1})`}focusTextarea(){setTimeout(()=>{this.textarea.focus(),this.textarea.select()},50)}centerModal(){const t=(window.innerWidth-280)/2,e=(window.innerHeight-240)/2;this.element.style.left=`${Math.max(10,t)}px`,this.element.style.top=`${Math.max(10,e)}px`}setPosition(t){let e=t.x-140,i=t.y-130;e=Math.max(10,Math.min(e,window.innerWidth-290)),i=Math.max(10,Math.min(i,window.innerHeight-270)),this.element.style.left=`${e}px`,this.element.style.top=`${i}px`}bindEvents(){if(!this.fontSizeSelect||!this.colorPreview||!this.colorPicker||!this.boldBtn||!this.italicBtn||!this.confirmBtn||!this.cancelBtn||!this.textarea){console.error("TextInputModalBox: Required elements not found");return}this.fontSizeSelect.addEventListener("change",()=>{this.updateTextareaStyle()}),this.colorPreview.addEventListener("click",t=>{t.stopPropagation(),this.colorPicker.click()}),this.colorPicker.addEventListener("change",t=>{t.stopPropagation();const e=t.target;this.currentColor=this.hexToRgba(e.value),this.updateColorPreview(),this.updateTextareaStyle()}),this.boldBtn.addEventListener("click",t=>{t.stopPropagation(),this.isBold=!this.isBold,this.updateStyleButtons(),this.updateTextareaStyle()}),this.italicBtn.addEventListener("click",t=>{t.stopPropagation(),this.isItalic=!this.isItalic,this.updateStyleButtons(),this.updateTextareaStyle()}),this.deleteBtn&&this.deleteBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onDelete&&this.options.onDelete(),this.destroy()}),this.confirmBtn.addEventListener("click",t=>{t.stopPropagation();const e=this.textarea.value.trim();e?this.options.onConfirm({text:e,fontSize:parseInt(this.fontSizeSelect.value),color:this.currentColor,fontWeight:this.isBold?"bold":"normal",fontStyle:this.isItalic?"italic":"normal"}):this.options.onCancel(),this.destroy()}),this.cancelBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onCancel(),this.destroy()}),this.textarea.addEventListener("keydown",t=>{t.key==="Enter"&&(t.ctrlKey||t.metaKey)?(t.preventDefault(),t.stopPropagation(),this.confirmBtn.click()):t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),this.cancelBtn.click())}),this.element.addEventListener("click",t=>{t.stopPropagation()})}updateTheme(t){this.options.theme=t;const e=t==="dark";if(this.element.style.background=e?"#2d2d2d":"#ffffff",this.element.style.borderColor=e?"#444":"#e0e0e0",this.header){this.header.style.background=e?"#252525":"#f5f5f5",this.header.style.borderBottomColor=e?"#3d3d3d":"#eee";const n=this.header.querySelector("span");n&&(n.style.color=e?"#fff":"#333")}this.textarea&&(this.textarea.style.background=e?"#1e1e1e":"#fafafa",this.textarea.style.color=e?"#fff":"#333"),this.toolbar&&(this.toolbar.style.background=e?"#252525":"#fafafa",this.toolbar.style.borderTopColor=e?"#3d3d3d":"#eee",this.toolbar.style.borderBottomColor=e?"#3d3d3d":"#eee"),this.footer&&(this.footer.style.background=e?"#252525":"#fafafa"),this.updateStyleButtons(),this.colorPreview&&(this.colorPreview.style.borderColor=e?"#555":"#ddd"),this.fontSizeSelect&&(this.fontSizeSelect.style.background=e?"#3d3d3d":"#ffffff",this.fontSizeSelect.style.borderColor=e?"#555":"#ddd",this.fontSizeSelect.style.color=e?"#fff":"#333"),this.element.querySelectorAll(".text-input-modal-divider").forEach(n=>{n.style.background=e?"#444":"#ddd"})}destroy(){this.overlay.remove(),this.element.remove()}getElement(){return this.element}}class ym extends It{constructor(t,e,i,n){super(t,e,Z.TEXT_DRAW,{...i,zIndex:i?.zIndex??100}),this.drawInteraction=null,this.transformInteraction=null,this.features=new Map,this.editingHelperFeature=null,this.onDrawCompleteCallback=null,this.onEditCompleteCallback=null,this.editingFeature=null,this.mapView=null,this.textInputModal=null,this.isInputActive=!1,this.currentTheme="dark",this.currentTranslations=null,this.defaultFontSize=i?.defaultFontSize||16,this.defaultFontFamily=i?.defaultFontFamily||"sans-serif",this.defaultColor=i?.defaultColor||[255,255,255,1],this.defaultBackgroundColor=i?.defaultBackgroundColor||[0,0,0,.7],this.defaultOutlineColor=i?.defaultOutlineColor||[0,0,0,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:r=>this.getStyleForFeature(r),properties:{id:t,name:e,type:Z.TEXT_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t,this.currentTranslations&&(this.currentTranslations=t)}getStyleForFeature(t){if(t?.get("isHelper"))return this.getHelperStyle();const e=t?.get("content")||"",i=t?.get("fontSize")||this.defaultFontSize,n=t?.get("fontFamily")||this.defaultFontFamily,r=t?.get("color")||this.defaultColor,o=t?.get("backgroundColor")||this.defaultBackgroundColor,a=t?.get("outlineColor")||this.defaultOutlineColor,l=t?.get("outlineWidth")||this.defaultOutlineWidth,h=t?.get("fontWeight")||"normal",c=t?.get("fontStyle")||"normal";let d="";return c!=="normal"&&(d+=`${c} `),h!=="normal"&&(d+=`${h} `),d+=`${i}px ${n}`,new A({text:new te({text:e,font:d,fill:new j({color:M(r)}),stroke:new G({color:M(a),width:l}),backgroundFill:new j({color:M(o)}),padding:[4,8,4,8],textAlign:"center",textBaseline:"middle"})})}getHelperStyle(){return this.currentTheme,new A({fill:new j({color:"rgba(0, 170, 255, 0.05)"}),stroke:new G({color:"#ffaa00",width:2,lineDash:[8,6]})})}createHelperGeometry(t,e,i){const n=i*.6,r=e.length*n,o=i*1.2,a=r/2,l=o/2,[h,c]=t;return new it([[[h-a,c-l],[h+a,c-l],[h+a,c+l],[h-a,c+l],[h-a,c-l]]])}setTheme(t,e){this.currentTheme=t,this.currentTranslations=e,this.t=e}showTextInputModal(t,e,i,n){this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),this.isInputActive=!0;const r=this.mapView;if(!r||typeof r.getTargetElement!="function"){console.error(this.t.cannotGetMapTarget),this.isInputActive=!1,i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"});return}if(!r.getTargetElement()){console.error(this.t.cannotGetMapTarget),this.isInputActive=!1,i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"});return}const a=r.getPixelFromCoordinate(t);if(!a||a.length<2){console.error(this.t.cannotGetPixelFromCoordinate,t),this.isInputActive=!1,i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"});return}let l=a[0]-140,h=a[1]-130;l=Math.max(10,Math.min(l,window.innerWidth-290)),h=Math.max(10,Math.min(h,window.innerHeight-270));const c={addText:this.t.editText,enterText:this.t.pleaseEnterText,bold:this.t.bold,italic:this.t.italic,fontSize:this.t.fontSize,color:this.t.color,confirm:this.t.confirm,cancel:this.t.cancel,delete:this.t.delete};this.textInputModal=new mm({initialText:e?.text||"",initialFontSize:e?.fontSize||this.defaultFontSize,initialColor:e?.color||this.defaultColor,initialFontWeight:e?.fontWeight||"normal",initialFontStyle:e?.fontStyle||"normal",onConfirm:d=>{i&&i(d),this.hideTextInputModal()},onCancel:()=>{i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"}),this.hideTextInputModal()},onDelete:n,theme:this.currentTheme,t:c},{x:l,y:h})}hideTextInputModal(){this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),this.isInputActive=!1}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 Y;this.drawInteraction=new ee({source:e,type:"Point"}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry();if(n instanceof rt){const[r,o]=n.getCoordinates(),[a,l]=U([r,o]);this.showTextInputModal([r,o],void 0,h=>{if(e&&e.clear(),this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),h.text&&h.text.trim()){const c=Vt("text_"),d=new V({geometry:new rt([r,o]),id:c,position:[a,l],content:h.text});d.set("fontSize",h.fontSize),d.set("fontFamily",this.defaultFontFamily),d.set("color",h.color),d.set("fontWeight",h.fontWeight),d.set("fontStyle",h.fontStyle),d.set("backgroundColor",this.defaultBackgroundColor),d.set("outlineColor",this.defaultOutlineColor),d.set("outlineWidth",this.defaultOutlineWidth),d.set("scale",1),this.source?.addFeature(d),this.features.set(c,d),this.layer?.setZIndex(999),d.changed(),this.mapView&&this.mapView.renderSync(),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:c,position:[a,l],content:h.text,fontSize:h.fontSize,fontFamily:this.defaultFontFamily,color:h.color,fontWeight:h.fontWeight,fontStyle:h.fontStyle,backgroundColor:this.defaultBackgroundColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth})}else this.onDrawCompleteCallback&&this.onDrawCompleteCallback(null);this.onDrawCompleteCallback=null,this.mapView?.render()})}else 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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=i.getGeometry();if(!(n instanceof rt))return;const[r,o]=n.getCoordinates(),a=i.get("content")||"",l=i.get("fontSize")||this.defaultFontSize,h=this.createHelperGeometry([r,o],a,l);this.editingHelperFeature=new V({geometry:h,isHelper:!0}),this.editingHelperFeature.setStyle(this.getHelperStyle()),this.source?.addFeature(this.editingHelperFeature);const c=new Y;c.addFeature(this.editingHelperFeature);const d=c.getFeaturesCollection();this.transformInteraction=new _e({features:d,translate:!0,scale:!0,rotate:!1,keepAspectRatio:u=>u.shiftKey}),this.transformInteraction.setActive(!0),this.transformInteraction.on("scaleend",()=>{if(!this.editingHelperFeature||!i)return;const u=this.editingHelperFeature.getGeometry();if(u instanceof it){const f=u.getExtent(),g=(f[0]+f[2])/2,p=(f[1]+f[3])/2,m=f[2]-f[0],y=this.createHelperGeometry([r,o],a,l).getExtent()[2]-f[0],w=m/y,E=Math.max(8,l*w),x=i.getGeometry();x&&x.setCoordinates([g,p]),i.set("fontSize",E);const[C,T]=U([g,p]);i.set("position",[C,T]),i.changed();const _=this.createHelperGeometry([g,p],a,E);this.editingHelperFeature?.setGeometry(_);const b=i.get("id");this.onEditCompleteCallback&&b&&this.onEditCompleteCallback({id:b,position:[C,T],content:i.get("content"),fontSize:E,fontFamily:i.get("fontFamily"),color:i.get("color"),fontWeight:i.get("fontWeight"),fontStyle:i.get("fontStyle"),backgroundColor:i.get("backgroundColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth")}),this.mapView?.render()}}),this.transformInteraction.on("translateend",()=>{if(!this.editingHelperFeature||!i)return;const u=this.editingHelperFeature.getGeometry();if(u instanceof it){const f=u.getExtent(),g=(f[0]+f[2])/2,p=(f[1]+f[3])/2,m=i.getGeometry();m&&m.setCoordinates([g,p]);const[y,w]=U([g,p]);i.set("position",[y,w]),i.changed();const E=i.get("content")||"",x=i.get("fontSize")||this.defaultFontSize,C=this.createHelperGeometry([g,p],E,x);this.editingHelperFeature?.setGeometry(C);const T=i.get("id");this.onEditCompleteCallback&&T&&this.onEditCompleteCallback({id:T,position:[y,w],content:i.get("content"),fontSize:x,fontFamily:i.get("fontFamily"),color:i.get("color"),fontWeight:i.get("fontWeight"),fontStyle:i.get("fontStyle"),backgroundColor:i.get("backgroundColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth")}),this.mapView?.render()}}),this.mapView?.addInteraction(this.transformInteraction),this.mapView?.render()}editProperties(t,e,i){const n=this.features.get(t);if(!n)return;const r=n.getGeometry();if(r instanceof rt){const[o,a]=r.getCoordinates(),l=n.get("content")||"",h=n.get("fontSize")||this.defaultFontSize,c=n.get("color")||this.defaultColor,d=n.get("fontWeight")||"normal",u=n.get("fontStyle")||"normal",f=()=>{this.removeText(t),i&&i(),e&&e(null)};this.showTextInputModal([o,a],{text:l,fontSize:h,color:c,fontWeight:d,fontStyle:u},g=>{if(g.text&&g.text.trim()){n.set("content",g.text),n.set("fontSize",g.fontSize),n.set("color",g.color),n.set("fontWeight",g.fontWeight),n.set("fontStyle",g.fontStyle),n.changed(),this.mapView?.render();const p=n.get("position");e&&e({id:t,position:p,content:g.text,fontSize:g.fontSize,fontFamily:n.get("fontFamily"),color:g.color,fontWeight:g.fontWeight,fontStyle:g.fontStyle,backgroundColor:n.get("backgroundColor"),outlineColor:n.get("outlineColor"),outlineWidth:n.get("outlineWidth")})}},f)}}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingHelperFeature&&(this.source?.removeFeature(this.editingHelperFeature),this.editingHelperFeature=null),this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),this.isInputActive=!1,this.editingFeature=null,this.onEditCompleteCallback=null}addText(t){const e=ut(t.position),i=new V({geometry:new rt(e),id:t.id,position:t.position,content:t.content});i.set("fontSize",t.fontSize||this.defaultFontSize),i.set("fontFamily",t.fontFamily||this.defaultFontFamily),i.set("color",t.color||this.defaultColor),i.set("fontWeight",t.fontWeight||"normal"),i.set("fontStyle",t.fontStyle||"normal"),i.set("backgroundColor",t.backgroundColor||this.defaultBackgroundColor),i.set("outlineColor",t.outlineColor||this.defaultOutlineColor),i.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),i.set("scale",1),this.source?.addFeature(i),this.features.set(t.id,i)}removeText(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllTexts(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,position:e.get("position"),content:e.get("content"),fontSize:e.get("fontSize"),fontFamily:e.get("fontFamily"),color:e.get("color"),fontWeight:e.get("fontWeight"),fontStyle:e.get("fontStyle"),backgroundColor:e.get("backgroundColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth")})}),t}getText(t){const e=this.features.get(t);if(e)return{id:t,position:e.get("position"),content:e.get("content"),fontSize:e.get("fontSize"),fontFamily:e.get("fontFamily"),color:e.get("color"),fontWeight:e.get("fontWeight"),fontStyle:e.get("fontStyle"),backgroundColor:e.get("backgroundColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth")}}updateTextStyle(t,e,i,n,r,o,a,l,h){const c=this.features.get(t);c&&(c.set("fontSize",e),c.set("fontFamily",i),c.set("color",n),c.set("backgroundColor",r),c.set("outlineColor",o),c.set("outlineWidth",a),l&&c.set("fontWeight",l),h&&c.set("fontStyle",h),c.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.texts&&(this.clearAll(),t.texts.forEach(e=>this.addText(e)))}destroy(){this.stopDraw(),this.stopEdit(),this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),super.destroy()}}class _m extends It{constructor(t,e,i){super(t,e,Z.ARROW_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.defaultColor=i?.defaultColor||[255,87,34,1],this.defaultWidth=i?.defaultWidth||3,this.defaultStyle=i?.defaultStyle||"solid",this.defaultHeadSize=i?.defaultHeadSize||50,this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.ARROW_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("type");if(e==="line"){const i=t?.get("startPoint"),n=t?.get("endPoint"),r=t?.get("color")||this.defaultColor,o=t?.get("width")||this.defaultWidth,l=(t?.get("style")||this.defaultStyle)==="dashed"?[10,10]:void 0;if(!i||!n)return[new A({})];const h=ut(i),c=ut(n);return[new A({geometry:new pt([h,c]),stroke:new G({color:M(r),width:o,lineDash:l})})]}if(e==="arrowHead"){const i=t?.get("angle")||0,n=t?.get("color")||this.defaultColor,r=t?.get("headSize")||this.defaultHeadSize,o=t?.getGeometry()?.getCoordinates();if(!o)return[new A({})];const a=o[0],l=o[1],h=i+Math.PI*.85,c=i-Math.PI*.85,d=a+Math.cos(h)*r,u=l+Math.sin(h)*r,f=a+Math.cos(c)*r,g=l+Math.sin(c)*r,p=new it([[[a,l],[d,u],[f,g],[a,l]]]);return[new A({geometry:p,fill:new j({color:M(n)}),stroke:new G({color:M(n),width:1})})]}return[new A({})]}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 Y;let i=null,n=null;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:2,geometryFunction:(r,o)=>r.length===0?(i=null,n=null,o):r.length===1?(i=r[0],n=null,o?o.setCoordinates([i,i]):o=new pt([i,i]),o):(r.length>=2&&(i=r[0],n=r[1],o?o.setCoordinates([i,n]):o=new pt([i,n])),o),style:new A({stroke:new G({color:M(this.defaultColor),width:this.defaultWidth,lineDash:this.defaultStyle==="dashed"?[10,10]:void 0})})}),this.drawInteraction.on("drawend",r=>{const o=Vt("arrow_");if(i&&n){const[a,l]=U(i),[h,c]=U(n),d=Math.atan2(n[1]-i[1],n[0]-i[0]),u=new pt([i,n]),f=new V({geometry:u,id:o,startPoint:[a,l],endPoint:[h,c],type:"line"});f.set("color",this.defaultColor),f.set("width",this.defaultWidth),f.set("style",this.defaultStyle),f.set("headSize",this.defaultHeadSize);const g=new rt(n),p=new V({geometry:g,id:o+"_head",parentId:o,type:"arrowHead",angle:d,color:this.defaultColor,headSize:this.defaultHeadSize});this.source?.addFeature(f),this.source?.addFeature(p),this.features.set(o,f),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:o,startPoint:[a,l],endPoint:[h,c],color:this.defaultColor,width:this.defaultWidth,style:this.defaultStyle,headSize:this.defaultHeadSize})}i=null,n=null,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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof pt){const l=a.getCoordinates();if(l&&l.length>=2){const[h,c]=U(l[0]),[d,u]=U(l[1]),f=i.get("id");this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,startPoint:[h,c],endPoint:[d,u]}),i.set("startPoint",[h,c]),i.set("endPoint",[d,u]),i.changed();const g=this.features.get(f+"_head");if(g){const p=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]);g.setGeometry(new rt(l[1])),g.set("angle",p),g.changed()}}}};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addArrow(t){const e=ut(t.startPoint),i=ut(t.endPoint),n=new pt([e,i]),r=new V({geometry:n,id:t.id,startPoint:t.startPoint,endPoint:t.endPoint,type:"line"});r.set("color",t.color||this.defaultColor),r.set("width",t.width||this.defaultWidth),r.set("style",t.style||this.defaultStyle);const o=Math.atan2(i[1]-e[1],i[0]-e[0]),a=new rt(i),l=new V({geometry:a,id:t.id+"_head",parentId:t.id,type:"arrowHead",angle:o,color:t.color||this.defaultColor,headSize:t.headSize||this.defaultHeadSize});this.source?.addFeature(r),this.source?.addFeature(l),this.features.set(t.id,r),this.features.set(t.id+"_head",l)}removeArrow(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t));const i=this.features.get(t+"_head");i&&(this.source?.removeFeature(i),this.features.delete(t+"_head")),this.editingFeature===e&&this.stopEdit()}getAllArrows(){const t=[];return this.features.forEach((e,i)=>{!i.toString().endsWith("_head")&&e.get("startPoint")&&t.push({id:i.toString(),startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style"),headSize:e.get("headSize")})}),t}getArrow(t){const e=this.features.get(t);if(e)return{id:t,startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style"),headSize:e.get("headSize")}}updateArrowStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;o.set("color",e),o.set("width",i),o.set("style",n),o.set("headSize",r),o.changed();const a=this.features.get(t+"_head");a&&(a.set("color",e),a.set("headSize",r),a.changed()),this.mapView?.render()}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.arrows&&(this.clearAll(),t.arrows.forEach(e=>this.addArrow(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class Qn extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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])=>ut([r,o]))],i=new it(e),n=new V({geometry:i,id:t.id,title:t.title});n.setStyle(new A({fill:new j({color:M(t.fillColor||this.defaultFillColor)}),stroke:new G({color:M(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)))}getAllPolygons(){const t=[];return this.features.forEach((e,i)=>{t.push(e.getProperties())}),t}getPolygon(t){const e=this.features.get(t);if(e)return e.getProperties()}}class ts extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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])=>ut([r,o])),i=new pt(e),n=new V({geometry:i,id:t.id,title:t.title});n.setStyle(new A({stroke:new G({color:M(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)))}getAllPolylines(){const t=[];return this.features.forEach((e,i)=>{t.push(e.getProperties())}),t}getPolyline(t){const e=this.features.get(t);if(e)return e.getProperties()}}class es extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.CIRCLE},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createLayer(t){return t.addLayer(this.layer),this.layer}addCircle(t){const e=ut(t.center),i=new Me(e,t.radius),n=new V({geometry:i,id:t.id,title:t.title});n.setStyle(new A({fill:new j({color:M(t.fillColor||this.defaultFillColor)}),stroke:new G({color:M(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)))}getAllCircles(){const t=[];return this.features.forEach((e,i)=>{t.push(e.getProperties())}),t}getCircle(t){const e=this.features.get(t);if(e)return e.getProperties()}}function cd(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function ua(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 Ir=34962,ol=34963,wm=35044,Do=35048,xm=5121,Cm=5123,Em=5125,dd=5126,Th=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function vm(s,t){t=Object.assign({preserveDrawingBuffer:!0,antialias:!hf},t);const e=Th.length;for(let i=0;i<e;++i)try{const n=s.getContext(Th[i],t);if(n)return n}catch{}return null}const Tm={STATIC_DRAW:wm};class ko{constructor(t,e){this.array_=null,this.type_=t,gt(t===Ir||t===ol,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=e!==void 0?e:Tm.STATIC_DRAW}ofSize(t){return this.array_=new(sr(this.type_))(t),this}fromArray(t){return this.array_=sr(this.type_).from(t),this}fromArrayBuffer(t){return this.array_=new(sr(this.type_))(t),this}getType(){return this.type_}getArray(){return this.array_}setArray(t){const e=sr(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 sr(s){switch(s){case Ir:return Float32Array;case ol:return Uint32Array;default:return Float32Array}}const rr={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"},bm=`
|
|
140
|
+
`,n?(r.onmouseenter=()=>{r.style.background="#d32f2f"},r.onmouseleave=()=>{r.style.background="#f44336"}):i?(r.onmouseenter=()=>{r.style.background="#0088cc"},r.onmouseleave=()=>{r.style.background="#00aaff"}):(r.onmouseenter=()=>{r.style.background=e?"#4a4a4a":"#e0e0e0"},r.onmouseleave=()=>{r.style.background=e?"#3d3d3d":"#e8e8e8"}),r}rgbaToHex(t){const e=Math.round(t[0]),i=Math.round(t[1]),n=Math.round(t[2]);return`#${((1<<24)+(e<<16)+(i<<8)+n).toString(16).slice(1)}`}hexToRgba(t){const e=parseInt(t.slice(1,3),16),i=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return[e,i,n,1]}updateColorPreview(){this.colorPreview.style.backgroundColor=`rgba(${this.currentColor[0]}, ${this.currentColor[1]}, ${this.currentColor[2]}, ${this.currentColor[3]||1})`}updateStyleButtons(){const t=this.options.theme==="dark";this.boldBtn.style.background=this.isBold?"#00aaff":t?"#3d3d3d":"#e8e8e8",this.boldBtn.style.color=this.isBold?"#fff":t?"#ccc":"#666",this.italicBtn.style.background=this.isItalic?"#00aaff":t?"#3d3d3d":"#e8e8e8",this.italicBtn.style.color=this.isItalic?"#fff":t?"#ccc":"#666"}updateTextareaStyle(){const t=parseInt(this.fontSizeSelect.value);this.textarea.style.fontSize=`${t}px`,this.textarea.style.fontWeight=this.isBold?"bold":"normal",this.textarea.style.fontStyle=this.isItalic?"italic":"normal",this.textarea.style.color=`rgba(${this.currentColor[0]}, ${this.currentColor[1]}, ${this.currentColor[2]}, ${this.currentColor[3]||1})`}focusTextarea(){setTimeout(()=>{this.textarea.focus(),this.textarea.select()},50)}centerModal(){const t=(window.innerWidth-280)/2,e=(window.innerHeight-240)/2;this.element.style.left=`${Math.max(10,t)}px`,this.element.style.top=`${Math.max(10,e)}px`}setPosition(t){let e=t.x-140,i=t.y-130;e=Math.max(10,Math.min(e,window.innerWidth-290)),i=Math.max(10,Math.min(i,window.innerHeight-270)),this.element.style.left=`${e}px`,this.element.style.top=`${i}px`}bindEvents(){if(!this.fontSizeSelect||!this.colorPreview||!this.colorPicker||!this.boldBtn||!this.italicBtn||!this.confirmBtn||!this.cancelBtn||!this.textarea){console.error("TextInputModalBox: Required elements not found");return}this.fontSizeSelect.addEventListener("change",()=>{this.updateTextareaStyle()}),this.colorPreview.addEventListener("click",t=>{t.stopPropagation(),this.colorPicker.click()}),this.colorPicker.addEventListener("change",t=>{t.stopPropagation();const e=t.target;this.currentColor=this.hexToRgba(e.value),this.updateColorPreview(),this.updateTextareaStyle()}),this.boldBtn.addEventListener("click",t=>{t.stopPropagation(),this.isBold=!this.isBold,this.updateStyleButtons(),this.updateTextareaStyle()}),this.italicBtn.addEventListener("click",t=>{t.stopPropagation(),this.isItalic=!this.isItalic,this.updateStyleButtons(),this.updateTextareaStyle()}),this.deleteBtn&&this.deleteBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onDelete&&this.options.onDelete(),this.destroy()}),this.confirmBtn.addEventListener("click",t=>{t.stopPropagation();const e=this.textarea.value.trim();e?this.options.onConfirm({text:e,fontSize:parseInt(this.fontSizeSelect.value),color:this.currentColor,fontWeight:this.isBold?"bold":"normal",fontStyle:this.isItalic?"italic":"normal"}):this.options.onCancel(),this.destroy()}),this.cancelBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onCancel(),this.destroy()}),this.textarea.addEventListener("keydown",t=>{t.key==="Enter"&&(t.ctrlKey||t.metaKey)?(t.preventDefault(),t.stopPropagation(),this.confirmBtn.click()):t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),this.cancelBtn.click())}),this.element.addEventListener("click",t=>{t.stopPropagation()})}updateTheme(t){this.options.theme=t;const e=t==="dark";if(this.element.style.background=e?"#2d2d2d":"#ffffff",this.element.style.borderColor=e?"#444":"#e0e0e0",this.header){this.header.style.background=e?"#252525":"#f5f5f5",this.header.style.borderBottomColor=e?"#3d3d3d":"#eee";const n=this.header.querySelector("span");n&&(n.style.color=e?"#fff":"#333")}this.textarea&&(this.textarea.style.background=e?"#1e1e1e":"#fafafa",this.textarea.style.color=e?"#fff":"#333"),this.toolbar&&(this.toolbar.style.background=e?"#252525":"#fafafa",this.toolbar.style.borderTopColor=e?"#3d3d3d":"#eee",this.toolbar.style.borderBottomColor=e?"#3d3d3d":"#eee"),this.footer&&(this.footer.style.background=e?"#252525":"#fafafa"),this.updateStyleButtons(),this.colorPreview&&(this.colorPreview.style.borderColor=e?"#555":"#ddd"),this.fontSizeSelect&&(this.fontSizeSelect.style.background=e?"#3d3d3d":"#ffffff",this.fontSizeSelect.style.borderColor=e?"#555":"#ddd",this.fontSizeSelect.style.color=e?"#fff":"#333"),this.element.querySelectorAll(".text-input-modal-divider").forEach(n=>{n.style.background=e?"#444":"#ddd"})}destroy(){this.overlay.remove(),this.element.remove()}getElement(){return this.element}}class wm extends It{constructor(t,e,i,n){super(t,e,Z.TEXT_DRAW,{...i,zIndex:i?.zIndex??100}),this.drawInteraction=null,this.transformInteraction=null,this.features=new Map,this.editingHelperFeature=null,this.onDrawCompleteCallback=null,this.onEditCompleteCallback=null,this.editingFeature=null,this.mapView=null,this.textInputModal=null,this.isInputActive=!1,this.currentTheme="dark",this.currentTranslations=null,this.defaultFontSize=i?.defaultFontSize||16,this.defaultFontFamily=i?.defaultFontFamily||"sans-serif",this.defaultColor=i?.defaultColor||[255,255,255,1],this.defaultBackgroundColor=i?.defaultBackgroundColor||[0,0,0,.7],this.defaultOutlineColor=i?.defaultOutlineColor||[0,0,0,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:r=>this.getStyleForFeature(r),properties:{id:t,name:e,type:Z.TEXT_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t,this.currentTranslations&&(this.currentTranslations=t)}getStyleForFeature(t){if(t?.get("isHelper"))return this.getHelperStyle();const e=t?.get("content")||"",i=t?.get("fontSize")||this.defaultFontSize,n=t?.get("fontFamily")||this.defaultFontFamily,r=t?.get("color")||this.defaultColor,o=t?.get("backgroundColor")||this.defaultBackgroundColor,a=t?.get("outlineColor")||this.defaultOutlineColor,l=t?.get("outlineWidth")||this.defaultOutlineWidth,h=t?.get("fontWeight")||"normal",c=t?.get("fontStyle")||"normal";let d="";return c!=="normal"&&(d+=`${c} `),h!=="normal"&&(d+=`${h} `),d+=`${i}px ${n}`,new A({text:new te({text:e,font:d,fill:new j({color:M(r)}),stroke:new G({color:M(a),width:l}),backgroundFill:new j({color:M(o)}),padding:[4,8,4,8],textAlign:"center",textBaseline:"middle"})})}getHelperStyle(){return this.currentTheme,new A({fill:new j({color:"rgba(0, 170, 255, 0.05)"}),stroke:new G({color:"#ffaa00",width:2,lineDash:[8,6]})})}createHelperGeometry(t,e,i){const n=i*.6,r=e.length*n,o=i*1.2,a=r/2,l=o/2,[h,c]=t;return new it([[[h-a,c-l],[h+a,c-l],[h+a,c+l],[h-a,c+l],[h-a,c-l]]])}setTheme(t,e){this.currentTheme=t,this.currentTranslations=e,this.t=e}showTextInputModal(t,e,i,n){this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),this.isInputActive=!0;const r=this.mapView;if(!r||typeof r.getTargetElement!="function"){console.error(this.t.cannotGetMapTarget),this.isInputActive=!1,i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"});return}if(!r.getTargetElement()){console.error(this.t.cannotGetMapTarget),this.isInputActive=!1,i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"});return}const a=r.getPixelFromCoordinate(t);if(!a||a.length<2){console.error(this.t.cannotGetPixelFromCoordinate,t),this.isInputActive=!1,i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"});return}let l=a[0]-140,h=a[1]-130;l=Math.max(10,Math.min(l,window.innerWidth-290)),h=Math.max(10,Math.min(h,window.innerHeight-270));const c={addText:this.t.editText,enterText:this.t.pleaseEnterText,bold:this.t.bold,italic:this.t.italic,fontSize:this.t.fontSize,color:this.t.color,confirm:this.t.confirm,cancel:this.t.cancel,delete:this.t.delete};this.textInputModal=new _m({initialText:e?.text||"",initialFontSize:e?.fontSize||this.defaultFontSize,initialColor:e?.color||this.defaultColor,initialFontWeight:e?.fontWeight||"normal",initialFontStyle:e?.fontStyle||"normal",onConfirm:d=>{i&&i(d),this.hideTextInputModal()},onCancel:()=>{i&&i({text:"",fontSize:this.defaultFontSize,color:this.defaultColor,fontWeight:"normal",fontStyle:"normal"}),this.hideTextInputModal()},onDelete:n,theme:this.currentTheme,t:c,container:this.mapView?.getTargetElement()},{x:l,y:h}),this.textInputModal.getElement().style.userSelect="none"}hideTextInputModal(){this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),this.isInputActive=!1}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 Y;this.drawInteraction=new ee({source:e,type:"Point"}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry();if(n instanceof rt){const[r,o]=n.getCoordinates(),[a,l]=U([r,o]);this.showTextInputModal([r,o],void 0,h=>{if(e&&e.clear(),this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),h.text&&h.text.trim()){const c=Vt("text_"),d=new V({geometry:new rt([r,o]),id:c,position:[a,l],content:h.text});d.set("fontSize",h.fontSize),d.set("fontFamily",this.defaultFontFamily),d.set("color",h.color),d.set("fontWeight",h.fontWeight),d.set("fontStyle",h.fontStyle),d.set("backgroundColor",this.defaultBackgroundColor),d.set("outlineColor",this.defaultOutlineColor),d.set("outlineWidth",this.defaultOutlineWidth),d.set("scale",1),this.source?.addFeature(d),this.features.set(c,d),this.layer?.setZIndex(999),d.changed(),this.mapView&&this.mapView.renderSync(),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:c,position:[a,l],content:h.text,fontSize:h.fontSize,fontFamily:this.defaultFontFamily,color:h.color,fontWeight:h.fontWeight,fontStyle:h.fontStyle,backgroundColor:this.defaultBackgroundColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth})}else this.onDrawCompleteCallback&&this.onDrawCompleteCallback(null);this.onDrawCompleteCallback=null,this.mapView?.render()})}else 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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=i.getGeometry();if(!(n instanceof rt))return;const[r,o]=n.getCoordinates(),a=i.get("content")||"",l=i.get("fontSize")||this.defaultFontSize,h=this.createHelperGeometry([r,o],a,l);this.editingHelperFeature=new V({geometry:h,isHelper:!0}),this.editingHelperFeature.setStyle(this.getHelperStyle()),this.source?.addFeature(this.editingHelperFeature);const c=new Y;c.addFeature(this.editingHelperFeature);const d=c.getFeaturesCollection();this.transformInteraction=new _e({features:d,translate:!0,scale:!0,rotate:!1,keepAspectRatio:u=>u.shiftKey}),this.transformInteraction.setActive(!0),this.transformInteraction.on("scaleend",()=>{if(!this.editingHelperFeature||!i)return;const u=this.editingHelperFeature.getGeometry();if(u instanceof it){const f=u.getExtent(),g=(f[0]+f[2])/2,p=(f[1]+f[3])/2,m=f[2]-f[0],y=this.createHelperGeometry([r,o],a,l).getExtent()[2]-f[0],x=m/y,E=Math.max(8,l*x),w=i.getGeometry();w&&w.setCoordinates([g,p]),i.set("fontSize",E);const[C,v]=U([g,p]);i.set("position",[C,v]),i.changed();const _=this.createHelperGeometry([g,p],a,E);this.editingHelperFeature?.setGeometry(_);const b=i.get("id");this.onEditCompleteCallback&&b&&this.onEditCompleteCallback({id:b,position:[C,v],content:i.get("content"),fontSize:E,fontFamily:i.get("fontFamily"),color:i.get("color"),fontWeight:i.get("fontWeight"),fontStyle:i.get("fontStyle"),backgroundColor:i.get("backgroundColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth")}),this.mapView?.render()}}),this.transformInteraction.on("translateend",()=>{if(!this.editingHelperFeature||!i)return;const u=this.editingHelperFeature.getGeometry();if(u instanceof it){const f=u.getExtent(),g=(f[0]+f[2])/2,p=(f[1]+f[3])/2,m=i.getGeometry();m&&m.setCoordinates([g,p]);const[y,x]=U([g,p]);i.set("position",[y,x]),i.changed();const E=i.get("content")||"",w=i.get("fontSize")||this.defaultFontSize,C=this.createHelperGeometry([g,p],E,w);this.editingHelperFeature?.setGeometry(C);const v=i.get("id");this.onEditCompleteCallback&&v&&this.onEditCompleteCallback({id:v,position:[y,x],content:i.get("content"),fontSize:w,fontFamily:i.get("fontFamily"),color:i.get("color"),fontWeight:i.get("fontWeight"),fontStyle:i.get("fontStyle"),backgroundColor:i.get("backgroundColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth")}),this.mapView?.render()}}),this.mapView?.addInteraction(this.transformInteraction),this.mapView?.render()}editProperties(t,e,i){const n=this.features.get(t);if(!n)return;const r=n.getGeometry();if(r instanceof rt){const[o,a]=r.getCoordinates(),l=n.get("content")||"",h=n.get("fontSize")||this.defaultFontSize,c=n.get("color")||this.defaultColor,d=n.get("fontWeight")||"normal",u=n.get("fontStyle")||"normal",f=()=>{this.removeText(t),i&&i(),e&&e(null)};this.showTextInputModal([o,a],{text:l,fontSize:h,color:c,fontWeight:d,fontStyle:u},g=>{if(g.text&&g.text.trim()){n.set("content",g.text),n.set("fontSize",g.fontSize),n.set("color",g.color),n.set("fontWeight",g.fontWeight),n.set("fontStyle",g.fontStyle),n.changed(),this.mapView?.render();const p=n.get("position");e&&e({id:t,position:p,content:g.text,fontSize:g.fontSize,fontFamily:n.get("fontFamily"),color:g.color,fontWeight:g.fontWeight,fontStyle:g.fontStyle,backgroundColor:n.get("backgroundColor"),outlineColor:n.get("outlineColor"),outlineWidth:n.get("outlineWidth")})}},f)}}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingHelperFeature&&(this.source?.removeFeature(this.editingHelperFeature),this.editingHelperFeature=null),this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),this.isInputActive=!1,this.editingFeature=null,this.onEditCompleteCallback=null}addText(t){const e=ut(t.position),i=new V({geometry:new rt(e),id:t.id,position:t.position,content:t.content});i.set("fontSize",t.fontSize||this.defaultFontSize),i.set("fontFamily",t.fontFamily||this.defaultFontFamily),i.set("color",t.color||this.defaultColor),i.set("fontWeight",t.fontWeight||"normal"),i.set("fontStyle",t.fontStyle||"normal"),i.set("backgroundColor",t.backgroundColor||this.defaultBackgroundColor),i.set("outlineColor",t.outlineColor||this.defaultOutlineColor),i.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),i.set("scale",1),this.source?.addFeature(i),this.features.set(t.id,i)}removeText(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllTexts(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,position:e.get("position"),content:e.get("content"),fontSize:e.get("fontSize"),fontFamily:e.get("fontFamily"),color:e.get("color"),fontWeight:e.get("fontWeight"),fontStyle:e.get("fontStyle"),backgroundColor:e.get("backgroundColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth")})}),t}getText(t){const e=this.features.get(t);if(e)return{id:t,position:e.get("position"),content:e.get("content"),fontSize:e.get("fontSize"),fontFamily:e.get("fontFamily"),color:e.get("color"),fontWeight:e.get("fontWeight"),fontStyle:e.get("fontStyle"),backgroundColor:e.get("backgroundColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth")}}updateTextStyle(t,e,i,n,r,o,a,l,h){const c=this.features.get(t);c&&(c.set("fontSize",e),c.set("fontFamily",i),c.set("color",n),c.set("backgroundColor",r),c.set("outlineColor",o),c.set("outlineWidth",a),l&&c.set("fontWeight",l),h&&c.set("fontStyle",h),c.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.texts&&(this.clearAll(),t.texts.forEach(e=>this.addText(e)))}destroy(){this.stopDraw(),this.stopEdit(),this.textInputModal&&(this.textInputModal.destroy(),this.textInputModal=null),super.destroy()}}class xm extends It{constructor(t,e,i){super(t,e,Z.ARROW_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.defaultColor=i?.defaultColor||[255,87,34,1],this.defaultWidth=i?.defaultWidth||3,this.defaultStyle=i?.defaultStyle||"solid",this.defaultHeadSize=i?.defaultHeadSize||50,this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.ARROW_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("type");if(e==="line"){const i=t?.get("startPoint"),n=t?.get("endPoint"),r=t?.get("color")||this.defaultColor,o=t?.get("width")||this.defaultWidth,l=(t?.get("style")||this.defaultStyle)==="dashed"?[10,10]:void 0;if(!i||!n)return[new A({})];const h=ut(i),c=ut(n);return[new A({geometry:new pt([h,c]),stroke:new G({color:M(r),width:o,lineDash:l})})]}if(e==="arrowHead"){const i=t?.get("angle")||0,n=t?.get("color")||this.defaultColor,r=t?.get("headSize")||this.defaultHeadSize,o=t?.getGeometry()?.getCoordinates();if(!o)return[new A({})];const a=o[0],l=o[1],h=i+Math.PI*.85,c=i-Math.PI*.85,d=a+Math.cos(h)*r,u=l+Math.sin(h)*r,f=a+Math.cos(c)*r,g=l+Math.sin(c)*r,p=new it([[[a,l],[d,u],[f,g],[a,l]]]);return[new A({geometry:p,fill:new j({color:M(n)}),stroke:new G({color:M(n),width:1})})]}return[new A({})]}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 Y;let i=null,n=null;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:2,geometryFunction:(r,o)=>r.length===0?(i=null,n=null,o):r.length===1?(i=r[0],n=null,o?o.setCoordinates([i,i]):o=new pt([i,i]),o):(r.length>=2&&(i=r[0],n=r[1],o?o.setCoordinates([i,n]):o=new pt([i,n])),o),style:new A({stroke:new G({color:M(this.defaultColor),width:this.defaultWidth,lineDash:this.defaultStyle==="dashed"?[10,10]:void 0})})}),this.drawInteraction.on("drawend",r=>{const o=Vt("arrow_");if(i&&n){const[a,l]=U(i),[h,c]=U(n),d=Math.atan2(n[1]-i[1],n[0]-i[0]),u=new pt([i,n]),f=new V({geometry:u,id:o,startPoint:[a,l],endPoint:[h,c],type:"line"});f.set("color",this.defaultColor),f.set("width",this.defaultWidth),f.set("style",this.defaultStyle),f.set("headSize",this.defaultHeadSize);const g=new rt(n),p=new V({geometry:g,id:o+"_head",parentId:o,type:"arrowHead",angle:d,color:this.defaultColor,headSize:this.defaultHeadSize});this.source?.addFeature(f),this.source?.addFeature(p),this.features.set(o,f),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:o,startPoint:[a,l],endPoint:[h,c],color:this.defaultColor,width:this.defaultWidth,style:this.defaultStyle,headSize:this.defaultHeadSize})}i=null,n=null,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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof pt){const l=a.getCoordinates();if(l&&l.length>=2){const[h,c]=U(l[0]),[d,u]=U(l[1]),f=i.get("id");this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,startPoint:[h,c],endPoint:[d,u]}),i.set("startPoint",[h,c]),i.set("endPoint",[d,u]),i.changed();const g=this.features.get(f+"_head");if(g){const p=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]);g.setGeometry(new rt(l[1])),g.set("angle",p),g.changed()}}}};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addArrow(t){const e=ut(t.startPoint),i=ut(t.endPoint),n=new pt([e,i]),r=new V({geometry:n,id:t.id,startPoint:t.startPoint,endPoint:t.endPoint,type:"line"});r.set("color",t.color||this.defaultColor),r.set("width",t.width||this.defaultWidth),r.set("style",t.style||this.defaultStyle);const o=Math.atan2(i[1]-e[1],i[0]-e[0]),a=new rt(i),l=new V({geometry:a,id:t.id+"_head",parentId:t.id,type:"arrowHead",angle:o,color:t.color||this.defaultColor,headSize:t.headSize||this.defaultHeadSize});this.source?.addFeature(r),this.source?.addFeature(l),this.features.set(t.id,r),this.features.set(t.id+"_head",l)}removeArrow(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t));const i=this.features.get(t+"_head");i&&(this.source?.removeFeature(i),this.features.delete(t+"_head")),this.editingFeature===e&&this.stopEdit()}getAllArrows(){const t=[];return this.features.forEach((e,i)=>{!i.toString().endsWith("_head")&&e.get("startPoint")&&t.push({id:i.toString(),startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style"),headSize:e.get("headSize")})}),t}getArrow(t){const e=this.features.get(t);if(e)return{id:t,startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style"),headSize:e.get("headSize")}}updateArrowStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;o.set("color",e),o.set("width",i),o.set("style",n),o.set("headSize",r),o.changed();const a=this.features.get(t+"_head");a&&(a.set("color",e),a.set("headSize",r),a.changed()),this.mapView?.render()}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.arrows&&(this.clearAll(),t.arrows.forEach(e=>this.addArrow(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class Qn extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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])=>ut([r,o]))],i=new it(e),n=new V({geometry:i,id:t.id,title:t.title});n.setStyle(new A({fill:new j({color:M(t.fillColor||this.defaultFillColor)}),stroke:new G({color:M(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)))}getAllPolygons(){const t=[];return this.features.forEach((e,i)=>{t.push(e.getProperties())}),t}getPolygon(t){const e=this.features.get(t);if(e)return e.getProperties()}}class ts extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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])=>ut([r,o])),i=new pt(e),n=new V({geometry:i,id:t.id,title:t.title});n.setStyle(new A({stroke:new G({color:M(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)))}getAllPolylines(){const t=[];return this.features.forEach((e,i)=>{t.push(e.getProperties())}),t}getPolyline(t){const e=this.features.get(t);if(e)return e.getProperties()}}class es extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.CIRCLE},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createLayer(t){return t.addLayer(this.layer),this.layer}addCircle(t){const e=ut(t.center),i=new Me(e,t.radius),n=new V({geometry:i,id:t.id,title:t.title});n.setStyle(new A({fill:new j({color:M(t.fillColor||this.defaultFillColor)}),stroke:new G({color:M(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)))}getAllCircles(){const t=[];return this.features.forEach((e,i)=>{t.push(e.getProperties())}),t}getCircle(t){const e=this.features.get(t);if(e)return e.getProperties()}}function ud(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function fa(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 Lr=34962,ll=34963,Cm=35044,ko=35048,Em=5121,vm=5123,Tm=5125,fd=5126,Sh=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function bm(s,t){t=Object.assign({preserveDrawingBuffer:!0,antialias:!df},t);const e=Sh.length;for(let i=0;i<e;++i)try{const n=s.getContext(Sh[i],t);if(n)return n}catch{}return null}const Sm={STATIC_DRAW:Cm};class Ro{constructor(t,e){this.array_=null,this.type_=t,gt(t===Lr||t===ll,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=e!==void 0?e:Sm.STATIC_DRAW}ofSize(t){return this.array_=new(rr(this.type_))(t),this}fromArray(t){return this.array_=rr(this.type_).from(t),this}fromArrayBuffer(t){return this.array_=new(rr(this.type_))(t),this}getType(){return this.type_}getArray(){return this.array_}setArray(t){const e=rr(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 rr(s){switch(s){case Lr:return Float32Array;case ll:return Uint32Array;default:return Float32Array}}const or={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"},Pm=`
|
|
140
141
|
precision mediump float;
|
|
141
142
|
|
|
142
143
|
attribute vec2 a_position;
|
|
@@ -150,7 +151,7 @@
|
|
|
150
151
|
v_screenCoord = v_texCoord * u_screenSize;
|
|
151
152
|
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
152
153
|
}
|
|
153
|
-
`,
|
|
154
|
+
`,Im=`
|
|
154
155
|
precision mediump float;
|
|
155
156
|
|
|
156
157
|
uniform sampler2D u_image;
|
|
@@ -161,25 +162,25 @@
|
|
|
161
162
|
void main() {
|
|
162
163
|
gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;
|
|
163
164
|
}
|
|
164
|
-
`;class bh{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||bm),e.compileShader(i);const n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,t.fragmentShader||Sm),e.compileShader(n),this.renderTargetProgram_=e.createProgram(),e.attachShader(this.renderTargetProgram_,i),e.attachShader(this.renderTargetProgram_,n),e.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=e.createBuffer();const r=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];e.bindBuffer(e.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW),this.renderTargetAttribLocation_=e.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],t.uniforms&&Object.keys(t.uniforms).forEach(o=>{this.uniforms_.push({value:t.uniforms[o],location:e.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(t){const e=this.getGL(),i=[e.drawingBufferWidth*this.scaleRatio_,e.drawingBufferHeight*this.scaleRatio_];if(e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer()),e.bindRenderbuffer(e.RENDERBUFFER,this.getDepthBuffer()),e.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;const n=0,r=e.RGBA,o=0,a=e.RGBA,l=e.UNSIGNED_BYTE,h=null;e.bindTexture(e.TEXTURE_2D,this.renderTargetTexture_),e.texImage2D(e.TEXTURE_2D,n,r,i[0],i[1],o,a,l,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.renderTargetTexture_,0),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i[0],i[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthBuffer_)}}apply(t,e,i,n){const r=this.getGL(),o=t.size;if(r.bindFramebuffer(r.FRAMEBUFFER,e?e.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!e){const l=K(r.canvas);if(!t.renderTargets[l]){const h=r.getContextAttributes();h&&h.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),t.renderTargets[l]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const a=t.layerStatesArray[t.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(t),i&&i(r,t),r.drawArrays(r.TRIANGLES,0,6),n&&n(r,t)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(t){const e=this.getGL();let i,n=1;this.uniforms_.forEach(function(r){if(i=typeof r.value=="function"?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof ImageData)r.texture||(r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${n}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i instanceof ImageData?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,i.width,i.height,0,e.UNSIGNED_BYTE,new Uint8Array(i.data)):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i),e.uniform1i(r.location,n++);else if(Array.isArray(i))switch(i.length){case 2:e.uniform2f(r.location,i[0],i[1]);return;case 3:e.uniform3f(r.location,i[0],i[1],i[2]);return;case 4:e.uniform4f(r.location,i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(r.location,i)})}}const Ae={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"},Jt={UNSIGNED_BYTE:xm,UNSIGNED_SHORT:Cm,UNSIGNED_INT:Em,FLOAT:dd},Lr={};function Sh(s){return"shared/"+s}let Ph=0;function Pm(){const s="unique/"+Ph;return Ph+=1,s}function Im(s){let t=Lr[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:vm(e)},Lr[s]=t}return t.users+=1,t.context}function Lm(s){const t=Lr[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 Lr[s]}class Dm extends Es{constructor(t){super(),t=t||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=t.canvasCacheKey?Sh(t.canvasCacheKey):Pm(),this.gl_=Im(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const e=this.gl_.canvas;e.addEventListener(rr.LOST,this.boundHandleWebGLContextLost_),e.addEventListener(rr.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Ut(),this.offsetScaleMatrix_=Ut(),this.tmpMat4_=cd(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],t.uniforms&&this.setUniforms(t.uniforms),this.postProcessPasses_=t.postProcesses?t.postProcesses.map(i=>new bh({webGlContext:this.gl_,scaleRatio:i.scaleRatio,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,uniforms:i.uniforms})):[new bh({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_===Sh(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 gt(!!t,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),t}bindBuffer(t){const e=this.gl_,i=K(t);let n=this.bufferCache_[i];if(!n){const r=e.createBuffer();n={buffer:t,webGlBuffer:r},this.bufferCache_[i]=n}e.bindBuffer(t.getType(),n.webGlBuffer)}flushBufferData(t){const e=this.gl_;this.bindBuffer(t),e.bufferData(t.getType(),t.getArray(),t.getUsage())}deleteBuffer(t){const e=K(t);delete this.bufferCache_[e]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(rr.LOST,this.boundHandleWebGLContextLost_),t.removeEventListener(rr.RESTORED,this.boundHandleWebGLContextRestored_),Lm(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(Ae.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(Ae.ZOOM,t.viewState.zoom),this.setUniformFloatValue(Ae.RESOLUTION,t.viewState.resolution),this.setUniformFloatValue(Ae.PIXEL_RATIO,n),this.setUniformFloatVec2(Ae.VIEWPORT_SIZE_PX,[e[0],e[1]]),this.setUniformFloatValue(Ae.ROTATION,i)}applyHitDetectionUniform(t){const e=this.getUniformLocation(Ae.HIT_DETECTION);this.getGL().uniform1i(e,t?1:0),t&&this.setUniformFloatValue(Ae.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,ua(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:e.uniform2f(this.getUniformLocation(r.name),i[0],i[1]);return;case 3:e.uniform3f(this.getUniformLocation(r.name),i[0],i[1],i[2]);return;case 4:e.uniform4f(this.getUniformLocation(r.name),i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(this.getUniformLocation(r.name),i)})}useProgram(t,e){this.disableAllAttributes_(),this.gl_.useProgram(t),this.currentProgram_=t,e&&(this.applyFrameState(e),this.applyUniforms(e))}compileShader(t,e){const i=this.gl_,n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}getProgram(t,e){const i=this.gl_,n=this.compileShader(t,i.FRAGMENT_SHADER),r=this.compileShader(e,i.VERTEX_SHADER),o=i.createProgram();if(i.attachShader(o,n),i.attachShader(o,r),i.linkProgram(o),!i.getShaderParameter(n,i.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${i.getShaderInfoLog(n)}`;throw new Error(a)}if(i.deleteShader(n),!i.getShaderParameter(r,i.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${i.getShaderInfoLog(r)}`;throw new Error(a)}if(i.deleteShader(r),!i.getProgramParameter(o,i.LINK_STATUS)){const a=`GL program linking failed: ${i.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(t){const e=K(this.currentProgram_);return this.uniformLocationsByProgram_[e]===void 0&&(this.uniformLocationsByProgram_[e]={}),this.uniformLocationsByProgram_[e][t]===void 0&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=K(this.currentProgram_);return this.attribLocationsByProgram_[e]===void 0&&(this.attribLocationsByProgram_[e]={}),this.attribLocationsByProgram_[e][t]===void 0&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const i=t.size,n=t.viewState.rotation,r=t.viewState.resolution,o=t.viewState.center;return Pe(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=km(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||dd,i,n,e),n+=o.size*ud(o.type)}}enableAttributes(t){this.enableAttributes_(t,!1)}enableAttributesInstanced(t){this.enableAttributes_(t,!0)}handleWebGLContextLost(t){kn(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,d=r.UNSIGNED_BYTE;return e instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,d,e):e?r.texImage2D(r.TEXTURE_2D,a,l,c,d,e):r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,d,null),i}}function km(s){let t=0;for(let e=0;e<s.length;e++){const i=s[e];t+=i.size*ud(i.type)}return t}function ud(s){switch(s){case Jt.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Jt.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Jt.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case Jt.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}class al extends Fr{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(nt.CHANGE)}release(){this.setState(X.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==X.EMPTY){if(this.state!==X.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){Q()}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:qc(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 fa(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const Rm=new Error("disposed"),Am=[256,256];class Ih extends al{constructor(t){const e=X.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=fa(this.data_);return t?[t.width,t.height]:Am}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==X.IDLE&&this.state!==X.ERROR)return;this.state=X.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=X.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=X.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Rm),this.controller_=null),super.disposeInternal()}}class fd extends al{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_,Ee?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=X.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=X.ERROR,this.unlistenImage_(),this.image_=Mm(),this.changed()}handleImageLoad_(){if(Ee)this.state=X.LOADED;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=X.LOADED:this.state=X.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==X.ERROR&&(this.state=X.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==X.IDLE&&(this.state=X.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=vf(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 Mm(){const s=$t(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}let Ro;const Cn=[];function Lh(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 Ao(s,t){return Math.abs(s[t*4]-210)>2||Math.abs(s[t*4+3]-.75*255)>2}function Fm(){if(Ro===void 0){const s=$t(6,6,Cn);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",Lh(s,4,5,4,0),Lh(s,4,5,0,5);const t=s.getImageData(0,0,3,3).data;Ro=Ao(t,0)||Ao(t,4)||Ao(t,8),Xr(s),Cn.push(s.canvas)}return Ro}function Dh(s,t,e,i){const n=Br(e,t,s);let r=Bl(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||Tn(l,n)){const h=Bl(s,r,n)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Om(s,t,e,i){const n=be(e);let r=Dh(s,t,n,i);return(!isFinite(r)||r<=0)&&Ea(e,function(o){return r=Dh(s,t,o,i),isFinite(r)&&r>0}),r}function zm(s,t,e,i,n,r,o,a,l,h,c,d,u,f){const g=$t(Math.round(e*s),Math.round(e*t),Cn);if(d||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function p(C){return Math.round(C*e)/e}g.globalCompositeOperation="lighter";const m=oe();l.forEach(function(C,T,_){ss(m,C.extent)});let y;const w=e/i,E=(d?1:1+Math.pow(2,-24))/w;y=$t(Math.round(Et(m)*w),Math.round(he(m)*w),Cn),d||(y.imageSmoothingEnabled=!1),l.forEach(function(C,T,_){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){y.save();const k=(C.clipExtent[0]-m[0])*w,F=-(C.clipExtent[3]-m[3])*w,O=Et(C.clipExtent)*w,R=he(C.clipExtent)*w;y.rect(d?k:Math.round(k),d?F:Math.round(F),d?O:Math.round(k+O)-Math.round(k),d?R:Math.round(F+R)-Math.round(F)),y.clip()}const b=(C.extent[0]-m[0])*w,S=-(C.extent[3]-m[3])*w,P=Et(C.extent)*w,L=he(C.extent)*w;y.drawImage(C.image,h,h,C.image.width-2*h,C.image.height-2*h,d?b:Math.round(b),d?S:Math.round(S),d?P:Math.round(b+P)-Math.round(b),d?L:Math.round(S+L)-Math.round(S)),C.clipExtent&&y.restore()}});const x=ji(o);return a.getTriangles().forEach(function(C,T,_){const b=C.source,S=C.target;let P=b[0][0],L=b[0][1],k=b[1][0],F=b[1][1],O=b[2][0],R=b[2][1];const B=p((S[0][0]-x[0])/r),D=p(-(S[0][1]-x[1])/r),z=p((S[1][0]-x[0])/r),N=p(-(S[1][1]-x[1])/r),tt=p((S[2][0]-x[0])/r),et=p(-(S[2][1]-x[1])/r),ht=P,ot=L;P=0,L=0,k-=ht,F-=ot,O-=ht,R-=ot;const I=[[k,F,0,0,z-B],[O,R,0,0,tt-B],[0,0,k,F,N-D],[0,0,O,R,et-D]],xt=lu(I);if(!xt)return;if(g.save(),g.beginPath(),Fm()||!d){g.moveTo(z,N);const Ot=4,ie=B-z,Ne=D-N;for(let St=0;St<Ot;St++)g.lineTo(z+p((St+1)*ie/Ot),N+p(St*Ne/(Ot-1))),St!=Ot-1&&g.lineTo(z+p((St+1)*ie/Ot),N+p((St+1)*Ne/(Ot-1)));g.lineTo(tt,et)}else g.moveTo(z,N),g.lineTo(B,D),g.lineTo(tt,et);g.clip(),g.transform(xt[0],xt[2],xt[1],xt[3],B,D),g.translate(m[0]-ht,m[3]-ot);let yt;if(y)yt=y.canvas,g.scale(E,-E);else{const Ot=l[0],ie=Ot.extent;yt=Ot.image,g.scale(Et(ie)/yt.width,-he(ie)/yt.height)}g.drawImage(yt,0,0),g.restore()}),y&&(Xr(y),Cn.push(y.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(C,T,_){const b=C.target,S=(b[0][0]-x[0])/r,P=-(b[0][1]-x[1])/r,L=(b[1][0]-x[0])/r,k=-(b[1][1]-x[1])/r,F=(b[2][0]-x[0])/r,O=-(b[2][1]-x[1])/r;g.beginPath(),g.moveTo(L,k),g.lineTo(S,P),g.lineTo(F,O),g.closePath(),g.stroke()}),g.restore()),g.canvas}const $m=10,kh=.25;class Nm{constructor(t,e,i,n,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?zu(E=>zt(a,Br(E,this.targetProj_,this.sourceProj_))):us(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){const x=E[0]+"/"+E[1];return l[x]||(l[x]=h(E)),l[x]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&Et(n)>=Et(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Et(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Et(this.targetProj_.getExtent()):null;const c=ji(i),d=$r(i),u=zr(i),f=Or(i),g=this.transformInv_(c),p=this.transformInv_(d),m=this.transformInv_(u),y=this.transformInv_(f),w=$m+(o?Math.max(0,Math.ceil(Math.log2(Ho(i)/(o*o*256*256)))):0);if(this.addQuad_(c,d,u,f,g,p,m,y,w),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(x,C,T){E=Math.min(E,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-E>this.sourceWorldWidth_/2){const C=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];C[0][0]-E>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-E>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-E>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);const T=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-T<this.sourceWorldWidth_/2&&(x.source=C)}})}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=mr([r,o,a,l]),d=this.sourceWorldWidth_?Et(c)/this.sourceWorldWidth_:null,u=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&d>.5&&d<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const m=mr([t,e,i,n]);g=Et(m)/this.targetWorldWidth_>kh||g}!f&&this.sourceProj_.isGlobal()&&d&&(g=d>kh||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!le(c,this.maxSourceExtent_))return;let p=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(p=(!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),p!=1&&p!=2&&p!=4&&p!=8)return}if(h>0){if(!g){const m=[(t[0]+i[0])/2,(t[1]+i[1])/2],y=this.transformInv_(m);let w;f?w=(Gi(r[0],u)+Gi(a[0],u))/2-Gi(y[0],u):w=(r[0]+a[0])/2-y[0];const E=(r[1]+a[1])/2-y[1];g=w*w+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const m=[(e[0]+i[0])/2,(e[1]+i[1])/2],y=this.transformInv_(m),w=[(n[0]+t[0])/2,(n[1]+t[1])/2],E=this.transformInv_(w);this.addQuad_(t,e,m,w,r,o,y,E,h-1),this.addQuad_(w,m,i,n,E,y,a,l,h-1)}else{const m=[(t[0]+e[0])/2,(t[1]+e[1])/2],y=this.transformInv_(m),w=[(i[0]+n[0])/2,(i[1]+n[1])/2],E=this.transformInv_(w);this.addQuad_(t,m,w,n,r,y,E,l,h-1),this.addQuad_(m,e,i,w,y,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(p&11)==0&&this.addTriangle_(t,i,n,r,a,l),(p&14)==0&&this.addTriangle_(t,i,e,r,a,o),p&&((p&13)==0&&this.addTriangle_(e,n,t,o,l,r),(p&7)==0&&this.addTriangle_(e,n,i,o,l,a))}calculateSourceExtent(){const t=oe();return this.triangles_.forEach(function(e,i,n){const r=e.source;rs(t,r[0]),rs(t,r[1]),rs(t,r[2])}),t}getTriangles(){return this.triangles_}}const Gm=.5;class gd extends al{constructor(t,e,i,n,r,o,a,l,h,c,d,u){super(r,X.IDLE,u),this.renderEdges_=d!==void 0?d:!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 p=this.sourceTileGrid_.getExtent();const m=g?Ni(f,g):f;if(Ho(m)===0){this.state=X.EMPTY;return}const y=t.getExtent();y&&(p?p=Ni(p,y):p=y);const w=n.getResolution(this.wrappedTileCoord_[0]),E=Om(t,i,m,w);if(!isFinite(E)||E<=0){this.state=X.EMPTY;return}const x=c!==void 0?c:Gm;if(this.triangulation_=new Nm(t,i,m,p,E*x,w),this.triangulation_.getTriangles().length===0){this.state=X.EMPTY;return}this.sourceZ_=e.getZForResolution(E);let C=this.triangulation_.calculateSourceExtent();if(p&&(t.canWrapX()?(C[1]=Pt(C[1],p[1],p[3]),C[3]=Pt(C[3],p[1],p[3])):C=Ni(C,p)),!Ho(C))this.state=X.EMPTY;else{let T=0,_=0;t.canWrapX()&&(T=Et(y),_=Math.floor((C[0]-y[0])/T)),Hh(C.slice(),t,!0).forEach(S=>{const P=e.getTileRangeForExtentAndZ(S,this.sourceZ_);for(let L=P.minX;L<=P.maxX;L++)for(let k=P.minY;k<=P.maxY;k++){const F=_*T;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,L,k,a),offset:F})}++_}),this.sourceTiles_.length===0&&(this.state=X.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==X.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=X.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_=zm(n,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=X.LOADED}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(this.state==X.IDLE){this.state=X.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==X.IDLE||i==X.LOADING){t++;const n=ft(e,nt.CHANGE,r=>{const o=e.getState();(o==X.LOADED||o==X.ERROR||o==X.EMPTY)&&(Tt(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()==X.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(Tt),this.sourcesListenerKeys_=null}release(){this.canvas_&&(Xr(this.canvas_.getContext("2d")),Cn.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}}class ll{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 sn(s,t,e,i,n){return n!==void 0?(n.minX=s,n.maxX=t,n.minY=e,n.maxY=i,n):new ll(s,t,e,i)}class Rh{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 Es&&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 gt(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 gt(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){gt(!(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 Dr(s,t,e,i){return i!==void 0?(i[0]=s,i[1]=t,i[2]=e,i):[s,t,e]}function Bm(s,t,e){return s+"/"+t+"/"+e}function cr(s,t,e,i,n){return`${K(s)},${t},${Bm(e,i,n)}`}function Wm(s){return Um(s[0],s[1],s[2])}function Um(s,t,e){return(t<<s)+e}function Vm(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 hl extends Gc{constructor(t,e){super(t),e=e||{},this.inversePixelTransform_=Ut(),this.postProcesses_=e.postProcesses,this.uniforms_=e.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},t.addChangeListener(wt.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(Yt.PRECOMPOSE)){const n=new hs(Yt.PRECOMPOSE,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Yt.POSTCOMPOSE)){const n=new hs(Yt.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 hl)){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 Dm({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(wt.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){Pe(this.inversePixelTransform_,0,0,i.pixelRatio,-i.pixelRatio,0,0,-i.size[1]);const r=new hs(t,this.inversePixelTransform_,i,e);n.dispatchEvent(r)}}preRender(t,e){this.dispatchRenderEvent_(Yt.PRERENDER,t,e)}postRender(t,e){this.dispatchRenderEvent_(Yt.POSTRENDER,t,e)}}const Mo={TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight"};class Hm{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 Xm(s,t){return`operator_${s}_${Object.keys(t.functions).length}`}function Si(s){const t=s.toString();return t.includes(".")?t:t+".0"}function cl(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(Si).join(", ")})`}function dr(s){const t=Ie(s),e=t.length>3?t[3]:1;return cl([t[0]/255,t[1]/255,t[2]/255,e])}function jm(s){const t=ce(s);return cl(t)}const Fo={};let Ym=0;function Cs(s){return s in Fo||(Fo[s]=Ym++),Fo[s]}function oi(s){return Si(Cs(s))}function dl(s){return"u_var_"+s}function pd(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const Oo="getBandValue",Zm="u_paletteTextures",md="featureId",yd="geometryType",ga=-9999999;function Km(s,t,e,i){const n=Zt(s,t,e);return ul(n,t,i)}function mt(s){return(t,e,i)=>{const n=e.args.length,r=new Array(n);for(let o=0;o<n;++o)r[o]=ul(e.args[o],i,t);return s(r,t)}}const qm={[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 Ue(t.type,Gt)&&(r=`(${r} > 0.0)`),r},[v.Id]:s=>(s.featureId=!0,"a_"+md),[v.GeometryType]:s=>(s.geometryType=!0,"a_"+yd),[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=dl(i);return Ue(t.type,Gt)&&(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} != ${Si(ga)})`},[v.Resolution]:()=>"u_resolution",[v.Zoom]:()=>"u_zoom",[v.Time]:()=>"u_time",[v.Any]:mt(s=>`(${s.join(" || ")})`),[v.All]:mt(s=>`(${s.join(" && ")})`),[v.Not]:mt(([s])=>`(!${s})`),[v.Equal]:mt(([s,t])=>`(${s} == ${t})`),[v.NotEqual]:mt(([s,t])=>`(${s} != ${t})`),[v.GreaterThan]:mt(([s,t])=>`(${s} > ${t})`),[v.GreaterThanOrEqualTo]:mt(([s,t])=>`(${s} >= ${t})`),[v.LessThan]:mt(([s,t])=>`(${s} < ${t})`),[v.LessThanOrEqualTo]:mt(([s,t])=>`(${s} <= ${t})`),[v.Multiply]:mt(s=>`(${s.join(" * ")})`),[v.Divide]:mt(([s,t])=>`(${s} / ${t})`),[v.Add]:mt(s=>`(${s.join(" + ")})`),[v.Subtract]:mt(([s,t])=>`(${s} - ${t})`),[v.Clamp]:mt(([s,t,e])=>`clamp(${s}, ${t}, ${e})`),[v.Mod]:mt(([s,t])=>`mod(${s}, ${t})`),[v.Pow]:mt(([s,t])=>`pow(${s}, ${t})`),[v.Abs]:mt(([s])=>`abs(${s})`),[v.Floor]:mt(([s])=>`floor(${s})`),[v.Ceil]:mt(([s])=>`ceil(${s})`),[v.Round]:mt(([s])=>`floor(${s} + 0.5)`),[v.Sin]:mt(([s])=>`sin(${s})`),[v.Cos]:mt(([s])=>`cos(${s})`),[v.Atan]:mt(([s,t])=>t!==void 0?`atan(${s}, ${t})`:`atan(${s})`),[v.Sqrt]:mt(([s])=>`sqrt(${s})`),[v.Match]:mt(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]:mt(([s,t,e])=>`(${s} >= ${t} && ${s} <= ${e})`),[v.Interpolate]:mt(([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===Si(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]:mt(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]:mt(([s,...t],e)=>{const i=Xm("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) {
|
|
165
|
+
`;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||Pm),e.compileShader(i);const n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,t.fragmentShader||Im),e.compileShader(n),this.renderTargetProgram_=e.createProgram(),e.attachShader(this.renderTargetProgram_,i),e.attachShader(this.renderTargetProgram_,n),e.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=e.createBuffer();const r=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];e.bindBuffer(e.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW),this.renderTargetAttribLocation_=e.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],t.uniforms&&Object.keys(t.uniforms).forEach(o=>{this.uniforms_.push({value:t.uniforms[o],location:e.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(t){const e=this.getGL(),i=[e.drawingBufferWidth*this.scaleRatio_,e.drawingBufferHeight*this.scaleRatio_];if(e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer()),e.bindRenderbuffer(e.RENDERBUFFER,this.getDepthBuffer()),e.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;const n=0,r=e.RGBA,o=0,a=e.RGBA,l=e.UNSIGNED_BYTE,h=null;e.bindTexture(e.TEXTURE_2D,this.renderTargetTexture_),e.texImage2D(e.TEXTURE_2D,n,r,i[0],i[1],o,a,l,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.renderTargetTexture_,0),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i[0],i[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthBuffer_)}}apply(t,e,i,n){const r=this.getGL(),o=t.size;if(r.bindFramebuffer(r.FRAMEBUFFER,e?e.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!e){const l=K(r.canvas);if(!t.renderTargets[l]){const h=r.getContextAttributes();h&&h.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),t.renderTargets[l]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const a=t.layerStatesArray[t.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(t),i&&i(r,t),r.drawArrays(r.TRIANGLES,0,6),n&&n(r,t)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(t){const e=this.getGL();let i,n=1;this.uniforms_.forEach(function(r){if(i=typeof r.value=="function"?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof ImageData)r.texture||(r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${n}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i instanceof ImageData?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,i.width,i.height,0,e.UNSIGNED_BYTE,new Uint8Array(i.data)):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i),e.uniform1i(r.location,n++);else if(Array.isArray(i))switch(i.length){case 2:e.uniform2f(r.location,i[0],i[1]);return;case 3:e.uniform3f(r.location,i[0],i[1],i[2]);return;case 4:e.uniform4f(r.location,i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(r.location,i)})}}const Ae={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"},Jt={UNSIGNED_BYTE:Em,UNSIGNED_SHORT:vm,UNSIGNED_INT:Tm,FLOAT:fd},Dr={};function Ih(s){return"shared/"+s}let Lh=0;function Lm(){const s="unique/"+Lh;return Lh+=1,s}function Dm(s){let t=Dr[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:bm(e)},Dr[s]=t}return t.users+=1,t.context}function km(s){const t=Dr[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 Dr[s]}class Rm extends vs{constructor(t){super(),t=t||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=t.canvasCacheKey?Ih(t.canvasCacheKey):Lm(),this.gl_=Dm(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const e=this.gl_.canvas;e.addEventListener(or.LOST,this.boundHandleWebGLContextLost_),e.addEventListener(or.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Ut(),this.offsetScaleMatrix_=Ut(),this.tmpMat4_=ud(),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_===Ih(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 gt(!!t,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),t}bindBuffer(t){const e=this.gl_,i=K(t);let n=this.bufferCache_[i];if(!n){const r=e.createBuffer();n={buffer:t,webGlBuffer:r},this.bufferCache_[i]=n}e.bindBuffer(t.getType(),n.webGlBuffer)}flushBufferData(t){const e=this.gl_;this.bindBuffer(t),e.bufferData(t.getType(),t.getArray(),t.getUsage())}deleteBuffer(t){const e=K(t);delete this.bufferCache_[e]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(or.LOST,this.boundHandleWebGLContextLost_),t.removeEventListener(or.RESTORED,this.boundHandleWebGLContextRestored_),km(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(Ae.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(Ae.ZOOM,t.viewState.zoom),this.setUniformFloatValue(Ae.RESOLUTION,t.viewState.resolution),this.setUniformFloatValue(Ae.PIXEL_RATIO,n),this.setUniformFloatVec2(Ae.VIEWPORT_SIZE_PX,[e[0],e[1]]),this.setUniformFloatValue(Ae.ROTATION,i)}applyHitDetectionUniform(t){const e=this.getUniformLocation(Ae.HIT_DETECTION);this.getGL().uniform1i(e,t?1:0),t&&this.setUniformFloatValue(Ae.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,fa(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:e.uniform2f(this.getUniformLocation(r.name),i[0],i[1]);return;case 3:e.uniform3f(this.getUniformLocation(r.name),i[0],i[1],i[2]);return;case 4:e.uniform4f(this.getUniformLocation(r.name),i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(this.getUniformLocation(r.name),i)})}useProgram(t,e){this.disableAllAttributes_(),this.gl_.useProgram(t),this.currentProgram_=t,e&&(this.applyFrameState(e),this.applyUniforms(e))}compileShader(t,e){const i=this.gl_,n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}getProgram(t,e){const i=this.gl_,n=this.compileShader(t,i.FRAGMENT_SHADER),r=this.compileShader(e,i.VERTEX_SHADER),o=i.createProgram();if(i.attachShader(o,n),i.attachShader(o,r),i.linkProgram(o),!i.getShaderParameter(n,i.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${i.getShaderInfoLog(n)}`;throw new Error(a)}if(i.deleteShader(n),!i.getShaderParameter(r,i.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${i.getShaderInfoLog(r)}`;throw new Error(a)}if(i.deleteShader(r),!i.getProgramParameter(o,i.LINK_STATUS)){const a=`GL program linking failed: ${i.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(t){const e=K(this.currentProgram_);return this.uniformLocationsByProgram_[e]===void 0&&(this.uniformLocationsByProgram_[e]={}),this.uniformLocationsByProgram_[e][t]===void 0&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=K(this.currentProgram_);return this.attribLocationsByProgram_[e]===void 0&&(this.attribLocationsByProgram_[e]={}),this.attribLocationsByProgram_[e][t]===void 0&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const i=t.size,n=t.viewState.rotation,r=t.viewState.resolution,o=t.viewState.center;return Pe(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=Am(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||fd,i,n,e),n+=o.size*gd(o.type)}}enableAttributes(t){this.enableAttributes_(t,!1)}enableAttributesInstanced(t){this.enableAttributes_(t,!0)}handleWebGLContextLost(t){kn(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,d=r.UNSIGNED_BYTE;return e instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,d,e):e?r.texImage2D(r.TEXTURE_2D,a,l,c,d,e):r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,d,null),i}}function Am(s){let t=0;for(let e=0;e<s.length;e++){const i=s[e];t+=i.size*gd(i.type)}return t}function gd(s){switch(s){case Jt.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Jt.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Jt.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case Jt.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}class hl extends Or{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(nt.CHANGE)}release(){this.setState(X.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==X.EMPTY){if(this.state!==X.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){Q()}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:Qc(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 ga(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const Mm=new Error("disposed"),Fm=[256,256];class Dh extends hl{constructor(t){const e=X.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=ga(this.data_);return t?[t.width,t.height]:Fm}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==X.IDLE&&this.state!==X.ERROR)return;this.state=X.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=X.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=X.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Mm),this.controller_=null),super.disposeInternal()}}class pd extends hl{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_,Ee?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=X.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=X.ERROR,this.unlistenImage_(),this.image_=Om(),this.changed()}handleImageLoad_(){if(Ee)this.state=X.LOADED;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=X.LOADED:this.state=X.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==X.ERROR&&(this.state=X.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==X.IDLE&&(this.state=X.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=bf(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 Om(){const s=$t(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}let Ao;const Cn=[];function kh(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 zm(){if(Ao===void 0){const s=$t(6,6,Cn);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",kh(s,4,5,4,0),kh(s,4,5,0,5);const t=s.getImageData(0,0,3,3).data;Ao=Mo(t,0)||Mo(t,4)||Mo(t,8),jr(s),Cn.push(s.canvas)}return Ao}function Rh(s,t,e,i){const n=Wr(e,t,s);let r=Ul(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||Tn(l,n)){const h=Ul(s,r,n)/r;isFinite(h)&&h>0&&(r/=h)}return r}function $m(s,t,e,i){const n=be(e);let r=Rh(s,t,n,i);return(!isFinite(r)||r<=0)&&Ta(e,function(o){return r=Rh(s,t,o,i),isFinite(r)&&r>0}),r}function Nm(s,t,e,i,n,r,o,a,l,h,c,d,u,f){const g=$t(Math.round(e*s),Math.round(e*t),Cn);if(d||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function p(C){return Math.round(C*e)/e}g.globalCompositeOperation="lighter";const m=oe();l.forEach(function(C,v,_){ss(m,C.extent)});let y;const x=e/i,E=(d?1:1+Math.pow(2,-24))/x;y=$t(Math.round(Et(m)*x),Math.round(he(m)*x),Cn),d||(y.imageSmoothingEnabled=!1),l.forEach(function(C,v,_){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){y.save();const k=(C.clipExtent[0]-m[0])*x,F=-(C.clipExtent[3]-m[3])*x,O=Et(C.clipExtent)*x,R=he(C.clipExtent)*x;y.rect(d?k:Math.round(k),d?F:Math.round(F),d?O:Math.round(k+O)-Math.round(k),d?R:Math.round(F+R)-Math.round(F)),y.clip()}const b=(C.extent[0]-m[0])*x,S=-(C.extent[3]-m[3])*x,P=Et(C.extent)*x,L=he(C.extent)*x;y.drawImage(C.image,h,h,C.image.width-2*h,C.image.height-2*h,d?b:Math.round(b),d?S:Math.round(S),d?P:Math.round(b+P)-Math.round(b),d?L:Math.round(S+L)-Math.round(S)),C.clipExtent&&y.restore()}});const w=ji(o);return a.getTriangles().forEach(function(C,v,_){const b=C.source,S=C.target;let P=b[0][0],L=b[0][1],k=b[1][0],F=b[1][1],O=b[2][0],R=b[2][1];const B=p((S[0][0]-w[0])/r),D=p(-(S[0][1]-w[1])/r),z=p((S[1][0]-w[0])/r),N=p(-(S[1][1]-w[1])/r),tt=p((S[2][0]-w[0])/r),et=p(-(S[2][1]-w[1])/r),ht=P,ot=L;P=0,L=0,k-=ht,F-=ot,O-=ht,R-=ot;const I=[[k,F,0,0,z-B],[O,R,0,0,tt-B],[0,0,k,F,N-D],[0,0,O,R,et-D]],xt=cu(I);if(!xt)return;if(g.save(),g.beginPath(),zm()||!d){g.moveTo(z,N);const Ot=4,ie=B-z,Ne=D-N;for(let St=0;St<Ot;St++)g.lineTo(z+p((St+1)*ie/Ot),N+p(St*Ne/(Ot-1))),St!=Ot-1&&g.lineTo(z+p((St+1)*ie/Ot),N+p((St+1)*Ne/(Ot-1)));g.lineTo(tt,et)}else g.moveTo(z,N),g.lineTo(B,D),g.lineTo(tt,et);g.clip(),g.transform(xt[0],xt[2],xt[1],xt[3],B,D),g.translate(m[0]-ht,m[3]-ot);let yt;if(y)yt=y.canvas,g.scale(E,-E);else{const Ot=l[0],ie=Ot.extent;yt=Ot.image,g.scale(Et(ie)/yt.width,-he(ie)/yt.height)}g.drawImage(yt,0,0),g.restore()}),y&&(jr(y),Cn.push(y.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(C,v,_){const b=C.target,S=(b[0][0]-w[0])/r,P=-(b[0][1]-w[1])/r,L=(b[1][0]-w[0])/r,k=-(b[1][1]-w[1])/r,F=(b[2][0]-w[0])/r,O=-(b[2][1]-w[1])/r;g.beginPath(),g.moveTo(L,k),g.lineTo(S,P),g.lineTo(F,O),g.closePath(),g.stroke()}),g.restore()),g.canvas}const Gm=10,Ah=.25;class Bm{constructor(t,e,i,n,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?Nu(E=>zt(a,Wr(E,this.targetProj_,this.sourceProj_))):fs(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){const w=E[0]+"/"+E[1];return l[w]||(l[w]=h(E)),l[w]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&Et(n)>=Et(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Et(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Et(this.targetProj_.getExtent()):null;const c=ji(i),d=Nr(i),u=$r(i),f=zr(i),g=this.transformInv_(c),p=this.transformInv_(d),m=this.transformInv_(u),y=this.transformInv_(f),x=Gm+(o?Math.max(0,Math.ceil(Math.log2(Xo(i)/(o*o*256*256)))):0);if(this.addQuad_(c,d,u,f,g,p,m,y,x),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(w,C,v){E=Math.min(E,w.source[0][0],w.source[1][0],w.source[2][0])}),this.triangles_.forEach(w=>{if(Math.max(w.source[0][0],w.source[1][0],w.source[2][0])-E>this.sourceWorldWidth_/2){const C=[[w.source[0][0],w.source[0][1]],[w.source[1][0],w.source[1][1]],[w.source[2][0],w.source[2][1]]];C[0][0]-E>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-E>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-E>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);const v=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-v<this.sourceWorldWidth_/2&&(w.source=C)}})}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=yr([r,o,a,l]),d=this.sourceWorldWidth_?Et(c)/this.sourceWorldWidth_:null,u=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&d>.5&&d<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const m=yr([t,e,i,n]);g=Et(m)/this.targetWorldWidth_>Ah||g}!f&&this.sourceProj_.isGlobal()&&d&&(g=d>Ah||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!le(c,this.maxSourceExtent_))return;let p=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(p=(!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),p!=1&&p!=2&&p!=4&&p!=8)return}if(h>0){if(!g){const m=[(t[0]+i[0])/2,(t[1]+i[1])/2],y=this.transformInv_(m);let x;f?x=(Gi(r[0],u)+Gi(a[0],u))/2-Gi(y[0],u):x=(r[0]+a[0])/2-y[0];const E=(r[1]+a[1])/2-y[1];g=x*x+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const m=[(e[0]+i[0])/2,(e[1]+i[1])/2],y=this.transformInv_(m),x=[(n[0]+t[0])/2,(n[1]+t[1])/2],E=this.transformInv_(x);this.addQuad_(t,e,m,x,r,o,y,E,h-1),this.addQuad_(x,m,i,n,E,y,a,l,h-1)}else{const m=[(t[0]+e[0])/2,(t[1]+e[1])/2],y=this.transformInv_(m),x=[(i[0]+n[0])/2,(i[1]+n[1])/2],E=this.transformInv_(x);this.addQuad_(t,m,x,n,r,y,E,l,h-1),this.addQuad_(m,e,i,x,y,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(p&11)==0&&this.addTriangle_(t,i,n,r,a,l),(p&14)==0&&this.addTriangle_(t,i,e,r,a,o),p&&((p&13)==0&&this.addTriangle_(e,n,t,o,l,r),(p&7)==0&&this.addTriangle_(e,n,i,o,l,a))}calculateSourceExtent(){const t=oe();return this.triangles_.forEach(function(e,i,n){const r=e.source;rs(t,r[0]),rs(t,r[1]),rs(t,r[2])}),t}getTriangles(){return this.triangles_}}const Wm=.5;class md extends hl{constructor(t,e,i,n,r,o,a,l,h,c,d,u){super(r,X.IDLE,u),this.renderEdges_=d!==void 0?d:!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 p=this.sourceTileGrid_.getExtent();const m=g?Ni(f,g):f;if(Xo(m)===0){this.state=X.EMPTY;return}const y=t.getExtent();y&&(p?p=Ni(p,y):p=y);const x=n.getResolution(this.wrappedTileCoord_[0]),E=$m(t,i,m,x);if(!isFinite(E)||E<=0){this.state=X.EMPTY;return}const w=c!==void 0?c:Wm;if(this.triangulation_=new Bm(t,i,m,p,E*w,x),this.triangulation_.getTriangles().length===0){this.state=X.EMPTY;return}this.sourceZ_=e.getZForResolution(E);let C=this.triangulation_.calculateSourceExtent();if(p&&(t.canWrapX()?(C[1]=Pt(C[1],p[1],p[3]),C[3]=Pt(C[3],p[1],p[3])):C=Ni(C,p)),!Xo(C))this.state=X.EMPTY;else{let v=0,_=0;t.canWrapX()&&(v=Et(y),_=Math.floor((C[0]-y[0])/v)),jh(C.slice(),t,!0).forEach(S=>{const P=e.getTileRangeForExtentAndZ(S,this.sourceZ_);for(let L=P.minX;L<=P.maxX;L++)for(let k=P.minY;k<=P.maxY;k++){const F=_*v;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,L,k,a),offset:F})}++_}),this.sourceTiles_.length===0&&(this.state=X.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==X.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=X.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_=Nm(n,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=X.LOADED}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(this.state==X.IDLE){this.state=X.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==X.IDLE||i==X.LOADING){t++;const n=ft(e,nt.CHANGE,r=>{const o=e.getState();(o==X.LOADED||o==X.ERROR||o==X.EMPTY)&&(Tt(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()==X.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(Tt),this.sourcesListenerKeys_=null}release(){this.canvas_&&(jr(this.canvas_.getContext("2d")),Cn.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}}class cl{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 sn(s,t,e,i,n){return n!==void 0?(n.minX=s,n.maxX=t,n.minY=e,n.maxY=i,n):new cl(s,t,e,i)}class Mh{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 vs&&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 gt(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 gt(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){gt(!(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 kr(s,t,e,i){return i!==void 0?(i[0]=s,i[1]=t,i[2]=e,i):[s,t,e]}function Um(s,t,e){return s+"/"+t+"/"+e}function dr(s,t,e,i,n){return`${K(s)},${t},${Um(e,i,n)}`}function Vm(s){return Hm(s[0],s[1],s[2])}function Hm(s,t,e){return(t<<s)+e}function Xm(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 dl extends Wc{constructor(t,e){super(t),e=e||{},this.inversePixelTransform_=Ut(),this.postProcesses_=e.postProcesses,this.uniforms_=e.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},t.addChangeListener(wt.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(Yt.PRECOMPOSE)){const n=new hs(Yt.PRECOMPOSE,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Yt.POSTCOMPOSE)){const n=new hs(Yt.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 dl)){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 Rm({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(wt.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){Pe(this.inversePixelTransform_,0,0,i.pixelRatio,-i.pixelRatio,0,0,-i.size[1]);const r=new hs(t,this.inversePixelTransform_,i,e);n.dispatchEvent(r)}}preRender(t,e){this.dispatchRenderEvent_(Yt.PRERENDER,t,e)}postRender(t,e){this.dispatchRenderEvent_(Yt.POSTRENDER,t,e)}}const Fo={TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight"};class jm{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 Ym(s,t){return`operator_${s}_${Object.keys(t.functions).length}`}function Si(s){const t=s.toString();return t.includes(".")?t:t+".0"}function ul(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(Si).join(", ")})`}function ur(s){const t=Ie(s),e=t.length>3?t[3]:1;return ul([t[0]/255,t[1]/255,t[2]/255,e])}function Zm(s){const t=ce(s);return ul(t)}const Oo={};let Km=0;function Es(s){return s in Oo||(Oo[s]=Km++),Oo[s]}function oi(s){return Si(Es(s))}function fl(s){return"u_var_"+s}function yd(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const zo="getBandValue",qm="u_paletteTextures",_d="featureId",wd="geometryType",pa=-9999999;function Jm(s,t,e,i){const n=Zt(s,t,e);return gl(n,t,i)}function mt(s){return(t,e,i)=>{const n=e.args.length,r=new Array(n);for(let o=0;o<n;++o)r[o]=gl(e.args[o],i,t);return s(r,t)}}const Qm={[T.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 Ue(t.type,Gt)&&(r=`(${r} > 0.0)`),r},[T.Id]:s=>(s.featureId=!0,"a_"+_d),[T.GeometryType]:s=>(s.geometryType=!0,"a_"+wd),[T.LineMetric]:()=>"currentLineMetric",[T.Var]:(s,t)=>{const i=t.args[0].value;i in s.variables||(s.variables[i]={name:i,type:t.type});let r=fl(i);return Ue(t.type,Gt)&&(r=`(${r} > 0.0)`),r},[T.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} != ${Si(pa)})`},[T.Resolution]:()=>"u_resolution",[T.Zoom]:()=>"u_zoom",[T.Time]:()=>"u_time",[T.Any]:mt(s=>`(${s.join(" || ")})`),[T.All]:mt(s=>`(${s.join(" && ")})`),[T.Not]:mt(([s])=>`(!${s})`),[T.Equal]:mt(([s,t])=>`(${s} == ${t})`),[T.NotEqual]:mt(([s,t])=>`(${s} != ${t})`),[T.GreaterThan]:mt(([s,t])=>`(${s} > ${t})`),[T.GreaterThanOrEqualTo]:mt(([s,t])=>`(${s} >= ${t})`),[T.LessThan]:mt(([s,t])=>`(${s} < ${t})`),[T.LessThanOrEqualTo]:mt(([s,t])=>`(${s} <= ${t})`),[T.Multiply]:mt(s=>`(${s.join(" * ")})`),[T.Divide]:mt(([s,t])=>`(${s} / ${t})`),[T.Add]:mt(s=>`(${s.join(" + ")})`),[T.Subtract]:mt(([s,t])=>`(${s} - ${t})`),[T.Clamp]:mt(([s,t,e])=>`clamp(${s}, ${t}, ${e})`),[T.Mod]:mt(([s,t])=>`mod(${s}, ${t})`),[T.Pow]:mt(([s,t])=>`pow(${s}, ${t})`),[T.Abs]:mt(([s])=>`abs(${s})`),[T.Floor]:mt(([s])=>`floor(${s})`),[T.Ceil]:mt(([s])=>`ceil(${s})`),[T.Round]:mt(([s])=>`floor(${s} + 0.5)`),[T.Sin]:mt(([s])=>`sin(${s})`),[T.Cos]:mt(([s])=>`cos(${s})`),[T.Atan]:mt(([s,t])=>t!==void 0?`atan(${s}, ${t})`:`atan(${s})`),[T.Sqrt]:mt(([s])=>`sqrt(${s})`),[T.Match]:mt(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}),[T.Between]:mt(([s,t,e])=>`(${s} >= ${t} && ${s} <= ${e})`),[T.Interpolate]:mt(([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===Si(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}),[T.Case]:mt(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}),[T.In]:mt(([s,...t],e)=>{const i=Ym("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) {
|
|
165
166
|
${n.join(`
|
|
166
167
|
`)}
|
|
167
168
|
return false;
|
|
168
|
-
}`,`${i}(${s})`}),[
|
|
169
|
+
}`,`${i}(${s})`}),[T.Array]:mt(s=>`vec${s.length}(${s.join(", ")})`),[T.Color]:mt(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})`}),[T.Band]:mt(([s,t,e],i)=>{if(!(zo 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=`${Fo.TILE_TEXTURE_ARRAY}[${a}]`;n+=` if (band == ${o+1}.0) {
|
|
169
170
|
return texture2D(${h}, v_textureCoord + vec2(dx, dy))[${l}];
|
|
170
171
|
}
|
|
171
|
-
`}i.functions[
|
|
172
|
-
float dx = xOffset / ${
|
|
173
|
-
float dy = yOffset / ${
|
|
172
|
+
`}i.functions[zo]=`float getBandValue(float band, float xOffset, float yOffset) {
|
|
173
|
+
float dx = xOffset / ${Fo.TEXTURE_PIXEL_WIDTH};
|
|
174
|
+
float dy = yOffset / ${Fo.TEXTURE_PIXEL_HEIGHT};
|
|
174
175
|
${n}
|
|
175
|
-
}`}return`${
|
|
176
|
+
}`}return`${zo}(${s}, ${t??"0.0"}, ${e??"0.0"})`}),[T.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,d=Ie(c),u=h*4;r[u]=d[0],r[u+1]=d[1],r[u+2]=d[2],r[u+3]=d[3]*255}s.paletteTextures||(s.paletteTextures=[]);const o=`${qm}[${s.paletteTextures.length}]`,a=new jm(o,r);s.paletteTextures.push(a);const l=gl(e,$,s);return`texture2D(${o}, vec2((${l} + 0.5) / ${n}.0, 0.5))`}};function gl(s,t,e){if(s instanceof Xc){const i=Qm[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&$)>0)return Si(s.value);if((s.type&Gt)>0)return s.value.toString();if((s.type&Wt)>0)return oi(s.value.toString());if((s.type&Rt)>0)return ur(s.value);if((s.type&me)>0)return ul(s.value);if((s.type&Te)>0)return Zm(s.value);throw new Error(`Unexpected expression ${s.value} (expected type ${pn(t)})`)}function ty(){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 Fh=.985;function J(s,t,e,i){return Jm(t,e,i??ks(),s)}function ey(s){const t=Ie(s),e=t[0]*256,i=t[1],n=t[2]*256,r=Math.round(t[3]*255);return[e+i,n+r]}const iy=`vec4 unpackColor(vec2 packedColor) {
|
|
176
177
|
return vec4(
|
|
177
178
|
min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
|
|
178
179
|
min(mod(packedColor[0], 256.0) / 255.0, 1.0),
|
|
179
180
|
min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
|
|
180
181
|
min(mod(packedColor[1], 256.0) / 255.0, 1.0)
|
|
181
182
|
);
|
|
182
|
-
}`;function
|
|
183
|
+
}`;function pl(s){return s===Rt||s===Te?2:s===me?4:1}function ma(s){const t=pl(s);return t>1?`vec${t}`:"float"}function xd(s,t){for(const e in t.variables){const i=t.variables[e],n=fl(i.name);let r=ma(i.type);i.type===Rt&&(r="vec4"),s.addUniform(n,r)}for(const e in t.properties){const i=t.properties[e],n=ma(i.type),r=`a_prop_${i.name}`;i.type===Rt?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 Cd(s,t){const e={};for(const i in s.variables){const n=s.variables[i],r=fl(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===Rt){const a=[...Ie(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?Es(o):o}}return e}function Ed(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===Rt?ey([...Ie(o||"#eee")]):typeof o=="string"?Es(o):typeof o=="boolean"?o?1:0:o};t[`prop_${i.name}`]={size:pl(i.type),callback:n}}return t}function $o(s){return s-fr(s)}function fr(s){return Math.fround(s)}const ny=`
|
|
183
184
|
vec2 df_from(float value) {
|
|
184
185
|
return vec2(value, 0.);
|
|
185
186
|
}
|
|
@@ -327,9 +328,9 @@ vec2 worldToPx(vec2 worldPos) {
|
|
|
327
328
|
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
|
328
329
|
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
|
329
330
|
}
|
|
330
|
-
${
|
|
331
|
-
${
|
|
332
|
-
`,on=
|
|
331
|
+
${iy}
|
|
332
|
+
${ny}
|
|
333
|
+
`,on=ty();class vd{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${Si(on["circle-radius"])} + ${Si(on["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=ur(on["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_=Si(on["stroke-width"]),this.strokeColorExpression_=ur(on["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=oi("round"),this.strokeJoinExpression_=oi("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=ur(on["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_?`${rn}
|
|
333
334
|
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
|
|
334
335
|
`)}
|
|
335
336
|
attribute vec2 a_position;
|
|
@@ -490,7 +491,7 @@ void main(void) {
|
|
|
490
491
|
vec2 joinDirection;
|
|
491
492
|
vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
|
|
492
493
|
// if angle is too high, do not make a proper join
|
|
493
|
-
if (cos(angle) > ${
|
|
494
|
+
if (cos(angle) > ${Fh} || isCap(angle)) {
|
|
494
495
|
joinDirection = normalPx * normalDir - tangentPx * tangentDir;
|
|
495
496
|
} else {
|
|
496
497
|
joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);
|
|
@@ -573,7 +574,7 @@ float bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAn
|
|
|
573
574
|
}
|
|
574
575
|
|
|
575
576
|
float miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
|
576
|
-
if (cos(joinAngle) > ${
|
|
577
|
+
if (cos(joinAngle) > ${Fh}) { // avoid risking a division by zero
|
|
577
578
|
return bevelJoinField(point, start, end, width, joinAngle);
|
|
578
579
|
}
|
|
579
580
|
float miterLength = 1. / sin(joinAngle * 0.5);
|
|
@@ -739,9 +740,9 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
739
740
|
if (gl_FragColor.a < 0.1) { discard; };
|
|
740
741
|
gl_FragColor = v_hitColor;
|
|
741
742
|
}
|
|
742
|
-
}`:null}}class kr{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(t,e){for(let i=0;i<t.length;i++)this.addFeature(t[i],e)}addFeature(t,e){let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}clearFeatureEntryInPointBatch_(t){const e=K(t),i=this.pointBatch.entries[e];if(i)return this.pointBatch.geometriesCount-=i.flatCoordss.length,delete this.pointBatch.entries[e],i}clearFeatureEntryInLineStringBatch_(t){const e=K(t),i=this.lineStringBatch.entries[e];if(i)return this.lineStringBatch.verticesCount-=i.verticesCount,this.lineStringBatch.geometriesCount-=i.flatCoordss.length,delete this.lineStringBatch.entries[e],i}clearFeatureEntryInPolygonBatch_(t){const e=K(t),i=this.polygonBatch.entries[e];if(i)return this.polygonBatch.verticesCount-=i.verticesCount,this.polygonBatch.ringsCount-=i.ringsCount,this.polygonBatch.geometriesCount-=i.flatCoordss.length,delete this.polygonBatch.entries[e],i}addGeometry_(t,e){const i=t.getType();switch(i){case"GeometryCollection":{const n=t.getGeometriesArray();for(const r of n)this.addGeometry_(r,e);break}case"MultiPolygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEndss(),e,K(e),n.getStride());break}case"MultiLineString":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,K(e),n.getStride());break}case"MultiPoint":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,K(e),n.getStride());break}case"Polygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,K(e),n.getStride());break}case"Point":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,K(e),n.getStride());break}case"LineString":case"LinearRing":{const n=t,r=n.getStride();this.addCoordinates_(i,n.getFlatCoordinates(),null,e,K(e),r,n.getLayout?.());break}}}addCoordinates_(t,e,i,n,r,o,a){let l;switch(t){case"MultiPolygon":{const h=i;for(let c=0,d=h.length;c<d;c++){let u=h[c];const f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,p=u[u.length-1];u=g>0?u.map(m=>m-g):u,this.addCoordinates_("Polygon",e.slice(g,p),u,n,r,o,a)}break}case"MultiLineString":{const h=i;for(let c=0,d=h.length;c<d;c++){const u=c>0?h[c-1]:0;this.addCoordinates_("LineString",e.slice(u,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 ge){const u=xc(e,h);if(u.length>1){this.addCoordinates_("MultiPolygon",e,u,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,d=i.map((u,f,g)=>f>0?(u-g[f-1])/o:u/o);this.polygonBatch.verticesCount+=l,this.polygonBatch.ringsCount+=c,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(iy(e,o)),this.polygonBatch.entries[r].ringsVerticesCounts.push(d),this.polygonBatch.entries[r].verticesCount+=l,this.polygonBatch.entries[r].ringsCount+=c;for(let u=0,f=h.length;u<f;u++){const g=u>0?h[u-1]:0;this.addCoordinates_("LinearRing",e.slice(g,h[u]),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(ny(e,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(t,e){const i=this.uidToRef_.get(t),n=i||this.freeGlobalRef_.pop()||++this.globalCounter_;return e.ref=n,i||(this.refToFeature_.set(n,e.feature),this.uidToRef_.set(t,n)),e}removeRef_(t,e){if(!t)throw new Error("This feature has no ref: "+e);this.refToFeature_.delete(t),this.uidToRef_.delete(e),this.freeGlobalRef_.push(t)}changeFeature(t,e){if(!this.uidToRef_.get(K(t)))return;this.removeFeature(t);let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}removeFeature(t){let e=this.clearFeatureEntryInPointBatch_(t);e=this.clearFeatureEntryInPolygonBatch_(t)||e,e=this.clearFeatureEntryInLineStringBatch_(t)||e,e&&this.removeRef_(e.ref,K(e.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(t){return this.refToFeature_.get(t)}isEmpty(){return this.globalCounter_===0}filter(t){const e=new kr;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 kr:e}}function iy(s,t){return t===2?s:s.filter((e,i)=>i%t<2)}function ny(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 sy(){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 $o={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function ry(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 oy(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 gl(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===ga&&console.warn('The "has" operator might return false positives.'),l===void 0?l=ga: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 to(s){return Object.keys(s).reduce((t,e)=>t+(s[e].size||1),0)}function ay(s,t,e,i){const n=(2+to(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],zt(i,r),t[o++]=r[0],t[o++]=r[1],o+=gl(t,e,l,o)}return t}function ly(s,t,e,i){const n=3*s.verticesCount+(1+to(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,Ye(l.flatCoordss[h],0,r.length,3,i,r,3),o+=gl(t,e,l,o),t[o++]=r.length/3;for(let d=0,u=r.length;d<u;d+=3)t[o++]=r[d],t[o++]=r[d+1],t[o++]=r[d+2]}}return t}function hy(s,t,e,i){const n=2*s.verticesCount+(1+to(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,Ye(l.flatCoordss[h],0,r.length,2,i,r),o+=gl(t,e,l,o),t[o++]=l.ringsVerticesCounts[h].length;for(let d=0,u=l.ringsVerticesCounts[h].length;d<u;d++)t[o++]=l.ringsVerticesCounts[h][d];for(let d=0,u=r.length;d<u;d+=2)t[o++]=r[d],t[o++]=r[d+1]}}return t}function Rr(s){return(JSON.stringify(s).split("").reduce((e,i)=>(e<<5)-e+i.charCodeAt(0),0)>>>0).toString()}function pl(s,t,e,i){if(`${i}radius`in s&&i!=="icon-"){let n=J(e,s[`${i}radius`],$);if(`${i}radius2`in s){const r=J(e,s[`${i}radius2`],$);n=`max(${n}, ${r})`}`${i}stroke-width`in s&&(n=`(${n} + ${J(e,s[`${i}stroke-width`],$)} * 0.5)`),t.setSymbolSizeExpression(`vec2(${n} * 2. + 0.5)`)}if(`${i}scale`in s){const n=J(e,s[`${i}scale`],Te);t.setSymbolSizeExpression(`${t.getSymbolSizeExpression()} * ${n}`)}`${i}displacement`in s&&t.setSymbolOffsetExpression(J(e,s[`${i}displacement`],me)),`${i}rotation`in s&&t.setSymbolRotationExpression(J(e,s[`${i}rotation`],$)),`${i}rotate-with-view`in s&&t.setSymbolRotateWithView(!!s[`${i}rotate-with-view`])}function Ed(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 ml(s,t,e,i,n){const r=new Image;r.crossOrigin=s[`${i}cross-origin`]===void 0?"anonymous":s[`${i}cross-origin`],gt(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 yl(s,t,e,i,n){let r=J(e,s[`${t}offset`],Te);if(`${t}offset-origin`in s)switch(s[`${t}offset-origin`]){case"top-right":r=`vec2(${i}.x, 0.) + ${n} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${i}.y) + ${n} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${i} - ${n} - ${r}`;break}return r}function cy(s,t,e,i){i.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
|
|
743
|
+
}`:null}}class Rr{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(t,e){for(let i=0;i<t.length;i++)this.addFeature(t[i],e)}addFeature(t,e){let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}clearFeatureEntryInPointBatch_(t){const e=K(t),i=this.pointBatch.entries[e];if(i)return this.pointBatch.geometriesCount-=i.flatCoordss.length,delete this.pointBatch.entries[e],i}clearFeatureEntryInLineStringBatch_(t){const e=K(t),i=this.lineStringBatch.entries[e];if(i)return this.lineStringBatch.verticesCount-=i.verticesCount,this.lineStringBatch.geometriesCount-=i.flatCoordss.length,delete this.lineStringBatch.entries[e],i}clearFeatureEntryInPolygonBatch_(t){const e=K(t),i=this.polygonBatch.entries[e];if(i)return this.polygonBatch.verticesCount-=i.verticesCount,this.polygonBatch.ringsCount-=i.ringsCount,this.polygonBatch.geometriesCount-=i.flatCoordss.length,delete this.polygonBatch.entries[e],i}addGeometry_(t,e){const i=t.getType();switch(i){case"GeometryCollection":{const n=t.getGeometriesArray();for(const r of n)this.addGeometry_(r,e);break}case"MultiPolygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEndss(),e,K(e),n.getStride());break}case"MultiLineString":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,K(e),n.getStride());break}case"MultiPoint":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,K(e),n.getStride());break}case"Polygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,K(e),n.getStride());break}case"Point":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,K(e),n.getStride());break}case"LineString":case"LinearRing":{const n=t,r=n.getStride();this.addCoordinates_(i,n.getFlatCoordinates(),null,e,K(e),r,n.getLayout?.());break}}}addCoordinates_(t,e,i,n,r,o,a){let l;switch(t){case"MultiPolygon":{const h=i;for(let c=0,d=h.length;c<d;c++){let u=h[c];const f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,p=u[u.length-1];u=g>0?u.map(m=>m-g):u,this.addCoordinates_("Polygon",e.slice(g,p),u,n,r,o,a)}break}case"MultiLineString":{const h=i;for(let c=0,d=h.length;c<d;c++){const u=c>0?h[c-1]:0;this.addCoordinates_("LineString",e.slice(u,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 ge){const u=Ec(e,h);if(u.length>1){this.addCoordinates_("MultiPolygon",e,u,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,d=i.map((u,f,g)=>f>0?(u-g[f-1])/o:u/o);this.polygonBatch.verticesCount+=l,this.polygonBatch.ringsCount+=c,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(sy(e,o)),this.polygonBatch.entries[r].ringsVerticesCounts.push(d),this.polygonBatch.entries[r].verticesCount+=l,this.polygonBatch.entries[r].ringsCount+=c;for(let u=0,f=h.length;u<f;u++){const g=u>0?h[u-1]:0;this.addCoordinates_("LinearRing",e.slice(g,h[u]),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(ry(e,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(t,e){const i=this.uidToRef_.get(t),n=i||this.freeGlobalRef_.pop()||++this.globalCounter_;return e.ref=n,i||(this.refToFeature_.set(n,e.feature),this.uidToRef_.set(t,n)),e}removeRef_(t,e){if(!t)throw new Error("This feature has no ref: "+e);this.refToFeature_.delete(t),this.uidToRef_.delete(e),this.freeGlobalRef_.push(t)}changeFeature(t,e){if(!this.uidToRef_.get(K(t)))return;this.removeFeature(t);let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}removeFeature(t){let e=this.clearFeatureEntryInPointBatch_(t);e=this.clearFeatureEntryInPolygonBatch_(t)||e,e=this.clearFeatureEntryInLineStringBatch_(t)||e,e&&this.removeRef_(e.ref,K(e.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(t){return this.refToFeature_.get(t)}isEmpty(){return this.globalCounter_===0}filter(t){const e=new Rr;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 Rr:e}}function sy(s,t){return t===2?s:s.filter((e,i)=>i%t<2)}function ry(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 oy(){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 No={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function ay(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 ly(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 ml(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===pa&&console.warn('The "has" operator might return false positives.'),l===void 0?l=pa: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 eo(s){return Object.keys(s).reduce((t,e)=>t+(s[e].size||1),0)}function hy(s,t,e,i){const n=(2+eo(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],zt(i,r),t[o++]=r[0],t[o++]=r[1],o+=ml(t,e,l,o)}return t}function cy(s,t,e,i){const n=3*s.verticesCount+(1+eo(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,Ye(l.flatCoordss[h],0,r.length,3,i,r,3),o+=ml(t,e,l,o),t[o++]=r.length/3;for(let d=0,u=r.length;d<u;d+=3)t[o++]=r[d],t[o++]=r[d+1],t[o++]=r[d+2]}}return t}function dy(s,t,e,i){const n=2*s.verticesCount+(1+eo(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,Ye(l.flatCoordss[h],0,r.length,2,i,r),o+=ml(t,e,l,o),t[o++]=l.ringsVerticesCounts[h].length;for(let d=0,u=l.ringsVerticesCounts[h].length;d<u;d++)t[o++]=l.ringsVerticesCounts[h][d];for(let d=0,u=r.length;d<u;d+=2)t[o++]=r[d],t[o++]=r[d+1]}}return t}function Ar(s){return(JSON.stringify(s).split("").reduce((e,i)=>(e<<5)-e+i.charCodeAt(0),0)>>>0).toString()}function yl(s,t,e,i){if(`${i}radius`in s&&i!=="icon-"){let n=J(e,s[`${i}radius`],$);if(`${i}radius2`in s){const r=J(e,s[`${i}radius2`],$);n=`max(${n}, ${r})`}`${i}stroke-width`in s&&(n=`(${n} + ${J(e,s[`${i}stroke-width`],$)} * 0.5)`),t.setSymbolSizeExpression(`vec2(${n} * 2. + 0.5)`)}if(`${i}scale`in s){const n=J(e,s[`${i}scale`],Te);t.setSymbolSizeExpression(`${t.getSymbolSizeExpression()} * ${n}`)}`${i}displacement`in s&&t.setSymbolOffsetExpression(J(e,s[`${i}displacement`],me)),`${i}rotation`in s&&t.setSymbolRotationExpression(J(e,s[`${i}rotation`],$)),`${i}rotate-with-view`in s&&t.setSymbolRotateWithView(!!s[`${i}rotate-with-view`])}function Td(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 _l(s,t,e,i,n){const r=new Image;r.crossOrigin=s[`${i}cross-origin`]===void 0?"anonymous":s[`${i}cross-origin`],gt(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 wl(s,t,e,i,n){let r=J(e,s[`${t}offset`],Te);if(`${t}offset-origin`in s)switch(s[`${t}offset-origin`]){case"top-right":r=`vec2(${i}.x, 0.) + ${n} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${i}.y) + ${n} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${i} - ${n} - ${r}`;break}return r}function uy(s,t,e,i){i.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
|
|
743
744
|
return length(point) - radius;
|
|
744
|
-
}`,
|
|
745
|
+
}`,yl(s,t,i,"circle-");let n=null;"circle-opacity"in s&&(n=J(i,s["circle-opacity"],$));let r="coordsPx";"circle-scale"in s&&(r=`coordsPx / ${J(i,s["circle-scale"],Te)}`);let o=null;"circle-fill-color"in s&&(o=J(i,s["circle-fill-color"],Rt));let a=null;"circle-stroke-color"in s&&(a=J(i,s["circle-stroke-color"],Rt));let l=J(i,s["circle-radius"],$),h=null;"circle-stroke-width"in s&&(h=J(i,s["circle-stroke-width"],$),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,d=Td(c,o,a,h,n);t.setSymbolColorExpression(d)}function fy(s,t,e,i){i.functions.round=`float round(float v) {
|
|
745
746
|
return sign(v) * floor(abs(v) + 0.5);
|
|
746
747
|
}`,i.functions.starDistanceField=`float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {
|
|
747
748
|
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
|
@@ -770,7 +771,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
770
771
|
s = sin(-gamma);
|
|
771
772
|
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
|
772
773
|
return inSector.x - radiusIn;
|
|
773
|
-
}`,
|
|
774
|
+
}`,yl(s,t,i,"shape-");let n=null;"shape-opacity"in s&&(n=J(i,s["shape-opacity"],$));let r="coordsPx";"shape-scale"in s&&(r=`coordsPx / ${J(i,s["shape-scale"],Te)}`);let o=null;"shape-fill-color"in s&&(o=J(i,s["shape-fill-color"],Rt));let a=null;"shape-stroke-color"in s&&(a=J(i,s["shape-stroke-color"],Rt));let l=null;"shape-stroke-width"in s&&(l=J(i,s["shape-stroke-width"],$));const h=J(i,s["shape-points"],$);let c="0.";"shape-angle"in s&&(c=J(i,s["shape-angle"],$));let d,u=J(i,s["shape-radius"],$);if(l!==null&&(u=`${u} + ${l} * 0.5`),"shape-radius2"in s){let g=J(i,s["shape-radius2"],$);l!==null&&(g=`${g} + ${l} * 0.5`),d=`starDistanceField(${r}, ${h}, ${u}, ${g}, ${c})`}else d=`regularDistanceField(${r}, ${h}, ${u}, ${c})`;const f=Td(d,o,a,l,n);t.setSymbolColorExpression(f)}function gy(s,t,e,i){let n="vec4(1.0)";"icon-color"in s&&(n=J(i,s["icon-color"],Rt)),"icon-opacity"in s&&(n=`${n} * vec4(1.0, 1.0, 1.0, ${J(i,s["icon-opacity"],$)})`);const r=Ar(s["icon-src"]),o=_l(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(${J(i,s["icon-width"],$)}, ${J(i,s["icon-height"],$)})`),"icon-offset"in s&&"icon-size"in s){const a=J(i,s["icon-size"],me),l=t.getSymbolSizeExpression();t.setSymbolSizeExpression(a);const h=wl(s,"icon-",i,"v_quadSizePx",a);t.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(yl(s,t,i,"icon-"),"icon-anchor"in s){const a=J(i,s["icon-anchor"],me);let l="1.0";"icon-scale"in s&&(l=J(i,s["icon-scale"],Te));let h;s["icon-anchor-x-units"]==="pixels"&&s["icon-anchor-y-units"]==="pixels"?h=`${a} * ${l}`:s["icon-anchor-x-units"]==="pixels"?h=`${a} * vec2(vec2(${l}).x, v_quadSizePx.y)`:s["icon-anchor-y-units"]==="pixels"?h=`${a} * vec2(v_quadSizePx.x, vec2(${l}).x)`:h=`${a} * v_quadSizePx`;let c=`v_quadSizePx * vec2(0.5, -0.5) + ${h} * vec2(-1., 1.)`;if("icon-anchor-origin"in s)switch(s["icon-anchor-origin"]){case"top-right":c=`v_quadSizePx * -0.5 + ${h}`;break;case"bottom-left":c=`v_quadSizePx * 0.5 - ${h}`;break;case"bottom-right":c=`v_quadSizePx * vec2(-0.5, 0.5) + ${h} * vec2(1., -1.)`;break}t.setSymbolOffsetExpression(`${t.getSymbolOffsetExpression()} + ${c}`)}}function py(s,t,e,i){if("stroke-color"in s&&t.setStrokeColorExpression(J(i,s["stroke-color"],Rt)),"stroke-pattern-src"in s){const n=Ar(s["stroke-pattern-src"]),r=_l(s,t,e,"stroke-pattern-",n);let o=r,a="vec2(0.)";"stroke-pattern-offset"in s&&"stroke-pattern-size"in s&&(o=J(i,s["stroke-pattern-size"],me),a=wl(s,"stroke-pattern-",i,r,o));let l="0.";"stroke-pattern-spacing"in s&&(l=J(i,s["stroke-pattern-spacing"],$));let h="0.";"stroke-pattern-start-offset"in s&&(h=J(i,s["stroke-pattern-start-offset"],$)),i.functions.sampleStrokePattern=`vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {
|
|
774
775
|
float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;
|
|
775
776
|
float spacingScaled = spacingPx * sampleSize.y / lineWidth;
|
|
776
777
|
float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));
|
|
@@ -794,12 +795,12 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
794
795
|
distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
|
|
795
796
|
}
|
|
796
797
|
return distanceSegment;
|
|
797
|
-
}`;let n=s["stroke-line-dash"].map(g=>J(i,g,$));n.length%2===1&&(n=[...n,...n]);let r="0.";"stroke-line-dash-offset"in s&&(r=J(i,s["stroke-line-dash-offset"],$));const a=`dashDistanceField_${
|
|
798
|
+
}`;let n=s["stroke-line-dash"].map(g=>J(i,g,$));n.length%2===1&&(n=[...n,...n]);let r="0.";"stroke-line-dash-offset"in s&&(r=J(i,s["stroke-line-dash-offset"],$));const a=`dashDistanceField_${Ar(s["stroke-line-dash"])}`,l=n.map((g,p)=>`float dashLength${p}`).join(", "),h=n.map((g,p)=>`dashLength${p}`).join(" + ");let c="0.",d=`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}`,d=`min(${d}, getSingleDashDistance(distance, radius, ${c}, dashLength${g}, totalDashLength, capType, lineWidth))`;i.functions[a]=`float ${a}(float distance, float radius, float capType, float lineWidth, ${l}) {
|
|
798
799
|
float totalDashLength = ${h};
|
|
799
800
|
return ${d};
|
|
800
801
|
}`;const u=n.map((g,p)=>`${g}`).join(", ");t.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${u})`);let f=n.join(" + ");t.getStrokePatternLengthExpression()&&(i.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) {
|
|
801
802
|
return patternLength1 * patternLength2;
|
|
802
|
-
}`,f=`combinePatternLengths(${t.getStrokePatternLengthExpression()}, ${f})`),t.setStrokePatternLengthExpression(f)}}function
|
|
803
|
+
}`,f=`combinePatternLengths(${t.getStrokePatternLengthExpression()}, ${f})`),t.setStrokePatternLengthExpression(f)}}function my(s,t,e,i){if("fill-color"in s&&t.setFillColorExpression(J(i,s["fill-color"],Rt)),"fill-pattern-src"in s){const n=Ar(s["fill-pattern-src"]),r=_l(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=J(i,s["fill-pattern-size"],me);t.setFillPatternSizeExpression(h),o=wl(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) {
|
|
803
804
|
vec2 pxRelativePos = pxPosition - patternOriginPx;
|
|
804
805
|
|
|
805
806
|
// rotate the relative position from origin by the current view rotation
|
|
@@ -810,7 +811,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
810
811
|
samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));
|
|
811
812
|
samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright
|
|
812
813
|
return texture2D(texture, (samplePos + textureOffset) / textureSize);
|
|
813
|
-
}`;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 Mh(s,t,e){const i=pd(),n=new Cd,r={};if("icon-src"in s?uy(s,n,r,i):"shape-points"in s?dy(s,n,r,i):"circle-radius"in s&&cy(s,n,r,i),fy(s,n,r,i),gy(s,n,r,i),e){const l=Ds(),h=J(i,e,Gt,l);l.mCoordinate?n.setFragmentDiscardExpression(`!${h}`):n.setShapeDiscardExpression(`!${h}`)}const o={};function a(l,h,c,d){if(!i[l])return;const u=pa(c),f=fl(c);n.addAttribute(`a_${h}`,u),o[h]={size:f,callback:d}}return a("geometryType",yd,Wt,l=>Cs(Ya(l.getGeometry()))),a("featureId",md,Wt|$,l=>{const h=l.getId()??null;return typeof h=="string"?Cs(h):h}),_d(n,i),{builder:n,attributes:{...o,...xd(i)},uniforms:{...r,...wd(i,t)}}}const py=[];let No;function my(){return No||(No=sy()),No}let yy=0;const Ce={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 _y{constructor(t,e,i,n){this.helper_,this.hitDetectionEnabled_=!!n,this.styleShaders=wy(t,e),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return ry(this.ref,py)},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:Jt.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:Ce.POSITION,size:2,type:Jt.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:Ce.LOCAL_POSITION,size:2,type:Jt.FLOAT}],instancedAttributesDesc:[{name:Ce.SEGMENT_START,size:2,type:Jt.FLOAT},{name:Ce.MEASURE_START,size:1,type:Jt.FLOAT},{name:Ce.SEGMENT_END,size:2,type:Jt.FLOAT},{name:Ce.MEASURE_END,size:1,type:Jt.FLOAT},{name:Ce.JOIN_ANGLES,size:2,type:Jt.FLOAT},{name:Ce.DISTANCE_LOW,size:1,type:Jt.FLOAT},{name:Ce.DISTANCE_HIGH,size:1,type:Jt.FLOAT},{name:Ce.ANGLE_TANGENT_SUM,size:1,type:Jt.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:Ce.LOCAL_POSITION,size:2,type:Jt.FLOAT}],instancedAttributesDesc:[{name:Ce.POSITION,size:2,type:Jt.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=Wr(Ut(),e);return{polygonBuffers:n,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(t,e){const i=this.hasFill_?hy(t.polygonBatch,new Float32Array(0),this.customAttributes_,e):null,n=this.hasStroke_?ly(t.lineStringBatch,new Float32Array(0),this.customAttributes_,e):null,r=this.hasSymbol_?ay(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=yy++;let r;switch(e){case"Polygon":r=$o.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=$o.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=$o.GENERATE_POINT_BUFFERS;break}const o={id:n,type:r,renderInstructions:t.buffer,renderInstructionsTransform:i,customAttributesSize:to(this.customAttributes_)},a=my();return a.postMessage(o,[t.buffer]),t=null,new Promise(l=>{const h=c=>{const d=c.data;if(d.id!==n||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const u=new ko(ol,Do).fromArrayBuffer(d.indicesBuffer),f=new ko(Ir,Do).fromArrayBuffer(d.vertexAttributesBuffer),g=new ko(Ir,Do).fromArrayBuffer(d.instanceAttributesBuffer);this.helper_.flushBufferData(u),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([u,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((d,u)=>d+(u.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 wy(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=>Mh(c,t,l));i.push(...h)}return i}return"builder"in e[0]?e:e.map(i=>Mh(i,t,null))}const Be=new Uint8Array(4);class xy{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){ui(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 Be[0]=0,Be[1]=0,Be[2]=0,Be[3]=0,Be;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return Be[0]=this.data_[i*4],Be[1]=this.data_[i*4+1],Be[2]=this.data_[i*4+2],Be[3]=this.data_[i*4+3],Be}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 fr={PATTERN_ORIGIN_X_DOUBLE:"u_df_patternOriginX",PATTERN_ORIGIN_Y_DOUBLE:"u_df_patternOriginY",PATTERN_SCALE_RATIO_DOUBLE:"u_df_patternScaleRatio",ONE:"u_one"},We=[0,0],an=[0,0],wi=Ut(),Fh=cd();function Cy(s,t,e,i){lc(wi,t),ac(wi,e),s.setUniformMatrixValue(Ae.PROJECTION_MATRIX,ua(Fh,wi)),Wr(wi,wi),s.setUniformMatrixValue(Ae.INVERT_PROJECTION_MATRIX,ua(Fh,wi)),We[0]=0,We[1]=0;const n=i.size,r=i.viewState.resolution,o=i.viewState.center;Pe(wi,n[0]/2,n[1]/2,1/r,1/r,0,-o[0],-o[1]),zt(wi,We),an[0]=ur(We[0]),an[1]=zo(We[0]),s.setUniformFloatVec2(fr.PATTERN_ORIGIN_X_DOUBLE,an),an[0]=ur(We[1]),an[1]=zo(We[1]),s.setUniformFloatVec2(fr.PATTERN_ORIGIN_Y_DOUBLE,an);const a=Math.pow(2,(i.viewState.zoom+.5)%1-.5);We[0]=ur(a),We[1]=zo(a),s.setUniformFloatVec2(fr.PATTERN_SCALE_RATIO_DOUBLE,We)}function Ey(s,t){const e=s.viewState.projection,n=t.getSource().getWrapX()&&e.canWrapX(),r=e.getExtent(),o=s.extent,a=n?Et(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 Go={...Ae,...fr,RENDER_EXTENT:"u_renderExtent",GLOBAL_ALPHA:"u_globalAlpha"};class vy extends hl{constructor(t,e){const i={[Go.RENDER_EXTENT]:[0,0,0,0],[Go.GLOBAL_ALPHA]:1,[Go.ONE]:1};super(t,{uniforms:i,postProcesses:e.postProcesses}),this.hitDetectionEnabled_=!e.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=oe(),this.currentTransform_=Ut(),this.currentFrameStateTransform_=Ut(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(e),this.batch_=new kr,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(t){const e=this.getLayer().getSource();let i;this.batch_.addFeatures(e.getFeatures(),i),this.sourceListenKeys_=[ft(e,re.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,i)),ft(e,re.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,i),this),ft(e,re.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),ft(e,re.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styleVariables_=t.variables,this.style_=t.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new _y(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 xy(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){Cy(this.helper,this.currentFrameStateTransform_,t,e)}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=Ey(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[jt.ANIMATING]&&!t.viewHints[jt.INTERACTING],o=!bn(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 Qr?e.getRenderBuffer():0,d=An(t.extent,c*h);i.loadFeatures(d,h,l),this.ready=!1;const u=this.helper.makeProjectionTransform(t,Ut());this.styleRenderer_.generateBuffers(this.batch_,u).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_),Bu(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(gt(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=zt(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=oy(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){Tt(t)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const ni={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},Ty=["#00f","#0ff","#0f0","#ff0","#f00"];class by extends Qr{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(ni.GRADIENT,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:Ty),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(ni.BLUR)}getGradient(){return this.get(ni.GRADIENT)}getRadius(){return this.get(ni.RADIUS)}handleGradientChanged_(){this.gradient_=Sy(this.getGradient())}setBlur(t){const e=this.get(ni.BLUR);if(this.set(ni.BLUR,t),typeof t=="number"&&typeof e=="number"){this.changed();return}this.clearRenderer()}setGradient(t){this.set(ni.GRADIENT,t)}setRadius(t){const e=this.get(ni.RADIUS);if(this.set(ni.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 Cd,e=pd(),i=Ds(),n=J(e,this.filter_,Gt,i);let r=J(e,this.getRadius(),$),o=J(e,this.getBlur(),$);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 p=f(g);return p!==void 0?Pt(p,0,1):1}},h="a_prop_weight",t.addAttribute("a_prop_weight","float")}else{const f=["clamp",this.weight_,0,1];h=J(e,f,$)}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}`),_d(t,e);const d=xd(e),u=wd(e,this.styleVariables_);return new vy(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:t,attributes:{...d,...l},uniforms:{...u,...a}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
|
|
814
|
+
}`;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 Oh(s,t,e){const i=yd(),n=new vd,r={};if("icon-src"in s?gy(s,n,r,i):"shape-points"in s?fy(s,n,r,i):"circle-radius"in s&&uy(s,n,r,i),py(s,n,r,i),my(s,n,r,i),e){const l=ks(),h=J(i,e,Gt,l);l.mCoordinate?n.setFragmentDiscardExpression(`!${h}`):n.setShapeDiscardExpression(`!${h}`)}const o={};function a(l,h,c,d){if(!i[l])return;const u=ma(c),f=pl(c);n.addAttribute(`a_${h}`,u),o[h]={size:f,callback:d}}return a("geometryType",wd,Wt,l=>Es(Ka(l.getGeometry()))),a("featureId",_d,Wt|$,l=>{const h=l.getId()??null;return typeof h=="string"?Es(h):h}),xd(n,i),{builder:n,attributes:{...o,...Ed(i)},uniforms:{...r,...Cd(i,t)}}}const yy=[];let Go;function _y(){return Go||(Go=oy()),Go}let wy=0;const Ce={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 xy{constructor(t,e,i,n){this.helper_,this.hitDetectionEnabled_=!!n,this.styleShaders=Cy(t,e),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return ay(this.ref,yy)},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:Jt.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:Ce.POSITION,size:2,type:Jt.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:Ce.LOCAL_POSITION,size:2,type:Jt.FLOAT}],instancedAttributesDesc:[{name:Ce.SEGMENT_START,size:2,type:Jt.FLOAT},{name:Ce.MEASURE_START,size:1,type:Jt.FLOAT},{name:Ce.SEGMENT_END,size:2,type:Jt.FLOAT},{name:Ce.MEASURE_END,size:1,type:Jt.FLOAT},{name:Ce.JOIN_ANGLES,size:2,type:Jt.FLOAT},{name:Ce.DISTANCE_LOW,size:1,type:Jt.FLOAT},{name:Ce.DISTANCE_HIGH,size:1,type:Jt.FLOAT},{name:Ce.ANGLE_TANGENT_SUM,size:1,type:Jt.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:Ce.LOCAL_POSITION,size:2,type:Jt.FLOAT}],instancedAttributesDesc:[{name:Ce.POSITION,size:2,type:Jt.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=Ur(Ut(),e);return{polygonBuffers:n,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(t,e){const i=this.hasFill_?dy(t.polygonBatch,new Float32Array(0),this.customAttributes_,e):null,n=this.hasStroke_?cy(t.lineStringBatch,new Float32Array(0),this.customAttributes_,e):null,r=this.hasSymbol_?hy(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=wy++;let r;switch(e){case"Polygon":r=No.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=No.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=No.GENERATE_POINT_BUFFERS;break}const o={id:n,type:r,renderInstructions:t.buffer,renderInstructionsTransform:i,customAttributesSize:eo(this.customAttributes_)},a=_y();return a.postMessage(o,[t.buffer]),t=null,new Promise(l=>{const h=c=>{const d=c.data;if(d.id!==n||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const u=new Ro(ll,ko).fromArrayBuffer(d.indicesBuffer),f=new Ro(Lr,ko).fromArrayBuffer(d.vertexAttributesBuffer),g=new Ro(Lr,ko).fromArrayBuffer(d.instanceAttributesBuffer);this.helper_.flushBufferData(u),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([u,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((d,u)=>d+(u.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 Cy(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=>Oh(c,t,l));i.push(...h)}return i}return"builder"in e[0]?e:e.map(i=>Oh(i,t,null))}const Be=new Uint8Array(4);class Ey{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){ui(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 Be[0]=0,Be[1]=0,Be[2]=0,Be[3]=0,Be;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return Be[0]=this.data_[i*4],Be[1]=this.data_[i*4+1],Be[2]=this.data_[i*4+2],Be[3]=this.data_[i*4+3],Be}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 gr={PATTERN_ORIGIN_X_DOUBLE:"u_df_patternOriginX",PATTERN_ORIGIN_Y_DOUBLE:"u_df_patternOriginY",PATTERN_SCALE_RATIO_DOUBLE:"u_df_patternScaleRatio",ONE:"u_one"},We=[0,0],an=[0,0],wi=Ut(),zh=ud();function vy(s,t,e,i){cc(wi,t),hc(wi,e),s.setUniformMatrixValue(Ae.PROJECTION_MATRIX,fa(zh,wi)),Ur(wi,wi),s.setUniformMatrixValue(Ae.INVERT_PROJECTION_MATRIX,fa(zh,wi)),We[0]=0,We[1]=0;const n=i.size,r=i.viewState.resolution,o=i.viewState.center;Pe(wi,n[0]/2,n[1]/2,1/r,1/r,0,-o[0],-o[1]),zt(wi,We),an[0]=fr(We[0]),an[1]=$o(We[0]),s.setUniformFloatVec2(gr.PATTERN_ORIGIN_X_DOUBLE,an),an[0]=fr(We[1]),an[1]=$o(We[1]),s.setUniformFloatVec2(gr.PATTERN_ORIGIN_Y_DOUBLE,an);const a=Math.pow(2,(i.viewState.zoom+.5)%1-.5);We[0]=fr(a),We[1]=$o(a),s.setUniformFloatVec2(gr.PATTERN_SCALE_RATIO_DOUBLE,We)}function Ty(s,t){const e=s.viewState.projection,n=t.getSource().getWrapX()&&e.canWrapX(),r=e.getExtent(),o=s.extent,a=n?Et(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 Bo={...Ae,...gr,RENDER_EXTENT:"u_renderExtent",GLOBAL_ALPHA:"u_globalAlpha"};class by extends dl{constructor(t,e){const i={[Bo.RENDER_EXTENT]:[0,0,0,0],[Bo.GLOBAL_ALPHA]:1,[Bo.ONE]:1};super(t,{uniforms:i,postProcesses:e.postProcesses}),this.hitDetectionEnabled_=!e.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=oe(),this.currentTransform_=Ut(),this.currentFrameStateTransform_=Ut(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(e),this.batch_=new Rr,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(t){const e=this.getLayer().getSource();let i;this.batch_.addFeatures(e.getFeatures(),i),this.sourceListenKeys_=[ft(e,re.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,i)),ft(e,re.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,i),this),ft(e,re.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),ft(e,re.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styleVariables_=t.variables,this.style_=t.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new xy(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 Ey(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){vy(this.helper,this.currentFrameStateTransform_,t,e)}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=Ty(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[jt.ANIMATING]&&!t.viewHints[jt.INTERACTING],o=!bn(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 to?e.getRenderBuffer():0,d=An(t.extent,c*h);i.loadFeatures(d,h,l),this.ready=!1;const u=this.helper.makeProjectionTransform(t,Ut());this.styleRenderer_.generateBuffers(this.batch_,u).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_),Uu(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(gt(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=zt(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=ly(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){Tt(t)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const ni={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},Sy=["#00f","#0ff","#0f0","#ff0","#f00"];class Py extends to{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(ni.GRADIENT,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:Sy),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(ni.BLUR)}getGradient(){return this.get(ni.GRADIENT)}getRadius(){return this.get(ni.RADIUS)}handleGradientChanged_(){this.gradient_=Iy(this.getGradient())}setBlur(t){const e=this.get(ni.BLUR);if(this.set(ni.BLUR,t),typeof t=="number"&&typeof e=="number"){this.changed();return}this.clearRenderer()}setGradient(t){this.set(ni.GRADIENT,t)}setRadius(t){const e=this.get(ni.RADIUS);if(this.set(ni.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 vd,e=yd(),i=ks(),n=J(e,this.filter_,Gt,i);let r=J(e,this.getRadius(),$),o=J(e,this.getBlur(),$);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 p=f(g);return p!==void 0?Pt(p,0,1):1}},h="a_prop_weight",t.addAttribute("a_prop_weight","float")}else{const f=["clamp",this.weight_,0,1];h=J(e,f,$)}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}`),xd(t,e);const d=Ed(e),u=Cd(e,this.styleVariables_);return new by(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:t,attributes:{...d,...l},uniforms:{...u,...a}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
|
|
814
815
|
precision mediump float;
|
|
815
816
|
|
|
816
817
|
uniform sampler2D u_image;
|
|
@@ -824,7 +825,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
824
825
|
gl_FragColor.a = color.a * u_opacity;
|
|
825
826
|
gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;
|
|
826
827
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
827
|
-
}`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}renderDeclutter(){}}function Sy(s){const i=$t(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 gr extends It{constructor(t,e,i){super(t,e,Z.HEATMAP,{...i,zIndex:i?.zIndex??20}),this.heatmapLayer=null,this.data=[],this.source=new Y,this.heatmapLayer=new by({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 V({geometry:new rt(ut([e.longitude,e.latitude])),weight:e.value||1,id:e.id,longitude:e.longitude,latitude:e.latitude});this.source?.addFeature(i)})}updateData(t){this.setData(t)}getLayer(){return this.heatmapLayer}getData(){return this.data}}class Py extends Y{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 gt(!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(nt.CHANGE,this.boundRefresh_),this.source=t,t&&t.addEventListener(nt.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=oe(),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(!(K(a)in n)){const l=this.geometryFunction(a);if(l){const h=l.getCoordinates();xa(h,t),An(t,e,t);const c=this.source.getFeaturesInExtent(t).filter(function(d){const u=K(d);return u in n?!1:(n[u]=!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?jh(i,l.getCoordinates()):t.splice(a,1)}Yh(i,1/t.length);const n=be(e),r=this.interpolationRatio,o=new rt([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(o,t):new V({geometry:o,features:t})}}class vd extends It{constructor(t,e,i){super(t,e,Z.CLUSTER,{...i,zIndex:i?.zIndex??15}),this.clusterSource=null,this.clusterLayer=null,this.source=new Y,this.clusterSource=new Py({distance:i?.distance||60,source:this.source}),this.clusterLayer=new bt({source:this.clusterSource,style:n=>this.createStyle(n),properties:{id:t,name:e,type:Z.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 A({image:new Le({radius:a,fill:new j({color:M(o)}),stroke:new G({color:"#fff",width:2})}),text:new te({text:i.toString(),fill:new j({color:"#fff"}),font:"bold 14px sans-serif"})})}return new A({image:new Le({radius:8,fill:new j({color:M(r)}),stroke:new G({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 V({geometry:new rt(ut([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()}getData(){const t=[];return this.source?.forEachFeature(e=>{const i=e.getProperties();t.push({id:i.id,longitude:i.geometry?.getCoordinates()[0],latitude:i.geometry?.getCoordinates()[1],title:i.title,popupContent:i.popupContent})}),t}}class Iy{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=V,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?Ft(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=Ft(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 Q()}readFeature(t,e){return Q()}readFeatures(t,e){return Q()}readGeometry(t,e){return Q()}readProjection(t){return Q()}writeFeature(t,e){return Q()}writeFeatures(t,e){return Q()}writeGeometry(t,e){return Q()}}function _l(s,t,e){const i=e?Ft(e.featureProjection):null,n=e?Ft(e.dataProjection):null;let r=s;if(i&&n&&!os(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(us(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 Ly={Point:rt,LineString:pt,Polygon:it,MultiPoint:Rs,MultiLineString:Ln,MultiPolygon:Dn};function Dy(s,t,e){return Array.isArray(t[0])?(wc(s,0,t,e)||(s=s.slice(),ia(s,0,t,e)),s):(Wa(s,0,t,e)||(s=s.slice(),Er(s,0,t,e)),s)}function Td(s,t){const e=s.geometry;if(!e)return[];if(Array.isArray(e))return e.map(r=>Td({...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 _l(new ge(i,i==="Polygon"?Dy(e.flatCoordinates,e.ends,n):e.flatCoordinates,e.ends?.flat(),n,s.properties||{},s.id).enableSimplifyTransformed(),!1,t)}function wl(s,t){if(!s)return null;if(Array.isArray(s)){const i=s.map(n=>wl(n,t));return new xs(i)}const e=Ly[s.type];return _l(new e(s.flatCoordinates,s.layout||"XY",s.ends),!1,t)}class ky extends Iy{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(or(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(or(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return Q()}readFeaturesFromObject(t,e){return Q()}readGeometry(t,e){return this.readGeometryFromObject(or(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return Q()}readProjection(t){return this.readProjectionFromObject(or(t))}readProjectionFromObject(t){return Q()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return Q()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return Q()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return Q()}}function or(s){if(typeof s=="string"){const t=JSON.parse(s);return t||null}return s!==null?s:null}class Ry extends ky{constructor(t){t=t||{},super(),this.dataProjection=Ft(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Ft(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=xl(i.geometry);if(this.featureClass===ge)return Td({geometry:n,id:i.id,properties:i.properties},e);const r=new V;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(wl(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 Ay(t,e)}readProjectionFromObject(t){const e=t.crs;let i;if(e)if(e.type=="name")i=Ft(e.properties.name);else if(e.type==="EPSG")i=Ft("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=ma(o,e),delete r[t.getGeometryName()]),Wi(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 ma(t,this.adaptOptions(e))}}function xl(s,t){if(!s)return null;let e;switch(s.type){case"Point":{e=Fy(s);break}case"LineString":{e=Oy(s);break}case"Polygon":{e=Gy(s);break}case"MultiPoint":{e=$y(s);break}case"MultiLineString":{e=zy(s);break}case"MultiPolygon":{e=Ny(s);break}case"GeometryCollection":{e=My(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return e}function Ay(s,t){const e=xl(s);return wl(e,t)}function My(s,t){return s.geometries.map(function(i){return xl(i)})}function Fy(s){const t=s.coordinates;return{type:"Point",flatCoordinates:t,layout:Yi(t.length)}}function Oy(s){const t=s.coordinates,e=t.flat();return{type:"LineString",flatCoordinates:e,ends:[e.length],layout:Yi(t[0]?.length||2)}}function zy(s){const t=s.coordinates,e=t[0]?.[0]?.length||2,i=[],n=Is(i,0,t,e);return{type:"MultiLineString",flatCoordinates:i,ends:n,layout:Yi(e)}}function $y(s){const t=s.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:Yi(t[0]?.length||2)}}function Ny(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.[0].length||2,n=dc(e,0,t,i);return{type:"MultiPolygon",flatCoordinates:e,ends:n,layout:Yi(i)}}function Gy(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.length,n=Is(e,0,t,i);return{type:"Polygon",flatCoordinates:e,ends:n,layout:Yi(i)}}function ma(s,t){s=_l(s,!0,t);const e=s.getType();let i;switch(e){case"Point":{i=Xy(s);break}case"LineString":{i=Wy(s);break}case"Polygon":{i=jy(s,t);break}case"MultiPoint":{i=Vy(s);break}case"MultiLineString":{i=Uy(s);break}case"MultiPolygon":{i=Hy(s,t);break}case"GeometryCollection":{i=By(s,t);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+e)}return i}function By(s,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(i){return ma(i,t)})}}function Wy(s,t){return{type:"LineString",coordinates:s.getCoordinates()}}function Uy(s,t){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function Vy(s,t){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function Hy(s,t){let e;return t&&(e=t.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(e)}}function Xy(s,t){return{type:"Point",coordinates:s.getCoordinates()}}function jy(s,t){let e;return t&&(e=t.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(e)}}class bd extends It{constructor(t,e,i){super(t,e,Z.GEOJSON,{...i,zIndex:i?.zIndex??15}),this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.GEOJSON},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.geoJsonFormat=new Ry}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)}getAllFeatures(){const t=[];return this.source?.forEachFeature(e=>{t.push(e)}),t}getLayer(){return this.layer}}class Sd extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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 V({geometry:new rt(ut([e.longitude,e.latitude])),id:e.id,title:e.title,value:e.value,height:i,color:M(n)});r.setStyle(new A({fill:new j({color:M(n)}),image:new Le({radius:Math.sqrt(i)/2,fill:new j({color:M(n)})})})),this.source?.addFeature(r),this.features.set(e.id,r)})}getData(){const t=[];return this.features.forEach((e,i)=>{const n=e.getProperties();t.push({id:i,longitude:n.geometry?.getCoordinates()[0],latitude:n.geometry?.getCoordinates()[1],value:n.value,title:n.title})}),t}updateData(t){this.setData(t)}}class is extends It{constructor(t,e,i){super(t,e,Z.MARKER,i),this.moveHandler=null,this.features=new Map,this.markersData=new Map,this.animationFrames=new Map,this.view=null,this.currentPopup=null,this.currentFeature=null,this.currentHoverTimeout=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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.MARKER},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setView(t){this.view=t,this.attachEvents(),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}attachEvents(){this.view&&(this.view.on("click",t=>{const i=this.view.getFeaturesAtPixel(t.pixel)?.find(n=>n.get("_popupLayer")===this.id);if(i){const n=i.get("id"),r=this.markersData.get(n);r&&r.onClick&&r.onClick(r,t),this.showPopup(i,t)}else this.hidePopup()}),this.view.on("contextmenu",t=>{const i=this.view.getFeaturesAtPixel(t.pixel)?.find(n=>n.get("_popupLayer")===this.id);if(i){t.preventDefault();const n=i.get("id"),r=this.markersData.get(n);r&&r.onContextMenu&&r.onContextMenu(r,t)}}),this.view.on("pointermove",t=>{const i=this.view.getFeaturesAtPixel(t.pixel)?.find(n=>n.get("_popupLayer")===this.id);if(i){const n=this.view.getTargetElement();n&&(n.style.cursor="pointer");const r=i.get("id"),o=this.markersData.get(r);o&&o.onHover&&(this.currentHoverTimeout&&clearTimeout(this.currentHoverTimeout),this.currentHoverTimeout=window.setTimeout(()=>{o.onHover&&o.onHover(o,t),this.currentHoverTimeout=null},100))}else{const n=this.view.getTargetElement();n&&(n.style.cursor=""),this.currentHoverTimeout&&(clearTimeout(this.currentHoverTimeout),this.currentHoverTimeout=null)}}))}createPointStyle(t){const e=t.pointType||H.CIRCLE,i=t.pointColor||M(this.defaultColor),n=t.pointSize||this.defaultSize,r=t.pointText||"标绘点",o="#ffffff",a=2;if(t.pointHtml,e===H.TEXT)return new A({text:new te({text:r,font:`${n}px sans-serif`,fill:new j({color:i}),stroke:new G({color:o,width:a}),textAlign:"center",textBaseline:"middle"})});if(e===H.CIRCLE)return new A({image:new Le({radius:n/2,fill:new j({color:i}),stroke:new G({color:o,width:a})})});const l=document.createElement("canvas"),h=l.getContext("2d"),c=n*2.5;l.width=c,l.height=c;const d=c/2;if(!h)return new A({image:new Le({radius:n/2,fill:new j({color:i}),stroke:new G({color:o,width:a})})});switch(h.fillStyle=i,h.strokeStyle=o,h.lineWidth=a,h.save(),h.translate(d,d),e){case H.SQUARE:const u=n/1.8;h.fillRect(-u,-u,u*2,u*2),h.strokeRect(-u,-u,u*2,u*2);break;case H.TRIANGLE:const f=n/.9,g=n/1.8;h.beginPath(),h.moveTo(0,-f/2),h.lineTo(g,f/2),h.lineTo(-g,f/2),h.closePath(),h.fill(),h.stroke();break;case H.PENTAGRAM:const p=n/1.2,m=p/2.2,y=5;h.beginPath();for(let vt=0;vt<y*2;vt++){const Dt=vt%2===0?p:m,Kt=vt*Math.PI*2/(y*2)-Math.PI/2,kt=Dt*Math.cos(Kt),Ht=Dt*Math.sin(Kt);vt===0?h.moveTo(kt,Ht):h.lineTo(kt,Ht)}h.closePath(),h.fill(),h.stroke();break;case H.DIAMOND:const w=n/1.2,E=n/1.2;h.beginPath(),h.moveTo(0,-E/2),h.lineTo(w/2,0),h.lineTo(0,E/2),h.lineTo(-w/2,0),h.closePath(),h.fill(),h.stroke();break;case H.CROSS:const x=n/3,C=n*1.2;h.fillRect(-C/2,-x/2,C,x),h.strokeRect(-C/2,-x/2,C,x),h.fillRect(-x/2,-C/2,x,C),h.strokeRect(-x/2,-C/2,x,C);break;case H.X_SHAPE:const T=n/4,_=n*1.4;h.save(),h.rotate(Math.PI/4),h.fillRect(-_/2,-T/2,_,T),h.strokeRect(-_/2,-T/2,_,T),h.rotate(Math.PI/2),h.fillRect(-_/2,-T/2,_,T),h.strokeRect(-_/2,-T/2,_,T),h.restore();break;case H.HEXAGON:const b=n/1.3;h.beginPath();for(let vt=0;vt<6;vt++){const Dt=(vt*60-30)*Math.PI/180,Kt=b*Math.cos(Dt),kt=b*Math.sin(Dt);vt===0?h.moveTo(Kt,kt):h.lineTo(Kt,kt)}h.closePath(),h.fill(),h.stroke();break;case H.FLAG:const S=n/1.2,P=n/1.5,L=n/1.8;h.fillRect(-P/2,-S/2,n/6,S),h.strokeRect(-P/2,-S/2,n/6,S),h.fillRect(-P/2,-S/2,P,L),h.strokeRect(-P/2,-S/2,P,L);break;case H.HOUSE:const k=n/1.2,F=n/1.5,O=n/1.8;h.fillRect(-k/2,-F/3,k,F),h.strokeRect(-k/2,-F/3,k,F),h.beginPath(),h.moveTo(-k/2,-F/3),h.lineTo(0,-F/3-O),h.lineTo(k/2,-F/3),h.closePath(),h.fill(),h.stroke();break;case H.ARROW:const R=n/1.2,B=n/1.5;h.beginPath(),h.moveTo(0,-R/2),h.lineTo(R/2,R/2),h.lineTo(0,R/3),h.lineTo(-R/2,R/2),h.closePath(),h.fill(),h.stroke(),h.fillRect(-n/8,R/3,n/4,B),h.strokeRect(-n/8,R/3,n/4,B);break;case H.TENT:const D=n/1.2,z=n/1.2;h.beginPath(),h.moveTo(-D/2,z/3),h.lineTo(0,-z/2),h.lineTo(D/2,z/3),h.closePath(),h.fill(),h.stroke(),h.fillRect(-D/6,z/3,D/3,z/3),h.strokeRect(-D/6,z/3,D/3,z/3);break;case H.BUNKER:const N=n/1.5;h.beginPath(),h.arc(0,N/3,N,0,Math.PI,!0),h.fill(),h.stroke(),h.fillRect(-n/6,-n/4,n/3,n/4),h.strokeRect(-n/6,-n/4,n/3,n/4);break;case H.LANDMINE:const tt=n/2;h.beginPath(),h.arc(0,0,tt,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,n/6,0,2*Math.PI),h.fill(),h.stroke();for(let vt=0;vt<4;vt++){const Dt=vt*Math.PI/2,Kt=tt*.7*Math.cos(Dt),kt=tt*.7*Math.sin(Dt);h.beginPath(),h.arc(Kt,kt,n/8,0,2*Math.PI),h.fill(),h.stroke()}break;case H.TANK:h.fillRect(-n/1.5,-n/3,n/.8,n/1.5),h.strokeRect(-n/1.5,-n/3,n/.8,n/1.5),h.beginPath(),h.arc(0,-n/6,n/3,0,2*Math.PI),h.fill(),h.stroke(),h.fillRect(n/4,-n/4,n/1.5,n/8),h.strokeRect(n/4,-n/4,n/1.5,n/8),h.fillRect(-n/1.8,n/5,n/.9,n/6),h.strokeRect(-n/1.8,n/5,n/.9,n/6);break;case H.PLANE:h.beginPath(),h.moveTo(0,-n/2),h.lineTo(n/1.5,n/3),h.lineTo(n/3,n/3),h.lineTo(n/3,n/2),h.lineTo(0,n/3),h.lineTo(-n/3,n/2),h.lineTo(-n/3,n/3),h.lineTo(-n/1.5,n/3),h.closePath(),h.fill(),h.stroke();break;case H.SHIP:h.beginPath(),h.moveTo(-n/1.5,0),h.lineTo(0,n/2),h.lineTo(n/1.5,0),h.lineTo(n/2,-n/3),h.lineTo(-n/2,-n/3),h.closePath(),h.fill(),h.stroke(),h.fillRect(-n/6,-n/2,n/5,n/3),h.strokeRect(-n/6,-n/2,n/5,n/3);break;case H.RADAR:h.beginPath(),h.arc(0,0,n/2,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(0,0),h.lineTo(n/1.2,-n/1.2),h.lineTo(n/1.8,-n/1.8),h.fill(),h.stroke();break;case H.MISSILE:h.beginPath(),h.ellipse(0,-n/6,n/2.5,n/1.2,0,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(n/4,-n/2.5),h.lineTo(-n/4,-n/2.5),h.closePath(),h.fill(),h.stroke(),h.beginPath(),h.moveTo(-n/3,n/2),h.lineTo(0,n/3),h.lineTo(n/3,n/2),h.fill(),h.stroke();break;case H.FIRE_HYDRANT:h.fillRect(-n/4,-n/2,n/2,n/1.2),h.strokeRect(-n/4,-n/2,n/2,n/1.2),h.beginPath(),h.arc(0,-n/2,n/3,0,2*Math.PI),h.fill(),h.stroke();break;case H.FIRST_AID:h.fillRect(-n/2,-n/2,n,n),h.strokeRect(-n/2,-n/2,n,n),h.fillStyle="#ff0000",h.fillRect(-n/8,-n/2.5,n/4,n/1.2),h.fillRect(-n/2.5,-n/8,n/1.2,n/4),h.fillStyle=i,h.strokeStyle=o;break;case H.WATER_TOWER:h.fillRect(-n/3,-n/2,n/1.5,n/1.2),h.strokeRect(-n/3,-n/2,n/1.5,n/1.2),h.beginPath(),h.arc(0,-n/2.5,n/2.5,0,2*Math.PI),h.fill(),h.stroke();break;case H.GENERATOR:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.beginPath(),h.arc(0,0,n/4,0,2*Math.PI),h.fill(),h.stroke();break;case H.MEGAPHONE:h.beginPath(),h.moveTo(-n/2,-n/3),h.lineTo(n/2,-n/4),h.lineTo(n/2,n/4),h.lineTo(-n/2,n/3),h.closePath(),h.fill(),h.stroke(),h.fillRect(-n/1.8,n/4,n/3,n/6),h.strokeRect(-n/1.8,n/4,n/3,n/6);break;case H.STREET_LAMP:h.fillRect(-n/12,-n/1.5,n/6,n/1.2),h.strokeRect(-n/12,-n/1.5,n/6,n/1.2),h.beginPath(),h.arc(0,-n/1.5,n/3,0,2*Math.PI),h.fill(),h.stroke();break;case H.PARKING:h.fillStyle="#0066cc",h.fillRect(-n/2,-n/2,n,n),h.strokeRect(-n/2,-n/2,n,n),h.fillStyle="#ffffff",h.font=`bold ${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("P",0,0),h.fillStyle=i,h.strokeStyle=o;break;case H.GAS_STATION:h.fillRect(-n/4,-n/2,n/2,n),h.strokeRect(-n/4,-n/2,n/2,n),h.beginPath(),h.moveTo(n/4,-n/3),h.lineTo(n/1.5,-n/2),h.lineTo(n/1.5,0),h.lineTo(n/4,n/3),h.fill(),h.stroke();break;case H.TUNNEL:h.beginPath(),h.rect(-n/1.5,0,n/.75,n/1.5),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,n/1.5,0,Math.PI,!0),h.fill(),h.stroke();break;case H.BRIDGE:h.fillRect(-n/1.5,-n/4,n/.75,n/4),h.strokeRect(-n/1.5,-n/4,n/.75,n/4),h.beginPath(),h.arc(0,-n/6,n/2,0,Math.PI,!1),h.fill(),h.stroke();break;case H.TRAFFIC_LIGHT:h.fillRect(-n/3,-n/1.5,n/1.5,n/.8),h.strokeRect(-n/3,-n/1.5,n/1.5,n/.8);const et=n/6;h.beginPath(),h.arc(0,-n/3,et,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,et,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.arc(0,n/3,et,0,2*Math.PI),h.fill(),h.stroke();break;case H.CAMERA:h.beginPath(),h.arc(0,-n/6,n/2.5,0,2*Math.PI),h.fill(),h.stroke(),h.fillRect(-n/4,n/4,n/2,n/4),h.strokeRect(-n/4,n/4,n/2,n/4);break;case H.TOILET:h.fillRect(-n/2,-n/2,n,n),h.strokeRect(-n/2,-n/2,n,n),h.fillStyle="#ffffff",h.font=`${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("WC",0,0),h.fillStyle=i,h.strokeStyle=o;break;case H.TRASH_CAN:h.fillRect(-n/3,-n/2,n/1.5,n),h.strokeRect(-n/3,-n/2,n/1.5,n),h.fillRect(-n/2,-n/1.8,n,n/6),h.strokeRect(-n/2,-n/1.8,n,n/6);break;case H.BUS_STOP:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.fillStyle="#ffffff",h.font=`${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("BUS",0,0),h.fillStyle=i;break;case H.SUBWAY:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.fillStyle="#ffffff",h.font=`bold ${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("M",0,0),h.fillStyle=i;break;case H.SCHOOL:h.fillRect(-n/2,-n/3,n,n/1.2),h.strokeRect(-n/2,-n/3,n,n/1.2),h.fillRect(-n/6,-n/1.2,n/3,n/1.5),h.strokeRect(-n/6,-n/1.2,n/3,n/1.5),h.beginPath(),h.moveTo(-n/2,-n/3),h.lineTo(0,-n/1.2),h.lineTo(n/2,-n/3),h.fill(),h.stroke();break;case H.HOSPITAL:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.fillStyle="#ffffff",h.font=`bold ${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("H",0,0),h.fillStyle=i;break;case H.TREE:h.fillRect(-n/8,0,n/4,n/1.5),h.strokeRect(-n/8,0,n/4,n/1.5),h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(-n/2,0),h.lineTo(n/2,0),h.closePath(),h.fill(),h.stroke();break;case H.WATER_SOURCE:h.beginPath(),h.moveTo(0,-n/1.8),h.bezierCurveTo(-n/1.5,-n/4,-n/1.5,n/2,0,n/2),h.bezierCurveTo(n/1.5,n/2,n/1.5,-n/4,0,-n/1.8),h.fill(),h.stroke();break;case H.MOUNTAIN:h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(-n/1.2,n/2),h.lineTo(n/1.2,n/2),h.closePath(),h.fill(),h.stroke(),h.fillStyle="#ffffff",h.beginPath(),h.moveTo(0,-n/2),h.lineTo(-n/4,0),h.lineTo(n/4,0),h.closePath(),h.fill(),h.fillStyle=i;break;case H.MINE:h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(n/1.5,0),h.lineTo(0,n/1.5),h.lineTo(-n/1.5,0),h.closePath(),h.fill(),h.stroke(),h.beginPath(),h.moveTo(-n/4,-n/4),h.lineTo(n/4,n/4),h.moveTo(n/4,-n/4),h.lineTo(-n/4,n/4),h.stroke();break;case H.HEART:h.beginPath();const ht=0,ot=-n/4,I=n/1.5;h.moveTo(ht,ot+I/3),h.bezierCurveTo(ht-I/2,ot-I/3,ht-I,ot+I/2,ht,ot+I),h.bezierCurveTo(ht+I,ot+I/2,ht+I/2,ot-I/3,ht,ot+I/3),h.fill(),h.stroke();break;case H.STAR:const xt=n/1.2;h.beginPath();for(let vt=0;vt<4;vt++){const Dt=(vt*90-45)*Math.PI/180,Kt=xt*Math.cos(Dt),kt=xt*Math.sin(Dt),Ht=xt/2.5*Math.cos(Dt+45*Math.PI/180),de=xt/2.5*Math.sin(Dt+45*Math.PI/180);vt===0?h.moveTo(Kt,kt):h.lineTo(Kt,kt),h.lineTo(Ht,de)}h.closePath(),h.fill(),h.stroke();break;case H.CLOUD:const yt=n/1.5;h.beginPath(),h.arc(-yt/2,-yt/4,yt/2,0,2*Math.PI),h.arc(yt/2,-yt/4,yt/2,0,2*Math.PI),h.arc(0,0,yt/1.5,0,2*Math.PI),h.arc(-yt/1.5,yt/4,yt/2.5,0,2*Math.PI),h.arc(yt/1.5,yt/4,yt/2.5,0,2*Math.PI),h.fill(),h.stroke();break;case H.GEAR:const Ot=n/1.5,ie=8,Ne=n/4;h.beginPath();for(let vt=0;vt<ie;vt++){const Dt=vt*360/ie*Math.PI/180,Kt=Ot*Math.cos(Dt),kt=Ot*Math.sin(Dt),Ht=(Ot+Ne)*Math.cos(Dt),de=(Ot+Ne)*Math.sin(Dt);vt===0?h.moveTo(Kt,kt):h.lineTo(Kt,kt),h.lineTo(Ht,de)}h.closePath(),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,Ot/2,0,2*Math.PI),h.fill(),h.stroke();break;case H.LIGHTNING:h.beginPath(),h.moveTo(-n/6,-n/1.5),h.lineTo(n/4,-n/6),h.lineTo(0,-n/6),h.lineTo(n/6,n/1.5),h.lineTo(-n/4,n/6),h.lineTo(0,n/6),h.closePath(),h.fill(),h.stroke();break;case H.PIN:h.beginPath(),h.arc(0,-n/4,n/3,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(-n/6,-n/8),h.lineTo(0,n/2),h.lineTo(n/6,-n/8),h.fill(),h.stroke();break;case H.COMPASS:h.beginPath(),h.arc(0,0,n/1.5,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(0,-n/1.8),h.lineTo(n/8,0),h.lineTo(0,n/1.8),h.lineTo(-n/8,0),h.closePath(),h.fillStyle="#ff0000",h.fill(),h.fillStyle=i,h.stroke();break;case H.ANCHOR:const St=n/1.5;h.beginPath(),h.arc(0,St/3,St/2,0,2*Math.PI),h.fill(),h.stroke(),h.fillRect(-n/8,-St/2,n/4,St),h.strokeRect(-n/8,-St/2,n/4,St),h.fillRect(-St/1.5,-St/4,St/.75,n/6),h.strokeRect(-St/1.5,-St/4,St/.75,n/6);break;default:h.beginPath(),h.arc(0,0,n/2,0,2*Math.PI),h.fill(),h.stroke();break}return h.restore(),new A({image:new Vi({img:l,size:[c,c]})})}startAnimation(t,e){const i=t.get("id");if(!i)return;this.stopAnimation(i),this.createPointStyle(this.markersData.get(i));const n=performance.now(),r=a=>{const l=a-n;let h;switch(e){case _n.PULSE:const d=.7+.3*(Math.sin(l*.008)+1)/2;h=this.createScaledStyle(this.markersData.get(i),d);break;case _n.FLASHING:const u=.3+.7*(Math.sin(l*.012)+1)/2;h=this.createBlendedStyle(this.markersData.get(i),u);break;case _n.BREATHING:const f=.3+.7*(Math.sin(l*.005)+1)/2;h=this.createOpacityStyle(this.markersData.get(i),f);break;case _n.LIGHT:const g=.3+.7*(Math.sin(l*.01)+1)/2;h=this.createGlowStyle(this.markersData.get(i),g);break;default:return}t.setStyle(h),t.changed();const c=requestAnimationFrame(r);this.animationFrames.set(i,{startTime:n,frameId:c})},o=requestAnimationFrame(r);this.animationFrames.set(i,{startTime:n,frameId:o})}createScaledStyle(t,e){const i=Math.max(6,(t.pointSize||this.defaultSize)*e),n={...t,pointSize:i};return this.createPointStyle(n)}createBlendedStyle(t,e){const i=Math.max(.3,Math.min(1,e));t.pointColor||M(this.defaultColor);const n=`rgba(255, ${Math.floor(255*i)}, ${Math.floor(255*i)}, 0.9)`,r={...t,pointColor:n};return this.createPointStyle(r)}createOpacityStyle(t,e){const i=Math.max(.2,Math.min(1,e)),r=(t.pointColor||M(this.defaultColor)).replace(/[\d.]+\)$/g,`${i})`),o={...t,pointColor:r};return this.createPointStyle(o)}createGlowStyle(t,e){t.pointColor||M(this.defaultColor);const i=(t.pointSize||this.defaultSize)*(1+e*.5),n={...t,pointSize:i};return this.createPointStyle(n)}stopAnimation(t){const e=this.animationFrames.get(t);e&&(cancelAnimationFrame(e.frameId),this.animationFrames.delete(t))}async createHtmlStyle(t){const e=t.pointColor||M(this.defaultColor),i="#ffffff",n=2,r=t.pointHtml||"",o=t.pointHtmlWidth||100,a=t.pointHtmlHeight||20,l=document.createElement("div");l.style.position="absolute",l.style.visibility="hidden",l.style.top="-9999px",l.style.left="-9999px",l.style.backgroundColor=e,l.style.border=`${n}px solid ${i}`,l.style.borderRadius="6px",l.style.padding="4px 8px",l.style.fontSize="14px",l.style.fontFamily="sans-serif",l.style.whiteSpace="nowrap",l.style.color="#ffffff",l.innerHTML=r,document.body.appendChild(l);const h=Math.max(l.offsetWidth+16,o),c=Math.max(l.offsetHeight+8,a);document.body.removeChild(l);const d=document.createElement("canvas");d.width=h,d.height=c;const u=`
|
|
828
|
+
}`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}renderDeclutter(){}}function Iy(s){const i=$t(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 pr extends It{constructor(t,e,i){super(t,e,Z.HEATMAP,{...i,zIndex:i?.zIndex??20}),this.heatmapLayer=null,this.data=[],this.source=new Y,this.heatmapLayer=new Py({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 V({geometry:new rt(ut([e.longitude,e.latitude])),weight:e.value||1,id:e.id,longitude:e.longitude,latitude:e.latitude});this.source?.addFeature(i)})}updateData(t){this.setData(t)}getLayer(){return this.heatmapLayer}getData(){return this.data}}class Ly extends Y{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 gt(!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(nt.CHANGE,this.boundRefresh_),this.source=t,t&&t.addEventListener(nt.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=oe(),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(!(K(a)in n)){const l=this.geometryFunction(a);if(l){const h=l.getCoordinates();Ea(h,t),An(t,e,t);const c=this.source.getFeaturesInExtent(t).filter(function(d){const u=K(d);return u in n?!1:(n[u]=!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?Zh(i,l.getCoordinates()):t.splice(a,1)}Kh(i,1/t.length);const n=be(e),r=this.interpolationRatio,o=new rt([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(o,t):new V({geometry:o,features:t})}}class bd extends It{constructor(t,e,i){super(t,e,Z.CLUSTER,{...i,zIndex:i?.zIndex??15}),this.clusterSource=null,this.clusterLayer=null,this.source=new Y,this.clusterSource=new Ly({distance:i?.distance||60,source:this.source}),this.clusterLayer=new bt({source:this.clusterSource,style:n=>this.createStyle(n),properties:{id:t,name:e,type:Z.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 A({image:new Le({radius:a,fill:new j({color:M(o)}),stroke:new G({color:"#fff",width:2})}),text:new te({text:i.toString(),fill:new j({color:"#fff"}),font:"bold 14px sans-serif"})})}return new A({image:new Le({radius:8,fill:new j({color:M(r)}),stroke:new G({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 V({geometry:new rt(ut([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()}getData(){const t=[];return this.source?.forEachFeature(e=>{const i=e.getProperties();t.push({id:i.id,longitude:i.geometry?.getCoordinates()[0],latitude:i.geometry?.getCoordinates()[1],title:i.title,popupContent:i.popupContent})}),t}}class Dy{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=V,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?Ft(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=Ft(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 Q()}readFeature(t,e){return Q()}readFeatures(t,e){return Q()}readGeometry(t,e){return Q()}readProjection(t){return Q()}writeFeature(t,e){return Q()}writeFeatures(t,e){return Q()}writeGeometry(t,e){return Q()}}function xl(s,t,e){const i=e?Ft(e.featureProjection):null,n=e?Ft(e.dataProjection):null;let r=s;if(i&&n&&!os(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(fs(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 ky={Point:rt,LineString:pt,Polygon:it,MultiPoint:As,MultiLineString:Ln,MultiPolygon:Dn};function Ry(s,t,e){return Array.isArray(t[0])?(Cc(s,0,t,e)||(s=s.slice(),na(s,0,t,e)),s):(Va(s,0,t,e)||(s=s.slice(),vr(s,0,t,e)),s)}function Sd(s,t){const e=s.geometry;if(!e)return[];if(Array.isArray(e))return e.map(r=>Sd({...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 xl(new ge(i,i==="Polygon"?Ry(e.flatCoordinates,e.ends,n):e.flatCoordinates,e.ends?.flat(),n,s.properties||{},s.id).enableSimplifyTransformed(),!1,t)}function Cl(s,t){if(!s)return null;if(Array.isArray(s)){const i=s.map(n=>Cl(n,t));return new Cs(i)}const e=ky[s.type];return xl(new e(s.flatCoordinates,s.layout||"XY",s.ends),!1,t)}class Ay extends Dy{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(ar(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(ar(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return Q()}readFeaturesFromObject(t,e){return Q()}readGeometry(t,e){return this.readGeometryFromObject(ar(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return Q()}readProjection(t){return this.readProjectionFromObject(ar(t))}readProjectionFromObject(t){return Q()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return Q()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return Q()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return Q()}}function ar(s){if(typeof s=="string"){const t=JSON.parse(s);return t||null}return s!==null?s:null}class My extends Ay{constructor(t){t=t||{},super(),this.dataProjection=Ft(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Ft(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=El(i.geometry);if(this.featureClass===ge)return Sd({geometry:n,id:i.id,properties:i.properties},e);const r=new V;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(Cl(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 Fy(t,e)}readProjectionFromObject(t){const e=t.crs;let i;if(e)if(e.type=="name")i=Ft(e.properties.name);else if(e.type==="EPSG")i=Ft("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=ya(o,e),delete r[t.getGeometryName()]),Wi(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 ya(t,this.adaptOptions(e))}}function El(s,t){if(!s)return null;let e;switch(s.type){case"Point":{e=zy(s);break}case"LineString":{e=$y(s);break}case"Polygon":{e=Wy(s);break}case"MultiPoint":{e=Gy(s);break}case"MultiLineString":{e=Ny(s);break}case"MultiPolygon":{e=By(s);break}case"GeometryCollection":{e=Oy(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return e}function Fy(s,t){const e=El(s);return Cl(e,t)}function Oy(s,t){return s.geometries.map(function(i){return El(i)})}function zy(s){const t=s.coordinates;return{type:"Point",flatCoordinates:t,layout:Yi(t.length)}}function $y(s){const t=s.coordinates,e=t.flat();return{type:"LineString",flatCoordinates:e,ends:[e.length],layout:Yi(t[0]?.length||2)}}function Ny(s){const t=s.coordinates,e=t[0]?.[0]?.length||2,i=[],n=Ls(i,0,t,e);return{type:"MultiLineString",flatCoordinates:i,ends:n,layout:Yi(e)}}function Gy(s){const t=s.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:Yi(t[0]?.length||2)}}function By(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.[0].length||2,n=fc(e,0,t,i);return{type:"MultiPolygon",flatCoordinates:e,ends:n,layout:Yi(i)}}function Wy(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.length,n=Ls(e,0,t,i);return{type:"Polygon",flatCoordinates:e,ends:n,layout:Yi(i)}}function ya(s,t){s=xl(s,!0,t);const e=s.getType();let i;switch(e){case"Point":{i=Yy(s);break}case"LineString":{i=Vy(s);break}case"Polygon":{i=Zy(s,t);break}case"MultiPoint":{i=Xy(s);break}case"MultiLineString":{i=Hy(s);break}case"MultiPolygon":{i=jy(s,t);break}case"GeometryCollection":{i=Uy(s,t);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+e)}return i}function Uy(s,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(i){return ya(i,t)})}}function Vy(s,t){return{type:"LineString",coordinates:s.getCoordinates()}}function Hy(s,t){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function Xy(s,t){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function jy(s,t){let e;return t&&(e=t.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(e)}}function Yy(s,t){return{type:"Point",coordinates:s.getCoordinates()}}function Zy(s,t){let e;return t&&(e=t.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(e)}}class Pd extends It{constructor(t,e,i){super(t,e,Z.GEOJSON,{...i,zIndex:i?.zIndex??15}),this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.GEOJSON},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.geoJsonFormat=new My}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)}getAllFeatures(){const t=[];return this.source?.forEachFeature(e=>{t.push(e)}),t}getLayer(){return this.layer}}class Id extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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 V({geometry:new rt(ut([e.longitude,e.latitude])),id:e.id,title:e.title,value:e.value,height:i,color:M(n)});r.setStyle(new A({fill:new j({color:M(n)}),image:new Le({radius:Math.sqrt(i)/2,fill:new j({color:M(n)})})})),this.source?.addFeature(r),this.features.set(e.id,r)})}getData(){const t=[];return this.features.forEach((e,i)=>{const n=e.getProperties();t.push({id:i,longitude:n.geometry?.getCoordinates()[0],latitude:n.geometry?.getCoordinates()[1],value:n.value,title:n.title})}),t}updateData(t){this.setData(t)}}class is extends It{constructor(t,e,i){super(t,e,Z.MARKER,i),this.moveHandler=null,this.features=new Map,this.markersData=new Map,this.animationFrames=new Map,this.view=null,this.currentPopup=null,this.currentFeature=null,this.currentHoverTimeout=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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.MARKER},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setView(t){this.view=t,this.attachEvents(),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}attachEvents(){this.view&&(this.view.on("click",t=>{const i=this.view.getFeaturesAtPixel(t.pixel)?.find(n=>n.get("_popupLayer")===this.id);if(i){const n=i.get("id"),r=this.markersData.get(n);r&&r.onClick&&r.onClick(r,t),this.showPopup(i,t)}else this.hidePopup()}),this.view.on("contextmenu",t=>{const i=this.view.getFeaturesAtPixel(t.pixel)?.find(n=>n.get("_popupLayer")===this.id);if(i){t.preventDefault();const n=i.get("id"),r=this.markersData.get(n);r&&r.onContextMenu&&r.onContextMenu(r,t)}}),this.view.on("pointermove",t=>{const i=this.view.getFeaturesAtPixel(t.pixel)?.find(n=>n.get("_popupLayer")===this.id);if(i){const n=this.view.getTargetElement();n&&(n.style.cursor="pointer");const r=i.get("id"),o=this.markersData.get(r);o&&o.onHover&&(this.currentHoverTimeout&&clearTimeout(this.currentHoverTimeout),this.currentHoverTimeout=window.setTimeout(()=>{o.onHover&&o.onHover(o,t),this.currentHoverTimeout=null},100))}else{const n=this.view.getTargetElement();n&&(n.style.cursor=""),this.currentHoverTimeout&&(clearTimeout(this.currentHoverTimeout),this.currentHoverTimeout=null)}}))}createPointStyle(t){const e=t.pointType||H.CIRCLE,i=t.pointColor||M(this.defaultColor),n=t.pointSize||this.defaultSize,r=t.pointText||"标绘点",o="#ffffff",a=2;if(t.pointHtml,e===H.TEXT)return new A({text:new te({text:r,font:`${n}px sans-serif`,fill:new j({color:i}),stroke:new G({color:o,width:a}),textAlign:"center",textBaseline:"middle"})});if(e===H.CIRCLE)return new A({image:new Le({radius:n/2,fill:new j({color:i}),stroke:new G({color:o,width:a})})});const l=document.createElement("canvas"),h=l.getContext("2d"),c=n*2.5;l.width=c,l.height=c;const d=c/2;if(!h)return new A({image:new Le({radius:n/2,fill:new j({color:i}),stroke:new G({color:o,width:a})})});switch(h.fillStyle=i,h.strokeStyle=o,h.lineWidth=a,h.save(),h.translate(d,d),e){case H.SQUARE:const u=n/1.8;h.fillRect(-u,-u,u*2,u*2),h.strokeRect(-u,-u,u*2,u*2);break;case H.TRIANGLE:const f=n/.9,g=n/1.8;h.beginPath(),h.moveTo(0,-f/2),h.lineTo(g,f/2),h.lineTo(-g,f/2),h.closePath(),h.fill(),h.stroke();break;case H.PENTAGRAM:const p=n/1.2,m=p/2.2,y=5;h.beginPath();for(let vt=0;vt<y*2;vt++){const Dt=vt%2===0?p:m,Kt=vt*Math.PI*2/(y*2)-Math.PI/2,kt=Dt*Math.cos(Kt),Ht=Dt*Math.sin(Kt);vt===0?h.moveTo(kt,Ht):h.lineTo(kt,Ht)}h.closePath(),h.fill(),h.stroke();break;case H.DIAMOND:const x=n/1.2,E=n/1.2;h.beginPath(),h.moveTo(0,-E/2),h.lineTo(x/2,0),h.lineTo(0,E/2),h.lineTo(-x/2,0),h.closePath(),h.fill(),h.stroke();break;case H.CROSS:const w=n/3,C=n*1.2;h.fillRect(-C/2,-w/2,C,w),h.strokeRect(-C/2,-w/2,C,w),h.fillRect(-w/2,-C/2,w,C),h.strokeRect(-w/2,-C/2,w,C);break;case H.X_SHAPE:const v=n/4,_=n*1.4;h.save(),h.rotate(Math.PI/4),h.fillRect(-_/2,-v/2,_,v),h.strokeRect(-_/2,-v/2,_,v),h.rotate(Math.PI/2),h.fillRect(-_/2,-v/2,_,v),h.strokeRect(-_/2,-v/2,_,v),h.restore();break;case H.HEXAGON:const b=n/1.3;h.beginPath();for(let vt=0;vt<6;vt++){const Dt=(vt*60-30)*Math.PI/180,Kt=b*Math.cos(Dt),kt=b*Math.sin(Dt);vt===0?h.moveTo(Kt,kt):h.lineTo(Kt,kt)}h.closePath(),h.fill(),h.stroke();break;case H.FLAG:const S=n/1.2,P=n/1.5,L=n/1.8;h.fillRect(-P/2,-S/2,n/6,S),h.strokeRect(-P/2,-S/2,n/6,S),h.fillRect(-P/2,-S/2,P,L),h.strokeRect(-P/2,-S/2,P,L);break;case H.HOUSE:const k=n/1.2,F=n/1.5,O=n/1.8;h.fillRect(-k/2,-F/3,k,F),h.strokeRect(-k/2,-F/3,k,F),h.beginPath(),h.moveTo(-k/2,-F/3),h.lineTo(0,-F/3-O),h.lineTo(k/2,-F/3),h.closePath(),h.fill(),h.stroke();break;case H.ARROW:const R=n/1.2,B=n/1.5;h.beginPath(),h.moveTo(0,-R/2),h.lineTo(R/2,R/2),h.lineTo(0,R/3),h.lineTo(-R/2,R/2),h.closePath(),h.fill(),h.stroke(),h.fillRect(-n/8,R/3,n/4,B),h.strokeRect(-n/8,R/3,n/4,B);break;case H.TENT:const D=n/1.2,z=n/1.2;h.beginPath(),h.moveTo(-D/2,z/3),h.lineTo(0,-z/2),h.lineTo(D/2,z/3),h.closePath(),h.fill(),h.stroke(),h.fillRect(-D/6,z/3,D/3,z/3),h.strokeRect(-D/6,z/3,D/3,z/3);break;case H.BUNKER:const N=n/1.5;h.beginPath(),h.arc(0,N/3,N,0,Math.PI,!0),h.fill(),h.stroke(),h.fillRect(-n/6,-n/4,n/3,n/4),h.strokeRect(-n/6,-n/4,n/3,n/4);break;case H.LANDMINE:const tt=n/2;h.beginPath(),h.arc(0,0,tt,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,n/6,0,2*Math.PI),h.fill(),h.stroke();for(let vt=0;vt<4;vt++){const Dt=vt*Math.PI/2,Kt=tt*.7*Math.cos(Dt),kt=tt*.7*Math.sin(Dt);h.beginPath(),h.arc(Kt,kt,n/8,0,2*Math.PI),h.fill(),h.stroke()}break;case H.TANK:h.fillRect(-n/1.5,-n/3,n/.8,n/1.5),h.strokeRect(-n/1.5,-n/3,n/.8,n/1.5),h.beginPath(),h.arc(0,-n/6,n/3,0,2*Math.PI),h.fill(),h.stroke(),h.fillRect(n/4,-n/4,n/1.5,n/8),h.strokeRect(n/4,-n/4,n/1.5,n/8),h.fillRect(-n/1.8,n/5,n/.9,n/6),h.strokeRect(-n/1.8,n/5,n/.9,n/6);break;case H.PLANE:h.beginPath(),h.moveTo(0,-n/2),h.lineTo(n/1.5,n/3),h.lineTo(n/3,n/3),h.lineTo(n/3,n/2),h.lineTo(0,n/3),h.lineTo(-n/3,n/2),h.lineTo(-n/3,n/3),h.lineTo(-n/1.5,n/3),h.closePath(),h.fill(),h.stroke();break;case H.SHIP:h.beginPath(),h.moveTo(-n/1.5,0),h.lineTo(0,n/2),h.lineTo(n/1.5,0),h.lineTo(n/2,-n/3),h.lineTo(-n/2,-n/3),h.closePath(),h.fill(),h.stroke(),h.fillRect(-n/6,-n/2,n/5,n/3),h.strokeRect(-n/6,-n/2,n/5,n/3);break;case H.RADAR:h.beginPath(),h.arc(0,0,n/2,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(0,0),h.lineTo(n/1.2,-n/1.2),h.lineTo(n/1.8,-n/1.8),h.fill(),h.stroke();break;case H.MISSILE:h.beginPath(),h.ellipse(0,-n/6,n/2.5,n/1.2,0,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(n/4,-n/2.5),h.lineTo(-n/4,-n/2.5),h.closePath(),h.fill(),h.stroke(),h.beginPath(),h.moveTo(-n/3,n/2),h.lineTo(0,n/3),h.lineTo(n/3,n/2),h.fill(),h.stroke();break;case H.FIRE_HYDRANT:h.fillRect(-n/4,-n/2,n/2,n/1.2),h.strokeRect(-n/4,-n/2,n/2,n/1.2),h.beginPath(),h.arc(0,-n/2,n/3,0,2*Math.PI),h.fill(),h.stroke();break;case H.FIRST_AID:h.fillRect(-n/2,-n/2,n,n),h.strokeRect(-n/2,-n/2,n,n),h.fillStyle="#ff0000",h.fillRect(-n/8,-n/2.5,n/4,n/1.2),h.fillRect(-n/2.5,-n/8,n/1.2,n/4),h.fillStyle=i,h.strokeStyle=o;break;case H.WATER_TOWER:h.fillRect(-n/3,-n/2,n/1.5,n/1.2),h.strokeRect(-n/3,-n/2,n/1.5,n/1.2),h.beginPath(),h.arc(0,-n/2.5,n/2.5,0,2*Math.PI),h.fill(),h.stroke();break;case H.GENERATOR:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.beginPath(),h.arc(0,0,n/4,0,2*Math.PI),h.fill(),h.stroke();break;case H.MEGAPHONE:h.beginPath(),h.moveTo(-n/2,-n/3),h.lineTo(n/2,-n/4),h.lineTo(n/2,n/4),h.lineTo(-n/2,n/3),h.closePath(),h.fill(),h.stroke(),h.fillRect(-n/1.8,n/4,n/3,n/6),h.strokeRect(-n/1.8,n/4,n/3,n/6);break;case H.STREET_LAMP:h.fillRect(-n/12,-n/1.5,n/6,n/1.2),h.strokeRect(-n/12,-n/1.5,n/6,n/1.2),h.beginPath(),h.arc(0,-n/1.5,n/3,0,2*Math.PI),h.fill(),h.stroke();break;case H.PARKING:h.fillStyle="#0066cc",h.fillRect(-n/2,-n/2,n,n),h.strokeRect(-n/2,-n/2,n,n),h.fillStyle="#ffffff",h.font=`bold ${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("P",0,0),h.fillStyle=i,h.strokeStyle=o;break;case H.GAS_STATION:h.fillRect(-n/4,-n/2,n/2,n),h.strokeRect(-n/4,-n/2,n/2,n),h.beginPath(),h.moveTo(n/4,-n/3),h.lineTo(n/1.5,-n/2),h.lineTo(n/1.5,0),h.lineTo(n/4,n/3),h.fill(),h.stroke();break;case H.TUNNEL:h.beginPath(),h.rect(-n/1.5,0,n/.75,n/1.5),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,n/1.5,0,Math.PI,!0),h.fill(),h.stroke();break;case H.BRIDGE:h.fillRect(-n/1.5,-n/4,n/.75,n/4),h.strokeRect(-n/1.5,-n/4,n/.75,n/4),h.beginPath(),h.arc(0,-n/6,n/2,0,Math.PI,!1),h.fill(),h.stroke();break;case H.TRAFFIC_LIGHT:h.fillRect(-n/3,-n/1.5,n/1.5,n/.8),h.strokeRect(-n/3,-n/1.5,n/1.5,n/.8);const et=n/6;h.beginPath(),h.arc(0,-n/3,et,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,et,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.arc(0,n/3,et,0,2*Math.PI),h.fill(),h.stroke();break;case H.CAMERA:h.beginPath(),h.arc(0,-n/6,n/2.5,0,2*Math.PI),h.fill(),h.stroke(),h.fillRect(-n/4,n/4,n/2,n/4),h.strokeRect(-n/4,n/4,n/2,n/4);break;case H.TOILET:h.fillRect(-n/2,-n/2,n,n),h.strokeRect(-n/2,-n/2,n,n),h.fillStyle="#ffffff",h.font=`${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("WC",0,0),h.fillStyle=i,h.strokeStyle=o;break;case H.TRASH_CAN:h.fillRect(-n/3,-n/2,n/1.5,n),h.strokeRect(-n/3,-n/2,n/1.5,n),h.fillRect(-n/2,-n/1.8,n,n/6),h.strokeRect(-n/2,-n/1.8,n,n/6);break;case H.BUS_STOP:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.fillStyle="#ffffff",h.font=`${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("BUS",0,0),h.fillStyle=i;break;case H.SUBWAY:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.fillStyle="#ffffff",h.font=`bold ${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("M",0,0),h.fillStyle=i;break;case H.SCHOOL:h.fillRect(-n/2,-n/3,n,n/1.2),h.strokeRect(-n/2,-n/3,n,n/1.2),h.fillRect(-n/6,-n/1.2,n/3,n/1.5),h.strokeRect(-n/6,-n/1.2,n/3,n/1.5),h.beginPath(),h.moveTo(-n/2,-n/3),h.lineTo(0,-n/1.2),h.lineTo(n/2,-n/3),h.fill(),h.stroke();break;case H.HOSPITAL:h.fillRect(-n/1.8,-n/2,n/.9,n/1.2),h.strokeRect(-n/1.8,-n/2,n/.9,n/1.2),h.fillStyle="#ffffff",h.font=`bold ${n/1.5}px sans-serif`,h.textAlign="center",h.textBaseline="middle",h.fillText("H",0,0),h.fillStyle=i;break;case H.TREE:h.fillRect(-n/8,0,n/4,n/1.5),h.strokeRect(-n/8,0,n/4,n/1.5),h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(-n/2,0),h.lineTo(n/2,0),h.closePath(),h.fill(),h.stroke();break;case H.WATER_SOURCE:h.beginPath(),h.moveTo(0,-n/1.8),h.bezierCurveTo(-n/1.5,-n/4,-n/1.5,n/2,0,n/2),h.bezierCurveTo(n/1.5,n/2,n/1.5,-n/4,0,-n/1.8),h.fill(),h.stroke();break;case H.MOUNTAIN:h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(-n/1.2,n/2),h.lineTo(n/1.2,n/2),h.closePath(),h.fill(),h.stroke(),h.fillStyle="#ffffff",h.beginPath(),h.moveTo(0,-n/2),h.lineTo(-n/4,0),h.lineTo(n/4,0),h.closePath(),h.fill(),h.fillStyle=i;break;case H.MINE:h.beginPath(),h.moveTo(0,-n/1.5),h.lineTo(n/1.5,0),h.lineTo(0,n/1.5),h.lineTo(-n/1.5,0),h.closePath(),h.fill(),h.stroke(),h.beginPath(),h.moveTo(-n/4,-n/4),h.lineTo(n/4,n/4),h.moveTo(n/4,-n/4),h.lineTo(-n/4,n/4),h.stroke();break;case H.HEART:h.beginPath();const ht=0,ot=-n/4,I=n/1.5;h.moveTo(ht,ot+I/3),h.bezierCurveTo(ht-I/2,ot-I/3,ht-I,ot+I/2,ht,ot+I),h.bezierCurveTo(ht+I,ot+I/2,ht+I/2,ot-I/3,ht,ot+I/3),h.fill(),h.stroke();break;case H.STAR:const xt=n/1.2;h.beginPath();for(let vt=0;vt<4;vt++){const Dt=(vt*90-45)*Math.PI/180,Kt=xt*Math.cos(Dt),kt=xt*Math.sin(Dt),Ht=xt/2.5*Math.cos(Dt+45*Math.PI/180),de=xt/2.5*Math.sin(Dt+45*Math.PI/180);vt===0?h.moveTo(Kt,kt):h.lineTo(Kt,kt),h.lineTo(Ht,de)}h.closePath(),h.fill(),h.stroke();break;case H.CLOUD:const yt=n/1.5;h.beginPath(),h.arc(-yt/2,-yt/4,yt/2,0,2*Math.PI),h.arc(yt/2,-yt/4,yt/2,0,2*Math.PI),h.arc(0,0,yt/1.5,0,2*Math.PI),h.arc(-yt/1.5,yt/4,yt/2.5,0,2*Math.PI),h.arc(yt/1.5,yt/4,yt/2.5,0,2*Math.PI),h.fill(),h.stroke();break;case H.GEAR:const Ot=n/1.5,ie=8,Ne=n/4;h.beginPath();for(let vt=0;vt<ie;vt++){const Dt=vt*360/ie*Math.PI/180,Kt=Ot*Math.cos(Dt),kt=Ot*Math.sin(Dt),Ht=(Ot+Ne)*Math.cos(Dt),de=(Ot+Ne)*Math.sin(Dt);vt===0?h.moveTo(Kt,kt):h.lineTo(Kt,kt),h.lineTo(Ht,de)}h.closePath(),h.fill(),h.stroke(),h.beginPath(),h.arc(0,0,Ot/2,0,2*Math.PI),h.fill(),h.stroke();break;case H.LIGHTNING:h.beginPath(),h.moveTo(-n/6,-n/1.5),h.lineTo(n/4,-n/6),h.lineTo(0,-n/6),h.lineTo(n/6,n/1.5),h.lineTo(-n/4,n/6),h.lineTo(0,n/6),h.closePath(),h.fill(),h.stroke();break;case H.PIN:h.beginPath(),h.arc(0,-n/4,n/3,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(-n/6,-n/8),h.lineTo(0,n/2),h.lineTo(n/6,-n/8),h.fill(),h.stroke();break;case H.COMPASS:h.beginPath(),h.arc(0,0,n/1.5,0,2*Math.PI),h.fill(),h.stroke(),h.beginPath(),h.moveTo(0,-n/1.8),h.lineTo(n/8,0),h.lineTo(0,n/1.8),h.lineTo(-n/8,0),h.closePath(),h.fillStyle="#ff0000",h.fill(),h.fillStyle=i,h.stroke();break;case H.ANCHOR:const St=n/1.5;h.beginPath(),h.arc(0,St/3,St/2,0,2*Math.PI),h.fill(),h.stroke(),h.fillRect(-n/8,-St/2,n/4,St),h.strokeRect(-n/8,-St/2,n/4,St),h.fillRect(-St/1.5,-St/4,St/.75,n/6),h.strokeRect(-St/1.5,-St/4,St/.75,n/6);break;default:h.beginPath(),h.arc(0,0,n/2,0,2*Math.PI),h.fill(),h.stroke();break}return h.restore(),new A({image:new Vi({img:l,size:[c,c]})})}startAnimation(t,e){const i=t.get("id");if(!i)return;this.stopAnimation(i),this.createPointStyle(this.markersData.get(i));const n=performance.now(),r=a=>{const l=a-n;let h;switch(e){case _n.PULSE:const d=.7+.3*(Math.sin(l*.008)+1)/2;h=this.createScaledStyle(this.markersData.get(i),d);break;case _n.FLASHING:const u=.3+.7*(Math.sin(l*.012)+1)/2;h=this.createBlendedStyle(this.markersData.get(i),u);break;case _n.BREATHING:const f=.3+.7*(Math.sin(l*.005)+1)/2;h=this.createOpacityStyle(this.markersData.get(i),f);break;case _n.LIGHT:const g=.3+.7*(Math.sin(l*.01)+1)/2;h=this.createGlowStyle(this.markersData.get(i),g);break;default:return}t.setStyle(h),t.changed();const c=requestAnimationFrame(r);this.animationFrames.set(i,{startTime:n,frameId:c})},o=requestAnimationFrame(r);this.animationFrames.set(i,{startTime:n,frameId:o})}createScaledStyle(t,e){const i=Math.max(6,(t.pointSize||this.defaultSize)*e),n={...t,pointSize:i};return this.createPointStyle(n)}createBlendedStyle(t,e){const i=Math.max(.3,Math.min(1,e));t.pointColor||M(this.defaultColor);const n=`rgba(255, ${Math.floor(255*i)}, ${Math.floor(255*i)}, 0.9)`,r={...t,pointColor:n};return this.createPointStyle(r)}createOpacityStyle(t,e){const i=Math.max(.2,Math.min(1,e)),r=(t.pointColor||M(this.defaultColor)).replace(/[\d.]+\)$/g,`${i})`),o={...t,pointColor:r};return this.createPointStyle(o)}createGlowStyle(t,e){t.pointColor||M(this.defaultColor);const i=(t.pointSize||this.defaultSize)*(1+e*.5),n={...t,pointSize:i};return this.createPointStyle(n)}stopAnimation(t){const e=this.animationFrames.get(t);e&&(cancelAnimationFrame(e.frameId),this.animationFrames.delete(t))}async createHtmlStyle(t){const e=t.pointColor||M(this.defaultColor),i="#ffffff",n=2,r=t.pointHtml||"",o=t.pointHtmlWidth||100,a=t.pointHtmlHeight||20,l=document.createElement("div");l.style.position="absolute",l.style.visibility="hidden",l.style.top="-9999px",l.style.left="-9999px",l.style.backgroundColor=e,l.style.border=`${n}px solid ${i}`,l.style.borderRadius="6px",l.style.padding="4px 8px",l.style.fontSize="14px",l.style.fontFamily="sans-serif",l.style.whiteSpace="nowrap",l.style.color="#ffffff",l.innerHTML=r,document.body.appendChild(l);const h=Math.max(l.offsetWidth+16,o),c=Math.max(l.offsetHeight+8,a);document.body.removeChild(l);const d=document.createElement("canvas");d.width=h,d.height=c;const u=`
|
|
828
829
|
<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${c}">
|
|
829
830
|
<rect width="100%" height="100%" fill="${e}" rx="6" ry="6" stroke="${i}" stroke-width="${n}"/>
|
|
830
831
|
<foreignObject width="100%" height="100%">
|
|
@@ -845,39 +846,91 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
845
846
|
</div>
|
|
846
847
|
</foreignObject>
|
|
847
848
|
</svg>
|
|
848
|
-
`;return new Promise(f=>{const g=new Image;g.onload=()=>{d.getContext("2d")?.drawImage(g,0,0),f(new A({image:new Vi({img:d,size:[h,c]})})),URL.revokeObjectURL(g.src)},g.src=URL.createObjectURL(new Blob([u],{type:"image/svg+xml"}))})}async addMarker(t){const e=new V({geometry:new rt(ut([t.longitude,t.latitude])),id:t.id,name:t.name||"Marker",bubbleBoxTitle:t.bubbleBoxTitle,bubbleBoxDescription:t.bubbleBoxDescription,bubbleBoxCoverImage:t.bubbleBoxCoverImage,timestamp:t.timestamp||Date.now(),_popupLayer:this.id});if(t.pointHtml){const i=await this.createHtmlStyle(t);e.setStyle(i)}else e.setStyle(this.createPointStyle(t));this.source?.addFeature(e),this.features.set(t.id,e),this.markersData.set(t.id,t),t.pointAnimationType&&this.startAnimation(e,t.pointAnimationType)}removeMarker(t){const e=this.features.get(t);e&&(this.stopAnimation(t),this.source?.removeFeature(e),this.features.delete(t),this.markersData.delete(t),this.currentFeature===e&&this.hidePopup())}async updateMarker(t,e){const i=this.features.get(t),n=this.markersData.get(t);if(!i||!n)return;const r=n.pointAnimationType,o=e.pointAnimationType;e.longitude!==void 0&&e.latitude!==void 0&&i.setGeometry(new rt(ut([e.longitude,e.latitude]))),e.bubbleBoxTitle!==void 0&&i.set("bubbleBoxTitle",e.bubbleBoxTitle),e.bubbleBoxDescription!==void 0&&i.set("bubbleBoxDescription",e.bubbleBoxDescription),e.bubbleBoxCoverImage!==void 0&&i.set("bubbleBoxCoverImage",e.bubbleBoxCoverImage);const a={...n,...e};if(e.pointColor!==void 0||e.pointSize!==void 0||e.pointType!==void 0||e.pointText!==void 0||e.pointHtml!==void 0)if(a.pointHtml){const l=await this.createHtmlStyle(a);i.setStyle(l)}else i.setStyle(this.createPointStyle(a));this.markersData.set(t,a),i.changed(),r!==o?(r&&this.stopAnimation(t),o&&this.startAnimation(i,o)):o&&(e.pointColor!==void 0||e.pointSize!==void 0)&&(this.stopAnimation(t),this.startAnimation(i,o))}showPopup(t,e){this.hidePopup(),this.currentFeature=t;const i=t.get("id"),n=this.markersData.get(i),o=t.getGeometry().getCoordinates();this.view&&o&&this.view.getView().animate({center:o,duration:300}),n&&n.onClick&&n.onClick(n,e);const a=t.getProperties(),l=a.bubbleBoxCoverImage&&a.bubbleBoxCoverImage.trim()!=="",h=a.bubbleBoxTitle&&a.bubbleBoxTitle.trim()!=="",c=a.bubbleBoxDescription&&a.bubbleBoxDescription.trim()!=="",u=(document.body.getAttribute("data-theme")||"dark")==="dark",f=u?"#1e1e1e":"#ffffff",g=u?"#333":"#e0e0e0",p=u?"#fff":"#333",m=u?"#aaa":"#666",y=document.createElement("div");y.style.position="
|
|
849
|
-
|
|
850
|
-
</div>`),w+='<div style="padding: 12px;">',h&&(w+=`<div style="font-size: 14px; font-weight: 600; color: ${p}; margin-bottom: 8px;">${a.bubbleBoxTitle}</div>`),c&&(w+=`<div style="font-size: 12px; color: ${m}; line-height: 1.5;">${a.bubbleBoxDescription}</div>`),w+="</div>",y.innerHTML=w;const E=this.view.getTargetElement();getComputedStyle(E).position==="static"&&(E.style.position="relative"),E.appendChild(y);const x=t.getGeometry(),C=this.view.getPixelFromCoordinate(x.getCoordinates()),T=E.getBoundingClientRect(),_=y.offsetWidth,b=y.offsetHeight;if(!(C[0]>=0&&C[0]<=T.width&&C[1]>=0&&C[1]<=T.height)){y.style.display="none",this.currentPopup=y;return}let P=C[0]-T.left-_/2,L=C[1]-T.top-b-15;L<5&&(L=C[1]-T.top+15),P=Math.max(5,Math.min(P,T.width-_-5)),L=Math.max(5,Math.min(L,T.height-b-5)),y.style.left=`${P}px`,y.style.top=`${L}px`,y.style.display="block",this.currentPopup=y}hidePopup(){this.currentPopup&&(this.currentPopup.remove(),this.currentPopup=null),this.currentFeature=null}clearAllMarkers(){this.animationFrames.forEach((t,e)=>{this.stopAnimation(e)}),this.clear(),this.features.clear(),this.markersData.clear(),this.hidePopup()}getAllMarkers(){const t=[];return this.markersData.forEach((e,i)=>{t.push({...e})}),t}getMarker(t){return this.markersData.get(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.animationFrames.forEach((t,e)=>{this.stopAnimation(e)}),this.updateFrame&&cancelAnimationFrame(this.updateFrame),this.currentHoverTimeout&&(clearTimeout(this.currentHoverTimeout),this.currentHoverTimeout=null),this.view&&this.postRenderHandler&&(this.view.un("postrender",this.postRenderHandler),this.postRenderHandler=null),super.destroy()}}class Pd extends It{constructor(t,e,i,n){super(t,e,Z.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.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:Z.CIRCLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t}createStyle(){return new A({fill:new j({color:M(this.defaultFillColor)}),stroke:new G({color:M(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 Y;this.drawInteraction=new ee({source:e,type:"Circle",style:this.createStyle()}),this.drawInteraction.on("drawend",i=>{const n=i.feature.clone(),r=n.getGeometry(),o=Vt("circle_");if(r instanceof Me){const a=U(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,outlineStyle:this.defaultOutlineStyle})}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.warn(this.t.featureNotFound,t);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({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 Me){const a=U(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 Me){const a=U(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=ut(t.center),i=new Me(e,t.radius),n=new V({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 Me){const r=U(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 Me){const n=U(i.getCenter());return{id:t,center:[n[0],n[1]],radius:i.getRadius(),fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")||"solid"}}}updateCircleStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r);const a=r==="dashed"?[10,10]:void 0;o.setStyle(new A({fill:new j({color:M(e)}),stroke:new G({color:M(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 Yy extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:Z.RECTANGLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createStyle(){return new A({fill:new j({color:M(this.defaultFillColor)}),stroke:new G({color:M(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 ee({source:this.source,type:"Circle",geometryFunction:(e,i)=>{if(i||(i=new it([[[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=Vt("rectangle_");if(n instanceof it){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],[d,u]=U([a,l]);i.set("id",r),i.set("center",[d,u]),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:[d,u],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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({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 it){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=a[2]-a[0],d=a[3]-a[1],[u,f]=U([l,h]),g=i.get("id");this.onEditCompleteCallback&&g&&this.onEditCompleteCallback({id:g,center:[u,f],width:c,height:d})}}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof it){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=a[2]-a[0],d=a[3]-a[1],[u,f]=U([l,h]),g=i.get("id");this.onEditCompleteCallback&&g&&this.onEditCompleteCallback({id:g,center:[u,f],width:c,height:d})}}),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=ut(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 it(r),a=new V({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 it){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,d]=U([o,a]);t.push({id:i,center:[c,d],width:l,height:h})}}),t}getRectangle(t){const e=this.features.get(t);if(!e)return;const i=e.getGeometry();if(i instanceof it){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]=U([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 A({fill:new j({color:M(e)}),stroke:new G({color:M(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 Zy extends It{constructor(t,e,i){super(t,e,Z.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.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:Z.TRIANGLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createStyle(){return new A({fill:new j({color:M(this.defaultFillColor)}),stroke:new G({color:M(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 ee({source:this.source,type:"LineString",maxPoints:2,geometryFunction:(i,n)=>{if(e=i,e.length<2)return n||(n=new it([[[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 it([[[0,0],[0,0],[0,0],[0,0]]])),n;const c=(r[0]+o[0])/2,d=(r[1]+o[1])/2,u=h*Math.sqrt(3)/2;let f=-l,g=a;const p=Math.sqrt(f*f+g*g);p>0&&(f/=p,g/=p);const m=c+f*u,y=d+g*u,w=[[m,y],[r[0],r[1]],[o[0],o[1]],[m,y]];return n?n.setCoordinates([w]):n=new it([w]),n},style:this.createStyle()}),this.drawInteraction.on("drawend",i=>{const n=i.feature,r=n.getGeometry(),o=Vt("triangle_");if(r instanceof it){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]),[d,u]=U([l,h]);n.set("id",o),n.set("center",[d,u]),n.set("size",c),n.setStyle(this.createStyle()),this.features.set(o,n),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:o,center:[d,u],size:c,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({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 it){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]),[d,u]=U([l,h]),f=i.get("id"),g=this.createEquilateralTriangle([l,h],c),p=new it([g]);i.setGeometry(p),this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,center:[d,u],size:c})}}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof it){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]),[d,u]=U([l,h]),f=i.get("id");this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,center:[d,u],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=ut(t.center),i=this.createEquilateralTriangle(e,t.size),n=new it([i]),r=new V({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 it){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]=U([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 it){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]=U([r,o]);return{id:t,center:[l,h],size:a,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")||"solid"}}}updateTriangleStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r);const a=r==="dashed"?[10,10]:void 0;o.setStyle(new A({fill:new j({color:M(e)}),stroke:new G({color:M(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 Ky extends It{constructor(t,e,i){super(t,e,Z.LINE_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.defaultColor=i?.defaultColor||[255,193,7,1],this.defaultWidth=i?.defaultWidth||3,this.defaultStyle=i?.defaultStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.LINE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("color")||this.defaultColor,i=t?.get("width")||this.defaultWidth,r=(t?.get("style")||this.defaultStyle)==="dashed"?[10,10]:void 0;return new A({stroke:new G({color:M(e),width:i,lineDash:r})})}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 Y;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:2,geometryFunction:(i,n)=>{if(i&&i.length>=2){const r=i[0],o=i[1];n?n.setCoordinates([r,o]):n=new pt([r,o])}return n},style:this.getStyleForFeature()}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry(),r=Vt("line_");if(n instanceof pt){const o=n.getCoordinates();if(o&&o.length>=2){const[a,l]=o[0],[h,c]=o[1],[d,u]=U([a,l]),[f,g]=U([h,c]),p=new V({geometry:n.clone(),id:r,startPoint:[d,u],endPoint:[f,g]});p.set("color",this.defaultColor),p.set("width",this.defaultWidth),p.set("style",this.defaultStyle),this.source?.addFeature(p),this.features.set(r,p),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:r,startPoint:[d,u],endPoint:[f,g],color:this.defaultColor,width:this.defaultWidth,style:this.defaultStyle})}}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof pt){const l=a.getCoordinates();if(l.length>=2){const[h,c]=U(l[0]),[d,u]=U(l[1]),f=i.get("id");i.set("startPoint",[h,c]),i.set("endPoint",[d,u]),i.changed(),this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,startPoint:[h,c],endPoint:[d,u],color:i.get("color"),width:i.get("width"),style:i.get("style")})}}this.mapView?.render()};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction.dispose?.(),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addLine(t){const e=ut(t.startPoint),i=ut(t.endPoint),n=new pt([e,i]),r=new V({geometry:n,id:t.id,startPoint:t.startPoint,endPoint:t.endPoint});r.set("color",t.color||this.defaultColor),r.set("width",t.width||this.defaultWidth),r.set("style",t.style||this.defaultStyle),this.source?.addFeature(r),this.features.set(t.id,r)}removeLine(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllLines(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i.toString(),startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")})}),t}getLine(t){const e=this.features.get(t);if(e)return{id:t,startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")}}updateLineStyle(t,e,i,n){const r=this.features.get(t);r&&(r.set("color",e),r.set("width",i),r.set("style",n),r.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.lines&&(this.clearAll(),t.lines.forEach(e=>this.addLine(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class qy extends It{constructor(t,e,i,n){super(t,e,Z.BEZIER_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.tempPoints=[],this.defaultColor=i?.defaultColor||[156,39,176,1],this.defaultWidth=i?.defaultWidth||3,this.defaultStyle=i?.defaultStyle||"solid",this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:r=>this.getStyleForFeature(r),properties:{id:t,name:e,type:Z.BEZIER_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t}getStyleForFeature(t){const e=t?.get("color")||this.defaultColor,i=t?.get("width")||this.defaultWidth,r=(t?.get("style")||this.defaultStyle)==="dashed"?[10,10]:void 0;return new A({stroke:new G({color:M(e),width:i,lineDash:r})})}computeBezierPoints(t,e,i,n,r=100){const o=[];for(let a=0;a<=r;a++){const l=a/r,h=1-l,c=h*h*h*t[0]+3*h*h*l*e[0]+3*h*l*l*i[0]+l*l*l*n[0],d=h*h*h*t[1]+3*h*h*l*e[1]+3*h*l*l*i[1]+l*l*l*n[1];o.push([c,d])}return o}createBezierGeometry(t,e,i,n){const r=this.computeBezierPoints(t,e,i,n);return new pt(r)}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.stopEdit(),this.onDrawCompleteCallback=t||null,this.tempPoints=[];const e=new Y;let i=[];const n=new Y,r=new bt({source:n,style:a=>a.get("type")==="control-line"?new A({stroke:new G({color:"rgba(255,0,0,0.4)",width:1,lineDash:[5,5]})}):new A({stroke:new G({color:M(this.defaultColor),width:this.defaultWidth,lineDash:this.defaultStyle==="dashed"?[10,10]:void 0})})});this.mapView?.addLayer(r);const o=a=>{if(n.clear(),a.length>=2)for(let l=0;l<a.length-1;l++){const h=new V({geometry:new pt([a[l],a[l+1]]),type:"control-line"});n.addFeature(h)}};this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:4,freehand:!1,style:new A({stroke:new G({color:M(this.defaultColor),width:this.defaultWidth,lineDash:this.defaultStyle==="dashed"?[10,10]:void 0})}),geometryFunction:(a,l)=>{if(i=a,o(i),i.length===0)return l;if(i.length===1)return l?l.setCoordinates([i[0],i[0]]):l=new pt([i[0],i[0]]),l;if(i.length===2)return l?l.setCoordinates([i[0],i[1]]):l=new pt([i[0],i[1]]),l;if(i.length===3){const h=new pt([i[0],i[1],i[2]]);return l?l.setCoordinates([i[0],i[1],i[2]]):l=h,l}if(i.length===4){const[h,c,d,u]=i,f=this.computeBezierPoints(h,c,d,u,100);return l?l.setCoordinates(f):l=new pt(f),l}return l}}),this.drawInteraction.on("drawstart",()=>{i=[],e.clear(),n.clear()}),this.drawInteraction.on("drawend",a=>{if(this.mapView?.removeLayer(r),i.length===4){const[l,h,c,d]=i,u=this.createBezierGeometry(l,h,c,d),f=Vt("bezier_"),[g,p]=U(l),[m,y]=U(h),[w,E]=U(c),[x,C]=U(d),T=new V({geometry:u,id:f,startPoint:[g,p],controlPoint1:[m,y],controlPoint2:[w,E],endPoint:[x,C]});T.set("color",this.defaultColor),T.set("width",this.defaultWidth),T.set("style",this.defaultStyle),this.source?.addFeature(T),this.features.set(f,T),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:f,startPoint:[g,p],controlPoint1:[m,y],controlPoint2:[w,E],endPoint:[x,C],color:this.defaultColor,width:this.defaultWidth,style:this.defaultStyle})}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(),this.stopDraw();const i=this.features.get(t);if(!i){console.warn(this.t.bezierFeatureNotFound,t);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof pt){const l=a.getCoordinates();if(l.length>0){const[h,c]=U(l[0]),[d,u]=U(l[l.length-1]),f=i.get("startPoint"),g=i.get("controlPoint1"),p=i.get("controlPoint2"),m=i.get("endPoint");if(f&&m){const y=ut(f),w=ut(m),E=ut([h,c]),x=ut([d,u]),C=E[0]-y[0],T=E[1]-y[1],_=w[0]-y[0],b=w[1]-y[1],S=x[0]-E[0],P=x[1]-E[1],L=Math.sqrt(_*_+b*b),k=Math.sqrt(S*S+P*P),F=L>0?k/L:1;if(g){const N=ut(g),tt=y[0]+(N[0]-y[0])*F+C,et=y[1]+(N[1]-y[1])*F+T,[ht,ot]=U([tt,et]);i.set("controlPoint1",[ht,ot])}if(p){const N=ut(p),tt=y[0]+(N[0]-y[0])*F+C,et=y[1]+(N[1]-y[1])*F+T,[ht,ot]=U([tt,et]);i.set("controlPoint2",[ht,ot])}i.set("startPoint",[h,c]),i.set("endPoint",[d,u]);const O=ut([h,c]),R=i.get("controlPoint1"),B=i.get("controlPoint2"),D=ut([d,u]);if(R&&B){const N=ut(R),tt=ut(B),et=this.createBezierGeometry([O[0],O[1]],[N[0],N[1]],[tt[0],tt[1]],[D[0],D[1]]);i.setGeometry(et)}i.changed();const z=i.get("id");this.onEditCompleteCallback&&z&&this.onEditCompleteCallback({id:z,startPoint:[h,c],controlPoint1:i.get("controlPoint1"),controlPoint2:i.get("controlPoint2"),endPoint:[d,u],color:i.get("color"),width:i.get("width"),style:i.get("style")})}}}this.mapView?.render()};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction.dispose?.(),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addBezier(t){const e=ut(t.startPoint),i=ut(t.controlPoint1),n=ut(t.controlPoint2),r=ut(t.endPoint),o=this.createBezierGeometry([e[0],e[1]],[i[0],i[1]],[n[0],n[1]],[r[0],r[1]]),a=new V({geometry:o,id:t.id,startPoint:t.startPoint,controlPoint1:t.controlPoint1,controlPoint2:t.controlPoint2,endPoint:t.endPoint});a.set("color",t.color||this.defaultColor),a.set("width",t.width||this.defaultWidth),a.set("style",t.style||this.defaultStyle),this.source?.addFeature(a),this.features.set(t.id,a)}removeBezier(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllBeziers(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i.toString(),startPoint:e.get("startPoint"),controlPoint1:e.get("controlPoint1"),controlPoint2:e.get("controlPoint2"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")})}),t}getBezier(t){const e=this.features.get(t);if(e)return{id:t,startPoint:e.get("startPoint"),controlPoint1:e.get("controlPoint1"),controlPoint2:e.get("controlPoint2"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")}}updateBezierStyle(t,e,i,n){const r=this.features.get(t);r&&(r.set("color",e),r.set("width",i),r.set("style",n),r.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.tempPoints=[],this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.beziers&&(this.clearAll(),t.beziers.forEach(e=>this.addBezier(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class Jy extends It{constructor(t,e,i){super(t,e,Z.SECTOR_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.tempPoints=[],this.defaultFillColor=i?.defaultFillColor||[33,150,243,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[33,150,243,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.SECTOR_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("fillColor")||this.defaultFillColor,i=t?.get("outlineColor")||this.defaultOutlineColor,n=t?.get("outlineWidth")||this.defaultOutlineWidth,o=(t?.get("outlineStyle")||this.defaultOutlineStyle)==="dashed"?[10,10]:void 0;return new A({fill:new j({color:M(e)}),stroke:new G({color:M(i),width:n,lineDash:o})})}createSectorGeometry(t,e,i,n,r=64){const o=[[t[0],t[1]]];let a=i,l=n;a>l&&(l+=2*Math.PI);const h=(l-a)/r;for(let c=0;c<=r;c++){const d=a+c*h,u=t[0]+e*Math.cos(d),f=t[1]+e*Math.sin(d);o.push([u,f])}return o.push([t[0],t[1]]),new it([o])}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 Y;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:3,freehand:!1,style:new A({stroke:new G({color:M(this.defaultOutlineColor),width:this.defaultOutlineWidth,lineDash:this.defaultOutlineStyle==="dashed"?[10,10]:void 0})})}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry();if(n instanceof pt){const r=n.getCoordinates();if(r.length===3){const o=r[0],a=r[1],l=r[2],h=o[0]-a[0],c=o[1]-a[1],d=Math.sqrt(h*h+c*c),u=Math.atan2(c,h),f=l[0]-a[0],g=l[1]-a[1];let p=Math.atan2(g,f),m=p-u;if(m<0&&(m+=2*Math.PI),m>Math.PI){m=2*Math.PI-m;const y=p,w=p+m,E=Vt("sector_"),[x,C]=U(a),T=this.createSectorGeometry([a[0],a[1]],d,y,w),_=new V({geometry:T,id:E,center:[x,C],radius:d,startAngle:y,endAngle:w});_.set("fillColor",this.defaultFillColor),_.set("outlineColor",this.defaultOutlineColor),_.set("outlineWidth",this.defaultOutlineWidth),_.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(_),this.features.set(E,_),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:E,center:[x,C],radius:d,startAngle:y,endAngle:w,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}else{const y=u,w=u+m,E=Vt("sector_"),[x,C]=U(a),T=this.createSectorGeometry([a[0],a[1]],d,y,w),_=new V({geometry:T,id:E,center:[x,C],radius:d,startAngle:y,endAngle:w});_.set("fillColor",this.defaultFillColor),_.set("outlineColor",this.defaultOutlineColor),_.set("outlineWidth",this.defaultOutlineWidth),_.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(_),this.features.set(E,_),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:E,center:[x,C],radius:d,startAngle:y,endAngle:w,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}}}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=i.get("startAngle")||0,r=i.get("endAngle")||Math.PI*2,o=new Y;o.addFeature(i);const a=o.getFeaturesCollection();this.transformInteraction=new _e({features:a,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const l=()=>{const h=i.getGeometry();if(h instanceof it){const c=h.getExtent(),d=(c[0]+c[2])/2,u=(c[1]+c[3])/2,f=Math.max(c[2]-c[0],c[3]-c[1])/2,[g,p]=U([d,u]);i.set("center",[g,p]),i.set("radius",f),i.set("startAngle",n),i.set("endAngle",r),i.changed();const m=i.get("id");this.onEditCompleteCallback&&m&&this.onEditCompleteCallback({id:m,center:[g,p],radius:f,startAngle:n,endAngle:r,fillColor:i.get("fillColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth"),outlineStyle:i.get("outlineStyle")})}this.mapView?.render()};this.transformInteraction.on("scaleend",l),this.transformInteraction.on("translateend",l),this.transformInteraction.on("rotateend",l),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction.dispose?.(),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addSector(t){const e=ut(t.center),i=this.createSectorGeometry([e[0],e[1]],t.radius,t.startAngle,t.endAngle),n=new V({geometry:i,id:t.id,center:t.center,radius:t.radius,startAngle:t.startAngle,endAngle:t.endAngle});n.set("fillColor",t.fillColor||this.defaultFillColor),n.set("outlineColor",t.outlineColor||this.defaultOutlineColor),n.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),n.set("outlineStyle",t.outlineStyle||this.defaultOutlineStyle),this.source?.addFeature(n),this.features.set(t.id,n)}removeSector(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllSectors(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i.toString(),center:e.get("center"),radius:e.get("radius"),startAngle:e.get("startAngle")||0,endAngle:e.get("endAngle")||Math.PI*2,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")})}),t}getSector(t){const e=this.features.get(t);if(e)return{id:t,center:e.get("center"),radius:e.get("radius"),startAngle:e.get("startAngle")||0,endAngle:e.get("endAngle")||Math.PI*2,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")}}updateSectorStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r),o.setStyle(this.getStyleForFeature(o)),o.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.tempPoints=[],this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.sectors&&(this.clearAll(),t.sectors.forEach(e=>this.addSector(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class Id extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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 ee({source:this.source,type:"LineString"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates(),o=r.map(u=>{const[f,g]=U(u);return{longitude:f,latitude:g}});let a=0;for(let u=0;u<o.length-1;u++)a+=this.calculateDistance(o[u],o[u+1]);const l=Vt("dist_"),h=Math.floor(o.length/2),c=a>=1e3?`${(a/1e3).toFixed(2)} km`:`${a.toFixed(0)} m`,d=new V({geometry:new rt([r[h][0],r[h][1]]),measurementId:l});d.setStyle(new A({text:new te({text:c,font:"14px sans-serif",fill:new j({color:"#ffffff"}),stroke:new G({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 A({stroke:new G({color:M(this.lineColor),width:this.lineWidth})})),this.source?.addFeature(d),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 pt([[t.longitude,t.latitude],[e.longitude,e.latitude]]);return nc(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 Ld extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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 ee({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,p]=U(f);return{longitude:g,latitude:p}}).slice(0,-1),a=sc(n),l=Vt("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 d=a>=1e6?`${(a/1e6).toFixed(2)} km²`:`${a.toFixed(0)} m²`,u=new V({geometry:new rt([h,c]),measurementId:l});u.setStyle(new A({text:new te({text:d,font:"14px sans-serif",fill:new j({color:"#ffffff"}),stroke:new G({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 A({fill:new j({color:M(this.fillColor)}),stroke:new G({color:M(this.lineColor),width:this.lineWidth})})),this.source?.addFeature(u),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){}}class Qy extends It{constructor(t,e,i){super(t,e,Z.POINT_COORDINATE_PICK,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.picks=new Map,this.onCompleteCallback=null,this.mapView=null,this.features=new Map,this.textColor=i?.textColor||[0,200,255,1],this.textSize=i?.textSize||12,this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.POINT_COORDINATE_PICK},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.t=i?.t||null}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startPick(t){this.stopPick(),this.onCompleteCallback=t||null,this.drawInteraction=new ee({source:this.source,type:"Point"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates(),[o,a]=U(r),l=Vt("coord_"),h=Date.now();i.setStyle(new A({image:new Le({radius:6,fill:new j({color:"#00aaff"}),stroke:new G({color:"#ffffff",width:2})})})),i.set("id",l),i.set("type","point_pick"),this.features.set(l,i);const c=new V({geometry:new rt(r),id:l+"_label",longitude:o,latitude:a,timestamp:h});c.set("type","point_pick"),c.setStyle(new A({text:new te({text:this.t?.pointPick.label_text||"Point Pick",font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})})),this.source?.addFeature(c),this.features.set(l+"_label",c);const d={id:l,longitude:o,latitude:a,timestamp:h};this.picks.set(l,d),this.onCompleteCallback&&this.onCompleteCallback(d),this.stopPick()}),this.mapView?.addInteraction(this.drawInteraction)}stopPick(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}removeCoordinate(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t));const i=this.features.get(t+"_label");return i&&(this.source?.removeFeature(i),this.features.delete(t+"_label")),this.picks.delete(t),!0}clearAllCoordinates(){this.clear(),this.features.clear(),this.picks.clear(),this.stopPick()}getAllCoordinates(){return Array.from(this.picks.values())}getCoordinate(t){return this.picks.get(t)}highlightCoordinate(t){this.features.forEach((e,i)=>{const n=i===t;e.setStyle(new A({text:new te({text:this.t?.pointPick.label_text||"Point Pick",font:`${this.textSize}px sans-serif`,fill:new j({color:M(n?[255,170,0,1]:this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}clearHighlight(){this.features.forEach(t=>{t.setStyle(new A({text:new te({text:this.t?.pointPick.label_text||"Point Pick",font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}stopDraw(){this.stopPick()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return!1}setEditable(t){t||this.stopPick()}stopEdit(){this.stopPick()}getEditingId(){return null}cancelDraw(){this.stopPick()}cancelEdit(){this.stopPick()}updateData(t){}destroy(){this.stopPick(),super.destroy()}}const Lt={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>',Point:'<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"/><circle cx="12" cy="12" r="3"/></svg>',Line2:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="2" y1="12" x2="22" y2="12"/></svg>',Polygon:'<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 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>'};class t_{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=`
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
849
|
+
`;return new Promise(f=>{const g=new Image;g.onload=()=>{d.getContext("2d")?.drawImage(g,0,0),f(new A({image:new Vi({img:d,size:[h,c]})})),URL.revokeObjectURL(g.src)},g.src=URL.createObjectURL(new Blob([u],{type:"image/svg+xml"}))})}async addMarker(t){const e=new V({geometry:new rt(ut([t.longitude,t.latitude])),id:t.id,name:t.name||"Marker",bubbleBoxTitle:t.bubbleBoxTitle,bubbleBoxDescription:t.bubbleBoxDescription,bubbleBoxCoverImage:t.bubbleBoxCoverImage,timestamp:t.timestamp||Date.now(),_popupLayer:this.id});if(t.pointHtml){const i=await this.createHtmlStyle(t);e.setStyle(i)}else e.setStyle(this.createPointStyle(t));this.source?.addFeature(e),this.features.set(t.id,e),this.markersData.set(t.id,t),t.pointAnimationType&&this.startAnimation(e,t.pointAnimationType)}removeMarker(t){const e=this.features.get(t);e&&(this.stopAnimation(t),this.source?.removeFeature(e),this.features.delete(t),this.markersData.delete(t),this.currentFeature===e&&this.hidePopup())}async updateMarker(t,e){const i=this.features.get(t),n=this.markersData.get(t);if(!i||!n)return;const r=n.pointAnimationType,o=e.pointAnimationType;e.longitude!==void 0&&e.latitude!==void 0&&i.setGeometry(new rt(ut([e.longitude,e.latitude]))),e.bubbleBoxTitle!==void 0&&i.set("bubbleBoxTitle",e.bubbleBoxTitle),e.bubbleBoxDescription!==void 0&&i.set("bubbleBoxDescription",e.bubbleBoxDescription),e.bubbleBoxCoverImage!==void 0&&i.set("bubbleBoxCoverImage",e.bubbleBoxCoverImage);const a={...n,...e};if(e.pointColor!==void 0||e.pointSize!==void 0||e.pointType!==void 0||e.pointText!==void 0||e.pointHtml!==void 0)if(a.pointHtml){const l=await this.createHtmlStyle(a);i.setStyle(l)}else i.setStyle(this.createPointStyle(a));this.markersData.set(t,a),i.changed(),r!==o?(r&&this.stopAnimation(t),o&&this.startAnimation(i,o)):o&&(e.pointColor!==void 0||e.pointSize!==void 0)&&(this.stopAnimation(t),this.startAnimation(i,o))}showPopup(t,e){this.hidePopup(),this.currentFeature=t;const i=t.get("id"),n=this.markersData.get(i),o=t.getGeometry().getCoordinates();this.view&&o&&this.view.getView().animate({center:o,duration:300}),n&&n.onClick&&n.onClick(n,e);const a=t.getProperties(),l=a.bubbleBoxCoverImage&&a.bubbleBoxCoverImage.trim()!=="",h=a.bubbleBoxTitle&&a.bubbleBoxTitle.trim()!=="",c=a.bubbleBoxDescription&&a.bubbleBoxDescription.trim()!=="",u=(document.body.getAttribute("data-theme")||"dark")==="dark",f=u?"#1e1e1e":"#ffffff",g=u?"#333":"#e0e0e0",p=u?"#fff":"#333",m=u?"#aaa":"#666",y=document.createElement("div");y.style.position="fixed",y.style.zIndex="10000",y.style.background=f,y.style.border=`1px solid ${g}`,y.style.borderRadius="8px",y.style.boxShadow="0 4px 12px rgba(0,0,0,0.3)",y.style.width=`${this.popupWidth}px`,y.style.maxWidth=`${this.popupWidth}px`,y.style.overflow="hidden";let x="";l&&(x+=`<div style="height: ${this.coverImageHeight}px; overflow: hidden;">
|
|
850
|
+
<img src="${a.bubbleBoxCoverImage}" style="width: 100%; height: 100%; object-fit: cover;" />
|
|
851
|
+
</div>`),x+='<div style="padding: 12px;">',h&&(x+=`<div style="font-size: 14px; font-weight: 600; color: ${p}; margin-bottom: 8px;">${this.escapeHtml(a.bubbleBoxTitle)}</div>`),c&&(x+=`<div style="font-size: 12px; color: ${m}; line-height: 1.5;">${this.escapeHtml(a.bubbleBoxDescription)}</div>`),x+="</div>",y.innerHTML=x;const E=t.getGeometry(),w=this.view.getPixelFromCoordinate(E.getCoordinates()),C=this.view.getTargetElement(),v=y.offsetWidth,_=y.offsetHeight;let b=w[0]-v/2,S=w[1]-_-15;b=Math.max(10,Math.min(b,window.innerWidth-v-10)),S=Math.max(10,Math.min(S,window.innerHeight-_-10)),y.style.left=`${b}px`,y.style.top=`${S}px`,C.appendChild(y),this.currentPopup=y}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}hidePopup(){this.currentPopup&&(this.currentPopup.parentNode&&this.currentPopup.parentNode.removeChild(this.currentPopup),this.currentPopup=null),this.currentFeature=null}clearAllMarkers(){this.animationFrames.forEach((t,e)=>{this.stopAnimation(e)}),this.clear(),this.features.clear(),this.markersData.clear(),this.hidePopup()}getAllMarkers(){const t=[];return this.markersData.forEach((e,i)=>{t.push({...e})}),t}getMarker(t){return this.markersData.get(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()),i=this.currentPopup.offsetWidth,n=this.currentPopup.offsetHeight;let r=e[0]-i/2,o=e[1]-n-15;if(r=Math.max(10,Math.min(r,window.innerWidth-i-10)),o=Math.max(10,Math.min(o,window.innerHeight-n-10)),!(e[0]>=0&&e[0]<=window.innerWidth&&e[1]>=0&&e[1]<=window.innerHeight)){this.currentPopup.style.display="none";return}this.currentPopup.style.display="block",this.currentPopup.style.left=`${r}px`,this.currentPopup.style.top=`${o}px`}))}destroy(){this.animationFrames.forEach((t,e)=>{this.stopAnimation(e)}),this.updateFrame&&cancelAnimationFrame(this.updateFrame),this.currentHoverTimeout&&(clearTimeout(this.currentHoverTimeout),this.currentHoverTimeout=null),this.view&&this.postRenderHandler&&(this.view.un("postrender",this.postRenderHandler),this.postRenderHandler=null),super.destroy()}}class Ld extends It{constructor(t,e,i,n){super(t,e,Z.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.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:Z.CIRCLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t}createStyle(){return new A({fill:new j({color:M(this.defaultFillColor)}),stroke:new G({color:M(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 Y;this.drawInteraction=new ee({source:e,type:"Circle",style:this.createStyle()}),this.drawInteraction.on("drawend",i=>{const n=i.feature.clone(),r=n.getGeometry(),o=Vt("circle_");if(r instanceof Me){const a=U(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,outlineStyle:this.defaultOutlineStyle})}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.warn(this.t.featureNotFound,t);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({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 Me){const a=U(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 Me){const a=U(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=ut(t.center),i=new Me(e,t.radius),n=new V({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 Me){const r=U(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 Me){const n=U(i.getCenter());return{id:t,center:[n[0],n[1]],radius:i.getRadius(),fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")||"solid"}}}updateCircleStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r);const a=r==="dashed"?[10,10]:void 0;o.setStyle(new A({fill:new j({color:M(e)}),stroke:new G({color:M(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 Ky extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:Z.RECTANGLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createStyle(){return new A({fill:new j({color:M(this.defaultFillColor)}),stroke:new G({color:M(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 ee({source:this.source,type:"Circle",geometryFunction:(e,i)=>{if(i||(i=new it([[[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=Vt("rectangle_");if(n instanceof it){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],[d,u]=U([a,l]);i.set("id",r),i.set("center",[d,u]),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:[d,u],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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({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 it){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=a[2]-a[0],d=a[3]-a[1],[u,f]=U([l,h]),g=i.get("id");this.onEditCompleteCallback&&g&&this.onEditCompleteCallback({id:g,center:[u,f],width:c,height:d})}}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof it){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=a[2]-a[0],d=a[3]-a[1],[u,f]=U([l,h]),g=i.get("id");this.onEditCompleteCallback&&g&&this.onEditCompleteCallback({id:g,center:[u,f],width:c,height:d})}}),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=ut(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 it(r),a=new V({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 it){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,d]=U([o,a]);t.push({id:i,center:[c,d],width:l,height:h})}}),t}getRectangle(t){const e=this.features.get(t);if(!e)return;const i=e.getGeometry();if(i instanceof it){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]=U([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 A({fill:new j({color:M(e)}),stroke:new G({color:M(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 qy extends It{constructor(t,e,i){super(t,e,Z.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.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:Z.TRIANGLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createStyle(){return new A({fill:new j({color:M(this.defaultFillColor)}),stroke:new G({color:M(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 ee({source:this.source,type:"LineString",maxPoints:2,geometryFunction:(i,n)=>{if(e=i,e.length<2)return n||(n=new it([[[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 it([[[0,0],[0,0],[0,0],[0,0]]])),n;const c=(r[0]+o[0])/2,d=(r[1]+o[1])/2,u=h*Math.sqrt(3)/2;let f=-l,g=a;const p=Math.sqrt(f*f+g*g);p>0&&(f/=p,g/=p);const m=c+f*u,y=d+g*u,x=[[m,y],[r[0],r[1]],[o[0],o[1]],[m,y]];return n?n.setCoordinates([x]):n=new it([x]),n},style:this.createStyle()}),this.drawInteraction.on("drawend",i=>{const n=i.feature,r=n.getGeometry(),o=Vt("triangle_");if(r instanceof it){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]),[d,u]=U([l,h]);n.set("id",o),n.set("center",[d,u]),n.set("size",c),n.setStyle(this.createStyle()),this.features.set(o,n),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:o,center:[d,u],size:c,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({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 it){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]),[d,u]=U([l,h]),f=i.get("id"),g=this.createEquilateralTriangle([l,h],c),p=new it([g]);i.setGeometry(p),this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,center:[d,u],size:c})}}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof it){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]),[d,u]=U([l,h]),f=i.get("id");this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,center:[d,u],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=ut(t.center),i=this.createEquilateralTriangle(e,t.size),n=new it([i]),r=new V({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 it){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]=U([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 it){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]=U([r,o]);return{id:t,center:[l,h],size:a,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")||"solid"}}}updateTriangleStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r);const a=r==="dashed"?[10,10]:void 0;o.setStyle(new A({fill:new j({color:M(e)}),stroke:new G({color:M(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 Jy extends It{constructor(t,e,i){super(t,e,Z.LINE_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.defaultColor=i?.defaultColor||[255,193,7,1],this.defaultWidth=i?.defaultWidth||3,this.defaultStyle=i?.defaultStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.LINE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("color")||this.defaultColor,i=t?.get("width")||this.defaultWidth,r=(t?.get("style")||this.defaultStyle)==="dashed"?[10,10]:void 0;return new A({stroke:new G({color:M(e),width:i,lineDash:r})})}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 Y;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:2,geometryFunction:(i,n)=>{if(i&&i.length>=2){const r=i[0],o=i[1];n?n.setCoordinates([r,o]):n=new pt([r,o])}return n},style:this.getStyleForFeature()}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry(),r=Vt("line_");if(n instanceof pt){const o=n.getCoordinates();if(o&&o.length>=2){const[a,l]=o[0],[h,c]=o[1],[d,u]=U([a,l]),[f,g]=U([h,c]),p=new V({geometry:n.clone(),id:r,startPoint:[d,u],endPoint:[f,g]});p.set("color",this.defaultColor),p.set("width",this.defaultWidth),p.set("style",this.defaultStyle),this.source?.addFeature(p),this.features.set(r,p),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:r,startPoint:[d,u],endPoint:[f,g],color:this.defaultColor,width:this.defaultWidth,style:this.defaultStyle})}}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof pt){const l=a.getCoordinates();if(l.length>=2){const[h,c]=U(l[0]),[d,u]=U(l[1]),f=i.get("id");i.set("startPoint",[h,c]),i.set("endPoint",[d,u]),i.changed(),this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,startPoint:[h,c],endPoint:[d,u],color:i.get("color"),width:i.get("width"),style:i.get("style")})}}this.mapView?.render()};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction.dispose?.(),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addLine(t){const e=ut(t.startPoint),i=ut(t.endPoint),n=new pt([e,i]),r=new V({geometry:n,id:t.id,startPoint:t.startPoint,endPoint:t.endPoint});r.set("color",t.color||this.defaultColor),r.set("width",t.width||this.defaultWidth),r.set("style",t.style||this.defaultStyle),this.source?.addFeature(r),this.features.set(t.id,r)}removeLine(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllLines(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i.toString(),startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")})}),t}getLine(t){const e=this.features.get(t);if(e)return{id:t,startPoint:e.get("startPoint"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")}}updateLineStyle(t,e,i,n){const r=this.features.get(t);r&&(r.set("color",e),r.set("width",i),r.set("style",n),r.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.lines&&(this.clearAll(),t.lines.forEach(e=>this.addLine(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class Qy extends It{constructor(t,e,i,n){super(t,e,Z.BEZIER_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.tempPoints=[],this.defaultColor=i?.defaultColor||[156,39,176,1],this.defaultWidth=i?.defaultWidth||3,this.defaultStyle=i?.defaultStyle||"solid",this.t=n||Hi("zh"),this.source=new Y,this.layer=new bt({source:this.source,style:r=>this.getStyleForFeature(r),properties:{id:t,name:e,type:Z.BEZIER_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setTranslations(t){this.t=t}getStyleForFeature(t){const e=t?.get("color")||this.defaultColor,i=t?.get("width")||this.defaultWidth,r=(t?.get("style")||this.defaultStyle)==="dashed"?[10,10]:void 0;return new A({stroke:new G({color:M(e),width:i,lineDash:r})})}computeBezierPoints(t,e,i,n,r=100){const o=[];for(let a=0;a<=r;a++){const l=a/r,h=1-l,c=h*h*h*t[0]+3*h*h*l*e[0]+3*h*l*l*i[0]+l*l*l*n[0],d=h*h*h*t[1]+3*h*h*l*e[1]+3*h*l*l*i[1]+l*l*l*n[1];o.push([c,d])}return o}createBezierGeometry(t,e,i,n){const r=this.computeBezierPoints(t,e,i,n);return new pt(r)}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.stopEdit(),this.onDrawCompleteCallback=t||null,this.tempPoints=[];const e=new Y;let i=[];const n=new Y,r=new bt({source:n,style:a=>a.get("type")==="control-line"?new A({stroke:new G({color:"rgba(255,0,0,0.4)",width:1,lineDash:[5,5]})}):new A({stroke:new G({color:M(this.defaultColor),width:this.defaultWidth,lineDash:this.defaultStyle==="dashed"?[10,10]:void 0})})});this.mapView?.addLayer(r);const o=a=>{if(n.clear(),a.length>=2)for(let l=0;l<a.length-1;l++){const h=new V({geometry:new pt([a[l],a[l+1]]),type:"control-line"});n.addFeature(h)}};this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:4,freehand:!1,style:new A({stroke:new G({color:M(this.defaultColor),width:this.defaultWidth,lineDash:this.defaultStyle==="dashed"?[10,10]:void 0})}),geometryFunction:(a,l)=>{if(i=a,o(i),i.length===0)return l;if(i.length===1)return l?l.setCoordinates([i[0],i[0]]):l=new pt([i[0],i[0]]),l;if(i.length===2)return l?l.setCoordinates([i[0],i[1]]):l=new pt([i[0],i[1]]),l;if(i.length===3){const h=new pt([i[0],i[1],i[2]]);return l?l.setCoordinates([i[0],i[1],i[2]]):l=h,l}if(i.length===4){const[h,c,d,u]=i,f=this.computeBezierPoints(h,c,d,u,100);return l?l.setCoordinates(f):l=new pt(f),l}return l}}),this.drawInteraction.on("drawstart",()=>{i=[],e.clear(),n.clear()}),this.drawInteraction.on("drawend",a=>{if(this.mapView?.removeLayer(r),i.length===4){const[l,h,c,d]=i,u=this.createBezierGeometry(l,h,c,d),f=Vt("bezier_"),[g,p]=U(l),[m,y]=U(h),[x,E]=U(c),[w,C]=U(d),v=new V({geometry:u,id:f,startPoint:[g,p],controlPoint1:[m,y],controlPoint2:[x,E],endPoint:[w,C]});v.set("color",this.defaultColor),v.set("width",this.defaultWidth),v.set("style",this.defaultStyle),this.source?.addFeature(v),this.features.set(f,v),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:f,startPoint:[g,p],controlPoint1:[m,y],controlPoint2:[x,E],endPoint:[w,C],color:this.defaultColor,width:this.defaultWidth,style:this.defaultStyle})}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(),this.stopDraw();const i=this.features.get(t);if(!i){console.warn(this.t.bezierFeatureNotFound,t);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const o=()=>{const a=i.getGeometry();if(a instanceof pt){const l=a.getCoordinates();if(l.length>0){const[h,c]=U(l[0]),[d,u]=U(l[l.length-1]),f=i.get("startPoint"),g=i.get("controlPoint1"),p=i.get("controlPoint2"),m=i.get("endPoint");if(f&&m){const y=ut(f),x=ut(m),E=ut([h,c]),w=ut([d,u]),C=E[0]-y[0],v=E[1]-y[1],_=x[0]-y[0],b=x[1]-y[1],S=w[0]-E[0],P=w[1]-E[1],L=Math.sqrt(_*_+b*b),k=Math.sqrt(S*S+P*P),F=L>0?k/L:1;if(g){const N=ut(g),tt=y[0]+(N[0]-y[0])*F+C,et=y[1]+(N[1]-y[1])*F+v,[ht,ot]=U([tt,et]);i.set("controlPoint1",[ht,ot])}if(p){const N=ut(p),tt=y[0]+(N[0]-y[0])*F+C,et=y[1]+(N[1]-y[1])*F+v,[ht,ot]=U([tt,et]);i.set("controlPoint2",[ht,ot])}i.set("startPoint",[h,c]),i.set("endPoint",[d,u]);const O=ut([h,c]),R=i.get("controlPoint1"),B=i.get("controlPoint2"),D=ut([d,u]);if(R&&B){const N=ut(R),tt=ut(B),et=this.createBezierGeometry([O[0],O[1]],[N[0],N[1]],[tt[0],tt[1]],[D[0],D[1]]);i.setGeometry(et)}i.changed();const z=i.get("id");this.onEditCompleteCallback&&z&&this.onEditCompleteCallback({id:z,startPoint:[h,c],controlPoint1:i.get("controlPoint1"),controlPoint2:i.get("controlPoint2"),endPoint:[d,u],color:i.get("color"),width:i.get("width"),style:i.get("style")})}}}this.mapView?.render()};this.transformInteraction.on("scaleend",o),this.transformInteraction.on("translateend",o),this.transformInteraction.on("rotateend",o),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction.dispose?.(),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addBezier(t){const e=ut(t.startPoint),i=ut(t.controlPoint1),n=ut(t.controlPoint2),r=ut(t.endPoint),o=this.createBezierGeometry([e[0],e[1]],[i[0],i[1]],[n[0],n[1]],[r[0],r[1]]),a=new V({geometry:o,id:t.id,startPoint:t.startPoint,controlPoint1:t.controlPoint1,controlPoint2:t.controlPoint2,endPoint:t.endPoint});a.set("color",t.color||this.defaultColor),a.set("width",t.width||this.defaultWidth),a.set("style",t.style||this.defaultStyle),this.source?.addFeature(a),this.features.set(t.id,a)}removeBezier(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllBeziers(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i.toString(),startPoint:e.get("startPoint"),controlPoint1:e.get("controlPoint1"),controlPoint2:e.get("controlPoint2"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")})}),t}getBezier(t){const e=this.features.get(t);if(e)return{id:t,startPoint:e.get("startPoint"),controlPoint1:e.get("controlPoint1"),controlPoint2:e.get("controlPoint2"),endPoint:e.get("endPoint"),color:e.get("color"),width:e.get("width"),style:e.get("style")}}updateBezierStyle(t,e,i,n){const r=this.features.get(t);r&&(r.set("color",e),r.set("width",i),r.set("style",n),r.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.tempPoints=[],this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.beziers&&(this.clearAll(),t.beziers.forEach(e=>this.addBezier(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class t_ extends It{constructor(t,e,i){super(t,e,Z.SECTOR_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.tempPoints=[],this.defaultFillColor=i?.defaultFillColor||[33,150,243,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[33,150,243,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.defaultOutlineStyle=i?.defaultOutlineStyle||"solid",this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.SECTOR_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("fillColor")||this.defaultFillColor,i=t?.get("outlineColor")||this.defaultOutlineColor,n=t?.get("outlineWidth")||this.defaultOutlineWidth,o=(t?.get("outlineStyle")||this.defaultOutlineStyle)==="dashed"?[10,10]:void 0;return new A({fill:new j({color:M(e)}),stroke:new G({color:M(i),width:n,lineDash:o})})}createSectorGeometry(t,e,i,n,r=64){const o=[[t[0],t[1]]];let a=i,l=n;a>l&&(l+=2*Math.PI);const h=(l-a)/r;for(let c=0;c<=r;c++){const d=a+c*h,u=t[0]+e*Math.cos(d),f=t[1]+e*Math.sin(d);o.push([u,f])}return o.push([t[0],t[1]]),new it([o])}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 Y;this.drawInteraction=new ee({source:e,type:"LineString",maxPoints:3,freehand:!1,style:new A({stroke:new G({color:M(this.defaultOutlineColor),width:this.defaultOutlineWidth,lineDash:this.defaultOutlineStyle==="dashed"?[10,10]:void 0})})}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry();if(n instanceof pt){const r=n.getCoordinates();if(r.length===3){const o=r[0],a=r[1],l=r[2],h=o[0]-a[0],c=o[1]-a[1],d=Math.sqrt(h*h+c*c),u=Math.atan2(c,h),f=l[0]-a[0],g=l[1]-a[1];let p=Math.atan2(g,f),m=p-u;if(m<0&&(m+=2*Math.PI),m>Math.PI){m=2*Math.PI-m;const y=p,x=p+m,E=Vt("sector_"),[w,C]=U(a),v=this.createSectorGeometry([a[0],a[1]],d,y,x),_=new V({geometry:v,id:E,center:[w,C],radius:d,startAngle:y,endAngle:x});_.set("fillColor",this.defaultFillColor),_.set("outlineColor",this.defaultOutlineColor),_.set("outlineWidth",this.defaultOutlineWidth),_.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(_),this.features.set(E,_),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:E,center:[w,C],radius:d,startAngle:y,endAngle:x,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}else{const y=u,x=u+m,E=Vt("sector_"),[w,C]=U(a),v=this.createSectorGeometry([a[0],a[1]],d,y,x),_=new V({geometry:v,id:E,center:[w,C],radius:d,startAngle:y,endAngle:x});_.set("fillColor",this.defaultFillColor),_.set("outlineColor",this.defaultOutlineColor),_.set("outlineWidth",this.defaultOutlineWidth),_.set("outlineStyle",this.defaultOutlineStyle),this.source?.addFeature(_),this.features.set(E,_),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:E,center:[w,C],radius:d,startAngle:y,endAngle:x,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth,outlineStyle:this.defaultOutlineStyle})}}}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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=i.get("startAngle")||0,r=i.get("endAngle")||Math.PI*2,o=new Y;o.addFeature(i);const a=o.getFeaturesCollection();this.transformInteraction=new _e({features:a,translate:!0,scale:!0,rotate:!0,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0);const l=()=>{const h=i.getGeometry();if(h instanceof it){const c=h.getExtent(),d=(c[0]+c[2])/2,u=(c[1]+c[3])/2,f=Math.max(c[2]-c[0],c[3]-c[1])/2,[g,p]=U([d,u]);i.set("center",[g,p]),i.set("radius",f),i.set("startAngle",n),i.set("endAngle",r),i.changed();const m=i.get("id");this.onEditCompleteCallback&&m&&this.onEditCompleteCallback({id:m,center:[g,p],radius:f,startAngle:n,endAngle:r,fillColor:i.get("fillColor"),outlineColor:i.get("outlineColor"),outlineWidth:i.get("outlineWidth"),outlineStyle:i.get("outlineStyle")})}this.mapView?.render()};this.transformInteraction.on("scaleend",l),this.transformInteraction.on("translateend",l),this.transformInteraction.on("rotateend",l),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction.dispose?.(),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addSector(t){const e=ut(t.center),i=this.createSectorGeometry([e[0],e[1]],t.radius,t.startAngle,t.endAngle),n=new V({geometry:i,id:t.id,center:t.center,radius:t.radius,startAngle:t.startAngle,endAngle:t.endAngle});n.set("fillColor",t.fillColor||this.defaultFillColor),n.set("outlineColor",t.outlineColor||this.defaultOutlineColor),n.set("outlineWidth",t.outlineWidth||this.defaultOutlineWidth),n.set("outlineStyle",t.outlineStyle||this.defaultOutlineStyle),this.source?.addFeature(n),this.features.set(t.id,n)}removeSector(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllSectors(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i.toString(),center:e.get("center"),radius:e.get("radius"),startAngle:e.get("startAngle")||0,endAngle:e.get("endAngle")||Math.PI*2,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")})}),t}getSector(t){const e=this.features.get(t);if(e)return{id:t,center:e.get("center"),radius:e.get("radius"),startAngle:e.get("startAngle")||0,endAngle:e.get("endAngle")||Math.PI*2,fillColor:e.get("fillColor"),outlineColor:e.get("outlineColor"),outlineWidth:e.get("outlineWidth"),outlineStyle:e.get("outlineStyle")}}updateSectorStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("fillColor",e),o.set("outlineColor",i),o.set("outlineWidth",n),o.set("outlineStyle",r),o.setStyle(this.getStyleForFeature(o)),o.changed(),this.mapView?.render())}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.tempPoints=[],this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.sectors&&(this.clearAll(),t.sectors.forEach(e=>this.addSector(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}}class Dd extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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 ee({source:this.source,type:"LineString"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates(),o=r.map(u=>{const[f,g]=U(u);return{longitude:f,latitude:g}});let a=0;for(let u=0;u<o.length-1;u++)a+=this.calculateDistance(o[u],o[u+1]);const l=Vt("dist_"),h=Math.floor(o.length/2),c=a>=1e3?`${(a/1e3).toFixed(2)} km`:`${a.toFixed(0)} m`,d=new V({geometry:new rt([r[h][0],r[h][1]]),measurementId:l});d.setStyle(new A({text:new te({text:c,font:"14px sans-serif",fill:new j({color:"#ffffff"}),stroke:new G({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 A({stroke:new G({color:M(this.lineColor),width:this.lineWidth})})),this.source?.addFeature(d),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 pt([[t.longitude,t.latitude],[e.longitude,e.latitude]]);return rc(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 kd extends It{constructor(t,e,i){super(t,e,Z.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 Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.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 ee({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,p]=U(f);return{longitude:g,latitude:p}}).slice(0,-1),a=oc(n),l=Vt("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 d=a>=1e6?`${(a/1e6).toFixed(2)} km²`:`${a.toFixed(0)} m²`,u=new V({geometry:new rt([h,c]),measurementId:l});u.setStyle(new A({text:new te({text:d,font:"14px sans-serif",fill:new j({color:"#ffffff"}),stroke:new G({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 A({fill:new j({color:M(this.fillColor)}),stroke:new G({color:M(this.lineColor),width:this.lineWidth})})),this.source?.addFeature(u),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){}}class e_ extends It{constructor(t,e,i){super(t,e,Z.POINT_COORDINATE_PICK,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.picks=new Map,this.onCompleteCallback=null,this.mapView=null,this.features=new Map,this.textColor=i?.textColor||[0,200,255,1],this.textSize=i?.textSize||12,this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.POINT_COORDINATE_PICK},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.t=i?.t||null}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startPick(t){this.stopPick(),this.onCompleteCallback=t||null,this.drawInteraction=new ee({source:this.source,type:"Point"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates(),[o,a]=U(r),l=Vt("coord_"),h=Date.now();i.setStyle(new A({image:new Le({radius:6,fill:new j({color:"#00aaff"}),stroke:new G({color:"#ffffff",width:2})})})),i.set("id",l),i.set("type","point_pick"),this.features.set(l,i);const c=new V({geometry:new rt(r),id:l+"_label",longitude:o,latitude:a,timestamp:h});c.set("type","point_pick"),c.setStyle(new A({text:new te({text:this.t?.pointPick.label_text||"Point Pick",font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})})),this.source?.addFeature(c),this.features.set(l+"_label",c);const d={id:l,longitude:o,latitude:a,timestamp:h};this.picks.set(l,d),this.onCompleteCallback&&this.onCompleteCallback(d),this.stopPick()}),this.mapView?.addInteraction(this.drawInteraction)}stopPick(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}removeCoordinate(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t));const i=this.features.get(t+"_label");return i&&(this.source?.removeFeature(i),this.features.delete(t+"_label")),this.picks.delete(t),!0}clearAllCoordinates(){this.clear(),this.features.clear(),this.picks.clear(),this.stopPick()}getAllCoordinates(){return Array.from(this.picks.values())}getCoordinate(t){return this.picks.get(t)}highlightCoordinate(t){this.features.forEach((e,i)=>{const n=i===t;e.setStyle(new A({text:new te({text:this.t?.pointPick.label_text||"Point Pick",font:`${this.textSize}px sans-serif`,fill:new j({color:M(n?[255,170,0,1]:this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}clearHighlight(){this.features.forEach(t=>{t.setStyle(new A({text:new te({text:this.t?.pointPick.label_text||"Point Pick",font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}stopDraw(){this.stopPick()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return!1}setEditable(t){t||this.stopPick()}stopEdit(){this.stopPick()}getEditingId(){return null}cancelDraw(){this.stopPick()}cancelEdit(){this.stopPick()}updateData(t){}destroy(){this.stopPick(),super.destroy()}}const Lt={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>',Point:'<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"/><circle cx="12" cy="12" r="3"/></svg>',Line2:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="2" y1="12" x2="22" y2="12"/></svg>',Polygon:'<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 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>'};class i_{constructor(t){this.buttons=new Map,this.scrollUpBtn=null,this.scrollDownBtn=null,this.isScrolling=!1,this.scrollTimer=null,this.options=t,this.element=this.createElement(),t.container.appendChild(this.element),this.scrollContainer=this.element.querySelector(".toolbar-scroll-container"),this.attachScrollEvents(),this.checkScrollPosition()}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.cssText=`
|
|
852
|
+
position: absolute;
|
|
853
|
+
top: 10px;
|
|
854
|
+
right: 10px;
|
|
855
|
+
z-index: 100;
|
|
856
|
+
display: flex;
|
|
857
|
+
flex-direction: column;
|
|
858
|
+
gap: 4px;
|
|
859
|
+
max-height: calc(100% - 20px);
|
|
860
|
+
background: ${t?"rgba(30,30,30,0.95)":"rgba(255,255,255,0.95)"};
|
|
861
|
+
border-radius: 8px;
|
|
862
|
+
padding: 4px;
|
|
863
|
+
backdrop-filter: blur(4px);
|
|
864
|
+
user-select: none;
|
|
865
|
+
`,this.scrollUpBtn=this.createScrollButton("▲",this.options.t.topScroll||"Top Scroll"),e.appendChild(this.scrollUpBtn),this.scrollUpBtn.style.display="none";const i=document.createElement("div");i.className="toolbar-scroll-container",i.style.cssText=`
|
|
866
|
+
overflow-y: auto;
|
|
867
|
+
overflow-x: hidden;
|
|
868
|
+
max-height: calc(100% - 70px);
|
|
869
|
+
display: flex;
|
|
870
|
+
flex-direction: column;
|
|
871
|
+
gap: 8px;
|
|
872
|
+
padding: 0 2px;
|
|
873
|
+
scrollbar-width: none;
|
|
874
|
+
-ms-overflow-style: none;
|
|
875
|
+
`;const n=document.createElement("style");n.textContent=`
|
|
876
|
+
.toolbar-scroll-container::-webkit-scrollbar {
|
|
877
|
+
display: none;
|
|
878
|
+
}
|
|
879
|
+
`,i.appendChild(n);const r=p=>`
|
|
880
|
+
width: 30px;
|
|
881
|
+
height: 30px;
|
|
882
|
+
background: ${p?"#00aaff":t?"#2d2d2d":"#f0f0f0"};
|
|
883
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
884
|
+
border-radius: 6px;
|
|
885
|
+
color: ${p?"white":t?"#ccc":"#666"};
|
|
886
|
+
cursor: pointer;
|
|
887
|
+
display: flex;
|
|
888
|
+
align-items: center;
|
|
889
|
+
justify-content: center;
|
|
890
|
+
transition: all 0.2s;
|
|
891
|
+
flex-shrink: 0;
|
|
892
|
+
`,o=this.createButton(Lt.Layers,"layers",r);o.title=this.options.t.layersTitle,i.appendChild(o),this.buttons.set("layers",o);const a=this.createButton(Lt.Basemap,"basemap",r);a.title=this.options.t.basemapTitle,i.appendChild(a),this.buttons.set("basemap",a);const l=this.createButton(Lt.Draw,"draw",r);l.title=this.options.t.drawToolsTitle,i.appendChild(l),this.buttons.set("draw",l);const h=this.createButton(Lt.Tools,"tools",r);h.title=this.options.t.toolsTitle,i.appendChild(h),this.buttons.set("tools",h);const c=document.createElement("button");c.style.cssText=r(!1),c.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
893
|
+
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
|
|
894
|
+
<line x1="3" y1="9" x2="21" y2="9"/>
|
|
895
|
+
<line x1="3" y1="15" x2="21" y2="15"/>
|
|
896
|
+
<line x1="9" y1="3" x2="9" y2="21"/>
|
|
897
|
+
<line x1="15" y1="3" x2="15" y2="21"/>
|
|
898
|
+
</svg>`,c.title=this.options.t.coordinateData,c.onclick=()=>{this.options.onShowCoordinatePickingDataPanel?.()},i.appendChild(c);const d=document.createElement("div");d.style.cssText=`height: 1px; background: ${t?"#444":"#ddd"}; margin: 4px 0; flex-shrink: 0;`,i.appendChild(d);const u=this.createButton(Lt.ZoomIn,null,r);u.title=this.options.t.zoomInTitle,u.onclick=()=>this.options.onZoomIn(),i.appendChild(u);const f=this.createButton(Lt.ZoomOut,null,r);f.title=this.options.t.zoomOutTitle,f.onclick=()=>this.options.onZoomOut(),i.appendChild(f);const g=this.createButton(Lt.Locate,null,r);return g.title=this.options.t.locateMe,g.onclick=()=>this.options.onLocate(),i.appendChild(g),e.appendChild(i),this.scrollDownBtn=this.createScrollButton("▼",this.options.t.bottomScroll||"Bottom Scroll"),e.appendChild(this.scrollDownBtn),this.scrollDownBtn.style.display="none",e}createScrollButton(t,e){const i=this.options.theme==="dark",n=document.createElement("button");return n.innerHTML=t,n.title=e,n.style.cssText=`
|
|
899
|
+
width: 30px;
|
|
900
|
+
height: 30px;
|
|
901
|
+
background: ${i?"rgba(30,30,30,0.95)":"rgba(255,255,255,0.95)"};
|
|
902
|
+
border: 1px solid ${i?"#444":"#ddd"};
|
|
903
|
+
border-radius: 6px;
|
|
904
|
+
color: ${i?"#ccc":"#666"};
|
|
905
|
+
cursor: pointer;
|
|
906
|
+
display: flex;
|
|
907
|
+
align-items: center;
|
|
908
|
+
justify-content: center;
|
|
909
|
+
transition: all 0.2s;
|
|
910
|
+
font-size: 12px;
|
|
911
|
+
backdrop-filter: blur(4px);
|
|
912
|
+
margin: 0;
|
|
913
|
+
flex-shrink: 0;
|
|
914
|
+
`,n.onmouseenter=()=>{n.style.background=i?"#3d3d3d":"#e8e8e8",n.style.color=i?"#fff":"#333"},n.onmouseleave=()=>{n.style.background=i?"rgba(30,30,30,0.95)":"rgba(255,255,255,0.95)",n.style.color=i?"#ccc":"#666"},n}injectScrollbarStyles(t){const e="earthview-toolbar-scroll-styles";if(document.getElementById(e))return;const i=t?"#555":"#ccc",n=t?"#2d2d2d":"#f0f0f0",r=`
|
|
915
|
+
.toolbar-scroll-container {
|
|
916
|
+
scrollbar-width: thin;
|
|
917
|
+
scrollbar-color: ${i} ${n};
|
|
918
|
+
}
|
|
919
|
+
.toolbar-scroll-container::-webkit-scrollbar {
|
|
920
|
+
width: 4px;
|
|
921
|
+
}
|
|
922
|
+
.toolbar-scroll-container::-webkit-scrollbar-track {
|
|
923
|
+
background: ${n};
|
|
924
|
+
border-radius: 4px;
|
|
925
|
+
}
|
|
926
|
+
.toolbar-scroll-container::-webkit-scrollbar-thumb {
|
|
927
|
+
background: ${i};
|
|
928
|
+
border-radius: 4px;
|
|
929
|
+
}
|
|
930
|
+
.toolbar-scroll-container::-webkit-scrollbar-thumb:hover {
|
|
931
|
+
background: ${i};
|
|
932
|
+
}
|
|
933
|
+
`,o=document.createElement("style");o.id=e,o.textContent=r,document.head.appendChild(o)}attachScrollEvents(){if(!this.scrollContainer)return;this.scrollContainer.addEventListener("scroll",()=>{this.checkScrollPosition()}),this.scrollUpBtn&&(this.scrollUpBtn.onclick=()=>{this.scrollContainer.scrollBy({top:-80,behavior:"smooth"}),this.checkScrollPosition()}),this.scrollDownBtn&&(this.scrollDownBtn.onclick=()=>{this.scrollContainer.scrollBy({top:80,behavior:"smooth"}),this.checkScrollPosition()}),new ResizeObserver(()=>{this.checkScrollPosition()}).observe(this.scrollContainer)}checkScrollPosition(){if(!this.scrollContainer||!this.scrollUpBtn||!this.scrollDownBtn)return;const{scrollTop:t,scrollHeight:e,clientHeight:i}=this.scrollContainer;if(!(e>i+2)){this.scrollUpBtn.style.display="none",this.scrollDownBtn.style.display="none";return}this.scrollUpBtn.style.display=t>5?"flex":"none",this.scrollDownBtn.style.display=t+i<e-5?"flex":"none"}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=>`
|
|
881
934
|
width: 30px;
|
|
882
935
|
height: 30px;
|
|
883
936
|
background: ${n?"#00aaff":e?"#2d2d2d":"#f0f0f0"};
|
|
@@ -889,68 +942,92 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
889
942
|
align-items: center;
|
|
890
943
|
justify-content: center;
|
|
891
944
|
transition: all 0.2s;
|
|
892
|
-
|
|
945
|
+
flex-shrink: 0;
|
|
946
|
+
`;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="transparent";const i=document.getElementById("earthview-toolbar-scroll-styles");i&&i.remove(),this.injectScrollbarStyles(e);const n=o=>`
|
|
893
947
|
width: 30px;
|
|
894
948
|
height: 30px;
|
|
895
|
-
background: ${
|
|
949
|
+
background: ${o?"#00aaff":e?"#2d2d2d":"#f0f0f0"};
|
|
896
950
|
border: 1px solid ${e?"#444":"#ddd"};
|
|
897
951
|
border-radius: 6px;
|
|
898
|
-
color: ${
|
|
952
|
+
color: ${o?"white":e?"#ccc":"#666"};
|
|
899
953
|
cursor: pointer;
|
|
900
954
|
display: flex;
|
|
901
955
|
align-items: center;
|
|
902
956
|
justify-content: center;
|
|
903
957
|
transition: all 0.2s;
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
958
|
+
flex-shrink: 0;
|
|
959
|
+
`;this.buttons.forEach((o,a)=>{const l=a===this.options.activePopup;o.style.cssText=n(l)});const r=`
|
|
960
|
+
background: ${e?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.9)"};
|
|
961
|
+
border: 1px solid ${e?"#444":"#ddd"};
|
|
962
|
+
color: ${e?"#ccc":"#666"};
|
|
963
|
+
`;this.scrollUpBtn&&(this.scrollUpBtn.style.cssText+=r),this.scrollDownBtn&&(this.scrollDownBtn.style.cssText+=r),this.checkScrollPosition()}destroy(){this.element.remove()}}class lr{constructor(t){this.options=t,this.element=this.createElement()}createElement(){const t=this.options.theme==="dark",e=document.createElement("div"),i=328;e.style.cssText=`
|
|
964
|
+
position: absolute;
|
|
965
|
+
top: 10px;
|
|
966
|
+
right: 60px;
|
|
967
|
+
width: 200px;
|
|
968
|
+
max-height: ${i}px;
|
|
969
|
+
background: ${t?"#1e1e1e":"#ffffff"};
|
|
970
|
+
border: 1px solid ${t?"#333":"#e0e0e0"};
|
|
971
|
+
border-radius: 8px;
|
|
972
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
973
|
+
z-index: 200;
|
|
974
|
+
overflow: hidden;
|
|
975
|
+
display: flex;
|
|
976
|
+
flex-direction: column;
|
|
977
|
+
user-select: none;
|
|
978
|
+
`;let n=328;if(this.element?.parentElement){const l=this.element.parentElement.getBoundingClientRect();n=Math.min(328,l.height-80)}e.style.cssText=`
|
|
979
|
+
position: absolute;
|
|
980
|
+
top: 10px;
|
|
981
|
+
right: 60px;
|
|
982
|
+
width: 200px;
|
|
983
|
+
max-height: ${Math.max(150,n)}px;
|
|
984
|
+
background: ${t?"#1e1e1e":"#ffffff"};
|
|
985
|
+
border: 1px solid ${t?"#333":"#e0e0e0"};
|
|
986
|
+
border-radius: 8px;
|
|
987
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
988
|
+
z-index: 200;
|
|
989
|
+
overflow: hidden;
|
|
990
|
+
display: flex;
|
|
991
|
+
flex-direction: column;
|
|
992
|
+
`;const r=document.createElement("div");r.style.cssText=`
|
|
917
993
|
display: flex;
|
|
918
994
|
justify-content: space-between;
|
|
919
995
|
align-items: center;
|
|
920
996
|
padding: 2px 10px;
|
|
921
997
|
border-bottom: 1px solid ${t?"#333":"#e0e0e0"};
|
|
922
998
|
background: ${t?"#2d2d2d":"#f5f5f5"};
|
|
923
|
-
`;const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
`,
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
999
|
+
`;const o=document.createElement("span");o.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 12px; font-weight: 500;`,o.textContent=this.options.title,r.appendChild(o);const a=document.createElement("button");return a.style.cssText=`
|
|
1000
|
+
background: none;
|
|
1001
|
+
border: none;
|
|
1002
|
+
cursor: pointer;
|
|
1003
|
+
padding: 4px;
|
|
1004
|
+
color: ${t?"#ccc":"#666"};
|
|
1005
|
+
font-size: 16px;
|
|
1006
|
+
`,a.innerHTML="✕",a.title=this.options.t.close,a.onclick=()=>this.options.onClose(),r.appendChild(a),e.appendChild(r),this.contentContainer=document.createElement("div"),this.contentContainer.style.cssText=`
|
|
1007
|
+
flex: 1;
|
|
1008
|
+
overflow-y: auto;
|
|
1009
|
+
padding: 4px 0;
|
|
1010
|
+
min-height: 0;
|
|
1011
|
+
`,this.contentContainer.className="earthview-popup-scroll",e.appendChild(this.contentContainer),e}injectScrollbarStyles(t){const e=this.element.parentElement;if(!e)return;const i="earthview-popup-scroll-styles";if(e.querySelector(`#${i}`))return;const n=t?"#555":"#ccc",r=t?"#2d2d2d":"#f0f0f0",a=`
|
|
935
1012
|
.earthview-popup-scroll {
|
|
936
1013
|
scrollbar-width: thin;
|
|
937
|
-
scrollbar-color: ${
|
|
1014
|
+
scrollbar-color: ${n} ${r};
|
|
938
1015
|
}
|
|
939
1016
|
.earthview-popup-scroll::-webkit-scrollbar {
|
|
940
1017
|
width: 4px;
|
|
941
1018
|
}
|
|
942
1019
|
.earthview-popup-scroll::-webkit-scrollbar-track {
|
|
943
|
-
background: ${
|
|
1020
|
+
background: ${r};
|
|
944
1021
|
border-radius: 4px;
|
|
945
1022
|
}
|
|
946
1023
|
.earthview-popup-scroll::-webkit-scrollbar-thumb {
|
|
947
|
-
background: ${
|
|
1024
|
+
background: ${n};
|
|
948
1025
|
border-radius: 4px;
|
|
949
1026
|
}
|
|
950
1027
|
.earthview-popup-scroll::-webkit-scrollbar-thumb:hover {
|
|
951
1028
|
background: ${t?"#777":"#aaa"};
|
|
952
1029
|
}
|
|
953
|
-
|
|
1030
|
+
`,l=document.createElement("style");l.id=i,l.textContent=a,e.appendChild(l)}getContentContainer(){return this.contentContainer}appendChild(t){this.contentContainer.appendChild(t)}onAttached(){const t=this.options.theme==="dark";this.injectScrollbarStyles(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=this.element.parentElement;if(n){const r=n.querySelector("#earthview-popup-scroll-styles");r&&r.remove(),this.injectScrollbarStyles(e)}}destroy(){this.element.remove()}getElement(){return this.element}}class n_{constructor(t){this.activeCategory=qt.DATA_LAYER,this.featureListPanel=null,this.featureDetailPanel=null,this.currentFeatureListLayerId=null,this.currentFeatureId=null,this.SYSTEM_LAYER_IDS=["circle-draw","rectangle-draw","triangle-draw","distance-measurement","area-measurement"],this.options=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
954
1031
|
width: 100%;
|
|
955
1032
|
height: 100%;
|
|
956
1033
|
`,t}isSystemLayer(t){return this.SYSTEM_LAYER_IDS.includes(t)}getLayerDisplayName(t){switch(t.id){case"circle-draw":return this.options.t.circleDrawLayer;case"rectangle-draw":return this.options.t.rectangleDrawLayer;case"triangle-draw":return this.options.t.triangleDrawLayer;case"distance-measurement":return this.options.t.distanceMeasurementLayer;case"area-measurement":return this.options.t.areaMeasurementLayer;case"freehand-draw":return this.options.t.freehandDrawLayer;case"ellipse-draw":return this.options.t.ellipseDrawLayer;case"marker-draw":return this.options.t.markerDrawLayer;case"text-draw":return this.options.t.textDrawLayer;case"image-draw":return this.options.t.imageDrawLayer;case"arrow-draw":return this.options.t.arrowDrawLayer;case"line-draw":return this.options.t.lineDrawLayer;case"bezier-draw":return this.options.t.bezierDrawLayer;case"sector-draw":return this.options.t.sectorDrawLayer;case"point-coordinate-pick":return this.options.t.pointPickLayer;case"line-coordinate-pick":return this.options.t.linePickLayer;case"polygon-coordinate-pick":return this.options.t.polygonPickLayer;default:return t.name}}getLayerClassification(t){const e=["circle-draw","rectangle-draw","triangle-draw","freehand-draw","ellipse-draw","marker-draw","text-draw","image-draw","arrow-draw","line-draw","bezier-draw","sector-draw"],i=["distance-measurement","area-measurement","point-coordinate-pick","line-coordinate-pick","polygon-coordinate-pick"];return e.includes(t)?qt.DRAW_LAYER:i.includes(t)?qt.TOOL_LAYER:qt.DATA_LAYER}getClassificationIcon(t){switch(t){case qt.DATA_LAYER:return"📊";case qt.DRAW_LAYER:return"✏️";case qt.TOOL_LAYER:return"🛠️";default:return"📁"}}getClassificationLabel(t){switch(t){case qt.DATA_LAYER:return this.options.t.dataLayers||"Data Layers";case qt.DRAW_LAYER:return this.options.t.drawLayers||"Draw Layers";case qt.TOOL_LAYER:return this.options.t.toolLayers||"Tool Layers";default:return""}}getClassificationOrder(){return[qt.DATA_LAYER,qt.DRAW_LAYER,qt.TOOL_LAYER]}render(){if(this.element.innerHTML="",this.options.layerList.length===0){const n=document.createElement("div");n.style.cssText=`
|
|
@@ -1003,12 +1080,12 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1003
1080
|
color: ${t?"#888":"#999"};
|
|
1004
1081
|
font-size: 11px;
|
|
1005
1082
|
border-bottom: 1px solid ${t?"#333":"#eee"};
|
|
1006
|
-
`,e.textContent=this.options.t.noLayers,e}showFeatureListPanel(t,e){this.hideFeatureListPanel(),this.hideFeatureDetailPanel(),this.currentFeatureListLayerId=t;const i=this.options.theme==="dark",n=this.element.getBoundingClientRect();this.featureListPanel=document.createElement("div"),this.featureListPanel.style.cssText=`
|
|
1007
|
-
position:
|
|
1008
|
-
left: ${n.left-267}px;
|
|
1009
|
-
top: ${
|
|
1083
|
+
`,e.textContent=this.options.t.noLayers,e}showFeatureListPanel(t,e){this.hideFeatureListPanel(),this.hideFeatureDetailPanel(),this.currentFeatureListLayerId=t;const i=this.options.theme==="dark",n=this.element.getBoundingClientRect();let r=this.element.closest(".earthview-container");r||(r=document.body);const o=r.getBoundingClientRect();let a=n.top-o.top-38,l=330;if(a+l+38>o.height){const m=o.height-a-48;if(m>100)l=m;else{const y=n.top-o.top-10;y>200?a=y-l-10:l=Math.max(100,m)}}a<5&&(a=5),this.featureListPanel=document.createElement("div"),this.featureListPanel.style.cssText=`
|
|
1084
|
+
position: absolute;
|
|
1085
|
+
left: ${n.left-o.left-267}px;
|
|
1086
|
+
top: ${a}px;
|
|
1010
1087
|
width: 260px;
|
|
1011
|
-
max-height:
|
|
1088
|
+
max-height: ${l}px;
|
|
1012
1089
|
background: ${i?"#1e1e1e":"#ffffff"};
|
|
1013
1090
|
border: 1px solid ${i?"#333":"#e0e0e0"};
|
|
1014
1091
|
border-radius: 8px;
|
|
@@ -1017,7 +1094,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1017
1094
|
overflow: hidden;
|
|
1018
1095
|
display: flex;
|
|
1019
1096
|
flex-direction: column;
|
|
1020
|
-
`;const
|
|
1097
|
+
`;const c=document.createElement("div");c.style.cssText=`
|
|
1021
1098
|
display: flex;
|
|
1022
1099
|
justify-content: space-between;
|
|
1023
1100
|
align-items: center;
|
|
@@ -1025,23 +1102,23 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1025
1102
|
background: ${i?"#2d2d2d":"#f5f5f5"};
|
|
1026
1103
|
border-bottom: 1px solid ${i?"#333":"#e0e0e0"};
|
|
1027
1104
|
flex-shrink: 0;
|
|
1028
|
-
`;const
|
|
1105
|
+
`;const d=document.createElement("span");d.style.cssText=`color: ${i?"#fff":"#333"}; font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;`,d.textContent=`${e} - ${this.options.t.coordinateData||"coordinateData"}`,c.appendChild(d);const u=document.createElement("button");u.style.cssText=`
|
|
1029
1106
|
background: none;
|
|
1030
1107
|
border: none;
|
|
1031
1108
|
cursor: pointer;
|
|
1032
1109
|
padding: 4px;
|
|
1033
1110
|
color: ${i?"#ccc":"#666"};
|
|
1034
1111
|
font-size: 16px;
|
|
1035
|
-
`,
|
|
1112
|
+
`,u.innerHTML="✕",u.onclick=()=>this.hideFeatureListPanel(),c.appendChild(u),this.featureListPanel.appendChild(c);const f=document.createElement("div");f.style.cssText=`
|
|
1036
1113
|
flex: 1;
|
|
1037
1114
|
overflow-y: auto;
|
|
1038
1115
|
min-height: 0;
|
|
1039
|
-
`,
|
|
1116
|
+
`,f.className="earthview-popup-scroll";const g=this.options.onGetLayerFeatures?this.options.onGetLayerFeatures(t):[];if(g.length===0){const m=document.createElement("div");m.style.cssText=`
|
|
1040
1117
|
padding: 16px;
|
|
1041
1118
|
text-align: center;
|
|
1042
1119
|
color: ${i?"#888":"#999"};
|
|
1043
1120
|
font-size: 12px;
|
|
1044
|
-
`,
|
|
1121
|
+
`,m.textContent=this.options.t.noDataAvailable||"noDataAvailable",f.appendChild(m)}else g.forEach((m,y)=>{const x=this.createFeatureItem(m,y,t,i);f.appendChild(x)});this.featureListPanel.appendChild(f),r.appendChild(this.featureListPanel);const p=m=>{this.featureListPanel&&!this.featureListPanel.contains(m.target)&&!this.element.contains(m.target)&&(this.hideFeatureListPanel(),document.removeEventListener("click",p))};setTimeout(()=>{document.addEventListener("click",p)},100)}createFeatureItem(t,e,i,n){const r=document.createElement("div");r.style.cssText=`
|
|
1045
1122
|
display: flex;
|
|
1046
1123
|
align-items: center;
|
|
1047
1124
|
justify-content: space-between;
|
|
@@ -1068,114 +1145,115 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1068
1145
|
transition: all 0.2s;
|
|
1069
1146
|
color: ${n?"#00aaff":"#0066cc"};
|
|
1070
1147
|
margin-left: 8px;
|
|
1071
|
-
`,h.textContent=this.options.t.details||"details",h.onmouseenter=()=>{h.style.background=n?"#444":"#e0e0e0"},h.onmouseleave=()=>{h.style.background="none"},h.onclick=c=>{c.stopPropagation(),this.showFeatureDetailPanel(t,i)},r.appendChild(h),r}getFeatureTypeIcon(t){switch(t){case"point":return"📍";case"line":return"📏";case"polygon":return"🔲";default:return"📍"}}getFeatureTypeLabel(t){switch(t){case"point":return this.options.t.pointData||"pointData";case"line":return this.options.t.lineData||"lineData";case"polygon":return this.options.t.polygonData||"polygonData";default:return""}}showFeatureDetailPanel(t,e){this.hideFeatureDetailPanel(),this.currentFeatureId=t.id;const i=this.options.theme==="dark",n=this.element.getBoundingClientRect(),r=this.featureListPanel?.getBoundingClientRect();let o=n.left-560+4;r&&(
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.coordinateData||"Coordinate Data"}</div>
|
|
1107
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 14px; font-weight: 500;">${t.name||t.id}</div>
|
|
1108
|
-
</div>
|
|
1109
|
-
<div style="margin-bottom: 12px;">
|
|
1110
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.featureType||"Feature Type"}</div>
|
|
1111
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 12px;">${this.getFeatureTypeLabel(t.type)}</div>
|
|
1112
|
-
</div>
|
|
1113
|
-
`;if(t.type==="point"&&t.coordinates)u+=`
|
|
1114
|
-
<div style="margin-bottom: 12px;">
|
|
1115
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.longitude||"longitude"}</div>
|
|
1116
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.coordinates.longitude?.toFixed(8)||t.coordinates[0]?.toFixed(8)||"-"}</div>
|
|
1117
|
-
</div>
|
|
1118
|
-
<div style="margin-bottom: 12px;">
|
|
1119
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.latitude||"latitude"}</div>
|
|
1120
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.coordinates.latitude?.toFixed(8)||t.coordinates[1]?.toFixed(8)||"-"}</div>
|
|
1121
|
-
</div>
|
|
1122
|
-
`;else if(t.type==="line"&&t.coordinates){const y=t.coordinates.points||t.coordinates;u+=`
|
|
1123
|
-
<div style="margin-bottom: 12px;">
|
|
1124
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.pointsCount||"Points Count"}</div>
|
|
1125
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 12px;">${y?.length||0} ${this.options.t.points||"Points"}</div>
|
|
1126
|
-
</div>
|
|
1127
|
-
<div style="margin-bottom: 12px;">
|
|
1128
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.startPoint||"Start Point"}</div>
|
|
1129
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 11px; font-family: monospace;">${y?.[0]?.longitude?.toFixed(6)||y?.[0]?.[0]?.toFixed(6)||"-"}, ${y?.[0]?.latitude?.toFixed(6)||y?.[0]?.[1]?.toFixed(6)||"-"}</div>
|
|
1130
|
-
</div>
|
|
1131
|
-
<div style="margin-bottom: 12px;">
|
|
1132
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.endPoint||"End Point"}</div>
|
|
1133
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 11px; font-family: monospace;">${y?.[y.length-1]?.longitude?.toFixed(6)||y?.[y.length-1]?.[0]?.toFixed(6)||"-"}, ${y?.[y.length-1]?.latitude?.toFixed(6)||y?.[y.length-1]?.[1]?.toFixed(6)||"-"}</div>
|
|
1134
|
-
</div>
|
|
1135
|
-
`}else if(t.type==="polygon"&&t.coordinates){const y=t.coordinates.points||t.coordinates;u+=`
|
|
1136
|
-
<div style="margin-bottom: 12px;">
|
|
1137
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.vertexCount||"Vertex Count"}</div>
|
|
1138
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 12px;">${y?.length||0} ${this.options.t.points||"Points"}</div>
|
|
1139
|
-
</div>
|
|
1140
|
-
`}t.properties&&(u+=`
|
|
1148
|
+
`,h.textContent=this.options.t.details||"details",h.onmouseenter=()=>{h.style.background=n?"#444":"#e0e0e0"},h.onmouseleave=()=>{h.style.background="none"},h.onclick=c=>{c.stopPropagation(),this.showFeatureDetailPanel(t,i)},r.appendChild(h),r}getFeatureTypeIcon(t){switch(t){case"point":return"📍";case"line":return"📏";case"polygon":return"🔲";default:return"📍"}}getFeatureTypeLabel(t){switch(t){case"point":return this.options.t.pointData||"pointData";case"line":return this.options.t.lineData||"lineData";case"polygon":return this.options.t.polygonData||"polygonData";default:return""}}showFeatureDetailPanel(t,e){this.hideFeatureDetailPanel(),this.currentFeatureId=t.id;const i=this.options.theme==="dark",n=this.element.getBoundingClientRect(),r=this.featureListPanel?.getBoundingClientRect();let o=this.element.closest(".earthview-container");o||(o=document.body);const a=o.getBoundingClientRect();let l=n.left-a.left-560+4;r&&(l=r.left-a.left-270+4),l<5&&(l=5);let h=n.top-a.top-38,c=330;if(h+c+38>a.height){const v=a.height-h-48;if(v>100)c=v;else{const _=n.top-a.top-10;_>200?h=_-c-10:c=Math.max(100,v)}}h<5&&(h=5),this.featureDetailPanel=document.createElement("div"),this.featureDetailPanel.style.cssText=`
|
|
1149
|
+
position: absolute;
|
|
1150
|
+
left: ${l}px;
|
|
1151
|
+
top: ${h}px;
|
|
1152
|
+
width: 260px;
|
|
1153
|
+
max-height: ${c}px;
|
|
1154
|
+
background: ${i?"#1e1e1e":"#ffffff"};
|
|
1155
|
+
border: 1px solid ${i?"#333":"#e0e0e0"};
|
|
1156
|
+
border-radius: 8px;
|
|
1157
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
1158
|
+
z-index: 1002;
|
|
1159
|
+
overflow: hidden;
|
|
1160
|
+
display: flex;
|
|
1161
|
+
flex-direction: column;
|
|
1162
|
+
`;const u=document.createElement("div");u.style.cssText=`
|
|
1163
|
+
display: flex;
|
|
1164
|
+
flex-direction: column;
|
|
1165
|
+
height: 100%;
|
|
1166
|
+
max-height: ${c}px;
|
|
1167
|
+
`;const f=document.createElement("div");f.style.cssText=`
|
|
1168
|
+
display: flex;
|
|
1169
|
+
justify-content: space-between;
|
|
1170
|
+
align-items: center;
|
|
1171
|
+
padding: 2px 12px;
|
|
1172
|
+
background: ${i?"#2d2d2d":"#f5f5f5"};
|
|
1173
|
+
border-bottom: 1px solid ${i?"#444":"#ddd"};
|
|
1174
|
+
flex-shrink: 0;
|
|
1175
|
+
`;const g=document.createElement("span");g.style.cssText=`color: ${i?"#fff":"#333"}; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;`,g.textContent=this.options.t.details||"details",f.appendChild(g);const p=document.createElement("button");p.style.cssText=`
|
|
1176
|
+
background: none;
|
|
1177
|
+
border: none;
|
|
1178
|
+
cursor: pointer;
|
|
1179
|
+
padding: 4px;
|
|
1180
|
+
color: ${i?"#ccc":"#666"};
|
|
1181
|
+
font-size: 16px;
|
|
1182
|
+
`,p.innerHTML="✕",p.onclick=()=>this.hideFeatureDetailPanel(),f.appendChild(p),u.appendChild(f);const m=document.createElement("div");m.style.cssText="padding: 10px 12px; overflow-y: auto; flex: 1; min-height: 0;",m.className="earthview-popup-scroll";let y=`
|
|
1141
1183
|
<div style="margin-bottom: 12px;">
|
|
1142
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.
|
|
1143
|
-
<div style="color: ${i?"#
|
|
1184
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.coordinateData||"Coordinate Data"}</div>
|
|
1185
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 14px; font-weight: 500;">${t.name||t.id}</div>
|
|
1144
1186
|
</div>
|
|
1145
|
-
`),t.timestamp&&(u+=`
|
|
1146
1187
|
<div style="margin-bottom: 12px;">
|
|
1147
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.
|
|
1148
|
-
<div style="color: ${i?"#
|
|
1188
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.featureType||"Feature Type"}</div>
|
|
1189
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 12px;">${this.getFeatureTypeLabel(t.type)}</div>
|
|
1149
1190
|
</div>
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1191
|
+
`;if(t.type==="point"&&t.coordinates)y+=`
|
|
1192
|
+
<div style="margin-bottom: 12px;">
|
|
1193
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.longitude||"longitude"}</div>
|
|
1194
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.coordinates.longitude?.toFixed(8)||t.coordinates[0]?.toFixed(8)||"-"}</div>
|
|
1195
|
+
</div>
|
|
1196
|
+
<div style="margin-bottom: 12px;">
|
|
1197
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.latitude||"latitude"}</div>
|
|
1198
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.coordinates.latitude?.toFixed(8)||t.coordinates[1]?.toFixed(8)||"-"}</div>
|
|
1199
|
+
</div>
|
|
1200
|
+
`;else if(t.type==="line"&&t.coordinates){const v=t.coordinates.points||t.coordinates;y+=`
|
|
1201
|
+
<div style="margin-bottom: 12px;">
|
|
1202
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.pointsCount||"Points Count"}</div>
|
|
1203
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 12px;">${v?.length||0} ${this.options.t.points||"Points"}</div>
|
|
1204
|
+
</div>
|
|
1205
|
+
<div style="margin-bottom: 12px;">
|
|
1206
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.startPoint||"Start Point"}</div>
|
|
1207
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 11px; font-family: monospace;">${v?.[0]?.longitude?.toFixed(6)||v?.[0]?.[0]?.toFixed(6)||"-"}, ${v?.[0]?.latitude?.toFixed(6)||v?.[0]?.[1]?.toFixed(6)||"-"}</div>
|
|
1208
|
+
</div>
|
|
1209
|
+
<div style="margin-bottom: 12px;">
|
|
1210
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.endPoint||"End Point"}</div>
|
|
1211
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 11px; font-family: monospace;">${v?.[v.length-1]?.longitude?.toFixed(6)||v?.[v.length-1]?.[0]?.toFixed(6)||"-"}, ${v?.[v.length-1]?.latitude?.toFixed(6)||v?.[v.length-1]?.[1]?.toFixed(6)||"-"}</div>
|
|
1212
|
+
</div>
|
|
1213
|
+
`}else if(t.type==="polygon"&&t.coordinates){const v=t.coordinates.points||t.coordinates;y+=`
|
|
1214
|
+
<div style="margin-bottom: 12px;">
|
|
1215
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.vertexCount||"Vertex Count"}</div>
|
|
1216
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 12px;">${v?.length||0} ${this.options.t.points||"Points"}</div>
|
|
1217
|
+
</div>
|
|
1218
|
+
`}t.properties&&(y+=`
|
|
1219
|
+
<div style="margin-bottom: 12px;">
|
|
1220
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.properties||"Properties"}</div>
|
|
1221
|
+
<div style="color: ${i?"#ddd":"#555"}; font-size: 11px; word-break: break-word;">${JSON.stringify(t.properties,null,2)}</div>
|
|
1222
|
+
</div>
|
|
1223
|
+
`),t.timestamp&&(y+=`
|
|
1224
|
+
<div style="margin-bottom: 12px;">
|
|
1225
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.createdTime||"Created Time"}</div>
|
|
1226
|
+
<div style="color: ${i?"#ddd":"#555"}; font-size: 11px;">${new Date(t.timestamp).toLocaleString()}</div>
|
|
1227
|
+
</div>
|
|
1228
|
+
`),m.innerHTML=y,u.appendChild(m);const x=document.createElement("div");x.style.cssText=`
|
|
1229
|
+
display: flex;
|
|
1230
|
+
gap: 8px;
|
|
1231
|
+
padding: 10px 12px;
|
|
1232
|
+
border-top: 1px solid ${i?"#444":"#ddd"};
|
|
1233
|
+
background: ${i?"#252525":"#fafafa"};
|
|
1234
|
+
flex-shrink: 0;
|
|
1235
|
+
`;const E=document.createElement("button");E.style.cssText=`
|
|
1236
|
+
flex: 1;
|
|
1237
|
+
background: #00aaff;
|
|
1238
|
+
border: none;
|
|
1239
|
+
cursor: pointer;
|
|
1240
|
+
padding: 6px;
|
|
1241
|
+
border-radius: 4px;
|
|
1242
|
+
color: white;
|
|
1243
|
+
font-size: 12px;
|
|
1244
|
+
transition: all 0.2s;
|
|
1245
|
+
`,E.textContent=this.options.t.locateOnMap||"Locate Map",E.onmouseenter=()=>{E.style.background="#0088cc"},E.onmouseleave=()=>{E.style.background="#00aaff"},E.onclick=v=>{v.stopPropagation(),this.options.onLocateFeature&&this.options.onLocateFeature(e,t.id)};const w=document.createElement("button");w.style.cssText=`
|
|
1246
|
+
flex: 1;
|
|
1247
|
+
background: ${i?"#444":"#e0e0e0"};
|
|
1248
|
+
border: none;
|
|
1249
|
+
cursor: pointer;
|
|
1250
|
+
padding: 6px;
|
|
1251
|
+
border-radius: 4px;
|
|
1252
|
+
color: ${i?"#fff":"#333"};
|
|
1253
|
+
font-size: 12px;
|
|
1254
|
+
transition: all 0.2s;
|
|
1255
|
+
`,w.textContent=this.options.t.copyCoordinates||"Copy Coordinates",w.onmouseenter=()=>{w.style.background=i?"#555":"#d0d0d0"},w.onmouseleave=()=>{w.style.background=i?"#444":"#e0e0e0"},w.onclick=v=>{if(v.stopPropagation(),this.options.onCopyFeatureCoordinates)this.options.onCopyFeatureCoordinates(e,t.id);else{let _="";if(t.type==="point"&&t.coordinates){const b=t.coordinates.longitude??t.coordinates[0],S=t.coordinates.latitude??t.coordinates[1];_=`${b?.toFixed(8)}, ${S?.toFixed(8)}`}else t.coordinates&&(_=(t.coordinates.points||t.coordinates).map(S=>`${(S.longitude??S[0]).toFixed(8)}, ${(S.latitude??S[1]).toFixed(8)}`).join(`
|
|
1256
|
+
`));navigator.clipboard.writeText(_),this.showToast(this.options.t.coordinatesCopied||"Coordinates Copied")}},x.appendChild(E),x.appendChild(w),u.appendChild(x),this.featureDetailPanel.appendChild(u),o.appendChild(this.featureDetailPanel);const C=v=>{this.featureDetailPanel&&!this.featureDetailPanel.contains(v.target)&&this.featureListPanel&&!this.featureListPanel.contains(v.target)&&!this.element.contains(v.target)&&(this.hideFeatureDetailPanel(),document.removeEventListener("click",C))};setTimeout(()=>{document.addEventListener("click",C)},100)}hideFeatureListPanel(){this.featureListPanel&&(this.featureListPanel.remove(),this.featureListPanel=null),this.currentFeatureListLayerId=null,this.hideFeatureDetailPanel()}hideFeatureDetailPanel(){this.featureDetailPanel&&(this.featureDetailPanel.remove(),this.featureDetailPanel=null),this.currentFeatureId=null}showToast(t){const e=document.createElement("div");e.style.cssText=`
|
|
1179
1257
|
position: fixed;
|
|
1180
1258
|
bottom: 20px;
|
|
1181
1259
|
left: 50%;
|
|
@@ -1188,7 +1266,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1188
1266
|
z-index: 10000;
|
|
1189
1267
|
pointer-events: none;
|
|
1190
1268
|
white-space: nowrap;
|
|
1191
|
-
`,e.textContent=t,document.body.appendChild(e),setTimeout(()=>e.remove(),2e3)}updateData(t){this.options.layerList=t,this.render()}updateTheme(t){this.options.theme=t,this.render()}setActiveCategory(t){this.activeCategory=t,this.render()}getElement(){return this.element}destroy(){this.hideFeatureListPanel(),this.hideFeatureDetailPanel(),this.element.remove()}}class
|
|
1269
|
+
`,e.textContent=t,document.body.appendChild(e),setTimeout(()=>e.remove(),2e3)}updateData(t){this.options.layerList=t,this.render()}updateTheme(t){this.options.theme=t,this.render()}setActiveCategory(t){this.activeCategory=t,this.render()}getElement(){return this.element}destroy(){this.hideFeatureListPanel(),this.hideFeatureDetailPanel(),this.element.remove()}}class s_{constructor(t){this.props=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
1192
1270
|
width: 100%;
|
|
1193
1271
|
height: 100%;
|
|
1194
1272
|
`,t}render(){this.element.innerHTML="";const t=this.props.theme==="dark";for(const e of this.props.options){const i=document.createElement("div"),n=this.props.currentBasemap===e.value;i.style.cssText=`
|
|
@@ -1200,7 +1278,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1200
1278
|
background: ${n?t?"#2a2a2a":"#f0f0f0":"transparent"};
|
|
1201
1279
|
border-left: ${n?"3px solid #00aaff":"3px solid transparent"};
|
|
1202
1280
|
transition: all 0.2s;
|
|
1203
|
-
`,i.onmouseenter=()=>{n||(i.style.background=t?"#2a2a2a":"#f5f5f5")},i.onmouseleave=()=>{n||(i.style.background="transparent")},i.onclick=()=>{this.props.currentBasemap!==e.value&&this.props.onSelect(e.value)};const r=document.createElement("span");r.style.cssText="font-size: 14px;",r.textContent=e.icon,i.appendChild(r);const o=document.createElement("span");if(o.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 12px; flex: 1;`,o.textContent=e.label,i.appendChild(o),n){const a=document.createElement("span");a.innerHTML=Lt.Check,a.style.cssText="color: #00aaff;",i.appendChild(a)}this.element.appendChild(i)}}updateCurrentBasemap(t){this.props.currentBasemap!==t&&(this.props.currentBasemap=t,this.render())}updateTheme(t){this.props.theme=t,this.render()}updateProps(t){Object.assign(this.props,t),this.render()}getElement(){return this.element}}class
|
|
1281
|
+
`,i.onmouseenter=()=>{n||(i.style.background=t?"#2a2a2a":"#f5f5f5")},i.onmouseleave=()=>{n||(i.style.background="transparent")},i.onclick=()=>{this.props.currentBasemap!==e.value&&this.props.onSelect(e.value)};const r=document.createElement("span");r.style.cssText="font-size: 14px;",r.textContent=e.icon,i.appendChild(r);const o=document.createElement("span");if(o.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 12px; flex: 1;`,o.textContent=e.label,i.appendChild(o),n){const a=document.createElement("span");a.innerHTML=Lt.Check,a.style.cssText="color: #00aaff;",i.appendChild(a)}this.element.appendChild(i)}}updateCurrentBasemap(t){this.props.currentBasemap!==t&&(this.props.currentBasemap=t,this.render())}updateTheme(t){this.props.theme=t,this.render()}updateProps(t){Object.assign(this.props,t),this.render()}getElement(){return this.element}}class r_{constructor(t){this.props=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
1204
1282
|
width: 100%;
|
|
1205
1283
|
height: 100%;
|
|
1206
1284
|
`,t}render(){this.element.innerHTML="",this.addSectionTitle(this.props.t.lineTool),this.element.appendChild(this.createToolRow(this.createLineIcon(),this.props.t.lineTool,this.props.onDrawLine)),this.element.appendChild(this.createToolRow(this.createArrowIcon(),this.props.t.arrowTool,this.props.onDrawArrow)),this.element.appendChild(this.createToolRow(this.createBezierIcon(),this.props.t.bezierTool,this.props.onDrawBezier)),this.addSectionTitle(this.props.t.drawTools),this.element.appendChild(this.createToolRow(Lt.Circle,this.props.t.drawCircle,this.props.onDrawCircle)),this.element.appendChild(this.createToolRow(this.createEllipseIcon(),this.props.t.ellipseTool,this.props.onDrawEllipse)),this.element.appendChild(this.createToolRow(this.createRectangleIcon(),this.props.t.rectangleTool,this.props.onDrawRectangle)),this.element.appendChild(this.createToolRow(this.createTriangleIcon(),this.props.t.triangleTool,this.props.onDrawTriangle)),this.element.appendChild(this.createToolRow(this.createSectorIcon(),this.props.t.sectorTool,this.props.onDrawSector)),this.addSectionTitle(this.props.t.drawFreehandLine),this.element.appendChild(this.createToolRow(this.createFreehandIcon(),this.props.t.drawFreehandLine,this.props.onDrawFreehand)),this.element.appendChild(this.createToolRow(this.createFreehandPolygonIcon(),this.props.t.drawFreehandPolygon,this.props.onDrawFreehandPolygon)),this.addSectionTitle(this.props.t.drawMarker),this.element.appendChild(this.createToolRow(this.createMarkerIcon(),this.props.t.drawMarker,this.props.onDrawMarker)),this.element.appendChild(this.createToolRow(this.createTextIcon(),this.props.t.drawText,this.props.onDrawText)),this.element.appendChild(this.createToolRow(this.createImageIcon(),this.props.t.drawImage,this.props.onDrawImage))}addSectionTitle(t){const e=this.props.theme==="dark",i=document.createElement("div");i.style.cssText=`
|
|
@@ -1260,7 +1338,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1260
1338
|
</svg>`}createArrowIcon(){return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1261
1339
|
<line x1="5" y1="12" x2="19" y2="12"/>
|
|
1262
1340
|
<polyline points="15 6 19 12 15 18"/>
|
|
1263
|
-
</svg>`}updateTheme(t){this.props.theme=t,this.render()}getElement(){return this.element}}class
|
|
1341
|
+
</svg>`}updateTheme(t){this.props.theme=t,this.render()}getElement(){return this.element}}class o_{constructor(t){this.props=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
1264
1342
|
width: 100%;
|
|
1265
1343
|
height: 100%;
|
|
1266
1344
|
`,t}render(){this.element.innerHTML="";const t=this.props.theme==="dark",e=this.createTitle(this.props.t.distanceMeasure,t);this.element.appendChild(e);const i=this.createMeasureRow(Lt.Ruler,this.props.t.distanceMeasure,"distance",this.props.onDistanceMeasure);this.element.appendChild(i);const n=this.createMeasureRow(Lt.Area,this.props.t.areaMeasure,"area",this.props.onAreaMeasure);this.element.appendChild(n);const r=this.createTitle(this.props.t.coordinatePick,t);this.element.appendChild(r);const o=this.createPickRow(Lt.Point,this.props.t.pointPick.default_name,"point",this.props.onPointCoordinatePick);this.element.appendChild(o);const a=this.createPickRow(Lt.Line2,this.props.t.linePick.default_name,"line",this.props.onLineCoordinatePick);this.element.appendChild(a);const l=this.createPickRow(Lt.Polygon,this.props.t.polygonPick.default_name,"polygon",this.props.onPolygonCoordinatePick);this.element.appendChild(l)}createTitle(t,e){const i=document.createElement("div");return i.style.cssText=`
|
|
@@ -1304,6 +1382,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1304
1382
|
backdrop-filter: blur(8px);
|
|
1305
1383
|
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
1306
1384
|
cursor: default;
|
|
1385
|
+
user-select: none;
|
|
1307
1386
|
`;const i=`
|
|
1308
1387
|
width: 28px;
|
|
1309
1388
|
height: 28px;
|
|
@@ -1365,26 +1444,26 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1365
1444
|
height: ${Math.min(r,8)}px;
|
|
1366
1445
|
background: ${t?"#fff":"#333"};
|
|
1367
1446
|
border-radius: 2px;
|
|
1368
|
-
`,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"
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1447
|
+
`,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=this.options.containerRef,i="earthview-stroke-width-scroll-styles";if(e.querySelector(`#${i}`))return;const n=t?"#555":"#ccc",r=t?"#2d2d2d":"#f0f0f0",a=`
|
|
1448
|
+
.earthview-stroke-width-scroll {
|
|
1449
|
+
scrollbar-width: thin;
|
|
1450
|
+
scrollbar-color: ${n} ${r};
|
|
1451
|
+
}
|
|
1452
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar {
|
|
1453
|
+
width: 4px;
|
|
1454
|
+
}
|
|
1455
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar-track {
|
|
1456
|
+
background: ${r};
|
|
1457
|
+
border-radius: 4px;
|
|
1458
|
+
}
|
|
1459
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar-thumb {
|
|
1460
|
+
background: ${n};
|
|
1461
|
+
border-radius: 4px;
|
|
1462
|
+
}
|
|
1463
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar-thumb:hover {
|
|
1464
|
+
background: ${t?"#777":"#aaa"};
|
|
1465
|
+
}
|
|
1466
|
+
`,l=document.createElement("style");l.id=i,l.textContent=a,e.appendChild(l)}createStrokeStylePicker(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.cssText=`
|
|
1388
1467
|
background: ${t?"#2d2d2d":"#ffffff"};
|
|
1389
1468
|
border: 1px solid ${t?"#444":"#ddd"};
|
|
1390
1469
|
border-radius: 8px;
|
|
@@ -1400,7 +1479,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1400
1479
|
cursor: pointer;
|
|
1401
1480
|
background: ${this.options.currentStrokeStyle===n.value?t?"#3d3d3d":"#e8e8e8":"transparent"};
|
|
1402
1481
|
transition: all 0.2s;
|
|
1403
|
-
`,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
|
|
1482
|
+
`,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 a_{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=`
|
|
1404
1483
|
position: absolute;
|
|
1405
1484
|
left: ${this.position.x}px;
|
|
1406
1485
|
top: ${this.position.y}px;
|
|
@@ -1415,6 +1494,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1415
1494
|
backdrop-filter: blur(8px);
|
|
1416
1495
|
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
1417
1496
|
cursor: default;
|
|
1497
|
+
user-select: none;
|
|
1418
1498
|
`;const i=`
|
|
1419
1499
|
width: 28px;
|
|
1420
1500
|
height: 28px;
|
|
@@ -1433,7 +1513,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1433
1513
|
width: 20px;
|
|
1434
1514
|
cursor: grab;
|
|
1435
1515
|
background: ${t?"#3d3d3d":"#e8e8e8"};
|
|
1436
|
-
`,n.innerHTML=Lt.DragHandle,n.title=this.options.t.dragToMove,n.onmousedown=this.onMouseDown.bind(this),e.appendChild(n);const r=document.createElement("button");r.style.cssText=i,r.innerHTML=Lt.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=Lt.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
|
|
1516
|
+
`,n.innerHTML=Lt.DragHandle,n.title=this.options.t.dragToMove,n.onmousedown=this.onMouseDown.bind(this),e.appendChild(n);const r=document.createElement("button");r.style.cssText=i,r.innerHTML=Lt.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=Lt.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 l_{constructor(t,e){this.theme=e,this.element=this.createElement(),t.appendChild(this.element)}createElement(){const t=this.theme==="dark",e=document.createElement("div");return e.style.cssText=`
|
|
1437
1517
|
position: absolute;
|
|
1438
1518
|
bottom: 10px;
|
|
1439
1519
|
right: 10px;
|
|
@@ -1447,7 +1527,8 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1447
1527
|
color: ${t?"#fff":"#333"};
|
|
1448
1528
|
pointer-events: none;
|
|
1449
1529
|
border: 1px solid ${t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"};
|
|
1450
|
-
|
|
1530
|
+
user-select: none;
|
|
1531
|
+
`,e.textContent="",e}updateScale(t){this.element.textContent=t}updateTheme(t){this.theme=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",this.element.style.borderColor=e?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"}destroy(){this.element.remove()}}class h_{constructor(t,e){this.theme=e,this.element=this.createElement(),t.appendChild(this.element),this.messageSpan=this.element.querySelector(".loading-message"),this.spinner=this.element.querySelector(".loading-spinner")}createElement(){const t=this.theme==="dark",e=document.createElement("div");e.className="earthview-loading-overlay",e.style.cssText=`
|
|
1451
1532
|
position: absolute;
|
|
1452
1533
|
top: 0;
|
|
1453
1534
|
left: 0;
|
|
@@ -1480,7 +1561,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1480
1561
|
0% { transform: rotate(0deg); }
|
|
1481
1562
|
100% { transform: rotate(360deg); }
|
|
1482
1563
|
}
|
|
1483
|
-
`,document.head.appendChild(i),e}show(t){this.messageSpan.textContent=t,this.element.style.display="flex"}hide(){this.element.style.display="none"}updateTheme(t){this.theme=t;const e=t==="dark";this.element.style.background=e?"rgba(0,0,0,0.8)":"rgba(255,255,255,0.8)",this.spinner.style.border=`3px solid ${e?"#444":"#ddd"}`,this.spinner.style.borderTop="3px solid #00aaff",this.messageSpan.style.color=e?"#fff":"#333",this.messageSpan.style.background=e?"rgba(0,0,0,0.5)":"rgba(255,255,255,0.8)"}destroy(){this.element.remove()}}class
|
|
1564
|
+
`,document.head.appendChild(i),e}show(t){this.messageSpan.textContent=t,this.element.style.display="flex"}hide(){this.element.style.display="none"}updateTheme(t){this.theme=t;const e=t==="dark";this.element.style.background=e?"rgba(0,0,0,0.8)":"rgba(255,255,255,0.8)",this.spinner.style.border=`3px solid ${e?"#444":"#ddd"}`,this.spinner.style.borderTop="3px solid #00aaff",this.messageSpan.style.color=e?"#fff":"#333",this.messageSpan.style.background=e?"rgba(0,0,0,0.5)":"rgba(255,255,255,0.8)"}destroy(){this.element.remove()}}class c_{constructor(t){this.activeCategory=null,this.detailPanel=null,this.options=t,this.element=this.createElement(),this.render()}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");return e.style.cssText=`
|
|
1484
1565
|
position: absolute;
|
|
1485
1566
|
top: 10px;
|
|
1486
1567
|
right: 60px;
|
|
@@ -1494,6 +1575,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1494
1575
|
overflow: hidden;
|
|
1495
1576
|
display: flex;
|
|
1496
1577
|
flex-direction: column;
|
|
1578
|
+
user-select: none;
|
|
1497
1579
|
`,e}getPointData(){return this.options.getPointData?this.options.getPointData():[]}getLineData(){return this.options.getLineData?this.options.getLineData():[]}getPolygonData(){return this.options.getPolygonData?this.options.getPolygonData():[]}render(){this.element.innerHTML="";const t=this.options.theme==="dark",e=this.createHeader(t);this.element.appendChild(e);const i=document.createElement("div");i.style.cssText=`
|
|
1498
1580
|
flex: 1;
|
|
1499
1581
|
overflow-y: auto;
|
|
@@ -1562,111 +1644,140 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1562
1644
|
transition: all 0.2s;
|
|
1563
1645
|
color: ${n?"#00aaff":"#0066cc"};
|
|
1564
1646
|
margin-left: 8px;
|
|
1565
|
-
`,c.textContent=this.options.t.details,c.onmouseenter=()=>{c.style.background=n?"#444":"#e0e0e0"},c.onmouseleave=()=>{c.style.background="none"},c.onclick=d=>{d.stopPropagation(),this.showDetailPanel(t,e)},r.appendChild(c),r.onclick=()=>{this.showDetailPanel(t,e)},r}showDetailPanel(t,e){this.hideDetailPanel();const i=this.options.theme==="dark",n=this.element.getBoundingClientRect();this.detailPanel=document.createElement("div"),this.detailPanel.style.cssText=`
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1647
|
+
`,c.textContent=this.options.t.details,c.onmouseenter=()=>{c.style.background=n?"#444":"#e0e0e0"},c.onmouseleave=()=>{c.style.background="none"},c.onclick=d=>{d.stopPropagation(),this.showDetailPanel(t,e)},r.appendChild(c),r.onclick=()=>{this.showDetailPanel(t,e)},r}showDetailPanel(t,e){this.hideDetailPanel();const i=this.options.theme==="dark",n=this.element.getBoundingClientRect();let r=this.element.closest(".earthview-container");r||(r=document.body);const o=r.getBoundingClientRect();let a=n.left-o.left-305,l=n.top-o.top,h=400,c=300;if(a+c>o.width&&(a=n.right-o.left+10),a<5&&(a=5),a+c>o.width&&(a=o.width-c-5),l+h>o.height){const v=o.height-l-20;v>100?h=v:(l=Math.max(5,n.top-o.top-h+50),h=Math.min(h,o.height-l-20))}l<5&&(l=5,h=Math.min(h,o.height-l-20)),this.detailPanel=document.createElement("div"),this.detailPanel.style.cssText=`
|
|
1648
|
+
position: absolute;
|
|
1649
|
+
left: ${a}px;
|
|
1650
|
+
top: ${l}px;
|
|
1651
|
+
width: ${c}px;
|
|
1652
|
+
max-height: ${h}px;
|
|
1653
|
+
background: ${i?"#1e1e1e":"#ffffff"};
|
|
1654
|
+
border: 1px solid ${i?"#444":"#ddd"};
|
|
1655
|
+
border-radius: 8px;
|
|
1656
|
+
box-shadow: 0 4px 20px rgba(0,0,0,0.4);
|
|
1657
|
+
z-index: 1001;
|
|
1658
|
+
overflow: hidden;
|
|
1659
|
+
display: flex;
|
|
1660
|
+
flex-direction: column;
|
|
1661
|
+
`,this.injectScrollbarStylesForDetail(i);const u=document.createElement("div");u.style.cssText=`
|
|
1662
|
+
display: flex;
|
|
1663
|
+
flex-direction: column;
|
|
1664
|
+
height: 100%;
|
|
1665
|
+
max-height: ${h}px;
|
|
1666
|
+
`;const f=document.createElement("div");f.style.cssText=`
|
|
1667
|
+
display: flex;
|
|
1668
|
+
justify-content: space-between;
|
|
1669
|
+
align-items: center;
|
|
1670
|
+
padding: 10px 12px;
|
|
1671
|
+
background: ${i?"#2d2d2d":"#f5f5f5"};
|
|
1672
|
+
border-bottom: 1px solid ${i?"#444":"#ddd"};
|
|
1673
|
+
flex-shrink: 0;
|
|
1674
|
+
`;const g=document.createElement("span");g.style.cssText=`color: ${i?"#fff":"#333"}; font-size: 13px; font-weight: 600;`,g.textContent=this.options.t.details,f.appendChild(g);const p=document.createElement("button");p.style.cssText=`
|
|
1675
|
+
background: none;
|
|
1676
|
+
border: none;
|
|
1677
|
+
cursor: pointer;
|
|
1678
|
+
padding: 4px;
|
|
1679
|
+
color: ${i?"#ccc":"#666"};
|
|
1680
|
+
font-size: 16px;
|
|
1681
|
+
`,p.innerHTML="✕",p.onclick=()=>this.hideDetailPanel(),f.appendChild(p),u.appendChild(f);const m=document.createElement("div");m.style.cssText="padding: 12px; overflow-y: auto; flex: 1; min-height: 0;",m.className="earthview-detail-scroll";let y=`
|
|
1682
|
+
<div style="margin-bottom: 12px;">
|
|
1683
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.coordinateData}</div>
|
|
1684
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 14px; font-weight: 500;">${t.name}</div>
|
|
1685
|
+
</div>
|
|
1686
|
+
`;e==="point"?y+=`
|
|
1591
1687
|
<div style="margin-bottom: 12px;">
|
|
1592
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.
|
|
1593
|
-
<div style="color: ${i?"#fff":"#333"}; font-size:
|
|
1688
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.longitude}</div>
|
|
1689
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 13px; font-family: monospace;">${t.longitude.toFixed(8)}</div>
|
|
1594
1690
|
</div>
|
|
1595
|
-
`;e==="point"?c+=`
|
|
1596
|
-
<div style="margin-bottom: 12px;">
|
|
1597
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.longitude}</div>
|
|
1598
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 13px; font-family: monospace;">${t.longitude.toFixed(8)}</div>
|
|
1599
|
-
</div>
|
|
1600
|
-
<div style="margin-bottom: 12px;">
|
|
1601
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.latitude}</div>
|
|
1602
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 13px; font-family: monospace;">${t.latitude.toFixed(8)}</div>
|
|
1603
|
-
</div>
|
|
1604
|
-
`:e==="line"?c+=`
|
|
1605
|
-
<div style="margin-bottom: 12px;">
|
|
1606
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.pointsCount}</div>
|
|
1607
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 13px;">${t.points.length} ${this.options.t.points}</div>
|
|
1608
|
-
</div>
|
|
1609
|
-
<div style="margin-bottom: 12px;">
|
|
1610
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.startPoint}</div>
|
|
1611
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.points[0]?.longitude.toFixed(6)}, ${t.points[0]?.latitude.toFixed(6)}</div>
|
|
1612
|
-
</div>
|
|
1613
|
-
<div style="margin-bottom: 12px;">
|
|
1614
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.endPoint}</div>
|
|
1615
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.points[t.points.length-1]?.longitude.toFixed(6)}, ${t.points[t.points.length-1]?.latitude.toFixed(6)}</div>
|
|
1616
|
-
</div>
|
|
1617
|
-
`:e==="polygon"&&(c+=`
|
|
1618
|
-
<div style="margin-bottom: 12px;">
|
|
1619
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.vertexCount}</div>
|
|
1620
|
-
<div style="color: ${i?"#fff":"#333"}; font-size: 13px;">${t.points.length} ${this.options.t.points}</div>
|
|
1621
|
-
</div>
|
|
1622
|
-
`),c+=`
|
|
1623
1691
|
<div style="margin-bottom: 12px;">
|
|
1624
|
-
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.
|
|
1625
|
-
<div style="color: ${i?"#
|
|
1692
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.latitude}</div>
|
|
1693
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 13px; font-family: monospace;">${t.latitude.toFixed(8)}</div>
|
|
1626
1694
|
</div>
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
`,e.textContent=t,document.body.appendChild(e),setTimeout(()=>e.remove(),2e3)}refresh(){this.render()}setActiveCategory(t){this.activeCategory=t,this.render()}updateTheme(t){this.options.theme=t,this.render()}getElement(){return this.element}destroy(){this.hideDetailPanel(),this.element.remove()}}class Dd{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 kd{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 Rd{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()}}class Ad{constructor(t,e,i=!1){this.id="freehand-draw",this.name="手绘线",this.icon="✏️",this.isPolygonMode=!1,this.freehandDrawLayer=t,this.isPolygonMode=i,this.name=i?e.drawFreehandPolygon||"手绘多边形":e.drawFreehandLine||"手绘线"}activate(){this.freehandDrawLayer.setEditable(!0)}deactivate(){this.freehandDrawLayer.stopDraw(),this.freehandDrawLayer.stopEdit()}isActive(){return this.freehandDrawLayer.isDrawActive()||this.freehandDrawLayer.isEditActive()}startDraw(t=!1){this.name=t?"手绘多边形":"手绘线",this.freehandDrawLayer.startDraw(t,e=>{this.onDrawComplete&&this.onDrawComplete(e)})}startEdit(t){this.freehandDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getFreehandLayer(){return this.freehandDrawLayer}destroy(){this.freehandDrawLayer.destroy()}}class Md{constructor(t,e){this.id="ellipse-draw",this.name="椭圆绘制",this.icon="⚪",this.ellipseDrawLayer=t,this.name=e.drawEllipse||"椭圆绘制"}activate(){this.ellipseDrawLayer.setEditable(!0)}deactivate(){this.ellipseDrawLayer.stopDraw(),this.ellipseDrawLayer.stopEdit()}isActive(){return this.ellipseDrawLayer.isDrawActive()||this.ellipseDrawLayer.isEditActive()}startDraw(){this.ellipseDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.ellipseDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getEllipseLayer(){return this.ellipseDrawLayer}destroy(){this.ellipseDrawLayer.destroy()}}class Fd{constructor(t,e){this.id="marker-draw",this.name="标记点绘制",this.icon="📍",this.markerDrawLayer=t,this.name=e.drawMarker||"标记点绘制"}activate(){this.markerDrawLayer.setEditable(!0)}deactivate(){this.markerDrawLayer.stopDraw(),this.markerDrawLayer.stopEdit()}isActive(){return this.markerDrawLayer.isDrawActive()||this.markerDrawLayer.isEditActive()}startDraw(){this.markerDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.markerDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getMarkerLayer(){return this.markerDrawLayer}destroy(){this.markerDrawLayer.destroy()}}class Od{constructor(t,e){this.id="text-draw",this.name="文字标注",this.icon="📝",this.textDrawLayer=t,this.name=e.drawText||"文字标注"}activate(){this.textDrawLayer.setEditable(!0)}deactivate(){this.textDrawLayer.stopDraw(),this.textDrawLayer.stopEdit()}isActive(){return this.textDrawLayer.isDrawActive()||this.textDrawLayer.isEditActive()}startDraw(){this.textDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.textDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}editProperties(t,e,i){this.textDrawLayer.editProperties(t,e,i)}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getTextLayer(){return this.textDrawLayer}destroy(){this.textDrawLayer.destroy()}}class zd{constructor(t,e){this.id="arrow-draw",this.name="箭头绘制",this.icon="➡️",this.arrowDrawLayer=t,this.name=e.drawArrow||"箭头绘制"}activate(){this.arrowDrawLayer.setEditable(!0)}deactivate(){this.arrowDrawLayer.stopDraw(),this.arrowDrawLayer.stopEdit()}isActive(){return this.arrowDrawLayer.isDrawActive()||this.arrowDrawLayer.isEditActive()}startDraw(){this.arrowDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.arrowDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getArrowLayer(){return this.arrowDrawLayer}destroy(){this.arrowDrawLayer.destroy()}}class h_{constructor(){this.tools=new Map,this.activeTool=null,this.eventHandlers=new Map}registerCircleTool(t,e){const i=new Dd(t,e);return this.registerTool(i),i}registerRectangleTool(t,e){const i=new kd(t,e);return this.registerTool(i),i}registerTriangleTool(t,e){const i=new Rd(t,e);return this.registerTool(i),i}registerFreehandTool(t,e){const i=new Ad(t,e);return this.registerTool(i),i}registerEllipseTool(t,e){const i=new Md(t,e);return this.registerTool(i),i}registerMarkerTool(t,e){const i=new Fd(t,e);return this.registerTool(i),i}registerTextTool(t,e){const i=new Od(t,e);return this.registerTool(i),i}registerArrowTool(t,e){const i=new zd(t,e);return this.registerTool(i),i}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))}getAllTools(){return Array.from(this.tools.values())}destroy(){this.tools.forEach(t=>t.destroy()),this.tools.clear(),this.eventHandlers.clear(),this.activeTool=null}}function Bo(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 c_(s,t,e){const i=s[e];return i?i.delete(t):!1}function Oh(s,t){const e=s.layerStatesArray[s.layerIndex];e.extent&&(t=Ni(t,Fi(e.extent,s.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(s.viewState.projection).getExtent();n&&(t=Ni(t,n))}return t}class d_ extends Bc{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=oe(),this.tempTileRange_=new ll(0,0,0,0),this.tempTileCoord_=Dr(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new Rh(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new Rh(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,a=this.getLayer().getSource(),l=cr(a,a.getKey(),t,e,i);let h;if(r.containsKey(l))h=r.get(l);else{const c=n.viewState.projection,d=a.getProjection();if(h=a.getTile(t,e,i,n.pixelRatio,c,!d||os(d,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=zt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Tn(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 d=l.getTileCoordForCoordAndZ(n,c),u=this.getTile(c,d[1],d[2],e);if(!u||u.getState()!==X.LOADED)continue;const f=l.getOrigin(c),g=ce(l.getTileSize(c)),p=l.getResolution(c);let m;if(u instanceof fd||u instanceof gd)m=u.getImage();else if(u instanceof Ih){if(m=fa(u.getData()),!m)continue}else continue;const y=Math.floor(h*((n[0]-f[0])/p-d[1]*g[0])),w=Math.floor(h*((f[1]-n[1])/p-d[2]*g[1])),E=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(m,y+E,w+E)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,i,n,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=K(l);c in t.wantedTiles||(t.wantedTiles[c]={});const d=t.wantedTiles[c],u=a.getMapInternal(),f=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),u?u.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,p=g?Uh(o.center,o.resolution,g,t.size):void 0;for(let m=i;m>=f;--m){const y=h.getTileRangeForExtentAndZ(e,m,this.tempTileRange_),w=h.getResolution(m);for(let E=y.minX;E<=y.maxX;++E)for(let x=y.minY;x<=y.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([m,E,x],p))continue;const C=this.getTile(m,E,x,t);if(!C||!Bo(n,C,m))continue;const _=C.getKey();if(d[_]=!0,C.getState()===X.IDLE&&!t.tileQueue.isKeyQueued(_)){const b=Dr(m,E,x,this.tempTileCoord_);t.tileQueue.enqueue([C,c,h.getTileCoordCenter(b),w])}}}}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=cr(this.getLayer().getSource(),a[l],n,r,o);if(i.containsKey(h)){const c=i.peek(h);if(c.getState()===X.LOADED)return c.endTransition(K(this)),Bo(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 d=r.minY;d<=r.maxY;++d){const u=cr(l,h,i,c,d);let f=!1;if(a.containsKey(u)){const g=a.peek(u);g.getState()===X.LOADED&&(Bo(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(),d=c.getTileGridForProjection(r),u=d.getZForResolution(o,c.zDirection),f=d.getResolution(u),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let p=t.extent;const m=c.getTilePixelRatio(l);this.prepareContainer(t,e);const y=this.context.canvas.width,w=this.context.canvas.height;this.layerExtent=i.extent?Fi(i.extent):null,this.layerExtent&&(p=Ni(p,this.layerExtent));const E=f*y/2/m,x=f*w/2/m,C=[a[0]-E,a[1]-x,a[0]+E,a[1]+x],T={};this.renderedTiles.length=0;const _=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){const D=d.getZForResolution(n.nextResolution,c.zDirection),z=Oh(t,t.nextExtent);this.enqueueTiles(t,z,D,T,_)}const b=Oh(t,p);if(this.enqueueTiles(t,b,u,T,0),_>0&&setTimeout(()=>{this.enqueueTiles(t,b,u-1,T,_-1)},0),!(u in T))return this.container;const S=K(this),P=t.time;for(const D of T[u]){const z=D.getState();if(z===X.EMPTY)continue;const N=D.tileCoord;if(z===X.LOADED&&D.getAlpha(S,P)===1){D.endTransition(S);continue}if(z!==X.ERROR&&(this.renderComplete=!1),this.findStaleTile_(N,T)){c_(T,D,u),t.animate=!0;continue}if(this.findAltTiles_(d,N,u+1,T))continue;const ht=d.getMinZoom();for(let ot=u-1;ot>=ht&&!this.findAltTiles_(d,N,ot,T);--ot);}const L=f/o*l/m,k=this.getRenderContext(t);Pe(this.tempTransform,y/2,w/2,L,L,0,-y/2,-w/2),this.layerExtent&&this.clipUnrotated(k,t,this.layerExtent),c.getInterpolate()||(k.imageSmoothingEnabled=!1),this.preRender(k,t);const F=Object.keys(T).map(Number);F.sort(ai);let O;const R=[],B=[];for(let D=F.length-1;D>=0;--D){const z=F[D],N=c.getTilePixelSize(z,l,r),et=d.getResolution(z)/f,ht=N[0]*et*L,ot=N[1]*et*L,I=d.getTileCoordForCoordAndZ(ji(C),z),xt=d.getTileCoordExtent(I),yt=zt(this.tempTransform,[m*(xt[0]-C[0])/f,m*(C[3]-xt[3])/f]),Ot=m*c.getGutterForProjection(r);for(const ie of T[z]){if(ie.getState()!==X.LOADED)continue;const Ne=ie.tileCoord,St=I[1]-Ne[1],vt=Math.round(yt[0]-(St-1)*ht),Dt=I[2]-Ne[2],Kt=Math.round(yt[1]-(Dt-1)*ot),kt=Math.round(yt[0]-St*ht),Ht=Math.round(yt[1]-Dt*ot),de=vt-kt,gi=Kt-Ht,Ms=F.length===1;let On=!1;O=[kt,Ht,kt+de,Ht,kt+de,Ht+gi,kt,Ht+gi];for(let qi=0,Fs=R.length;qi<Fs;++qi)if(!Ms&&z<B[qi]){const ne=R[qi];le([kt,Ht,kt+de,Ht+gi],[ne[0],ne[3],ne[4],ne[7]])&&(On||(k.save(),On=!0),k.beginPath(),k.moveTo(O[0],O[1]),k.lineTo(O[2],O[3]),k.lineTo(O[4],O[5]),k.lineTo(O[6],O[7]),k.moveTo(ne[6],ne[7]),k.lineTo(ne[4],ne[5]),k.lineTo(ne[2],ne[3]),k.lineTo(ne[0],ne[1]),k.clip())}R.push(O),B.push(z),this.drawTile(ie,t,kt,Ht,de,gi,Ot,Ms),On&&k.restore(),this.renderedTiles.unshift(ie),this.updateUsedTiles(t.usedTiles,c,ie)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!bn(this.renderedExtent_,C),this.renderedExtent_=C,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&k.restore(),k.imageSmoothingEnabled=!0,this.renderComplete){const D=(z,N)=>{const tt=K(c),et=N.wantedTiles[tt],ht=et?Object.keys(et).length:0;this.updateCacheSize(ht),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(D)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,n,r,o,a,l){let h;if(t instanceof Ih){if(h=fa(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),d=K(this),u=e.layerStatesArray[e.layerIndex],f=u.opacity*(l?t.getAlpha(d,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!==u.opacity?e.animate=!0:l&&t.endTransition(d)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const n=K(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}}const lr={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class u_ extends Jr{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(lr.PRELOAD)}setPreload(t){this.set(lr.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(lr.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(lr.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class jn extends u_{constructor(t){super(t)}createRenderer(){return new d_(this,{cacheSize:this.getCacheSize()})}}const ln=[0,0,0],xi=5;class $d{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,gt(Qd(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,gt(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_=ji(i)),gt(!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,gt(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:Qa,gt(!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 ll(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=sn(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 sn(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 sn(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 sn(h,h,c,c,i);const d=Math.floor(l*(r+1))-1,u=Math.floor(l*(o+1))-1;return sn(h,d,c,u,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,ln);const n=ln[1],r=ln[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,ln);const o=ln[1],a=ln[2];return sn(n,o,r,a,i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),n=ce(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=ce(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 di(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=ce(this.getTileSize(o),this.tmpSize_);let c=a*(t-l[0])/i/h[0],d=a*(l[1]-e)/i/h[1];return n?(c=Bs(c,xi)-1,d=Bs(d,xi)-1):(c=Gs(c,xi),d=Gs(d,xi)),Dr(o,c,d,r)}getTileCoordForXYAndZ_(t,e,i,n,r){const o=this.getOrigin(i),a=this.getResolution(i),l=ce(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,xi)-1,c=Bs(c,xi)-1):(h=Gs(h,xi),c=Gs(c,xi)),Dr(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=_a(this.resolutions_,t,e||0);return Pt(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return fc(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 Nd(s){let t=s.getDefaultTileGrid();return t||(t=m_(s),s.setDefaultTileGrid(t)),t}function f_(s,t,e){const i=t[0],n=s.getTileCoordCenter(t),r=Cl(e);if(!Tn(r,n)){const o=Et(r),a=Math.ceil((r[0]-n[0])/o);return n[0]+=o*a,s.getTileCoordForCoordAndZ(n,i)}return t}function g_(s,t,e,i){i=i!==void 0?i:"top-left";const n=Gd(s,t,e);return new $d({extent:s,origin:su(s,i),resolutions:n,tileSize:e})}function p_(s){const t=s||{},e=t.extent||Ft("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:Gd(e,t.maxZoom,t.tileSize,t.maxResolution)};return new $d(i)}function Gd(s,t,e,i){t=t!==void 0?t:mp,e=ce(e!==void 0?e:Qa);const n=he(s),r=Et(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 m_(s,t,e,i){const n=Cl(s);return g_(n,t,e,i)}function Cl(s){s=Ft(s);let t=s.getExtent();if(!t){const e=180*Ta.degrees/s.getMetersPerUnit();t=di(-e,-e,e,e)}return t}const y_=/\{z\}/g,__=/\{x\}/g,w_=/\{y\}/g,x_=/\{-y\}/g;function C_(s,t,e,i,n){return s.replace(y_,t.toString()).replace(__,e.toString()).replace(w_,i.toString()).replace(x_,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 E_(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 v_(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 C_(s,o,e[1],e[2],r)})}function T_(s,t){const e=s.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=v_(s[n],t);return b_(i)}function b_(s){return s.length===1?s[0]:(function(t,e,i){if(!t)return;const n=Wm(t),r=Gi(n,s.length);return s[r](t,e,i)})}class S_ extends td{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&&ce(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||K(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,n,r,o){return Q()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Nd(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const n=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),o=ce(n.getTileSize(t),this.tmpSize);return r==1?o:Qf(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=f_(n,t,i)),Vm(t,n)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class P_ extends qe{constructor(t,e){super(t),this.tile=e}}const Wo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class El extends S_{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===El.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,i=K(e),n=e.getState();let r;n==X.LOADING?(this.tileLoadingKeys_[i]=!0,r=Wo.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==X.ERROR?Wo.TILELOADERROR:n==X.LOADED?Wo.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new P_(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=E_(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join(`
|
|
1669
|
-
`);this.generateTileUrlFunction_?this.setTileUrlFunction(T_(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class I_ extends El{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:L_,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:fd,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!os(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||os(e,t)))return this.tileGrid;const i=K(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Nd(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?X.IDLE:X.EMPTY,h!==void 0?h:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(nt.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,n,r,o){const a=this.getProjection();if(!a||!r||os(a,r))return this.getTileInternal(t,e,i,n,a||r);const l=[t,e,i],h=this.getKey(),c=this.getTileGridForProjection(a),d=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(l,r),f=new gd(a,c,r,d,l,u,this.getTilePixelRatio(n),this.getGutter(),(g,p,m,y)=>this.getTileInternal(g,p,m,y,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=cr(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=Ft(t);if(i){const n=K(i);n in this.tileGridForProjection||(this.tileGridForProjection[n]=e)}}}function L_(s,t){if(Ee){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 ns extends I_{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:p_({extent:Cl(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_}}const D_='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class k_ extends ns{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[D_];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 Mt=Math.PI,Ar=6378245,Mr=.006693421622965943;function vl(s,t){return s<72.004||s>137.8347||t<.8293||t>55.8271}function Bd(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*Mt)+20*Math.sin(2*s*Mt))*(2/3),e+=(20*Math.sin(t*Mt)+40*Math.sin(t/3*Mt))*(2/3),e+=(160*Math.sin(t/12*Mt)+320*Math.sin(t*Mt/30))*(2/3),e}function Wd(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*Mt)+20*Math.sin(2*s*Mt))*(2/3),e+=(20*Math.sin(s*Mt)+40*Math.sin(s/3*Mt))*(2/3),e+=(150*Math.sin(s/12*Mt)+300*Math.sin(s*Mt/30))*(2/3),e}function Tl(s,t){if(vl(s,t))return[s,t];let e=Bd(s-105,t-35),i=Wd(s-105,t-35);const n=t/180*Mt;let r=Math.sin(n);r=1-Mr*r*r;const o=Math.sqrt(r);return e=e*180/(Ar*(1-Mr)/(r*o)*Mt),i=i*180/(Ar/o*Math.cos(n)*Mt),[s-i,t-e]}function zh(s,t){if(vl(s,t))return[s,t];let e=Bd(s-105,t-35),i=Wd(s-105,t-35);const n=t/180*Mt;let r=Math.sin(n);r=1-Mr*r*r;const o=Math.sqrt(r);return e=e*180/(Ar*(1-Mr)/(r*o)*Mt),i=i*180/(Ar/o*Math.cos(n)*Mt),[s+i,t+e]}function R_(s,t){const e=s,i=t,n=Math.sqrt(e*e+i*i)+2e-5*Math.sin(i*Mt),r=Math.atan2(i,e)+3e-6*Math.cos(e*Mt),o=n*Math.cos(r)+.0065,a=n*Math.sin(r)+.006;return[o,a]}function A_(s,t){const e=s-.0065,i=t-.006,n=Math.sqrt(e*e+i*i)-2e-5*Math.sin(i*Mt),r=Math.atan2(i,e)-3e-6*Math.cos(e*Mt),o=n*Math.cos(r),a=n*Math.sin(r);return[o,a]}function Ud(s,t){const[e,i]=A_(s,t);return Tl(e,i)}function ya(s,t,e){switch(e){case Oe.WGS84:return[s,t];case Oe.GCJ02:return Tl(s,t);case Oe.BD09:return Ud(s,t);default:return[s,t]}}function M_(s,t,e){switch(e){case Oe.WGS84:return[s,t];case Oe.GCJ02:return zh(s,t);case Oe.BD09:return R_(...zh(s,t));default:return[s,t]}}function F_(s,t){return!vl(s,t)}const Uo={[dt.SATELLITE]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.STREETS]:{url:"https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"OpenStreetMap"},[dt.TOPO]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.OCEANS]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.DARK_GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.NATIONAL_GEOGRAPHIC]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.TERRAIN]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.HYBRID]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.LIGHT_GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.IMAGERY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.PHYSICAL]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.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:"高德地图"},[dt.AMAP_SATELLITE]:{url:"https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",attribution:"高德地图"},[dt.GOOGLE_STREETS]:{url:"http://www.google.cn/maps/vt?lyrs=m&x={x}&y={y}&z={z}",attribution:"Google"},[dt.GOOGLE_SATELLITE]:{url:"http://www.google.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",attribution:"Google"}};class O_{constructor(t,e,i,n,r,o){getComputedStyle(t).position==="static"&&(t.style.position="relative");let a=i;r!==Oe.WGS84&&(a=ya(i[0],i[1],r)),e===dt.CUSTOMIZE&&o?(this.basemapLayer=this.createBasemapLayerFromUrl(o),this.currentBasemap=null):(this.basemapLayer=this.createBasemapLayer(e),this.currentBasemap=e),this.view=new He({center:ut(a),zoom:n,minZoom:1,maxZoom:19}),this.map=new hd({target:t,layers:[this.basemapLayer],view:this.view,controls:[],interactions:od({doubleClickZoom:!1})})}createBasemapLayerFromUrl(t){const e=new ns({url:t});return new jn({source:e})}createBasemapLayer(t){const e=Uo[t];if(t===dt.STREETS){const n=new k_;return new jn({source:n})}if(e){const n=new ns({url:e.url,attributions:e.attribution});return new jn({source:n})}const i=new ns({url:Uo[dt.SATELLITE]?.url,attributions:Uo[dt.SATELLITE]?.attribution});return new jn({source:i})}setBasemapByUrl(t){const e=new ns({url:t}),i=new jn({source:e});this.map.removeLayer(this.basemapLayer),this.basemapLayer=i,this.map.addLayer(this.basemapLayer),this.currentBasemap=null}setBasemap(t){this.map.removeLayer(this.basemapLayer),this.basemapLayer=this.createBasemapLayer(t),this.map.addLayer(this.basemapLayer),this.currentBasemap=t}getCurrentBasemap(){return this.currentBasemap}getMap(){return this.map}getView(){return this.view}getCenter(){const t=U(this.view.getCenter()||[0,0]);return[t[0],t[1]]}getZoom(){return this.view.getZoom()||0}setCenter(t,e){let i=t;e&&e!==Oe.WGS84&&(i=ya(t[0],t[1],e)),this.view.setCenter(ut(i))}setZoom(t){this.view.setZoom(t)}setRotation(t){this.view.setRotation(t)}destroy(){this.map.setTarget(void 0),this.map.dispose()}}class z_{constructor(t,e){this.id="line-draw",this.name="线段",this.icon="━━",this.lineDrawLayer=t,this.name=e.drawLine||"线段"}activate(){this.lineDrawLayer.setEditable(!0)}deactivate(){this.lineDrawLayer.stopDraw(),this.lineDrawLayer.stopEdit()}isActive(){return this.lineDrawLayer.isDrawActive()||this.lineDrawLayer.isEditActive()}startDraw(){this.lineDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.lineDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getLineLayer(){return this.lineDrawLayer}destroy(){this.lineDrawLayer.destroy()}}class $_{constructor(t,e){this.id="bezier-draw",this.name="贝塞尔曲线",this.icon="〰️",this.bezierDrawLayer=t,this.name=e.drawBezier||"贝塞尔曲线"}activate(){this.bezierDrawLayer.setEditable(!0)}deactivate(){this.bezierDrawLayer.stopDraw(),this.bezierDrawLayer.stopEdit()}isActive(){return this.bezierDrawLayer.isDrawActive()||this.bezierDrawLayer.isEditActive()}startDraw(){this.bezierDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.bezierDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getBezierLayer(){return this.bezierDrawLayer}destroy(){this.bezierDrawLayer.destroy()}}class N_{constructor(t,e){this.id="sector-draw",this.name="扇形",this.icon="🥧",this.sectorDrawLayer=t,this.name=e.drawSector||"扇形"}activate(){this.sectorDrawLayer.setEditable(!0)}deactivate(){this.sectorDrawLayer.stopDraw(),this.sectorDrawLayer.stopEdit()}isActive(){return this.sectorDrawLayer.isDrawActive()||this.sectorDrawLayer.isEditActive()}startDraw(){this.sectorDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.sectorDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getSectorLayer(){return this.sectorDrawLayer}destroy(){this.sectorDrawLayer.destroy()}}var ct=(s=>(s.CIRCLE="circle-draw",s.RECTANGLE="rectangle-draw",s.TRIANGLE="triangle-draw",s.FREEHAND="freehand-draw",s.FREEHAND_POLYGON="freehand-polygon-draw",s.ELLIPSE="ellipse-draw",s.SECTOR="sector-draw",s.MARKER="marker-draw",s.TEXT="text-draw",s.ARROW="arrow-draw",s.BEZIER="bezier-draw",s.LINE="line-draw",s.IMAGE="image",s))(ct||{});class G_{constructor(t,e,i,n,r,o){this.toolbar=null,this.scaleBar=null,this.loadingOverlay=null,this.activePopupPanel=null,this.activePopupType=null,this.basemapOptionsInstance=null,this.layersPanelInstance=null,this.coordinatePickingDataPanel=null,this.container=t,this.theme=e,this.t=i,this.callbacks=n,this.getLayerListFn=r,this.getCurrentBasemapFn=o,this.currentBasemap=o()||dt.SATELLITE,this.init()}init(){this.toolbar=new t_({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(),onShowCoordinatePickingDataPanel:()=>this.showCoordinatePickingDataPanel()}),this.scaleBar=new o_(this.container,this.theme),this.loadingOverlay=new a_(this.container,this.theme)}getBasemapOptions(){return[{value:dt.SATELLITE,label:this.t.satellite,icon:"🛰️"},{value:dt.STREETS,label:this.t.streets,icon:"🗺️"},{value:dt.TOPO,label:this.t.topographic,icon:"⛰️"},{value:dt.HYBRID,label:this.t.hybrid,icon:"🔄"},{value:dt.TERRAIN,label:this.t.terrain,icon:"🗻"},{value:dt.OCEANS,label:this.t.oceans,icon:"🌊"},{value:dt.DARK_GRAY,label:this.t.darkGray,icon:"🌙"},{value:dt.LIGHT_GRAY,label:this.t.lightGray,icon:"☀️"},{value:dt.NATIONAL_GEOGRAPHIC,label:this.t.nationalGeographic,icon:"📰"},{value:dt.IMAGERY,label:this.t.imagery,icon:"📷"},{value:dt.PHYSICAL,label:this.t.physical,icon:"🌎"},{value:dt.AMAP_STREETS,label:this.t.amapStreets,icon:"🗺️"},{value:dt.AMAP_SATELLITE,label:this.t.amapSatellite,icon:"🛰️"},{value:dt.GOOGLE_STREETS,label:this.t.googleStreets,icon:"🗺️"},{value:dt.GOOGLE_SATELLITE,label:this.t.googleSatellite,icon:"🛰️"}]}handleTogglePopup(t){if(this.coordinatePickingDataPanel&&(this.coordinatePickingDataPanel.destroy(),this.coordinatePickingDataPanel=null),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 ar({title:this.t.layers,theme:this.theme,t:this.t,onClose:()=>{this.layersPanelInstance=null,this.handleTogglePopup(null)}}),this.layersPanelInstance=new e_({layerList:this.getLayerListFn(),onToggleVisibility:r=>this.callbacks.onToggleLayerVisibility(r),onRemoveLayer:r=>this.callbacks.onRemoveLayer(r),onGetLayerFeatures:r=>this.callbacks.onGetLayerFeatures?this.callbacks.onGetLayerFeatures(r):[],onLocateFeature:(r,o)=>{this.callbacks.onLocateFeature&&this.callbacks.onLocateFeature(r,o)},onCopyFeatureCoordinates:(r,o)=>{this.callbacks.onCopyFeatureCoordinates&&this.callbacks.onCopyFeatureCoordinates(r,o)},theme:this.theme,t:this.t}),e.appendChild(this.layersPanelInstance.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break;case"basemap":e=new ar({title:this.t.basemap,theme:this.theme,t:this.t,onClose:()=>{this.basemapOptionsInstance=null,this.handleTogglePopup(null)}}),this.basemapOptionsInstance=new i_({currentBasemap:this.currentBasemap,onSelect:r=>{this.callbacks.onSetBasemap(r)},theme:this.theme,t:this.t,options:this.getBasemapOptions()}),e.appendChild(this.basemapOptionsInstance.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break;case"draw":e=new ar({title:this.t.drawTools,theme:this.theme,t:this.t,onClose:()=>this.handleTogglePopup(null)});const i=new n_({onDrawCircle:()=>this.callbacks.onDrawCircle(),onDrawRectangle:()=>this.callbacks.onDrawRectangle(),onDrawTriangle:()=>this.callbacks.onDrawTriangle(),onDrawFreehand:()=>this.callbacks.onDrawFreehand(),onDrawFreehandPolygon:()=>this.callbacks.onDrawFreehandPolygon(),onDrawEllipse:()=>this.callbacks.onDrawEllipse(),onDrawMarker:()=>this.callbacks.onDrawMarker(),onDrawText:()=>this.callbacks.onDrawText(),onDrawArrow:()=>this.callbacks.onDrawArrow(),onDrawLine:()=>this.callbacks.onDrawLine(),onDrawBezier:()=>this.callbacks.onDrawBezier(),onDrawSector:()=>this.callbacks.onDrawSector(),onDrawImage:this.callbacks.onDrawImage,onEditShape:()=>this.callbacks.onEditShape(),theme:this.theme,t:this.t});e.appendChild(i.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break;case"tools":e=new ar({title:this.t.tools,theme:this.theme,t:this.t,onClose:()=>{this.handleTogglePopup(null),this.callbacks.onClearMeasurements()}});const n=new s_({onDistanceMeasure:()=>this.callbacks.onDistanceMeasure(),onAreaMeasure:()=>this.callbacks.onAreaMeasure(),onClearMeasurements:()=>this.callbacks.onClearMeasurements(),onPointCoordinatePick:()=>this.callbacks.onPointCoordinatePick(),onLineCoordinatePick:()=>this.callbacks.onLineCoordinatePick(),onPolygonCoordinatePick:()=>this.callbacks.onPolygonCoordinatePick(),onShowCoordinateList:()=>this.callbacks.onShowCoordinateList(),isMeasuring:!1,currentMeasureType:null,currentPickType:null,measurePreview:null,theme:this.theme,t:this.t});e.appendChild(n.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break}}updateCurrentBasemap(t){t!==null&&(this.currentBasemap=t,this.basemapOptionsInstance&&this.basemapOptionsInstance.updateCurrentBasemap(t))}refreshBasemapOptions(){this.basemapOptionsInstance&&this.activePopupType==="basemap"&&this.basemapOptionsInstance.updateProps({options:this.getBasemapOptions(),t:this.t,theme:this.theme,currentBasemap:this.currentBasemap})}updateLayerList(){this.activePopupType==="layers"&&this.layersPanelInstance&&this.layersPanelInstance.updateData(this.getLayerListFn())}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.basemapOptionsInstance&&this.basemapOptionsInstance.updateTheme(t),this.layersPanelInstance&&this.layersPanelInstance.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.refreshBasemapOptions(),this.activePopupType&&this.handleTogglePopup(this.activePopupType)}showCoordinatePickingDataPanel(){if(this.coordinatePickingDataPanel){this.coordinatePickingDataPanel.destroy(),this.coordinatePickingDataPanel=null;return}this.activePopupPanel&&(this.activePopupPanel.destroy(),this.activePopupPanel=null),this.activePopupType=null,this.toolbar?.updateActivePopup(null);const t=new l_({onClose:()=>{this.coordinatePickingDataPanel&&(this.coordinatePickingDataPanel.destroy(),this.coordinatePickingDataPanel=null)},onSelectCategory:e=>{console.log("选中分类:",e)},onLocatePoint:(e,i)=>{this.callbacks.onLocateCoordinate&&this.callbacks.onLocateCoordinate(e,i)},onLocateLine:e=>{this.callbacks.onLocateLine&&this.callbacks.onLocateLine(e)},onLocatePolygon:e=>{this.callbacks.onLocatePolygon&&this.callbacks.onLocatePolygon(e)},getPointData:()=>this.callbacks.getPointData?this.callbacks.getPointData():[],getLineData:()=>this.callbacks.getLineData?this.callbacks.getLineData():[],getPolygonData:()=>this.callbacks.getPolygonData?this.callbacks.getPolygonData():[],theme:this.theme,t:this.t});this.container.appendChild(t.getElement()),this.coordinatePickingDataPanel=t}destroy(){this.toolbar?.destroy(),this.scaleBar?.destroy(),this.loadingOverlay?.destroy(),this.activePopupPanel&&this.activePopupPanel.destroy(),this.coordinatePickingDataPanel&&this.coordinatePickingDataPanel.destroy(),this.basemapOptionsInstance=null,this.layersPanelInstance=null}getContainer(){return this.container}}class B_{constructor(){this.activeToolType=null,this.circleTool=null,this.rectangleTool=null,this.triangleTool=null,this.freehandTool=null,this.ellipseTool=null,this.markerTool=null,this.textTool=null,this.arrowTool=null,this.imageTool=null,this.lineTool=null,this.bezierTool=null,this.sectorTool=null}registerTools(t,e,i,n,r,o,a,l,h,c,d,u){this.circleTool=t,this.rectangleTool=e,this.triangleTool=i,this.freehandTool=n,this.ellipseTool=r,this.markerTool=o,this.textTool=a,this.arrowTool=l,this.lineTool=h,this.bezierTool=c,this.sectorTool=d,this.imageTool=u,this.circleTool?.setOnDrawComplete(()=>this.endDrawing()),this.rectangleTool?.setOnDrawComplete(()=>this.endDrawing()),this.triangleTool?.setOnDrawComplete(()=>this.endDrawing()),this.freehandTool?.setOnDrawComplete(()=>this.endDrawing()),this.ellipseTool?.setOnDrawComplete(()=>this.endDrawing()),this.markerTool?.setOnDrawComplete(()=>this.endDrawing()),this.textTool?.setOnDrawComplete(()=>this.endDrawing()),this.arrowTool?.setOnDrawComplete(()=>this.endDrawing()),this.imageTool?.setOnDrawComplete(()=>this.endDrawing()),this.circleTool?.setOnEditComplete(()=>this.endDrawing()),this.rectangleTool?.setOnEditComplete(()=>this.endDrawing()),this.triangleTool?.setOnEditComplete(()=>this.endDrawing()),this.freehandTool?.setOnEditComplete(()=>this.endDrawing()),this.ellipseTool?.setOnEditComplete(()=>this.endDrawing()),this.markerTool?.setOnEditComplete(()=>this.endDrawing()),this.textTool?.setOnEditComplete(()=>this.endDrawing()),this.arrowTool?.setOnEditComplete(()=>this.endDrawing()),this.imageTool?.setOnEditComplete(()=>this.endDrawing()),this.lineTool?.setOnDrawComplete(()=>this.endDrawing()),this.bezierTool?.setOnDrawComplete(()=>this.endDrawing()),this.sectorTool?.setOnDrawComplete(()=>this.endDrawing()),this.lineTool?.setOnEditComplete(()=>this.endDrawing()),this.bezierTool?.setOnEditComplete(()=>this.endDrawing()),this.sectorTool?.setOnEditComplete(()=>this.endDrawing())}startDrawingLine(){this.deactivateAll(),this.activeToolType=ct.LINE,this.lineTool?.startDraw(),this.onDrawingStartCallback?.(ct.LINE)}startDrawingBezier(){this.deactivateAll(),this.activeToolType=ct.BEZIER,this.bezierTool?.startDraw(),this.onDrawingStartCallback?.(ct.BEZIER)}startDrawingSector(){this.deactivateAll(),this.activeToolType=ct.SECTOR,this.sectorTool?.startDraw(),this.onDrawingStartCallback?.(ct.SECTOR)}setCallbacks(t,e){this.onDrawingStartCallback=t,this.onDrawingEndCallback=e}startDrawingCircle(){this.deactivateAll(),this.activeToolType=ct.CIRCLE,this.circleTool?.startDraw(),this.onDrawingStartCallback?.(ct.CIRCLE)}startDrawingRectangle(){this.deactivateAll(),this.activeToolType=ct.RECTANGLE,this.rectangleTool?.startDraw(),this.onDrawingStartCallback?.(ct.RECTANGLE)}startDrawingTriangle(){this.deactivateAll(),this.activeToolType=ct.TRIANGLE,this.triangleTool?.startDraw(),this.onDrawingStartCallback?.(ct.TRIANGLE)}startDrawingFreehand(){this.deactivateAll(),this.activeToolType=ct.FREEHAND,this.freehandTool?.startDraw(!1),this.onDrawingStartCallback?.(ct.FREEHAND)}startDrawingFreehandPolygon(){this.deactivateAll(),this.activeToolType=ct.FREEHAND_POLYGON,this.freehandTool?.startDraw(!0),this.onDrawingStartCallback?.(ct.FREEHAND_POLYGON)}startDrawingEllipse(){this.deactivateAll(),this.activeToolType=ct.ELLIPSE,this.ellipseTool?.startDraw(),this.onDrawingStartCallback?.(ct.ELLIPSE)}startDrawingMarker(){this.deactivateAll(),this.activeToolType=ct.MARKER,this.markerTool?.startDraw(),this.onDrawingStartCallback?.(ct.MARKER)}startDrawingText(){this.deactivateAll(),this.activeToolType=ct.TEXT,this.textTool?.startDraw(),this.onDrawingStartCallback?.(ct.TEXT)}startDrawingArrow(){this.deactivateAll(),this.activeToolType=ct.ARROW,this.arrowTool?.startDraw(),this.onDrawingStartCallback?.(ct.ARROW)}startDrawingImage(){this.deactivateAll(),this.activeToolType=ct.IMAGE,this.imageTool?.startDraw(),this.onDrawingStartCallback?.(ct.IMAGE)}cancelDrawing(){this.deactivateAll()}deactivateAll(){const t=this.activeToolType!==null;this.circleTool?.deactivate(),this.rectangleTool?.deactivate(),this.triangleTool?.deactivate(),this.freehandTool?.deactivate(),this.ellipseTool?.deactivate(),this.markerTool?.deactivate(),this.textTool?.deactivate(),this.arrowTool?.deactivate(),this.imageTool?.deactivate(),this.lineTool?.deactivate(),this.bezierTool?.deactivate(),this.sectorTool?.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,this.freehandTool=null,this.ellipseTool=null,this.markerTool=null,this.textTool=null,this.arrowTool=null,this.imageTool=null,this.lineTool=null,this.bezierTool=null,this.sectorTool=null}}class W_{constructor(){this.drawingManager=null,this.mapView=null,this.keydownHandler=null}setDrawingManager(t){this.drawingManager=t}setMapView(t){this.mapView=t}bindEvents(){this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{t.key==="Escape"&&this.handleEscCancel()},document.addEventListener("keydown",this.keydownHandler)}handleEscCancel(){this.drawingManager?.isDrawing()&&this.drawingManager.cancelDrawing()}unbindEvents(){this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}destroy(){this.unbindEvents(),this.drawingManager=null,this.mapView=null}}class U_ extends It{constructor(t,e,i){super(t,e,Z.LINE_COORDINATE_PICK,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.lines=new Map,this.onCompleteCallback=null,this.mapView=null,this.features=new Map,this.labelFeatures=new Map,this.lineColor=i?.lineColor||[0,200,255,1],this.lineWidth=i?.lineWidth||3,this.textColor=i?.textColor||[255,200,0,1],this.textSize=i?.textSize||12,this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.LINE_COORDINATE_PICK},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.t=i?.t||null}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startPick(t){this.stopPick(),this.onCompleteCallback=t||null,this.drawInteraction=new ee({source:this.source,type:"LineString"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates(),o=r.map(f=>{const[g,p]=U(f);return{longitude:g,latitude:p}}),a=Vt("LineCoordinatePick_"),l=Date.now(),h=Math.floor(o.length/2),c=r[h],d={id:a,points:o,timestamp:l,name:`${this.t?.linePick.default_name||"Line Pick"} ${new Date(l).toLocaleTimeString()}`};this.lines.set(a,d),this.features.set(a,i),i.setStyle(new A({stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})})),i.set("id",a),i.set("type","line_pick");const u=new V({geometry:new rt(c),id:a});u.set("type","line_pick"),u.setStyle(new A({text:new te({text:`${this.t?.linePick.label_prefix||"Line"} ${this.lines.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})})),this.labelFeatures.set(a,u),this.source?.addFeature(u),this.onCompleteCallback&&this.onCompleteCallback(d),this.stopPick()}),this.mapView?.addInteraction(this.drawInteraction)}stopPick(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}removeLine(t){const e=this.features.get(t),i=this.labelFeatures.get(t);return e&&(this.source?.removeFeature(e),this.features.delete(t)),i&&(this.source?.removeFeature(i),this.labelFeatures.delete(t)),this.lines.delete(t),!0}clearAllLines(){this.clear(),this.features.clear(),this.labelFeatures.clear(),this.lines.clear(),this.stopPick()}getAllLines(){return Array.from(this.lines.values())}getLine(t){return this.lines.get(t)}highlightLine(t){this.features.forEach((e,i)=>{const n=i===t;e.setStyle(new A({stroke:new G({color:M(n?[255,170,0,1]:this.lineColor),width:this.lineWidth+(n?2:0),lineDash:n?[]:[10,10]})}))}),this.labelFeatures.forEach((e,i)=>{const n=i===t;e.setStyle(new A({text:new te({text:n?this.t?.linePick.highlight_text||"● Line Pick ●":`${this.t?.linePick.label_prefix||"Line"} ${this.lines.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(n?[255,170,0,1]:this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}clearHighlight(){this.features.forEach(t=>{t.setStyle(new A({stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})}))}),this.labelFeatures.forEach(t=>{t.setStyle(new A({text:new te({text:`${this.t?.linePick.label_prefix||"Line"} ${this.lines.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}stopDraw(){this.stopPick()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return!1}setEditable(t){t||this.stopPick()}stopEdit(){this.stopPick()}getEditingId(){return null}cancelDraw(){this.stopPick()}cancelEdit(){this.stopPick()}updateData(t){}destroy(){this.stopPick(),super.destroy()}}class V_ extends It{constructor(t,e,i){super(t,e,Z.POLYGON_COORDINATE_PICK,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.polygons=new Map,this.onCompleteCallback=null,this.mapView=null,this.features=new Map,this.labelFeatures=new Map,this.fillColor=i?.fillColor||[0,200,255,.2],this.lineColor=i?.lineColor||[0,200,255,1],this.lineWidth=i?.lineWidth||2,this.textColor=i?.textColor||[255,200,0,1],this.textSize=i?.textSize||12,this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.POLYGON_COORDINATE_PICK},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.t=i?.t||null}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startPick(t){this.stopPick(),this.onCompleteCallback=t||null,this.drawInteraction=new ee({source:this.source,type:"Polygon"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates()[0],o=r.map(f=>{const[g,p]=U(f);return{longitude:g,latitude:p}}).slice(0,-1),a=Vt("PolygonCoordinatePick_"),l=Date.now();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 d={id:a,points:o,timestamp:l,name:`${this.t?.polygonPick.default_name||"Polygon Pick"} ${new Date(l).toLocaleTimeString()}`};this.polygons.set(a,d),this.features.set(a,i),i.setStyle(new A({fill:new j({color:M(this.fillColor)}),stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})})),i.set("id",a),i.set("type","polygon_pick");const u=new V({geometry:new rt([h,c]),id:a});u.set("type","polygon_pick"),u.setStyle(new A({text:new te({text:`${this.t?.polygonPick.label_prefix||"Polygon"} ${this.polygons.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"middle"})})),this.labelFeatures.set(a,u),this.source?.addFeature(u),this.onCompleteCallback&&this.onCompleteCallback(d),this.stopPick()}),this.mapView?.addInteraction(this.drawInteraction)}stopPick(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}removePolygon(t){const e=this.features.get(t),i=this.labelFeatures.get(t);return e&&(this.source?.removeFeature(e),this.features.delete(t)),i&&(this.source?.removeFeature(i),this.labelFeatures.delete(t)),this.polygons.delete(t),!0}clearAllPolygons(){this.clear(),this.features.clear(),this.labelFeatures.clear(),this.polygons.clear(),this.stopPick()}getAllPolygons(){return Array.from(this.polygons.values())}getPolygon(t){return this.polygons.get(t)}highlightPolygon(t){this.features.forEach((e,i)=>{const n=i===t;e.setStyle(new A({fill:new j({color:M(n?[255,170,0,.3]:this.fillColor)}),stroke:new G({color:M(n?[255,170,0,1]:this.lineColor),width:this.lineWidth+(n?2:0),lineDash:n?[]:[10,10]})}))}),this.labelFeatures.forEach((e,i)=>{const n=i===t;e.setStyle(new A({text:new te({text:n?this.t?.polygonPick.highlight_text||"● Polygon Pick ●":`${this.t?.polygonPick.label_prefix||"Polygon"} ${this.polygons.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(n?[255,170,0,1]:this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"middle"})}))}),this.mapView?.render()}clearHighlight(){this.features.forEach(t=>{t.setStyle(new A({fill:new j({color:M(this.fillColor)}),stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})}))}),this.labelFeatures.forEach(t=>{t.setStyle(new A({text:new te({text:`${this.t?.polygonPick.label_prefix||"Polygon"} ${this.polygons.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"middle"})}))}),this.mapView?.render()}stopDraw(){this.stopPick()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return!1}setEditable(t){t||this.stopPick()}stopEdit(){this.stopPick()}getEditingId(){return null}cancelDraw(){this.stopPick()}cancelEdit(){this.stopPick()}updateData(t){}destroy(){this.stopPick(),super.destroy()}}class H_{constructor(t,e){this.id="image-draw",this.name="图片标注",this.icon="🖼️",this.imageDrawLayer=t,this.name=e.drawImage||"图片标注"}activate(){this.imageDrawLayer.setEditable(!0)}deactivate(){this.imageDrawLayer.stopDraw(),this.imageDrawLayer.stopEdit()}isActive(){return this.imageDrawLayer.isDrawActive()||this.imageDrawLayer.isEditActive()}startDraw(){this.imageDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.imageDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}editProperties(t,e,i){this.imageDrawLayer.editProperties(t,e,i)}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getImageLayer(){return this.imageDrawLayer}destroy(){this.imageDrawLayer.destroy()}}class X_{constructor(t,e){this.options=t,this.currentImageUrl=t.initialImageUrl||"",this.currentImageData=t.initialImageData,this.overlay=this.createOverlay(),this.element=this.createElement(),document.body.appendChild(this.overlay),document.body.appendChild(this.element),e?this.setPosition(e):this.centerModal(),this.urlInput=this.element.querySelector(".image-input-modal-url"),this.widthInput=this.element.querySelector(".image-input-modal-width"),this.heightInput=this.element.querySelector(".image-input-modal-height"),this.opacityInput=this.element.querySelector(".image-input-modal-opacity"),this.opacityValue=this.element.querySelector(".image-input-modal-opacity-value"),this.imagePreview=this.element.querySelector(".image-input-modal-preview"),this.previewImg=this.element.querySelector(".image-input-modal-preview-img"),this.uploadBtn=this.element.querySelector(".image-input-modal-upload"),this.fileInput=this.element.querySelector(".image-input-modal-file-input"),this.confirmBtn=this.element.querySelector(".image-input-modal-confirm"),this.cancelBtn=this.element.querySelector(".image-input-modal-cancel"),this.deleteBtn=this.element.querySelector(".image-input-modal-delete"),this.bindEvents(),this.updatePreview()}createOverlay(){const t=document.createElement("div");return t.className="image-input-modal-overlay",t.style.cssText=`
|
|
1695
|
+
`:e==="line"?y+=`
|
|
1696
|
+
<div style="margin-bottom: 12px;">
|
|
1697
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.pointsCount}</div>
|
|
1698
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 13px;">${t.points.length} ${this.options.t.points}</div>
|
|
1699
|
+
</div>
|
|
1700
|
+
<div style="margin-bottom: 12px;">
|
|
1701
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.startPoint}</div>
|
|
1702
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.points[0]?.longitude.toFixed(6)}, ${t.points[0]?.latitude.toFixed(6)}</div>
|
|
1703
|
+
</div>
|
|
1704
|
+
<div style="margin-bottom: 12px;">
|
|
1705
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.endPoint}</div>
|
|
1706
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 12px; font-family: monospace;">${t.points[t.points.length-1]?.longitude.toFixed(6)}, ${t.points[t.points.length-1]?.latitude.toFixed(6)}</div>
|
|
1707
|
+
</div>
|
|
1708
|
+
`:e==="polygon"&&(y+=`
|
|
1709
|
+
<div style="margin-bottom: 12px;">
|
|
1710
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.vertexCount}</div>
|
|
1711
|
+
<div style="color: ${i?"#fff":"#333"}; font-size: 13px;">${t.points.length} ${this.options.t.points}</div>
|
|
1712
|
+
</div>
|
|
1713
|
+
`),y+=`
|
|
1714
|
+
<div style="margin-bottom: 12px;">
|
|
1715
|
+
<div style="color: ${i?"#888":"#666"}; font-size: 11px; margin-bottom: 4px;">${this.options.t.createdTime}</div>
|
|
1716
|
+
<div style="color: ${i?"#ddd":"#555"}; font-size: 11px;">${new Date(t.timestamp).toLocaleString()}</div>
|
|
1717
|
+
</div>
|
|
1718
|
+
`,m.innerHTML=y,u.appendChild(m);const x=document.createElement("div");x.style.cssText=`
|
|
1719
|
+
display: flex;
|
|
1720
|
+
gap: 8px;
|
|
1721
|
+
padding: 10px 12px;
|
|
1722
|
+
border-top: 1px solid ${i?"#444":"#ddd"};
|
|
1723
|
+
background: ${i?"#252525":"#fafafa"};
|
|
1724
|
+
flex-shrink: 0;
|
|
1725
|
+
`;const E=document.createElement("button");E.style.cssText=`
|
|
1726
|
+
flex: 1;
|
|
1727
|
+
background: #00aaff;
|
|
1728
|
+
border: none;
|
|
1729
|
+
cursor: pointer;
|
|
1730
|
+
padding: 6px;
|
|
1731
|
+
border-radius: 4px;
|
|
1732
|
+
color: white;
|
|
1733
|
+
font-size: 12px;
|
|
1734
|
+
transition: all 0.2s;
|
|
1735
|
+
`,E.textContent=this.options.t.locateOnMap,E.onmouseenter=()=>{E.style.background="#0088cc"},E.onmouseleave=()=>{E.style.background="#00aaff"},E.onclick=()=>{e==="point"&&this.options.onLocatePoint?this.options.onLocatePoint(t.longitude,t.latitude):e==="line"&&this.options.onLocateLine?this.options.onLocateLine(t.points):e==="polygon"&&this.options.onLocatePolygon&&this.options.onLocatePolygon(t.points),this.hideDetailPanel()};const w=document.createElement("button");w.style.cssText=`
|
|
1736
|
+
flex: 1;
|
|
1737
|
+
background: ${i?"#444":"#e0e0e0"};
|
|
1738
|
+
border: none;
|
|
1739
|
+
cursor: pointer;
|
|
1740
|
+
padding: 6px;
|
|
1741
|
+
border-radius: 4px;
|
|
1742
|
+
color: ${i?"#fff":"#333"};
|
|
1743
|
+
font-size: 12px;
|
|
1744
|
+
transition: all 0.2s;
|
|
1745
|
+
`,w.textContent=this.options.t.copyCoordinates,w.onmouseenter=()=>{w.style.background=i?"#555":"#d0d0d0"},w.onmouseleave=()=>{w.style.background=i?"#444":"#e0e0e0"},w.onclick=()=>{let v="";e==="point"?v=`${t.longitude.toFixed(8)}, ${t.latitude.toFixed(8)}`:e==="line"?v=t.points.map(_=>`${_.longitude.toFixed(8)}, ${_.latitude.toFixed(8)}`).join(`
|
|
1746
|
+
`):e==="polygon"&&(v=t.points.map(_=>`${_.longitude.toFixed(8)}, ${_.latitude.toFixed(8)}`).join(`
|
|
1747
|
+
`)),navigator.clipboard.writeText(v),this.showToast(this.options.t.coordinatesCopied)},x.appendChild(E),x.appendChild(w),u.appendChild(x),this.detailPanel.appendChild(u),r.appendChild(this.detailPanel);const C=v=>{this.detailPanel&&!this.detailPanel.contains(v.target)&&!this.element.contains(v.target)&&(this.hideDetailPanel(),document.removeEventListener("click",C))};setTimeout(()=>{document.addEventListener("click",C)},100)}injectScrollbarStylesForDetail(t){const e="earthview-detail-scroll-styles";if(document.getElementById(e))return;const i=t?"#555":"#ccc",n=t?"#2d2d2d":"#f0f0f0",o=`
|
|
1748
|
+
.earthview-detail-scroll {
|
|
1749
|
+
scrollbar-width: thin;
|
|
1750
|
+
scrollbar-color: ${i} ${n};
|
|
1751
|
+
}
|
|
1752
|
+
.earthview-detail-scroll::-webkit-scrollbar {
|
|
1753
|
+
width: 6px;
|
|
1754
|
+
}
|
|
1755
|
+
.earthview-detail-scroll::-webkit-scrollbar-track {
|
|
1756
|
+
background: ${n};
|
|
1757
|
+
border-radius: 3px;
|
|
1758
|
+
}
|
|
1759
|
+
.earthview-detail-scroll::-webkit-scrollbar-thumb {
|
|
1760
|
+
background: ${i};
|
|
1761
|
+
border-radius: 3px;
|
|
1762
|
+
}
|
|
1763
|
+
.earthview-detail-scroll::-webkit-scrollbar-thumb:hover {
|
|
1764
|
+
background: ${t?"#777":"#aaa"};
|
|
1765
|
+
}
|
|
1766
|
+
`,a=document.createElement("style");a.id=e,a.textContent=o,document.head.appendChild(a)}hideDetailPanel(){this.detailPanel&&(this.detailPanel.remove(),this.detailPanel=null)}showToast(t){const e=document.createElement("div");e.style.cssText=`
|
|
1767
|
+
position: fixed;
|
|
1768
|
+
bottom: 20px;
|
|
1769
|
+
left: 50%;
|
|
1770
|
+
transform: translateX(-50%);
|
|
1771
|
+
background: rgba(0,0,0,0.8);
|
|
1772
|
+
color: white;
|
|
1773
|
+
padding: 6px 12px;
|
|
1774
|
+
border-radius: 6px;
|
|
1775
|
+
font-size: 12px;
|
|
1776
|
+
z-index: 10000;
|
|
1777
|
+
pointer-events: none;
|
|
1778
|
+
white-space: nowrap;
|
|
1779
|
+
`,e.textContent=t,document.body.appendChild(e),setTimeout(()=>e.remove(),2e3)}refresh(){this.render()}setActiveCategory(t){this.activeCategory=t,this.render()}updateTheme(t){this.options.theme=t,this.render()}getElement(){return this.element}destroy(){this.hideDetailPanel(),this.element.remove()}}class Rd{constructor(t,e){this.id="circle-draw",this.name="Circle Draw",this.icon="⭕",this.circleDrawLayer=t,this.name=e.drawCircle||"Circle Draw"}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 Ad{constructor(t,e){this.id="rectangle-draw",this.name="Rectangle Draw",this.icon="◻️",this.rectangleDrawLayer=t,this.name=e.drawRectangle||"Rectangle Draw"}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 Md{constructor(t,e){this.id="triangle-draw",this.name="Triangle Draw",this.icon="▲",this.triangleDrawLayer=t,this.name=e.drawTriangle||"Triangle Draw"}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()}}class Fd{constructor(t,e,i=!1){this.id="freehand-draw",this.name="Freehand Line",this.icon="✏️",this.isPolygonMode=!1,this.freehandDrawLayer=t,this.isPolygonMode=i,this.name=i?e.drawFreehandPolygon||"Freehand Polygon":e.drawFreehandLine||"Freehand Line"}activate(){this.freehandDrawLayer.setEditable(!0)}deactivate(){this.freehandDrawLayer.stopDraw(),this.freehandDrawLayer.stopEdit()}isActive(){return this.freehandDrawLayer.isDrawActive()||this.freehandDrawLayer.isEditActive()}startDraw(t=!1){this.name=t?"Freehand Polygon":"Freehand Line",this.freehandDrawLayer.startDraw(t,e=>{this.onDrawComplete&&this.onDrawComplete(e)})}startEdit(t){this.freehandDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getFreehandLayer(){return this.freehandDrawLayer}destroy(){this.freehandDrawLayer.destroy()}}class Od{constructor(t,e){this.id="ellipse-draw",this.name="Ellipse Draw",this.icon="⚪",this.ellipseDrawLayer=t,this.name=e.drawEllipse||"Ellipse Draw"}activate(){this.ellipseDrawLayer.setEditable(!0)}deactivate(){this.ellipseDrawLayer.stopDraw(),this.ellipseDrawLayer.stopEdit()}isActive(){return this.ellipseDrawLayer.isDrawActive()||this.ellipseDrawLayer.isEditActive()}startDraw(){this.ellipseDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.ellipseDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getEllipseLayer(){return this.ellipseDrawLayer}destroy(){this.ellipseDrawLayer.destroy()}}class zd{constructor(t,e){this.id="marker-draw",this.name="Marker Draw",this.icon="📍",this.markerDrawLayer=t,this.name=e.drawMarker||"Marker Draw"}activate(){this.markerDrawLayer.setEditable(!0)}deactivate(){this.markerDrawLayer.stopDraw(),this.markerDrawLayer.stopEdit()}isActive(){return this.markerDrawLayer.isDrawActive()||this.markerDrawLayer.isEditActive()}startDraw(){this.markerDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.markerDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getMarkerLayer(){return this.markerDrawLayer}destroy(){this.markerDrawLayer.destroy()}}class $d{constructor(t,e){this.id="text-draw",this.name="Text Annotation",this.icon="📝",this.textDrawLayer=t,this.name=e.drawText||"Text Annotation"}activate(){this.textDrawLayer.setEditable(!0)}deactivate(){this.textDrawLayer.stopDraw(),this.textDrawLayer.stopEdit()}isActive(){return this.textDrawLayer.isDrawActive()||this.textDrawLayer.isEditActive()}startDraw(){this.textDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.textDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}editProperties(t,e,i){this.textDrawLayer.editProperties(t,e,i)}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getTextLayer(){return this.textDrawLayer}destroy(){this.textDrawLayer.destroy()}}class Nd{constructor(t,e){this.id="arrow-draw",this.name="Arrow Draw",this.icon="➡️",this.arrowDrawLayer=t,this.name=e.drawArrow||"Arrow Draw"}activate(){this.arrowDrawLayer.setEditable(!0)}deactivate(){this.arrowDrawLayer.stopDraw(),this.arrowDrawLayer.stopEdit()}isActive(){return this.arrowDrawLayer.isDrawActive()||this.arrowDrawLayer.isEditActive()}startDraw(){this.arrowDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.arrowDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getArrowLayer(){return this.arrowDrawLayer}destroy(){this.arrowDrawLayer.destroy()}}class d_{constructor(){this.tools=new Map,this.activeTool=null,this.eventHandlers=new Map}registerCircleTool(t,e){const i=new Rd(t,e);return this.registerTool(i),i}registerRectangleTool(t,e){const i=new Ad(t,e);return this.registerTool(i),i}registerTriangleTool(t,e){const i=new Md(t,e);return this.registerTool(i),i}registerFreehandTool(t,e){const i=new Fd(t,e);return this.registerTool(i),i}registerEllipseTool(t,e){const i=new Od(t,e);return this.registerTool(i),i}registerMarkerTool(t,e){const i=new zd(t,e);return this.registerTool(i),i}registerTextTool(t,e){const i=new $d(t,e);return this.registerTool(i),i}registerArrowTool(t,e){const i=new Nd(t,e);return this.registerTool(i),i}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))}getAllTools(){return Array.from(this.tools.values())}destroy(){this.tools.forEach(t=>t.destroy()),this.tools.clear(),this.eventHandlers.clear(),this.activeTool=null}}function Wo(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 $h(s,t){const e=s.layerStatesArray[s.layerIndex];e.extent&&(t=Ni(t,Fi(e.extent,s.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(s.viewState.projection).getExtent();n&&(t=Ni(t,n))}return t}class f_ extends Uc{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=oe(),this.tempTileRange_=new cl(0,0,0,0),this.tempTileCoord_=kr(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new Mh(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new Mh(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,a=this.getLayer().getSource(),l=dr(a,a.getKey(),t,e,i);let h;if(r.containsKey(l))h=r.get(l);else{const c=n.viewState.projection,d=a.getProjection();if(h=a.getTile(t,e,i,n.pixelRatio,c,!d||os(d,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=zt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Tn(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 d=l.getTileCoordForCoordAndZ(n,c),u=this.getTile(c,d[1],d[2],e);if(!u||u.getState()!==X.LOADED)continue;const f=l.getOrigin(c),g=ce(l.getTileSize(c)),p=l.getResolution(c);let m;if(u instanceof pd||u instanceof md)m=u.getImage();else if(u instanceof Dh){if(m=ga(u.getData()),!m)continue}else continue;const y=Math.floor(h*((n[0]-f[0])/p-d[1]*g[0])),x=Math.floor(h*((f[1]-n[1])/p-d[2]*g[1])),E=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(m,y+E,x+E)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,i,n,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=K(l);c in t.wantedTiles||(t.wantedTiles[c]={});const d=t.wantedTiles[c],u=a.getMapInternal(),f=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),u?u.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,p=g?Hh(o.center,o.resolution,g,t.size):void 0;for(let m=i;m>=f;--m){const y=h.getTileRangeForExtentAndZ(e,m,this.tempTileRange_),x=h.getResolution(m);for(let E=y.minX;E<=y.maxX;++E)for(let w=y.minY;w<=y.maxY;++w){if(g&&!h.tileCoordIntersectsViewport([m,E,w],p))continue;const C=this.getTile(m,E,w,t);if(!C||!Wo(n,C,m))continue;const _=C.getKey();if(d[_]=!0,C.getState()===X.IDLE&&!t.tileQueue.isKeyQueued(_)){const b=kr(m,E,w,this.tempTileCoord_);t.tileQueue.enqueue([C,c,h.getTileCoordCenter(b),x])}}}}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=dr(this.getLayer().getSource(),a[l],n,r,o);if(i.containsKey(h)){const c=i.peek(h);if(c.getState()===X.LOADED)return c.endTransition(K(this)),Wo(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 d=r.minY;d<=r.maxY;++d){const u=dr(l,h,i,c,d);let f=!1;if(a.containsKey(u)){const g=a.peek(u);g.getState()===X.LOADED&&(Wo(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(),d=c.getTileGridForProjection(r),u=d.getZForResolution(o,c.zDirection),f=d.getResolution(u),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let p=t.extent;const m=c.getTilePixelRatio(l);this.prepareContainer(t,e);const y=this.context.canvas.width,x=this.context.canvas.height;this.layerExtent=i.extent?Fi(i.extent):null,this.layerExtent&&(p=Ni(p,this.layerExtent));const E=f*y/2/m,w=f*x/2/m,C=[a[0]-E,a[1]-w,a[0]+E,a[1]+w],v={};this.renderedTiles.length=0;const _=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){const D=d.getZForResolution(n.nextResolution,c.zDirection),z=$h(t,t.nextExtent);this.enqueueTiles(t,z,D,v,_)}const b=$h(t,p);if(this.enqueueTiles(t,b,u,v,0),_>0&&setTimeout(()=>{this.enqueueTiles(t,b,u-1,v,_-1)},0),!(u in v))return this.container;const S=K(this),P=t.time;for(const D of v[u]){const z=D.getState();if(z===X.EMPTY)continue;const N=D.tileCoord;if(z===X.LOADED&&D.getAlpha(S,P)===1){D.endTransition(S);continue}if(z!==X.ERROR&&(this.renderComplete=!1),this.findStaleTile_(N,v)){u_(v,D,u),t.animate=!0;continue}if(this.findAltTiles_(d,N,u+1,v))continue;const ht=d.getMinZoom();for(let ot=u-1;ot>=ht&&!this.findAltTiles_(d,N,ot,v);--ot);}const L=f/o*l/m,k=this.getRenderContext(t);Pe(this.tempTransform,y/2,x/2,L,L,0,-y/2,-x/2),this.layerExtent&&this.clipUnrotated(k,t,this.layerExtent),c.getInterpolate()||(k.imageSmoothingEnabled=!1),this.preRender(k,t);const F=Object.keys(v).map(Number);F.sort(ai);let O;const R=[],B=[];for(let D=F.length-1;D>=0;--D){const z=F[D],N=c.getTilePixelSize(z,l,r),et=d.getResolution(z)/f,ht=N[0]*et*L,ot=N[1]*et*L,I=d.getTileCoordForCoordAndZ(ji(C),z),xt=d.getTileCoordExtent(I),yt=zt(this.tempTransform,[m*(xt[0]-C[0])/f,m*(C[3]-xt[3])/f]),Ot=m*c.getGutterForProjection(r);for(const ie of v[z]){if(ie.getState()!==X.LOADED)continue;const Ne=ie.tileCoord,St=I[1]-Ne[1],vt=Math.round(yt[0]-(St-1)*ht),Dt=I[2]-Ne[2],Kt=Math.round(yt[1]-(Dt-1)*ot),kt=Math.round(yt[0]-St*ht),Ht=Math.round(yt[1]-Dt*ot),de=vt-kt,gi=Kt-Ht,Fs=F.length===1;let On=!1;O=[kt,Ht,kt+de,Ht,kt+de,Ht+gi,kt,Ht+gi];for(let qi=0,Os=R.length;qi<Os;++qi)if(!Fs&&z<B[qi]){const ne=R[qi];le([kt,Ht,kt+de,Ht+gi],[ne[0],ne[3],ne[4],ne[7]])&&(On||(k.save(),On=!0),k.beginPath(),k.moveTo(O[0],O[1]),k.lineTo(O[2],O[3]),k.lineTo(O[4],O[5]),k.lineTo(O[6],O[7]),k.moveTo(ne[6],ne[7]),k.lineTo(ne[4],ne[5]),k.lineTo(ne[2],ne[3]),k.lineTo(ne[0],ne[1]),k.clip())}R.push(O),B.push(z),this.drawTile(ie,t,kt,Ht,de,gi,Ot,Fs),On&&k.restore(),this.renderedTiles.unshift(ie),this.updateUsedTiles(t.usedTiles,c,ie)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!bn(this.renderedExtent_,C),this.renderedExtent_=C,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&k.restore(),k.imageSmoothingEnabled=!0,this.renderComplete){const D=(z,N)=>{const tt=K(c),et=N.wantedTiles[tt],ht=et?Object.keys(et).length:0;this.updateCacheSize(ht),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(D)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,n,r,o,a,l){let h;if(t instanceof Dh){if(h=ga(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),d=K(this),u=e.layerStatesArray[e.layerIndex],f=u.opacity*(l?t.getAlpha(d,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!==u.opacity?e.animate=!0:l&&t.endTransition(d)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const n=K(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}}const hr={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class g_ extends Qr{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(hr.PRELOAD)}setPreload(t){this.set(hr.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(hr.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(hr.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class jn extends g_{constructor(t){super(t)}createRenderer(){return new f_(this,{cacheSize:this.getCacheSize()})}}const ln=[0,0,0],xi=5;class Gd{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,gt(eu(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,gt(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_=ji(i)),gt(!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,gt(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:el,gt(!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 cl(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=sn(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 sn(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 sn(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 sn(h,h,c,c,i);const d=Math.floor(l*(r+1))-1,u=Math.floor(l*(o+1))-1;return sn(h,d,c,u,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,ln);const n=ln[1],r=ln[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,ln);const o=ln[1],a=ln[2];return sn(n,o,r,a,i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),n=ce(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=ce(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 di(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=ce(this.getTileSize(o),this.tmpSize_);let c=a*(t-l[0])/i/h[0],d=a*(l[1]-e)/i/h[1];return n?(c=Ws(c,xi)-1,d=Ws(d,xi)-1):(c=Bs(c,xi),d=Bs(d,xi)),kr(o,c,d,r)}getTileCoordForXYAndZ_(t,e,i,n,r){const o=this.getOrigin(i),a=this.getResolution(i),l=ce(this.getTileSize(i),this.tmpSize_);let h=(t-o[0])/a/l[0],c=(o[1]-e)/a/l[1];return n?(h=Ws(h,xi)-1,c=Ws(c,xi)-1):(h=Bs(h,xi),c=Bs(c,xi)),kr(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=xa(this.resolutions_,t,e||0);return Pt(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return pc(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 Bd(s){let t=s.getDefaultTileGrid();return t||(t=__(s),s.setDefaultTileGrid(t)),t}function p_(s,t,e){const i=t[0],n=s.getTileCoordCenter(t),r=vl(e);if(!Tn(r,n)){const o=Et(r),a=Math.ceil((r[0]-n[0])/o);return n[0]+=o*a,s.getTileCoordForCoordAndZ(n,i)}return t}function m_(s,t,e,i){i=i!==void 0?i:"top-left";const n=Wd(s,t,e);return new Gd({extent:s,origin:ou(s,i),resolutions:n,tileSize:e})}function y_(s){const t=s||{},e=t.extent||Ft("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:Wd(e,t.maxZoom,t.tileSize,t.maxResolution)};return new Gd(i)}function Wd(s,t,e,i){t=t!==void 0?t:_p,e=ce(e!==void 0?e:el);const n=he(s),r=Et(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 __(s,t,e,i){const n=vl(s);return m_(n,t,e,i)}function vl(s){s=Ft(s);let t=s.getExtent();if(!t){const e=180*Sa.degrees/s.getMetersPerUnit();t=di(-e,-e,e,e)}return t}const w_=/\{z\}/g,x_=/\{x\}/g,C_=/\{y\}/g,E_=/\{-y\}/g;function v_(s,t,e,i,n){return s.replace(w_,t.toString()).replace(x_,e.toString()).replace(C_,i.toString()).replace(E_,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 T_(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 b_(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 v_(s,o,e[1],e[2],r)})}function S_(s,t){const e=s.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=b_(s[n],t);return P_(i)}function P_(s){return s.length===1?s[0]:(function(t,e,i){if(!t)return;const n=Vm(t),r=Gi(n,s.length);return s[r](t,e,i)})}class I_ extends id{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&&ce(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||K(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,n,r,o){return Q()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Bd(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const n=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),o=ce(n.getTileSize(t),this.tmpSize);return r==1?o:eg(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=p_(n,t,i)),Xm(t,n)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class L_ extends qe{constructor(t,e){super(t),this.tile=e}}const Uo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class Tl extends I_{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===Tl.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,i=K(e),n=e.getState();let r;n==X.LOADING?(this.tileLoadingKeys_[i]=!0,r=Uo.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==X.ERROR?Uo.TILELOADERROR:n==X.LOADED?Uo.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new L_(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=T_(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join(`
|
|
1780
|
+
`);this.generateTileUrlFunction_?this.setTileUrlFunction(S_(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class D_ extends Tl{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:k_,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:pd,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!os(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||os(e,t)))return this.tileGrid;const i=K(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Bd(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?X.IDLE:X.EMPTY,h!==void 0?h:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(nt.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,n,r,o){const a=this.getProjection();if(!a||!r||os(a,r))return this.getTileInternal(t,e,i,n,a||r);const l=[t,e,i],h=this.getKey(),c=this.getTileGridForProjection(a),d=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(l,r),f=new md(a,c,r,d,l,u,this.getTilePixelRatio(n),this.getGutter(),(g,p,m,y)=>this.getTileInternal(g,p,m,y,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=dr(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=Ft(t);if(i){const n=K(i);n in this.tileGridForProjection||(this.tileGridForProjection[n]=e)}}}function k_(s,t){if(Ee){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 ns extends D_{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:y_({extent:vl(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_}}const R_='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class A_ extends ns{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[R_];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 Mt=Math.PI,Mr=6378245,Fr=.006693421622965943;function bl(s,t){return s<72.004||s>137.8347||t<.8293||t>55.8271}function Ud(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*Mt)+20*Math.sin(2*s*Mt))*(2/3),e+=(20*Math.sin(t*Mt)+40*Math.sin(t/3*Mt))*(2/3),e+=(160*Math.sin(t/12*Mt)+320*Math.sin(t*Mt/30))*(2/3),e}function Vd(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*Mt)+20*Math.sin(2*s*Mt))*(2/3),e+=(20*Math.sin(s*Mt)+40*Math.sin(s/3*Mt))*(2/3),e+=(150*Math.sin(s/12*Mt)+300*Math.sin(s*Mt/30))*(2/3),e}function Sl(s,t){if(bl(s,t))return[s,t];let e=Ud(s-105,t-35),i=Vd(s-105,t-35);const n=t/180*Mt;let r=Math.sin(n);r=1-Fr*r*r;const o=Math.sqrt(r);return e=e*180/(Mr*(1-Fr)/(r*o)*Mt),i=i*180/(Mr/o*Math.cos(n)*Mt),[s-i,t-e]}function Nh(s,t){if(bl(s,t))return[s,t];let e=Ud(s-105,t-35),i=Vd(s-105,t-35);const n=t/180*Mt;let r=Math.sin(n);r=1-Fr*r*r;const o=Math.sqrt(r);return e=e*180/(Mr*(1-Fr)/(r*o)*Mt),i=i*180/(Mr/o*Math.cos(n)*Mt),[s+i,t+e]}function M_(s,t){const e=s,i=t,n=Math.sqrt(e*e+i*i)+2e-5*Math.sin(i*Mt),r=Math.atan2(i,e)+3e-6*Math.cos(e*Mt),o=n*Math.cos(r)+.0065,a=n*Math.sin(r)+.006;return[o,a]}function F_(s,t){const e=s-.0065,i=t-.006,n=Math.sqrt(e*e+i*i)-2e-5*Math.sin(i*Mt),r=Math.atan2(i,e)-3e-6*Math.cos(e*Mt),o=n*Math.cos(r),a=n*Math.sin(r);return[o,a]}function Hd(s,t){const[e,i]=F_(s,t);return Sl(e,i)}function _a(s,t,e){switch(e){case Oe.WGS84:return[s,t];case Oe.GCJ02:return Sl(s,t);case Oe.BD09:return Hd(s,t);default:return[s,t]}}function O_(s,t,e){switch(e){case Oe.WGS84:return[s,t];case Oe.GCJ02:return Nh(s,t);case Oe.BD09:return M_(...Nh(s,t));default:return[s,t]}}function z_(s,t){return!bl(s,t)}const Vo={[dt.SATELLITE]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.STREETS]:{url:"https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"OpenStreetMap"},[dt.TOPO]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.OCEANS]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.DARK_GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.NATIONAL_GEOGRAPHIC]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.TERRAIN]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.HYBRID]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.LIGHT_GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.IMAGERY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.PHYSICAL]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[dt.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:"高德地图"},[dt.AMAP_SATELLITE]:{url:"https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",attribution:"高德地图"},[dt.GOOGLE_STREETS]:{url:"http://www.google.cn/maps/vt?lyrs=m&x={x}&y={y}&z={z}",attribution:"Google"},[dt.GOOGLE_SATELLITE]:{url:"http://www.google.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",attribution:"Google"}};class $_{constructor(t,e,i,n,r,o){getComputedStyle(t).position==="static"&&(t.style.position="relative");let a=i;r!==Oe.WGS84&&(a=_a(i[0],i[1],r)),e===dt.CUSTOMIZE&&o?(this.basemapLayer=this.createBasemapLayerFromUrl(o),this.currentBasemap=null):(this.basemapLayer=this.createBasemapLayer(e),this.currentBasemap=e),this.view=new He({center:ut(a),zoom:n,minZoom:1,maxZoom:19}),this.map=new dd({target:t,layers:[this.basemapLayer],view:this.view,controls:[],interactions:ld({doubleClickZoom:!1})})}createBasemapLayerFromUrl(t){const e=new ns({url:t});return new jn({source:e})}createBasemapLayer(t){const e=Vo[t];if(t===dt.STREETS){const n=new A_;return new jn({source:n})}if(e){const n=new ns({url:e.url,attributions:e.attribution});return new jn({source:n})}const i=new ns({url:Vo[dt.SATELLITE]?.url,attributions:Vo[dt.SATELLITE]?.attribution});return new jn({source:i})}setBasemapByUrl(t){const e=new ns({url:t}),i=new jn({source:e});this.map.removeLayer(this.basemapLayer),this.basemapLayer=i,this.map.addLayer(this.basemapLayer),this.currentBasemap=null}setBasemap(t){this.map.removeLayer(this.basemapLayer),this.basemapLayer=this.createBasemapLayer(t),this.map.addLayer(this.basemapLayer),this.currentBasemap=t}getCurrentBasemap(){return this.currentBasemap}getMap(){return this.map}getView(){return this.view}getCenter(){const t=U(this.view.getCenter()||[0,0]);return[t[0],t[1]]}getZoom(){return this.view.getZoom()||0}setCenter(t,e){let i=t;e&&e!==Oe.WGS84&&(i=_a(t[0],t[1],e)),this.view.setCenter(ut(i))}setZoom(t){this.view.setZoom(t)}setRotation(t){this.view.setRotation(t)}destroy(){this.map.setTarget(void 0),this.map.dispose()}}class N_{constructor(t,e){this.id="line-draw",this.name="Line",this.icon="━━",this.lineDrawLayer=t,this.name=e.drawLine||"Line"}activate(){this.lineDrawLayer.setEditable(!0)}deactivate(){this.lineDrawLayer.stopDraw(),this.lineDrawLayer.stopEdit()}isActive(){return this.lineDrawLayer.isDrawActive()||this.lineDrawLayer.isEditActive()}startDraw(){this.lineDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.lineDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getLineLayer(){return this.lineDrawLayer}destroy(){this.lineDrawLayer.destroy()}}class G_{constructor(t,e){this.id="bezier-draw",this.name="Bezier Curve",this.icon="〰️",this.bezierDrawLayer=t,this.name=e.drawBezier||"Bezier Curve"}activate(){this.bezierDrawLayer.setEditable(!0)}deactivate(){this.bezierDrawLayer.stopDraw(),this.bezierDrawLayer.stopEdit()}isActive(){return this.bezierDrawLayer.isDrawActive()||this.bezierDrawLayer.isEditActive()}startDraw(){this.bezierDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.bezierDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getBezierLayer(){return this.bezierDrawLayer}destroy(){this.bezierDrawLayer.destroy()}}class B_{constructor(t,e){this.id="sector-draw",this.name="Sector",this.icon="🥧",this.sectorDrawLayer=t,this.name=e.drawSector||"Sector"}activate(){this.sectorDrawLayer.setEditable(!0)}deactivate(){this.sectorDrawLayer.stopDraw(),this.sectorDrawLayer.stopEdit()}isActive(){return this.sectorDrawLayer.isDrawActive()||this.sectorDrawLayer.isEditActive()}startDraw(){this.sectorDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.sectorDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getSectorLayer(){return this.sectorDrawLayer}destroy(){this.sectorDrawLayer.destroy()}}var ct=(s=>(s.CIRCLE="circle-draw",s.RECTANGLE="rectangle-draw",s.TRIANGLE="triangle-draw",s.FREEHAND="freehand-draw",s.FREEHAND_POLYGON="freehand-polygon-draw",s.ELLIPSE="ellipse-draw",s.SECTOR="sector-draw",s.MARKER="marker-draw",s.TEXT="text-draw",s.ARROW="arrow-draw",s.BEZIER="bezier-draw",s.LINE="line-draw",s.IMAGE="image",s))(ct||{});class W_{constructor(t,e,i,n,r,o){this.toolbar=null,this.scaleBar=null,this.loadingOverlay=null,this.activePopupPanel=null,this.activePopupType=null,this.basemapOptionsInstance=null,this.layersPanelInstance=null,this.coordinatePickingDataPanel=null,this.container=t,this.theme=e,this.t=i,this.callbacks=n,this.getLayerListFn=r,this.getCurrentBasemapFn=o,this.currentBasemap=o()||dt.SATELLITE,this.init()}init(){this.toolbar=new i_({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(),onShowCoordinatePickingDataPanel:()=>this.showCoordinatePickingDataPanel()}),this.scaleBar=new l_(this.container,this.theme),this.loadingOverlay=new h_(this.container,this.theme)}getBasemapOptions(){return[{value:dt.SATELLITE,label:this.t.satellite,icon:"🛰️"},{value:dt.STREETS,label:this.t.streets,icon:"🗺️"},{value:dt.TOPO,label:this.t.topographic,icon:"⛰️"},{value:dt.HYBRID,label:this.t.hybrid,icon:"🔄"},{value:dt.TERRAIN,label:this.t.terrain,icon:"🗻"},{value:dt.OCEANS,label:this.t.oceans,icon:"🌊"},{value:dt.DARK_GRAY,label:this.t.darkGray,icon:"🌙"},{value:dt.LIGHT_GRAY,label:this.t.lightGray,icon:"☀️"},{value:dt.NATIONAL_GEOGRAPHIC,label:this.t.nationalGeographic,icon:"📰"},{value:dt.IMAGERY,label:this.t.imagery,icon:"📷"},{value:dt.PHYSICAL,label:this.t.physical,icon:"🌎"},{value:dt.AMAP_STREETS,label:this.t.amapStreets,icon:"🗺️"},{value:dt.AMAP_SATELLITE,label:this.t.amapSatellite,icon:"🛰️"},{value:dt.GOOGLE_STREETS,label:this.t.googleStreets,icon:"🗺️"},{value:dt.GOOGLE_SATELLITE,label:this.t.googleSatellite,icon:"🛰️"}]}handleTogglePopup(t){if(this.coordinatePickingDataPanel&&(this.coordinatePickingDataPanel.destroy(),this.coordinatePickingDataPanel=null),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 lr({title:this.t.layers,theme:this.theme,t:this.t,onClose:()=>{this.layersPanelInstance=null,this.handleTogglePopup(null)}}),this.layersPanelInstance=new n_({layerList:this.getLayerListFn(),onToggleVisibility:r=>this.callbacks.onToggleLayerVisibility(r),onRemoveLayer:r=>this.callbacks.onRemoveLayer(r),onGetLayerFeatures:r=>this.callbacks.onGetLayerFeatures?this.callbacks.onGetLayerFeatures(r):[],onLocateFeature:(r,o)=>{this.callbacks.onLocateFeature&&this.callbacks.onLocateFeature(r,o)},onCopyFeatureCoordinates:(r,o)=>{this.callbacks.onCopyFeatureCoordinates&&this.callbacks.onCopyFeatureCoordinates(r,o)},theme:this.theme,t:this.t}),e.appendChild(this.layersPanelInstance.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement()),e.onAttached(),this.adjustPopupPosition(e);break;case"basemap":e=new lr({title:this.t.basemap,theme:this.theme,t:this.t,onClose:()=>{this.basemapOptionsInstance=null,this.handleTogglePopup(null)}}),this.basemapOptionsInstance=new s_({currentBasemap:this.currentBasemap,onSelect:r=>{this.callbacks.onSetBasemap(r)},theme:this.theme,t:this.t,options:this.getBasemapOptions()}),e.appendChild(this.basemapOptionsInstance.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement()),e.onAttached(),this.adjustPopupPosition(e);break;case"draw":e=new lr({title:this.t.drawTools,theme:this.theme,t:this.t,onClose:()=>this.handleTogglePopup(null)});const i=new r_({onDrawCircle:()=>this.callbacks.onDrawCircle(),onDrawRectangle:()=>this.callbacks.onDrawRectangle(),onDrawTriangle:()=>this.callbacks.onDrawTriangle(),onDrawFreehand:()=>this.callbacks.onDrawFreehand(),onDrawFreehandPolygon:()=>this.callbacks.onDrawFreehandPolygon(),onDrawEllipse:()=>this.callbacks.onDrawEllipse(),onDrawMarker:()=>this.callbacks.onDrawMarker(),onDrawText:()=>this.callbacks.onDrawText(),onDrawArrow:()=>this.callbacks.onDrawArrow(),onDrawLine:()=>this.callbacks.onDrawLine(),onDrawBezier:()=>this.callbacks.onDrawBezier(),onDrawSector:()=>this.callbacks.onDrawSector(),onDrawImage:this.callbacks.onDrawImage,onEditShape:()=>this.callbacks.onEditShape(),theme:this.theme,t:this.t});e.appendChild(i.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement()),e.onAttached(),this.adjustPopupPosition(e);break;case"tools":e=new lr({title:this.t.tools,theme:this.theme,t:this.t,onClose:()=>{this.handleTogglePopup(null)}});const n=new o_({onDistanceMeasure:()=>this.callbacks.onDistanceMeasure(),onAreaMeasure:()=>this.callbacks.onAreaMeasure(),onClearMeasurements:()=>this.callbacks.onClearMeasurements(),onPointCoordinatePick:()=>this.callbacks.onPointCoordinatePick(),onLineCoordinatePick:()=>this.callbacks.onLineCoordinatePick(),onPolygonCoordinatePick:()=>this.callbacks.onPolygonCoordinatePick(),onShowCoordinateList:()=>this.callbacks.onShowCoordinateList(),isMeasuring:!1,currentMeasureType:null,currentPickType:null,measurePreview:null,theme:this.theme,t:this.t});e.appendChild(n.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement()),e.onAttached(),this.adjustPopupPosition(e);break}}adjustPopupPosition(t){setTimeout(()=>{const e=t.getElement();if(!e)return;const i=this.container.getBoundingClientRect(),n=e.getBoundingClientRect(),r=n.bottom,o=i.bottom;if(r>o){const a=o-n.top-10;a>100?e.style.maxHeight=`${a}px`:e.style.maxHeight="100px"}},10)}updateCurrentBasemap(t){t!==null&&(this.currentBasemap=t,this.basemapOptionsInstance&&this.basemapOptionsInstance.updateCurrentBasemap(t))}refreshBasemapOptions(){this.basemapOptionsInstance&&this.activePopupType==="basemap"&&this.basemapOptionsInstance.updateProps({options:this.getBasemapOptions(),t:this.t,theme:this.theme,currentBasemap:this.currentBasemap})}updateLayerList(){this.activePopupType==="layers"&&this.layersPanelInstance&&this.layersPanelInstance.updateData(this.getLayerListFn())}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.basemapOptionsInstance&&this.basemapOptionsInstance.updateTheme(t),this.layersPanelInstance&&this.layersPanelInstance.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.refreshBasemapOptions(),this.activePopupType&&this.handleTogglePopup(this.activePopupType)}showCoordinatePickingDataPanel(){if(this.coordinatePickingDataPanel){this.coordinatePickingDataPanel.destroy(),this.coordinatePickingDataPanel=null;return}this.activePopupPanel&&(this.activePopupPanel.destroy(),this.activePopupPanel=null),this.activePopupType=null,this.toolbar?.updateActivePopup(null);const t=new c_({onClose:()=>{this.coordinatePickingDataPanel&&(this.coordinatePickingDataPanel.destroy(),this.coordinatePickingDataPanel=null)},onSelectCategory:e=>{},onLocatePoint:(e,i)=>{this.callbacks.onLocateCoordinate&&this.callbacks.onLocateCoordinate(e,i)},onLocateLine:e=>{this.callbacks.onLocateLine&&this.callbacks.onLocateLine(e)},onLocatePolygon:e=>{this.callbacks.onLocatePolygon&&this.callbacks.onLocatePolygon(e)},getPointData:()=>this.callbacks.getPointData?this.callbacks.getPointData():[],getLineData:()=>this.callbacks.getLineData?this.callbacks.getLineData():[],getPolygonData:()=>this.callbacks.getPolygonData?this.callbacks.getPolygonData():[],theme:this.theme,t:this.t});this.container.appendChild(t.getElement()),this.coordinatePickingDataPanel=t}destroy(){this.toolbar?.destroy(),this.scaleBar?.destroy(),this.loadingOverlay?.destroy(),this.activePopupPanel&&this.activePopupPanel.destroy(),this.coordinatePickingDataPanel&&this.coordinatePickingDataPanel.destroy(),this.basemapOptionsInstance=null,this.layersPanelInstance=null}getContainer(){return this.container}}class U_{constructor(){this.activeToolType=null,this.circleTool=null,this.rectangleTool=null,this.triangleTool=null,this.freehandTool=null,this.ellipseTool=null,this.markerTool=null,this.textTool=null,this.arrowTool=null,this.imageTool=null,this.lineTool=null,this.bezierTool=null,this.sectorTool=null}registerTools(t,e,i,n,r,o,a,l,h,c,d,u){this.circleTool=t,this.rectangleTool=e,this.triangleTool=i,this.freehandTool=n,this.ellipseTool=r,this.markerTool=o,this.textTool=a,this.arrowTool=l,this.lineTool=h,this.bezierTool=c,this.sectorTool=d,this.imageTool=u,this.circleTool?.setOnDrawComplete(()=>this.endDrawing()),this.rectangleTool?.setOnDrawComplete(()=>this.endDrawing()),this.triangleTool?.setOnDrawComplete(()=>this.endDrawing()),this.freehandTool?.setOnDrawComplete(()=>this.endDrawing()),this.ellipseTool?.setOnDrawComplete(()=>this.endDrawing()),this.markerTool?.setOnDrawComplete(()=>this.endDrawing()),this.textTool?.setOnDrawComplete(()=>this.endDrawing()),this.arrowTool?.setOnDrawComplete(()=>this.endDrawing()),this.imageTool?.setOnDrawComplete(()=>this.endDrawing()),this.circleTool?.setOnEditComplete(()=>this.endDrawing()),this.rectangleTool?.setOnEditComplete(()=>this.endDrawing()),this.triangleTool?.setOnEditComplete(()=>this.endDrawing()),this.freehandTool?.setOnEditComplete(()=>this.endDrawing()),this.ellipseTool?.setOnEditComplete(()=>this.endDrawing()),this.markerTool?.setOnEditComplete(()=>this.endDrawing()),this.textTool?.setOnEditComplete(()=>this.endDrawing()),this.arrowTool?.setOnEditComplete(()=>this.endDrawing()),this.imageTool?.setOnEditComplete(()=>this.endDrawing()),this.lineTool?.setOnDrawComplete(()=>this.endDrawing()),this.bezierTool?.setOnDrawComplete(()=>this.endDrawing()),this.sectorTool?.setOnDrawComplete(()=>this.endDrawing()),this.lineTool?.setOnEditComplete(()=>this.endDrawing()),this.bezierTool?.setOnEditComplete(()=>this.endDrawing()),this.sectorTool?.setOnEditComplete(()=>this.endDrawing())}startDrawingLine(){this.deactivateAll(),this.activeToolType=ct.LINE,this.lineTool?.startDraw(),this.onDrawingStartCallback?.(ct.LINE)}startDrawingBezier(){this.deactivateAll(),this.activeToolType=ct.BEZIER,this.bezierTool?.startDraw(),this.onDrawingStartCallback?.(ct.BEZIER)}startDrawingSector(){this.deactivateAll(),this.activeToolType=ct.SECTOR,this.sectorTool?.startDraw(),this.onDrawingStartCallback?.(ct.SECTOR)}setCallbacks(t,e){this.onDrawingStartCallback=t,this.onDrawingEndCallback=e}startDrawingCircle(){this.deactivateAll(),this.activeToolType=ct.CIRCLE,this.circleTool?.startDraw(),this.onDrawingStartCallback?.(ct.CIRCLE)}startDrawingRectangle(){this.deactivateAll(),this.activeToolType=ct.RECTANGLE,this.rectangleTool?.startDraw(),this.onDrawingStartCallback?.(ct.RECTANGLE)}startDrawingTriangle(){this.deactivateAll(),this.activeToolType=ct.TRIANGLE,this.triangleTool?.startDraw(),this.onDrawingStartCallback?.(ct.TRIANGLE)}startDrawingFreehand(){this.deactivateAll(),this.activeToolType=ct.FREEHAND,this.freehandTool?.startDraw(!1),this.onDrawingStartCallback?.(ct.FREEHAND)}startDrawingFreehandPolygon(){this.deactivateAll(),this.activeToolType=ct.FREEHAND_POLYGON,this.freehandTool?.startDraw(!0),this.onDrawingStartCallback?.(ct.FREEHAND_POLYGON)}startDrawingEllipse(){this.deactivateAll(),this.activeToolType=ct.ELLIPSE,this.ellipseTool?.startDraw(),this.onDrawingStartCallback?.(ct.ELLIPSE)}startDrawingMarker(){this.deactivateAll(),this.activeToolType=ct.MARKER,this.markerTool?.startDraw(),this.onDrawingStartCallback?.(ct.MARKER)}startDrawingText(){this.deactivateAll(),this.activeToolType=ct.TEXT,this.textTool?.startDraw(),this.onDrawingStartCallback?.(ct.TEXT)}startDrawingArrow(){this.deactivateAll(),this.activeToolType=ct.ARROW,this.arrowTool?.startDraw(),this.onDrawingStartCallback?.(ct.ARROW)}startDrawingImage(){this.deactivateAll(),this.activeToolType=ct.IMAGE,this.imageTool?.startDraw(),this.onDrawingStartCallback?.(ct.IMAGE)}cancelDrawing(){this.deactivateAll()}deactivateAll(){const t=this.activeToolType!==null;this.circleTool?.deactivate(),this.rectangleTool?.deactivate(),this.triangleTool?.deactivate(),this.freehandTool?.deactivate(),this.ellipseTool?.deactivate(),this.markerTool?.deactivate(),this.textTool?.deactivate(),this.arrowTool?.deactivate(),this.imageTool?.deactivate(),this.lineTool?.deactivate(),this.bezierTool?.deactivate(),this.sectorTool?.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,this.freehandTool=null,this.ellipseTool=null,this.markerTool=null,this.textTool=null,this.arrowTool=null,this.imageTool=null,this.lineTool=null,this.bezierTool=null,this.sectorTool=null}}class V_{constructor(){this.drawingManager=null,this.mapView=null,this.keydownHandler=null,this.container=null}setDrawingManager(t){this.drawingManager=t}setMapView(t){this.mapView=t}bindEvents(t){t&&(this.container=t),this.keydownHandler&&(this.container?this.container.removeEventListener("keydown",this.keydownHandler):document.removeEventListener("keydown",this.keydownHandler)),this.keydownHandler=e=>{e.key==="Escape"&&this.handleEscCancel()},this.container?this.container.addEventListener("keydown",this.keydownHandler):document.addEventListener("keydown",this.keydownHandler)}handleEscCancel(){this.drawingManager?.isDrawing()&&this.drawingManager.cancelDrawing()}unbindEvents(){this.keydownHandler&&(this.container?this.container.removeEventListener("keydown",this.keydownHandler):document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}destroy(){this.unbindEvents(),this.drawingManager=null,this.mapView=null,this.container=null}}class H_ extends It{constructor(t,e,i){super(t,e,Z.LINE_COORDINATE_PICK,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.lines=new Map,this.onCompleteCallback=null,this.mapView=null,this.features=new Map,this.labelFeatures=new Map,this.lineColor=i?.lineColor||[0,200,255,1],this.lineWidth=i?.lineWidth||3,this.textColor=i?.textColor||[255,200,0,1],this.textSize=i?.textSize||12,this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.LINE_COORDINATE_PICK},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.t=i?.t||null}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startPick(t){this.stopPick(),this.onCompleteCallback=t||null,this.drawInteraction=new ee({source:this.source,type:"LineString"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates(),o=r.map(f=>{const[g,p]=U(f);return{longitude:g,latitude:p}}),a=Vt("LineCoordinatePick_"),l=Date.now(),h=Math.floor(o.length/2),c=r[h],d={id:a,points:o,timestamp:l,name:`${this.t?.linePick.default_name||"Line Pick"} ${new Date(l).toLocaleTimeString()}`};this.lines.set(a,d),this.features.set(a,i),i.setStyle(new A({stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})})),i.set("id",a),i.set("type","line_pick");const u=new V({geometry:new rt(c),id:a});u.set("type","line_pick"),u.setStyle(new A({text:new te({text:`${this.t?.linePick.label_prefix||"Line"} ${this.lines.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})})),this.labelFeatures.set(a,u),this.source?.addFeature(u),this.onCompleteCallback&&this.onCompleteCallback(d),this.stopPick()}),this.mapView?.addInteraction(this.drawInteraction)}stopPick(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}removeLine(t){const e=this.features.get(t),i=this.labelFeatures.get(t);return e&&(this.source?.removeFeature(e),this.features.delete(t)),i&&(this.source?.removeFeature(i),this.labelFeatures.delete(t)),this.lines.delete(t),!0}clearAllLines(){this.clear(),this.features.clear(),this.labelFeatures.clear(),this.lines.clear(),this.stopPick()}getAllLines(){return Array.from(this.lines.values())}getLine(t){return this.lines.get(t)}highlightLine(t){this.features.forEach((e,i)=>{const n=i===t;e.setStyle(new A({stroke:new G({color:M(n?[255,170,0,1]:this.lineColor),width:this.lineWidth+(n?2:0),lineDash:n?[]:[10,10]})}))}),this.labelFeatures.forEach((e,i)=>{const n=i===t;e.setStyle(new A({text:new te({text:n?this.t?.linePick.highlight_text||"● Line Pick ●":`${this.t?.linePick.label_prefix||"Line"} ${this.lines.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(n?[255,170,0,1]:this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}clearHighlight(){this.features.forEach(t=>{t.setStyle(new A({stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})}))}),this.labelFeatures.forEach(t=>{t.setStyle(new A({text:new te({text:`${this.t?.linePick.label_prefix||"Line"} ${this.lines.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"bottom",offsetY:-10})}))}),this.mapView?.render()}stopDraw(){this.stopPick()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return!1}setEditable(t){t||this.stopPick()}stopEdit(){this.stopPick()}getEditingId(){return null}cancelDraw(){this.stopPick()}cancelEdit(){this.stopPick()}updateData(t){}destroy(){this.stopPick(),super.destroy()}}class X_ extends It{constructor(t,e,i){super(t,e,Z.POLYGON_COORDINATE_PICK,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.polygons=new Map,this.onCompleteCallback=null,this.mapView=null,this.features=new Map,this.labelFeatures=new Map,this.fillColor=i?.fillColor||[0,200,255,.2],this.lineColor=i?.lineColor||[0,200,255,1],this.lineWidth=i?.lineWidth||2,this.textColor=i?.textColor||[255,200,0,1],this.textSize=i?.textSize||12,this.source=new Y,this.layer=new bt({source:this.source,properties:{id:t,name:e,type:Z.POLYGON_COORDINATE_PICK},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.t=i?.t||null}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startPick(t){this.stopPick(),this.onCompleteCallback=t||null,this.drawInteraction=new ee({source:this.source,type:"Polygon"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates()[0],o=r.map(f=>{const[g,p]=U(f);return{longitude:g,latitude:p}}).slice(0,-1),a=Vt("PolygonCoordinatePick_"),l=Date.now();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 d={id:a,points:o,timestamp:l,name:`${this.t?.polygonPick.default_name||"Polygon Pick"} ${new Date(l).toLocaleTimeString()}`};this.polygons.set(a,d),this.features.set(a,i),i.setStyle(new A({fill:new j({color:M(this.fillColor)}),stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})})),i.set("id",a),i.set("type","polygon_pick");const u=new V({geometry:new rt([h,c]),id:a});u.set("type","polygon_pick"),u.setStyle(new A({text:new te({text:`${this.t?.polygonPick.label_prefix||"Polygon"} ${this.polygons.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"middle"})})),this.labelFeatures.set(a,u),this.source?.addFeature(u),this.onCompleteCallback&&this.onCompleteCallback(d),this.stopPick()}),this.mapView?.addInteraction(this.drawInteraction)}stopPick(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}removePolygon(t){const e=this.features.get(t),i=this.labelFeatures.get(t);return e&&(this.source?.removeFeature(e),this.features.delete(t)),i&&(this.source?.removeFeature(i),this.labelFeatures.delete(t)),this.polygons.delete(t),!0}clearAllPolygons(){this.clear(),this.features.clear(),this.labelFeatures.clear(),this.polygons.clear(),this.stopPick()}getAllPolygons(){return Array.from(this.polygons.values())}getPolygon(t){return this.polygons.get(t)}highlightPolygon(t){this.features.forEach((e,i)=>{const n=i===t;e.setStyle(new A({fill:new j({color:M(n?[255,170,0,.3]:this.fillColor)}),stroke:new G({color:M(n?[255,170,0,1]:this.lineColor),width:this.lineWidth+(n?2:0),lineDash:n?[]:[10,10]})}))}),this.labelFeatures.forEach((e,i)=>{const n=i===t;e.setStyle(new A({text:new te({text:n?this.t?.polygonPick.highlight_text||"● Polygon Pick ●":`${this.t?.polygonPick.label_prefix||"Polygon"} ${this.polygons.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(n?[255,170,0,1]:this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"middle"})}))}),this.mapView?.render()}clearHighlight(){this.features.forEach(t=>{t.setStyle(new A({fill:new j({color:M(this.fillColor)}),stroke:new G({color:M(this.lineColor),width:this.lineWidth,lineDash:[10,10]})}))}),this.labelFeatures.forEach(t=>{t.setStyle(new A({text:new te({text:`${this.t?.polygonPick.label_prefix||"Polygon"} ${this.polygons.size}`,font:`${this.textSize}px sans-serif`,fill:new j({color:M(this.textColor)}),stroke:new G({color:"#000000",width:2}),textAlign:"center",textBaseline:"middle"})}))}),this.mapView?.render()}stopDraw(){this.stopPick()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return!1}setEditable(t){t||this.stopPick()}stopEdit(){this.stopPick()}getEditingId(){return null}cancelDraw(){this.stopPick()}cancelEdit(){this.stopPick()}updateData(t){}destroy(){this.stopPick(),super.destroy()}}class j_{constructor(t,e){this.id="image-draw",this.name="Image Annotation",this.icon="🖼️",this.imageDrawLayer=t,this.name=e.drawImage||"Image Annotation"}activate(){this.imageDrawLayer.setEditable(!0)}deactivate(){this.imageDrawLayer.stopDraw(),this.imageDrawLayer.stopEdit()}isActive(){return this.imageDrawLayer.isDrawActive()||this.imageDrawLayer.isEditActive()}startDraw(){this.imageDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.imageDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}editProperties(t,e,i){this.imageDrawLayer.editProperties(t,e,i)}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getImageLayer(){return this.imageDrawLayer}destroy(){this.imageDrawLayer.destroy()}}class Y_{constructor(t,e){this.options=t,this.currentImageUrl=t.initialImageUrl||"",this.currentImageData=t.initialImageData,this.containerEl=t.container||document.body,this.overlay=this.createOverlay(),this.element=this.createElement(),this.containerEl.appendChild(this.overlay),this.containerEl.appendChild(this.element),e?this.setPosition(e):this.centerModal(),this.urlInput=this.element.querySelector(".image-input-modal-url"),this.widthInput=this.element.querySelector(".image-input-modal-width"),this.heightInput=this.element.querySelector(".image-input-modal-height"),this.opacityInput=this.element.querySelector(".image-input-modal-opacity"),this.opacityValue=this.element.querySelector(".image-input-modal-opacity-value"),this.imagePreview=this.element.querySelector(".image-input-modal-preview"),this.previewImg=this.element.querySelector(".image-input-modal-preview-img"),this.uploadBtn=this.element.querySelector(".image-input-modal-upload"),this.fileInput=this.element.querySelector(".image-input-modal-file-input"),this.confirmBtn=this.element.querySelector(".image-input-modal-confirm"),this.cancelBtn=this.element.querySelector(".image-input-modal-cancel"),this.deleteBtn=this.element.querySelector(".image-input-modal-delete"),this.bindEvents(),this.updatePreview()}createOverlay(){const t=document.createElement("div");return t.className="image-input-modal-overlay",t.style.cssText=`
|
|
1670
1781
|
position: fixed;
|
|
1671
1782
|
top: 0;
|
|
1672
1783
|
left: 0;
|
|
@@ -1674,7 +1785,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1674
1785
|
bottom: 0;
|
|
1675
1786
|
background: transparent;
|
|
1676
1787
|
z-index: 10000;
|
|
1677
|
-
`,t.onclick=e=>{e.stopPropagation(),this.options.onCancel(),this.destroy()},t}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.className="image-input-modal-container",e.style.cssText=`
|
|
1788
|
+
`,t.onclick=e=>{e.stopPropagation(),this.options.onCancel(),this.destroy()},t}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.className="image-input-modal-container",e.style.userSelect="none",e.style.cssText=`
|
|
1678
1789
|
position: fixed;
|
|
1679
1790
|
z-index: 10001;
|
|
1680
1791
|
width: 300px;
|
|
@@ -1722,9 +1833,7 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1722
1833
|
align-items: center;
|
|
1723
1834
|
justify-content: center;
|
|
1724
1835
|
height: 100px;
|
|
1725
|
-
`,n.textContent=this.options.t.noImage,this.imagePreview.appendChild(n),e.appendChild(this.imagePreview),e}createFormArea(t){const e=document.createElement("div");e.style.cssText="padding: 8px 12px;";const i=this.createInputRow(this.options.t.imageUrl,"text",this.currentImageUrl,t);this.urlInput=i.input,this.urlInput.className="image-input-modal-url",e.appendChild(i.container);const n=this.createUploadRow(t);e.appendChild(n);const r=this.createNumberRow(this.options.t.width,"width",this.options.initialWidth||32,16,512,t);this.widthInput=r.input,this.widthInput.className="image-input-modal-width",e.appendChild(r.container);const o=this.createNumberRow(this.options.t.height,"height",this.options.initialHeight||32,16,512,t);this.heightInput=o.input,this.heightInput.className="image-input-modal-height",e.appendChild(o.container);const a=this.createOpacityRow(t);return this.opacityInput=a.input,this.opacityInput.className="image-input-modal-opacity",e.appendChild(a.container),e}createInputRow(t,e,i,n){const r=document.createElement("div");r.style.cssText=`
|
|
1726
|
-
margin-bottom: 8px;
|
|
1727
|
-
`;const o=document.createElement("span");o.style.cssText=`
|
|
1836
|
+
`,n.textContent=this.options.t.noImage,this.imagePreview.appendChild(n),e.appendChild(this.imagePreview),e}createFormArea(t){const e=document.createElement("div");e.style.cssText="padding: 8px 12px;";const i=this.createInputRow(this.options.t.imageUrl,"text",this.currentImageUrl,t);this.urlInput=i.input,this.urlInput.className="image-input-modal-url",e.appendChild(i.container);const n=this.createUploadRow(t);e.appendChild(n);const r=this.createNumberRow(this.options.t.width,"width",this.options.initialWidth||32,16,512,t);this.widthInput=r.input,this.widthInput.className="image-input-modal-width",e.appendChild(r.container);const o=this.createNumberRow(this.options.t.height,"height",this.options.initialHeight||32,16,512,t);this.heightInput=o.input,this.heightInput.className="image-input-modal-height",e.appendChild(o.container);const a=this.createOpacityRow(t);return this.opacityInput=a.input,this.opacityInput.className="image-input-modal-opacity",e.appendChild(a.container),e}createInputRow(t,e,i,n){const r=document.createElement("div");r.style.cssText="margin-bottom: 8px;";const o=document.createElement("span");o.style.cssText=`
|
|
1728
1837
|
display: block;
|
|
1729
1838
|
color: ${n?"#aaa":"#666"};
|
|
1730
1839
|
font-size: 10px;
|
|
@@ -1814,23 +1923,32 @@ ${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { d
|
|
|
1814
1923
|
color: ${e?"#ccc":"#666"};
|
|
1815
1924
|
border: 1px solid ${e?"#555":"#ddd"};
|
|
1816
1925
|
`}
|
|
1817
|
-
`,n?(r.onmouseenter=()=>{r.style.background="#d32f2f"},r.onmouseleave=()=>{r.style.background="#f44336"}):i?(r.onmouseenter=()=>{r.style.background="#0088cc"},r.onmouseleave=()=>{r.style.background="#00aaff"}):(r.onmouseenter=()=>{r.style.background=e?"#4a4a4a":"#e0e0e0"},r.onmouseleave=()=>{r.style.background=e?"#3d3d3d":"#e8e8e8"}),r}updatePreview(){if(!this.imagePreview||!this.previewImg||!this.urlInput){console.warn("updatePreview: required elements not ready");return}const t=this.urlInput.value||this.currentImageUrl,e=this.imagePreview.querySelector("#no-image-text");t&&t.trim()?(this.previewImg.src=t,this.previewImg.style.display="block",e&&(e.style.display="none"),this.previewImg.onload=()=>{this.widthInput&&(!this.options.initialWidth||this.options.initialWidth===32)&&(this.widthInput.value=Math.min(this.previewImg.naturalWidth,200).toString()),this.heightInput&&(!this.options.initialHeight||this.options.initialHeight===32)&&(this.heightInput.value=Math.min(this.previewImg.naturalHeight,200).toString())},this.previewImg.onerror=()=>{this.previewImg.style.display="none",e&&(e.style.display="flex",e.textContent=this.options.t.imageLoadFailed)}):(this.previewImg.style.display="none",e&&(e.style.display="flex",e.textContent=this.options.t.noImage))}uploadImage(t){const e=new FileReader;e.onload=i=>{const n=i.target?.result;this.currentImageData=n,this.currentImageUrl=n,this.urlInput&&(this.urlInput.value=n),this.updatePreview()},e.readAsDataURL(t)}centerModal(){const t=(window.innerWidth-300)/2,e=(window.innerHeight-420)/2;this.element.style.left=`${Math.max(10,t)}px`,this.element.style.top=`${Math.max(10,e)}px`}setPosition(t){let e=t.x-150,i=t.y-200;e=Math.max(10,Math.min(e,window.innerWidth-310)),i=Math.max(10,Math.min(i,window.innerHeight-420)),this.element.style.left=`${e}px`,this.element.style.top=`${i}px`}bindEvents(){if(!this.urlInput||!this.confirmBtn||!this.cancelBtn){console.error("ImageInputModalBox: Required elements not found");return}this.urlInput.addEventListener("input",()=>{this.currentImageUrl=this.urlInput.value,this.currentImageData=void 0,this.updatePreview()}),this.deleteBtn&&this.deleteBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onDelete&&this.options.onDelete(),this.destroy()}),this.confirmBtn.addEventListener("click",t=>{t.stopPropagation();const e=this.urlInput.value.trim();e?this.options.onConfirm({imageUrl:e,imageData:this.currentImageData,width:this.widthInput&&parseInt(this.widthInput.value)||32,height:this.heightInput&&parseInt(this.heightInput.value)||32,opacity:this.opacityInput?parseInt(this.opacityInput.value)/100:1}):this.options.onCancel(),this.destroy()}),this.cancelBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onCancel(),this.destroy()}),this.widthInput&&this.widthInput.addEventListener("input",()=>{this.updatePreviewSize()}),this.heightInput&&this.heightInput.addEventListener("input",()=>{this.updatePreviewSize()}),this.opacityInput&&this.opacityValue&&this.opacityInput.addEventListener("input",()=>{this.opacityValue.textContent=`${this.opacityInput.value}%`,this.updatePreviewOpacity()}),this.element.addEventListener("click",t=>{t.stopPropagation()}),document.addEventListener("keydown",t=>{t.key==="Escape"&&document.body.contains(this.element)&&(this.options.onCancel(),this.destroy())})}updatePreviewSize(){const t=parseInt(this.widthInput.value)||32,e=parseInt(this.heightInput.value)||32;this.previewImg.style.maxWidth=`${Math.min(t,200)}px`,this.previewImg.style.maxHeight=`${Math.min(e,200)}px`}updatePreviewOpacity(){const t=parseInt(this.opacityInput.value)/100;this.previewImg.style.opacity=t.toString()}updateTheme(t){this.options.theme=t;const e=t==="dark";this.element.style.background=e?"#2d2d2d":"#ffffff",this.element.style.borderColor=e?"#444":"#e0e0e0"}destroy(){this.overlay.remove(),this.element.remove()}getElement(){return this.element}}class j_ extends It{constructor(t,e,i){super(t,e,Z.IMAGE_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.imageInputModal=null,this.isInputActive=!1,this.currentTheme="dark",this.currentTranslations=null,this.defaultWidth=i?.defaultWidth||32,this.defaultHeight=i?.defaultHeight||32,this.defaultOpacity=i?.defaultOpacity||1,this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.IMAGE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("imageUrl")||"",i=t?.get("width")||this.defaultWidth,n=t?.get("height")||this.defaultHeight,r=t?.get("opacity")||this.defaultOpacity,o=t?.get("rotation")||0;return e?new A({image:new Vi({src:e,width:i,height:n,opacity:r,rotation:o,crossOrigin:"anonymous"})}):new A({})}setTheme(t,e){this.currentTheme=t,this.currentTranslations=e}showImageInputModal(t,e,i,n){this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),this.isInputActive=!0;const r=this.mapView;if(!r||typeof r.getTargetElement!="function"){console.error("ImageDrawLayer: mapView is not a valid map object"),this.isInputActive=!1,i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity});return}if(!r.getTargetElement()){console.error("ImageDrawLayer: cannot get map target element"),this.isInputActive=!1,i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity});return}const a=r.getPixelFromCoordinate(t);if(!a||a.length<2){console.error("ImageDrawLayer: cannot get pixel from coordinate",t),this.isInputActive=!1,i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity});return}let l=a[0]-150,h=a[1]-200;l=Math.max(10,Math.min(l,window.innerWidth-310)),h=Math.max(10,Math.min(h,window.innerHeight-400));const c={addImage:"添加图片",enterImageUrl:"请输入图片URL或点击上传...",imageUrl:"图片URL",uploadImage:"上传图片",width:"宽度",height:"高度",opacity:"透明度",confirm:"确定",cancel:"取消",delete:"删除"};this.imageInputModal=new X_({initialImageUrl:e?.imageUrl||"",initialImageData:e?.imageData,initialWidth:e?.width||this.defaultWidth,initialHeight:e?.height||this.defaultHeight,initialOpacity:e?.opacity||this.defaultOpacity,onConfirm:d=>{console.log("onConfirm called in ImageDrawLayer",d),i&&i(d),this.hideImageInputModal()},onCancel:()=>{console.log("onCancel called in ImageDrawLayer"),i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity}),this.hideImageInputModal()},onDelete:n,theme:this.currentTheme,t:c},{x:l,y:h})}hideImageInputModal(){this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),this.isInputActive=!1}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 Y;this.drawInteraction=new ee({source:e,type:"Point"}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry();if(n instanceof rt){const[r,o]=n.getCoordinates(),[a,l]=U([r,o]);this.showImageInputModal([r,o],void 0,h=>{if(e&&e.clear(),this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),h.imageUrl&&h.imageUrl.trim()){const c=Vt("image_"),d=new V({geometry:new rt([r,o]),id:c,position:[a,l],imageUrl:h.imageUrl,imageData:h.imageData});d.set("width",h.width),d.set("height",h.height),d.set("opacity",h.opacity),d.set("rotation",0),this.source?.addFeature(d),this.features.set(c,d),this.layer?.setZIndex(999),d.changed(),this.mapView&&this.mapView.renderSync(),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:c,position:[a,l],imageUrl:h.imageUrl,imageData:h.imageData,width:h.width,height:h.height,opacity:h.opacity,rotation:0})}else this.onDrawCompleteCallback&&this.onDrawCompleteCallback(null);this.onDrawCompleteCallback=null,this.mapView?.render()})}else 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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!1,keepAspectRatio:o=>o.shiftKey}),this.transformInteraction.setActive(!0),this.transformInteraction.on("scaleend",()=>{const o=i.get("scale")||1,a=i.get("width")||this.defaultWidth,l=i.get("height")||this.defaultHeight,h=Math.max(10,a*o),c=Math.max(10,l*o);i.set("width",h),i.set("height",c),i.set("scale",1),i.changed();const d=i.get("position"),u=i.get("id");this.onEditCompleteCallback&&u&&this.onEditCompleteCallback({id:u,position:d,imageUrl:i.get("imageUrl"),imageData:i.get("imageData"),width:h,height:c,opacity:i.get("opacity"),rotation:i.get("rotation")||0}),this.mapView?.render()}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof rt){const[a,l]=o.getCoordinates(),[h,c]=U([a,l]);i.set("position",[h,c]),i.changed();const d=i.get("id");this.onEditCompleteCallback&&d&&this.onEditCompleteCallback({id:d,position:[h,c],imageUrl:i.get("imageUrl"),imageData:i.get("imageData"),width:i.get("width"),height:i.get("height"),opacity:i.get("opacity"),rotation:i.get("rotation")||0})}}),this.mapView?.addInteraction(this.transformInteraction),this.mapView?.render()}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),this.isInputActive=!1,this.editingFeature=null,this.onEditCompleteCallback=null}editProperties(t,e,i){const n=this.features.get(t);if(!n)return;const r=n.getGeometry();if(r instanceof rt){const[o,a]=r.getCoordinates(),l=n.get("imageUrl")||"",h=n.get("imageData"),c=n.get("width")||this.defaultWidth,d=n.get("height")||this.defaultHeight,u=n.get("opacity")||this.defaultOpacity,f=()=>{this.removeImage(t),i&&i(),e&&e(null)};this.showImageInputModal([o,a],{imageUrl:l,imageData:h,width:c,height:d,opacity:u},g=>{if(g.imageUrl&&g.imageUrl.trim()){n.set("imageUrl",g.imageUrl),g.imageData&&n.set("imageData",g.imageData),n.set("width",g.width),n.set("height",g.height),n.set("opacity",g.opacity),n.changed(),this.mapView?.render();const p=n.get("position");e&&e({id:t,position:p,imageUrl:g.imageUrl,imageData:g.imageData,width:g.width,height:g.height,opacity:g.opacity,rotation:n.get("rotation")||0})}},f)}}addImage(t){const e=ut(t.position),i=new V({geometry:new rt(e),id:t.id,position:t.position,imageUrl:t.imageUrl,imageData:t.imageData});i.set("width",t.width||this.defaultWidth),i.set("height",t.height||this.defaultHeight),i.set("opacity",t.opacity||this.defaultOpacity),i.set("rotation",t.rotation||0),i.set("scale",1),this.source?.addFeature(i),this.features.set(t.id,i)}removeImage(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllImages(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,position:e.get("position"),imageUrl:e.get("imageUrl"),imageData:e.get("imageData"),width:e.get("width"),height:e.get("height"),opacity:e.get("opacity"),rotation:e.get("rotation")})}),t}getImage(t){const e=this.features.get(t);if(e)return{id:t,position:e.get("position"),imageUrl:e.get("imageUrl"),imageData:e.get("imageData"),width:e.get("width"),height:e.get("height"),opacity:e.get("opacity"),rotation:e.get("rotation")}}updateImageStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("width",e),o.set("height",i),o.set("opacity",n),r!==void 0&&o.set("rotation",r),o.changed(),this.mapView&&(this.mapView.renderSync(),this.layer&&this.layer.changed()))}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.images&&(this.clearAll(),t.images.forEach(e=>this.addImage(e)))}destroy(){this.stopDraw(),this.stopEdit(),this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),super.destroy()}}class Y_{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.isOwnContainer=!1,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.currentSize=10,this.currentScale="",this.isLoading=!0,this.isChangingBasemap=!1,this.drawingStatusText=null,this.measureStatusText=null,this.freehandDrawLayer=null,this.ellipseDrawLayer=null,this.markerDrawLayer=null,this.textDrawLayer=null,this.arrowDrawLayer=null,this.freehandDrawTool=null,this.ellipseDrawTool=null,this.markerDrawTool=null,this.textDrawTool=null,this.arrowDrawTool=null,this.selectedFreehandId=null,this.selectedEllipseId=null,this.selectedMarkerId=null,this.selectedTextId=null,this.selectedArrowId=null,this.lineDrawLayer=null,this.bezierDrawLayer=null,this.sectorDrawLayer=null,this.lineDrawTool=null,this.bezierDrawTool=null,this.sectorDrawTool=null,this.selectedLineId=null,this.selectedBezierId=null,this.selectedSectorId=null,this.pointCoordinatePickLayer=null,this.lineCoordinatePickLayer=null,this.polygonCoordinatePickLayer=null,this.pointCoordinateListPanel=null,this.currentPointCoordinates=[],this.currentLineCoordinates=[],this.currentPolygonCoordinates=[],this.imageDrawLayer=null,this.imageDrawTool=null,this.selectedImageId=null,this.selectedPointPickId=null,this.selectedLinePickId=null,this.selectedPolygonPickId=null;const{container:e,containerSelector:i,id:n,parent:r,parentSelector:o,basemap:a=dt.SATELLITE,baseMapUrl:l,center:h=[0,0],zoom:c=12,coordinateSystem:d=Oe.WGS84,onLoad:u,onMoveEnd:f,onMapClick:g,onCircleDrawn:p,theme:m="dark",i18n:y="zh",enableDrawing:w=!0}=t,{container:E,isOwn:x}=this.resolveContainer({container:e,containerSelector:i,id:n,parent:r,parentSelector:o});this.container=E,this.isOwnContainer=x,this.theme=m,this.locale=y,this.t=Hi(this.locale),this.onLoadCallback=u,this.onMoveEndCallback=f,this.onMapClickCallback=g,this.onCircleDrawnCallback=p,this.enableDrawing=w,this.container.setAttribute("data-theme",m),document.body.setAttribute("data-theme",m),this.container.style.cssText="position:relative;width:100%;height:100%;margin:0;padding:0;overflow:hidden;box-sizing:border-box;",this.mapManager=new O_(this.container,a,h,c,d,l),this.layerManager=new $h(this.mapManager.getMap()),this.drawToolManager=new h_,this.drawingManager=new B_,this.eventManager=new W_,this.initUI(),this.initLayers(),this.initEventManager(),this.initDrawingManager(),this.bindEvents(),this.initRightClickMenu(),this.onLoadCallback&&setTimeout(()=>this.onLoadCallback?.(this),100),setTimeout(()=>this.hideLoading(),500)}initEventManager(){this.eventManager.setDrawingManager(this.drawingManager),this.eventManager.setMapView(this.mapManager.getMap()),this.eventManager.bindEvents()}resolveContainer(t){const{container:e,containerSelector:i,id:n,parent:r,parentSelector:o}=t;if(e)return{container:e,isOwn:!1};if(i){const a=document.querySelector(i);if(!a)throw new Error(`[EarthView] Container element not found: ${i}`);return{container:a,isOwn:!1}}if(n){const a=document.getElementById(n);if(!a)throw new Error(`[EarthView] Container element not found: #${n}`);return{container:a,isOwn:!1}}if(r){const a=this.createAutoContainer();return r.appendChild(a),{container:a,isOwn:!0}}if(o){const a=document.querySelector(o);if(!a)throw new Error(`[EarthView] Parent element not found: ${o}`);const l=this.createAutoContainer();return a.appendChild(l),{container:l,isOwn:!0}}throw new Error("[EarthView] Must provide one of: container, containerSelector, id, parent, or parentSelector")}createAutoContainer(){const t=document.createElement("div");return t.style.cssText="width:100%;height:100%;position:relative;overflow:hidden;margin:0;padding:0;box-sizing:border-box;",t}initUI(){this.uiManager=new G_(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(),onDrawFreehand:()=>this.startDrawFreehand(),onDrawFreehandPolygon:()=>this.startDrawFreehandPolygon(),onDrawEllipse:()=>this.startDrawEllipse(),onDrawMarker:()=>this.startDrawMarker(),onDrawText:()=>this.startDrawText(),onDrawArrow:()=>this.startDrawArrow(),onDrawLine:()=>this.startDrawLine(),onDrawBezier:()=>this.startDrawBezier(),onDrawSector:()=>this.startDrawSector(),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),onPointCoordinatePick:()=>this.startPointCoordinatePick(),onLineCoordinatePick:()=>this.startLineCoordinatePick(),onPolygonCoordinatePick:()=>this.startPolygonCoordinatePick(),onShowCoordinateList:()=>this.showCoordinateList(),getPointData:()=>this.getPointDataForPanel(),getLineData:()=>this.getLineDataForPanel(),getPolygonData:()=>this.getPolygonDataForPanel(),onLocateCoordinate:(t,e)=>this.locateToPoint(t,e),onLocateLine:t=>this.locateToLine(t),onLocatePolygon:t=>this.locateToPolygon(t),onDrawImage:()=>this.startDrawImage(),onGetLayerFeatures:t=>{const e=this.layerManager.getLayer(t);return e&&e instanceof is?e.getAllMarkers().map(n=>({id:n.id,name:n.bubbleBoxTitle||n.name||n.id,type:"point",coordinates:{longitude:n.longitude,latitude:n.latitude},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof Qn?(e.getAllPolygons?.()||[]).map((n,r)=>({id:n.id||`polygon_${r}`,name:n.title||n.name||`面 ${r+1}`,type:"polygon",coordinates:n.points||n.coordinates,properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof ts?(e.getAllPolylines?.()||[]).map((n,r)=>({id:n.id||`polyline_${r}`,name:n.title||n.name||`线 ${r+1}`,type:"line",coordinates:n.points||n.coordinates,properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof es?(e.getAllCircles?.()||[]).map((n,r)=>({id:n.id||`circle_${r}`,name:n.title||n.name||`圆 ${r+1}`,type:"polygon",coordinates:{center:n.center,radius:n.radius},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof gr?(e.getLayer()?.getSource()?.getFeatures()||[]).map((r,o)=>{const a=r.getGeometry();let l=r.get("longitude"),h=r.get("latitude");if((l===void 0||h===void 0)&&a){const c=a.getCoordinates();l=c[0],h=c[1]}return{id:r.get("id")||`heat_${o}`,name:`HotPoint ${o+1}`,type:"point",coordinates:{longitude:l,latitude:h},properties:r.getProperties(),timestamp:Date.now()}}):e&&e instanceof vd?(e.getData?.()||[]).map((n,r)=>({id:n.id||`cluster_${r}`,name:n.title||`聚合点 ${r+1}`,type:"point",coordinates:{longitude:n.longitude,latitude:n.latitude},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof Sd?(e.getData?.()||[]).map((n,r)=>({id:n.id||`barchart_${r}`,name:n.title||`柱 ${r+1}`,type:"point",coordinates:{longitude:n.longitude,latitude:n.latitude},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof bd?e.getAllFeatures().map((n,r)=>{const o=n.getGeometry?.();let a="point",l=null;if(o){const h=o.getType();if(h==="Point"){a="point";const c=o.getCoordinates();l={longitude:c[0],latitude:c[1]}}else h==="LineString"?(a="line",l=o.getCoordinates().map(c=>({longitude:c[0],latitude:c[1]}))):h==="Polygon"&&(a="polygon",l=o.getCoordinates()[0].map(c=>({longitude:c[0],latitude:c[1]})))}return{id:n.getId?.()||`geojson_${r}`,name:n.get("name")||n.get("title")||`Elements ${r+1}`,type:a,coordinates:l,properties:n.getProperties?.(),timestamp:Date.now()}}):[]},onLocateFeature:(t,e)=>{const i=this.layerManager.getLayer(t),n=d=>{if(!d)return null;if(d.longitude!==void 0&&d.latitude!==void 0)return{lng:d.longitude,lat:d.latitude};if(d.coordinates){if(d.coordinates.longitude!==void 0&&d.coordinates.latitude!==void 0)return{lng:d.coordinates.longitude,lat:d.coordinates.latitude};if(Array.isArray(d.coordinates)&&d.coordinates.length>=2)return{lng:d.coordinates[0],lat:d.coordinates[1]}}return null},r=d=>{if(!d)return null;let u=d.points||d.coordinates;return!u||!Array.isArray(u)||u.length===0?null:u.map(f=>({lng:f.longitude??f[0],lat:f.latitude??f[1]}))},a=i instanceof is?i.getMarker(e):i instanceof Qn?i.getPolygon?.(e):i instanceof ts?i.getPolyline?.(e):i instanceof es?i.getCircle?.(e):(i?.getAllFeatures?.()||i?.getData?.()||[]).find(u=>u.id===e);if(!a){this.showToast("The element was not found.");return}let l,h,c=16;if(i instanceof is){const d=n(a);d&&(l=d.lng,h=d.lat,c=18)}else if(i instanceof es)if(a.center)l=a.center[0],h=a.center[1];else{const d=n(a);d&&(l=d.lng,h=d.lat)}else if(i instanceof Qn||i instanceof ts){const d=r(a);if(d&&d.length>0){const u=d.map(p=>p.lng),f=d.map(p=>p.lat);l=(Math.min(...u)+Math.max(...u))/2,h=(Math.min(...f)+Math.max(...f))/2;const g=Math.max(...u)-Math.min(...u);c=g>.5?10:g>.1?12:g>.05?14:16}}else if(i instanceof gr){const f=(i.getLayer()?.getSource()?.getFeatures()||[]).find(g=>g.get("id")===e);if(f){const g=f.get("longitude"),p=f.get("latitude"),m=f.getGeometry();if(g!==void 0&&p!==void 0)l=g,h=p,c=16;else if(m){const y=m.getCoordinates();l=y[0],h=y[1],c=16}}}else{const d=n(a);d&&(l=d.lng,h=d.lat,c=16)}l!==void 0&&h!==void 0?(this.setCenter([l,h]),this.setZoom(c),this.showToast(`${this.t.locatedToPoint}: ${l.toFixed(6)}, ${h.toFixed(6)}`)):this.showToast("Unable to locate the element")},onCopyFeatureCoordinates:(t,e)=>{const i=this.layerManager.getLayer(t);let n="";if(i&&i instanceof is){const r=i.getMarker(e);r&&(n=`${r.longitude.toFixed(8)}, ${r.latitude.toFixed(8)}`)}else if(i&&i instanceof gr){const a=(i.getLayer()?.getSource()?.getFeatures()||[]).find(l=>l.get("id")===e);if(a){const l=a.get("longitude"),h=a.get("latitude"),c=a.getGeometry();if(l!==void 0&&h!==void 0)n=`${Number(l).toFixed(8)}, ${Number(h).toFixed(8)}`;else if(c){const d=c.getCoordinates();n=`${d[0].toFixed(8)}, ${d[1].toFixed(8)}`}}}else if(i&&i instanceof Qn){const r=i.getPolygon?.(e);r&&r.points&&(n=r.points.map(o=>{const a=o.longitude??o[0],l=o.latitude??o[1];return`${a.toFixed(8)}, ${l.toFixed(8)}`}).join(`
|
|
1926
|
+
`,n?(r.onmouseenter=()=>{r.style.background="#d32f2f"},r.onmouseleave=()=>{r.style.background="#f44336"}):i?(r.onmouseenter=()=>{r.style.background="#0088cc"},r.onmouseleave=()=>{r.style.background="#00aaff"}):(r.onmouseenter=()=>{r.style.background=e?"#4a4a4a":"#e0e0e0"},r.onmouseleave=()=>{r.style.background=e?"#3d3d3d":"#e8e8e8"}),r}updatePreview(){if(!this.imagePreview||!this.previewImg||!this.urlInput){console.warn("updatePreview: required elements not ready");return}const t=this.urlInput.value||this.currentImageUrl,e=this.imagePreview.querySelector("#no-image-text");t&&t.trim()?(this.previewImg.src=t,this.previewImg.style.display="block",e&&(e.style.display="none"),this.previewImg.onload=()=>{this.widthInput&&(!this.options.initialWidth||this.options.initialWidth===32)&&(this.widthInput.value=Math.min(this.previewImg.naturalWidth,200).toString()),this.heightInput&&(!this.options.initialHeight||this.options.initialHeight===32)&&(this.heightInput.value=Math.min(this.previewImg.naturalHeight,200).toString())},this.previewImg.onerror=()=>{this.previewImg.style.display="none",e&&(e.style.display="flex",e.textContent=this.options.t.imageLoadFailed)}):(this.previewImg.style.display="none",e&&(e.style.display="flex",e.textContent=this.options.t.noImage))}uploadImage(t){const e=new FileReader;e.onload=i=>{const n=i.target?.result;this.currentImageData=n,this.currentImageUrl=n,this.urlInput&&(this.urlInput.value=n),this.updatePreview()},e.readAsDataURL(t)}centerModal(){const t=(window.innerWidth-300)/2,e=(window.innerHeight-420)/2;this.element.style.left=`${Math.max(10,t)}px`,this.element.style.top=`${Math.max(10,e)}px`}setPosition(t){let e=t.x-150,i=t.y-200;e=Math.max(10,Math.min(e,window.innerWidth-310)),i=Math.max(10,Math.min(i,window.innerHeight-420)),this.element.style.left=`${e}px`,this.element.style.top=`${i}px`}bindEvents(){if(!this.urlInput||!this.confirmBtn||!this.cancelBtn){console.error("ImageInputModalBox: Required elements not found");return}this.urlInput.addEventListener("input",()=>{this.currentImageUrl=this.urlInput.value,this.currentImageData=void 0,this.updatePreview()}),this.deleteBtn&&this.deleteBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onDelete&&this.options.onDelete(),this.destroy()}),this.confirmBtn.addEventListener("click",t=>{t.stopPropagation();const e=this.urlInput.value.trim();e?this.options.onConfirm({imageUrl:e,imageData:this.currentImageData,width:this.widthInput&&parseInt(this.widthInput.value)||32,height:this.heightInput&&parseInt(this.heightInput.value)||32,opacity:this.opacityInput?parseInt(this.opacityInput.value)/100:1}):this.options.onCancel(),this.destroy()}),this.cancelBtn.addEventListener("click",t=>{t.stopPropagation(),this.options.onCancel(),this.destroy()}),this.widthInput&&this.widthInput.addEventListener("input",()=>{this.updatePreviewSize()}),this.heightInput&&this.heightInput.addEventListener("input",()=>{this.updatePreviewSize()}),this.opacityInput&&this.opacityValue&&this.opacityInput.addEventListener("input",()=>{this.opacityValue.textContent=`${this.opacityInput.value}%`,this.updatePreviewOpacity()}),this.element.addEventListener("click",t=>{t.stopPropagation()}),document.addEventListener("keydown",t=>{t.key==="Escape"&&document.body.contains(this.element)&&(this.options.onCancel(),this.destroy())})}updatePreviewSize(){const t=parseInt(this.widthInput.value)||32,e=parseInt(this.heightInput.value)||32;this.previewImg.style.maxWidth=`${Math.min(t,200)}px`,this.previewImg.style.maxHeight=`${Math.min(e,200)}px`}updatePreviewOpacity(){const t=parseInt(this.opacityInput.value)/100;this.previewImg.style.opacity=t.toString()}updateTheme(t){this.options.theme=t;const e=t==="dark";this.element.style.background=e?"#2d2d2d":"#ffffff",this.element.style.borderColor=e?"#444":"#e0e0e0"}destroy(){this.overlay.remove(),this.element.remove()}getElement(){return this.element}}class Z_ extends It{constructor(t,e,i){super(t,e,Z.IMAGE_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.imageInputModal=null,this.isInputActive=!1,this.currentTheme="dark",this.currentTranslations=null,this.defaultWidth=i?.defaultWidth||32,this.defaultHeight=i?.defaultHeight||32,this.defaultOpacity=i?.defaultOpacity||1,this.source=new Y,this.layer=new bt({source:this.source,style:n=>this.getStyleForFeature(n),properties:{id:t,name:e,type:Z.IMAGE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}getStyleForFeature(t){const e=t?.get("imageUrl")||"",i=t?.get("width")||this.defaultWidth,n=t?.get("height")||this.defaultHeight,r=t?.get("opacity")||this.defaultOpacity,o=t?.get("rotation")||0;return e?new A({image:new Vi({src:e,width:i,height:n,opacity:r,rotation:o,crossOrigin:"anonymous"})}):new A({})}setTheme(t,e){this.currentTheme=t,this.currentTranslations=e}showImageInputModal(t,e,i,n){this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),this.isInputActive=!0;const r=this.mapView;if(!r||typeof r.getTargetElement!="function"){console.error("ImageDrawLayer: mapView is not a valid map object"),this.isInputActive=!1,i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity});return}if(!r.getTargetElement()){console.error("ImageDrawLayer: cannot get map target element"),this.isInputActive=!1,i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity});return}const a=r.getPixelFromCoordinate(t);if(!a||a.length<2){console.error("ImageDrawLayer: cannot get pixel from coordinate",t),this.isInputActive=!1,i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity});return}let l=a[0]-150,h=a[1]-200;l=Math.max(10,Math.min(l,window.innerWidth-310)),h=Math.max(10,Math.min(h,window.innerHeight-400));const c={addImage:"添加图片",enterImageUrl:"请输入图片URL或点击上传...",imageUrl:"图片URL",uploadImage:"上传图片",width:"宽度",height:"高度",opacity:"透明度",confirm:"确定",cancel:"取消",delete:"删除"};this.imageInputModal=new Y_({initialImageUrl:e?.imageUrl||"",initialImageData:e?.imageData,initialWidth:e?.width||this.defaultWidth,initialHeight:e?.height||this.defaultHeight,initialOpacity:e?.opacity||this.defaultOpacity,onConfirm:d=>{console.log("onConfirm called in ImageDrawLayer",d),i&&i(d),this.hideImageInputModal()},onCancel:()=>{console.log("onCancel called in ImageDrawLayer"),i&&i({imageUrl:"",width:this.defaultWidth,height:this.defaultHeight,opacity:this.defaultOpacity}),this.hideImageInputModal()},onDelete:n,theme:this.currentTheme,t:c,container:this.mapView?.getTargetElement()},{x:l,y:h}),this.imageInputModal.getElement().style.userSelect="none"}hideImageInputModal(){this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),this.isInputActive=!1}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 Y;this.drawInteraction=new ee({source:e,type:"Point"}),this.drawInteraction.on("drawend",i=>{const n=i.feature.getGeometry();if(n instanceof rt){const[r,o]=n.getCoordinates(),[a,l]=U([r,o]);this.showImageInputModal([r,o],void 0,h=>{if(e&&e.clear(),this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),h.imageUrl&&h.imageUrl.trim()){const c=Vt("image_"),d=new V({geometry:new rt([r,o]),id:c,position:[a,l],imageUrl:h.imageUrl,imageData:h.imageData});d.set("width",h.width),d.set("height",h.height),d.set("opacity",h.opacity),d.set("rotation",0),this.source?.addFeature(d),this.features.set(c,d),this.layer?.setZIndex(999),d.changed(),this.mapView&&this.mapView.renderSync(),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:c,position:[a,l],imageUrl:h.imageUrl,imageData:h.imageData,width:h.width,height:h.height,opacity:h.opacity,rotation:0})}else this.onDrawCompleteCallback&&this.onDrawCompleteCallback(null);this.onDrawCompleteCallback=null,this.mapView?.render()})}else 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)return;this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new Y;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new _e({features:r,translate:!0,scale:!0,rotate:!1,keepAspectRatio:o=>o.shiftKey}),this.transformInteraction.setActive(!0),this.transformInteraction.on("scaleend",()=>{const o=i.get("scale")||1,a=i.get("width")||this.defaultWidth,l=i.get("height")||this.defaultHeight,h=Math.max(10,a*o),c=Math.max(10,l*o);i.set("width",h),i.set("height",c),i.set("scale",1),i.changed();const d=i.get("position"),u=i.get("id");this.onEditCompleteCallback&&u&&this.onEditCompleteCallback({id:u,position:d,imageUrl:i.get("imageUrl"),imageData:i.get("imageData"),width:h,height:c,opacity:i.get("opacity"),rotation:i.get("rotation")||0}),this.mapView?.render()}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof rt){const[a,l]=o.getCoordinates(),[h,c]=U([a,l]);i.set("position",[h,c]),i.changed();const d=i.get("id");this.onEditCompleteCallback&&d&&this.onEditCompleteCallback({id:d,position:[h,c],imageUrl:i.get("imageUrl"),imageData:i.get("imageData"),width:i.get("width"),height:i.get("height"),opacity:i.get("opacity"),rotation:i.get("rotation")||0})}}),this.mapView?.addInteraction(this.transformInteraction),this.mapView?.render()}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),this.isInputActive=!1,this.editingFeature=null,this.onEditCompleteCallback=null}editProperties(t,e,i){const n=this.features.get(t);if(!n)return;const r=n.getGeometry();if(r instanceof rt){const[o,a]=r.getCoordinates(),l=n.get("imageUrl")||"",h=n.get("imageData"),c=n.get("width")||this.defaultWidth,d=n.get("height")||this.defaultHeight,u=n.get("opacity")||this.defaultOpacity,f=()=>{this.removeImage(t),i&&i(),e&&e(null)};this.showImageInputModal([o,a],{imageUrl:l,imageData:h,width:c,height:d,opacity:u},g=>{if(g.imageUrl&&g.imageUrl.trim()){n.set("imageUrl",g.imageUrl),g.imageData&&n.set("imageData",g.imageData),n.set("width",g.width),n.set("height",g.height),n.set("opacity",g.opacity),n.changed(),this.mapView?.render();const p=n.get("position");e&&e({id:t,position:p,imageUrl:g.imageUrl,imageData:g.imageData,width:g.width,height:g.height,opacity:g.opacity,rotation:n.get("rotation")||0})}},f)}}addImage(t){const e=ut(t.position),i=new V({geometry:new rt(e),id:t.id,position:t.position,imageUrl:t.imageUrl,imageData:t.imageData});i.set("width",t.width||this.defaultWidth),i.set("height",t.height||this.defaultHeight),i.set("opacity",t.opacity||this.defaultOpacity),i.set("rotation",t.rotation||0),i.set("scale",1),this.source?.addFeature(i),this.features.set(t.id,i)}removeImage(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllImages(){const t=[];return this.features.forEach((e,i)=>{t.push({id:i,position:e.get("position"),imageUrl:e.get("imageUrl"),imageData:e.get("imageData"),width:e.get("width"),height:e.get("height"),opacity:e.get("opacity"),rotation:e.get("rotation")})}),t}getImage(t){const e=this.features.get(t);if(e)return{id:t,position:e.get("position"),imageUrl:e.get("imageUrl"),imageData:e.get("imageData"),width:e.get("width"),height:e.get("height"),opacity:e.get("opacity"),rotation:e.get("rotation")}}updateImageStyle(t,e,i,n,r){const o=this.features.get(t);o&&(o.set("width",e),o.set("height",i),o.set("opacity",n),r!==void 0&&o.set("rotation",r),o.changed(),this.mapView&&(this.mapView.renderSync(),this.layer&&this.layer.changed()))}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAll(){this.clear(),this.features.clear(),this.stopEdit()}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()}updateData(t){t.images&&(this.clearAll(),t.images.forEach(e=>this.addImage(e)))}destroy(){this.stopDraw(),this.stopEdit(),this.imageInputModal&&(this.imageInputModal.destroy(),this.imageInputModal=null),super.destroy()}}const cs=class cs{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.isOwnContainer=!1,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.currentSize=10,this.currentScale="",this.isLoading=!0,this.isChangingBasemap=!1,this.drawingStatusText=null,this.measureStatusText=null,this.freehandDrawLayer=null,this.ellipseDrawLayer=null,this.markerDrawLayer=null,this.textDrawLayer=null,this.arrowDrawLayer=null,this.freehandDrawTool=null,this.ellipseDrawTool=null,this.markerDrawTool=null,this.textDrawTool=null,this.arrowDrawTool=null,this.selectedFreehandId=null,this.selectedEllipseId=null,this.selectedMarkerId=null,this.selectedTextId=null,this.selectedArrowId=null,this.lineDrawLayer=null,this.bezierDrawLayer=null,this.sectorDrawLayer=null,this.lineDrawTool=null,this.bezierDrawTool=null,this.sectorDrawTool=null,this.selectedLineId=null,this.selectedBezierId=null,this.selectedSectorId=null,this.pointCoordinatePickLayer=null,this.lineCoordinatePickLayer=null,this.polygonCoordinatePickLayer=null,this.pointCoordinateListPanel=null,this.currentPointCoordinates=[],this.currentLineCoordinates=[],this.currentPolygonCoordinates=[],this.imageDrawLayer=null,this.imageDrawTool=null,this.selectedImageId=null,this.selectedPointPickId=null,this.selectedLinePickId=null,this.selectedPolygonPickId=null;const{container:e,containerSelector:i,id:n,parent:r,parentSelector:o,basemap:a=dt.SATELLITE,baseMapUrl:l,center:h=[0,0],zoom:c=12,coordinateSystem:d=Oe.WGS84,onLoad:u,onMoveEnd:f,onMapClick:g,onCircleDrawn:p,theme:m="dark",i18n:y="zh",enableDrawing:x=!0}=t,{container:E,isOwn:w}=this.resolveContainer({container:e,containerSelector:i,id:n,parent:r,parentSelector:o});this.container=E,this.isOwnContainer=w,this.theme=m,this.locale=y,this.t=Hi(this.locale),this.onLoadCallback=u,this.onMoveEndCallback=f,this.onMapClickCallback=g,this.onCircleDrawnCallback=p,this.enableDrawing=x,this.container.setAttribute("data-theme",m),this.container.style.cssText="position:relative;width:100%;height:100%;margin:0;padding:0;overflow:hidden;box-sizing:border-box;",this.injectGlobalStyles(),this.mapManager=new $_(this.container,a,h,c,d,l),this.layerManager=new Gh(this.mapManager.getMap()),this.drawToolManager=new d_,this.drawingManager=new U_,this.eventManager=new V_,this.initUI(),this.initLayers(),this.initEventManager(),this.initDrawingManager(),this.bindEvents(),this.initRightClickMenu(),this.onLoadCallback&&setTimeout(()=>this.onLoadCallback?.(this),100),setTimeout(()=>this.hideLoading(),500)}injectGlobalStyles(){if(cs.globalStylesInjected)return;cs.globalStylesInjected=!0;const t="earthview-global-styles";if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent=`
|
|
1927
|
+
@keyframes earthview-spin {
|
|
1928
|
+
0% { transform: rotate(0deg); }
|
|
1929
|
+
100% { transform: rotate(360deg); }
|
|
1930
|
+
}
|
|
1931
|
+
@keyframes earthview-pulse {
|
|
1932
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
1933
|
+
50% { opacity: 0.5; transform: scale(1.2); }
|
|
1934
|
+
}
|
|
1935
|
+
`,document.head.appendChild(e)}}initEventManager(){this.eventManager.setDrawingManager(this.drawingManager),this.eventManager.setMapView(this.mapManager.getMap()),this.eventManager.bindEvents(this.container)}resolveContainer(t){const{container:e,containerSelector:i,id:n,parent:r,parentSelector:o}=t;if(e)return{container:e,isOwn:!1};if(i){const a=document.querySelector(i);if(!a)throw new Error(`[EarthView] Container element not found: ${i}`);return{container:a,isOwn:!1}}if(n){const a=document.getElementById(n);if(!a)throw new Error(`[EarthView] Container element not found: #${n}`);return{container:a,isOwn:!1}}if(r){const a=this.createAutoContainer();return r.appendChild(a),{container:a,isOwn:!0}}if(o){const a=document.querySelector(o);if(!a)throw new Error(`[EarthView] Parent element not found: ${o}`);const l=this.createAutoContainer();return a.appendChild(l),{container:l,isOwn:!0}}throw new Error("[EarthView] Must provide one of: container, containerSelector, id, parent, or parentSelector")}createAutoContainer(){const t=document.createElement("div");return t.style.cssText="width:100%;height:100%;position:relative;overflow:hidden;margin:0;padding:0;box-sizing:border-box;",t}initUI(){this.uiManager=new W_(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(),onDrawFreehand:()=>this.startDrawFreehand(),onDrawFreehandPolygon:()=>this.startDrawFreehandPolygon(),onDrawEllipse:()=>this.startDrawEllipse(),onDrawMarker:()=>this.startDrawMarker(),onDrawText:()=>this.startDrawText(),onDrawArrow:()=>this.startDrawArrow(),onDrawLine:()=>this.startDrawLine(),onDrawBezier:()=>this.startDrawBezier(),onDrawSector:()=>this.startDrawSector(),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),onPointCoordinatePick:()=>this.startPointCoordinatePick(),onLineCoordinatePick:()=>this.startLineCoordinatePick(),onPolygonCoordinatePick:()=>this.startPolygonCoordinatePick(),onShowCoordinateList:()=>this.showCoordinateList(),getPointData:()=>this.getPointDataForPanel(),getLineData:()=>this.getLineDataForPanel(),getPolygonData:()=>this.getPolygonDataForPanel(),onLocateCoordinate:(t,e)=>this.locateToPoint(t,e),onLocateLine:t=>this.locateToLine(t),onLocatePolygon:t=>this.locateToPolygon(t),onDrawImage:()=>this.startDrawImage(),onGetLayerFeatures:t=>{const e=this.layerManager.getLayer(t);return e&&e instanceof is?e.getAllMarkers().map(n=>({id:n.id,name:n.bubbleBoxTitle||n.name||n.id,type:"point",coordinates:{longitude:n.longitude,latitude:n.latitude},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof Qn?(e.getAllPolygons?.()||[]).map((n,r)=>({id:n.id||`polygon_${r}`,name:n.title||n.name||`面 ${r+1}`,type:"polygon",coordinates:n.points||n.coordinates,properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof ts?(e.getAllPolylines?.()||[]).map((n,r)=>({id:n.id||`polyline_${r}`,name:n.title||n.name||`线 ${r+1}`,type:"line",coordinates:n.points||n.coordinates,properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof es?(e.getAllCircles?.()||[]).map((n,r)=>({id:n.id||`circle_${r}`,name:n.title||n.name||`圆 ${r+1}`,type:"polygon",coordinates:{center:n.center,radius:n.radius},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof pr?(e.getLayer()?.getSource()?.getFeatures()||[]).map((r,o)=>{const a=r.getGeometry();let l=r.get("longitude"),h=r.get("latitude");if((l===void 0||h===void 0)&&a){const c=a.getCoordinates();l=c[0],h=c[1]}return{id:r.get("id")||`heat_${o}`,name:`HotPoint ${o+1}`,type:"point",coordinates:{longitude:l,latitude:h},properties:r.getProperties(),timestamp:Date.now()}}):e&&e instanceof bd?(e.getData?.()||[]).map((n,r)=>({id:n.id||`cluster_${r}`,name:n.title||`聚合点 ${r+1}`,type:"point",coordinates:{longitude:n.longitude,latitude:n.latitude},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof Id?(e.getData?.()||[]).map((n,r)=>({id:n.id||`barchart_${r}`,name:n.title||`柱 ${r+1}`,type:"point",coordinates:{longitude:n.longitude,latitude:n.latitude},properties:n,timestamp:n.timestamp||Date.now()})):e&&e instanceof Pd?e.getAllFeatures().map((n,r)=>{const o=n.getGeometry?.();let a="point",l=null;if(o){const h=o.getType();if(h==="Point"){a="point";const c=o.getCoordinates();l={longitude:c[0],latitude:c[1]}}else h==="LineString"?(a="line",l=o.getCoordinates().map(c=>({longitude:c[0],latitude:c[1]}))):h==="Polygon"&&(a="polygon",l=o.getCoordinates()[0].map(c=>({longitude:c[0],latitude:c[1]})))}return{id:n.getId?.()||`geojson_${r}`,name:n.get("name")||n.get("title")||`Elements ${r+1}`,type:a,coordinates:l,properties:n.getProperties?.(),timestamp:Date.now()}}):[]},onLocateFeature:(t,e)=>{const i=this.layerManager.getLayer(t),n=d=>{if(!d)return null;if(d.longitude!==void 0&&d.latitude!==void 0)return{lng:d.longitude,lat:d.latitude};if(d.coordinates){if(d.coordinates.longitude!==void 0&&d.coordinates.latitude!==void 0)return{lng:d.coordinates.longitude,lat:d.coordinates.latitude};if(Array.isArray(d.coordinates)&&d.coordinates.length>=2)return{lng:d.coordinates[0],lat:d.coordinates[1]}}return null},r=d=>{if(!d)return null;let u=d.points||d.coordinates;return!u||!Array.isArray(u)||u.length===0?null:u.map(f=>({lng:f.longitude??f[0],lat:f.latitude??f[1]}))},a=i instanceof is?i.getMarker(e):i instanceof Qn?i.getPolygon?.(e):i instanceof ts?i.getPolyline?.(e):i instanceof es?i.getCircle?.(e):(i?.getAllFeatures?.()||i?.getData?.()||[]).find(u=>u.id===e);if(!a){this.showToast("The element was not found.");return}let l,h,c=16;if(i instanceof is){const d=n(a);d&&(l=d.lng,h=d.lat,c=18)}else if(i instanceof es)if(a.center)l=a.center[0],h=a.center[1];else{const d=n(a);d&&(l=d.lng,h=d.lat)}else if(i instanceof Qn||i instanceof ts){const d=r(a);if(d&&d.length>0){const u=d.map(p=>p.lng),f=d.map(p=>p.lat);l=(Math.min(...u)+Math.max(...u))/2,h=(Math.min(...f)+Math.max(...f))/2;const g=Math.max(...u)-Math.min(...u);c=g>.5?10:g>.1?12:g>.05?14:16}}else if(i instanceof pr){const f=(i.getLayer()?.getSource()?.getFeatures()||[]).find(g=>g.get("id")===e);if(f){const g=f.get("longitude"),p=f.get("latitude"),m=f.getGeometry();if(g!==void 0&&p!==void 0)l=g,h=p,c=16;else if(m){const y=m.getCoordinates();l=y[0],h=y[1],c=16}}}else{const d=n(a);d&&(l=d.lng,h=d.lat,c=16)}l!==void 0&&h!==void 0?(this.setCenter([l,h]),this.setZoom(c),this.showToast(`${this.t.locatedToPoint}: ${l.toFixed(6)}, ${h.toFixed(6)}`)):this.showToast("Unable to locate the element")},onCopyFeatureCoordinates:(t,e)=>{const i=this.layerManager.getLayer(t);let n="";if(i&&i instanceof is){const r=i.getMarker(e);r&&(n=`${r.longitude.toFixed(8)}, ${r.latitude.toFixed(8)}`)}else if(i&&i instanceof pr){const a=(i.getLayer()?.getSource()?.getFeatures()||[]).find(l=>l.get("id")===e);if(a){const l=a.get("longitude"),h=a.get("latitude"),c=a.getGeometry();if(l!==void 0&&h!==void 0)n=`${Number(l).toFixed(8)}, ${Number(h).toFixed(8)}`;else if(c){const d=c.getCoordinates();n=`${d[0].toFixed(8)}, ${d[1].toFixed(8)}`}}}else if(i&&i instanceof Qn){const r=i.getPolygon?.(e);r&&r.points&&(n=r.points.map(o=>{const a=o.longitude??o[0],l=o.latitude??o[1];return`${a.toFixed(8)}, ${l.toFixed(8)}`}).join(`
|
|
1818
1936
|
`))}else if(i&&i instanceof ts){const r=i.getPolyline?.(e);r&&r.points&&(n=r.points.map(o=>{const a=o.longitude??o[0],l=o.latitude??o[1];return`${a.toFixed(8)}, ${l.toFixed(8)}`}).join(`
|
|
1819
1937
|
`))}else if(i&&i instanceof es){const r=i.getCircle?.(e);r&&r.center&&(n=`Center: ${r.center[0].toFixed(8)}, ${r.center[1].toFixed(8)}
|
|
1820
1938
|
Radius: ${r.radius}m`)}else{const o=(i?.getAllFeatures?.()||[]).find(a=>a.id===e);o&&o.longitude!==void 0&&o.latitude!==void 0&&(n=`${o.longitude.toFixed(8)}, ${o.latitude.toFixed(8)}`)}n?(navigator.clipboard.writeText(n),this.showToast(this.t.coordinatesCopied)):this.showToast("No coordinates to copy")}},()=>this.getLayerList(),()=>this.getBasemap()),this.createStatusIndicators()}updateCoordinateListPanel(){this.pointCoordinateListPanel&&this.pointCoordinateListPanel.getElement().querySelector(".coordinate-list-content")&&(this.pointCoordinateListPanel.destroy(),this.pointCoordinateListPanel=null,this.showCoordinateList())}showToast(t){const e=document.createElement("div");e.style.cssText=`
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1939
|
+
position: absolute;
|
|
1940
|
+
bottom: 80px;
|
|
1941
|
+
left: 50%;
|
|
1942
|
+
transform: translateX(-50%);
|
|
1943
|
+
background: rgba(0,0,0,0.8);
|
|
1944
|
+
color: white;
|
|
1945
|
+
padding: 8px 16px;
|
|
1946
|
+
border-radius: 8px;
|
|
1947
|
+
font-size: 12px;
|
|
1948
|
+
z-index: 10000;
|
|
1949
|
+
pointer-events: none;
|
|
1950
|
+
white-space: nowrap;
|
|
1951
|
+
`,e.textContent=t,this.container.appendChild(e),setTimeout(()=>e.remove(),2e3)}startPointCoordinatePick(){this.lineCoordinatePickLayer?.stopPick(),this.polygonCoordinatePickLayer?.stopPick(),this.setMeasureStatus(this.t.clickMapToPickPoint),this.pointCoordinatePickLayer?.startPick(t=>{this.setMeasureStatus(null),this.currentPointCoordinates.unshift(t),this.showToast(`${this.t.pointPickSuccess}: ${t.longitude.toFixed(6)}, ${t.latitude.toFixed(6)}`)})}startLineCoordinatePick(){this.pointCoordinatePickLayer?.stopPick(),this.polygonCoordinatePickLayer?.stopPick(),this.setMeasureStatus(this.t.clickMapToDrawLine),this.lineCoordinatePickLayer?.startPick(t=>{this.setMeasureStatus(null),this.currentLineCoordinates.unshift(t),this.showToast(`${this.t.linePickSuccess} ${t.points.length} ${this.t.points}`)})}startPolygonCoordinatePick(){this.pointCoordinatePickLayer?.stopPick(),this.lineCoordinatePickLayer?.stopPick(),this.setMeasureStatus(this.t.clickMapToDrawPolygon),this.polygonCoordinatePickLayer?.startPick(t=>{this.setMeasureStatus(null),this.currentPolygonCoordinates.unshift(t),this.showToast(`${this.t.polygonPickSuccess} ${t.points.length} ${this.t.points}`)})}showCoordinateList(){const t=this.currentPointCoordinates.length,e=this.currentLineCoordinates.length,i=this.currentPolygonCoordinates.length;if(t===0&&e===0&&i===0){this.showToast(this.t.noCoordinateData);return}let n=`${this.t.coordinateData}
|
|
1834
1952
|
|
|
1835
1953
|
`;if(t>0&&(n+=`${this.t.pointData} (${t}):
|
|
1836
1954
|
`,this.currentPointCoordinates.slice(0,5).forEach((r,o)=>{n+=` ${o+1}. ${r.longitude.toFixed(6)}, ${r.latitude.toFixed(6)}
|
|
@@ -1853,11 +1971,11 @@ ${this.t.copyAllPointCoordinates}`,confirm(n)){const r=this.currentPointCoordina
|
|
|
1853
1971
|
padding: 8px 16px; backdrop-filter: blur(4px);
|
|
1854
1972
|
display: flex; align-items: center; gap: 10px;
|
|
1855
1973
|
display: none;
|
|
1856
|
-
`;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=`
|
|
1974
|
+
`;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:earthview-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=`
|
|
1857
1975
|
position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
|
|
1858
1976
|
z-index: 200; background: ${t?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.95)"};
|
|
1859
1977
|
border: 1px solid ${t?"#444":"#ddd"}; border-radius: 8px;
|
|
1860
1978
|
padding: 6px 12px; backdrop-filter: blur(4px);
|
|
1861
1979
|
display: flex; align-items: center; gap: 8px; pointer-events: none;
|
|
1862
1980
|
display: none;
|
|
1863
|
-
`;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 Pd("circle-draw",this.t.circleDrawLayer),this.circleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.circleDrawLayer),this.rectangleDrawLayer=new Yy("rectangle-draw",this.t.rectangleDrawLayer),this.rectangleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.rectangleDrawLayer),this.triangleDrawLayer=new Zy("triangle-draw",this.t.triangleDrawLayer),this.triangleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.triangleDrawLayer),this.imageDrawLayer=new j_("image-draw",this.t.imageDrawLayer),this.imageDrawLayer.setView(this.mapManager.getMap()),this.imageDrawLayer.setTheme(this.theme,this.t),this.imageDrawLayer.setZIndex(200),this.layerManager.addLayer(this.imageDrawLayer),this.pointCoordinatePickLayer=new Qy("point-coordinate-pick",this.t.pointPickLayer,{t:this.t}),this.pointCoordinatePickLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.pointCoordinatePickLayer),this.lineCoordinatePickLayer=new U_("line-coordinate-pick",this.t.linePickLayer,{t:this.t}),this.lineCoordinatePickLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.lineCoordinatePickLayer),this.polygonCoordinatePickLayer=new V_("polygon-coordinate-pick",this.t.polygonPickLayer,{t:this.t}),this.polygonCoordinatePickLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.polygonCoordinatePickLayer),this.freehandDrawLayer=new fm("freehand-draw",this.t.freehandDrawLayer),this.freehandDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.freehandDrawLayer),this.ellipseDrawLayer=new gm("ellipse-draw",this.t.ellipseDrawLayer),this.ellipseDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.ellipseDrawLayer),this.markerDrawLayer=new pm("marker-draw",this.t.markerDrawLayer),this.markerDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.markerDrawLayer),this.textDrawLayer=new ym("text-draw",this.t.textDrawLayer),this.textDrawLayer.setView(this.mapManager.getMap()),this.textDrawLayer.setTheme(this.theme,this.t),this.layerManager.addLayer(this.textDrawLayer),this.arrowDrawLayer=new _m("arrow-draw",this.t.arrowDrawLayer),this.arrowDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.arrowDrawLayer),this.distanceMeasureLayer=new Id("distance-measurement",this.t.distanceMeasurementLayer),this.distanceMeasureLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.distanceMeasureLayer),this.areaMeasureLayer=new Ld("area-measurement",this.t.areaMeasurementLayer),this.areaMeasureLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.areaMeasureLayer),this.lineDrawLayer=new Ky("line-draw",this.t.lineDrawLayer),this.lineDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.lineDrawLayer),this.bezierDrawLayer=new qy("bezier-draw",this.t.bezierDrawLayer),this.bezierDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.bezierDrawLayer),this.sectorDrawLayer=new Jy("sector-draw",this.t.sectorDrawLayer),this.sectorDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.sectorDrawLayer),this.imageDrawTool=new H_(this.imageDrawLayer,this.t),this.imageDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.lineDrawTool=new z_(this.lineDrawLayer,this.t),this.bezierDrawTool=new $_(this.bezierDrawLayer,this.t),this.sectorDrawTool=new N_(this.sectorDrawLayer,this.t),this.lineDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.bezierDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.sectorDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.circleDrawTool=new Dd(this.circleDrawLayer,this.t),this.rectangleDrawTool=new kd(this.rectangleDrawLayer,this.t),this.triangleDrawTool=new Rd(this.triangleDrawLayer,this.t),this.freehandDrawTool=new Ad(this.freehandDrawLayer,this.t,!1),this.ellipseDrawTool=new Md(this.ellipseDrawLayer,this.t),this.markerDrawTool=new Fd(this.markerDrawLayer,this.t),this.textDrawTool=new Od(this.textDrawLayer,this.t),this.arrowDrawTool=new zd(this.arrowDrawLayer,this.t),this.circleDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.rectangleDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.triangleDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.freehandDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.ellipseDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.markerDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.textDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.arrowDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.drawingManager.registerTools(this.circleDrawTool,this.rectangleDrawTool,this.triangleDrawTool,this.freehandDrawTool,this.ellipseDrawTool,this.markerDrawTool,this.textDrawTool,this.arrowDrawTool,this.lineDrawTool,this.bezierDrawTool,this.sectorDrawTool,this.imageDrawTool),this.drawingManager.setCallbacks(t=>this.onDrawingStart(t),()=>this.onDrawingEnd()),this.setupSelections())}onDrawingStart(t){let e="";switch(t){case ct.CIRCLE:e=this.t.drawingCircle;break;case ct.RECTANGLE:e=this.t.drawingRectangle;break;case ct.TRIANGLE:e=this.t.drawingTriangle;break;case ct.FREEHAND:e=this.t.drawingFreehand;break;case ct.FREEHAND_POLYGON:e=this.t.drawingFreehandPolygon;break;case ct.ELLIPSE:e=this.t.drawingEllipse;break;case ct.MARKER:e=this.t.addingMarker;break;case ct.TEXT:e=this.t.addingText;break;case ct.ARROW:e=this.t.drawingArrow;break;case ct.LINE:e=this.t.drawingLine;break;case ct.BEZIER:e=this.t.drawingBezier;break;case ct.SECTOR:e=this.t.drawingSector;break;default:e=this.t.drawing}this.setDrawingStatus(`${e}${this.t.pressEscToCancel}`)}onDrawingEnd(){this.setDrawingStatus(null)}setupSelections(){const t=this.mapManager.getMap(),e=o=>{const a=o.get("id");if(!a)return null;if(typeof a=="string"){if(a.startsWith("circle_"))return"circle";if(a.startsWith("rectangle_"))return"rectangle";if(a.startsWith("triangle_"))return"triangle";if(a.startsWith("freehand_"))return"freehand";if(a.startsWith("ellipse_"))return"ellipse";if(a.startsWith("marker_"))return"marker";if(a.startsWith("text_"))return"text";if(a.startsWith("arrow_")&&!a.endsWith("_head"))return"arrow";if(a.startsWith("line_"))return"line";if(a.startsWith("bezier_"))return"bezier";if(a.startsWith("sector_"))return"sector";if(a.startsWith("image_"))return"image"}return null},i=()=>this.circleDrawLayer?.getEditingId()||this.rectangleDrawLayer?.getEditingId()||this.triangleDrawLayer?.getEditingId()||this.freehandDrawLayer?.getEditingId()||this.ellipseDrawLayer?.getEditingId()||this.markerDrawLayer?.getEditingId()||this.textDrawLayer?.getEditingId()||this.arrowDrawLayer?.getEditingId()||this.lineDrawLayer?.getEditingId()||this.bezierDrawLayer?.getEditingId()||this.sectorDrawLayer?.getEditingId()||null,n=()=>!!(this.circleDrawLayer?.isDrawActive()||this.rectangleDrawLayer?.isDrawActive()||this.triangleDrawLayer?.isDrawActive()||this.freehandDrawLayer?.isDrawActive()||this.ellipseDrawLayer?.isDrawActive()||this.markerDrawLayer?.isDrawActive()||this.textDrawLayer?.isDrawActive()||this.arrowDrawLayer?.isDrawActive()||this.lineDrawLayer?.isDrawActive()||this.bezierDrawLayer?.isDrawActive()||this.sectorDrawLayer?.isDrawActive()),r=(o,a)=>{if(o)switch(this.stopAllEditing(),a){case"circle":this.circleDrawTool?.startEdit(o);break;case"rectangle":this.rectangleDrawTool?.startEdit(o);break;case"triangle":this.triangleDrawTool?.startEdit(o);break;case"freehand":this.freehandDrawTool?.startEdit(o);break;case"ellipse":this.ellipseDrawTool?.startEdit(o);break;case"marker":this.markerDrawTool?.startEdit(o);break;case"text":this.textDrawTool?.startEdit(o);break;case"arrow":this.arrowDrawTool?.startEdit(o);break;case"line":this.lineDrawTool?.startEdit(o);break;case"bezier":this.bezierDrawTool?.startEdit(o);break;case"sector":this.sectorDrawTool?.startEdit(o);break;case"image":this.imageDrawTool?.startEdit(o);break}};t.on("singleclick",o=>{if(n()||this.textDrawLayer?.isInputActive||this.imageDrawLayer?.isInputActive)return;const a=t.getFeaturesAtPixel(o.pixel,{hitTolerance:5});let l=null,h=null;for(const c of a){const d=e(c);if(d){l=c,h=d;break}}if(l&&h){const c=l.get("id");if(i()===c)return;c&&r(c,h)}else 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.imageDrawLayer?.isInputActive||(this.hideFloatingToolbar(),this.hideMeasurementToolbar())})}initRightClickMenu(){this.container.addEventListener("contextmenu",t=>{if(this.imageDrawLayer?.isInputActive){t.preventDefault();return}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(_=>_.get("type")==="point_pick");if(a&&this.pointCoordinatePickLayer){const _=a.get("id");if(this.pointCoordinatePickLayer.getCoordinate(_)){this.selectedPointPickId=_,this.showMeasurementToolbarForFeature({x:i,y:n});return}}const l=o?.find(_=>_.get("type")==="line_pick");if(l&&this.lineCoordinatePickLayer){const _=l.get("id");if(this.lineCoordinatePickLayer.getLine(_)){this.selectedLinePickId=_,this.showMeasurementToolbarForFeature({x:i,y:n});return}}const h=o?.find(_=>_.get("type")==="polygon_pick");if(h&&this.polygonCoordinatePickLayer){const _=h.get("id");if(this.polygonCoordinatePickLayer.getPolygon(_)){this.selectedPolygonPickId=_,this.showMeasurementToolbarForFeature({x:i,y:n});return}}const c=o?.find(_=>_.get("id")?.startsWith("circle_"));if(c&&this.circleDrawLayer){const _=this.circleDrawLayer.getCircle(c.get("id"));if(_){this.selectedCircleId=_.id,this.showFloatingToolbarForCircle({x:i,y:n},_);return}}const d=o?.find(_=>_.get("id")?.startsWith("rectangle_"));if(d&&this.rectangleDrawLayer){const _=this.rectangleDrawLayer.getRectangle(d.get("id"));if(_){this.selectedRectangleId=_.id,this.showFloatingToolbarForRectangle({x:i,y:n},_);return}}const u=o?.find(_=>_.get("id")?.startsWith("triangle_"));if(u&&this.triangleDrawLayer){const _=this.triangleDrawLayer.getTriangle(u.get("id"));if(_){this.selectedTriangleId=_.id,this.showFloatingToolbarForTriangle({x:i,y:n},_);return}}const f=o?.find(_=>{const b=_.get("id");return b&&typeof b=="string"&&b.startsWith("freehand_")});if(f&&this.freehandDrawLayer){const _=this.freehandDrawLayer.getFreehand(f.get("id"));if(_){this.selectedFreehandId=_.id,this.showFloatingToolbarForFreehand({x:i,y:n},_);return}}const g=o?.find(_=>_.get("id")?.startsWith("line_"));if(g&&this.lineDrawLayer){const _=this.lineDrawLayer.getLine(g.get("id"));if(_){this.selectedLineId=_.id,this.showFloatingToolbarForLine({x:i,y:n},_);return}}const p=o?.find(_=>_.get("id")?.startsWith("bezier_"));if(p&&this.bezierDrawLayer){const _=this.bezierDrawLayer.getBezier(p.get("id"));if(_){this.selectedBezierId=_.id,this.showFloatingToolbarForBezier({x:i,y:n},_);return}}const m=o?.find(_=>_.get("id")?.startsWith("sector_"));if(m&&this.sectorDrawLayer){const _=this.sectorDrawLayer.getSector(m.get("id"));if(_){this.selectedSectorId=_.id,this.showFloatingToolbarForSector({x:i,y:n},_);return}}const y=o?.find(_=>_.get("id")?.startsWith("ellipse_"));if(y&&this.ellipseDrawLayer){const _=this.ellipseDrawLayer.getEllipse(y.get("id"));if(_){this.selectedEllipseId=_.id,this.showFloatingToolbarForEllipse({x:i,y:n},_);return}}const w=o?.find(_=>_.get("id")?.startsWith("marker_"));if(w&&this.markerDrawLayer){const _=this.markerDrawLayer.getMarker(w.get("id"));if(_){this.selectedMarkerId=_.id,this.showFloatingToolbarForMarker({x:i,y:n},_);return}}const E=o?.find(_=>_.get("id")?.startsWith("text_"));if(E&&this.textDrawLayer){const _=this.textDrawLayer.getText(E.get("id"));if(_){this.selectedTextId=_.id,this.textDrawTool?.editProperties(_.id);return}}const x=o?.find(_=>_.get("id")?.startsWith("image_"));if(x&&this.imageDrawLayer){const _=this.imageDrawLayer.getImage(x.get("id"));if(_){this.selectedImageId=_.id,this.imageDrawTool?.editProperties(_.id);return}}const C=o?.find(_=>_.get("id")?.startsWith("arrow_")&&!_.get("id")?.toString().endsWith("_head"));if(C&&this.arrowDrawLayer){const _=this.arrowDrawLayer.getArrow(C.get("id"));if(_){this.selectedArrowId=_.id,this.showFloatingToolbarForArrow({x:i,y:n},_);return}}const T=o?.find(_=>_.get("measurementId"));if(T){this.selectedMeasurementId=T.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.textDrawLayer?.isInputActive||this.imageDrawLayer?.isInputActive||(this.circleDrawLayer?.stopEdit(),this.rectangleDrawLayer?.stopEdit(),this.triangleDrawLayer?.stopEdit(),this.freehandDrawLayer?.stopEdit(),this.ellipseDrawLayer?.stopEdit(),this.markerDrawLayer?.stopEdit(),this.textDrawLayer?.stopEdit(),this.arrowDrawLayer?.stopEdit(),this.lineDrawLayer?.stopEdit(),this.bezierDrawLayer?.stopEdit(),this.sectorDrawLayer?.stopEdit(),this.imageDrawLayer?.stopEdit())}showFloatingToolbarForCircle(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[255,0,0,1],r=e.outlineWidth||3,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.circleDrawLayer?.updateCircleStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedCircleId=i},onStrokeWidthChange:a=>{r=a,this.circleDrawLayer?.updateCircleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedCircleId=i},onStrokeStyleChange:a=>{o=a,this.circleDrawLayer?.updateCircleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedCircleId=i},onDelete:()=>{this.circleDrawLayer?.removeCircle(i),this.selectedCircleId===i&&(this.selectedCircleId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedCircleId===i&&(this.selectedCircleId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForRectangle(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[0,0,255,1],r=e.outlineWidth||3,o="solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.rectangleDrawLayer?.updateRectangleStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedRectangleId=i},onStrokeWidthChange:a=>{r=a,this.rectangleDrawLayer?.updateRectangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedRectangleId=i},onStrokeStyleChange:a=>{o=a,this.rectangleDrawLayer?.updateRectangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedRectangleId=i},onDelete:()=>{this.rectangleDrawLayer?.removeRectangle(i),this.selectedRectangleId===i&&(this.selectedRectangleId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedRectangleId===i&&(this.selectedRectangleId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForFreehand(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[76,175,80,.3],r=e.outlineColor||[76,175,80,1],o=e.outlineWidth||3,a=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:l=>{n=[l[0],l[1],l[2],.3],r=[l[0],l[1],l[2],1],this.freehandDrawLayer?.updateFreehandStyle(i,n,r,o,a),this.selectedFreehandId=i},onStrokeWidthChange:l=>{o=l,this.freehandDrawLayer?.updateFreehandStyle(i,n,r,l,a),this.selectedFreehandId=i},onStrokeStyleChange:l=>{a=l,this.freehandDrawLayer?.updateFreehandStyle(i,n,r,o,l),this.selectedFreehandId=i},onDelete:()=>{this.freehandDrawLayer?.removeFreehand(i),this.selectedFreehandId===i&&(this.selectedFreehandId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedFreehandId===i&&(this.selectedFreehandId=null),this.hideFloatingToolbar()},onPositionChange:l=>{this.floatingToolbarPosition=l},theme:this.theme,t:this.t,containerRef:this.container,currentColor:r,currentStrokeWidth:o,currentStrokeStyle:a,position:t})}showFloatingToolbarForLine(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[255,193,7,1],r=e.width||3,o=e.style||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.lineDrawLayer?.updateLineStyle(i,a,r,o),this.selectedLineId=i},onStrokeWidthChange:a=>{r=a,this.lineDrawLayer?.updateLineStyle(i,n,a,o),this.selectedLineId=i},onStrokeStyleChange:a=>{o=a,this.lineDrawLayer?.updateLineStyle(i,n,r,a),this.selectedLineId=i},onDelete:()=>{this.lineDrawLayer?.removeLine(i),this.selectedLineId===i&&(this.selectedLineId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedLineId===i&&(this.selectedLineId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForBezier(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[156,39,176,1],r=e.width||3,o=e.style||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.bezierDrawLayer?.updateBezierStyle(i,a,r,o),this.selectedBezierId=i},onStrokeWidthChange:a=>{r=a,this.bezierDrawLayer?.updateBezierStyle(i,n,a,o),this.selectedBezierId=i},onStrokeStyleChange:a=>{o=a,this.bezierDrawLayer?.updateBezierStyle(i,n,r,a),this.selectedBezierId=i},onDelete:()=>{this.bezierDrawLayer?.removeBezier(i),this.selectedBezierId===i&&(this.selectedBezierId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedBezierId===i&&(this.selectedBezierId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForSector(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[33,150,243,.3],r=e.outlineWidth||2,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.sectorDrawLayer?.updateSectorStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedSectorId=i},onStrokeWidthChange:a=>{r=a,this.sectorDrawLayer?.updateSectorStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedSectorId=i},onStrokeStyleChange:a=>{o=a,this.sectorDrawLayer?.updateSectorStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedSectorId=i},onDelete:()=>{this.sectorDrawLayer?.removeSector(i),this.selectedSectorId===i&&(this.selectedSectorId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedSectorId===i&&(this.selectedSectorId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:[n[0],n[1],n[2],1],currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForEllipse(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[156,39,176,.3],r=e.outlineWidth||2,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.ellipseDrawLayer?.updateEllipseStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedEllipseId=i},onStrokeWidthChange:a=>{r=a,this.ellipseDrawLayer?.updateEllipseStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedEllipseId=i},onStrokeStyleChange:a=>{o=a,this.ellipseDrawLayer?.updateEllipseStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedEllipseId=i},onDelete:()=>{this.ellipseDrawLayer?.removeEllipse(i),this.selectedEllipseId===i&&(this.selectedEllipseId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedEllipseId===i&&(this.selectedEllipseId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:[n[0],n[1],n[2],1],currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForMarker(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[255,87,34,1],r=e.size||10;this.floatingToolbar=new ke({onColorChange:o=>{n=o,this.markerDrawLayer?.updateMarkerStyle(i,o,r),this.selectedMarkerId=i},onStrokeWidthChange:o=>{r=o,this.markerDrawLayer?.updateMarkerStyle(i,n,o),this.selectedMarkerId=i},onStrokeStyleChange:()=>{},onDelete:()=>{this.markerDrawLayer?.removeMarker(i),this.selectedMarkerId===i&&(this.selectedMarkerId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedMarkerId===i&&(this.selectedMarkerId=null),this.hideFloatingToolbar()},onPositionChange:o=>{this.floatingToolbarPosition=o},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:"solid",position:t})}startDrawImage(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingImage()}showFloatingToolbarForArrow(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[255,87,34,1],r=e.width||3,o=e.style||"solid";const a=e.headSize||50;this.floatingToolbar=new ke({onColorChange:l=>{n=l,this.arrowDrawLayer?.updateArrowStyle(i,l,r,o,a),this.selectedArrowId=i},onStrokeWidthChange:l=>{r=l,this.arrowDrawLayer?.updateArrowStyle(i,n,l,o,a),this.selectedArrowId=i},onStrokeStyleChange:l=>{o=l,this.arrowDrawLayer?.updateArrowStyle(i,n,r,l,a),this.selectedArrowId=i},onDelete:()=>{this.arrowDrawLayer?.removeArrow(i),this.selectedArrowId===i&&(this.selectedArrowId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedArrowId===i&&(this.selectedArrowId=null),this.hideFloatingToolbar()},onPositionChange:l=>{this.floatingToolbarPosition=l},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showGenericFloatingToolbar(t,e){this.floatingToolbar?(this.floatingToolbar.updatePosition(t),this.floatingToolbar.setVisible(!0)):this.floatingToolbar=new ke({onColorChange:i=>{this.currentColor=i,e.updateStyle(i,this.currentStrokeWidth,this.currentStrokeStyle)},onStrokeWidthChange:i=>{this.currentStrokeWidth=i,e.updateStyle(this.currentColor,i,this.currentStrokeStyle)},onStrokeStyleChange:i=>{this.currentStrokeStyle=i,e.updateStyle(this.currentColor,this.currentStrokeWidth,i)},onDelete:()=>{e.delete(),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.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[255,255,0,1],r=e.outlineWidth||3,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.triangleDrawLayer?.updateTriangleStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedTriangleId=i},onStrokeWidthChange:a=>{r=a,this.triangleDrawLayer?.updateTriangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedTriangleId=i},onStrokeStyleChange:a=>{o=a,this.triangleDrawLayer?.updateTriangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedTriangleId=i},onDelete:()=>{this.triangleDrawLayer?.removeTriangle(i),this.selectedTriangleId===i&&(this.selectedTriangleId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedTriangleId===i&&(this.selectedTriangleId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showMeasurementToolbarForFeature(t){this.measurementToolbarPosition=t,this.showMeasurementToolbar=!0,this.measurementFloatingToolbar&&(this.measurementFloatingToolbar.destroy(),this.measurementFloatingToolbar=null),this.measurementFloatingToolbar=new r_({onDelete:()=>{this.selectedMeasurementId?(this.deleteMeasurement(this.selectedMeasurementId),this.selectedMeasurementId=null):this.selectedPointPickId?(this.deleteMeasurement(this.selectedPointPickId),this.selectedPointPickId=null):this.selectedLinePickId?(this.deleteMeasurement(this.selectedLinePickId),this.selectedLinePickId=null):this.selectedPolygonPickId&&(this.deleteMeasurement(this.selectedPolygonPickId),this.selectedPolygonPickId=null),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.selectedFreehandId=null,this.selectedEllipseId=null,this.selectedMarkerId=null,this.selectedTextId=null,this.selectedArrowId=null,this.selectedLineId=null,this.selectedBezierId=null,this.selectedSectorId=null,this.selectedImageId=null,this.floatingToolbar&&this.floatingToolbar.setVisible(!1)}hideMeasurementToolbar(){this.showMeasurementToolbar=!1,this.selectedMeasurementId=null,this.selectedPointPickId=null,this.selectedLinePickId=null,this.selectedPolygonPickId=null,this.measurementFloatingToolbar&&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),this.uiManager.updateCurrentBasemap(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),this.textDrawLayer?.setTheme(t,this.t)}getTheme(){return this.theme}setLocale(t){this.locale=t,this.t=Hi(t),this.uiManager.updateLocale(this.t)}getContainer(){return this.container}getLayerManager(){return this.layerManager}getMap(){return this.mapManager.getMap()}removeLayer(t){this.layerManager.removeLayer(t),this.uiManager.updateLayerList()}setLayerVisibility(t,e){this.layerManager.getLayer(t)?.setVisible(e),this.uiManager.updateLayerList()}startDrawFreehand(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingFreehand()}startDrawFreehandPolygon(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingFreehandPolygon()}startDrawEllipse(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingEllipse()}startDrawMarker(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingMarker()}startDrawText(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingText()}startDrawArrow(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingArrow()}startDrawLine(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingLine()}startDrawBezier(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingBezier()}startDrawSector(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingSector()}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 t.startsWith("LineCoordinatePick_")&&this.lineCoordinatePickLayer?.removeLine(t)?(this.currentLineCoordinates=this.currentLineCoordinates.filter(e=>e.id!==t),!0):t.startsWith("PolygonCoordinatePick_")&&this.polygonCoordinatePickLayer?.removePolygon(t)?(this.currentPolygonCoordinates=this.currentPolygonCoordinates.filter(e=>e.id!==t),!0):t.startsWith("coord_")&&this.pointCoordinatePickLayer?.removeCoordinate(t)?(this.currentPointCoordinates=this.currentPointCoordinates.filter(e=>e.id!==t),!0):!!(this.distanceMeasureLayer?.deleteMeasurement(t)||this.areaMeasureLayer?.deleteMeasurement(t))}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()))}getPointDataForPanel(){return(this.pointCoordinatePickLayer?.getAllCoordinates()||[]).map((e,i)=>({id:e.id,name:`${this.t.pointData} ${i+1}`,longitude:e.longitude,latitude:e.latitude,timestamp:e.timestamp}))}getLineDataForPanel(){return(this.lineCoordinatePickLayer?.getAllLines()||[]).map((e,i)=>({id:e.id,name:`${this.t.lineData} ${i+1}`,points:e.points,timestamp:e.timestamp}))}getPolygonDataForPanel(){return(this.polygonCoordinatePickLayer?.getAllPolygons()||[]).map((e,i)=>({id:e.id,name:`${this.t.polygonData} ${i+1}`,points:e.points,timestamp:e.timestamp}))}locateToPoint(t,e){this.setCenter([t,e]),this.setZoom(18),this.showToast(`${this.t.locatedToPoint}: ${t.toFixed(6)}, ${e.toFixed(6)}`)}locateToLine(t){if(t.length===0)return;const e=t.map(g=>g.longitude),i=t.map(g=>g.latitude),n=Math.min(...e),r=Math.max(...e),o=Math.min(...i),a=Math.max(...i),l=(n+r)/2,h=(o+a)/2;this.setCenter([l,h]);const c=r-n,d=a-o,u=Math.max(c,d);let f=18;u>.5?f=10:u>.1?f=12:u>.05?f=14:u>.01&&(f=16),this.setZoom(f),this.showToast(`${this.t.locatedToLine} ${t.length} ${this.t.points}`)}setBasemapByUrl(t){this.mapManager.setBasemapByUrl(t),this.uiManager.updateCurrentBasemap(null)}locateToPolygon(t){this.locateToLine(t),this.showToast(`${this.t.locatedToPolygon} ${t.length} ${this.t.points}`)}clearAllCoordinatePicks(){this.pointCoordinatePickLayer?.clearAllCoordinates(),this.lineCoordinatePickLayer?.clearAllLines(),this.polygonCoordinatePickLayer?.clearAllPolygons(),this.currentPointCoordinates=[],this.currentLineCoordinates=[],this.currentPolygonCoordinates=[],this.showToast(this.t.allCoordinatesCleared)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.eventManager.destroy(),this.uiManager.destroy(),this.drawingManager.destroy(),this.floatingToolbar?.destroy(),this.measurementFloatingToolbar?.destroy(),this.drawingStatusDiv?.remove(),this.measureStatusDiv?.remove(),this.freehandDrawTool?.destroy(),this.ellipseDrawTool?.destroy(),this.markerDrawTool?.destroy(),this.textDrawTool?.destroy(),this.arrowDrawTool?.destroy(),this.layerManager.clearAll(),this.mapManager.destroy(),this.isOwnContainer&&this.container.parentNode&&this.container.remove())}}exports.AreaMeasurementLayer=Ld;exports.BarChartLayer=Sd;exports.BaseLayer=It;exports.BasemapTypeEnum=dt;exports.CircleDrawLayer=Pd;exports.CircleLayer=es;exports.ClusterLayer=vd;exports.CoordinateSystemTypeEnum=Oe;exports.DistanceMeasurementLayer=Id;exports.EarthView=Y_;exports.GeoJSONLayer=bd;exports.HeatmapLayer=gr;exports.LayerManager=$h;exports.LayerTypeEnum=Z;exports.MarkerLayer=is;exports.MarkerLayerAnimationTypeEnum=_n;exports.MarkerLayerPointTypeEnum=H;exports.PolygonLayer=Qn;exports.PolylineLayer=ts;exports.bd09ToWgs84=Ud;exports.fromWGS84=M_;exports.gcj02ToWgs84=Tl;exports.getTranslation=Hi;exports.isInChina=F_;exports.toWGS84=ya;
|
|
1981
|
+
`;const n=document.createElement("div");n.style.cssText="width:8px;height:8px;background:#00aaff;border-radius:50%;animation:earthview-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)}initLayers(){this.enableDrawing&&(this.circleDrawLayer=new Ld("circle-draw",this.t.circleDrawLayer),this.circleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.circleDrawLayer),this.rectangleDrawLayer=new Ky("rectangle-draw",this.t.rectangleDrawLayer),this.rectangleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.rectangleDrawLayer),this.triangleDrawLayer=new qy("triangle-draw",this.t.triangleDrawLayer),this.triangleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.triangleDrawLayer),this.imageDrawLayer=new Z_("image-draw",this.t.imageDrawLayer),this.imageDrawLayer.setView(this.mapManager.getMap()),this.imageDrawLayer.setTheme(this.theme,this.t),this.imageDrawLayer.setZIndex(200),this.layerManager.addLayer(this.imageDrawLayer),this.pointCoordinatePickLayer=new e_("point-coordinate-pick",this.t.pointPickLayer,{t:this.t}),this.pointCoordinatePickLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.pointCoordinatePickLayer),this.lineCoordinatePickLayer=new H_("line-coordinate-pick",this.t.linePickLayer,{t:this.t}),this.lineCoordinatePickLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.lineCoordinatePickLayer),this.polygonCoordinatePickLayer=new X_("polygon-coordinate-pick",this.t.polygonPickLayer,{t:this.t}),this.polygonCoordinatePickLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.polygonCoordinatePickLayer),this.freehandDrawLayer=new pm("freehand-draw",this.t.freehandDrawLayer),this.freehandDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.freehandDrawLayer),this.ellipseDrawLayer=new mm("ellipse-draw",this.t.ellipseDrawLayer),this.ellipseDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.ellipseDrawLayer),this.markerDrawLayer=new ym("marker-draw",this.t.markerDrawLayer),this.markerDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.markerDrawLayer),this.textDrawLayer=new wm("text-draw",this.t.textDrawLayer),this.textDrawLayer.setView(this.mapManager.getMap()),this.textDrawLayer.setTheme(this.theme,this.t),this.layerManager.addLayer(this.textDrawLayer),this.arrowDrawLayer=new xm("arrow-draw",this.t.arrowDrawLayer),this.arrowDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.arrowDrawLayer),this.distanceMeasureLayer=new Dd("distance-measurement",this.t.distanceMeasurementLayer),this.distanceMeasureLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.distanceMeasureLayer),this.areaMeasureLayer=new kd("area-measurement",this.t.areaMeasurementLayer),this.areaMeasureLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.areaMeasureLayer),this.lineDrawLayer=new Jy("line-draw",this.t.lineDrawLayer),this.lineDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.lineDrawLayer),this.bezierDrawLayer=new Qy("bezier-draw",this.t.bezierDrawLayer),this.bezierDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.bezierDrawLayer),this.sectorDrawLayer=new t_("sector-draw",this.t.sectorDrawLayer),this.sectorDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.sectorDrawLayer),this.imageDrawTool=new j_(this.imageDrawLayer,this.t),this.imageDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.lineDrawTool=new N_(this.lineDrawLayer,this.t),this.bezierDrawTool=new G_(this.bezierDrawLayer,this.t),this.sectorDrawTool=new B_(this.sectorDrawLayer,this.t),this.lineDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.bezierDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.sectorDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.circleDrawTool=new Rd(this.circleDrawLayer,this.t),this.rectangleDrawTool=new Ad(this.rectangleDrawLayer,this.t),this.triangleDrawTool=new Md(this.triangleDrawLayer,this.t),this.freehandDrawTool=new Fd(this.freehandDrawLayer,this.t,!1),this.ellipseDrawTool=new Od(this.ellipseDrawLayer,this.t),this.markerDrawTool=new zd(this.markerDrawLayer,this.t),this.textDrawTool=new $d(this.textDrawLayer,this.t),this.arrowDrawTool=new Nd(this.arrowDrawLayer,this.t),this.circleDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.rectangleDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.triangleDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.freehandDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.ellipseDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.markerDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.textDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.arrowDrawTool.setOnDrawComplete(()=>this.onDrawingEnd()),this.drawingManager.registerTools(this.circleDrawTool,this.rectangleDrawTool,this.triangleDrawTool,this.freehandDrawTool,this.ellipseDrawTool,this.markerDrawTool,this.textDrawTool,this.arrowDrawTool,this.lineDrawTool,this.bezierDrawTool,this.sectorDrawTool,this.imageDrawTool),this.drawingManager.setCallbacks(t=>this.onDrawingStart(t),()=>this.onDrawingEnd()),this.setupSelections())}onDrawingStart(t){let e="";switch(t){case ct.CIRCLE:e=this.t.drawingCircle;break;case ct.RECTANGLE:e=this.t.drawingRectangle;break;case ct.TRIANGLE:e=this.t.drawingTriangle;break;case ct.FREEHAND:e=this.t.drawingFreehand;break;case ct.FREEHAND_POLYGON:e=this.t.drawingFreehandPolygon;break;case ct.ELLIPSE:e=this.t.drawingEllipse;break;case ct.MARKER:e=this.t.addingMarker;break;case ct.TEXT:e=this.t.addingText;break;case ct.ARROW:e=this.t.drawingArrow;break;case ct.LINE:e=this.t.drawingLine;break;case ct.BEZIER:e=this.t.drawingBezier;break;case ct.SECTOR:e=this.t.drawingSector;break;default:e=this.t.drawing}this.setDrawingStatus(`${e}${this.t.pressEscToCancel}`)}onDrawingEnd(){this.setDrawingStatus(null)}setupSelections(){const t=this.mapManager.getMap(),e=o=>{const a=o.get("id");if(!a)return null;if(typeof a=="string"){if(a.startsWith("circle_"))return"circle";if(a.startsWith("rectangle_"))return"rectangle";if(a.startsWith("triangle_"))return"triangle";if(a.startsWith("freehand_"))return"freehand";if(a.startsWith("ellipse_"))return"ellipse";if(a.startsWith("marker_"))return"marker";if(a.startsWith("text_"))return"text";if(a.startsWith("arrow_")&&!a.endsWith("_head"))return"arrow";if(a.startsWith("line_"))return"line";if(a.startsWith("bezier_"))return"bezier";if(a.startsWith("sector_"))return"sector";if(a.startsWith("image_"))return"image"}return null},i=()=>this.circleDrawLayer?.getEditingId()||this.rectangleDrawLayer?.getEditingId()||this.triangleDrawLayer?.getEditingId()||this.freehandDrawLayer?.getEditingId()||this.ellipseDrawLayer?.getEditingId()||this.markerDrawLayer?.getEditingId()||this.textDrawLayer?.getEditingId()||this.arrowDrawLayer?.getEditingId()||this.lineDrawLayer?.getEditingId()||this.bezierDrawLayer?.getEditingId()||this.sectorDrawLayer?.getEditingId()||null,n=()=>!!(this.circleDrawLayer?.isDrawActive()||this.rectangleDrawLayer?.isDrawActive()||this.triangleDrawLayer?.isDrawActive()||this.freehandDrawLayer?.isDrawActive()||this.ellipseDrawLayer?.isDrawActive()||this.markerDrawLayer?.isDrawActive()||this.textDrawLayer?.isDrawActive()||this.arrowDrawLayer?.isDrawActive()||this.lineDrawLayer?.isDrawActive()||this.bezierDrawLayer?.isDrawActive()||this.sectorDrawLayer?.isDrawActive()),r=(o,a)=>{if(o)switch(this.stopAllEditing(),a){case"circle":this.circleDrawTool?.startEdit(o);break;case"rectangle":this.rectangleDrawTool?.startEdit(o);break;case"triangle":this.triangleDrawTool?.startEdit(o);break;case"freehand":this.freehandDrawTool?.startEdit(o);break;case"ellipse":this.ellipseDrawTool?.startEdit(o);break;case"marker":this.markerDrawTool?.startEdit(o);break;case"text":this.textDrawTool?.startEdit(o);break;case"arrow":this.arrowDrawTool?.startEdit(o);break;case"line":this.lineDrawTool?.startEdit(o);break;case"bezier":this.bezierDrawTool?.startEdit(o);break;case"sector":this.sectorDrawTool?.startEdit(o);break;case"image":this.imageDrawTool?.startEdit(o);break}};t.on("singleclick",o=>{if(n()||this.textDrawLayer?.isInputActive||this.imageDrawLayer?.isInputActive)return;const a=t.getFeaturesAtPixel(o.pixel,{hitTolerance:5});let l=null,h=null;for(const c of a){const d=e(c);if(d){l=c,h=d;break}}if(l&&h){const c=l.get("id");if(i()===c)return;c&&r(c,h)}else 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.imageDrawLayer?.isInputActive||(this.hideFloatingToolbar(),this.hideMeasurementToolbar())})}initRightClickMenu(){this.container.addEventListener("contextmenu",t=>{if(this.imageDrawLayer?.isInputActive){t.preventDefault();return}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(_=>_.get("type")==="point_pick");if(a&&this.pointCoordinatePickLayer){const _=a.get("id");if(this.pointCoordinatePickLayer.getCoordinate(_)){this.selectedPointPickId=_,this.showMeasurementToolbarForFeature({x:i,y:n});return}}const l=o?.find(_=>_.get("type")==="line_pick");if(l&&this.lineCoordinatePickLayer){const _=l.get("id");if(this.lineCoordinatePickLayer.getLine(_)){this.selectedLinePickId=_,this.showMeasurementToolbarForFeature({x:i,y:n});return}}const h=o?.find(_=>_.get("type")==="polygon_pick");if(h&&this.polygonCoordinatePickLayer){const _=h.get("id");if(this.polygonCoordinatePickLayer.getPolygon(_)){this.selectedPolygonPickId=_,this.showMeasurementToolbarForFeature({x:i,y:n});return}}const c=o?.find(_=>_.get("id")?.startsWith("circle_"));if(c&&this.circleDrawLayer){const _=this.circleDrawLayer.getCircle(c.get("id"));if(_){this.selectedCircleId=_.id,this.showFloatingToolbarForCircle({x:i,y:n},_);return}}const d=o?.find(_=>_.get("id")?.startsWith("rectangle_"));if(d&&this.rectangleDrawLayer){const _=this.rectangleDrawLayer.getRectangle(d.get("id"));if(_){this.selectedRectangleId=_.id,this.showFloatingToolbarForRectangle({x:i,y:n},_);return}}const u=o?.find(_=>_.get("id")?.startsWith("triangle_"));if(u&&this.triangleDrawLayer){const _=this.triangleDrawLayer.getTriangle(u.get("id"));if(_){this.selectedTriangleId=_.id,this.showFloatingToolbarForTriangle({x:i,y:n},_);return}}const f=o?.find(_=>{const b=_.get("id");return b&&typeof b=="string"&&b.startsWith("freehand_")});if(f&&this.freehandDrawLayer){const _=this.freehandDrawLayer.getFreehand(f.get("id"));if(_){this.selectedFreehandId=_.id,this.showFloatingToolbarForFreehand({x:i,y:n},_);return}}const g=o?.find(_=>_.get("id")?.startsWith("line_"));if(g&&this.lineDrawLayer){const _=this.lineDrawLayer.getLine(g.get("id"));if(_){this.selectedLineId=_.id,this.showFloatingToolbarForLine({x:i,y:n},_);return}}const p=o?.find(_=>_.get("id")?.startsWith("bezier_"));if(p&&this.bezierDrawLayer){const _=this.bezierDrawLayer.getBezier(p.get("id"));if(_){this.selectedBezierId=_.id,this.showFloatingToolbarForBezier({x:i,y:n},_);return}}const m=o?.find(_=>_.get("id")?.startsWith("sector_"));if(m&&this.sectorDrawLayer){const _=this.sectorDrawLayer.getSector(m.get("id"));if(_){this.selectedSectorId=_.id,this.showFloatingToolbarForSector({x:i,y:n},_);return}}const y=o?.find(_=>_.get("id")?.startsWith("ellipse_"));if(y&&this.ellipseDrawLayer){const _=this.ellipseDrawLayer.getEllipse(y.get("id"));if(_){this.selectedEllipseId=_.id,this.showFloatingToolbarForEllipse({x:i,y:n},_);return}}const x=o?.find(_=>_.get("id")?.startsWith("marker_"));if(x&&this.markerDrawLayer){const _=this.markerDrawLayer.getMarker(x.get("id"));if(_){this.selectedMarkerId=_.id,this.showFloatingToolbarForMarker({x:i,y:n},_);return}}const E=o?.find(_=>_.get("id")?.startsWith("text_"));if(E&&this.textDrawLayer){const _=this.textDrawLayer.getText(E.get("id"));if(_){this.selectedTextId=_.id,this.textDrawTool?.editProperties(_.id);return}}const w=o?.find(_=>_.get("id")?.startsWith("image_"));if(w&&this.imageDrawLayer){const _=this.imageDrawLayer.getImage(w.get("id"));if(_){this.selectedImageId=_.id,this.imageDrawTool?.editProperties(_.id);return}}const C=o?.find(_=>_.get("id")?.startsWith("arrow_")&&!_.get("id")?.toString().endsWith("_head"));if(C&&this.arrowDrawLayer){const _=this.arrowDrawLayer.getArrow(C.get("id"));if(_){this.selectedArrowId=_.id,this.showFloatingToolbarForArrow({x:i,y:n},_);return}}const v=o?.find(_=>_.get("measurementId"));if(v){this.selectedMeasurementId=v.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.textDrawLayer?.isInputActive||this.imageDrawLayer?.isInputActive||(this.circleDrawLayer?.stopEdit(),this.rectangleDrawLayer?.stopEdit(),this.triangleDrawLayer?.stopEdit(),this.freehandDrawLayer?.stopEdit(),this.ellipseDrawLayer?.stopEdit(),this.markerDrawLayer?.stopEdit(),this.textDrawLayer?.stopEdit(),this.arrowDrawLayer?.stopEdit(),this.lineDrawLayer?.stopEdit(),this.bezierDrawLayer?.stopEdit(),this.sectorDrawLayer?.stopEdit(),this.imageDrawLayer?.stopEdit())}showFloatingToolbarForCircle(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[255,0,0,1],r=e.outlineWidth||3,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.circleDrawLayer?.updateCircleStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedCircleId=i},onStrokeWidthChange:a=>{r=a,this.circleDrawLayer?.updateCircleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedCircleId=i},onStrokeStyleChange:a=>{o=a,this.circleDrawLayer?.updateCircleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedCircleId=i},onDelete:()=>{this.circleDrawLayer?.removeCircle(i),this.selectedCircleId===i&&(this.selectedCircleId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedCircleId===i&&(this.selectedCircleId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForRectangle(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[0,0,255,1],r=e.outlineWidth||3,o="solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.rectangleDrawLayer?.updateRectangleStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedRectangleId=i},onStrokeWidthChange:a=>{r=a,this.rectangleDrawLayer?.updateRectangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedRectangleId=i},onStrokeStyleChange:a=>{o=a,this.rectangleDrawLayer?.updateRectangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedRectangleId=i},onDelete:()=>{this.rectangleDrawLayer?.removeRectangle(i),this.selectedRectangleId===i&&(this.selectedRectangleId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedRectangleId===i&&(this.selectedRectangleId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForFreehand(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[76,175,80,.3],r=e.outlineColor||[76,175,80,1],o=e.outlineWidth||3,a=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:l=>{n=[l[0],l[1],l[2],.3],r=[l[0],l[1],l[2],1],this.freehandDrawLayer?.updateFreehandStyle(i,n,r,o,a),this.selectedFreehandId=i},onStrokeWidthChange:l=>{o=l,this.freehandDrawLayer?.updateFreehandStyle(i,n,r,l,a),this.selectedFreehandId=i},onStrokeStyleChange:l=>{a=l,this.freehandDrawLayer?.updateFreehandStyle(i,n,r,o,l),this.selectedFreehandId=i},onDelete:()=>{this.freehandDrawLayer?.removeFreehand(i),this.selectedFreehandId===i&&(this.selectedFreehandId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedFreehandId===i&&(this.selectedFreehandId=null),this.hideFloatingToolbar()},onPositionChange:l=>{this.floatingToolbarPosition=l},theme:this.theme,t:this.t,containerRef:this.container,currentColor:r,currentStrokeWidth:o,currentStrokeStyle:a,position:t})}showFloatingToolbarForLine(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[255,193,7,1],r=e.width||3,o=e.style||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.lineDrawLayer?.updateLineStyle(i,a,r,o),this.selectedLineId=i},onStrokeWidthChange:a=>{r=a,this.lineDrawLayer?.updateLineStyle(i,n,a,o),this.selectedLineId=i},onStrokeStyleChange:a=>{o=a,this.lineDrawLayer?.updateLineStyle(i,n,r,a),this.selectedLineId=i},onDelete:()=>{this.lineDrawLayer?.removeLine(i),this.selectedLineId===i&&(this.selectedLineId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedLineId===i&&(this.selectedLineId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForBezier(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[156,39,176,1],r=e.width||3,o=e.style||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.bezierDrawLayer?.updateBezierStyle(i,a,r,o),this.selectedBezierId=i},onStrokeWidthChange:a=>{r=a,this.bezierDrawLayer?.updateBezierStyle(i,n,a,o),this.selectedBezierId=i},onStrokeStyleChange:a=>{o=a,this.bezierDrawLayer?.updateBezierStyle(i,n,r,a),this.selectedBezierId=i},onDelete:()=>{this.bezierDrawLayer?.removeBezier(i),this.selectedBezierId===i&&(this.selectedBezierId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedBezierId===i&&(this.selectedBezierId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForSector(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[33,150,243,.3],r=e.outlineWidth||2,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.sectorDrawLayer?.updateSectorStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedSectorId=i},onStrokeWidthChange:a=>{r=a,this.sectorDrawLayer?.updateSectorStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedSectorId=i},onStrokeStyleChange:a=>{o=a,this.sectorDrawLayer?.updateSectorStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedSectorId=i},onDelete:()=>{this.sectorDrawLayer?.removeSector(i),this.selectedSectorId===i&&(this.selectedSectorId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedSectorId===i&&(this.selectedSectorId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:[n[0],n[1],n[2],1],currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForEllipse(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[156,39,176,.3],r=e.outlineWidth||2,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.ellipseDrawLayer?.updateEllipseStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedEllipseId=i},onStrokeWidthChange:a=>{r=a,this.ellipseDrawLayer?.updateEllipseStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedEllipseId=i},onStrokeStyleChange:a=>{o=a,this.ellipseDrawLayer?.updateEllipseStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedEllipseId=i},onDelete:()=>{this.ellipseDrawLayer?.removeEllipse(i),this.selectedEllipseId===i&&(this.selectedEllipseId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedEllipseId===i&&(this.selectedEllipseId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:[n[0],n[1],n[2],1],currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showFloatingToolbarForMarker(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[255,87,34,1],r=e.size||10;this.floatingToolbar=new ke({onColorChange:o=>{n=o,this.markerDrawLayer?.updateMarkerStyle(i,o,r),this.selectedMarkerId=i},onStrokeWidthChange:o=>{r=o,this.markerDrawLayer?.updateMarkerStyle(i,n,o),this.selectedMarkerId=i},onStrokeStyleChange:()=>{},onDelete:()=>{this.markerDrawLayer?.removeMarker(i),this.selectedMarkerId===i&&(this.selectedMarkerId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedMarkerId===i&&(this.selectedMarkerId=null),this.hideFloatingToolbar()},onPositionChange:o=>{this.floatingToolbarPosition=o},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:"solid",position:t})}startDrawImage(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingImage()}showFloatingToolbarForArrow(t,e){this.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.color||[255,87,34,1],r=e.width||3,o=e.style||"solid";const a=e.headSize||50;this.floatingToolbar=new ke({onColorChange:l=>{n=l,this.arrowDrawLayer?.updateArrowStyle(i,l,r,o,a),this.selectedArrowId=i},onStrokeWidthChange:l=>{r=l,this.arrowDrawLayer?.updateArrowStyle(i,n,l,o,a),this.selectedArrowId=i},onStrokeStyleChange:l=>{o=l,this.arrowDrawLayer?.updateArrowStyle(i,n,r,l,a),this.selectedArrowId=i},onDelete:()=>{this.arrowDrawLayer?.removeArrow(i),this.selectedArrowId===i&&(this.selectedArrowId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedArrowId===i&&(this.selectedArrowId=null),this.hideFloatingToolbar()},onPositionChange:l=>{this.floatingToolbarPosition=l},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showGenericFloatingToolbar(t,e){this.floatingToolbar?(this.floatingToolbar.updatePosition(t),this.floatingToolbar.setVisible(!0)):this.floatingToolbar=new ke({onColorChange:i=>{this.currentColor=i,e.updateStyle(i,this.currentStrokeWidth,this.currentStrokeStyle)},onStrokeWidthChange:i=>{this.currentStrokeWidth=i,e.updateStyle(this.currentColor,i,this.currentStrokeStyle)},onStrokeStyleChange:i=>{this.currentStrokeStyle=i,e.updateStyle(this.currentColor,this.currentStrokeWidth,i)},onDelete:()=>{e.delete(),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.floatingToolbar&&(this.floatingToolbar.destroy(),this.floatingToolbar=null);const i=e.id;let n=e.fillColor||[255,255,0,1],r=e.outlineWidth||3,o=e.outlineStyle||"solid";this.floatingToolbar=new ke({onColorChange:a=>{n=a,this.triangleDrawLayer?.updateTriangleStyle(i,[a[0],a[1],a[2],.3],[a[0],a[1],a[2],1],r,o),this.selectedTriangleId=i},onStrokeWidthChange:a=>{r=a,this.triangleDrawLayer?.updateTriangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],a,o),this.selectedTriangleId=i},onStrokeStyleChange:a=>{o=a,this.triangleDrawLayer?.updateTriangleStyle(i,[n[0],n[1],n[2],.3],[n[0],n[1],n[2],1],r,a),this.selectedTriangleId=i},onDelete:()=>{this.triangleDrawLayer?.removeTriangle(i),this.selectedTriangleId===i&&(this.selectedTriangleId=null),this.hideFloatingToolbar()},onClose:()=>{this.selectedTriangleId===i&&(this.selectedTriangleId=null),this.hideFloatingToolbar()},onPositionChange:a=>{this.floatingToolbarPosition=a},theme:this.theme,t:this.t,containerRef:this.container,currentColor:n,currentStrokeWidth:r,currentStrokeStyle:o,position:t})}showMeasurementToolbarForFeature(t){this.measurementToolbarPosition=t,this.showMeasurementToolbar=!0,this.measurementFloatingToolbar&&(this.measurementFloatingToolbar.destroy(),this.measurementFloatingToolbar=null),this.measurementFloatingToolbar=new a_({onDelete:()=>{this.selectedMeasurementId?(this.deleteMeasurement(this.selectedMeasurementId),this.selectedMeasurementId=null):this.selectedPointPickId?(this.deleteMeasurement(this.selectedPointPickId),this.selectedPointPickId=null):this.selectedLinePickId?(this.deleteMeasurement(this.selectedLinePickId),this.selectedLinePickId=null):this.selectedPolygonPickId&&(this.deleteMeasurement(this.selectedPolygonPickId),this.selectedPolygonPickId=null),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.selectedFreehandId=null,this.selectedEllipseId=null,this.selectedMarkerId=null,this.selectedTextId=null,this.selectedArrowId=null,this.selectedLineId=null,this.selectedBezierId=null,this.selectedSectorId=null,this.selectedImageId=null,this.floatingToolbar&&this.floatingToolbar.setVisible(!1)}hideMeasurementToolbar(){this.showMeasurementToolbar=!1,this.selectedMeasurementId=null,this.selectedPointPickId=null,this.selectedLinePickId=null,this.selectedPolygonPickId=null,this.measurementFloatingToolbar&&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),this.uiManager.updateCurrentBasemap(t),setTimeout(()=>this.hideLoading(),500)}getBasemap(){return this.mapManager.getCurrentBasemap()}setTheme(t){this.theme=t,this.container.setAttribute("data-theme",t),this.uiManager.updateTheme(t),this.textDrawLayer?.setTheme(t,this.t)}getTheme(){return this.theme}setLocale(t){this.locale=t,this.t=Hi(t),this.uiManager.updateLocale(this.t)}getContainer(){return this.container}getLayerManager(){return this.layerManager}getMap(){return this.mapManager.getMap()}removeLayer(t){this.layerManager.removeLayer(t),this.uiManager.updateLayerList()}setLayerVisibility(t,e){this.layerManager.getLayer(t)?.setVisible(e),this.uiManager.updateLayerList()}startDrawFreehand(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingFreehand()}startDrawFreehandPolygon(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingFreehandPolygon()}startDrawEllipse(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingEllipse()}startDrawMarker(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingMarker()}startDrawText(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingText()}startDrawArrow(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingArrow()}startDrawLine(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingLine()}startDrawBezier(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingBezier()}startDrawSector(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingSector()}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 t.startsWith("LineCoordinatePick_")&&this.lineCoordinatePickLayer?.removeLine(t)?(this.currentLineCoordinates=this.currentLineCoordinates.filter(e=>e.id!==t),!0):t.startsWith("PolygonCoordinatePick_")&&this.polygonCoordinatePickLayer?.removePolygon(t)?(this.currentPolygonCoordinates=this.currentPolygonCoordinates.filter(e=>e.id!==t),!0):t.startsWith("coord_")&&this.pointCoordinatePickLayer?.removeCoordinate(t)?(this.currentPointCoordinates=this.currentPointCoordinates.filter(e=>e.id!==t),!0):!!(this.distanceMeasureLayer?.deleteMeasurement(t)||this.areaMeasureLayer?.deleteMeasurement(t))}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()))}getPointDataForPanel(){return(this.pointCoordinatePickLayer?.getAllCoordinates()||[]).map((e,i)=>({id:e.id,name:`${this.t.pointData} ${i+1}`,longitude:e.longitude,latitude:e.latitude,timestamp:e.timestamp}))}getLineDataForPanel(){return(this.lineCoordinatePickLayer?.getAllLines()||[]).map((e,i)=>({id:e.id,name:`${this.t.lineData} ${i+1}`,points:e.points,timestamp:e.timestamp}))}getPolygonDataForPanel(){return(this.polygonCoordinatePickLayer?.getAllPolygons()||[]).map((e,i)=>({id:e.id,name:`${this.t.polygonData} ${i+1}`,points:e.points,timestamp:e.timestamp}))}locateToPoint(t,e){this.setCenter([t,e]),this.setZoom(18),this.showToast(`${this.t.locatedToPoint}: ${t.toFixed(6)}, ${e.toFixed(6)}`)}locateToLine(t){if(t.length===0)return;const e=t.map(g=>g.longitude),i=t.map(g=>g.latitude),n=Math.min(...e),r=Math.max(...e),o=Math.min(...i),a=Math.max(...i),l=(n+r)/2,h=(o+a)/2;this.setCenter([l,h]);const c=r-n,d=a-o,u=Math.max(c,d);let f=18;u>.5?f=10:u>.1?f=12:u>.05?f=14:u>.01&&(f=16),this.setZoom(f),this.showToast(`${this.t.locatedToLine} ${t.length} ${this.t.points}`)}setBasemapByUrl(t){this.mapManager.setBasemapByUrl(t),this.uiManager.updateCurrentBasemap(null)}locateToPolygon(t){this.locateToLine(t),this.showToast(`${this.t.locatedToPolygon} ${t.length} ${this.t.points}`)}clearAllCoordinatePicks(){this.pointCoordinatePickLayer?.clearAllCoordinates(),this.lineCoordinatePickLayer?.clearAllLines(),this.polygonCoordinatePickLayer?.clearAllPolygons(),this.currentPointCoordinates=[],this.currentLineCoordinates=[],this.currentPolygonCoordinates=[],this.showToast(this.t.allCoordinatesCleared)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.eventManager.destroy(),this.uiManager.destroy(),this.drawingManager.destroy(),this.floatingToolbar?.destroy(),this.measurementFloatingToolbar?.destroy(),this.drawingStatusDiv?.remove(),this.measureStatusDiv?.remove(),this.freehandDrawTool?.destroy(),this.ellipseDrawTool?.destroy(),this.markerDrawTool?.destroy(),this.textDrawTool?.destroy(),this.arrowDrawTool?.destroy(),this.layerManager.clearAll(),this.mapManager.destroy(),this.isOwnContainer&&this.container.parentNode&&this.container.remove())}};cs.globalStylesInjected=!1;let wa=cs;exports.AreaMeasurementLayer=kd;exports.BarChartLayer=Id;exports.BaseLayer=It;exports.BasemapTypeEnum=dt;exports.CircleDrawLayer=Ld;exports.CircleLayer=es;exports.ClusterLayer=bd;exports.CoordinateSystemTypeEnum=Oe;exports.DistanceMeasurementLayer=Dd;exports.EarthView=wa;exports.GeoJSONLayer=Pd;exports.HeatmapLayer=pr;exports.LayerManager=Gh;exports.LayerTypeEnum=Z;exports.MarkerLayer=is;exports.MarkerLayerAnimationTypeEnum=_n;exports.MarkerLayerPointTypeEnum=H;exports.PolygonLayer=Qn;exports.PolylineLayer=ts;exports.bd09ToWgs84=Hd;exports.fromWGS84=O_;exports.gcj02ToWgs84=Sl;exports.getTranslation=Hi;exports.isInChina=z_;exports.toWGS84=_a;
|