UNPKG

geostyler-openlayers-parser

Version:

GeoStyler Style Parser implementation for OpenLayers styles

1 lines 146 kB
var GeoStylerOpenlayersParser=(function(mt){"use strict";function Me(s){return!/^(-?\d|--)/.test(s)}function Pe(s){const t=[];let e="",i="",n=7;for(let l,r=0;l=s.charAt(r);r++)if(/[a-zA-Z\d\xa0-\uffff_-]/.test(l)&&n===7)e+=l;else if(l==="\\"&&n===7)n=6;else if(l===" "&&n===7){if(e!==""){if(!Me(e))return null;t.push(e),e=""}}else if(n===6)/[0-9a-f]/i.test(l)?(i+=l,n=8):(e+=l,n=7);else{if(n!==8)return null;/[0-9a-f]/i.test(l)&&i.length<6?i+=l:(e+=String.fromCodePoint(parseInt(i,16)),e+=l,i="",n=7)}if(e!==""){if(!Me(e))return null;t.push(e)}return t.join(" ")}function Ui(s,t){let e=t,i="";const n={"font-family":[]};for(let l,r=0;l=s.charAt(r);r+=1)if(e!==4||l!=='"'&&l!=="'")if(e===3&&l===",")e=4,i="";else if(e===4&&l===","){const o=Pe(i);o&&n["font-family"].push(o),i=""}else if(e===5&&l===" ")/^(?:\+|-)?(?:[0-9]*\.)?[0-9]+(?:deg|grad|rad|turn)$/.test(i)?(n["font-style"]+=" "+i,i=""):r-=1,e=1;else if(e!==1||l!==" "&&l!=="/")e===2&&l===" "?(/^(?:\+|-)?([0-9]*\.)?[0-9]+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc|%)?$/.test(i)&&(n["line-height"]=i),e=4,i=""):i+=l;else{if(/^(?:(?:xx|x)-large|(?:xx|s)-small|small|large|medium)$/.test(i)||/^(?:larg|small)er$/.test(i)||/^(?:\+|-)?(?:[0-9]*\.)?[0-9]+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc|%)$/.test(i))e=l==="/"?2:4,n["font-size"]=i;else if(/^italic$/.test(i))n["font-style"]=i;else if(/^oblique$/.test(i))n["font-style"]=i,e=5;else if(/^small-caps$/.test(i))n["font-variant"]=i;else if(/^(?:bold(?:er)?|lighter|normal)$/.test(i))n["font-weight"]=i;else if(/^[+-]?(?:[0-9]*\.)?[0-9]+(?:e[+-]?(?:0|[1-9][0-9]*))?$/.test(i)){const o=parseFloat(i);o>=1&&o<=1e3&&(n["font-weight"]=i)}else/^(?:(?:ultra|extra|semi)-)?(?:condensed|expanded)$/.test(i)&&(n["font-stretch"]=i);i=""}else{let o=r+1;do if(o=s.indexOf(l,o)+1,!o)return null;while(s.charAt(o-2)==="\\");n["font-family"].push(s.slice(r+1,o-1).replace(/\\('|")/g,"$1")),r=o-1,e=3,i=""}if(e===3&&!/^\s*$/.test(i))return null;if(e===4){const l=Pe(i);l&&n["font-family"].push(l)}return n}function Ji(s){const t=Ui(s,1);return t!==null&&t["font-size"]&&t["font-family"].length?t:null}function Zi(s){return s!=null&&typeof s.valueOf()=="string"}const Te=s=>s?.kind==="Icon",Qi=s=>s?.kind==="Mark"&&Zi(s?.wellKnownName),qt=s=>["abs","acos","add","asin","atan","atan2","ceil","cos","div","exp","floor","interpolate","log","max","min","modulo","mul","pi","pow","random","rint","round","sin","sqrt","strIndexOf","strLastIndexOf","strLength","sub","tan","toDegrees","toNumber","toRadians"].includes(s?.name),ot=s=>["numberFormat","strAbbreviate","strCapitalize","strConcat","strDefaultIfBlank","strReplace","strStripAccents","strSubstring","strSubstringStart","strToLowerCase","strToString","strToUpperCase","strTrim"].includes(s?.name),wt=s=>["all","any","between","double2bool","equalTo","greaterThan","greaterThanOrEqualTo","in","lessThan","lessThanOrEqualTo","not","notEqualTo","parseBoolean","strEndsWith","strEqualsIgnoreCase","strMatches","strStartsWith"].includes(s?.name),De=s=>["case","property","step"].includes(s?.name),b=s=>wt(s)||qt(s)||ot(s)||De(s),Bt=s=>typeof s?.source=="string"||b(s?.source)&&Array.isArray(s.position)&&Array.isArray(s.size);var S={IDLE:0,LOADING:1,LOADED:2,ERROR:3},I={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Z(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 Ne(s,t,e){return s[0]<=t&&t<=s[2]&&s[1]<=e&&e<=s[3]}function We(s,t){const e=s[0],i=s[1],n=s[2],l=s[3],r=t[0],o=t[1];let a=I.UNKNOWN;return r<e?a=a|I.LEFT:r>n&&(a=a|I.RIGHT),o<i?a=a|I.BELOW:o>l&&(a=a|I.ABOVE),a===I.UNKNOWN&&(a=I.INTERSECTING),a}function $t(){return[1/0,1/0,-1/0,-1/0]}function Ge(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 ze(s){return Ge(1/0,1/0,-1/0,-1/0,s)}function tn(s,t){const e=s[0],i=s[1];return Ge(e,i,e,i,t)}function Xe(s,t,e,i,n){const l=ze(n);return Ye(l,s,t,e,i)}function Ye(s,t,e,i,n){for(;e<i;e+=n)en(s,t[e],t[e+1]);return s}function en(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 nn(s,t){let e;return e=t(sn(s)),e||(e=t(ln(s)),e)||(e=t(on(s)),e)||(e=t(rn(s)),e)?e:!1}function sn(s){return[s[0],s[1]]}function ln(s){return[s[2],s[1]]}function qe(s){return[(s[0]+s[2])/2,(s[1]+s[3])/2]}function Be(s){return s[3]-s[1]}function rn(s){return[s[0],s[3]]}function on(s){return[s[2],s[3]]}function Q(s,t){return s[0]<=t[2]&&s[2]>=t[0]&&s[1]<=t[3]&&s[3]>=t[1]}function an(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s}function hn(s,t,e){let i=!1;const n=We(s,t),l=We(s,e);if(n===I.INTERSECTING||l===I.INTERSECTING)i=!0;else{const r=s[0],o=s[1],a=s[2],h=s[3],c=t[0],f=t[1],g=e[0],u=e[1],y=(u-f)/(g-c);let d,p;l&I.ABOVE&&!(n&I.ABOVE)&&(d=g-(u-h)/y,i=d>=r&&d<=a),!i&&l&I.RIGHT&&!(n&I.RIGHT)&&(p=u-(g-a)*y,i=p>=o&&p<=h),!i&&l&I.BELOW&&!(n&I.BELOW)&&(d=g-(u-o)/y,i=d>=r&&d<=a),!i&&l&I.LEFT&&!(n&I.LEFT)&&(p=u-(g-r)*y,i=p>=o&&p<=h)}return i}function xt(s,t,e){return Math.min(Math.max(s,t),e)}function cn(s,t,e,i,n,l){const r=n-e,o=l-i;if(r!==0||o!==0){const a=((s-e)*r+(t-i)*o)/(r*r+o*o);a>1?(e=n,i=l):a>0&&(e+=r*a,i+=o*a)}return Y(s,t,e,i)}function Y(s,t,e,i){const n=e-s,l=i-t;return n*n+l*l}function $e(s){return s*180/Math.PI}function kt(s){return s*Math.PI/180}function Vt(s,t,e){return s+e*(t-s)}function Ve(s,t){const e=Math.pow(10,t);return Math.round(s*e)/e}function jt(s,t,e){if(s>=t&&s<e)return s;const i=e-t;return((s-t)%i+i)%i+t}function C(){throw new Error("Unimplemented abstract method.")}let fn=0;function Ht(s){return s.ol_uid||(s.ol_uid=String(++fn))}var gn={PROPERTYCHANGE:"propertychange"},q={CHANGE:"change"};class un{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function dn(s,t,e){let i,n;e=e||je;let l=0,r=s.length,o=!1;for(;l<r;)i=l+(r-l>>1),n=+e(s[i],t),n<0?l=i+1:(r=i,o=!n);return o?l:~l}function je(s,t){return s>t?1:s<t?-1:0}function G(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 He(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 Ke(){}function yn(s){let t,e,i;return function(){const n=Array.prototype.slice.call(arguments);return(!e||this!==i||!He(n,e))&&(i=this,e=n,t=s.apply(this,arguments)),t}}function Ue(s){for(const t in s)delete s[t]}function pn(s){let t;for(t in s)return!1;return!t}class Je{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Ze extends un{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 l=e?new Je(t):t;l.target||(l.target=this.eventTarget_||this);const r=this.dispatching_||(this.dispatching_={}),o=this.pendingRemovals_||(this.pendingRemovals_={});i in r||(r[i]=0,o[i]=0),++r[i];let a;for(let h=0,c=n.length;h<c;++h)if("handleEvent"in n[h]?a=n[h].handleEvent(l):a=n[h].call(this,l),a===!1||l.propagationStopped){a=!1;break}if(--r[i]===0){let h=o[i];for(delete o[i];h--;)this.removeEventListener(i,Ke);delete r[i]}return a}disposeInternal(){this.listeners_&&Ue(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]=Ke,++this.pendingRemovals_[t]):(i.splice(n,1),i.length===0&&delete this.listeners_[t]))}}function St(s,t,e,i,n){if(n){const r=e;e=function(o){return s.removeEventListener(t,e),r.call(i??this,o)}}else i&&i!==s&&(e=e.bind(i));const l={target:s,type:t,listener:e};return s.addEventListener(t,e),l}function Qe(s,t,e,i){return St(s,t,e,i,!0)}function Kt(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),Ue(s))}class bt extends Ze{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(q.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let l=0;l<i;++l)n[l]=St(this,t[l],e);return n}return St(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const n=t.length;i=new Array(n);for(let l=0;l<n;++l)i[l]=Qe(this,t[l],e)}else i=Qe(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)_n(i);else if(Array.isArray(t))for(let n=0,l=t.length;n<l;++n)this.removeEventListener(t[n],e);else this.removeEventListener(t,e)}}bt.prototype.on,bt.prototype.once,bt.prototype.un;function _n(s){if(Array.isArray(s))for(let t=0,e=s.length;t<e;++t)Kt(s[t]);else Kt(s)}class ti extends Je{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class Ut extends bt{constructor(t){super(),this.on,this.once,this.un,Ht(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 ti(i,t,e)),i=gn.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ti(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 l=n[t];n[t]=e,l!==e&&this.notify(t,l)}}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],pn(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}const ei={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Jt{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_||ei[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 at=6378137,tt=Math.PI*at,mn=[-tt,-tt,tt,tt],wn=[-180,-85,180,85],Ct=at*Math.log(Math.tan(Math.PI/2));class et extends Jt{constructor(t){super({code:t,units:"m",extent:mn,global:!0,worldExtent:wn,getPointResolution:function(e,i){return e/Math.cosh(i[1]/at)}})}}const ii=[new et("EPSG:3857"),new et("EPSG:102100"),new et("EPSG:102113"),new et("EPSG:900913"),new et("http://www.opengis.net/def/crs/EPSG/0/3857"),new et("http://www.opengis.net/gml/srs/epsg.xml#3857")];function xn(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 l=0;l<n;l+=i){t[l]=tt*s[l]/180;let r=at*Math.log(Math.tan(Math.PI*(+s[l+1]+90)/360));r>Ct?r=Ct:r<-Ct&&(r=-Ct),t[l+1]=r}return t}function kn(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 l=0;l<n;l+=i)t[l]=180*s[l]/tt,t[l+1]=360*Math.atan(Math.exp(s[l+1]/at))/Math.PI-90;return t}const Sn=6378137,ni=[-180,-90,180,90],bn=Math.PI*Sn/180;class B extends Jt{constructor(t,e){super({code:t,units:"degrees",extent:ni,axisOrientation:e,global:!0,metersPerUnit:bn,worldExtent:ni})}}const si=[new B("CRS:84"),new B("EPSG:4326","neu"),new B("urn:ogc:def:crs:OGC:1.3:CRS84"),new B("urn:ogc:def:crs:OGC:2:84"),new B("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new B("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new B("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Zt={};function Cn(s){return Zt[s]||Zt[s.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function vn(s,t){Zt[s]=t}let it={};function ht(s,t,e){const i=s.getCode(),n=t.getCode();i in it||(it[i]={}),it[i][n]=e}function Qt(s,t){return s in it&&t in it[s]?it[s][t]:null}const vt=.9996,P=.00669438,Ft=P*P,Ot=Ft*P,$=P/(1-P),li=Math.sqrt(1-P),nt=(1-li)/(1+li),ri=nt*nt,te=ri*nt,ee=te*nt,oi=ee*nt,ai=1-P/4-3*Ft/64-5*Ot/256,Fn=3*P/8+3*Ft/32+45*Ot/1024,On=15*Ft/256+45*Ot/1024,Ln=35*Ot/3072,In=3/2*nt-27/32*te+269/512*oi,Rn=21/16*ri-55/32*ee,An=151/96*te-417/128*oi,En=1097/512*ee,Lt=6378137;function Mn(s,t,e){const i=s-5e5,r=(e.north?t:t-1e7)/vt/(Lt*ai),o=r+In*Math.sin(2*r)+Rn*Math.sin(4*r)+An*Math.sin(6*r)+En*Math.sin(8*r),a=Math.sin(o),h=a*a,c=Math.cos(o),f=a/c,g=f*f,u=g*g,y=1-P*h,d=Math.sqrt(1-P*h),p=Lt/d,m=(1-P)/y,w=$*c**2,k=w*w,x=i/(p*vt),F=x*x,D=F*x,J=D*x,E=J*x,L=E*x,R=o-f/m*(F/2-J/24*(5+3*g+10*w-4*k-9*$))+L/720*(61+90*g+298*w+45*u-252*$-3*k);let O=(x-D/6*(1+2*g+w)+E/120*(5-2*w+28*g-3*k+8*$+24*u))/c;return O=jt(O+kt(fi(e.number)),-Math.PI,Math.PI),[$e(O),$e(R)]}const hi=-80,ci=84,Pn=-180,Tn=180;function Dn(s,t,e){s=jt(s,Pn,Tn),t<hi?t=hi:t>ci&&(t=ci);const i=kt(t),n=Math.sin(i),l=Math.cos(i),r=n/l,o=r*r,a=o*o,h=kt(s),c=fi(e.number),f=kt(c),g=Lt/Math.sqrt(1-P*n**2),u=$*l**2,y=l*jt(h-f,-Math.PI,Math.PI),d=y*y,p=d*y,m=p*y,w=m*y,k=w*y,x=Lt*(ai*i-Fn*Math.sin(2*i)+On*Math.sin(4*i)-Ln*Math.sin(6*i)),F=vt*g*(y+p/6*(1-o+u)+w/120*(5-18*o+a+72*u-58*$))+5e5;let D=vt*(x+g*r*(d/2+m/24*(5-o+9*u+4*u**2)+k/720*(61-58*o+a+600*u-330*$)));return e.north||(D+=1e7),[F,D]}function fi(s){return(s-1)*6-180+3}const Nn=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function gi(s){let t=0;for(const n of Nn){const l=s.match(n);if(l){t=parseInt(l[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 ui(s,t){return function(e,i,n,l){const r=e.length;n=n>1?n:2,l=l??n,i||(n>2?i=e.slice():i=new Array(r));for(let o=0;o<r;o+=l){const a=e[o],h=e[o+1],c=s(a,h,t);i[o]=c[0],i[o+1]=c[1]}return i}}function Wn(s){return gi(s)?new Jt({code:s,units:"m"}):null}function Gn(s){const t=gi(s.getCode());return t?{forward:ui(Dn,t),inverse:ui(Mn,t)}:null}const zn=[Gn],Xn=[Wn];function di(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 ie(s){vn(s.getCode(),s),ht(s,s,di)}function Yn(s){s.forEach(ie)}function ne(s){if(typeof s!="string")return s;const t=Cn(s);if(t)return t;for(const e of Xn){const i=e(s);if(i)return i}return null}function yi(s){Yn(s),s.forEach(function(t){s.forEach(function(e){t!==e&&ht(t,e,di)})})}function qn(s,t,e,i){s.forEach(function(n){t.forEach(function(l){ht(n,l,e),ht(l,n,i)})})}function Bn(s,t){const e=s.getCode(),i=t.getCode();let n=Qt(e,i);if(n)return n;let l=null,r=null;for(const a of zn)l||(l=a(s)),r||(r=a(t));if(!l&&!r)return null;const o="EPSG:4326";if(r)if(l)n=se(l.inverse,r.forward);else{const a=Qt(e,o);a&&(n=se(a,r.forward))}else{const a=Qt(o,i);a&&(n=se(l.inverse,a))}return n&&(ie(s),ie(t),ht(s,t,n)),n}function se(s,t){return function(e,i,n,l){return i=s(e,i,n,l),t(i,i,n,l)}}function pi(s,t){const e=ne(s),i=ne(t);return Bn(e,i)}function $n(){yi(ii),yi(si),qn(si,ii,xn,kn)}$n();function It(s,t){if(!s)throw new Error(t)}const Vn=new Array(6);function le(){return[1,0,0,1,0,0]}function jn(s,t){const e=s[0],i=s[1],n=s[2],l=s[3],r=s[4],o=s[5],a=t[0],h=t[1],c=t[2],f=t[3],g=t[4],u=t[5];return s[0]=e*a+n*h,s[1]=i*a+l*h,s[2]=e*c+n*f,s[3]=i*c+l*f,s[4]=e*g+n*u+r,s[5]=i*g+l*u+o,s}function Hn(s,t,e,i,n,l,r){return s[0]=t,s[1]=e,s[2]=i,s[3]=n,s[4]=l,s[5]=r,s}function Kn(s,t,e){return jn(s,Hn(Vn,t,0,0,e,0,0))}function _i(s,t,e,i,n,l,r,o){const a=Math.sin(l),h=Math.cos(l);return s[0]=i*h,s[1]=n*a,s[2]=-i*a,s[3]=n*h,s[4]=r*i*h-o*i*a+t,s[5]=r*n*a+o*n*h+e,s}function ct(s,t,e,i,n,l,r){l=l||[],r=r||2;let o=0;for(let a=t;a<e;a+=i){const h=s[a],c=s[a+1];l[o++]=n[0]*h+n[2]*c+n[4],l[o++]=n[1]*h+n[3]*c+n[5];for(let f=2;f<r;f++)l[o++]=s[a+f]}return l&&l.length!=o&&(l.length=o),l}function Un(s,t,e,i,n,l,r){r=r||[];const o=Math.cos(n),a=Math.sin(n),h=l[0],c=l[1];let f=0;for(let g=t;g<e;g+=i){const u=s[g]-h,y=s[g+1]-c;r[f++]=h+u*o-y*a,r[f++]=c+u*a+y*o;for(let d=g+2;d<g+i;++d)r[f++]=s[d]}return r&&r.length!=f&&(r.length=f),r}function Jn(s,t,e,i,n,l,r,o){o=o||[];const a=r[0],h=r[1];let c=0;for(let f=t;f<e;f+=i){const g=s[f]-a,u=s[f+1]-h;o[c++]=a+n*g,o[c++]=h+l*u;for(let y=f+2;y<f+i;++y)o[c++]=s[y]}return o&&o.length!=c&&(o.length=c),o}function Zn(s,t,e,i,n,l,r){r=r||[];let o=0;for(let a=t;a<e;a+=i){r[o++]=s[a]+n,r[o++]=s[a+1]+l;for(let h=a+2;h<a+i;++h)r[o++]=s[h]}return r&&r.length!=o&&(r.length=o),r}const mi=le(),Qn=[NaN,NaN];class ts extends Ut{constructor(){super(),this.extent_=$t(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=yn((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 C()}closestPointXY(t,e,i,n){return C()}containsXY(t,e){return this.closestPointXY(t,e,Qn,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 C()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&ze(e),this.extentRevision_=this.getRevision()}return an(this.extent_,t)}rotate(t,e){C()}scale(t,e,i){C()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return C()}getType(){return C()}applyTransform(t){C()}intersectsExtent(t){return C()}translate(t,e){C()}transform(t,e){const i=ne(t),n=i.getUnits()=="tile-pixels"?function(l,r,o){const a=i.getExtent(),h=i.getWorldExtent(),c=Be(h)/Be(a);_i(mi,h[0],h[3],c,-c,0,0,0);const f=ct(l,0,l.length,o,mi,r),g=pi(i,e);return g?g(f,f,o):f}:pi(i,e);return this.applyTransform(n),this}}class V extends ts{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Xe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return C()}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=wi(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){C()}setLayout(t,e,i){let n;if(t)n=wi(t);else{for(let l=0;l<i;++l){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}n=e.length,t=es(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();Un(i,0,i.length,n,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=qe(this.getExtent()));const n=this.getFlatCoordinates();if(n){const l=this.getStride();Jn(n,0,n.length,l,t,e,i,n),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();Zn(i,0,i.length,n,t,e,i),this.changed()}}}function es(s){let t;return s==2?t="XY":s==3?t="XYZ":s==4&&(t="XYZM"),t}function wi(s){let t;return s=="XY"?t=2:s=="XYZ"||s=="XYM"?t=3:s=="XYZM"&&(t=4),t}function is(s,t,e){const i=s.getFlatCoordinates();if(!i)return null;const n=s.getStride();return ct(i,0,i.length,n,t,e)}function ns(s,t,e,i){for(let n=0,l=e.length;n<l;++n)s[t++]=e[n];return t}function Rt(s,t,e,i){for(let n=0,l=e.length;n<l;++n){const r=e[n];for(let o=0;o<i;++o)s[t++]=r[o]}return t}function re(s,t,e,i,n){n=n||[];let l=0;for(let r=0,o=e.length;r<o;++r){const a=Rt(s,t,e[r],i);n[l++]=a,t=a}return n.length=l,n}function ss(s,t,e,i,n){n=n||[];let l=0;for(let r=0,o=e.length;r<o;++r){const a=re(s,t,e[r],i,n[l]);a.length===0&&(a[0]=t),n[l++]=a,t=a[a.length-1]}return n.length=l,n}class j extends V{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new j(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const l=this.flatCoordinates,r=Y(t,e,l[0],l[1]);if(r<n){const o=this.stride;for(let a=0;a<o;++a)i[a]=l[a];return i.length=o,r}return n}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return tn(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Ne(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ns(this.flatCoordinates,0,t,this.stride),this.changed()}}const H=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"";H.includes("safari")&&!H.includes("chrom")&&(H.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(H)),H.includes("webkit")&&H.includes("edge"),H.includes("macintosh");const ls=typeof devicePixelRatio<"u"?devicePixelRatio:1,rs=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,os=typeof Image<"u"&&Image.prototype.decode;(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 z(s,t,e,i){let n;return rs?n=new OffscreenCanvas(s||300,t||300):n=document.createElement("canvas"),s&&(n.width=s),t&&(n.height=t),n.getContext("2d",i)}let oe;function xi(){return oe||(oe=z(1,1)),oe}const as=[NaN,NaN,NaN,0];let ae;function hs(){return ae||(ae=z(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),ae}const cs=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,fs=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,gs=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,us=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function At(s,t){return s.endsWith("%")?Number(s.substring(0,s.length-1))/t:Number(s)}function ft(s){throw new Error('failed to parse "'+s+'" as color')}function ki(s){if(s.toLowerCase().startsWith("rgb")){const l=s.match(fs)||s.match(cs)||s.match(gs);if(l){const r=l[4],o=100/255;return[xt(At(l[1],o)+.5|0,0,255),xt(At(l[2],o)+.5|0,0,255),xt(At(l[3],o)+.5|0,0,255),r!==void 0?xt(At(r,100),0,1):1]}ft(s)}if(s.startsWith("#")){if(us.test(s)){const l=s.substring(1),r=l.length<=4?1:2,o=[0,0,0,255];for(let a=0,h=l.length;a<h;a+=r){let c=parseInt(l.substring(a,a+r),16);r===1&&(c+=c<<4),o[a/r]=c}return o[3]=o[3]/255,o}ft(s)}const t=hs();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&&ft(s));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return ki(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]=Ve(n[3]/255,3),n}function ds(s){return typeof s=="string"?s:Si(s)}const ys=1024,gt={};let he=0;function ps(s){if(s==="none")return as;if(gt.hasOwnProperty(s))return gt[s];if(he>=ys){let e=0;for(const i in gt)(e++&3)===0&&(delete gt[i],--he)}const t=ki(s);t.length!==4&&ft(s);for(const e of t)isNaN(e)&&ft(s);return gt[s]=t,++he,t}function Et(s){return Array.isArray(s)?s:ps(s)}function Si(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 _s(s,t){return new Promise((e,i)=>{function n(){r(),e(s)}function l(){r(),i(new Error("Image load error"))}function r(){s.removeEventListener("load",n),s.removeEventListener("error",l)}s.addEventListener("load",n),s.addEventListener("error",l)})}function ms(s,t){return t&&(s.src=t),s.src&&os?new Promise((e,i)=>s.decode().then(()=>e(s)).catch(n=>s.complete&&s.width?e(s):i(n))):_s(s)}class ws{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const n=ce(t,e,i);return n in this.cache_?this.cache_[n]:null}getPattern(t,e,i){const n=ce(t,e,i);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,i,n,l){const r=ce(t,e,i),o=r in this.cache_;this.cache_[r]=n,l&&(n.getImageState()===S.IDLE&&n.load(),n.getImageState()===S.LOADING?n.ready().then(()=>{this.patternCache_[r]=xi().createPattern(n.getImage(1),"repeat")}):this.patternCache_[r]=xi().createPattern(n.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function ce(s,t,e){const i=e?Et(e):"null";return t+":"+s+":"+i}const W=new ws;let ut=null;class bi extends Ze{constructor(t,e,i,n,l){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=l,this.imageState_=n===void 0?S.IDLE:n,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===S.LOADED){ut||(ut=z(1,1,void 0,{willReadFrequently:!0})),ut.drawImage(this.image_,0,0);try{ut.getImageData(0,0,1,1),this.tainted_=!1}catch{ut=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(q.CHANGE)}handleImageError_(){this.imageState_=S.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=S.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=z(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_===S.IDLE){this.image_||this.initializeImage_(),this.imageState_=S.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&ms(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_!==S.LOADED)return;const e=this.image_,i=z(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=ds(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_===S.LOADED||this.imageState_===S.ERROR)t();else{const e=()=>{(this.imageState_===S.LOADED||this.imageState_===S.ERROR)&&(this.removeEventListener(q.CHANGE,e),t())};this.addEventListener(q.CHANGE,e)}})),this.ready_}}function fe(s,t,e,i,n,l){let r=t===void 0?void 0:W.get(t,e,n);return r||(r=new bi(s,s&&"src"in s?s.src||void 0:t,e,i,n),W.set(t,e,n,r,l)),l&&r&&!W.getPattern(t,e,n)&&W.set(t,e,n,r,l),r}function st(s){return s?Array.isArray(s)?Si(s):typeof s=="object"&&"src"in s?xs(s):s:null}function xs(s){if(!s.offset||!s.size)return W.getPattern(s.src,"anonymous",s.color);const t=s.src+":"+s.offset,e=W.getPattern(t,void 0,s.color);if(e)return e;const i=W.get(s.src,"anonymous",null);if(i.getImageState()!==S.LOADED)return null;const n=z(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]),fe(n.canvas,t,void 0,S.LOADED,s.color,!0),W.getPattern(t,void 0,s.color)}const ks="10px sans-serif",Mt="#000",Pt="round",Ci=[],vi=0,Tt="round",ge=10,ue="#000",Fi="center",Ss="middle",de=1;new Ut;function Dt(s,t){return Array.isArray(s)?s:(t===void 0?t=[s,s]:(t[0]=s,t[1]=s),t)}class dt{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Dt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new dt({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 C()}getImage(t){return C()}getHitDetectionImage(){return C()}getPixelRatio(t){return 1}getImageState(){return C()}getImageSize(){return C()}getOrigin(){return C()}getSize(){return C()}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_=Dt(t)}listenImageChange(t){C()}load(){C()}unlistenImageChange(t){C()}ready(){return Promise.resolve()}}class Nt extends dt{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()?S.LOADING:S.LOADED,this.imageState_===S.LOADING&&this.ready().then(()=>this.imageState_=S.LOADED),this.render()}clone(){const t=this.getScale(),e=new Nt({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=W.get(i,null,null)?.getImage(1);if(!n){const l=this.renderOptions_,r=Math.ceil(l.size*t),o=z(r,r);this.draw_(l,o,t),n=o.canvas,W.set(i,null,null,new bi(n,void 0,null,S.LOADED,null))}return n}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let n=this.radius,l=this.radius2_===void 0?n:this.radius2_;if(n<l){const D=n;n=l,l=D}const r=this.radius2_===void 0?this.points_:this.points_*2,o=2*Math.PI/r,a=l*Math.sin(o),h=Math.sqrt(l*l-a*a),c=n-h,f=Math.sqrt(a*a+c*c),g=f/a;if(t==="miter"&&g<=i)return g*e;const u=e/2/g,y=e/2*(c/f),p=Math.sqrt((n+u)*(n+u)+y*y)-n;if(this.radius2_===void 0||t==="bevel")return p*2;const m=n*Math.sin(o),w=Math.sqrt(n*n-m*m),k=l-w,F=Math.sqrt(m*m+k*k)/m;if(F<=i){const D=F*e/2-l-n;return 2*Math.max(p,D)}return p*2}createRenderOptions(){let t=Pt,e=Tt,i=0,n=null,l=0,r,o=0;this.stroke_&&(r=st(this.stroke_.getColor()??ue),o=this.stroke_.getWidth()??de,n=this.stroke_.getLineDash(),l=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??Tt,t=this.stroke_.getLineCap()??Pt,i=this.stroke_.getMiterLimit()??ge);const a=this.calculateLineJoinSize_(e,o,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+a);return{strokeStyle:r,strokeWidth:o,size:c,lineCap:t,lineDash:n,lineDashOffset:l,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=Mt),e.fillStyle=st(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=Et(i)),i===null?n=1:Array.isArray(i)&&(n=i.length===4?i[3]:1),n===0&&(e=z(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 l=this.angle_-Math.PI/2,r=2*Math.PI/e;for(let o=0;o<e;o++){const a=l+o*r,h=o%2===0?i:n;t.lineTo(h*Math.cos(a),h*Math.sin(a))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Mt,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 ye extends Nt{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 ye({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}setRadius(t){this.radius=t,this.render()}}class yt{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 yt({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=fe(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===S.IDLE&&e.load(),e.getImageState()===S.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?Ht(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:Et(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class pe{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new pe({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}class Wt{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Oi,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 Wt({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_=Oi,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function Oi(s){return s.getGeometry()}const bs="#333";class _e{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_=Dt(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 yt({color:bs}),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 _e({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()?this.getFill().clone():void 0,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_=Dt(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 Li(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 me extends dt{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,l=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:n,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:l,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const r=t.img!==void 0?t.img:null;let o=t.src;It(!(o!==void 0&&r),"`image` and `src` cannot be provided at the same time"),(o===void 0||o.length===0)&&r&&(o=r.src||Ht(r)),It(o!==void 0&&o.length>0,"A defined and non-empty `src` or `image` must be provided"),It(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let a;if(t.src!==void 0?a=S.IDLE:r!==void 0&&("complete"in r?r.complete?a=r.src?S.LOADED:S.IDLE:a=S.LOADING:a=S.LOADED),this.color_=t.color!==void 0?Et(t.color):null,this.iconImage_=fe(r,o,this.crossOrigin_,a,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 f=this.getImage(1);if(f.width&&f.height)h=f.width,c=f.height;else if(f instanceof HTMLImageElement){this.initialOptions_=t;const g=()=>{if(this.unlistenImageChange(g),!this.initialOptions_)return;const u=this.iconImage_.getSize();this.setScale(Li(u[0],u[1],t.width,t.height))};this.listenImageChange(g);return}}h!==void 0&&this.setScale(Li(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 me({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const n=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!n)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=n[0]),this.anchorYUnits_=="fraction"&&(t[1]*=n[1])}if(this.anchorOrigin_!="top-left"){if(!n)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+n[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+n[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}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()==S.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()==S.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(q.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(q.CHANGE,t)}ready(){return this.iconImage_.ready()}}function Ii(s,t,e,i,n,l,r){const o=s[t],a=s[t+1],h=s[e]-o,c=s[e+1]-a;let f;if(h===0&&c===0)f=t;else{const g=((n-o)*h+(l-a)*c)/(h*h+c*c);if(g>1)f=e;else if(g>0){for(let u=0;u<i;++u)r[u]=Vt(s[t+u],s[e+u],g);r.length=i;return}else f=t}for(let g=0;g<i;++g)r[g]=s[f+g];r.length=i}function we(s,t,e,i,n){let l=s[t],r=s[t+1];for(t+=i;t<e;t+=i){const o=s[t],a=s[t+1],h=Y(l,r,o,a);h>n&&(n=h),l=o,r=a}return n}function xe(s,t,e,i,n){for(let l=0,r=e.length;l<r;++l){const o=e[l];n=we(s,t,o,i,n),t=o}return n}function Cs(s,t,e,i,n){for(let l=0,r=e.length;l<r;++l){const o=e[l];n=xe(s,t,o,i,n),t=o[o.length-1]}return n}function ke(s,t,e,i,n,l,r,o,a,h,c){if(t==e)return h;let f,g;if(n===0){if(g=Y(r,o,s[t],s[t+1]),g<h){for(f=0;f<i;++f)a[f]=s[t+f];return a.length=i,g}return h}c=c||[NaN,NaN];let u=t+i;for(;u<e;)if(Ii(s,u-i,u,i,r,o,c),g=Y(r,o,c[0],c[1]),g<h){for(h=g,f=0;f<i;++f)a[f]=c[f];a.length=i,u+=i}else u+=i*Math.max((Math.sqrt(g)-Math.sqrt(h))/n|0,1);if(l&&(Ii(s,e-i,t,i,r,o,c),g=Y(r,o,c[0],c[1]),g<h)){for(h=g,f=0;f<i;++f)a[f]=c[f];a.length=i}return h}function Se(s,t,e,i,n,l,r,o,a,h,c){c=c||[NaN,NaN];for(let f=0,g=e.length;f<g;++f){const u=e[f];h=ke(s,t,u,i,n,l,r,o,a,h,c),t=u}return h}function vs(s,t,e,i,n,l,r,o,a,h,c){c=c||[NaN,NaN];for(let f=0,g=e.length;f<g;++f){const u=e[f];h=Se(s,t,u,i,n,l,r,o,a,h,c),t=u[u.length-1]}return h}function Gt(s,t,e,i,n){n=n!==void 0?n:[];let l=