@nextgis/ngw-map 3.0.0 → 3.1.0

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.
@@ -1,2 +1,2 @@
1
- const e={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'};function t(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const o=void 0===r.replace||r.replace;t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{const i=-1!==n.indexOf(r);if(!o&&!i||o){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}})})}function r(e,t,n=!1){let o=e;const i=t,s=Array.isArray(i);let a=s&&[]||{};return s&&Array.isArray(i)?n?(o=o||[],a=a.concat(o),i.forEach((e,t)=>{void 0===a[t]?a[t]=e:"object"==typeof e?a[t]=r(o[t],e,n):-1===o.indexOf(e)&&a.push(e)})):a=i:(o&&"object"==typeof o&&Object.keys(o).forEach(function(e){a[e]=o[e]}),Object.keys(i).forEach(function(e){a[e]="object"==typeof i[e]&&i[e]&&"object"==typeof o[e]&&"object"==typeof i[e]?r(o[e],i[e],n):i[e]})),a}function n(e){return null!=e}function o(e){return"string"==typeof e?!!e:n(e)}function i(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}function s(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}function a(e){return{type:"Polygon",coordinates:[l(e)]}}function l(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const c=Math.PI/180,u=180/Math.PI;function h(e,t,r=10,n=6){const o=r/6371*u,i=o/Math.cos(t*c),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+i*Math.cos(r),c=t+o*Math.sin(r);s.push([l,c])}return s}function p(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:d(e,t));return e===t}function d(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let o=0;o<r.length;o++){if(!p(e[r[o]],t[n[o]],e,t))return!1}return!0}function f(e){const t={};return Object.keys(e).forEach(r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=f(e[r])}),t}function y(e){return"[object Object]"===Object.prototype.toString.call(e)}function m(e){return"[object Array]"===Object.prototype.toString.call(e)}function b(e){return e.replace(/([^:]\/)\/+/g,"$1")}const g=/\{ *([\w_-]+) *\}/g;function v(e,t){return e.replace(g,(e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n})}var w=Object.defineProperty,_=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,P=(e,t,r)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function I(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=v(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach(([e,t])=>{r.push(`${e}=${t}`)});for(const e in t)-1===s.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))O.call(t,r)&&P(e,r,t[r]);if(_)for(var r of _(t))L.call(t,r)&&P(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var x=Object.defineProperty,j=(e,t,r)=>((e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const E=class e{constructor(t={}){var r;j(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,t,r,n,i){let s,a;"object"==typeof r&&"valueToSet"in r?(s=r,n=s.onlyFull,i=s.expirationTime,a=s.props):a=r;const l=this._find(e,a);if(l)return l.value;{let r;r=t instanceof Function?t():t;const s=a&&JSON.parse(JSON.stringify(f(a)));i=i?Date.now()+i:void 0;const l={key:e,value:r,props:s,expirationTime:i};return n&&!o(r)?r:(this.cache.push(l),r instanceof Promise?(r.catch(()=>{this.delete(e,a)}),n&&r.then(t=>(o(t)||this.delete(e,a),t)),r):r)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach(e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)}),e?this.cache.filter(r=>this._filter(r,e,t)).map(e=>e.value):this.cache.map(e=>e.value)}delete(e,t){const r="string"==typeof e?this.cache.filter(r=>this._filter(r,e,t)):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find(r=>this._filter(r,e,t))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return d(e.props||{},f(r))}};j(E,"instance",{});let A=E;function C(){}function k(){k.init.call(this)}function M(e){return void 0===e._maxListeners?k.defaultMaxListeners:e._maxListeners}function S(e,t,r,n){var o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]):(i=e._events=new C,e._eventsCount=0),s){if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(o=M(e))&&o>0&&s.length>o){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function T(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function N(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function R(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}C.prototype=Object.create(null),k.EventEmitter=k,k.usingDomains=!1,k.prototype.domain=void 0,k.prototype._events=void 0,k.prototype._maxListeners=void 0,k.defaultMaxListeners=10,k.init=function(){this.domain=null,k.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new C,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},k.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},k.prototype.getMaxListeners=function(){return M(this)},k.prototype.emit=function(e){var t,r,n,o,i,s,a,l="error"===e;if(s=this._events)l=l&&null==s.error;else if(!l)return!1;if(a=this.domain,l){if(t=arguments[1],!a){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=R(e,n),i=0;i<n;++i)o[i].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=R(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=R(e,i),a=0;a<i;++a)s[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,a=R(e,s),l=0;l<s;++l)a[l].call(r,n,o,i)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=R(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,u,this,o)}return!0},k.prototype.on=k.prototype.addListener=function(e,t){return S(this,e,t,!1)},k.prototype.prependListener=function(e,t){return S(this,e,t,!0)},k.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,T(this,e,t)),this},k.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,T(this,e,t)),this},k.prototype.removeListener=function(e,t){var r,n,o,i,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0===--this._eventsCount?this._events=new C:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0===--this._eventsCount)return this._events=new C,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,s||t)}return this},k.prototype.off=function(e,t){return this.removeListener(e,t)},k.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new C,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new C:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new C,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},k.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},k.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):N.call(e,t)},k.prototype.listenerCount=N,k.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var F="3.0.0";class B extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var $=Object.defineProperty,q=(e,t,r)=>((e,t,r)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class D extends Error{constructor(e){super(),q(this,"name","NgwError"),q(this,"title"),q(this,"message"),q(this,"detail"),q(this,"exception"),q(this,"status_code"),q(this,"data"),q(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,D.prototype)}}var U=Object.defineProperty,V=(e,t,r)=>((e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class G extends D{constructor(e){super(e),V(this,"name","InsufficientPermissionsError"),V(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,G.prototype)}}var z=Object.defineProperty,Z=(e,t,r)=>((e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let W=class e extends D{constructor(t){super(t),Z(this,"message","There is no response from the server or problem connecting to server."),Z(this,"title","Network error"),Z(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var H=Object.defineProperty,J=(e,t,r)=>((e,t,r)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class Q extends Error{constructor(e){super(),J(this,"name","NetworkError"),Object.setPrototypeOf(this,Q.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var K=Object.defineProperty,X=(e,t,r)=>((e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Y extends D{constructor(e){super(e),X(this,"name","ResourceNotFoundError"),X(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,Y.prototype)}}var ee=Object.freeze({__proto__:null,AbortError:B,InsufficientPermissionsError:G,NetworkError:Q,NetworksResponseError:W,NgwError:D,ResourceNotFoundError:Y,extractError:function(e){if(y(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new W({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!y(e)&&(e.status_code&&e.exception&&e.title)}}),te=Object.defineProperty,re=(e,t,r)=>((e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ne extends Error{constructor(e){super(e||"Something went wrong."),re(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,ne)}}class oe extends ne{constructor(e){super(e||"There is no response from the server or problem connecting to server."),re(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class ie extends ne{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class se extends ne{constructor(e){super(e.message),re(this,"detail"),re(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ae extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),re(this,"title"),re(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ae)}}class le extends ae{constructor(e){super("Long-running request was cancelled.",e)}}class ce extends ae{constructor(e){super(void 0,e)}}var ue=Object.defineProperty,he=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,fe=(e,t,r)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t)=>{for(var r in t||(t={}))pe.call(t,r)&&fe(e,r,t[r]);if(he)for(var r of he(t))de.call(t,r)&&fe(e,r,t[r]);return e},me=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function be(e){return me(this,null,function*(){const t=yield function(e){return me(this,null,function*(){try{return e.json()}catch(t){throw new Error}})}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise(t=>setTimeout(t,e));let a=!1,l=!1;for(;!l;){let e,t;yield s(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(c){a=!0;continue}switch(t.status){case void 0:throw new ae(void 0,t);case"ready":l=!0;break;case"cancelled":throw new le(t);case"failed":throw new ce(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ae(void 0,t)}}return i})}const ge=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ve(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function we(e,t,r){return me(this,null,function*(){var n,o;const i=ye(ye({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:s,responseType:a,cacheProps:l,cacheName:c,lunkwill:u,cache:h,query:p,json:d}=i,y=((e,t)=>{var r={};for(var n in e)pe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&he)for(var n of he(e))t.indexOf(n)<0&&de.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),s&&(y.credentials="include");let m=!1;void 0!==u&&(u.toHeaders(y.headers||{}),m=!0);const b=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=ve(e,p),v=()=>me(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new oe}if(m&&function(e){const t=e.headers.get("content-type");return null!=t&&t.includes("application/vnd.lunkwill.request-summary+json")}(e)){const t=yield be(e);if(b)return t;e=yield function(e){return me(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new oe}})}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&ge.test(t);if("blob"===a||o)n=yield e.blob();else{if(!r)throw new ie;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof ie)throw o;throw new ie}if(400<=e.status&&e.status<=599)throw new se(n);return n});if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==h){const e=l||ye({},f({withCredentials:s,responseType:a}));return r.add(c||g,v,{props:e,expirationTime:h?void 0:500})}}else{["api/feature_layer/identify"].every(t=>!e.includes(t))&&r.clean()}return v()})}var _e=Object.defineProperty,Oe=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,je=(e,t,r)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ee=(e,t)=>{for(var r in t||(t={}))Ie.call(t,r)&&je(e,r,t[r]);if(Pe)for(var r of Pe(t))xe.call(t,r)&&je(e,r,t[r]);return e},Ae=(e,t)=>{var r={};for(var n in e)Ie.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Pe)for(var n of Pe(e))t.indexOf(n)<0&&xe.call(e,n)&&(r[n]=e[n]);return r};function Ce(e,t,r,...n){const[o,...i]=r[e],s=n[0];let a;if(void 0===s)a=[];else if("object"==typeof s&&null!==s){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");a=[];for(const[e,t]of Object.entries(s))a[i.indexOf(e)]=String(t)}else a=n.map(e=>String(e));return b(t+o.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)}))}function ke(e,t,...r){const n={url:n=>{return o=null,i=null,s=function*(){var o;const i=yield t.connect();return ve(Ce(e,null!=(o=t.options.baseUrl)?o:"",i,...r),null==n?void 0:n.query)},new Promise((e,t)=>{var r=e=>{try{a(s.next(e))}catch(r){t(r)}},n=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((s=s.apply(o,i)).next())});var o,i,s}},o=["get","post","put","delete","patch"];for(const i of o){const o=n=>{var o;const s=n||{},{headers:a}=s,l=Ae(s,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new B;return t.connect().then(n=>{var o;const s=Ce(e,null!=(o=t.options.baseUrl)?o:"",n,...r),c=f(Ee(Ee({},t.getAuthorizationHeaders()),null!=a?a:{}));return we(s,(u=Ee({headers:c},l),Oe(u,Le({method:i}))),t.cache);var u})};n[i]=o}return n}function Me(e){return"[object Object]"===Object.prototype.toString.call(e)}let Se;Se=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new D(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new Q(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&i.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o(()=>{i.abort()}),i.send(l)};const Te=[];function Ne(e){Te.push(e)}var Re=Object.defineProperty,Fe=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,Ue=(e,t,r)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ve=(e,t)=>{for(var r in t||(t={}))qe.call(t,r)&&Ue(e,r,t[r]);if($e)for(var r of $e(t))De.call(t,r)&&Ue(e,r,t[r]);return e},Ge=(e,t,r)=>Ue(e,"symbol"!=typeof t?t+"":t,r),ze=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});let Ze=0,We=0;class He{constructor(e){this.options=e,Ge(this,"id",Ze++),Ge(this,"emitter",new k),Ge(this,"user"),Ge(this,"cache"),Ge(this,"withCredentials"),Ge(this,"routeCache"),Ge(this,"client",`NextGIS-NGW-Connector/${F}`),Ge(this,"routeStr","/api/component/pyramid/route"),Ge(this,"activeRequests",{}),Ge(this,"requestTransform");const t=function(e){return Te.find(t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return d(t.options.auth,e.auth)}})}(e);if(this.cache=new A({namespace:e.cacheId}),this.routeCache=new A({namespace:"routecache"}),t)return t;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),Ne(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Ne(this)}connect(){return ze(this,arguments,function*({signal:e}={}){const t=this.options.auth;if(t){const{login:e,password:r}=t;e&&r&&(yield this._login({login:e,password:r}))}const r=`${this.routeStr}?client=${this.client}`;return this.routeCache.add(this.options.baseUrl||String(this.id),()=>this.makeQuery(r,null,{signal:e,cache:!1}))})}login(e,t){return this.logout(),Ne(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Te.indexOf(e);-1!==t&&Te.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return ze(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ve({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)})}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Ve({},this.activeRequests)}route(e,...t){return ke(e,this,...t)}makeQuery(e,t){return ze(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)qe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&$e)for(var n of $e(e))t.indexOf(n)<0&&De.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=v(e,r)}e=encodeURI(b(e)),r=Ve({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:h}=r,p=new AbortController,d=p.signal;if(i){if(i.aborted)throw new B;i.addEventListener("abort",()=>{p.abort()})}r.signal=d;const y=()=>ze(this,null,function*(){const t=We++;this.activeRequests[t]=p;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===s&&!1!==o){const r=c||(m=Ve({},f({headers:a,withCredentials:h,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Fe(m,Be({params:t})));return this.cache.add(l||e,y,{props:r,expirationTime:o?void 0:500})}var m;return y()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Ve(Ve({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;Se(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new B)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return ze(this,null,function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}})}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof D){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new Y(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new G(e)}return e}}Ge(He,"errors",ee);const Je=["description"];function Qe(e,t=""){t=t?t+"__":"";const r={};for(const[o,i]of Object.entries(e))if(-1===Je.indexOf(o))if(Me(i))if("owner_user"===o){const e=Qe(i,o);Object.assign(r,e)}else"parent"===o&&"id"in i&&(r.parent_id=i.id);else n(i)&&(r[t+o]=i);return r}var Ke=Object.defineProperty,Xe=Object.defineProperties,Ye=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,tt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,nt=(e,t,r)=>t in e?Ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ot=(e,t)=>{for(var r in t||(t={}))tt.call(t,r)&&nt(e,r,t[r]);if(et)for(var r of et(t))rt.call(t,r)&&nt(e,r,t[r]);return e},it=(e,t)=>Xe(e,Ye(t)),st=(e,t,r)=>nt(e,"symbol"!=typeof t?t+"":t,r),at=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class lt{constructor({connector:e,cacheId:t}){st(this,"cache"),st(this,"connector"),this.connector=e,this.cache=new A({namespace:t})}getOne(e,t){const r=ot({},t);return"string"==typeof e||"number"==typeof e||Me(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Me(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then(e=>{if(e)return e;throw new Y})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Me(e)?this.getOne(e,t).then(e=>{if(e)return e.resource.id}):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then(e=>{if(void 0===e)throw new Error;return e})}getMany(e,t){return this._resourceCacheFilter(e).then(r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,Qe(e)),this.connector.route("resource.search").get(it(ot({},t),{query:ot({serialization:"full"},r)})).then(e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e})}return r})}getParent(e,t){return this.getOne(e,t).then(e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)})}getChildrenOf(e,t){return this.getIdOrFail(e).then(e=>this._getChildrenOf(e,t))}update(e,t){return this.getId(e).then(e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})})}delete(e){return this.getId(e).then(e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then(()=>{this._cleanResourceItemCache(e)})})}_getChildrenOf(e,t){return at(this,arguments,function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(it(ot({},t),{query:{parent:n}})),i=[];for(const s of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(s),{id:s.resource.id}),r.push(s),(null==t?void 0:t.recursive)&&s.resource.children&&i.push(this._getChildrenOf(s.resource.id,t,r));return i.length?Promise.all(i).then(()=>r):r})}_cleanResourceItemCache(e){return at(this,null,function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)})}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then(e=>e[0])}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then(t=>(t.filter(t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:n(e.id)&&n(t.resource.id)?e.id===t.resource.id:d(e,t.resource)}),[]))}}var ct=Object.defineProperty,ut=(e,t,r)=>((e,t,r)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ht extends He{constructor(e){super(e),ut(this,"resources"),this.resources=new lt({connector:this,cacheId:e.cacheId})}static create(e){return new this(e)}clearCache(){super.clearCache(),this.resources.cache.clean()}apiRequest(e,t={},r={}){var n;return I({name:e,params:f(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}var pt=Object.defineProperty,dt=Object.defineProperties,ft=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,gt=(e,t,r)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))mt.call(t,r)&&gt(e,r,t[r]);if(yt)for(var r of yt(t))bt.call(t,r)&&gt(e,r,t[r]);return e},wt=(e,t)=>dt(e,ft(t));function _t(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,o=e.extent_right;if(t&&r&&n&&o){const e=[r,t,o,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function Ot({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.route("layer.extent",{id:Number(e)}).get({cache:r,signal:n}).then(e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}})}function Lt(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then(t=>{if(t)return Pt(t,e.connector,e)})}function Pt(e,t,r){if(e.webmap)return Promise.resolve(_t(e.webmap));{const n=e.resource;return n.cls&&n.parent&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id,r).then(e=>{if(e)return Ot(wt(vt({},r),{resourceId:e.resource.id,connector:t}))}):Ot(wt(vt({},r),{resourceId:n.id,connector:t}))}}var It=Object.defineProperty,xt=(e,t,r)=>((e,t,r)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),jt=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class Et{constructor(){xt(this,"item"),xt(this,"connector"),xt(this,"_extent")}getExtent(){return jt(this,null,function*(){return this.getBounds()})}getBounds(e){return jt(this,null,function*(){return this._extent?this._extent:this.item?(this._extent=yield Pt(this.item,this.connector,e),this._extent):void 0})}}function At(e,t){return r=this,n=null,o=function*(){const r=e.resource,n=r;let{keyname:o,resourceId:i}=e;if(r&&("string"==typeof r?o=r:i="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield At(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i},new Promise((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())});var r,n,o}var Ct=Object.defineProperty,kt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Tt=(e,t,r)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nt=(e,t,r)=>Tt(e,"symbol"!=typeof t?t+"":t,r),Rt=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Ft(e){return Rt(this,arguments,function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){Nt(this,"options",{}),Nt(this,"layer",[]),Nt(this,"_removed",!1),Nt(this,"_creatingInProgress",!1)}addLayer(){return this.layer}removeLayer(){this._removed=!0;for(const t of this.layer)e.removeLayer(t)}destroyed(){return this._removed}showLayer(){return Rt(this,null,function*(){if(this.options.visibility=!0,this.layer.length)for(const t of this.layer)yield e.showLayer(t);else yield this.loadLayer()})}hideLayer(){return Rt(this,null,function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)})}loadLayer(){return Rt(this,null,function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const o=yield n(this);if(o){const n=new o(e.mapAdapter.map,((e,t)=>{for(var r in t||(t={}))Mt.call(t,r)&&Tt(e,r,t[r]);if(kt)for(var r of kt(t))St.call(t,r)&&Tt(e,r,t[r]);return e})({},t)),i=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=i,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer})}}})}function Bt(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){return Ft({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>Zi({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)})},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var $t=Object.defineProperty,qt=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?$t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function Gt(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const zt={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>Gt(e,t),ilike:(e,t)=>Gt(e,t,!0)};function Zt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Wt(e,t){const r=((e,t)=>{for(var r in t||(t={}))Dt.call(t,r)&&Vt(e,r,t[r]);if(qt)for(var r of qt(t))Ut.call(t,r)&&Vt(e,r,t[r]);return e})({},e.properties);return!!r&&(r.$id=e.id,Ht(r,t))}function Ht(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Zt(t)){const[r,n,o]=t,i=zt[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,(n,i)=>(t=e[i],r.replace(i,o)));return i(t,n)}return i(e[r],o)}return!1}return Ht(e,t)},o=t.filter(e=>Array.isArray(e));return"any"===r?o.some(n):o.every(n)}var Jt=Object.defineProperty,Qt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Xt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,er=Object.prototype.propertyIsEnumerable,tr=(e,t,r)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rr=(e,t)=>{for(var r in t||(t={}))Yt.call(t,r)&&tr(e,r,t[r]);if(Xt)for(var r of Xt(t))er.call(t,r)&&tr(e,r,t[r]);return e},nr=(e,t)=>Qt(e,Kt(t)),or=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const ir={srs:4326,geom_format:"geojson",dt_format:"iso"};function sr(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function ar(e,t){const{extensions:r,geom:o,fields:i,srs:s,ilike:a,like:l}=t;e.extensions=r||[],i&&(e.fields=i),void 0!==o&&(e.geom=o,o||(delete e.srs,delete e.geom_format)),n(a)?e.ilike=a:n(l)&&(e.like=l),n(s)&&(e.srs=s)}function lr(e){return or(this,null,function*(){const t=ur(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o})}function cr(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,(e,t,r,n)=>(o=t,i=n,r))}__${r}`,o+n+i]}function ur(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter(e=>Array.isArray(e));if("any"===s)for(const l of a)Zt(l)?t.push(pr(nr(rr({},e),{paramList:[...r,...i,cr(l)]}))):ur(nr(rr({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)Zt(e)?n.push(cr(e)):o.push(e);if(o.length)for(const i of o)ur(nr(rr({},e),{filters:i}),t,[...r,...n]);else t.push(pr(nr(rr({},e),{paramList:[...r,...i,...n]})))}return t}function hr(e){return`POLYGON((${e.map(([e,t])=>{const[r,n]=s(e,t).map(e=>Math.round(1*(e+Number.EPSILON))/1);return r+" "+n}).join(", ")}))`}function pr(e){const t=rr({},ir),{limit:r,query:n,cache:o,signal:i,offset:s,orderBy:a,paramList:c,connector:u,geomFormat:h,intersects:p,resourceId:d}=e;if("number"==typeof r&&r!==Number.POSITIVE_INFINITY&&(t.limit=r),s&&(t.offset=s),h&&(t.geom_format=h),ar(t,e),a&&(t.order_by=a.join(",")),Array.isArray(p)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every(e=>"number"==typeof e)}(p)?l(p):p;t.intersects=hr(e)}else"string"==typeof p&&(t.intersects=p);return c&&Object.assign(t,function(e){return e.reduce((e,[t,r])=>(e[t]=r,e),{})}(c)),u.route("feature_layer.feature.collection",{id:Number(d)}).get({query:rr(rr({},t),n),cache:o,signal:i})}function dr(e){let t;for(t in e){const r=e[t];if(y(r)){const o=r;if(n(o.year)&&n(o.month)&&n(o.day)){const r=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach(e=>{r.push(e)}),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var fr=Object.defineProperty,yr=Object.defineProperties,mr=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,vr=Object.prototype.propertyIsEnumerable,wr=(e,t,r)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_r=(e,t)=>{for(var r in t||(t={}))gr.call(t,r)&&wr(e,r,t[r]);if(br)for(var r of br(t))vr.call(t,r)&&wr(e,r,t[r]);return e},Or=(e,t)=>yr(e,mr(t)),Lr=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Pr(e){return Lr(this,null,function*(){var t;const r=e.filters;if(r){let n=yield lr(Or(_r({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:Ir(r))&&(n=n.filter(e=>Ht(dr(Or(_r({},e.fields),{id:e.id})),r))),n}return pr(e)})}function Ir(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(m(r)){if(Ir(r))return!0}}return!1}function xr({options:e,webMap:t,baseUrl:r}){var n;let o,i=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===i){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const o=t+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:t=>(r&&(t.nd=r),_o(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});i="TILE"}if("WMS"===i){o=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:o,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===i)return o=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:o,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===i)return o=r+`/api/resource/${a}/terrain_provider`,{url:o,adapter:i};if("MODEL_3D"===i)return o=r+`/api/component/model_3d/${a}/data.glb`,{url:o};if("TILE"===i)return o=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:o,adapter:i}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var jr=Object.defineProperty,Er=Object.defineProperties,Ar=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,Sr=(e,t,r)=>t in e?jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tr=(e,t)=>{for(var r in t||(t={}))kr.call(t,r)&&Sr(e,r,t[r]);if(Cr)for(var r of Cr(t))Mr.call(t,r)&&Sr(e,r,t[r]);return e},Nr=(e,t)=>Er(e,Ar(t)),Rr=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Fr(e){return Rr(this,null,function*(){const t=Tr({},ir);ar(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Nr(Tr({},e),{query:t}));return Nr(Tr({},r),{toGeojson:()=>Rr(null,null,function*(){if(r.geom)return sr(r);{const t=(yield Fr(Nr(Tr({},e),{geom:!0,fields:null,extensions:null}))).geom;return sr(Nr(Tr({},r),{geom:t}))}})})})}var Br=Object.defineProperty,$r=Object.getOwnPropertySymbols,qr=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,Ur=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Vr=(e,t,r)=>Ur(e,"symbol"!=typeof t?t+"":t,r);class Gr{constructor(e){this.options=e,Vr(this,"name"),Vr(this,"resourceId"),Vr(this,"item"),Vr(this,"_extent"),this.resourceId=e.resourceId;const t=e.item;this.item=t,this.name=e.labelField&&t.fields?t.fields[e.labelField]:String(t.id)}extent(e){return this._extent?Promise.resolve(this._extent):this.options.connector.route("feature_layer.feature.item_extent",{id:this.resourceId,fid:this.item.id}).get(e).then(e=>{if(e.extent){const{minLat:t,minLon:r,maxLat:n,maxLon:o}=e.extent,i=[r,t,o,n];return this._extent=i,i}})}geoJson(e){return this.item.geom?Promise.resolve(sr(this.item)):Fr(((e,t)=>{for(var r in t||(t={}))qr.call(t,r)&&Ur(e,r,t[r]);if($r)for(var r of $r(t))Dr.call(t,r)&&Ur(e,r,t[r]);return e})({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null},e)).then(e=>(this.item.geom=e.geom,sr(this.item)))}}var zr=Object.defineProperty,Zr=(e,t,r)=>((e,t,r)=>t in e?zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Wr{constructor(e,t,r){Zr(this,"options"),Zr(this,"emitter",new k),Zr(this,"name"),Zr(this,"item"),Zr(this,"_blocked",!1),Zr(this,"_container"),Zr(this,"__value"),Zr(this,"_removeEventsListener"),this.item=t,this.options=Object.assign({},r),this.name=e,this._value=this.getProperty()}set _value(e){this.__value=e}get _value(){return this.__value}getProperty(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value}getParents(){return this.item.tree.getParents()||[]}getParent(){return this.item.tree.getParent()}getChildren(){return this.item.tree.getChildren()}isGroup(){return this.item.tree.getDescendants().length}isBlocked(){if(void 0!==this._blocked)return this._blocked;const e=this.item.tree.getParents();return this._blocked=this._calculateBlockedStatus(e),this._blocked}set(e,t){this._value=this._prepareValue(e),this.update(this._value,t),this._fireChangeEvent(this._value,t)}get(){return this.getValue()}update(e,t){this._callOnSet(e,t)}getContainer(){return this._container}destroy(){if(this._container){const e=this._container.parentNode;e&&e.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()}getValue(){return void 0!==this._value?this._value:this.getProperty()}_prepareValue(e){return e}_callOnSet(e,t){this.options.onSet&&this.options.onSet.call(this,e,t,this.item)}_fireChangeEvent(e,t){if(this.emitter){e=void 0!==e?e:this.getValue(),this.emitter.emit("change",{value:e,options:t});this.item.tree.getParents().forEach(r=>{const n=r.properties&&r.properties.property(this.name);n&&n.emitter.emit("change-tree",{value:e,options:t,item:this.item})})}}_calculateBlockedStatus(e){return e.some(e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()})}}var Hr=Object.defineProperty,Jr=Object.getOwnPropertySymbols,Qr=Object.prototype.hasOwnProperty,Kr=Object.prototype.propertyIsEnumerable,Xr=(e,t,r)=>t in e?Hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yr=(e,t)=>{for(var r in t||(t={}))Qr.call(t,r)&&Xr(e,r,t[r]);if(Jr)for(var r of Jr(t))Kr.call(t,r)&&Xr(e,r,t[r]);return e};const en=class e extends Wr{constructor(t,r,n){super(t,r,Yr(Yr({},e.options),n)),this.set(this.get())}update(e,t){if(e){if(t&&t.bubble||this.options.bubble){this.unBlock(t);const r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(e,Object.assign({},t,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(t)}else this._turnOff(t);(t&&t.propagation||this.options.propagation)&&this._propagation(e,t)}getHierarchyValue(){return this.get()&&this.getParents().every(e=>{const t=e.properties&&e.properties.get(this.name);return t&&t.get()})}block(e){this._blocked=!0,this._block(e)}unBlock(e){this._blocked=!1;this.getValue()&&this._unBlock(e)}blockChild(e){this.item.tree.getDescendants().forEach(t=>this._blockChild(t,e))}unblockChild(e){this.item.tree.getChildren().forEach(t=>this._unBlockChild(t,e))}_prepareValue(e){return e}_turnOff(e){this.options.turnOff&&this.options.turnOff.call(this,e),this._callOnSet(!1,e),this.options.hierarchy&&this.isGroup()&&this.blockChild(e)}_turnOn(e){this.options.turnOn&&this.options.turnOn.call(this,e),this._callOnSet(!0,e),this.options.hierarchy&&this.isGroup()&&this.unblockChild(e)}_block(e){this._turnOff(e)}_unBlock(e){this._turnOn(e)}_blockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.block&&r.block(Yr({silent:!0},t||{}))}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(Yr({silent:!0},t||{}))}_propagation(e,t){if(this.isGroup()){const r=this.item.tree.getChildren();for(let n=0;n<r.length;n++){const o=r[n],i=o.properties&&o.properties.property(this.name);i&&i.set(e,Yr(Yr({},t),{propagation:!0,bubble:!1}))}}}};Xr(en,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let tn=en;var rn=Object.defineProperty,nn=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable,an=(e,t,r)=>t in e?rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ln=(e,t,r)=>an(e,"symbol"!=typeof t?t+"":t,r);const cn=class e{constructor(e,t){this.item=e,ln(this,"options",{}),ln(this,"_properties",{}),ln(this,"_propertiesList",[]),t&&t.forEach(this._setPropertyHandler.bind(this))}add(e){this._setPropertyHandler(e)}update(){this.list().forEach(e=>e.update())}get(e){const t=this.property(e);return t?t.get():void 0}set(e,t,r){const n=this.property(e);n&&n.getValue()!==t&&n.set(t,r)}property(e){return this._properties[e]}list(){return this._propertiesList.map(e=>this._properties[e])}destroy(){for(const e in this._properties){const t=this.property(e);t&&t.destroy&&t.destroy()}this._properties={},this._propertiesList=[]}_setPropertyHandler(e){const t=this._getHandler(e);if(t&&e.name){const r=((e,t)=>{for(var r in t||(t={}))on.call(t,r)&&an(e,r,t[r]);if(nn)for(var r of nn(t))sn.call(t,r)&&an(e,r,t[r]);return e})({},e);this._properties[e.name]=new t(e.name,this.item,r),this._propertiesList.push(e.name)}}_getHandler(t){const r=t.handler;return!r&&t.type?"boolean"===t.type?e.handlers.CheckProperty:e.handlers.BaseProperty:r}};ln(cn,"handlers",{CheckProperty:tn});let un=cn;function hn(e,t,r,n){return!!fn(e,t,r,yn)}function pn(e,t,r,n){return fn(e,t,r,mn)}function dn(e,t="children"){let r=[];const n=("function"==typeof t?t:e=>e[t])(e);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function fn(e,t=e=>!!e,r="children",n,o){return n(e,"function"==typeof t?t:e=>Ht(e,t),r)}function yn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(t(e))return e;const n=dn(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){const e=yn(o[i],t,r,n);if(e)return e}}function mn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{t(e)&&n.push(e);const i=dn(e,r);i&&(o=i)}for(let i=0;i<o.length;i++)o[i]&&mn(o[i],t,r,n);return n}function bn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(!t(e))return!1;const n=dn(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){if(!bn(o[i],t,r,n))return!1}return!0}var gn=Object.defineProperty,vn=(e,t,r)=>((e,t,r)=>t in e?gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class wn{constructor(e){vn(this,"item"),vn(this,"_children",[]),vn(this,"_parent"),this.item=e}setParent(e){this._parent=e}addChild(e){this._children.push(e)}getParent(){return this._parent}getParents(e){const t=this.getParent();return t?pn(t,e,e=>e.tree.getParent()):[]}getRoot(){let e=this.getParent(),t=e;for(;e;)e=e.tree.getParent(),e&&(t=e);return t}find(e){return fn(this._children,e,e=>e.tree.getChildren(),yn)}every(e){return!!fn(this._children,e,e=>e.tree.getChildren(),bn)}some(e){return hn(this._children,e,e=>e.tree.getChildren())}all(e){return this.getDescendants(e)}getDescendants(e){return pn(this._children,e,e=>e.tree.getChildren())}getChildren(){return[...this._children]}}var _n=Object.defineProperty,On=Object.getOwnPropertySymbols,Ln=Object.prototype.hasOwnProperty,Pn=Object.prototype.propertyIsEnumerable,In=(e,t,r)=>t in e?_n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xn=(e,t,r)=>In(e,"symbol"!=typeof t?t+"":t,r);let jn=0;class En{constructor(e){xn(this,"options",{}),xn(this,"properties"),xn(this,"tree"),xn(this,"id",jn),jn+=1,this.options=((e,t)=>{for(var r in t||(t={}))Ln.call(t,r)&&In(e,r,t[r]);if(On)for(var r of On(t))Pn.call(t,r)&&In(e,r,t[r]);return e})({},e),this.tree=new wn(this)}initProperties(){this.properties=new un(this,this.options.properties)}}function An(e,t){return{[`symbols[${e}]`]:t.join(",")||void 0}}var Cn=Object.defineProperty,kn=Object.defineProperties,Mn=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertySymbols,Tn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Rn=(e,t,r)=>t in e?Cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fn=(e,t)=>{for(var r in t||(t={}))Tn.call(t,r)&&Rn(e,r,t[r]);if(Sn)for(var r of Sn(t))Nn.call(t,r)&&Rn(e,r,t[r]);return e},Bn=(e,t,r)=>Rn(e,"symbol"!=typeof t?t+"":t,r);class $n{constructor({legendSymbols:e,resourceId:t,connector:r,layerId:n,legend:o,webMap:i,layer:s,onSymbolRenderChange:a}){Bn(this,"layerId"),Bn(this,"layer"),Bn(this,"resourceId"),Bn(this,"legendSymbols","expand"),Bn(this,"legend"),Bn(this,"layerVisibility",!0),Bn(this,"onSymbolRenderChange"),Bn(this,"webMap"),Bn(this,"connector"),e&&(this.legendSymbols=e),this.connector=r,this.layer=s,this.layerId=n,o&&(this.legend=this.createLegend(o)),this.resourceId=t,this.webMap=i,this.onSymbolRenderChange=a}attachLayer(e){this.layerId=String(e.id),this.layer=e}create(){return e=this,t=arguments,r=function*(e={}){if(this.connector){const t=yield this.connector.route("render.legend_symbols",{id:this.resourceId}).get(Fn({},e));return this.legend=t,this.createLegend(t)}},new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});var e,t,r}createLegend(e){return e.map(e=>{return t=Fn({},e),kn(t,Mn({name:e.display_name,symbol:e.icon}));var t})}setSymbolRender(e,t){if(this.legend){const r=this.legend.find(t=>t.index===e);if(r){if(r.render!==t){r.render=t;const e=this.legend.filter(e=>e.render).map(e=>e.index);this.setLegendSymbol(e),this.onSymbolRenderChange&&this.onSymbolRenderChange(e)}}}}setLegendSymbol(e){const t=this._consolidateIntervals(e);t.length||this._hideLayer(),this.layer.updateLayer&&this.layer.updateLayer({params:Fn({},An(this.resourceId,t))}),t.length&&this._showLayer()}_hideLayer(){this.layer.options.id&&this.webMap.mapAdapter.hideLayer(this.layer.layer)}_showLayer(){this.layer.options.id&&this.layerVisibility&&this.webMap.showLayer(this.layer.options.id,{silent:!0})}_consolidateIntervals(e){const t=e.slice().sort((e,t)=>e-t),r=[];let n=t[0],o=n;for(let i=1;i<=t.length;i++)t[i]===o+1?o=t[i]:(r.push(n===o?`${n}`:`${n}-${o}`),n=t[i],o=n);return r}}var qn=Object.defineProperty,Dn=Object.defineProperties,Un=Object.getOwnPropertyDescriptors,Vn=Object.getOwnPropertySymbols,Gn=Object.prototype.hasOwnProperty,zn=Object.prototype.propertyIsEnumerable,Zn=(e,t,r)=>t in e?qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wn=(e,t)=>{for(var r in t||(t={}))Gn.call(t,r)&&Zn(e,r,t[r]);if(Vn)for(var r of Vn(t))zn.call(t,r)&&Zn(e,r,t[r]);return e},Hn=(e,t)=>Dn(e,Un(t)),Jn=(e,t,r)=>Zn(e,"symbol"!=typeof t?t+"":t,r),Qn=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const Kn=class e extends En{constructor({webMap:t,item:r,options:n,connector:o,parent:i,noInit:s}){if(super(Wn(Wn({},e.options),n)),Jn(this,"item"),Jn(this,"webMap"),Jn(this,"connector"),Jn(this,"layer"),Jn(this,"legend"),Jn(this,"emitter",new k),Jn(this,"_rootDescendantsCount",0),this.webMap=t,o&&(this.connector=o),i&&this.tree.setParent(i),this.item=r,"root"===this.item.item_type)this._rootDescendantsCount=this._sumUp(this.item.children);else{const e=this.tree.getRoot();e&&(this._rootDescendantsCount=e._rootDescendantsCount)}this.initProperties(),s||this._init(r)}static create(t,r,n,o,i){return Qn(this,null,function*(){const s=new e({webMap:t,item:r,options:n,connector:o,parent:i,noInit:!0});return yield s._init(r),s})}initItem(e){return"group"===e.item_type||"root"===e.item_type?this.initGroupItem(e):this.initLayerItem(e)}bringToFront(){}fit(){}getLayer(){return this.layer}getLegend(e){return Qn(this,null,function*(){var t,r;const n=null==(t=this.layer)?void 0:t.id;if(void 0!==n){if(this.connector&&"resourceId"in this.item){const t=Number(this.item.resourceId);if("layer"===this.item.item_type&&this.layer){const o=new $n({connector:this.connector,layerId:n,layer:this.layer,resourceId:t,webMap:this.webMap,legendSymbols:null!=(r=this.item.legend_symbols)?r:void 0,onSymbolRenderChange:e=>{this.webMap.emitter.emit("event-symbol-render:change",{layerId:n,resourceId:t,indexes:e})}});return yield o.create(e),[o]}return[]}}return[]})}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=Hn(Wn({visibility:!1,name:e.display_name},this.options),{params:{resource:"resourceId"in this.item?this.item.resourceId:void 0,item:this.item}});if(delete n.id,this.options.order){const t=String(this.options.drawOrderEnabled&&"draw_order_position"in e&&null!=e.draw_order_position?this._rootDescendantsCount-e.draw_order_position:this.id).padStart(4,"0");n.order=Number((0|this.options.order)+"."+t)}if(this.options.popupOptions&&(n.popupOptions=this.options.popupOptions),"layer"===e.item_type){const{maxZoom:t,minZoom:r}=this._getZoomRange(e);Object.assign(n,Hn(Wn({updateWmsParams:e.updateWmsParams},n),{url:e.url,maxZoom:t,minZoom:r,minScale:e.layer_min_scale_denom,maxScale:e.layer_max_scale_denom,interactive:e.layer_identifiable}))}return void 0!==r&&(n.opacity=r),n}getChildren(e){return[...e.children].reverse()}_mapScaleToZoomLevel(e){return function(e,t=0){const r=t,n=function(){if(void 0===Lo){const e=document.createElement("div");e.style.cssText="position: absolute; left: -100%; top: -100%; width: 100cm;",document.body.appendChild(e);const t=e.offsetWidth;document.body.removeChild(e),Lo=t}return Lo}()*function(e){return 12756274*Math.PI*Math.cos(e*Math.PI/180)}(r)/e;return function(e){return Math.log(e/256)/Math.LN2}(n)}(e)}initGroupItem(e){if(e.children&&e.children.length){const t=this.getChildren(e);for(const e of t){const t=new this.constructor({webMap:this.webMap,item:e,options:this.options,connector:this.connector,parent:this});this.tree.addChild(t)}}return Promise.resolve()}initLayerItem(t){const r=this.getItemOptions(t),n=e=>{t._layer=e,this.layer=e;this.properties.get("visibility")&&this.properties.set("visibility",!0),null!=r.opacity&&this.webMap.setLayerOpacity(e,r.opacity)};let o;if("layer"===t.item_type)o=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){o=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return o?this.webMap.addLayer(o,r).then(e=>{this.webMap.emitter.on(`layer-${e.id}:toggle`,t=>{const r=this.properties.get("visibility"),n=this.webMap.isLayerVisible(e);r!==n&&this.properties.set("visibility",n)}),n(e)}):t._layer?Promise.resolve(n(t._layer)):Promise.reject("No layer added")}_getZoomRange(e){const t=this.options.minZoom,r=this.options.maxZoom,n=e.layer_min_scale_denom?this._mapScaleToZoomLevel(e.layer_min_scale_denom):void 0,o=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,i=[t,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max(...i):void 0,maxZoom:s.length?Math.min(...s):void 0}}_init(e){this.initItem(e).then(()=>{this.emitter.emit("init")})}_sumUp(e,t=0){for(const r of e)"layer"===r.item_type?(t+=1,r.draw_order_position=r.draw_order_position||t):"group"===r.item_type&&(t=this._sumUp(r.children,t));return t}};Jn(Kn,"GetAdapterFromLayerType",{}),Jn(Kn,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return hn(e.item,e=>"layer_enabled"in e&&e.layer_enabled,e=>e.children);if("layer"===e.item.item_type)return e.item.layer_enabled}return!1},onSet(e,t,r){r&&"layer"===r.item.item_type&&(r.layer&&(e?r.webMap.showLayer(r.layer,t):r.webMap.hideLayer(r.layer,t)),r.item.layer_enabled=e)}},{name:"opacity",handler:class extends Wr{getProperty(){const e=this.item.layer;return e&&e&&e.options&&null!=e.options.opacity?e.options.opacity:1}update(e,t){if(t=t||{},this.isGroup()){this._value=this._prepareValue(e,t);const r=this.getChildren();for(const n of r){const r=n.properties.property(this.name);r&&(t.propagation?r.set(e,t):r.update(r.get(),t))}}const r=this.item.layer;if(r){const t=this.getParents().reduce((e,t)=>{const r=t.properties.property(this.name);return e*(r?r.getValue():1)},1);this.item.webMap.setLayerOpacity(r,this._prepareValue(e*t))}}_prepareValue(e,t){return t&&t.propagation&&this.isGroup()?1:Number(e)}}}]});let Xn=Kn;var Yn=Object.defineProperty,eo=Object.defineProperties,to=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertySymbols,no=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable,io=(e,t,r)=>t in e?Yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,so=(e,t)=>{for(var r in t||(t={}))no.call(t,r)&&io(e,r,t[r]);if(ro)for(var r of ro(t))oo.call(t,r)&&io(e,r,t[r]);return e},ao=(e,t,r)=>io(e,"symbol"!=typeof t?t+"":t,r),lo=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class co{constructor(e,t){this.map=e,this.options=t,ao(this,"layer"),ao(this,"NgwWebmapItem",Xn),ao(this,"pixelRadius",10),ao(this,"resourceId"),ao(this,"webmapClassName","webmap"),ao(this,"emitter",new k),ao(this,"_extent"),ao(this,"webmapResource"),ao(this,"_webmapBaselayersIds",[]),ao(this,"_lastActiveBaselayer");const r=t.resourceId;if(Array.isArray(r)?(this.resourceId=r[0],this.options.id=r[1]):this.resourceId=r,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}addLayer(e){return lo(this,null,function*(){var t;this.options=so(so({},this.options),e),this.layer=yield this._getWebMapLayerItem();const r=null==(t=this.webmapResource)?void 0:t.constraining_extent;return this.options.useExtentConstrained&&this._extent&&r&&this.options.webMap.setView({maxBounds:this._extent}),this.layer})}removeLayer(){const e=this.options.webMap.mapAdapter;if(this.getDependLayers().forEach(t=>{"layer"in t&&e.removeLayer(t.layer.layer)}),this._webmapBaselayersIds.length){for(const e of this._webmapBaselayersIds)this.options.webMap.removeLayer(e);this._lastActiveBaselayer&&this.options.webMap.showLayer(this._lastActiveBaselayer)}this.options.useExtentConstrained&&this._extent&&this.options.webMap.setView({maxBounds:null}),delete this.layer,delete this.webmapResource}showLayer(){return lo(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)})}hideLayer(){return lo(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)})}setOpacity(e){return lo(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("opacity").set(e)})}getExtent(){return this.getBounds()}getBounds(){const e=this.webmapResource;if(e)return _t(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.webmapResource;if(e&&e.bookmark_resource)return e.bookmark_resource.id}fetchBookmarks(e){const t=this.getBookmarksResourceId(),r=this.options.connector;if(t)return r.getResourceOrFail(t,e).then(n=>{var o;const i=null==(o=n.feature_layer)?void 0:o.fields.find(e=>e.label_field),s=i&&i.keyname;return Pr(so({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then(e=>{const n=[];for(const o of e){const e=new Gr({item:o,resourceId:t,labelField:s,connector:r});n.push(e)}return n})});throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(e){return lo(this,null,function*(){const t=[];let r=this.getDependLayers();r=r.sort((e,t)=>t.id-e.id);for(const n of r){const r=yield n.getLegend(e);t.push(...r)}return t})}getIdentificationIds(e){return lo(this,null,function*(){const e=[];let t=this.getDependLayers();return t=t.sort((e,t)=>t.id-e.id),t.forEach(t=>{const r=t.item,n="style_parent_id"in r?r.style_parent_id:void 0;if(null!=n&&"layer"===r.item_type&&r.layer_identifiable){const r=t.properties.property("visibility");r.get()&&!r.isBlocked()&&e.push(n)}}),e})}_getWebMapLayerItem(){return lo(this,null,function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise(t=>{var r;const n=this.options.connector,o=(null==n?void 0:n.options.auth)?n.getAuthorizationHeaders():void 0,i=n.withCredentials,s=(a=so({},this.options),l={withCredentials:i,headers:o,drawOrderEnabled:null!=(r=e.draw_order_enabled)&&r},eo(a,to(l)));var a,l;const c=new this.NgwWebmapItem({webMap:this.options.webMap,item:e.root_item,options:s,connector:n});c.emitter.on("init",()=>{t(c)})}):void 0})}getWebMapConfig(e){return lo(this,null,function*(){var t;const r=yield this.options.connector.getResource(e);if(r){const e=r[this.webmapClassName];if(this.webmapResource=e,this._setupBaselayers(r),e)return this._extent=null!=(t=e.initial_extent)?t:void 0,this._updateItemsParams(e.root_item,this.options.webMap,r),e}})}_setupBaselayers(e){var t;const r=this.options.webMap;if(null==(t=this.options.useBasemap)||t)if(e.basemap_webmap&&e.basemap_webmap.basemaps.length){const t=r.getActiveBaseLayer();this._lastActiveBaselayer=t?t.id:void 0,this._setBasemaps(e.basemap_webmap)}else this.options.defaultBasemap&&r.addBaseLayer("OSM",{id:"webmap-default-baselayer",name:"OpenStreetMap"})}_setBasemaps(e){const t=this.options.webMap;let r=!1;for(const n of e.basemaps)Bt({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then(e=>{const o=!r&&n.enabled;return n.enabled&&(r=!0),t.addBaseLayer(e,{id:"webmap-baselayer"+n.resource_id,name:n.display_name,opacity:n.opacity,visibility:o}).then(e=>{e.id&&this._webmapBaselayersIds.push(e.id)})})}_updateItemsParams(e,t,r){var n;if(e)if("group"===e.item_type||"root"===e.item_type){if("children"in e&&e.children){const n=e.children.map(e=>this._updateItemsParams(e,t,r));e.children=n}"root"===e.item_type&&(e.display_name=r.resource.display_name)}else if("layer"===e.item_type){const r=e,n=b(this.options.connector.options.baseUrl+"/api/component/render/image"),o=r.layer_style_id;r.url=n,r.resourceId=o,r.updateWmsParams=e=>_o(e,o);const i=xr({options:{adapter:r.layer_adapter.toUpperCase(),resource:o},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=so(so({},r),i)}return"function"==typeof(null==(n=this.options.nativeOptions)?void 0:n.beforeItemCreated)&&(e=this.options.nativeOptions.beforeItemCreated(e)),e}}var uo=Object.defineProperty,ho=Object.defineProperties,po=Object.getOwnPropertyDescriptors,fo=Object.getOwnPropertySymbols,yo=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,bo=(e,t,r)=>t in e?uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,go=(e,t)=>{for(var r in t||(t={}))yo.call(t,r)&&bo(e,r,t[r]);if(fo)for(var r of fo(t))mo.call(t,r)&&bo(e,r,t[r]);return e},vo=(e,t)=>ho(e,po(t)),wo=(e,t)=>{var r={};for(var n in e)yo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&fo)for(var n of fo(e))t.indexOf(n)<0&&mo.call(e,n)&&(r[n]=e[n]);return r};function _o(e,t){const r=e,{bbox:n,width:o,height:i,nd:s}=r,a=wo(r,["bbox","width","height","nd"]);return vo(go({},a),{resource:Array.isArray(t)?t.join(","):t,extent:n,size:o+","+i,timestamp:Date.now(),nd:null!=s?s:200})}const Oo={POINT:"point",LINESTRING:"line",POLYGON:"polygon",MULTIPOINT:"point",MULTILINESTRING:"line",MULTIPOLYGON:"polygon",POINTZ:"point",LINESTRINGZ:"line",POLYGONZ:"polygon",MULTIPOINTZ:"point",MULTILINESTRINGZ:"line",MULTIPOLYGONZ:"polygon"};let Lo;const Po={tms:"TILE"};var Io=Object.defineProperty,xo=Object.getOwnPropertySymbols,jo=Object.prototype.hasOwnProperty,Eo=Object.prototype.propertyIsEnumerable,Ao=(e,t,r)=>t in e?Io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Co=(e,t)=>{for(var r in t||(t={}))jo.call(t,r)&&Ao(e,r,t[r]);if(xo)for(var r of xo(t))Eo.call(t,r)&&Ao(e,r,t[r]);return e},ko=(e,t,r)=>Ao(e,"symbol"!=typeof t?t+"":t,r);const Mo="https://qms.nextgis.com";function So(e,t=Mo,r={}){let n;if("webMap"in e){const o=e,{webMap:i,url:s}=o,a=((e,t)=>{var r={};for(var n in e)jo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&xo)for(var n of xo(e))t.indexOf(n)<0&&Eo.call(e,n)&&(r[n]=e[n]);return r})(o,["webMap","url"]);n=i,s&&(t=s),a&&(r=a)}else n=e;t||(t=Mo);class o{constructor(e,t){ko(this,"qms"),ko(this,"options"),ko(this,"map"),this.map=e;const n=Co(Co({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,i=null,s=function*(){if(!this.qms&&e.qmsId)try{this.qms=yield function(e){return new Promise((t,r)=>{const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState&&200===n.status&&n.responseText)try{t(JSON.parse(n.responseText))}catch(e){r(e)}},n.open("GET",b(e),!0),n.send()})}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=Po[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(i=o,s=a,["showLayer","hideLayer"].forEach(e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(i.prototype,e,t)}),"TILE"===t)){if(e=Co(Co({order:0,maxZoom:n.options.maxZoom,minZoom:n.options.minZoom},this.options),function(e){const t=("https:"===location.protocol?"https":"http")+"://";let r=e.url.replace(/^(https?|ftp):\/\//,t);return e.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:e.name,attribution:e.copyright_text,maxZoom:e.z_max,minZoom:e.z_min}}(r)),r.origin_url){const[t,n]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,(e,r)=>("string"==typeof r&&r.split(",").forEach(e=>t.push(e)),"{s}")),t]}(r.origin_url);n.length&&(e.subdomains=n,e.url=t)}return this.options=e,new a(this.map,e).addLayer(e)}}var i,s},new Promise((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},o=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,o);a((s=s.apply(r,i)).next())});var r,i,s}}return o}var To=Object.defineProperty,No=Object.getOwnPropertySymbols,Ro=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,Bo=(e,t,r)=>t in e?To(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$o=(e,t)=>{for(var r in t||(t={}))Ro.call(t,r)&&Bo(e,r,t[r]);if(No)for(var r of No(t))Fo.call(t,r)&&Bo(e,r,t[r]);return e},qo=(e,t,r)=>Bo(e,"symbol"!=typeof t?t+"":t,r);class Do{constructor(e){qo(this,"options",{url:"https://qms.nextgis.com"}),qo(this,"url"),this.options=$o($o({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return So({webMap:e,url:this.url})}}qo(Do,"utils",{createQmsAdapter:So});var Uo=Object.defineProperty,Vo=Object.defineProperties,Go=Object.getOwnPropertyDescriptors,zo=Object.getOwnPropertySymbols,Zo=Object.getPrototypeOf,Wo=Object.prototype.hasOwnProperty,Ho=Object.prototype.propertyIsEnumerable,Jo=Reflect.get,Qo=(e,t,r)=>t in e?Uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ko=(e,t)=>{for(var r in t||(t={}))Wo.call(t,r)&&Qo(e,r,t[r]);if(zo)for(var r of zo(t))Ho.call(t,r)&&Qo(e,r,t[r]);return e},Xo=(e,t)=>Vo(e,Go(t)),Yo=(e,t,r)=>Jo(Zo(e),r,t),ei=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});var ti=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function ri(e){return function(e){return ti(this,null,function*(){const t=yield Pr(e),r=[];return t.forEach(e=>{r.push(sr(e))}),r})}(e).then(e=>({type:"FeatureCollection",features:e}))}const ni=["fields","intersects","limit","orderBy","strategy"];function oi(e){const t={};return ni.forEach(r=>{const n=e[r];void 0!==n&&(t[r]=n)}),t}var ii=Object.defineProperty,si=Object.defineProperties,ai=Object.getOwnPropertyDescriptors,li=Object.getOwnPropertySymbols,ci=Object.getPrototypeOf,ui=Object.prototype.hasOwnProperty,hi=Object.prototype.propertyIsEnumerable,pi=Reflect.get,di=(e,t,r)=>t in e?ii(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fi=(e,t)=>{for(var r in t||(t={}))ui.call(t,r)&&di(e,r,t[r]);if(li)for(var r of li(t))hi.call(t,r)&&di(e,r,t[r]);return e},yi=(e,t)=>si(e,ai(t)),mi=(e,t,r)=>di(e,"symbol"!=typeof t?t+"":t,r),bi=(e,t,r)=>pi(ci(e),r,t),gi=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function vi(e){return gi(this,null,function*(){var t,r;const{item:n,webMap:o,Adapter:i,connector:s,layerOptions:a,addLayerOptionsPriority:l}=e,c=null==l||l,u=a,h=i||a.Adapter||o.mapAdapter.layerAdapters.GEOJSON,p=[];let d,f,y=!1;const m=yield At(u,s);(null==(r=null==(t=u.adapterOptions)?void 0:t.popupOptions)?void 0:r.fromProperties)&&(u.adapterOptions.popupOptions.createPopupContent=({feature:e})=>e&&function(e,t){{const r=document.createElement("div");if(t&&t.feature_layer)t.feature_layer.fields.forEach(t=>{if(t.grid_visibility){const n=e.properties&&e.properties[t.keyname];if(n){const e=document.createElement("div");r.appendChild(e),e.innerHTML=`<span>${t.display_name}</span>: ${n}<span></span>`}}});else if(e.properties)for(const t in e.properties){const n=document.createElement("div");r.appendChild(n),n.innerHTML=`<span>${t}</span>: ${e.properties[t]}<span></span>`}return r}}(e,n));const b=(e,t)=>gi(null,null,function*(){v(),f=new AbortController;const r=f.signal;return(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",f.abort),(t=t||{}).signal=r,d={filters:e,options:t},ri(fi({resourceId:m,filters:e,connector:s,cache:!0},t))});let g=!1;const v=()=>{f&&(f.abort(),f=void 0)};class w extends h{constructor(){super(...arguments),mi(this,"emitter",new k),mi(this,"__onMapMove"),mi(this,"__onMapMoveStart"),mi(this,"__enableMapMoveListener"),mi(this,"__disableMapMoveListener")}addLayer(e){return gi(this,null,function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==u.id&&(e.id=u.id),n&&n.vector_layer&&(e.type=Oo[n.vector_layer.geometry_type]),u.adapterOptions&&(e=c?fi(fi({},u.adapterOptions),e):fi(fi({},e),u.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const o=e.strategy||void 0;this.options.strategy=o;const i=bi(w.prototype,this,"addLayer").call(this,e);let s;return d={filters:e.propertiesFilter,options:oi(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),o&&o.startsWith("BBOX")&&!y&&this._addBboxEventListener(),i})}getExtent(){return this.getBounds()}getBounds(){return gi(this,null,function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?Lt({connector:s,resourceId:n.resource.id}):bi(w.prototype,this,"getBounds")?bi(w.prototype,this,"getBounds").call(this):void 0})}beforeRemove(){g=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,v()}getCount(){return function({connector:e,resourceId:t,cache:r=!0,signal:n}){return e.route("feature_layer.feature.count",{id:t}).get({cache:r,signal:n}).then(e=>e.total_count)}({connector:s,resourceId:m,cache:!0})}updateLayer(e){return gi(this,null,function*(){var t;const r=e||d||{};if(null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield o.onLoad("create"),r.options=r.options||{},r.options.intersects=o.getBounds();const{minZoom:e,maxZoom:t}=this.options,n=o.getZoom();if(void 0!==n){if(void 0!==e&&n<e)return;if(void 0!==t&&n>t)return;if(y)return}}if(!g){try{this.emitter.emit("preupdate",r),o._emitLayerEvent("layer:preupdate",u.id||"",r);const e=yield b(r.filters,yi(fi({},r.options),{srs:this.options.srs}));let t=e;const n=yield this.getCount();if("BBOX+"===this.options.strategy){t={type:"FeatureCollection",features:[]};for(const r of e.features)-1===p.indexOf(String(r.id))&&(p.push(String(r.id)),t.features.push(r));y=void 0!==n&&p.length>=n,yield o.addLayerData(this,t)}else y=void 0!==n&&e.features.length>=n,yield o.setLayerData(this,e);this.emitter.emit("updated",e),o._emitLayerEvent("layer:updated",u.id||"",{data:e,newData:t,isFull:y})}catch(n){if(n instanceof Error&&"AbortError"!==n.name)throw n}bi(w.prototype,this,"updateLayer")&&bi(w.prototype,this,"updateLayer").call(this)}})}propertiesFilter(e,t){return gi(this,null,function*(){if(v(),this.filter&&y)this.filter(t=>{const r=t.feature&&t.feature.properties&&dr(fi({},t.feature.properties));return!r||Ht(r,e)});else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(e,yi(fi({},t),{srs:this.options.srs}));this.setData(r)}})}removeFilter(){d=void 0,this.propertiesFilter([]),this.filter&&this.filter(()=>!0)}_addBboxEventListener(){this.__enableMapMoveListener=e=>{e===this&&(this._removeMoveEventListener(),this.updateLayer(),this._addMoveEventListener())},this.__disableMapMoveListener=e=>{e===this&&this._removeMoveEventListener()},o.emitter.on("layer:show",this.__enableMapMoveListener),o.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&o.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&o.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...o){n.clear(),r=setTimeout(()=>{r=null,e.apply(this,o)},t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}(()=>this.updateLayer()),this.__onMapMoveStart=v,o.emitter.on("movestart",this.__onMapMoveStart),o.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&o.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&o.emitter.removeListener("movestart",this.__onMapMoveStart)}}return w})}var wi=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});var _i=Object.defineProperty,Oi=Object.defineProperties,Li=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,Ii=Object.prototype.hasOwnProperty,xi=Object.prototype.propertyIsEnumerable,ji=(e,t,r)=>t in e?_i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ei=(e,t)=>{for(var r in t||(t={}))Ii.call(t,r)&&ji(e,r,t[r]);if(Pi)for(var r of Pi(t))xi.call(t,r)&&ji(e,r,t[r]);return e},Ai=(e,t)=>Oi(e,Li(t)),Ci=(e,t,r)=>ji(e,"symbol"!=typeof t?t+"":t,r),ki=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Mi(e){return ki(this,arguments,function*({layerOptions:e,connector:t,webMap:r,item:o}){const i=o.resource.cls;let s=e.adapter||i&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[i]||"IMAGE";if(void 0!==s&&(e.adapter=s),"IMAGE"===s){const e=r.getLayerAdapters();!e||e.IMAGE||(s="TILE")}const a=r.mapAdapter.layerAdapters[s];if(a){const i=yield At(e,t);return class extends a{constructor(s,a){super(s,a),this.map=s,Ci(this,"item",o),Ci(this,"resourceId",i),Ci(this,"blocked",!1),Ci(this,"layerVisibility");const l=xr({options:e,webMap:r,baseUrl:t.options.baseUrl||""});if(l){const t=Ai(Ei(Ei({},l),e.adapterOptions),{params:{resource:i},layers:l.layers||String(i),resourceId:i});e.adapterOptions&&n(e.adapterOptions.setViewDelay)&&(t.setViewDelay=e.adapterOptions.setViewDelay),this.options=Ei(Ei({},this.options),t)}}addLayer(e){return super.addLayer(Ei(Ei({},this.options),e))}getIdentificationIds(){return ki(this,null,function*(){if(this.item){if("MVT"===s)return[this.item.resource.id];if(this.item.resource.parent){const e=this.item.resource.parent.id;if(n(e))return[e]}}return[]})}getLegend(e){return ki(this,null,function*(){const n=this.options.id;if(void 0!==n){const o=yield t.route("render.legend_symbols",{id:i}).get(Ei({cache:!0},e));return[new $n({layerId:n,layer:this,resourceId:i,webMap:r,legend:o})]}return[]})}}}throw new Error(s+" not supported yet. Only TILE")})}var Si=Object.defineProperty,Ti=Object.defineProperties,Ni=Object.getOwnPropertyDescriptors,Ri=Object.getOwnPropertySymbols,Fi=Object.prototype.hasOwnProperty,Bi=Object.prototype.propertyIsEnumerable,$i=(e,t,r)=>t in e?Si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qi=(e,t)=>{for(var r in t||(t={}))Fi.call(t,r)&&$i(e,r,t[r]);if(Ri)for(var r of Ri(t))Bi.call(t,r)&&$i(e,r,t[r]);return e},Di=(e,t)=>Ti(e,Ni(t)),Ui=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const Vi={},Gi=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function zi(e){return Ui(this,arguments,function*({layerOptions:e,webMap:t,connector:r,item:n}){const o=n.resource.id,i=yield r.getResourceChildren(o),s=i&&i[0];if(s)return Zi(Di(qi({},e),{resource:s.resource.id}),t,r)})}function Zi(e,r,n){return Ui(this,null,function*(){let o,i;const s=e.adapter,a=yield At(e,n);if(a){const t=e.resource;if(i=t&&t.resource&&void 0!==t.resource.id?t:yield n.getResource(a),!i)throw"Resource item is not found";{const t=i.resource.cls,l={layerOptions:Di(qi({},e),{resource:a}),connector:n,webMap:r,item:i};if(-1!==Gi.indexOf(t))if("webmap"===t)o=function(e){return wi(this,arguments,function*({layerOptions:e,webMap:t,connector:r}){const n=yield At(e,r);return class extends co{constructor(e){super(e,{url:"",webMap:t,resourceId:n,connector:r})}}})}(l);else if("vector_layer"===t||"postgis_layer"===t){const t=l.layerOptions.adapterOptions||{};if(t.type=t.type||i.vector_layer&&Oo[i.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==s&&"GEOJSON"!==s){if("MVT"!==s)return zi(l);o=Mi(l)}else o=vi(l)}else{if("raster_layer"===t)return zi(l);if("basemap_layer"===t)o=function(e){return ei(this,arguments,function*({webMap:e,item:t}){if(t.basemap_layer){const r=t.basemap_layer.qms,n=t.basemap_layer.url;if(r){const t=JSON.parse(r);return Promise.resolve(Do.utils.createQmsAdapter(e,void 0,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return ei(this,null,function*(){if(n)return Yo(e.prototype,this,"addLayer").call(this,Xo(Ko({},t),{url:n}))})}}return e}}}})}(l);else if("GEOJSON"===s&&i.resource.parent){const t=yield n.getResource(i.resource.parent.id);if(t){const r=Di(qi({},e),{resource:i.resource.parent.id});o=vi(Di(qi({},l),{item:t,layerOptions:r}))}}else o=Mi(l)}else{if(!Vi[t])throw`Resource class '${t}' not yet supported.`;{const e=Vi[t];let r;r=s&&"function"!=typeof r?e[s]:e,r&&(o=r(l))}}}}if(o)return o.then(e=>{if(e){const r=e;return i&&(r.prototype.item=i,r.prototype.resourceId=i.resource.id,r.prototype.connector=n),t(r,[Et],{replace:!1}),r}})})}var Wi=Object.defineProperty,Hi=Object.getOwnPropertySymbols,Ji=Object.prototype.hasOwnProperty,Qi=Object.prototype.propertyIsEnumerable,Ki=(e,t,r)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xi=(e,t)=>{for(var r in t||(t={}))Ji.call(t,r)&&Ki(e,r,t[r]);if(Hi)for(var r of Hi(t))Qi.call(t,r)&&Ki(e,r,t[r]);return e},Yi=(e,t,r)=>Ki(e,"symbol"!=typeof t?t+"":t,r);class es{constructor(e){if(this.options=e,Yi(this,"url"),Yi(this,"connector"),Yi(this,"webMap"),this.options.connector)this.url=this.options.connector.options.baseUrl||"",this.connector=this.options.connector;else{if(!this.options.baseUrl)throw new Error("url is not defined");this.url=this.options.baseUrl,this.connector=new ht({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){Vi[e]=t}onLoadSync(e){return t=this,r=null,n=function*(){if(this.options.resourceId&&this.url){const t=[this.options.resourceId];if(t.length)for(const r of t){const t={resourceId:r,connector:this.connector,webMap:e};return yield e.addLayer(co,Xi({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}getLayerAdapters(){return Promise.resolve([this._getLayerAdapter()])}_getLayerAdapter(){return{name:"WEBMAP",createAdapter:e=>Promise.resolve(this._createAdapter(e))}}_createAdapter(e){return t={webMap:e,connector:this.connector,baseUrl:this.url},class extends co{constructor(e,r){super(e,r=go(go({},t),r))}};var t}}var ts=Object.defineProperty,rs=Object.getOwnPropertySymbols,ns=Object.prototype.hasOwnProperty,os=Object.prototype.propertyIsEnumerable,is=(e,t,r)=>t in e?ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ss=(e,t)=>{for(var r in t||(t={}))ns.call(t,r)&&is(e,r,t[r]);if(rs)for(var r of rs(t))os.call(t,r)&&is(e,r,t[r]);return e},as=(e,t,r)=>is(e,"symbol"!=typeof t?t+"":t,r),ls=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class cs{constructor(e){as(this,"id"),as(this,"label"),as(this,"layerId"),as(this,"parent"),as(this,"fields"),as(this,"geom"),as(this,"extensions"),as(this,"connector"),as(this,"_item"),as(this,"_geojson"),as(this,"_resource"),as(this,"_extent");const t=e.feature;this.id=t.id,this.geom=t.geom,this.label=t.label,this.parent=t.parent,this.fields=t.fields,this.layerId=t.layerId,this.connector=e.connector}identify(e={}){return this._item?Promise.resolve(this._item):Fr(ss({connector:this.connector,featureId:this.id,resourceId:this.layerId,fields:null,extensions:["attachment","description"]},e)).then(e=>(this._item=e,this.geom=e.geom,this.extensions=e.extensions,e))}resource(e){return ls(this,null,function*(){return(yield this.composite(e)).feature_layer})}composite(e){return ls(this,null,function*(){if(this._resource&&this._resource.feature_layer)return this._resource;const t=yield this.connector.getResource(this.layerId,e);if(!t)throw new Error("Resource does not exist");if(!t.feature_layer)throw new Error("Resource is not a vector layer");return this._resource=t,t})}getBounds(e){return this._extent?Promise.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0,signal:o}){return r.route("feature_layer.feature.item_extent",{id:Number(e),fid:t}).get({cache:n,signal:o}).then(e=>{if(e&&e.extent){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}})}(ss({connector:this.connector,featureId:this.id,resourceId:this.layerId},e))}geojson(e={}){return this._geojson?Promise.resolve(this._geojson):this.identify(e).then(e=>e.toGeojson().then(e=>(this._geojson=e,e)))}}function us(e){return t=this,r=null,n=function*(){return sr(yield Fr(e))},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}function hs(e,t){return r=this,n=null,o=function*(){var r,n;const o=yield e.route("pyramid.settings").get({query:{component:"pyramid"}});if(o&&o.company_logo&&o.company_logo.enabled){const i=document.createElement("a");i.style.position="absolute",i.style.bottom="0",i.style.right="0",i.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",i.className="ngw-map-logo",t&&t.cssClass&&(i.className+=" "+t.cssClass);const s=new Image;s.style.maxHeight="100px",s.style.maxWidth="100px",s.src="";const a=null==(n=(yield e.route("pyramid.csettings").get({query:{pyramid:["header_logo"]}})).pyramid)?void 0:n.header_logo;if(!a)return;{const[e,t]=a,r=atob(t),n=new Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);const o=new Uint8Array(n),i=new Blob([o],{type:e}),l=(window.URL||window.webkitURL).createObjectURL(i);s.src=l}return null!==o.company_logo.link&&""!==o.company_logo.link.trim()&&(i.href=o.company_logo.link,i.target="_blank",-1!==o.company_logo.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),i.appendChild(s),i}},new Promise((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())});var r,n,o}var ps=Object.defineProperty,ds=Object.defineProperties,fs=Object.getOwnPropertyDescriptors,ys=Object.getOwnPropertySymbols,ms=Object.prototype.hasOwnProperty,bs=Object.prototype.propertyIsEnumerable,gs=(e,t,r)=>t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vs=(e,t)=>{for(var r in t||(t={}))ms.call(t,r)&&gs(e,r,t[r]);if(ys)for(var r of ys(t))bs.call(t,r)&&gs(e,r,t[r]);return e},ws=(e,t)=>ds(e,fs(t));function _s(e,t=!1){const r=[],n=[];for(const i in e){const e=Number(i);isNaN(e)||r.push(e)}const o=e.resources;o&&r.sort((e,t)=>o.indexOf(e)-o.indexOf(t));for(let i=0;i<r.length;i++){const o=r[i],s=e[o];if("features"in s){const e=Os(s.features,Number(o),t);if(e.length&&(n.push(...e),!t))break}}return n}function Os(e,t,r){const n=[];for(const o of e){if(n.push({featureId:o.id,resourceId:t,feature:o}),!r)break}return n}function Ls(e){const{geom:t,signal:r,cache:n,layers:o}=e,i="string"==typeof t?t:function(e){const t=function(e){var t;if(Array.isArray(e))return e;if("Feature"===e.type)return null==(t=e.geometry)?void 0:t.coordinates[0];if("Polygon"===e.type)return e.coordinates[0];return null}(e);if(!t)return null;return`POLYGON((${t.map(([e,t])=>{const[r,n]=s(e,t);return`${r} ${n}`}).join(",")}))`}(t);if(!i)throw new Error("Not valid geometry format to make intersection");const a={geom:i,srs:3857,layers:o};return e.connector.route("feature_layer.identify").post({json:a,signal:r,cache:n})}const Ps={};function Is(e){return Ps[e]}function xs(e,t){Ps[e]=t}function js(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const o=t.title||"",i=t.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function l(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(e,t){e.split(" ").forEach(e=>{t?r.classList.add(e):r.classList.remove(e)})}function u(){t.addClassOn&&c(t.addClassOn,n),t.addClassOff&&c(t.addClassOff,!n)}s(),l(),t.addClass&&c(t.addClass,!0),u();const h=e=>{void 0!==e&&(n=e),l(),s(),u()},p=e=>{if(n=void 0!==e?e:!n,t.onClick){const e=t.onClick(n);Promise.resolve(e).then(()=>h()).catch(()=>n=!n)}else h()},d=e({html:r,onClick:p});return d.onClick=p,d.changeStatus=h,d}function Es(e){return(t,r)=>{const n=t.map(e=>e());return e(n,r)}}const As={"!":Es(function([e]){return!e}),"!=":Es(function([e,t]){return e!==t}),"<":Es(function([e,t]){return e<t}),"<=":Es(function([e,t]){return e<=t}),"==":Es(function([e,t]){return e===t}),">":Es(function([e,t]){return e>t}),">=":Es(function([e,t]){return e>=t}),coalesce:e=>{for(let t=0;t<e.length;t++){const r=e[t]();if(null!=r)return r}return null},all:e=>{for(let t=0;t<e.length;t++){if(!e[t]())return!1}return!0},any:e=>{for(let t=0;t<e.length;t++){if(e[t]())return!0}return!1},case:e=>{if(e.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(e.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(let t=0;t<e.length-1;t+=2){const r=e[t](),n=e[t+1]();if(r)return n}return(0,e[e.length-1])()},match:e=>{const[t,...r]=e,n=t(),o=r.splice(-1,r.length%2)[0];for(let i=0;i<r.length-1;i+=2){if(r[i]()===n)return r[i+1]()}return o()}},Cs={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function ks(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Ms(e);if("string"==typeof(t=e)&&t in Cs)return function(e){return Ms(Cs[e])}(e);if(function(e){return"string"==typeof e&&/^rgb(a?)\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)(?:\s*,\s*([01](?:\.\d+)?))?\s*\)$/.test(e)}(e))return function(e){const t=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;let r;if(r=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)];if(r=e.match(t))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4])];throw new Error(`The '${e}' Is not valid rgb`)}(e);if(function(e){if("object"==typeof e&&null!==e)return"r"in e&&"g"in e&&"b"in e&&(!("a"in e)||"number"==typeof e.a&&e.a>=0&&e.a<=1);return!1}(e))return function({r:e,g:t,b:r,a:n}){return[e,t,r,...void 0!==n?[n]:[]]}(e);var t,r;throw new Error(`The '${e}' cannot be converted to color`)}function Ms(e){let t;if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),parseInt(t[4]+t[4],16)/255];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16)/255];throw new Error(`The '${e}' Is not valid hex`)}function Ss(e,t,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(e-t)/(n-t)*(o-r);try{const i=ks(r),s=ks(o);return function(e){return`rgb(${e.join(",")})`}(i.map((r,o)=>Math.ceil(Ss(e,t,r,n,s[o]))))}catch(i){console.log(i)}throw new Error("Unsupported output type for linear interpolation.")}const Ts={step:e=>{const[t,r,...n]=e,o=t();if("number"!=typeof o)return r();for(let i=0;i<n.length-2;i+=2){const e=n[i](),t=n[i+1](),r=n[i+2]();if(o>=e&&o<r)return t}return o>=n[n.length-2]()?n[n.length-1]():r()},interpolate:([e,t,...r])=>{if(r.length<2)throw new Error("At least two stops are required");if(r.length<2||r.length%2!=0)throw new Error("Invalid stops provided.");const n=t();if("number"!=typeof n)throw new Error("Input must be a number.");const o=e();for(let i=0;i<r.length-2;i+=2){const e=r[i](),t=r[i+1](),s=r[i+2](),a=r[i+3]();if(n>=e&&n<=s&&"linear"===o[0])return Ss(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Ns={get:Es(function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null}),length:Es(([e])=>{if("string"==typeof e||Array.isArray(e))return e.length}),at:Es(function([e,t]){return t[e]}),has:Es(function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))}),in:Es(function([e,t]){if("string"==typeof t)return t.includes(String(e));if(Array.isArray(t))return t.includes(e);throw new Error(`Invalid input type for 'in'. Expected string or array, got ${typeof t}.`)}),"index-of":Es(function([e,t,r]){if("string"==typeof t)return t.indexOf(String(e),r);if(Array.isArray(t))return t.indexOf(e,r);throw new Error(`Invalid input type for 'index-of'. Expected string or array, got ${typeof t}.`)}),slice:Es(function(e){const[t,r,n]=e;if("string"==typeof t)return t.slice(r,n);if(Array.isArray(t))return t.slice(r,n);throw new Error(`Invalid input type for 'slice'. Expected string or array, got ${typeof t}.`)})},Rs={"+":Es(e=>e.reduce((e,t)=>e+t,0)),"-":Es(e=>e.reduce((e,t)=>e-t)),"*":Es(e=>e.reduce((e,t)=>e*t,1)),"/":Es(e=>e.reduce((e,t)=>e/t)),"%":Es(e=>e[0]%e[1]),"^":Es(e=>Math.pow(e[0],e[1])),abs:Es(e=>Math.abs(e[0])),acos:Es(e=>Math.acos(e[0])),asin:Es(e=>Math.asin(e[0])),atan:Es(e=>Math.atan(e[0])),ceil:Es(e=>Math.ceil(e[0])),cos:Es(e=>Math.cos(e[0])),e:()=>Math.E,floor:Es(e=>Math.floor(e[0])),ln:Es(e=>Math.log(e[0])),ln2:()=>Math.LN2,log10:Es(e=>Math.log10(e[0])),log2:Es(e=>Math.log2(e[0])),max:Es(e=>Math.max(...e)),min:Es(e=>Math.min(...e)),pi:()=>Math.PI,round:Es(e=>Math.round(e[0])),sin:Es(e=>Math.sin(e[0])),sqrt:Es(e=>Math.sqrt(e[0])),tan:Es(e=>Math.tan(e[0]))},Fs={concat:Es(e=>e.reduce((e,t)=>String(e)+String(t),"")),downcase:Es(e=>String(e[0]).toLowerCase()),upcase:Es(e=>String(e[0]).toUpperCase())},Bs=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function $s(e){return(t,r)=>{for(const n of t){const t=Bs(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const qs={array:Es(e=>{const[t,r,n]=e;let o,i,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(o=t,"number"==typeof r?(i=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(o&&!s.every(e=>typeof e===o))throw new Error(`Expected all items in array to be of type ${o}`);if(i&&s.length!==i)throw new Error(`Expected array of length ${i}`);return s}),boolean:Es($s(e=>"boolean"==typeof e?e:void 0)),literal:Es(([e])=>e),number:Es($s(e=>"number"==typeof e?e:void 0)),object:Es($s(e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e)),string:Es($s(e=>"string"==typeof e?e:void 0)),"to-boolean":Es($s(Boolean)),"to-number":Es($s(Number)),"to-string":Es($s(String)),typeof:Es(([e])=>function(e){if(null===e)return"null";switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":if(Array.isArray(e)){let t="value";return e.every(e=>"number"==typeof e)?t="number":e.every(e=>"string"==typeof e)?t="string":e.every(e=>"boolean"==typeof e)&&(t="boolean"),`array<${t}, ${e.length}>`}return"object";default:return"undefined"}}(e))};var Ds=Object.defineProperty,Us=Object.getOwnPropertySymbols,Vs=Object.prototype.hasOwnProperty,Gs=Object.prototype.propertyIsEnumerable,zs=(e,t,r)=>t in e?Ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Zs=(e,t)=>{for(var r in t||(t={}))Vs.call(t,r)&&zs(e,r,t[r]);if(Us)for(var r of Us(t))Gs.call(t,r)&&zs(e,r,t[r]);return e};function Ws(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in Hs&&r.length>0}return!1}const Hs=Zs(Zs(Zs(Zs(Zs(Zs({},Rs),qs),Fs),Ns),As),Ts);function Js(e,t={}){const[r,...n]=e,o=Hs[r];if(o)return o(n.map(e=>()=>Ws(e)?Js(e,t):e),t);throw new Error(`Expression "${r}" is not supported.`)}var Qs=Object.defineProperty,Ks=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,ea=(e,t,r)=>t in e?Qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ta=(e,t)=>{for(var r in t||(t={}))Xs.call(t,r)&&ea(e,r,t[r]);if(Ks)for(var r of Ks(t))Ys.call(t,r)&&ea(e,r,t[r]);return e};function ra(e){return t=>{const r=t.properties;return!!r&&Js(e,r)}}const na=["iconSize","iconAnchor"];function oa(e){return"function"==typeof e}var ia=Object.defineProperty,sa=Object.getOwnPropertySymbols,aa=Object.prototype.hasOwnProperty,la=Object.prototype.propertyIsEnumerable,ca=(e,t,r)=>t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ua=(e,t)=>{for(var r in t||(t={}))aa.call(t,r)&&ca(e,r,t[r]);if(sa)for(var r of sa(t))la.call(t,r)&&ca(e,r,t[r]);return e};function ha(e){let t={};const r=[];for(const n of e)n&&(Array.isArray(n)?r.push(n):t=n);return e=>{const n=r.find(t=>Wt(e,t[0]));return n?ua(ua({},t),n[1]):t}}function pa({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===na.indexOf(n)){const o=n,i=e[o];Ws(i)&&(t=!0,r[o]=ra(i))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return ta(ta({},e),n)}}(e);if(r){const n=e=>fa({paint:r(e),defaultPaint:t});return n.paint=da({paint:e,defaultPaint:t}),n}return da({paint:e,defaultPaint:t})}function da({paint:e,defaultPaint:t}){var r;let n=ua({},t);return n=ua(ua({},n),e),n.fill=null==(r=n.fill)||r,n.stroke=void 0!==n.stroke?n.stroke:!n.fill||!(!n.strokeColor&&!n.strokeOpacity),n}function fa({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=ua({},t);if(oa(e)){const n=n=>{const o=fa({paint:e(n),defaultPaint:t,getPaintFunctions:r});return o.type=e.type,o};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>fa({paint:ha(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const o=function(e,t){if("function"==typeof e.from)return e.from(e.options);if("string"==typeof e.from&&t){const r=t[e.from];if(r)return r(e.options)}}(e,r);o&&(n=fa({paint:o,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=pa({paint:e,defaultPaint:t})}return oa(n)||("color"in n&&(n.strokeColor||(n.strokeColor=n.color),n.fillColor||(n.fillColor=n.color)),"opacity"in n&&(void 0===n.strokeOpacity&&(n.strokeOpacity=n.opacity),void 0===n.fillOpacity&&(n.fillOpacity=n.opacity))),n}function ya(e){const t={};for(let n=0;n<e.length;n++)t[e[n]]=1+(t[e[n]]||0);let r;for(const n in t){t[n]>((void 0!==r?t[r]:0)||0)&&(r=n)}return r}function ma(e){let t;if("FeatureCollection"===e.type){t=ya(e.features.map(e=>e.geometry.type))}else if("GeometryCollection"===e.type){t=ya(e.geometries.map(e=>e.type))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const ba={polygon:"path",line:"path",point:"circle"},ga={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function va(e){if(e.data){const t=ga[ma(e.data)],r=e.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===t||"line"===t?"path":"html"in r||"className"in r?"icon":ba[t]),e.type=e.type||t}return e}var wa=Object.defineProperty,_a=(e,t,r)=>((e,t,r)=>t in e?wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Oa{constructor(){_a(this,"backspace",8),_a(this,"tab",9),_a(this,"enter",13),_a(this,"shift",16),_a(this,"ctrl",17),_a(this,"alt",18),_a(this,"pause/break",19),_a(this,"caps_lock",20),_a(this,"escape",27),_a(this,"page_up",33),_a(this,"page_down",34),_a(this,"end",35),_a(this,"home",36),_a(this,"left_arrow",37),_a(this,"up_arrow",38),_a(this,"right_arrow",39),_a(this,"down_arrow",40),_a(this,"insert",45),_a(this,"delete",46),_a(this,"left_window_key",91),_a(this,"right_window_key",92),_a(this,"select_key",93),_a(this,"numpad_0",96),_a(this,"numpad_1",97),_a(this,"numpad_2",98),_a(this,"numpad_3",99),_a(this,"numpad_4",100),_a(this,"numpad_5",101),_a(this,"numpad_6",102),_a(this,"numpad_7",103),_a(this,"numpad_8",104),_a(this,"numpad_9",105),_a(this,"multiply",106),_a(this,"add",107),_a(this,"subtract",109),_a(this,"decimal_point",110),_a(this,"divide",111),_a(this,"f1",112),_a(this,"f2",113),_a(this,"f3",114),_a(this,"f4",115),_a(this,"f5",116),_a(this,"f6",117),_a(this,"f7",118),_a(this,"f8",119),_a(this,"f9",120),_a(this,"f10",121),_a(this,"f11",122),_a(this,"f12",123),_a(this,"num_lock",144),_a(this,"scroll_lock",145),_a(this,"semi-colon",186),_a(this,"equal_sign",187),_a(this,",",188),_a(this,"-",189),_a(this,".",190),_a(this,"/",191),_a(this,"`",192),_a(this,"[",219),_a(this,"\\",220),_a(this,"]",221),_a(this,"'",222)}}var La=Object.defineProperty,Pa=(e,t,r)=>((e,t,r)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var Ia=Object.defineProperty,xa=(e,t,r)=>((e,t,r)=>t in e?Ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ja{constructor(e,t){this.webMap=e,xa(this,"name"),xa(this,"event"),xa(this,"value"),t&&(t.value&&this.setValue(t.value),t.name&&(this.name=t.name),t.event&&(this.event="string"==typeof t.event?[t.event]:t.event))}getValue(){return this.value}setValue(e){this.value=e}}var Ea=Object.defineProperty,Aa=(e,t,r)=>((e,t,r)=>t in e?Ea(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ca extends ja{constructor(){super(...arguments),Aa(this,"name","bounds"),Aa(this,"event",["moveend"])}getValue(){return this.webMap.getBounds()}setValue(e){this.webMap.setView({bounds:e})}toString(){const e=this.getValue();if(e)return e.slice(0,4).map(e=>e.toFixed(5)).join("_")}parse(e){return e.split("_").map(Number)}}var ka=Object.defineProperty,Ma=(e,t,r)=>((e,t,r)=>t in e?ka(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Sa extends ja{constructor(){super(...arguments),Ma(this,"name","center"),Ma(this,"event",["moveend"])}getValue(){return this.webMap.getCenter()}setValue(e){this.webMap.setCenter(e)}toString(){const e=this.getValue();if(e){const t=e.map(e=>e.toFixed(5));return t[0]+"_"+t[1]}return""}parse(e){return e.split("_").map(Number)}}var Ta=Object.defineProperty,Na=(e,t,r)=>((e,t,r)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ra extends ja{constructor(){super(...arguments),Na(this,"name","zoom"),Na(this,"event",["zoomend"])}getValue(){const e=this.webMap.getZoom();return void 0!==e?Math.round(e):void 0}setValue(e){this.webMap.setZoom(e)}toString(){return String(this.getValue())}parse(e){return Number(e)}}var Fa=Object.defineProperty,Ba=(e,t,r)=>((e,t,r)=>t in e?Fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),$a=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});let qa=0;const Da={minZoom:0,maxZoom:22,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},Ua=class e{constructor(t){Ba(this,"options",Da),Ba(this,"emitter",new k),Ba(this,"keys",e.keys),Ba(this,"mapAdapter"),Ba(this,"runtimeParams",[]),Ba(this,"getPaintFunctions",e.getPaintFunctions),Ba(this,"mapStateItems",[Sa,Ra,Ca]),Ba(this,"id",qa++),Ba(this,"mapState",[]),Ba(this,"_initMapState",{}),Ba(this,"_starterKits"),Ba(this,"_extent"),Ba(this,"_eventsStatus",{}),Ba(this,"_coordFromMapClickAbort"),Ba(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(Da||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}create(){return $a(this,null,function*(){return this.getEventStatus("create")||(yield this._setInitMapState(this.mapStateItems),yield this._setupMap(),this._emitStatusEvent("create",this)),this})}setRuntimeParams(e){this.runtimeParams.push(e)}destroy(){this._removeEventListeners(),function(e){for(const t in e)delete e[t]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}mapStateWithFunc(e){const t={};return this.mapState.forEach(r=>{t[r.name]=e(r)}),t}getStateAsString(){return this.mapStateWithFunc(e=>e.toString())}getState(){return this.mapStateWithFunc(e=>e.getValue())}getRuntimeParams(){const e={};return this.mapState.forEach(t=>{for(const r of this.runtimeParams){const n=r.get(t.name);if(void 0!==n){e[t.name]=t.parse(n);break}}}),e}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const e=document.getElementById(this.options.target);if(e)return e}}}setCursor(e){this.onLoad().then(()=>{this.mapAdapter.setCursor&&this.mapAdapter.setCursor(e)})}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const e=this.getContainer();return e?e.style.cursor:void 0}setCenter(e){return this.mapAdapter.setCenter(e),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const e=this.getBounds();if(e){return{type:"Feature",properties:{},geometry:a(e)}}}setZoom(e){return this.mapAdapter.setZoom(e),this}getZoom(){const e=this.mapAdapter.getZoom();if("number"==typeof e)return e}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e-1)}}}setView(e,t){if(Array.isArray(e)){const r=e;this.mapAdapter.setView&&r&&n(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),n(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return function(e){const[t,r,n,o]=e,i=t<n&&r<o;if(!i){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${o}]`);const e=[Math.min(t,n),Math.min(r,o),Math.max(t,n),Math.max(o,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&o<=90;s&&a||console.log("Warning: The coordinates may not be within valid geographic ranges.")}(e),e.every(e=>n(e))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,t)),this}getEventStatus(e){const t=this._eventsStatus[e];return null!=t&&t}onLoad(e="create"){return new Promise(t=>{this.getEventStatus(e)?t(this):this.emitter.once(e,()=>{t(this)})})}onMapLoad(e){return new Promise(t=>{var r;const n=()=>{const r=this.mapAdapter;e&&e(r),r&&t(r)},o=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&o?n():this.mapAdapter.emitter.once("create",()=>{n()})})}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(e){return this.mapAdapter.layerAdapters[e]}locate(e,t){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(e,t);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickAbort&&(this._coordFromMapClickAbort(),this._coordFromMapClickAbort=void 0)}getCoordFromMapClick(){return this._coordFromMapClickAbort?this.getCoordFromMapClick():new Promise((e,t)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const n=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickAbort=void 0},o=t=>{n(),i(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),this._coordFromMapClickAbort=n})}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return $a(this,null,function*(){})}_onLoadSync(){return $a(this,null,function*(){})}_setupMap(){return $a(this,null,function*(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return yield this.mapAdapter.create(this.options),this._zoomToInitialExtent(),yield this._addLayerProviders(),yield this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this})}_setTileJsonOptions(e){e.center&&(this.options.center=e.center),e.bounds&&(this.options.bounds=e.bounds),n(e.maxzoom)&&(this.options.zoom=e.maxzoom),n(e.minzoom)&&(this.options.zoom=e.minzoom),n(e.maxzoom)&&n(e.minzoom)&&(this.options.zoom=(e.maxzoom+e.minzoom)/2)}_zoomToInitialExtent(){const{center:e,zoom:t,bounds:r}=this.options;this._extent?this.fitBounds(this._extent):e&&t?this.setView(e,t):r&&(this.fitBounds(r),void 0!==t&&this.setZoom(t))}_setInitMapState(e){for(const t of e){const e=new t(this);this.mapState.push(e);for(const t of this.runtimeParams){const r=t.get(e.name);if(void 0!==r){const t=e.parse(r);this._initMapState[e.name]=t,Object.defineProperty(this.options,e.name,{value:t,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(e){let t=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend","mousemove","mouseout","mouseover"];e&&e.include&&(t=t.filter(t=>e.include.includes(t))),t.forEach(e=>{this._mapEvents[e]=t=>{if(this.runtimeParams.length){this.mapState.filter(t=>t.event.includes(e)).forEach(e=>{const t=e.toString();this.runtimeParams.forEach(r=>{r.set(e.name,t)})})}this._eventsStatus&&this.emitter.emit(e,t)};const t=this._mapEvents[e];t&&this.mapAdapter.emitter.on(e,t)})}_removeEventListeners(e){let t=Object.entries(this._mapEvents);e&&e.include&&(t=t.filter(t=>e.include.includes(t[0]))),t.forEach(([e,t])=>{t&&this.mapAdapter.emitter.removeListener(e,t)})}};Ba(Ua,"keys",new class{constructor(){Pa(this,"keyCodeAlias",new Oa),Pa(this,"keys",{}),Pa(this,"_windowOnFocus"),Pa(this,"_keysPressed"),Pa(this,"_keysReleased"),this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(e){const t=this.keyCodeAlias[e];return!!t&&this.keys[t]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(e){e.stopPropagation(),this.keys[e.keyCode]||(this.keys[e.keyCode]=!0)}keysReleased(e){e.stopPropagation(),this.keys[e.keyCode]=!1}windowOnFocus(){this.keys={}}}),Ba(Ua,"getPaintFunctions");let Va=Ua;var Ga=Object.defineProperty,za=Object.defineProperties,Za=Object.getOwnPropertyDescriptors,Wa=Object.getOwnPropertySymbols,Ha=Object.prototype.hasOwnProperty,Ja=Object.prototype.propertyIsEnumerable,Qa=(e,t,r)=>t in e?Ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ka=(e,t)=>{for(var r in t||(t={}))Ha.call(t,r)&&Qa(e,r,t[r]);if(Wa)for(var r of Wa(t))Ja.call(t,r)&&Qa(e,r,t[r]);return e},Xa=(e,t)=>za(e,Za(t)),Ya=(e,t,r)=>Qa(e,"symbol"!=typeof t?t+"":t,r),el=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class tl extends Va{constructor(e){super(e),Ya(this,"_layersIdCounter",1),Ya(this,"_layersOrderCounter",1),Ya(this,"_baselayers",[]),Ya(this,"_layers",{}),Ya(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",()=>this.addTileJsonLayer(t))}fitLayer(e,t){return el(this,null,function*(){const r=this.getLayer(e),n=r&&(r.getBounds||r.getExtent);if(n){const e=yield n.call(r);e&&this.fitBounds(e,t)}})}isBaseLayer(e){const t=this.getLayer(e);if(t&&t.id)return-1!==this._baselayers.indexOf(t.id)}getBaseLayers(){const e=[];return this._baselayers.forEach(t=>{const r=this._layers[t];r&&e.push(r)}),e}getBaseLayersIds(){return this._baselayers}getLayer(e){return"string"==typeof e?this._layers[e]:e}getLayerId(e){const t=this.getLayer(e);if(t){if(t.id)return null==t?void 0:t.id;if(t&&t.options)return t.options.id}throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort((e,t)=>e.order&&t.order?e.order-t.order:0)}findLayer(e){for(const t in this._layers){const r=this._layers[t];if(e(r))return r}}isLayerVisible(e){const t=this.getLayer(e);return!(!t||void 0===t.options.visibility)&&t.options.visibility}addBaseLayer(e,t){return el(this,null,function*(){return yield this.addLayer(e,Xa(Ka({},t),{baselayer:!0}),void 0)})}addLayer(e){return el(this,arguments,function*(e,t={},r){var o,i;const s=this._layersIdCounter++,a=n(r)?r:void 0!==t.order?t.order:this.reserveOrder();let l;"string"==typeof e?l=this.getLayerAdapter(e):"function"==typeof e?l=e:"then"in e&&(l=yield e);const c=t;this._updateGeoJsonOptions(c);const u=null==(o=(t=Ka({id:String(s),order:a},t)).visibility)||o;if(t.visibility=!1,t.baselayer&&(t.order=0),this.options.onBeforeAddLayer){const e=this.options.onBeforeAddLayer({options:t,adapter:l});e&&(e.options&&(t=e.options),e.adapter&&(l=e.adapter))}if(void 0!==l){const e=new l(this.mapAdapter.map,t);let r;e.options=Ka(Ka({},t),e.options),e.options.baselayer&&(t.baselayer=!0,t.order=0,e.options.order=0),e.options.id&&(r=String(e.options.id),this._layers[r]=e),this._emitLayerEvent("layer:preadd",r||"",e),yield this.onMapLoad(),e.map=this.mapAdapter.map;const n=yield e.addLayer(e.options);if(e.layer=n,e.id=e.options.id||String(s),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(i=e.options.order)?i:a,r&&delete this._layers[r],r=String(e.id),this._layers[r])throw Error(`layer with id '${r}' already exist`);r&&(this._layers[r]=e,c.filter&&this.filterLayer(e,c.filter),t.baselayer&&this._baselayers.push(r),u&&(yield this.showLayer(r)));const o=t.opacity;null!=o&&o<=1&&this.setLayerOpacity(e,o);const h=n&&(e.getBounds||e.getExtent);if(t.fit&&h){const t=yield h.call(e);t&&(yield this.fitBounds(t))}return t.onAdded&&t.onAdded(e),this._emitLayerEvent("layer:add",r,e),e}return Promise.reject("No adapter")})}addLayerFromAsyncAdapter(e,t,r){return el(this,null,function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),o=e(),i=yield o;return i?this.addLayer(i,t,n):Promise.reject("No adapter")})}removeLayers(e){for(const t in this._layers){let r=!0;e&&(r=e(t,this._layers[t])),r&&(this.removeLayer(t),delete this._layers[t])}}getLegend(e){return el(this,null,function*(){const t=[];for(const r of this.orderedLayers())r.getLegend&&t.push(r.getLegend(e));return(yield Promise.all(t)).flat()})}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers((e,t)=>!(t&&t.options&&t.options.baselayer))}removeLayer(e){const t=this.getLayer(e),r=t&&this.getLayerId(t);if(t&&r){if(this.emitter.emit("layer:preremove",t),t.beforeRemove&&t.beforeRemove(),t.removeLayer?t.removeLayer():this.mapAdapter.removeLayer(t.layer),t.options&&t.options.baselayer){const e=this._baselayers.indexOf(r);e&&this._baselayers.splice(e,1)}delete this._layers[r],this.emitter.emit("layer:remove",t)}}addGeoJsonLayer(e={},t){return(e=e||{}).multiselect=void 0!==e.multiselect&&e.multiselect,e.unselectOnSecondClick=void 0===e.unselectOnSecondClick||e.unselectOnSecondClick,t||(e=va(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",Xa(Ka({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",Xa(Ka({},t),{url:r}))}showLayer(e,t={}){return this.toggleLayer(e,!0,t)}hideLayer(e,t={}){return this.toggleLayer(e,!1,t)}toggleLayer(e,t,r={}){const n=this.getLayer(e),o=void 0!==t?t:!(n&&n.options.visibility),i=void 0!==r.silent&&r.silent,s=e=>el(this,null,function*(){const t=String(e.id),r=o?"layer:show":"layer:hide";if(i||(this._emitLayerEvent(o?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),o&&this.mapAdapter){const t=e.options.baselayer?0:e.options.order;if(e.options.baselayer&&this._baselayers.length){const t=this._baselayers.filter(t=>t!==e.id&&this.isLayerVisible(t));for(const e of t)yield this.hideLayer(e)}e.showLayer?yield e.showLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.showLayer(e.layer)),void 0!==t&&this.mapAdapter.setLayerOrder(e.layer,t,this._layers)}else e.hideLayer?yield e.hideLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.hideLayer(e.layer));e.options.visibility=o,i||(this._emitLayerEvent(r,t,e),this._emitLayerEvent("layer:toggle",t,e))});return n?this.onMapLoad().then(()=>s(n)):Promise.resolve()}updateLayer(e,t){const r=this.getLayer(e);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer(t));if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then(()=>this.showLayer(r,{silent:!0}))}return Promise.resolve()}setLayerOpacity(e,t){const r=this.getLayer(e);r&&(r.setOpacity?r.setOpacity(t):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,t))}isLayerLabelVisible(e){var t;const r=this.getLayer(e);return r.isLabelVisible?r.isLabelVisible():null==(t=r.options.labelVisibility)||t}showLayerLabel(e){this.toggleLayerLabel(e,!0)}hideLayerLabel(e){this.toggleLayerLabel(e,!1)}toggleLayerLabel(e,t){const r=this.getLayer(e);return t=null!=t?t:!this.isLayerLabelVisible(e),r&&(t?r.showLabel&&(r.options.labelVisibility=!0,r.showLabel()):r.hideLabel&&(r.options.labelVisibility=!1,r.hideLabel()),r.id&&this._emitLayerEvent("layer:label:toggle",r.id,r)),t}selectLayer(e,t){const r=this.getLayer(e);if(r){r&&r.select&&r.select(t);const e=this.getLayerId(r);e&&this._selectedLayers.push(e)}}unSelectLayer(e,t){const r=this.getLayer(e);if(r){const e=r&&r;e.unselect&&e.unselect(t);const n=this.getLayerId(r);if(n){const e=this._selectedLayers.indexOf(n);-1!==e&&this._selectedLayers.splice(e,1)}}}unSelectLayers(){const e=Object.values(this.allLayers());let t;for(t of e)t.unselect&&t.unselect()}filterLayer(e,t){const r=this.getLayer(e);return r.filter?r.filter(t):[]}propertiesFilter(e,t,r){const n=this.getLayer(e);if(n){const e=n;if(e.propertiesFilter)return e.propertiesFilter(t,r);e.filter&&this.filterLayer(e,e=>!e.feature||!e.feature.properties||Ht(e.feature.properties,t))}return Promise.resolve()}removeLayerFilter(e){const t=this.getLayer(e);t.removeFilter?t.removeFilter():t.filter&&t.filter(()=>!0)}setLayerData(e,t){const r=this.getLayer(e);if(r){if(r.setData)return r.setData(t);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(t)}return Promise.resolve()}addLayerData(e,t){const r=this.getLayer(e);r.addData&&r.addData(t)}clearLayerData(e,t){const r=this.getLayer(e);r&&r.clearLayer&&r.clearLayer(t)}setLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.setPaint&&r.setPaint(t)}setLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.setSelectedPaint&&r.setSelectedPaint(t)}updateLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.updatePaint&&r.updatePaint(t)}updateLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(t)}getAttributions(e){const t=[];for(const r in this._layers){const n=this._layers[r];let o=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(o&&e.onlyBaselayer&&(o=this._baselayers.includes(r)),o){const e=n.options&&n.options.attribution;e&&t.push(e)}}return t}getActiveBaseLayer(){const e=this.getBaseLayers().find(e=>this.isLayerVisible(e));if(e)return this.getLayer(e)}addTileJsonLayer(e){return this.addLayer("TILE",{url:e.tiles[0],maxZoom:e.maxzoom,minZoom:e.minzoom,subdomains:e.scheme,attribution:e.attribution})}_emitLayerEvent(e,t,r){const o=String(e);if(n(t)&&o.startsWith("layer:")){const e=o.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return el(this,null,function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)})}_onLayerDoubleClick(e){return el(this,null,function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)})}_onLayerSelect(e){return el(this,null,function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)})}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:o,onDoubleClick:i,onLayerClick:s,onMouseOut:a,onMouseOver:l}=e,c=o||s,u=i||s;e.onClick=e=>(c&&c(e),this._onLayerClick(e)),e.onDoubleClick=e=>(u&&u(e),this._onLayerDoubleClick(e)),e.onMouseOut=e=>{const t=e.layer.id;a&&a(e),n(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;l&&l(e),n(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const h=t||r;e.onSelect=e=>(h&&h(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=fa({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=fa({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}var rl=Object.defineProperty,nl=(e,t,r)=>((e,t,r)=>t in e?rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),ol=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const il=class e extends tl{constructor(){super(...arguments),nl(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),nl(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return ol(this,null,function*(){let n;if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,r):e,n)return new Promise(e=>{this._setControlQueue(t,()=>ol(this,null,function*(){const r=yield n,o=this.mapAdapter.addControl(r,t);e(o)}))})})}createControl(e,t){return ol(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)})}createButtonControl(e){return ol(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)})}createToggleControl(e){return ol(this,null,function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?js(this.mapAdapter.createButtonControl,e):void 0})}removeControl(e){"remove"in e?e.remove():this.mapAdapter.removeControl&&Promise.resolve(e).then(e=>{this.mapAdapter.removeControl(e)})}getControl(t,r){const n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);{const n=e.controls[t];if(n)return n(this,r)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return ol(this,null,function*(){if(this._loadControlQueue[e].length){this._isControlLoading[e]=!0;const t=this._loadControlQueue[e][0];yield t(),this._loadControlQueue[e].splice(0,1),this._applyControls(e)}else this._isControlLoading[e]=!1})}};nl(il,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let sl=il;var al=Object.getOwnPropertySymbols,ll=Object.prototype.hasOwnProperty,cl=Object.prototype.propertyIsEnumerable,ul=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),hl=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}),pl=(e,t,r)=>(t=e[ul("asyncIterator")])?t.call(e):(e=e[ul("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:i}),o)))),r("next"),r("return"),t);class dl extends sl{constructor(e){super(e),this._addControls(),xs(this.id,this)}static get(e){return Is(e)}_addLayerProviders(){return hl(this,null,function*(){try{for(var e,t,r,n=pl(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.getLayerAdapters){const t=yield e.getLayerAdapters.call(e);if(t)try{for(var o,i,s,a=pl(t);o=!(i=yield a.next()).done;o=!1){const e=i.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(i){s=[i]}finally{try{o&&(i=a.return)&&(yield i.call(a))}finally{if(s)throw s[0]}}}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}})}_onLoadSync(){return hl(this,null,function*(){try{for(var e,t,r,n=pl(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.onLoadSync)try{yield e.onLoadSync.call(e,this)}catch(o){console.error(o)}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}})}_addControls(){this.options.controls&&this.options.controls.forEach(e=>{let t=e,r={};"string"==typeof e&&this.options.controlsOptions&&this.options.controlsOptions[e]&&(r=this.options.controlsOptions[e],void 0!==r.control&&(t=r.control));const n=r,{position:o}=n,i=((e,t)=>{var r={};for(var n in e)ll.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&al)for(var n of al(e))t.indexOf(n)<0&&cl.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,o||"top-left",i)}),this._emitStatusEvent("controls:create")}}function fl(){return["ZOOM","ATTRIBUTION"]}function yl(e){return t=this,r=null,n=function*(){return new dl(e).onLoad()},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var ml=Object.defineProperty,bl=Object.defineProperties,gl=Object.getOwnPropertyDescriptors,vl=Object.getOwnPropertySymbols,wl=Object.prototype.hasOwnProperty,_l=Object.prototype.propertyIsEnumerable,Ol=(e,t,r)=>t in e?ml(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ll=(e,t)=>{for(var r in t||(t={}))wl.call(t,r)&&Ol(e,r,t[r]);if(vl)for(var r of vl(t))_l.call(t,r)&&Ol(e,r,t[r]);return e},Pl=(e,t)=>bl(e,gl(t));function Il(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(Pl(Ll({},r),{resource:t}));else if(Array.isArray(t)){const[o,i]=t;e.push(Ll(Pl(Ll({},r),{resource:o,id:i}),n))}else"object"==typeof t&&e.push(Ll(Ll(Ll({},r),t),n))}var xl=Object.defineProperty,jl=Object.defineProperties,El=Object.getOwnPropertyDescriptors,Al=Object.getOwnPropertySymbols,Cl=Object.prototype.hasOwnProperty,kl=Object.prototype.propertyIsEnumerable,Ml=(e,t,r)=>t in e?xl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const Sl={target:"map",baseUrl:"",whitlabel:!1,controls:["ZOOM","ATTRIBUTION"],controlsOptions:{ZOOM:{position:"top-left"},ATTRIBUTION:{position:"bottom-right",customAttribution:['<a href="https://nextgis.com" target="_blank">©NextGIS</a>']}},pixelRadius:10};function Tl(e){const t=[new Do];var n;return e.starterKits&&e.starterKits.forEach(e=>{t.push(e)}),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new ht({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=r(Sl,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new es({connector:e.connector,auth:e.auth})),n=((e,t)=>{for(var r in t||(t={}))Cl.call(t,r)&&Ml(e,r,t[r]);if(Al)for(var r of Al(t))kl.call(t,r)&&Ml(e,r,t[r]);return e})({},e),e=jl(n,El({starterKits:t,create:!1}))}var Nl=Object.defineProperty,Rl=Object.defineProperties,Fl=Object.getOwnPropertyDescriptors,Bl=Object.getOwnPropertySymbols,$l=Object.getPrototypeOf,ql=Object.prototype.hasOwnProperty,Dl=Object.prototype.propertyIsEnumerable,Ul=Reflect.get,Vl=(e,t,r)=>t in e?Nl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Gl=(e,t)=>{for(var r in t||(t={}))ql.call(t,r)&&Vl(e,r,t[r]);if(Bl)for(var r of Bl(t))Dl.call(t,r)&&Vl(e,r,t[r]);return e},zl=(e,t)=>Rl(e,Fl(t)),Zl=(e,t,r)=>Vl(e,"symbol"!=typeof t?t+"":t,r),Wl=(e,t,r)=>Ul($l(e),r,t),Hl=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const Jl=class e extends dl{constructor(e){super(Tl(e)),Zl(this,"emitter",new k),Zl(this,"connector"),Zl(this,"_ngwLayers",{}),Zl(this,"$$selectFromNgwRaster"),Zl(this,"$$selectFromNgwVector"),Zl(this,"_promises",{select:[],identify:[]}),e.connector&&(this.connector=e.connector),this._createWebMap().then(()=>{const e=this.getContainer();e&&e.classList.add("ngw-map-container"),this.options.whitlabel&&this._whiteLabel()})}addControl(t,r,n){return Hl(this,null,function*(){return yield this.onLoad("controls:create"),Wl(e.prototype,this,"addControl").call(this,t,r,n)})}addNgwLayer(e){return Hl(this,null,function*(){yield this.onMapLoad();const{keyname:t,resourceId:r}=e;(t||void 0!==r)&&console.warn(`DEPRECATED WARN: ${"set `resource` options instead of `keyname` or `resourceId`"}`);const o=e.resource;if(!t&&!r&&!o)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(n(this.options.baseUrl))try{n(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},n(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),Zi(e,t,r)}(e,this,this.connector),r=Gl(Gl({visibility:!0},e),e.adapterOptions),o=yield this.addLayer(t,r),i=o&&this.getLayerId(o);if(o&&i&&(this._ngwLayers[i]={layer:o,resourceId:o.resourceId},o.options.name=o.options.name||o.item&&o.item.resource.display_name,o.options.baselayer)){if(this.getActiveBaseLayer())return o}return o}catch(i){const e=y(o)&&"id"in o?o.id:t||r||o;console.error(`Can't add NGW layer ${e}.`,i)}})}fit(){const{center:e,zoom:t,bounds:r}=this.options;e?(this.setCenter(e),t&&this.setZoom(t)):r&&this.fitBounds(r)}fetchNgwLayerItem(e){return Fr(Gl({connector:this.connector},e))}fetchNgwLayerItems(e){return Pr(Gl({connector:this.connector},e))}fetchNgwLayerFeature(e){return us(Gl({connector:this.connector},e))}fetchNgwLayerFeatures(e){return ri(Gl({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=new AbortController,n=r.signal;(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",r.abort),(t=t||{}).signal=n;const o=function(e){const{connector:t,identify:r}=e,n=_s(r);return n&&n.length?Fr(vs(vs({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",o,r),o}fetchIdentifyGeoJson(e,{multiple:t,signal:r}={}){const n=new AbortController;if(r){if(r.aborted)return Promise.reject(new ht.errors.AbortError);r.addEventListener("abort",()=>{n.abort("AbortError")})}const o=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const i in r){const e=Number(i);if(!isNaN(e)){const e=r[i];if("features"in e){const t=e.features.find(e=>e.geom);if(t&&t.geom){const e=t.geom;return Promise.resolve(sr(ws(vs({},t),{geom:e})))}}}}const o=_s(r);return o&&o.length?us(vs(ws(vs({},n),{connector:t}),o[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,multiple:t,requestOptions:{signal:n.signal}});return o&&"then"in o?(this._addPromise("identify",o,n),o):Promise.resolve(o)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,{multiple:t})}getNgwLayers(){return Hl(this,null,function*(){return yield this.onLoad(),this._ngwLayers})}getNgwLayerByResourceId(e){return Hl(this,null,function*(){for(const t in this._ngwLayers){const r=this._ngwLayers[t];if(r.resourceId===e)return r&&r.layer;if(r.layer.getIdentificationIds){const t=yield r.layer.getIdentificationIds();if(t&&t.some(t=>t===e))return r.layer}if(r.layer.getDependLayers){const t=r.layer.getDependLayers().find(t=>t.item&&"style_parent_id"in t.item&&void 0!==t.item.style_parent_id&&t.item.style_parent_id===e);if(t)return t.layer}}})}fitLayer(t,r){return Hl(this,null,function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const o=n&&this._ngwLayers[n];if(o)if(o.layer.getBounds){const e=yield o.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(o.layer.item)e=o.layer.item;else{const t=o.resourceId;e=yield this.connector.getResource(t)}e&&this.fitResource(e.resource.id)}else Wl(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)})}fitResource(e,t){return Hl(this,null,function*(){const r=yield this.connector.resources.getIdOrFail(e),n=yield Lt({resourceId:r,connector:this.connector});n&&this.fitBounds(n,t)})}zoomToLayer(e){return Hl(this,null,function*(){return this.fitLayer(e)})}onLoad(e="ngw-map:create"){return super.onLoad(e)}removeLayer(e){const t=this.getLayer(e);if(t){const e=this.getLayerId(t);e&&delete this._ngwLayers[e],super.removeLayer(t)}}enableSelection(){this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=e=>{this._getSelectListenersCount()&&this.selectFromNgwRaster(e)},this.$$selectFromNgwVector=e=>{this._getSelectListenersCount()&&this._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))}disableSelection(){this.$$selectFromNgwRaster&&(this.emitter.removeListener("click",this.$$selectFromNgwRaster),this.$$selectFromNgwRaster=void 0),this.$$selectFromNgwVector&&(this.emitter.removeListener("layer:click",this.$$selectFromNgwVector),this.$$selectFromNgwVector=void 0)}getNgwLayerItem(e){return this.fetchNgwLayerItem(e)}getNgwLayerItems(e){return this.fetchNgwLayerItems(e)}getNgwLayerFeature(e){return this.fetchNgwLayerFeature(e)}getNgwLayerFeatures(e){return this.fetchNgwLayerFeatures(e)}cancelPromise(...e){this.cancelPromises(...e)}cancelPromises(...e){e.length||(e=Object.keys(this._promises)),e.forEach(e=>{const t=this._promises[e];t&&(t.forEach(e=>e[1].abort()),this._promises[e]=[])})}selectFromNgwRaster(e){return Hl(this,null,function*(){var t;this._emitStatusEvent("ngw:preselect");const r=[],n=Object.values(this._ngwLayers);n.sort((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1);for(const e of n){const n=e.layer,o="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,i=null==(t=n.options.interactive)||t;if(o&&n.options.selectable&&i&&this.isLayerVisible(n)){const e=o.call(n);r.push(e)}}const o=Promise.all(r),s=yield o,a=[];for(const e of s)e&&a.push(...e);if(!a.length)return void this._emitStatusEvent("ngw:select",null);const l=this.options.pixelRadius||10,c=this.getCenter();let u=this.getZoom();if(u=void 0!==u?u:20,!c||!u)return void this._emitStatusEvent("ngw:select",null);const p=function(e,t,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*e[1]/Math.PI))/Math.pow(2,t+8))*5e-4}(c,u,l);let d;if(this.options.highlightIdentification){const t=this.options.highlightIdentification,r="number"==typeof t?t:1e3,[n,o]=e.lngLat;d={type:"Polygon",coordinates:[h(n,o,p)]};const i=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:d}});r!==1/0&&setTimeout(()=>{this.removeLayer(i)},r)}const f=new AbortController,y=function(e,t){i(e);const[r,n]=e.lngLat,{geom:o,radius:s}=t,a=null!=o?o:h(r,n,s);return Ls(ws(vs({},t),{geom:a}))}(e,{layers:a,connector:this.connector,radius:p,geom:d,signal:f.signal}).then(t=>{const r=zl(Gl({},t),{resources:a,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n});return this._addPromise("select",y,f),y})}_addPromise(e,t,r){const n=this._promises[e];if(n&&-1===n.findIndex(e=>e[0]===t)){const e=()=>{const e=n.findIndex(e=>e[0]===t);-1!==e&&n.splice(e,1)};t.then(e,e),n.push([t,r])}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}_createWebMap(){return Hl(this,null,function*(){yield this.create(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer();const e=[],t=this._isFitFromResource();if(this.options.webmapId&&Il(e,this.options.webmapId,{fit:t}),this.options.resources&&Array.isArray(this.options.resources))for(const n of this.options.resources){const r={};t||(r.fit=!1),Il(e,n,{},r)}for(const n of e)try{yield this.addNgwLayer(n)}catch(r){console.warn(r)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()})}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const r={qmsId:e};t&&(r.id=t),this.addBaseLayer("QMS",r)}_selectFromNgwVector(e){const t=e.layer;if(!(t.options.selectable&&this.isLayerVisible(t)))return;const r=t.item&&t.item.resource.id,n=e.feature;if(void 0!==r&&n){const e=n.id;if(e){const t={featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]},o={featureCount:1,[r]:t};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(zl(Gl({},o),{resources:[r],sourceType:"vector"}))),o}}}_prepareToIdentify(e){return zl(Gl({},e),{getIdentifyItems:()=>_s(e,!0).map(e=>new cs({feature:e.feature,connector:this.connector}))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return Hl(this,null,function*(){const e=this.getContainer();if(e){const t=yield hs(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}})}};Zl(Jl,"getIcon",function(t={}){var r,n,o,i,s,a;const l=null!=(r=t.shape)?r:"circle",c=null!=(n=t.color)?n:"blue",u=null!=(o=t.strokeColor)?o:"white",h=null!=(i=t.size)?i:12,p=null!=(s=t.rotate)?s:0,d=null!=(a=t.anchor)?a:[h/2,h/2],f=void 0!==t.stroke?Number(t.stroke):.8,y=t.p||e[l]||"circle",m="string"==typeof y?y:y(t),b=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(t.svg||function({width:e,height:t,stroke:r=0,content:n}){const o=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${o} -${o} ${12+r} ${12+r}"\n >${n}</svg>`}({width:h,height:h,stroke:f,content:m}));return b.setAttribute("width",String(h)),b.setAttribute("height",String(h)),b.setAttribute("fill",c),f&&(b.setAttribute("stroke",u),b.setAttribute("stroke-width",String(f))),{type:"icon",iconSize:[h,h],iconAnchor:d,html:(new XMLSerializer).serializeToString(b),rotate:p,svg:b}});let Ql=Jl;function Kl(e){return t=this,r=null,n=function*(){return new Ql(e).onLoad()},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}export{Ql as NgwMap,dl as WebMap,sl as WebMapControls,tl as WebMapLayers,Va as WebMapMain,Kl as createNgwMap,js as createToggleControl,yl as createWebMap,ma as detectGeometryType,ya as findMostFrequentGeomType,fl as getDefaultControls,Is as getWebMap,ba as paintTypeAlias,xs as setWebMap,ga as typeAlias,va as updateGeoJsonAdapterOptions};
1
+ const e={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'};function t(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const o=void 0===r.replace||r.replace;t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{const i=-1!==n.indexOf(r);if(!o&&!i||o){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}})})}function r(e,t,n=!1){let o=e;const i=t,s=Array.isArray(i);let a=s&&[]||{};return s&&Array.isArray(i)?n?(o=o||[],a=a.concat(o),i.forEach((e,t)=>{void 0===a[t]?a[t]=e:"object"==typeof e?a[t]=r(o[t],e,n):-1===o.indexOf(e)&&a.push(e)})):a=i:(o&&"object"==typeof o&&Object.keys(o).forEach(function(e){a[e]=o[e]}),Object.keys(i).forEach(function(e){a[e]="object"==typeof i[e]&&i[e]&&"object"==typeof o[e]&&"object"==typeof i[e]?r(o[e],i[e],n):i[e]})),a}function n(e){return null!=e}function o(e){return"string"==typeof e?!!e:n(e)}function i(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}function s(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}function a(e){return{type:"Polygon",coordinates:[l(e)]}}function l(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const c=Math.PI/180,u=180/Math.PI;function p(e,t,r=10,n=6){const o=r/6371*u,i=o/Math.cos(t*c),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+i*Math.cos(r),c=t+o*Math.sin(r);s.push([l,c])}return s}function h(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:d(e,t));return e===t}function d(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let o=0;o<r.length;o++){if(!h(e[r[o]],t[n[o]],e,t))return!1}return!0}function f(e){const t={};return Object.keys(e).forEach(r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=f(e[r])}),t}function y(e){return"[object Object]"===Object.prototype.toString.call(e)}function m(e){return"[object Array]"===Object.prototype.toString.call(e)}function b(e){return e.replace(/([^:]\/)\/+/g,"$1")}function g(e,t){const r=new URL(e),n=new URLSearchParams(r.search);Object.entries(t).forEach(([e,t])=>{void 0===t?n.delete(e):n.set(e,t)}),n.set("timestamp",String((new Date).getTime()));const o=[...n.entries()].map(([e,t])=>`${e}=${t}`).join("&");return`${r.origin}${r.pathname}?${o}`}const v=/\{ *([\w_-]+) *\}/g;function w(e,t){return e.replace(v,(e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n})}var _=Object.defineProperty,O=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,I=(e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function x(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=w(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach(([e,t])=>{r.push(`${e}=${t}`)});for(const e in t)-1===s.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))L.call(t,r)&&I(e,r,t[r]);if(O)for(var r of O(t))P.call(t,r)&&I(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var j=Object.defineProperty,E=(e,t,r)=>((e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const A=class e{constructor(t={}){var r;E(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,t,r,n,i){let s,a;"object"==typeof r&&"valueToSet"in r?(s=r,n=s.onlyFull,i=s.expirationTime,a=s.props):a=r;const l=this._find(e,a);if(l)return l.value;{let r;r=t instanceof Function?t():t;const s=a&&JSON.parse(JSON.stringify(f(a)));i=i?Date.now()+i:void 0;const l={key:e,value:r,props:s,expirationTime:i};return n&&!o(r)?r:(this.cache.push(l),r instanceof Promise?(r.catch(()=>{this.delete(e,a)}),n&&r.then(t=>(o(t)||this.delete(e,a),t)),r):r)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach(e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)}),e?this.cache.filter(r=>this._filter(r,e,t)).map(e=>e.value):this.cache.map(e=>e.value)}delete(e,t){const r="string"==typeof e?this.cache.filter(r=>this._filter(r,e,t)):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find(r=>this._filter(r,e,t))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return d(e.props||{},f(r))}};E(A,"instance",{});let C=A;function k(){}function M(){M.init.call(this)}function S(e){return void 0===e._maxListeners?M.defaultMaxListeners:e._maxListeners}function T(e,t,r,n){var o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]):(i=e._events=new k,e._eventsCount=0),s){if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(o=S(e))&&o>0&&s.length>o){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function N(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function R(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function $(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}k.prototype=Object.create(null),M.EventEmitter=M,M.usingDomains=!1,M.prototype.domain=void 0,M.prototype._events=void 0,M.prototype._maxListeners=void 0,M.defaultMaxListeners=10,M.init=function(){this.domain=null,M.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new k,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},M.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},M.prototype.getMaxListeners=function(){return S(this)},M.prototype.emit=function(e){var t,r,n,o,i,s,a,l="error"===e;if(s=this._events)l=l&&null==s.error;else if(!l)return!1;if(a=this.domain,l){if(t=arguments[1],!a){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=$(e,n),i=0;i<n;++i)o[i].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=$(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=$(e,i),a=0;a<i;++a)s[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,a=$(e,s),l=0;l<s;++l)a[l].call(r,n,o,i)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=$(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,u,this,o)}return!0},M.prototype.on=M.prototype.addListener=function(e,t){return T(this,e,t,!1)},M.prototype.prependListener=function(e,t){return T(this,e,t,!0)},M.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,N(this,e,t)),this},M.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,N(this,e,t)),this},M.prototype.removeListener=function(e,t){var r,n,o,i,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0===--this._eventsCount?this._events=new k:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0===--this._eventsCount)return this._events=new k,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,s||t)}return this},M.prototype.off=function(e,t){return this.removeListener(e,t)},M.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new k,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new k:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new k,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},M.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},M.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):R.call(e,t)},M.prototype.listenerCount=R,M.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var F="3.0.1";class B extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var q=Object.defineProperty,D=(e,t,r)=>((e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class U extends Error{constructor(e){super(),D(this,"name","NgwError"),D(this,"title"),D(this,"message"),D(this,"detail"),D(this,"exception"),D(this,"status_code"),D(this,"data"),D(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,U.prototype)}}var V=Object.defineProperty,G=(e,t,r)=>((e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class z extends U{constructor(e){super(e),G(this,"name","InsufficientPermissionsError"),G(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,z.prototype)}}var Z=Object.defineProperty,W=(e,t,r)=>((e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let J=class e extends U{constructor(t){super(t),W(this,"message","There is no response from the server or problem connecting to server."),W(this,"title","Network error"),W(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var H=Object.defineProperty,Q=(e,t,r)=>((e,t,r)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class K extends Error{constructor(e){super(),Q(this,"name","NetworkError"),Object.setPrototypeOf(this,K.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var X=Object.defineProperty,Y=(e,t,r)=>((e,t,r)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ee extends U{constructor(e){super(e),Y(this,"name","ResourceNotFoundError"),Y(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ee.prototype)}}var te=Object.freeze({__proto__:null,AbortError:B,InsufficientPermissionsError:z,NetworkError:K,NetworksResponseError:J,NgwError:U,ResourceNotFoundError:ee,extractError:function(e){if(y(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new J({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!y(e)&&(e.status_code&&e.exception&&e.title)}}),re=Object.defineProperty,ne=(e,t,r)=>((e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class oe extends Error{constructor(e){super(e||"Something went wrong."),ne(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,oe)}}class ie extends oe{constructor(e){super(e||"There is no response from the server or problem connecting to server."),ne(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class se extends oe{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ae extends oe{constructor(e){super(e.message),ne(this,"detail"),ne(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class le extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),ne(this,"title"),ne(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,le)}}class ce extends le{constructor(e){super("Long-running request was cancelled.",e)}}class ue extends le{constructor(e){super(void 0,e)}}var pe=Object.defineProperty,he=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,ye=(e,t,r)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,me=(e,t)=>{for(var r in t||(t={}))de.call(t,r)&&ye(e,r,t[r]);if(he)for(var r of he(t))fe.call(t,r)&&ye(e,r,t[r]);return e},be=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function ge(e){return be(this,null,function*(){const t=yield function(e){return be(this,null,function*(){try{return e.json()}catch(t){throw new Error}})}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise(t=>setTimeout(t,e));let a=!1,l=!1;for(;!l;){let e,t;yield s(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(c){a=!0;continue}switch(t.status){case void 0:throw new le(void 0,t);case"ready":l=!0;break;case"cancelled":throw new ce(t);case"failed":throw new ue(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new le(void 0,t)}}return i})}const ve=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function we(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function _e(e,t,r){return be(this,null,function*(){var n,o;const i=me(me({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:s,responseType:a,cacheProps:l,cacheName:c,lunkwill:u,cache:p,query:h,json:d}=i,y=((e,t)=>{var r={};for(var n in e)de.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&he)for(var n of he(e))t.indexOf(n)<0&&fe.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),s&&(y.credentials="include");let m=!1;void 0!==u&&(u.toHeaders(y.headers||{}),m=!0);const b=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=we(e,h),v=()=>be(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new ie}if(m&&function(e){const t=e.headers.get("content-type");return null!=t&&t.includes("application/vnd.lunkwill.request-summary+json")}(e)){const t=yield ge(e);if(b)return t;e=yield function(e){return be(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new ie}})}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&ve.test(t);if("blob"===a||o)n=yield e.blob();else{if(!r)throw new se;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof se)throw o;throw new se}if(400<=e.status&&e.status<=599)throw new ae(n);return n});if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==p){const e=l||me({},f({withCredentials:s,responseType:a}));return r.add(c||g,v,{props:e,expirationTime:p?void 0:500})}}else{["api/feature_layer/identify"].every(t=>!e.includes(t))&&r.clean()}return v()})}var Oe=Object.defineProperty,Le=Object.defineProperties,Pe=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Ee=(e,t,r)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ae=(e,t)=>{for(var r in t||(t={}))xe.call(t,r)&&Ee(e,r,t[r]);if(Ie)for(var r of Ie(t))je.call(t,r)&&Ee(e,r,t[r]);return e},Ce=(e,t)=>{var r={};for(var n in e)xe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ie)for(var n of Ie(e))t.indexOf(n)<0&&je.call(e,n)&&(r[n]=e[n]);return r};function ke(e,t,r,...n){const[o,...i]=r[e],s=n[0];let a;if(void 0===s)a=[];else if("object"==typeof s&&null!==s){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");a=[];for(const[e,t]of Object.entries(s))a[i.indexOf(e)]=String(t)}else a=n.map(e=>String(e));return b(t+o.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)}))}function Me(e,t,...r){const n={url:n=>{return o=null,i=null,s=function*(){var o;const i=yield t.connect();return we(ke(e,null!=(o=t.options.baseUrl)?o:"",i,...r),null==n?void 0:n.query)},new Promise((e,t)=>{var r=e=>{try{a(s.next(e))}catch(r){t(r)}},n=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((s=s.apply(o,i)).next())});var o,i,s}},o=["get","post","put","delete","patch"];for(const i of o){const o=n=>{var o;const s=n||{},{headers:a}=s,l=Ce(s,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new B;return t.connect().then(n=>{var o;const s=ke(e,null!=(o=t.options.baseUrl)?o:"",n,...r),c=f(Ae(Ae({},t.getAuthorizationHeaders()),null!=a?a:{}));return _e(s,(u=Ae({headers:c},l),Le(u,Pe({method:i}))),t.cache);var u})};n[i]=o}return n}function Se(e){return"[object Object]"===Object.prototype.toString.call(e)}let Te;Te=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new U(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new K(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&i.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o(()=>{i.abort()}),i.send(l)};const Ne=[];function Re(e){Ne.push(e)}var $e=Object.defineProperty,Fe=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,qe=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,Ve=(e,t,r)=>t in e?$e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ge=(e,t)=>{for(var r in t||(t={}))De.call(t,r)&&Ve(e,r,t[r]);if(qe)for(var r of qe(t))Ue.call(t,r)&&Ve(e,r,t[r]);return e},ze=(e,t,r)=>Ve(e,"symbol"!=typeof t?t+"":t,r),Ze=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});let We=0,Je=0;class He{constructor(e){this.options=e,ze(this,"id",We++),ze(this,"emitter",new M),ze(this,"user"),ze(this,"cache"),ze(this,"withCredentials"),ze(this,"routeCache"),ze(this,"client",`NextGIS-NGW-Connector/${F}`),ze(this,"routeStr","/api/component/pyramid/route"),ze(this,"activeRequests",{}),ze(this,"requestTransform");const t=function(e){return Ne.find(t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return d(t.options.auth,e.auth)}})}(e);if(this.cache=new C({namespace:e.cacheId}),this.routeCache=new C({namespace:"routecache"}),t)return t;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),Re(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Re(this)}connect(){return Ze(this,arguments,function*({signal:e}={}){const t=this.options.auth;if(t){const{login:e,password:r}=t;e&&r&&(yield this._login({login:e,password:r}))}const r=`${this.routeStr}?client=${this.client}`;return this.routeCache.add(this.options.baseUrl||String(this.id),()=>this.makeQuery(r,null,{signal:e,cache:!1}))})}login(e,t){return this.logout(),Re(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Ne.indexOf(e);-1!==t&&Ne.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return Ze(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ge({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)})}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e;return window.btoa(`${t}:${r}`)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Ge({},this.activeRequests)}route(e,...t){return Me(e,this,...t)}makeQuery(e,t){return Ze(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)De.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&qe)for(var n of qe(e))t.indexOf(n)<0&&Ue.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=w(e,r)}e=encodeURI(b(e)),r=Ge({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:p}=r,h=new AbortController,d=h.signal;if(i){if(i.aborted)throw new B;i.addEventListener("abort",()=>{h.abort()})}r.signal=d;const y=()=>Ze(this,null,function*(){const t=Je++;this.activeRequests[t]=h;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===s&&!1!==o){const r=c||(m=Ge({},f({headers:a,withCredentials:p,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Fe(m,Be({params:t})));return this.cache.add(l||e,y,{props:r,expirationTime:o?void 0:500})}var m;return y()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Ge(Ge({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;Te(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new B)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return Ze(this,null,function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}})}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof U){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ee(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new z(e)}return e}}ze(He,"errors",te);const Qe=["description"];function Ke(e,t=""){t=t?t+"__":"";const r={};for(const[o,i]of Object.entries(e))if(-1===Qe.indexOf(o))if(Se(i))if("owner_user"===o){const e=Ke(i,o);Object.assign(r,e)}else"parent"===o&&"id"in i&&(r.parent_id=i.id);else n(i)&&(r[t+o]=i);return r}var Xe=Object.defineProperty,Ye=Object.defineProperties,et=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,ot=(e,t,r)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,it=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&ot(e,r,t[r]);if(tt)for(var r of tt(t))nt.call(t,r)&&ot(e,r,t[r]);return e},st=(e,t)=>Ye(e,et(t)),at=(e,t,r)=>ot(e,"symbol"!=typeof t?t+"":t,r),lt=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class ct{constructor({connector:e,cacheId:t}){at(this,"cache"),at(this,"connector"),this.connector=e,this.cache=new C({namespace:t})}getOne(e,t){const r=it({},t);return"string"==typeof e||"number"==typeof e||Se(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Se(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then(e=>{if(e)return e;throw new ee})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Se(e)?this.getOne(e,t).then(e=>{if(e)return e.resource.id}):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then(e=>{if(void 0===e)throw new Error;return e})}getMany(e,t){return this._resourceCacheFilter(e).then(r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,Ke(e)),this.connector.route("resource.search").get(st(it({},t),{query:it({serialization:"full"},r)})).then(e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e})}return r})}getParent(e,t){return this.getOne(e,t).then(e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)})}getChildrenOf(e,t){return this.getIdOrFail(e).then(e=>this._getChildrenOf(e,t))}update(e,t){return this.getId(e).then(e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})})}delete(e){return this.getId(e).then(e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then(()=>{this._cleanResourceItemCache(e)})})}_getChildrenOf(e,t){return lt(this,arguments,function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(st(it({},t),{query:{parent:n}})),i=[];for(const s of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(s),{id:s.resource.id}),r.push(s),(null==t?void 0:t.recursive)&&s.resource.children&&i.push(this._getChildrenOf(s.resource.id,t,r));return i.length?Promise.all(i).then(()=>r):r})}_cleanResourceItemCache(e){return lt(this,null,function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)})}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then(e=>e[0])}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then(t=>(t.filter(t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:n(e.id)&&n(t.resource.id)?e.id===t.resource.id:d(e,t.resource)}),[]))}}var ut=Object.defineProperty,pt=(e,t,r)=>((e,t,r)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ht extends He{constructor(e){super(e),pt(this,"resources"),this.resources=new ct({connector:this,cacheId:e.cacheId})}static create(e){return new this(e)}clearCache(){super.clearCache(),this.resources.cache.clean()}apiRequest(e,t={},r={}){var n;return x({name:e,params:f(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}var dt=Object.defineProperty,ft=Object.defineProperties,yt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable,vt=(e,t,r)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))bt.call(t,r)&&vt(e,r,t[r]);if(mt)for(var r of mt(t))gt.call(t,r)&&vt(e,r,t[r]);return e},_t=(e,t)=>ft(e,yt(t));function Ot(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,o=e.extent_right;if(t&&r&&n&&o){const e=[r,t,o,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function Lt({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.route("layer.extent",{id:Number(e)}).get({cache:r,signal:n}).then(e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}})}function Pt(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then(t=>{if(t)return It(t,e.connector,e)})}function It(e,t,r){if(e.webmap)return Promise.resolve(Ot(e.webmap));{const n=e.resource;return n.cls&&n.parent&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id,r).then(e=>{if(e)return Lt(_t(wt({},r),{resourceId:e.resource.id,connector:t}))}):Lt(_t(wt({},r),{resourceId:n.id,connector:t}))}}var xt=Object.defineProperty,jt=(e,t,r)=>((e,t,r)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Et=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class At{constructor(){jt(this,"item"),jt(this,"connector"),jt(this,"_extent")}getExtent(){return Et(this,null,function*(){return this.getBounds()})}getBounds(e){return Et(this,null,function*(){return this._extent?this._extent:this.item?(this._extent=yield It(this.item,this.connector,e),this._extent):void 0})}}function Ct(e,t){return r=this,n=null,o=function*(){const r=e.resource,n=r;let{keyname:o,resourceId:i}=e;if(r&&("string"==typeof r?o=r:i="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield Ct(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i},new Promise((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())});var r,n,o}var kt=Object.defineProperty,Mt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Nt=(e,t,r)=>t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Rt=(e,t,r)=>Nt(e,"symbol"!=typeof t?t+"":t,r),$t=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Ft(e){return $t(this,arguments,function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){Rt(this,"options",{}),Rt(this,"layer",[]),Rt(this,"_removed",!1),Rt(this,"_creatingInProgress",!1)}addLayer(){return this.layer}removeLayer(){this._removed=!0;for(const t of this.layer)e.removeLayer(t)}destroyed(){return this._removed}showLayer(){return $t(this,null,function*(){if(this.options.visibility=!0,this.layer.length)for(const t of this.layer)yield e.showLayer(t);else yield this.loadLayer()})}hideLayer(){return $t(this,null,function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)})}loadLayer(){return $t(this,null,function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const o=yield n(this);if(o){const n=new o(e.mapAdapter.map,((e,t)=>{for(var r in t||(t={}))St.call(t,r)&&Nt(e,r,t[r]);if(Mt)for(var r of Mt(t))Tt.call(t,r)&&Nt(e,r,t[r]);return e})({},t)),i=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=i,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer})}}})}function Bt(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){return Ft({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>ts({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)})},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var qt=Object.defineProperty,Dt=Object.getOwnPropertySymbols,Ut=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable,Gt=(e,t,r)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function zt(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const Zt={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>zt(e,t),ilike:(e,t)=>zt(e,t,!0)};function Wt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Jt(e,t){const r=((e,t)=>{for(var r in t||(t={}))Ut.call(t,r)&&Gt(e,r,t[r]);if(Dt)for(var r of Dt(t))Vt.call(t,r)&&Gt(e,r,t[r]);return e})({},e.properties);return!!r&&(r.$id=e.id,Ht(r,t))}function Ht(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Wt(t)){const[r,n,o]=t,i=Zt[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,(n,i)=>(t=e[i],r.replace(i,o)));return i(t,n)}return i(e[r],o)}return!1}return Ht(e,t)},o=t.filter(e=>Array.isArray(e));return"any"===r?o.some(n):o.every(n)}var Qt=Object.defineProperty,Kt=Object.defineProperties,Xt=Object.getOwnPropertyDescriptors,Yt=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,rr=(e,t,r)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nr=(e,t)=>{for(var r in t||(t={}))er.call(t,r)&&rr(e,r,t[r]);if(Yt)for(var r of Yt(t))tr.call(t,r)&&rr(e,r,t[r]);return e},or=(e,t)=>Kt(e,Xt(t)),ir=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const sr={srs:4326,geom_format:"geojson",dt_format:"iso"};function ar(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function lr(e,t){const{extensions:r,geom:o,fields:i,srs:s,ilike:a,like:l}=t;e.extensions=r||[],i&&(e.fields=i),void 0!==o&&(e.geom=o,o||(delete e.srs,delete e.geom_format)),n(a)?e.ilike=a:n(l)&&(e.like=l),n(s)&&(e.srs=s)}function cr(e){return ir(this,null,function*(){const t=pr(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o})}function ur(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,(e,t,r,n)=>(o=t,i=n,r))}__${r}`,o+n+i]}function pr(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter(e=>Array.isArray(e));if("any"===s)for(const l of a)Wt(l)?t.push(dr(or(nr({},e),{paramList:[...r,...i,ur(l)]}))):pr(or(nr({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)Wt(e)?n.push(ur(e)):o.push(e);if(o.length)for(const i of o)pr(or(nr({},e),{filters:i}),t,[...r,...n]);else t.push(dr(or(nr({},e),{paramList:[...r,...i,...n]})))}return t}function hr(e){return`POLYGON((${e.map(([e,t])=>{const[r,n]=s(e,t).map(e=>Math.round(1*(e+Number.EPSILON))/1);return r+" "+n}).join(", ")}))`}function dr(e){const t=nr({},sr),{limit:r,query:n,cache:o,signal:i,offset:s,orderBy:a,paramList:c,connector:u,geomFormat:p,intersects:h,resourceId:d}=e;if("number"==typeof r&&r!==Number.POSITIVE_INFINITY&&(t.limit=r),s&&(t.offset=s),p&&(t.geom_format=p),lr(t,e),a&&(t.order_by=a.join(",")),Array.isArray(h)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every(e=>"number"==typeof e)}(h)?l(h):h;t.intersects=hr(e)}else"string"==typeof h&&(t.intersects=h);return c&&Object.assign(t,function(e){return e.reduce((e,[t,r])=>(e[t]=r,e),{})}(c)),u.route("feature_layer.feature.collection",{id:Number(d)}).get({query:nr(nr({},t),n),cache:o,signal:i})}function fr(e){let t;for(t in e){const r=e[t];if(y(r)){const o=r;if(n(o.year)&&n(o.month)&&n(o.day)){const r=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach(e=>{r.push(e)}),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var yr=Object.defineProperty,mr=Object.defineProperties,br=Object.getOwnPropertyDescriptors,gr=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,wr=Object.prototype.propertyIsEnumerable,_r=(e,t,r)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Or=(e,t)=>{for(var r in t||(t={}))vr.call(t,r)&&_r(e,r,t[r]);if(gr)for(var r of gr(t))wr.call(t,r)&&_r(e,r,t[r]);return e},Lr=(e,t)=>mr(e,br(t)),Pr=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Ir(e){return Pr(this,null,function*(){var t;const r=e.filters;if(r){let n=yield cr(Lr(Or({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:xr(r))&&(n=n.filter(e=>Ht(fr(Lr(Or({},e.fields),{id:e.id})),r))),n}return dr(e)})}function xr(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(m(r)){if(xr(r))return!0}}return!1}function jr({options:e,webMap:t,baseUrl:r}){var n;let o,i=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===i){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const o=t+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:t=>(r&&(t.nd=r),Oo(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});i="TILE"}if("WMS"===i){o=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:o,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===i)return o=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:o,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===i)return o=r+`/api/resource/${a}/terrain_provider`,{url:o,adapter:i};if("MODEL_3D"===i)return o=r+`/api/component/model_3d/${a}/data.glb`,{url:o};if("TILE"===i)return o=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:o,adapter:i}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var Er=Object.defineProperty,Ar=Object.defineProperties,Cr=Object.getOwnPropertyDescriptors,kr=Object.getOwnPropertySymbols,Mr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,Tr=(e,t,r)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nr=(e,t)=>{for(var r in t||(t={}))Mr.call(t,r)&&Tr(e,r,t[r]);if(kr)for(var r of kr(t))Sr.call(t,r)&&Tr(e,r,t[r]);return e},Rr=(e,t)=>Ar(e,Cr(t)),$r=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Fr(e){return $r(this,null,function*(){const t=Nr({},sr);lr(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Rr(Nr({},e),{query:t}));return Rr(Nr({},r),{toGeojson:()=>$r(null,null,function*(){if(r.geom)return ar(r);{const t=(yield Fr(Rr(Nr({},e),{geom:!0,fields:null,extensions:null}))).geom;return ar(Rr(Nr({},r),{geom:t}))}})})})}var Br=Object.defineProperty,qr=Object.getOwnPropertySymbols,Dr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Vr=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Gr=(e,t,r)=>Vr(e,"symbol"!=typeof t?t+"":t,r);class zr{constructor(e){this.options=e,Gr(this,"name"),Gr(this,"resourceId"),Gr(this,"item"),Gr(this,"_extent"),this.resourceId=e.resourceId;const t=e.item;this.item=t,this.name=e.labelField&&t.fields?t.fields[e.labelField]:String(t.id)}extent(e){return this._extent?Promise.resolve(this._extent):this.options.connector.route("feature_layer.feature.item_extent",{id:this.resourceId,fid:this.item.id}).get(e).then(e=>{if(e.extent){const{minLat:t,minLon:r,maxLat:n,maxLon:o}=e.extent,i=[r,t,o,n];return this._extent=i,i}})}geoJson(e){return this.item.geom?Promise.resolve(ar(this.item)):Fr(((e,t)=>{for(var r in t||(t={}))Dr.call(t,r)&&Vr(e,r,t[r]);if(qr)for(var r of qr(t))Ur.call(t,r)&&Vr(e,r,t[r]);return e})({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null},e)).then(e=>(this.item.geom=e.geom,ar(this.item)))}}var Zr=Object.defineProperty,Wr=(e,t,r)=>((e,t,r)=>t in e?Zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Jr{constructor(e,t,r){Wr(this,"options"),Wr(this,"emitter",new M),Wr(this,"name"),Wr(this,"item"),Wr(this,"_blocked",!1),Wr(this,"_container"),Wr(this,"__value"),Wr(this,"_removeEventsListener"),this.item=t,this.options=Object.assign({},r),this.name=e,this._value=this.getProperty()}set _value(e){this.__value=e}get _value(){return this.__value}getProperty(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value}getParents(){return this.item.tree.getParents()||[]}getParent(){return this.item.tree.getParent()}getChildren(){return this.item.tree.getChildren()}isGroup(){return this.item.tree.getDescendants().length}isBlocked(){if(void 0!==this._blocked)return this._blocked;const e=this.item.tree.getParents();return this._blocked=this._calculateBlockedStatus(e),this._blocked}set(e,t){this._value=this._prepareValue(e),this.update(this._value,t),this._fireChangeEvent(this._value,t)}get(){return this.getValue()}update(e,t){this._callOnSet(e,t)}getContainer(){return this._container}destroy(){if(this._container){const e=this._container.parentNode;e&&e.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()}getValue(){return void 0!==this._value?this._value:this.getProperty()}_prepareValue(e){return e}_callOnSet(e,t){this.options.onSet&&this.options.onSet.call(this,e,t,this.item)}_fireChangeEvent(e,t){if(this.emitter){e=void 0!==e?e:this.getValue(),this.emitter.emit("change",{value:e,options:t});this.item.tree.getParents().forEach(r=>{const n=r.properties&&r.properties.property(this.name);n&&n.emitter.emit("change-tree",{value:e,options:t,item:this.item})})}}_calculateBlockedStatus(e){return e.some(e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()})}}var Hr=Object.defineProperty,Qr=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Xr=Object.prototype.propertyIsEnumerable,Yr=(e,t,r)=>t in e?Hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,en=(e,t)=>{for(var r in t||(t={}))Kr.call(t,r)&&Yr(e,r,t[r]);if(Qr)for(var r of Qr(t))Xr.call(t,r)&&Yr(e,r,t[r]);return e};const tn=class e extends Jr{constructor(t,r,n){super(t,r,en(en({},e.options),n)),this.set(this.get())}update(e,t){if(e){if(t&&t.bubble||this.options.bubble){this.unBlock(t);const r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(e,Object.assign({},t,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(t)}else this._turnOff(t);(t&&t.propagation||this.options.propagation)&&this._propagation(e,t)}getHierarchyValue(){return this.get()&&this.getParents().every(e=>{const t=e.properties&&e.properties.get(this.name);return t&&t.get()})}block(e){this._blocked=!0,this._block(e)}unBlock(e){this._blocked=!1;this.getValue()&&this._unBlock(e)}blockChild(e){this.item.tree.getDescendants().forEach(t=>this._blockChild(t,e))}unblockChild(e){this.item.tree.getChildren().forEach(t=>this._unBlockChild(t,e))}_prepareValue(e){return e}_turnOff(e){this.options.turnOff&&this.options.turnOff.call(this,e),this._callOnSet(!1,e),this.options.hierarchy&&this.isGroup()&&this.blockChild(e)}_turnOn(e){this.options.turnOn&&this.options.turnOn.call(this,e),this._callOnSet(!0,e),this.options.hierarchy&&this.isGroup()&&this.unblockChild(e)}_block(e){this._turnOff(e)}_unBlock(e){this._turnOn(e)}_blockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.block&&r.block(en({silent:!0},t||{}))}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(en({silent:!0},t||{}))}_propagation(e,t){if(this.isGroup()){const r=this.item.tree.getChildren();for(let n=0;n<r.length;n++){const o=r[n],i=o.properties&&o.properties.property(this.name);i&&i.set(e,en(en({},t),{propagation:!0,bubble:!1}))}}}};Yr(tn,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let rn=tn;var nn=Object.defineProperty,on=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable,ln=(e,t,r)=>t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,cn=(e,t,r)=>ln(e,"symbol"!=typeof t?t+"":t,r);const un=class e{constructor(e,t){this.item=e,cn(this,"options",{}),cn(this,"_properties",{}),cn(this,"_propertiesList",[]),t&&t.forEach(this._setPropertyHandler.bind(this))}add(e){this._setPropertyHandler(e)}update(){this.list().forEach(e=>e.update())}get(e){const t=this.property(e);return t?t.get():void 0}set(e,t,r){const n=this.property(e);n&&n.getValue()!==t&&n.set(t,r)}property(e){return this._properties[e]}list(){return this._propertiesList.map(e=>this._properties[e])}destroy(){for(const e in this._properties){const t=this.property(e);t&&t.destroy&&t.destroy()}this._properties={},this._propertiesList=[]}_setPropertyHandler(e){const t=this._getHandler(e);if(t&&e.name){const r=((e,t)=>{for(var r in t||(t={}))sn.call(t,r)&&ln(e,r,t[r]);if(on)for(var r of on(t))an.call(t,r)&&ln(e,r,t[r]);return e})({},e);this._properties[e.name]=new t(e.name,this.item,r),this._propertiesList.push(e.name)}}_getHandler(t){const r=t.handler;return!r&&t.type?"boolean"===t.type?e.handlers.CheckProperty:e.handlers.BaseProperty:r}};cn(un,"handlers",{CheckProperty:rn});let pn=un;function hn(e,t,r,n){return!!yn(e,t,r,mn)}function dn(e,t,r,n){return yn(e,t,r,bn)}function fn(e,t="children"){let r=[];const n=("function"==typeof t?t:e=>e[t])(e);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function yn(e,t=e=>!!e,r="children",n,o){return n(e,"function"==typeof t?t:e=>Ht(e,t),r)}function mn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(t(e))return e;const n=fn(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){const e=mn(o[i],t,r,n);if(e)return e}}function bn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{t(e)&&n.push(e);const i=fn(e,r);i&&(o=i)}for(let i=0;i<o.length;i++)o[i]&&bn(o[i],t,r,n);return n}function gn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(!t(e))return!1;const n=fn(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){if(!gn(o[i],t,r,n))return!1}return!0}var vn=Object.defineProperty,wn=(e,t,r)=>((e,t,r)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class _n{constructor(e){wn(this,"item"),wn(this,"_children",[]),wn(this,"_parent"),this.item=e}setParent(e){this._parent=e}addChild(e){this._children.push(e)}getParent(){return this._parent}getParents(e){const t=this.getParent();return t?dn(t,e,e=>e.tree.getParent()):[]}getRoot(){let e=this.getParent(),t=e;for(;e;)e=e.tree.getParent(),e&&(t=e);return t}find(e){return yn(this._children,e,e=>e.tree.getChildren(),mn)}every(e){return!!yn(this._children,e,e=>e.tree.getChildren(),gn)}some(e){return hn(this._children,e,e=>e.tree.getChildren())}all(e){return this.getDescendants(e)}getDescendants(e){return dn(this._children,e,e=>e.tree.getChildren())}getChildren(){return[...this._children]}}var On=Object.defineProperty,Ln=Object.getOwnPropertySymbols,Pn=Object.prototype.hasOwnProperty,In=Object.prototype.propertyIsEnumerable,xn=(e,t,r)=>t in e?On(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jn=(e,t,r)=>xn(e,"symbol"!=typeof t?t+"":t,r);let En=0;class An{constructor(e){jn(this,"options",{}),jn(this,"properties"),jn(this,"tree"),jn(this,"id",En),En+=1,this.options=((e,t)=>{for(var r in t||(t={}))Pn.call(t,r)&&xn(e,r,t[r]);if(Ln)for(var r of Ln(t))In.call(t,r)&&xn(e,r,t[r]);return e})({},e),this.tree=new _n(this)}initProperties(){this.properties=new pn(this,this.options.properties)}}function Cn(e,t){return{[`symbols[${e}]`]:t.join(",")||void 0}}var kn=Object.defineProperty,Mn=Object.defineProperties,Sn=Object.getOwnPropertyDescriptors,Tn=Object.getOwnPropertySymbols,Nn=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable,$n=(e,t,r)=>t in e?kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fn=(e,t)=>{for(var r in t||(t={}))Nn.call(t,r)&&$n(e,r,t[r]);if(Tn)for(var r of Tn(t))Rn.call(t,r)&&$n(e,r,t[r]);return e},Bn=(e,t,r)=>$n(e,"symbol"!=typeof t?t+"":t,r);class qn{constructor({legendSymbols:e,resourceId:t,connector:r,layerId:n,legend:o,webMap:i,layer:s,onSymbolRenderChange:a}){Bn(this,"layerId"),Bn(this,"layer"),Bn(this,"resourceId"),Bn(this,"legendSymbols","expand"),Bn(this,"legend"),Bn(this,"layerVisibility",!0),Bn(this,"onSymbolRenderChange"),Bn(this,"webMap"),Bn(this,"connector"),e&&(this.legendSymbols=e),this.connector=r,this.layer=s,this.layerId=n,o&&(this.legend=this.createLegend(o)),this.resourceId=t,this.webMap=i,this.onSymbolRenderChange=a}attachLayer(e){this.layerId=String(e.id),this.layer=e}create(){return e=this,t=arguments,r=function*(e={}){if(this.connector){const t=yield this.connector.route("render.legend_symbols",{id:this.resourceId}).get(Fn({},e));return this.legend=t,this.createLegend(t)}},new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});var e,t,r}createLegend(e){return e.map(e=>{return t=Fn({},e),Mn(t,Sn({name:e.display_name,symbol:e.icon}));var t})}setSymbolRender(e,t){if(this.legend){const r=this.legend.find(t=>t.index===e);if(r){if(r.render!==t){r.render=t;const e=this.legend.filter(e=>e.render).map(e=>e.index);this.setLegendSymbol(e),this.onSymbolRenderChange&&this.onSymbolRenderChange(e)}}}}setLegendSymbol(e){const t=this._consolidateIntervals(e);t.length||this._hideLayer(),this.layer.updateLayer&&this.layer.updateLayer({params:Fn({},Cn(this.resourceId,t))}),t.length&&this._showLayer()}_hideLayer(){this.layer.options.id&&this.webMap.mapAdapter.hideLayer(this.layer.layer)}_showLayer(){this.layer.options.id&&this.layerVisibility&&this.webMap.showLayer(this.layer.options.id,{silent:!0})}_consolidateIntervals(e){const t=e.slice().sort((e,t)=>e-t),r=[];let n=t[0],o=n;for(let i=1;i<=t.length;i++)t[i]===o+1?o=t[i]:(r.push(n===o?`${n}`:`${n}-${o}`),n=t[i],o=n);return r}}var Dn=Object.defineProperty,Un=Object.defineProperties,Vn=Object.getOwnPropertyDescriptors,Gn=Object.getOwnPropertySymbols,zn=Object.prototype.hasOwnProperty,Zn=Object.prototype.propertyIsEnumerable,Wn=(e,t,r)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Jn=(e,t)=>{for(var r in t||(t={}))zn.call(t,r)&&Wn(e,r,t[r]);if(Gn)for(var r of Gn(t))Zn.call(t,r)&&Wn(e,r,t[r]);return e},Hn=(e,t)=>Un(e,Vn(t)),Qn=(e,t,r)=>Wn(e,"symbol"!=typeof t?t+"":t,r),Kn=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const Xn=class e extends An{constructor({webMap:t,item:r,options:n,connector:o,parent:i,noInit:s}){if(super(Jn(Jn({},e.options),n)),Qn(this,"item"),Qn(this,"webMap"),Qn(this,"connector"),Qn(this,"layer"),Qn(this,"legend"),Qn(this,"emitter",new M),Qn(this,"_rootDescendantsCount",0),this.webMap=t,o&&(this.connector=o),i&&this.tree.setParent(i),this.item=r,"root"===this.item.item_type)this._rootDescendantsCount=this._sumUp(this.item.children);else{const e=this.tree.getRoot();e&&(this._rootDescendantsCount=e._rootDescendantsCount)}this.initProperties(),s||this._init(r)}static create(t,r,n,o,i){return Kn(this,null,function*(){const s=new e({webMap:t,item:r,options:n,connector:o,parent:i,noInit:!0});return yield s._init(r),s})}initItem(e){return"group"===e.item_type||"root"===e.item_type?this.initGroupItem(e):this.initLayerItem(e)}bringToFront(){}fit(){}getLayer(){return this.layer}getLegend(e){return Kn(this,null,function*(){var t,r;const n=null==(t=this.layer)?void 0:t.id;if(void 0!==n){if(this.connector&&"resourceId"in this.item){const t=Number(this.item.resourceId);if("layer"===this.item.item_type&&this.layer){const o=new qn({connector:this.connector,layerId:n,layer:this.layer,resourceId:t,webMap:this.webMap,legendSymbols:null!=(r=this.item.legend_symbols)?r:void 0,onSymbolRenderChange:e=>{this.webMap.emitter.emit("event-symbol-render:change",{layerId:n,resourceId:t,indexes:e})}});return yield o.create(e),[o]}return[]}}return[]})}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=Hn(Jn({visibility:!1,name:e.display_name},this.options),{params:{resource:"resourceId"in this.item?this.item.resourceId:void 0,item:this.item}});if(delete n.id,this.options.order){const t=String(this.options.drawOrderEnabled&&"draw_order_position"in e&&null!=e.draw_order_position?this._rootDescendantsCount-e.draw_order_position:this.id).padStart(4,"0");n.order=Number((0|this.options.order)+"."+t)}if(this.options.popupOptions&&(n.popupOptions=this.options.popupOptions),"layer"===e.item_type){const{maxZoom:t,minZoom:r}=this._getZoomRange(e);Object.assign(n,Hn(Jn({updateWmsParams:e.updateWmsParams},n),{url:e.url,maxZoom:t,minZoom:r,minScale:e.layer_min_scale_denom,maxScale:e.layer_max_scale_denom,interactive:e.layer_identifiable}))}return void 0!==r&&(n.opacity=r),n}getChildren(e){return[...e.children].reverse()}_mapScaleToZoomLevel(e){return function(e,t=0){const r=t,n=function(){if(void 0===Po){const e=document.createElement("div");e.style.cssText="position: absolute; left: -100%; top: -100%; width: 100cm;",document.body.appendChild(e);const t=e.offsetWidth;document.body.removeChild(e),Po=t}return Po}()*function(e){return 12756274*Math.PI*Math.cos(e*Math.PI/180)}(r)/e;return function(e){return Math.log(e/256)/Math.LN2}(n)}(e)}initGroupItem(e){if(e.children&&e.children.length){const t=this.getChildren(e);for(const e of t){const t=new this.constructor({webMap:this.webMap,item:e,options:this.options,connector:this.connector,parent:this});this.tree.addChild(t)}}return Promise.resolve()}initLayerItem(t){const r=this.getItemOptions(t),n=e=>{t._layer=e,this.layer=e;this.properties.get("visibility")&&this.properties.set("visibility",!0),null!=r.opacity&&this.webMap.setLayerOpacity(e,r.opacity)};let o;if("layer"===t.item_type)o=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){o=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return o?this.webMap.addLayer(o,r).then(e=>{this.webMap.emitter.on(`layer-${e.id}:toggle`,t=>{const r=this.properties.get("visibility"),n=this.webMap.isLayerVisible(e);r!==n&&this.properties.set("visibility",n)}),n(e)}):t._layer?Promise.resolve(n(t._layer)):Promise.reject("No layer added")}_getZoomRange(e){const t=this.options.minZoom,r=this.options.maxZoom,n=e.layer_min_scale_denom?this._mapScaleToZoomLevel(e.layer_min_scale_denom):void 0,o=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,i=[t,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max(...i):void 0,maxZoom:s.length?Math.min(...s):void 0}}_init(e){this.initItem(e).then(()=>{this.emitter.emit("init")})}_sumUp(e,t=0){for(const r of e)"layer"===r.item_type?(t+=1,r.draw_order_position=r.draw_order_position||t):"group"===r.item_type&&(t=this._sumUp(r.children,t));return t}};Qn(Xn,"GetAdapterFromLayerType",{}),Qn(Xn,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return hn(e.item,e=>"layer_enabled"in e&&e.layer_enabled,e=>e.children);if("layer"===e.item.item_type)return e.item.layer_enabled}return!1},onSet(e,t,r){r&&"layer"===r.item.item_type&&(r.layer&&(e?r.webMap.showLayer(r.layer,t):r.webMap.hideLayer(r.layer,t)),r.item.layer_enabled=e)}},{name:"opacity",handler:class extends Jr{getProperty(){const e=this.item.layer;return e&&e&&e.options&&null!=e.options.opacity?e.options.opacity:1}update(e,t){if(t=t||{},this.isGroup()){this._value=this._prepareValue(e,t);const r=this.getChildren();for(const n of r){const r=n.properties.property(this.name);r&&(t.propagation?r.set(e,t):r.update(r.get(),t))}}const r=this.item.layer;if(r){const t=this.getParents().reduce((e,t)=>{const r=t.properties.property(this.name);return e*(r?r.getValue():1)},1);this.item.webMap.setLayerOpacity(r,this._prepareValue(e*t))}}_prepareValue(e,t){return t&&t.propagation&&this.isGroup()?1:Number(e)}}}]});let Yn=Xn;var eo=Object.defineProperty,to=Object.defineProperties,ro=Object.getOwnPropertyDescriptors,no=Object.getOwnPropertySymbols,oo=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable,so=(e,t,r)=>t in e?eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ao=(e,t)=>{for(var r in t||(t={}))oo.call(t,r)&&so(e,r,t[r]);if(no)for(var r of no(t))io.call(t,r)&&so(e,r,t[r]);return e},lo=(e,t,r)=>so(e,"symbol"!=typeof t?t+"":t,r),co=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class uo{constructor(e,t){this.map=e,this.options=t,lo(this,"layer"),lo(this,"NgwWebmapItem",Yn),lo(this,"pixelRadius",10),lo(this,"resourceId"),lo(this,"webmapClassName","webmap"),lo(this,"emitter",new M),lo(this,"_extent"),lo(this,"webmapResource"),lo(this,"_webmapBaselayersIds",[]),lo(this,"_lastActiveBaselayer");const r=t.resourceId;if(Array.isArray(r)?(this.resourceId=r[0],this.options.id=r[1]):this.resourceId=r,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}addLayer(e){return co(this,null,function*(){var t;this.options=ao(ao({},this.options),e),this.layer=yield this._getWebMapLayerItem();const r=null==(t=this.webmapResource)?void 0:t.constraining_extent;return this.options.useExtentConstrained&&this._extent&&r&&this.options.webMap.setView({maxBounds:this._extent}),this.layer})}removeLayer(){const e=this.options.webMap.mapAdapter;if(this.getDependLayers().forEach(t=>{"layer"in t&&e.removeLayer(t.layer.layer)}),this._webmapBaselayersIds.length){for(const e of this._webmapBaselayersIds)this.options.webMap.removeLayer(e);this._lastActiveBaselayer&&this.options.webMap.showLayer(this._lastActiveBaselayer)}this.options.useExtentConstrained&&this._extent&&this.options.webMap.setView({maxBounds:null}),delete this.layer,delete this.webmapResource}showLayer(){return co(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)})}hideLayer(){return co(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)})}setOpacity(e){return co(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("opacity").set(e)})}getExtent(){return this.getBounds()}getBounds(){const e=this.webmapResource;if(e)return Ot(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.webmapResource;if(e&&e.bookmark_resource)return e.bookmark_resource.id}fetchBookmarks(e){const t=this.getBookmarksResourceId(),r=this.options.connector;if(t)return r.getResourceOrFail(t,e).then(n=>{var o;const i=null==(o=n.feature_layer)?void 0:o.fields.find(e=>e.label_field),s=i&&i.keyname;return Ir(ao({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then(e=>{const n=[];for(const o of e){const e=new zr({item:o,resourceId:t,labelField:s,connector:r});n.push(e)}return n})});throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(e){return co(this,null,function*(){const t=[];let r=this.getDependLayers();r=r.sort((e,t)=>t.id-e.id);for(const n of r){const r=yield n.getLegend(e);t.push(...r)}return t})}getIdentificationIds(e){return co(this,null,function*(){const e=[];let t=this.getDependLayers();return t=t.sort((e,t)=>t.id-e.id),t.forEach(t=>{const r=t.item,n="style_parent_id"in r?r.style_parent_id:void 0;if(null!=n&&"layer"===r.item_type&&r.layer_identifiable){const r=t.properties.property("visibility");r.get()&&!r.isBlocked()&&e.push(n)}}),e})}_getWebMapLayerItem(){return co(this,null,function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise(t=>{var r;const n=this.options.connector,o=(null==n?void 0:n.options.auth)?n.getAuthorizationHeaders():void 0,i=n.withCredentials,s=(a=ao({},this.options),l={withCredentials:i,headers:o,drawOrderEnabled:null!=(r=e.draw_order_enabled)&&r},to(a,ro(l)));var a,l;const c=new this.NgwWebmapItem({webMap:this.options.webMap,item:e.root_item,options:s,connector:n});c.emitter.on("init",()=>{t(c)})}):void 0})}getWebMapConfig(e){return co(this,null,function*(){var t;const r=yield this.options.connector.getResource(e);if(r){const e=r[this.webmapClassName];if(this.webmapResource=e,this._setupBaselayers(r),e)return this._extent=null!=(t=e.initial_extent)?t:void 0,this._updateItemsParams(e.root_item,this.options.webMap,r),e}})}_setupBaselayers(e){var t;const r=this.options.webMap;if(null==(t=this.options.useBasemap)||t)if(e.basemap_webmap&&e.basemap_webmap.basemaps.length){const t=r.getActiveBaseLayer();this._lastActiveBaselayer=t?t.id:void 0,this._setBasemaps(e.basemap_webmap)}else this.options.defaultBasemap&&r.addBaseLayer("OSM",{id:"webmap-default-baselayer",name:"OpenStreetMap"})}_setBasemaps(e){const t=this.options.webMap;let r=!1;for(const n of e.basemaps)Bt({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then(e=>{const o=!r&&n.enabled;return n.enabled&&(r=!0),t.addBaseLayer(e,{id:"webmap-baselayer"+n.resource_id,name:n.display_name,opacity:n.opacity,visibility:o}).then(e=>{e.id&&this._webmapBaselayersIds.push(e.id)})})}_updateItemsParams(e,t,r){var n;if(e)if("group"===e.item_type||"root"===e.item_type){if("children"in e&&e.children){const n=e.children.map(e=>this._updateItemsParams(e,t,r));e.children=n}"root"===e.item_type&&(e.display_name=r.resource.display_name)}else if("layer"===e.item_type){const r=e,n=b(this.options.connector.options.baseUrl+"/api/component/render/image"),o=r.layer_style_id;r.url=n,r.resourceId=o,r.updateWmsParams=e=>Oo(e,o);const i=jr({options:{adapter:r.layer_adapter.toUpperCase(),resource:o},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=ao(ao({},r),i)}return"function"==typeof(null==(n=this.options.nativeOptions)?void 0:n.beforeItemCreated)&&(e=this.options.nativeOptions.beforeItemCreated(e)),e}}var po=Object.defineProperty,ho=Object.defineProperties,fo=Object.getOwnPropertyDescriptors,yo=Object.getOwnPropertySymbols,mo=Object.prototype.hasOwnProperty,bo=Object.prototype.propertyIsEnumerable,go=(e,t,r)=>t in e?po(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vo=(e,t)=>{for(var r in t||(t={}))mo.call(t,r)&&go(e,r,t[r]);if(yo)for(var r of yo(t))bo.call(t,r)&&go(e,r,t[r]);return e},wo=(e,t)=>ho(e,fo(t)),_o=(e,t)=>{var r={};for(var n in e)mo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&yo)for(var n of yo(e))t.indexOf(n)<0&&bo.call(e,n)&&(r[n]=e[n]);return r};function Oo(e,t){const r=e,{bbox:n,width:o,height:i,nd:s}=r,a=_o(r,["bbox","width","height","nd"]);return wo(vo({},a),{resource:Array.isArray(t)?t.join(","):t,extent:n,size:o+","+i,timestamp:Date.now(),nd:null!=s?s:200})}const Lo={POINT:"point",LINESTRING:"line",POLYGON:"polygon",MULTIPOINT:"point",MULTILINESTRING:"line",MULTIPOLYGON:"polygon",POINTZ:"point",LINESTRINGZ:"line",POLYGONZ:"polygon",MULTIPOINTZ:"point",MULTILINESTRINGZ:"line",MULTIPOLYGONZ:"polygon"};let Po;const Io={tms:"TILE"};var xo=Object.defineProperty,jo=Object.getOwnPropertySymbols,Eo=Object.prototype.hasOwnProperty,Ao=Object.prototype.propertyIsEnumerable,Co=(e,t,r)=>t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ko=(e,t)=>{for(var r in t||(t={}))Eo.call(t,r)&&Co(e,r,t[r]);if(jo)for(var r of jo(t))Ao.call(t,r)&&Co(e,r,t[r]);return e},Mo=(e,t,r)=>Co(e,"symbol"!=typeof t?t+"":t,r);const So="https://qms.nextgis.com";function To(e,t=So,r={}){let n;if("webMap"in e){const o=e,{webMap:i,url:s}=o,a=((e,t)=>{var r={};for(var n in e)Eo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&jo)for(var n of jo(e))t.indexOf(n)<0&&Ao.call(e,n)&&(r[n]=e[n]);return r})(o,["webMap","url"]);n=i,s&&(t=s),a&&(r=a)}else n=e;t||(t=So);class o{constructor(e,t){Mo(this,"qms"),Mo(this,"options"),Mo(this,"map"),this.map=e;const n=ko(ko({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,i=null,s=function*(){if(!this.qms&&e.qmsId)try{this.qms=yield function(e){return new Promise((t,r)=>{const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState&&200===n.status&&n.responseText)try{t(JSON.parse(n.responseText))}catch(e){r(e)}},n.open("GET",b(e),!0),n.send()})}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=Io[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(i=o,s=a,["showLayer","hideLayer"].forEach(e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(i.prototype,e,t)}),"TILE"===t)){if(e=ko(ko({order:0,maxZoom:n.options.maxZoom,minZoom:n.options.minZoom},this.options),function(e){const t=("https:"===location.protocol?"https":"http")+"://";let r=e.url.replace(/^(https?|ftp):\/\//,t);return e.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:e.name,attribution:e.copyright_text,maxZoom:e.z_max,minZoom:e.z_min}}(r)),r.origin_url){const[t,n]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,(e,r)=>("string"==typeof r&&r.split(",").forEach(e=>t.push(e)),"{s}")),t]}(r.origin_url);n.length&&(e.subdomains=n,e.url=t)}return this.options=e,new a(this.map,e).addLayer(e)}}var i,s},new Promise((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},o=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,o);a((s=s.apply(r,i)).next())});var r,i,s}}return o}var No=Object.defineProperty,Ro=Object.getOwnPropertySymbols,$o=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,Bo=(e,t,r)=>t in e?No(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qo=(e,t)=>{for(var r in t||(t={}))$o.call(t,r)&&Bo(e,r,t[r]);if(Ro)for(var r of Ro(t))Fo.call(t,r)&&Bo(e,r,t[r]);return e},Do=(e,t,r)=>Bo(e,"symbol"!=typeof t?t+"":t,r);class Uo{constructor(e){Do(this,"options",{url:"https://qms.nextgis.com"}),Do(this,"url"),this.options=qo(qo({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return To({webMap:e,url:this.url})}}Do(Uo,"utils",{createQmsAdapter:To});var Vo=Object.defineProperty,Go=Object.defineProperties,zo=Object.getOwnPropertyDescriptors,Zo=Object.getOwnPropertySymbols,Wo=Object.getPrototypeOf,Jo=Object.prototype.hasOwnProperty,Ho=Object.prototype.propertyIsEnumerable,Qo=Reflect.get,Ko=(e,t,r)=>t in e?Vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xo=(e,t)=>{for(var r in t||(t={}))Jo.call(t,r)&&Ko(e,r,t[r]);if(Zo)for(var r of Zo(t))Ho.call(t,r)&&Ko(e,r,t[r]);return e},Yo=(e,t)=>Go(e,zo(t)),ei=(e,t,r)=>Qo(Wo(e),r,t),ti=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});var ri=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function ni(e){return function(e){return ri(this,null,function*(){const t=yield Ir(e),r=[];return t.forEach(e=>{r.push(ar(e))}),r})}(e).then(e=>({type:"FeatureCollection",features:e}))}const oi=["fields","intersects","limit","orderBy","strategy"];function ii(e){const t={};return oi.forEach(r=>{const n=e[r];void 0!==n&&(t[r]=n)}),t}var si=Object.defineProperty,ai=Object.defineProperties,li=Object.getOwnPropertyDescriptors,ci=Object.getOwnPropertySymbols,ui=Object.getPrototypeOf,pi=Object.prototype.hasOwnProperty,hi=Object.prototype.propertyIsEnumerable,di=Reflect.get,fi=(e,t,r)=>t in e?si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yi=(e,t)=>{for(var r in t||(t={}))pi.call(t,r)&&fi(e,r,t[r]);if(ci)for(var r of ci(t))hi.call(t,r)&&fi(e,r,t[r]);return e},mi=(e,t)=>ai(e,li(t)),bi=(e,t,r)=>fi(e,"symbol"!=typeof t?t+"":t,r),gi=(e,t,r)=>di(ui(e),r,t),vi=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function wi(e){return vi(this,null,function*(){var t,r;const{item:n,webMap:o,Adapter:i,connector:s,layerOptions:a,addLayerOptionsPriority:l}=e,c=null==l||l,u=a,p=i||a.Adapter||o.mapAdapter.layerAdapters.GEOJSON,h=[];let d,f,y=!1;const m=yield Ct(u,s);(null==(r=null==(t=u.adapterOptions)?void 0:t.popupOptions)?void 0:r.fromProperties)&&(u.adapterOptions.popupOptions.createPopupContent=({feature:e})=>e&&function(e,t){{const r=document.createElement("div");if(t&&t.feature_layer)t.feature_layer.fields.forEach(t=>{if(t.grid_visibility){const n=e.properties&&e.properties[t.keyname];if(n){const e=document.createElement("div");r.appendChild(e),e.innerHTML=`<span>${t.display_name}</span>: ${n}<span></span>`}}});else if(e.properties)for(const t in e.properties){const n=document.createElement("div");r.appendChild(n),n.innerHTML=`<span>${t}</span>: ${e.properties[t]}<span></span>`}return r}}(e,n));const b=(e,t)=>vi(null,null,function*(){v(),f=new AbortController;const r=f.signal;return(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",f.abort),(t=t||{}).signal=r,d={filters:e,options:t},ni(yi({resourceId:m,filters:e,connector:s,cache:!0},t))});let g=!1;const v=()=>{f&&(f.abort(),f=void 0)};class w extends p{constructor(){super(...arguments),bi(this,"emitter",new M),bi(this,"__onMapMove"),bi(this,"__onMapMoveStart"),bi(this,"__enableMapMoveListener"),bi(this,"__disableMapMoveListener")}addLayer(e){return vi(this,null,function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==u.id&&(e.id=u.id),n&&n.vector_layer&&(e.type=Lo[n.vector_layer.geometry_type]),u.adapterOptions&&(e=c?yi(yi({},u.adapterOptions),e):yi(yi({},e),u.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const o=e.strategy||void 0;this.options.strategy=o;const i=gi(w.prototype,this,"addLayer").call(this,e);let s;return d={filters:e.propertiesFilter,options:ii(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),o&&o.startsWith("BBOX")&&!y&&this._addBboxEventListener(),i})}getExtent(){return this.getBounds()}getBounds(){return vi(this,null,function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?Pt({connector:s,resourceId:n.resource.id}):gi(w.prototype,this,"getBounds")?gi(w.prototype,this,"getBounds").call(this):void 0})}beforeRemove(){g=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,v()}getCount(){return function({connector:e,resourceId:t,cache:r=!0,signal:n}){return e.route("feature_layer.feature.count",{id:t}).get({cache:r,signal:n}).then(e=>e.total_count)}({connector:s,resourceId:m,cache:!0})}updateLayer(e){return vi(this,null,function*(){var t;const r=e||d||{};if(null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield o.onLoad("create"),r.options=r.options||{},r.options.intersects=o.getBounds();const{minZoom:e,maxZoom:t}=this.options,n=o.getZoom();if(void 0!==n){if(void 0!==e&&n<e)return;if(void 0!==t&&n>t)return;if(y)return}}if(!g){try{this.emitter.emit("preupdate",r),o._emitLayerEvent("layer:preupdate",u.id||"",r);const e=yield b(r.filters,mi(yi({},r.options),{srs:this.options.srs}));let t=e;const n=yield this.getCount();if("BBOX+"===this.options.strategy){t={type:"FeatureCollection",features:[]};for(const r of e.features)-1===h.indexOf(String(r.id))&&(h.push(String(r.id)),t.features.push(r));y=void 0!==n&&h.length>=n,yield o.addLayerData(this,t)}else y=void 0!==n&&e.features.length>=n,yield o.setLayerData(this,e);this.emitter.emit("updated",e),o._emitLayerEvent("layer:updated",u.id||"",{data:e,newData:t,isFull:y})}catch(n){if(n instanceof Error&&"AbortError"!==n.name)throw n}gi(w.prototype,this,"updateLayer")&&gi(w.prototype,this,"updateLayer").call(this)}})}propertiesFilter(e,t){return vi(this,null,function*(){if(v(),this.filter&&y)this.filter(t=>{const r=t.feature&&t.feature.properties&&fr(yi({},t.feature.properties));return!r||Ht(r,e)});else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(e,mi(yi({},t),{srs:this.options.srs}));this.setData(r)}})}removeFilter(){d=void 0,this.propertiesFilter([]),this.filter&&this.filter(()=>!0)}_addBboxEventListener(){this.__enableMapMoveListener=e=>{e===this&&(this._removeMoveEventListener(),this.updateLayer(),this._addMoveEventListener())},this.__disableMapMoveListener=e=>{e===this&&this._removeMoveEventListener()},o.emitter.on("layer:show",this.__enableMapMoveListener),o.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&o.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&o.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...o){n.clear(),r=setTimeout(()=>{r=null,e.apply(this,o)},t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}(()=>this.updateLayer()),this.__onMapMoveStart=v,o.emitter.on("movestart",this.__onMapMoveStart),o.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&o.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&o.emitter.removeListener("movestart",this.__onMapMoveStart)}}return w})}var _i=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Oi(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Li(e){return Array.isArray(e)&&!Oi(e)}function Pi(e){const[t,r,n]=e,o=String(t),i=function(e){return["get",e]}(o);switch(r){case"eq":return null===n?["is_null",i]:["==",i,n];case"ne":return null===n?["!is_null",i]:["!=",i,n];case"gt":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "gt" requires number or string for "${o}"`);return[">",i,n];case"lt":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "lt" requires number or string for "${o}"`);return["<",i,n];case"ge":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "ge" requires number or string for "${o}"`);return[">=",i,n];case"le":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "le" requires number or string for "${o}"`);return["<=",i,n];case"in":if(!Array.isArray(n)||!n.every(e=>"string"==typeof e||"number"==typeof e))throw new Error(`Operator "in" requires (string | number)[] for "${o}"`);if(!n.length)throw new Error(`Operator "in" requires non-empty array for "${o}"`);return["in",i,...n];case"notin":if(!Array.isArray(n)||!n.every(e=>"string"==typeof e||"number"==typeof e))throw new Error(`Operator "notin" requires (string | number)[] for "${o}"`);if(!n.length)throw new Error(`Operator "notin" requires non-empty array for "${o}"`);return["!in",i,...n];case"like":case"ilike":throw new Error(`Operator "${r}" is not supported by server FilterExpression`);default:throw new Error(`Unsupported operator: ${r}`)}}function Ii(e){let t="all";const r=[];for(const n of e)if("all"!==n&&"any"!==n)if(Oi(n))r.push(Pi(n));else{if(!Li(n))throw new Error("Invalid PropertiesFilter node");r.push(Ii(n))}else t=n;return[t,...r]}function xi(e){return(null==e?void 0:e.length)?Ii(e):[]}function ji(e){if(null==e?void 0:e.length)return JSON.stringify(xi(e))}function Ei(e,t){return{[`filter[${e}]`]:ji(t)}}var Ai=Object.defineProperty,Ci=Object.defineProperties,ki=Object.getOwnPropertyDescriptors,Mi=Object.getOwnPropertySymbols,Si=Object.prototype.hasOwnProperty,Ti=Object.prototype.propertyIsEnumerable,Ni=(e,t,r)=>t in e?Ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ri=(e,t)=>{for(var r in t||(t={}))Si.call(t,r)&&Ni(e,r,t[r]);if(Mi)for(var r of Mi(t))Ti.call(t,r)&&Ni(e,r,t[r]);return e},$i=(e,t)=>Ci(e,ki(t)),Fi=(e,t)=>{var r={};for(var n in e)Si.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Mi)for(var n of Mi(e))t.indexOf(n)<0&&Ti.call(e,n)&&(r[n]=e[n]);return r},Bi=(e,t,r)=>Ni(e,"symbol"!=typeof t?t+"":t,r),qi=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Di(e){return qi(this,arguments,function*({layerOptions:e,connector:t,webMap:r,item:o}){const i=o.resource.cls;let s=e.adapter||i&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[i]||"IMAGE";if(void 0!==s&&(e.adapter=s),"IMAGE"===s){const e=r.getLayerAdapters();!e||e.IMAGE||(s="TILE")}const a=r.mapAdapter.layerAdapters[s];if(a){const i=yield Ct(e,t);return class extends a{constructor(a,l){super(a,l),this.map=a,Bi(this,"item",o),Bi(this,"resourceId",i),Bi(this,"blocked",!1),Bi(this,"layerVisibility");const c=jr({options:e,webMap:r,baseUrl:t.options.baseUrl||""});if(c){const t=e.adapterOptions||{},{propertiesFilter:r}=t,o=Fi(t,["propertiesFilter"]),a=Ei(i,r),l=$i(Ri(Ri({},c),o),{params:Ri({resource:i},a),url:"TILE"===s&&c.url?g(c.url,Ri({resource:String(i)},a)):c.url,layers:c.layers||String(i),resourceId:i});e.adapterOptions&&n(e.adapterOptions.setViewDelay)&&(l.setViewDelay=e.adapterOptions.setViewDelay),this.options=Ri(Ri({},this.options),l)}}addLayer(e){return super.addLayer(Ri(Ri({},this.options),e))}propertiesFilter(e){return qi(this,null,function*(){var t;const r=this.options,n=Ri(Ri({},r.params||{}),Ei(this.resourceId,e));r.params=n,null==(t=this.updateLayer)||t.call(this,{params:n})})}getIdentificationIds(){return qi(this,null,function*(){if(this.item){if("MVT"===s)return[this.item.resource.id];if(this.item.resource.parent){const e=this.item.resource.parent.id;if(n(e))return[e]}}return[]})}getLegend(e){return qi(this,null,function*(){const n=this.options.id;if(void 0!==n){const o=yield t.route("render.legend_symbols",{id:i}).get(Ri({cache:!0},e));return[new qn({layerId:n,layer:this,resourceId:i,webMap:r,legend:o})]}return[]})}}}throw new Error(s+" not supported yet. Only TILE")})}var Ui=Object.defineProperty,Vi=Object.defineProperties,Gi=Object.getOwnPropertyDescriptors,zi=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Wi=Object.prototype.propertyIsEnumerable,Ji=(e,t,r)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hi=(e,t)=>{for(var r in t||(t={}))Zi.call(t,r)&&Ji(e,r,t[r]);if(zi)for(var r of zi(t))Wi.call(t,r)&&Ji(e,r,t[r]);return e},Qi=(e,t)=>Vi(e,Gi(t)),Ki=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const Xi={},Yi=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function es(e){return Ki(this,arguments,function*({layerOptions:e,webMap:t,connector:r,item:n}){const o=n.resource.id,i=yield r.getResourceChildren(o),s=i&&i[0];if(s)return ts(Qi(Hi({},e),{resource:s.resource.id}),t,r)})}function ts(e,r,n){return Ki(this,null,function*(){let o,i;const s=e.adapter,a=yield Ct(e,n);if(a){const t=e.resource;if(i=t&&t.resource&&void 0!==t.resource.id?t:yield n.getResource(a),!i)throw"Resource item is not found";{const t=i.resource.cls,l={layerOptions:Qi(Hi({},e),{resource:a}),connector:n,webMap:r,item:i};if(-1!==Yi.indexOf(t))if("webmap"===t)o=function(e){return _i(this,arguments,function*({layerOptions:e,webMap:t,connector:r}){const n=yield Ct(e,r);return class extends uo{constructor(e){super(e,{url:"",webMap:t,resourceId:n,connector:r})}}})}(l);else if("vector_layer"===t||"postgis_layer"===t){const t=l.layerOptions.adapterOptions||{};if(t.type=t.type||i.vector_layer&&Lo[i.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==s&&"GEOJSON"!==s){if("MVT"!==s)return es(l);o=Di(l)}else o=wi(l)}else{if("raster_layer"===t)return es(l);if("basemap_layer"===t)o=function(e){return ti(this,arguments,function*({webMap:e,item:t}){if(t.basemap_layer){const r=t.basemap_layer.qms,n=t.basemap_layer.url;if(r){const t=JSON.parse(r);return Promise.resolve(Uo.utils.createQmsAdapter(e,void 0,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return ti(this,null,function*(){if(n)return ei(e.prototype,this,"addLayer").call(this,Yo(Xo({},t),{url:n}))})}}return e}}}})}(l);else if("GEOJSON"===s&&i.resource.parent){const t=yield n.getResource(i.resource.parent.id);if(t){const r=Qi(Hi({},e),{resource:i.resource.parent.id});o=wi(Qi(Hi({},l),{item:t,layerOptions:r}))}}else o=Di(l)}else{if(!Xi[t])throw`Resource class '${t}' not yet supported.`;{const e=Xi[t];let r;r=s&&"function"!=typeof r?e[s]:e,r&&(o=r(l))}}}}if(o)return o.then(e=>{if(e){const r=e;return i&&(r.prototype.item=i,r.prototype.resourceId=i.resource.id,r.prototype.connector=n),t(r,[At],{replace:!1}),r}})})}var rs=Object.defineProperty,ns=Object.getOwnPropertySymbols,os=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,ss=(e,t,r)=>t in e?rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,as=(e,t)=>{for(var r in t||(t={}))os.call(t,r)&&ss(e,r,t[r]);if(ns)for(var r of ns(t))is.call(t,r)&&ss(e,r,t[r]);return e},ls=(e,t,r)=>ss(e,"symbol"!=typeof t?t+"":t,r);class cs{constructor(e){if(this.options=e,ls(this,"url"),ls(this,"connector"),ls(this,"webMap"),this.options.connector)this.url=this.options.connector.options.baseUrl||"",this.connector=this.options.connector;else{if(!this.options.baseUrl)throw new Error("url is not defined");this.url=this.options.baseUrl,this.connector=new ht({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){Xi[e]=t}onLoadSync(e){return t=this,r=null,n=function*(){if(this.options.resourceId&&this.url){const t=[this.options.resourceId];if(t.length)for(const r of t){const t={resourceId:r,connector:this.connector,webMap:e};return yield e.addLayer(uo,as({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}getLayerAdapters(){return Promise.resolve([this._getLayerAdapter()])}_getLayerAdapter(){return{name:"WEBMAP",createAdapter:e=>Promise.resolve(this._createAdapter(e))}}_createAdapter(e){return t={webMap:e,connector:this.connector,baseUrl:this.url},class extends uo{constructor(e,r){super(e,r=vo(vo({},t),r))}};var t}}var us=Object.defineProperty,ps=Object.getOwnPropertySymbols,hs=Object.prototype.hasOwnProperty,ds=Object.prototype.propertyIsEnumerable,fs=(e,t,r)=>t in e?us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ys=(e,t)=>{for(var r in t||(t={}))hs.call(t,r)&&fs(e,r,t[r]);if(ps)for(var r of ps(t))ds.call(t,r)&&fs(e,r,t[r]);return e},ms=(e,t,r)=>fs(e,"symbol"!=typeof t?t+"":t,r),bs=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class gs{constructor(e){ms(this,"id"),ms(this,"label"),ms(this,"layerId"),ms(this,"parent"),ms(this,"fields"),ms(this,"geom"),ms(this,"extensions"),ms(this,"connector"),ms(this,"_item"),ms(this,"_geojson"),ms(this,"_resource"),ms(this,"_extent");const t=e.feature;this.id=t.id,this.geom=t.geom,this.label=t.label,this.parent=t.parent,this.fields=t.fields,this.layerId=t.layerId,this.connector=e.connector}identify(e={}){return this._item?Promise.resolve(this._item):Fr(ys({connector:this.connector,featureId:this.id,resourceId:this.layerId,fields:null,extensions:["attachment","description"]},e)).then(e=>(this._item=e,this.geom=e.geom,this.extensions=e.extensions,e))}resource(e){return bs(this,null,function*(){return(yield this.composite(e)).feature_layer})}composite(e){return bs(this,null,function*(){if(this._resource&&this._resource.feature_layer)return this._resource;const t=yield this.connector.getResource(this.layerId,e);if(!t)throw new Error("Resource does not exist");if(!t.feature_layer)throw new Error("Resource is not a vector layer");return this._resource=t,t})}getBounds(e){return this._extent?Promise.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0,signal:o}){return r.route("feature_layer.feature.item_extent",{id:Number(e),fid:t}).get({cache:n,signal:o}).then(e=>{if(e&&e.extent){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}})}(ys({connector:this.connector,featureId:this.id,resourceId:this.layerId},e))}geojson(e={}){return this._geojson?Promise.resolve(this._geojson):this.identify(e).then(e=>e.toGeojson().then(e=>(this._geojson=e,e)))}}function vs(e){return t=this,r=null,n=function*(){return ar(yield Fr(e))},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}function ws(e,t){return r=this,n=null,o=function*(){var r,n;const o=yield e.route("pyramid.settings").get({query:{component:"pyramid"}}),i=o&&"company_logo"in o?o.company_logo:void 0;if(i&&i.enabled){const o=document.createElement("a");o.style.position="absolute",o.style.bottom="0",o.style.right="0",o.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",o.className="ngw-map-logo",t&&t.cssClass&&(o.className+=" "+t.cssClass);const s=new Image;s.style.maxHeight="100px",s.style.maxWidth="100px",s.src="";const a=null==(n=(yield e.route("pyramid.csettings").get({query:{pyramid:["header_logo"]}})).pyramid)?void 0:n.header_logo;if(!a)return;{const[e,t]=a,r=atob(t),n=new Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);const o=new Uint8Array(n),i=new Blob([o],{type:e}),l=(window.URL||window.webkitURL).createObjectURL(i);s.src=l}return null!==i.link&&""!==i.link.trim()&&(o.href=i.link,o.target="_blank",-1!==i.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),o.appendChild(s),o}},new Promise((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())});var r,n,o}var _s=Object.defineProperty,Os=Object.defineProperties,Ls=Object.getOwnPropertyDescriptors,Ps=Object.getOwnPropertySymbols,Is=Object.prototype.hasOwnProperty,xs=Object.prototype.propertyIsEnumerable,js=(e,t,r)=>t in e?_s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Es=(e,t)=>{for(var r in t||(t={}))Is.call(t,r)&&js(e,r,t[r]);if(Ps)for(var r of Ps(t))xs.call(t,r)&&js(e,r,t[r]);return e},As=(e,t)=>Os(e,Ls(t));function Cs(e,t=!1){const r=[],n=[];for(const i in e){const e=Number(i);isNaN(e)||r.push(e)}const o=e.resources;o&&r.sort((e,t)=>o.indexOf(e)-o.indexOf(t));for(let i=0;i<r.length;i++){const o=r[i],s=e[o];if("features"in s){const e=ks(s.features,Number(o),t);if(e.length&&(n.push(...e),!t))break}}return n}function ks(e,t,r){const n=[];for(const o of e){if(n.push({featureId:o.id,resourceId:t,feature:o}),!r)break}return n}function Ms(e){const{geom:t,signal:r,cache:n,layers:o}=e,i="string"==typeof t?t:function(e){const t=function(e){var t;if(Array.isArray(e))return e;if("Feature"===e.type)return null==(t=e.geometry)?void 0:t.coordinates[0];if("Polygon"===e.type)return e.coordinates[0];return null}(e);if(!t)return null;return`POLYGON((${t.map(([e,t])=>{const[r,n]=s(e,t);return`${r} ${n}`}).join(",")}))`}(t);if(!i)throw new Error("Not valid geometry format to make intersection");const a={geom:i,srs:3857,layers:o};return e.connector.route("feature_layer.identify").post({json:a,signal:r,cache:n})}const Ss={};function Ts(e){return Ss[e]}function Ns(e,t){Ss[e]=t}function Rs(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const o=t.title||"",i=t.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function l(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(e,t){e.split(" ").forEach(e=>{t?r.classList.add(e):r.classList.remove(e)})}function u(){t.addClassOn&&c(t.addClassOn,n),t.addClassOff&&c(t.addClassOff,!n)}s(),l(),t.addClass&&c(t.addClass,!0),u();const p=e=>{void 0!==e&&(n=e),l(),s(),u()},h=e=>{if(n=void 0!==e?e:!n,t.onClick){const e=t.onClick(n);Promise.resolve(e).then(()=>p()).catch(()=>n=!n)}else p()},d=e({html:r,onClick:h});return d.onClick=h,d.changeStatus=p,d}function $s(e){return(t,r)=>{const n=t.map(e=>e());return e(n,r)}}const Fs={"!":$s(function([e]){return!e}),"!=":$s(function([e,t]){return e!==t}),"<":$s(function([e,t]){return e<t}),"<=":$s(function([e,t]){return e<=t}),"==":$s(function([e,t]){return e===t}),">":$s(function([e,t]){return e>t}),">=":$s(function([e,t]){return e>=t}),coalesce:e=>{for(let t=0;t<e.length;t++){const r=e[t]();if(null!=r)return r}return null},all:e=>{for(let t=0;t<e.length;t++){if(!e[t]())return!1}return!0},any:e=>{for(let t=0;t<e.length;t++){if(e[t]())return!0}return!1},case:e=>{if(e.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(e.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(let t=0;t<e.length-1;t+=2){const r=e[t](),n=e[t+1]();if(r)return n}return(0,e[e.length-1])()},match:e=>{const[t,...r]=e,n=t(),o=r.splice(-1,r.length%2)[0];for(let i=0;i<r.length-1;i+=2){if(r[i]()===n)return r[i+1]()}return o()}},Bs={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function qs(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Ds(e);if("string"==typeof(t=e)&&t in Bs)return function(e){return Ds(Bs[e])}(e);if(function(e){return"string"==typeof e&&/^rgb(a?)\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)(?:\s*,\s*([01](?:\.\d+)?))?\s*\)$/.test(e)}(e))return function(e){const t=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;let r;if(r=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)];if(r=e.match(t))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4])];throw new Error(`The '${e}' Is not valid rgb`)}(e);if(function(e){if("object"==typeof e&&null!==e)return"r"in e&&"g"in e&&"b"in e&&(!("a"in e)||"number"==typeof e.a&&e.a>=0&&e.a<=1);return!1}(e))return function({r:e,g:t,b:r,a:n}){return[e,t,r,...void 0!==n?[n]:[]]}(e);var t,r;throw new Error(`The '${e}' cannot be converted to color`)}function Ds(e){let t;if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),parseInt(t[4]+t[4],16)/255];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16)/255];throw new Error(`The '${e}' Is not valid hex`)}function Us(e,t,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(e-t)/(n-t)*(o-r);try{const i=qs(r),s=qs(o);return function(e){return`rgb(${e.join(",")})`}(i.map((r,o)=>Math.ceil(Us(e,t,r,n,s[o]))))}catch(i){console.log(i)}throw new Error("Unsupported output type for linear interpolation.")}const Vs={step:e=>{const[t,r,...n]=e,o=t();if("number"!=typeof o)return r();for(let i=0;i<n.length-2;i+=2){const e=n[i](),t=n[i+1](),r=n[i+2]();if(o>=e&&o<r)return t}return o>=n[n.length-2]()?n[n.length-1]():r()},interpolate:([e,t,...r])=>{if(r.length<2)throw new Error("At least two stops are required");if(r.length<2||r.length%2!=0)throw new Error("Invalid stops provided.");const n=t();if("number"!=typeof n)throw new Error("Input must be a number.");const o=e();for(let i=0;i<r.length-2;i+=2){const e=r[i](),t=r[i+1](),s=r[i+2](),a=r[i+3]();if(n>=e&&n<=s&&"linear"===o[0])return Us(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Gs={get:$s(function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null}),length:$s(([e])=>{if("string"==typeof e||Array.isArray(e))return e.length}),at:$s(function([e,t]){return t[e]}),has:$s(function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))}),in:$s(function([e,t]){if("string"==typeof t)return t.includes(String(e));if(Array.isArray(t))return t.includes(e);throw new Error(`Invalid input type for 'in'. Expected string or array, got ${typeof t}.`)}),"index-of":$s(function([e,t,r]){if("string"==typeof t)return t.indexOf(String(e),r);if(Array.isArray(t))return t.indexOf(e,r);throw new Error(`Invalid input type for 'index-of'. Expected string or array, got ${typeof t}.`)}),slice:$s(function(e){const[t,r,n]=e;if("string"==typeof t)return t.slice(r,n);if(Array.isArray(t))return t.slice(r,n);throw new Error(`Invalid input type for 'slice'. Expected string or array, got ${typeof t}.`)})},zs={"+":$s(e=>e.reduce((e,t)=>e+t,0)),"-":$s(e=>e.reduce((e,t)=>e-t)),"*":$s(e=>e.reduce((e,t)=>e*t,1)),"/":$s(e=>e.reduce((e,t)=>e/t)),"%":$s(e=>e[0]%e[1]),"^":$s(e=>Math.pow(e[0],e[1])),abs:$s(e=>Math.abs(e[0])),acos:$s(e=>Math.acos(e[0])),asin:$s(e=>Math.asin(e[0])),atan:$s(e=>Math.atan(e[0])),ceil:$s(e=>Math.ceil(e[0])),cos:$s(e=>Math.cos(e[0])),e:()=>Math.E,floor:$s(e=>Math.floor(e[0])),ln:$s(e=>Math.log(e[0])),ln2:()=>Math.LN2,log10:$s(e=>Math.log10(e[0])),log2:$s(e=>Math.log2(e[0])),max:$s(e=>Math.max(...e)),min:$s(e=>Math.min(...e)),pi:()=>Math.PI,round:$s(e=>Math.round(e[0])),sin:$s(e=>Math.sin(e[0])),sqrt:$s(e=>Math.sqrt(e[0])),tan:$s(e=>Math.tan(e[0]))},Zs={concat:$s(e=>e.reduce((e,t)=>String(e)+String(t),"")),downcase:$s(e=>String(e[0]).toLowerCase()),upcase:$s(e=>String(e[0]).toUpperCase())},Ws=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function Js(e){return(t,r)=>{for(const n of t){const t=Ws(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Hs={array:$s(e=>{const[t,r,n]=e;let o,i,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(o=t,"number"==typeof r?(i=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(o&&!s.every(e=>typeof e===o))throw new Error(`Expected all items in array to be of type ${o}`);if(i&&s.length!==i)throw new Error(`Expected array of length ${i}`);return s}),boolean:$s(Js(e=>"boolean"==typeof e?e:void 0)),literal:$s(([e])=>e),number:$s(Js(e=>"number"==typeof e?e:void 0)),object:$s(Js(e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e)),string:$s(Js(e=>"string"==typeof e?e:void 0)),"to-boolean":$s(Js(Boolean)),"to-number":$s(Js(Number)),"to-string":$s(Js(String)),typeof:$s(([e])=>function(e){if(null===e)return"null";switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":if(Array.isArray(e)){let t="value";return e.every(e=>"number"==typeof e)?t="number":e.every(e=>"string"==typeof e)?t="string":e.every(e=>"boolean"==typeof e)&&(t="boolean"),`array<${t}, ${e.length}>`}return"object";default:return"undefined"}}(e))};var Qs=Object.defineProperty,Ks=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,ea=(e,t,r)=>t in e?Qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ta=(e,t)=>{for(var r in t||(t={}))Xs.call(t,r)&&ea(e,r,t[r]);if(Ks)for(var r of Ks(t))Ys.call(t,r)&&ea(e,r,t[r]);return e};function ra(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in na&&r.length>0}return!1}const na=ta(ta(ta(ta(ta(ta({},zs),Hs),Zs),Gs),Fs),Vs);function oa(e,t={}){const[r,...n]=e,o=na[r];if(o)return o(n.map(e=>()=>ra(e)?oa(e,t):e),t);throw new Error(`Expression "${r}" is not supported.`)}var ia=Object.defineProperty,sa=Object.getOwnPropertySymbols,aa=Object.prototype.hasOwnProperty,la=Object.prototype.propertyIsEnumerable,ca=(e,t,r)=>t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ua=(e,t)=>{for(var r in t||(t={}))aa.call(t,r)&&ca(e,r,t[r]);if(sa)for(var r of sa(t))la.call(t,r)&&ca(e,r,t[r]);return e};function pa(e){return t=>{const r=t.properties;return!!r&&oa(e,r)}}const ha=["iconSize","iconAnchor"];function da(e){return"function"==typeof e}var fa=Object.defineProperty,ya=Object.getOwnPropertySymbols,ma=Object.prototype.hasOwnProperty,ba=Object.prototype.propertyIsEnumerable,ga=(e,t,r)=>t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,va=(e,t)=>{for(var r in t||(t={}))ma.call(t,r)&&ga(e,r,t[r]);if(ya)for(var r of ya(t))ba.call(t,r)&&ga(e,r,t[r]);return e};function wa(e){let t={};const r=[];for(const n of e)n&&(Array.isArray(n)?r.push(n):t=n);return e=>{const n=r.find(t=>Jt(e,t[0]));return n?va(va({},t),n[1]):t}}function _a({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===ha.indexOf(n)){const o=n,i=e[o];ra(i)&&(t=!0,r[o]=pa(i))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return ua(ua({},e),n)}}(e);if(r){const n=e=>La({paint:r(e),defaultPaint:t});return n.paint=Oa({paint:e,defaultPaint:t}),n}return Oa({paint:e,defaultPaint:t})}function Oa({paint:e,defaultPaint:t}){var r;let n=va({},t);return n=va(va({},n),e),n.fill=null==(r=n.fill)||r,n.stroke=void 0!==n.stroke?n.stroke:!n.fill||!(!n.strokeColor&&!n.strokeOpacity),n}function La({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=va({},t);if(da(e)){const n=n=>{const o=La({paint:e(n),defaultPaint:t,getPaintFunctions:r});return o.type=e.type,o};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>La({paint:wa(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const o=function(e,t){if("function"==typeof e.from)return e.from(e.options);if("string"==typeof e.from&&t){const r=t[e.from];if(r)return r(e.options)}}(e,r);o&&(n=La({paint:o,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=_a({paint:e,defaultPaint:t})}return da(n)||("color"in n&&(n.strokeColor||(n.strokeColor=n.color),n.fillColor||(n.fillColor=n.color)),"opacity"in n&&(void 0===n.strokeOpacity&&(n.strokeOpacity=n.opacity),void 0===n.fillOpacity&&(n.fillOpacity=n.opacity))),n}function Pa(e){const t={};for(let n=0;n<e.length;n++)t[e[n]]=1+(t[e[n]]||0);let r;for(const n in t){t[n]>((void 0!==r?t[r]:0)||0)&&(r=n)}return r}function Ia(e){let t;if("FeatureCollection"===e.type){t=Pa(e.features.map(e=>e.geometry.type))}else if("GeometryCollection"===e.type){t=Pa(e.geometries.map(e=>e.type))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const xa={polygon:"path",line:"path",point:"circle"},ja={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Ea(e){if(e.data){const t=ja[Ia(e.data)],r=e.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===t||"line"===t?"path":"html"in r||"className"in r?"icon":xa[t]),e.type=e.type||t}return e}var Aa=Object.defineProperty,Ca=(e,t,r)=>((e,t,r)=>t in e?Aa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ka{constructor(){Ca(this,"backspace",8),Ca(this,"tab",9),Ca(this,"enter",13),Ca(this,"shift",16),Ca(this,"ctrl",17),Ca(this,"alt",18),Ca(this,"pause/break",19),Ca(this,"caps_lock",20),Ca(this,"escape",27),Ca(this,"page_up",33),Ca(this,"page_down",34),Ca(this,"end",35),Ca(this,"home",36),Ca(this,"left_arrow",37),Ca(this,"up_arrow",38),Ca(this,"right_arrow",39),Ca(this,"down_arrow",40),Ca(this,"insert",45),Ca(this,"delete",46),Ca(this,"left_window_key",91),Ca(this,"right_window_key",92),Ca(this,"select_key",93),Ca(this,"numpad_0",96),Ca(this,"numpad_1",97),Ca(this,"numpad_2",98),Ca(this,"numpad_3",99),Ca(this,"numpad_4",100),Ca(this,"numpad_5",101),Ca(this,"numpad_6",102),Ca(this,"numpad_7",103),Ca(this,"numpad_8",104),Ca(this,"numpad_9",105),Ca(this,"multiply",106),Ca(this,"add",107),Ca(this,"subtract",109),Ca(this,"decimal_point",110),Ca(this,"divide",111),Ca(this,"f1",112),Ca(this,"f2",113),Ca(this,"f3",114),Ca(this,"f4",115),Ca(this,"f5",116),Ca(this,"f6",117),Ca(this,"f7",118),Ca(this,"f8",119),Ca(this,"f9",120),Ca(this,"f10",121),Ca(this,"f11",122),Ca(this,"f12",123),Ca(this,"num_lock",144),Ca(this,"scroll_lock",145),Ca(this,"semi-colon",186),Ca(this,"equal_sign",187),Ca(this,",",188),Ca(this,"-",189),Ca(this,".",190),Ca(this,"/",191),Ca(this,"`",192),Ca(this,"[",219),Ca(this,"\\",220),Ca(this,"]",221),Ca(this,"'",222)}}var Ma=Object.defineProperty,Sa=(e,t,r)=>((e,t,r)=>t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var Ta=Object.defineProperty,Na=(e,t,r)=>((e,t,r)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ra{constructor(e,t){this.webMap=e,Na(this,"name"),Na(this,"event"),Na(this,"value"),t&&(t.value&&this.setValue(t.value),t.name&&(this.name=t.name),t.event&&(this.event="string"==typeof t.event?[t.event]:t.event))}getValue(){return this.value}setValue(e){this.value=e}}var $a=Object.defineProperty,Fa=(e,t,r)=>((e,t,r)=>t in e?$a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ba extends Ra{constructor(){super(...arguments),Fa(this,"name","bounds"),Fa(this,"event",["moveend"])}getValue(){return this.webMap.getBounds()}setValue(e){this.webMap.setView({bounds:e})}toString(){const e=this.getValue();if(e)return e.slice(0,4).map(e=>e.toFixed(5)).join("_")}parse(e){return e.split("_").map(Number)}}var qa=Object.defineProperty,Da=(e,t,r)=>((e,t,r)=>t in e?qa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ua extends Ra{constructor(){super(...arguments),Da(this,"name","center"),Da(this,"event",["moveend"])}getValue(){return this.webMap.getCenter()}setValue(e){this.webMap.setCenter(e)}toString(){const e=this.getValue();if(e){const t=e.map(e=>e.toFixed(5));return t[0]+"_"+t[1]}return""}parse(e){return e.split("_").map(Number)}}var Va=Object.defineProperty,Ga=(e,t,r)=>((e,t,r)=>t in e?Va(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class za extends Ra{constructor(){super(...arguments),Ga(this,"name","zoom"),Ga(this,"event",["zoomend"])}getValue(){const e=this.webMap.getZoom();return void 0!==e?Math.round(e):void 0}setValue(e){this.webMap.setZoom(e)}toString(){return String(this.getValue())}parse(e){return Number(e)}}var Za=Object.defineProperty,Wa=(e,t,r)=>((e,t,r)=>t in e?Za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Ja=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});let Ha=0;const Qa={minZoom:0,maxZoom:22,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},Ka=class e{constructor(t){Wa(this,"options",Qa),Wa(this,"emitter",new M),Wa(this,"keys",e.keys),Wa(this,"mapAdapter"),Wa(this,"runtimeParams",[]),Wa(this,"getPaintFunctions",e.getPaintFunctions),Wa(this,"mapStateItems",[Ua,za,Ba]),Wa(this,"id",Ha++),Wa(this,"mapState",[]),Wa(this,"_initMapState",{}),Wa(this,"_starterKits"),Wa(this,"_extent"),Wa(this,"_eventsStatus",{}),Wa(this,"_coordFromMapClickAbort"),Wa(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(Qa||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}create(){return Ja(this,null,function*(){return this.getEventStatus("create")||(yield this._setInitMapState(this.mapStateItems),yield this._setupMap(),this._emitStatusEvent("create",this)),this})}setRuntimeParams(e){this.runtimeParams.push(e)}destroy(){this._removeEventListeners(),function(e){for(const t in e)delete e[t]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}mapStateWithFunc(e){const t={};return this.mapState.forEach(r=>{t[r.name]=e(r)}),t}getStateAsString(){return this.mapStateWithFunc(e=>e.toString())}getState(){return this.mapStateWithFunc(e=>e.getValue())}getRuntimeParams(){const e={};return this.mapState.forEach(t=>{for(const r of this.runtimeParams){const n=r.get(t.name);if(void 0!==n){e[t.name]=t.parse(n);break}}}),e}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const e=document.getElementById(this.options.target);if(e)return e}}}setCursor(e){this.onLoad().then(()=>{this.mapAdapter.setCursor&&this.mapAdapter.setCursor(e)})}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const e=this.getContainer();return e?e.style.cursor:void 0}setCenter(e){return this.mapAdapter.setCenter(e),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const e=this.getBounds();if(e){return{type:"Feature",properties:{},geometry:a(e)}}}setZoom(e){return this.mapAdapter.setZoom(e),this}getZoom(){const e=this.mapAdapter.getZoom();if("number"==typeof e)return e}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e-1)}}}setView(e,t){if(Array.isArray(e)){const r=e;this.mapAdapter.setView&&r&&n(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),n(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return function(e){const[t,r,n,o]=e,i=t<n&&r<o;if(!i){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${o}]`);const e=[Math.min(t,n),Math.min(r,o),Math.max(t,n),Math.max(o,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&o<=90;s&&a||console.log("Warning: The coordinates may not be within valid geographic ranges.")}(e),e.every(e=>n(e))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,t)),this}getEventStatus(e){const t=this._eventsStatus[e];return null!=t&&t}onLoad(e="create"){return new Promise(t=>{this.getEventStatus(e)?t(this):this.emitter.once(e,()=>{t(this)})})}onMapLoad(e){return new Promise(t=>{var r;const n=()=>{const r=this.mapAdapter;e&&e(r),r&&t(r)},o=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&o?n():this.mapAdapter.emitter.once("create",()=>{n()})})}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(e){return this.mapAdapter.layerAdapters[e]}locate(e,t){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(e,t);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickAbort&&(this._coordFromMapClickAbort(),this._coordFromMapClickAbort=void 0)}getCoordFromMapClick(){return this._coordFromMapClickAbort?this.getCoordFromMapClick():new Promise((e,t)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const n=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickAbort=void 0},o=t=>{n(),i(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),this._coordFromMapClickAbort=n})}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return Ja(this,null,function*(){})}_onLoadSync(){return Ja(this,null,function*(){})}_setupMap(){return Ja(this,null,function*(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return yield this.mapAdapter.create(this.options),this._zoomToInitialExtent(),yield this._addLayerProviders(),yield this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this})}_setTileJsonOptions(e){e.center&&(this.options.center=e.center),e.bounds&&(this.options.bounds=e.bounds),n(e.maxzoom)&&(this.options.zoom=e.maxzoom),n(e.minzoom)&&(this.options.zoom=e.minzoom),n(e.maxzoom)&&n(e.minzoom)&&(this.options.zoom=(e.maxzoom+e.minzoom)/2)}_zoomToInitialExtent(){const{center:e,zoom:t,bounds:r}=this.options;this._extent?this.fitBounds(this._extent):e&&t?this.setView(e,t):r&&(this.fitBounds(r),void 0!==t&&this.setZoom(t))}_setInitMapState(e){for(const t of e){const e=new t(this);this.mapState.push(e);for(const t of this.runtimeParams){const r=t.get(e.name);if(void 0!==r){const t=e.parse(r);this._initMapState[e.name]=t,Object.defineProperty(this.options,e.name,{value:t,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(e){let t=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend","mousemove","mouseout","mouseover"];e&&e.include&&(t=t.filter(t=>e.include.includes(t))),t.forEach(e=>{this._mapEvents[e]=t=>{if(this.runtimeParams.length){this.mapState.filter(t=>t.event.includes(e)).forEach(e=>{const t=e.toString();this.runtimeParams.forEach(r=>{r.set(e.name,t)})})}this._eventsStatus&&this.emitter.emit(e,t)};const t=this._mapEvents[e];t&&this.mapAdapter.emitter.on(e,t)})}_removeEventListeners(e){let t=Object.entries(this._mapEvents);e&&e.include&&(t=t.filter(t=>e.include.includes(t[0]))),t.forEach(([e,t])=>{t&&this.mapAdapter.emitter.removeListener(e,t)})}};Wa(Ka,"keys",new class{constructor(){Sa(this,"keyCodeAlias",new ka),Sa(this,"keys",{}),Sa(this,"_windowOnFocus"),Sa(this,"_keysPressed"),Sa(this,"_keysReleased"),this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(e){const t=this.keyCodeAlias[e];return!!t&&this.keys[t]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(e){e.stopPropagation(),this.keys[e.keyCode]||(this.keys[e.keyCode]=!0)}keysReleased(e){e.stopPropagation(),this.keys[e.keyCode]=!1}windowOnFocus(){this.keys={}}}),Wa(Ka,"getPaintFunctions");let Xa=Ka;var Ya=Object.defineProperty,el=Object.defineProperties,tl=Object.getOwnPropertyDescriptors,rl=Object.getOwnPropertySymbols,nl=Object.prototype.hasOwnProperty,ol=Object.prototype.propertyIsEnumerable,il=(e,t,r)=>t in e?Ya(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,sl=(e,t)=>{for(var r in t||(t={}))nl.call(t,r)&&il(e,r,t[r]);if(rl)for(var r of rl(t))ol.call(t,r)&&il(e,r,t[r]);return e},al=(e,t)=>el(e,tl(t)),ll=(e,t,r)=>il(e,"symbol"!=typeof t?t+"":t,r),cl=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class ul extends Xa{constructor(e){super(e),ll(this,"_layersIdCounter",1),ll(this,"_layersOrderCounter",1),ll(this,"_baselayers",[]),ll(this,"_layers",{}),ll(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",()=>this.addTileJsonLayer(t))}fitLayer(e,t){return cl(this,null,function*(){const r=this.getLayer(e),n=r&&(r.getBounds||r.getExtent);if(n){const e=yield n.call(r);e&&this.fitBounds(e,t)}})}isBaseLayer(e){const t=this.getLayer(e);if(t&&t.id)return-1!==this._baselayers.indexOf(t.id)}getBaseLayers(){const e=[];return this._baselayers.forEach(t=>{const r=this._layers[t];r&&e.push(r)}),e}getBaseLayersIds(){return this._baselayers}getLayer(e){return"string"==typeof e?this._layers[e]:e}getLayerId(e){const t=this.getLayer(e);if(t){if(t.id)return null==t?void 0:t.id;if(t&&t.options)return t.options.id}throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort((e,t)=>e.order&&t.order?e.order-t.order:0)}findLayer(e){for(const t in this._layers){const r=this._layers[t];if(e(r))return r}}isLayerVisible(e){const t=this.getLayer(e);return!(!t||void 0===t.options.visibility)&&t.options.visibility}addBaseLayer(e,t){return cl(this,null,function*(){return yield this.addLayer(e,al(sl({},t),{baselayer:!0}),void 0)})}addLayer(e){return cl(this,arguments,function*(e,t={},r){var o,i;const s=this._layersIdCounter++,a=n(r)?r:void 0!==t.order?t.order:this.reserveOrder();let l;"string"==typeof e?l=this.getLayerAdapter(e):"function"==typeof e?l=e:"then"in e&&(l=yield e);const c=t;this._updateGeoJsonOptions(c);const u=null==(o=(t=sl({id:String(s),order:a},t)).visibility)||o;if(t.visibility=!1,t.baselayer&&(t.order=0),this.options.onBeforeAddLayer){const e=this.options.onBeforeAddLayer({options:t,adapter:l});e&&(e.options&&(t=e.options),e.adapter&&(l=e.adapter))}if(void 0!==l){const e=new l(this.mapAdapter.map,t);let r;e.options=sl(sl({},t),e.options),e.options.baselayer&&(t.baselayer=!0,t.order=0,e.options.order=0),e.options.id&&(r=String(e.options.id),this._layers[r]=e),this._emitLayerEvent("layer:preadd",r||"",e),yield this.onMapLoad(),e.map=this.mapAdapter.map;const n=yield e.addLayer(e.options);if(e.layer=n,e.id=e.options.id||String(s),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(i=e.options.order)?i:a,r&&delete this._layers[r],r=String(e.id),this._layers[r])throw Error(`layer with id '${r}' already exist`);r&&(this._layers[r]=e,c.filter&&this.filterLayer(e,c.filter),t.baselayer&&this._baselayers.push(r),u&&(yield this.showLayer(r)));const o=t.opacity;null!=o&&o<=1&&this.setLayerOpacity(e,o);const p=n&&(e.getBounds||e.getExtent);if(t.fit&&p){const t=yield p.call(e);t&&(yield this.fitBounds(t))}return t.onAdded&&t.onAdded(e),this._emitLayerEvent("layer:add",r,e),e}return Promise.reject("No adapter")})}addLayerFromAsyncAdapter(e,t,r){return cl(this,null,function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),o=e(),i=yield o;return i?this.addLayer(i,t,n):Promise.reject("No adapter")})}removeLayers(e){for(const t in this._layers){let r=!0;e&&(r=e(t,this._layers[t])),r&&(this.removeLayer(t),delete this._layers[t])}}getLegend(e){return cl(this,null,function*(){const t=[];for(const r of this.orderedLayers())r.getLegend&&t.push(r.getLegend(e));return(yield Promise.all(t)).flat()})}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers((e,t)=>!(t&&t.options&&t.options.baselayer))}removeLayer(e){const t=this.getLayer(e),r=t&&this.getLayerId(t);if(t&&r){if(this.emitter.emit("layer:preremove",t),t.beforeRemove&&t.beforeRemove(),t.removeLayer?t.removeLayer():this.mapAdapter.removeLayer(t.layer),t.options&&t.options.baselayer){const e=this._baselayers.indexOf(r);e&&this._baselayers.splice(e,1)}delete this._layers[r],this.emitter.emit("layer:remove",t)}}addGeoJsonLayer(e={},t){return(e=e||{}).multiselect=void 0!==e.multiselect&&e.multiselect,e.unselectOnSecondClick=void 0===e.unselectOnSecondClick||e.unselectOnSecondClick,t||(e=Ea(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",al(sl({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",al(sl({},t),{url:r}))}showLayer(e,t={}){return this.toggleLayer(e,!0,t)}hideLayer(e,t={}){return this.toggleLayer(e,!1,t)}toggleLayer(e,t,r={}){const n=this.getLayer(e),o=void 0!==t?t:!(n&&n.options.visibility),i=void 0!==r.silent&&r.silent,s=e=>cl(this,null,function*(){const t=String(e.id),r=o?"layer:show":"layer:hide";if(i||(this._emitLayerEvent(o?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),o&&this.mapAdapter){const t=e.options.baselayer?0:e.options.order;if(e.options.baselayer&&this._baselayers.length){const t=this._baselayers.filter(t=>t!==e.id&&this.isLayerVisible(t));for(const e of t)yield this.hideLayer(e)}e.showLayer?yield e.showLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.showLayer(e.layer)),void 0!==t&&this.mapAdapter.setLayerOrder(e.layer,t,this._layers)}else e.hideLayer?yield e.hideLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.hideLayer(e.layer));e.options.visibility=o,i||(this._emitLayerEvent(r,t,e),this._emitLayerEvent("layer:toggle",t,e))});return n?this.onMapLoad().then(()=>s(n)):Promise.resolve()}updateLayer(e,t){const r=this.getLayer(e);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer(t));if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then(()=>this.showLayer(r,{silent:!0}))}return Promise.resolve()}setLayerOpacity(e,t){const r=this.getLayer(e);r&&(r.setOpacity?r.setOpacity(t):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,t))}isLayerLabelVisible(e){var t;const r=this.getLayer(e);return r.isLabelVisible?r.isLabelVisible():null==(t=r.options.labelVisibility)||t}showLayerLabel(e){this.toggleLayerLabel(e,!0)}hideLayerLabel(e){this.toggleLayerLabel(e,!1)}toggleLayerLabel(e,t){const r=this.getLayer(e);return t=null!=t?t:!this.isLayerLabelVisible(e),r&&(t?r.showLabel&&(r.options.labelVisibility=!0,r.showLabel()):r.hideLabel&&(r.options.labelVisibility=!1,r.hideLabel()),r.id&&this._emitLayerEvent("layer:label:toggle",r.id,r)),t}selectLayer(e,t){const r=this.getLayer(e);if(r){r&&r.select&&r.select(t);const e=this.getLayerId(r);e&&this._selectedLayers.push(e)}}unSelectLayer(e,t){const r=this.getLayer(e);if(r){const e=r&&r;e.unselect&&e.unselect(t);const n=this.getLayerId(r);if(n){const e=this._selectedLayers.indexOf(n);-1!==e&&this._selectedLayers.splice(e,1)}}}unSelectLayers(){const e=Object.values(this.allLayers());let t;for(t of e)t.unselect&&t.unselect()}filterLayer(e,t){const r=this.getLayer(e);return r.filter?r.filter(t):[]}propertiesFilter(e,t,r){const n=this.getLayer(e);if(n){const e=n;if(e.propertiesFilter)return e.propertiesFilter(t,r);e.filter&&this.filterLayer(e,e=>!e.feature||!e.feature.properties||Ht(e.feature.properties,t))}return Promise.resolve()}removeLayerFilter(e){const t=this.getLayer(e);t.removeFilter?t.removeFilter():t.filter&&t.filter(()=>!0)}setLayerData(e,t){const r=this.getLayer(e);if(r){if(r.setData)return r.setData(t);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(t)}return Promise.resolve()}addLayerData(e,t){const r=this.getLayer(e);r.addData&&r.addData(t)}clearLayerData(e,t){const r=this.getLayer(e);r&&r.clearLayer&&r.clearLayer(t)}setLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.setPaint&&r.setPaint(t)}setLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.setSelectedPaint&&r.setSelectedPaint(t)}updateLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.updatePaint&&r.updatePaint(t)}updateLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(t)}getAttributions(e){const t=[];for(const r in this._layers){const n=this._layers[r];let o=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(o&&e.onlyBaselayer&&(o=this._baselayers.includes(r)),o){const e=n.options&&n.options.attribution;e&&t.push(e)}}return t}getActiveBaseLayer(){const e=this.getBaseLayers().find(e=>this.isLayerVisible(e));if(e)return this.getLayer(e)}addTileJsonLayer(e){return this.addLayer("TILE",{url:e.tiles[0],maxZoom:e.maxzoom,minZoom:e.minzoom,subdomains:e.scheme,attribution:e.attribution})}_emitLayerEvent(e,t,r){const o=String(e);if(n(t)&&o.startsWith("layer:")){const e=o.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return cl(this,null,function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)})}_onLayerDoubleClick(e){return cl(this,null,function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)})}_onLayerSelect(e){return cl(this,null,function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)})}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:o,onDoubleClick:i,onLayerClick:s,onMouseOut:a,onMouseOver:l}=e,c=o||s,u=i||s;e.onClick=e=>(c&&c(e),this._onLayerClick(e)),e.onDoubleClick=e=>(u&&u(e),this._onLayerDoubleClick(e)),e.onMouseOut=e=>{const t=e.layer.id;a&&a(e),n(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;l&&l(e),n(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const p=t||r;e.onSelect=e=>(p&&p(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=La({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=La({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}var pl=Object.defineProperty,hl=(e,t,r)=>((e,t,r)=>t in e?pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),dl=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const fl=class e extends ul{constructor(){super(...arguments),hl(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),hl(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return dl(this,null,function*(){let n;if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,r):e,n)return new Promise(e=>{this._setControlQueue(t,()=>dl(this,null,function*(){const r=yield n,o=this.mapAdapter.addControl(r,t);e(o)}))})})}createControl(e,t){return dl(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)})}createButtonControl(e){return dl(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)})}createToggleControl(e){return dl(this,null,function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?Rs(this.mapAdapter.createButtonControl,e):void 0})}removeControl(e){"remove"in e?e.remove():this.mapAdapter.removeControl&&Promise.resolve(e).then(e=>{this.mapAdapter.removeControl(e)})}getControl(t,r){const n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);{const n=e.controls[t];if(n)return n(this,r)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return dl(this,null,function*(){if(this._loadControlQueue[e].length){this._isControlLoading[e]=!0;const t=this._loadControlQueue[e][0];yield t(),this._loadControlQueue[e].splice(0,1),this._applyControls(e)}else this._isControlLoading[e]=!1})}};hl(fl,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let yl=fl;var ml=Object.getOwnPropertySymbols,bl=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable,vl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),wl=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}),_l=(e,t,r)=>(t=e[vl("asyncIterator")])?t.call(e):(e=e[vl("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:i}),o)))),r("next"),r("return"),t);class Ol extends yl{constructor(e){super(e),this._addControls(),Ns(this.id,this)}static get(e){return Ts(e)}_addLayerProviders(){return wl(this,null,function*(){try{for(var e,t,r,n=_l(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.getLayerAdapters){const t=yield e.getLayerAdapters.call(e);if(t)try{for(var o,i,s,a=_l(t);o=!(i=yield a.next()).done;o=!1){const e=i.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(i){s=[i]}finally{try{o&&(i=a.return)&&(yield i.call(a))}finally{if(s)throw s[0]}}}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}})}_onLoadSync(){return wl(this,null,function*(){try{for(var e,t,r,n=_l(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.onLoadSync)try{yield e.onLoadSync.call(e,this)}catch(o){console.error(o)}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}})}_addControls(){this.options.controls&&this.options.controls.forEach(e=>{let t=e,r={};"string"==typeof e&&this.options.controlsOptions&&this.options.controlsOptions[e]&&(r=this.options.controlsOptions[e],void 0!==r.control&&(t=r.control));const n=r,{position:o}=n,i=((e,t)=>{var r={};for(var n in e)bl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&ml)for(var n of ml(e))t.indexOf(n)<0&&gl.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,o||"top-left",i)}),this._emitStatusEvent("controls:create")}}function Ll(){return["ZOOM","ATTRIBUTION"]}function Pl(e){return t=this,r=null,n=function*(){return new Ol(e).onLoad()},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var Il=Object.defineProperty,xl=Object.defineProperties,jl=Object.getOwnPropertyDescriptors,El=Object.getOwnPropertySymbols,Al=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,kl=(e,t,r)=>t in e?Il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ml=(e,t)=>{for(var r in t||(t={}))Al.call(t,r)&&kl(e,r,t[r]);if(El)for(var r of El(t))Cl.call(t,r)&&kl(e,r,t[r]);return e},Sl=(e,t)=>xl(e,jl(t));function Tl(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(Sl(Ml({},r),{resource:t}));else if(Array.isArray(t)){const[o,i]=t;e.push(Ml(Sl(Ml({},r),{resource:o,id:i}),n))}else"object"==typeof t&&e.push(Ml(Ml(Ml({},r),t),n))}var Nl=Object.defineProperty,Rl=Object.defineProperties,$l=Object.getOwnPropertyDescriptors,Fl=Object.getOwnPropertySymbols,Bl=Object.prototype.hasOwnProperty,ql=Object.prototype.propertyIsEnumerable,Dl=(e,t,r)=>t in e?Nl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const Ul={target:"map",baseUrl:"",whitlabel:!1,controls:["ZOOM","ATTRIBUTION"],controlsOptions:{ZOOM:{position:"top-left"},ATTRIBUTION:{position:"bottom-right",customAttribution:['<a href="https://nextgis.com" target="_blank">©NextGIS</a>']}},pixelRadius:10};function Vl(e){const t=[new Uo];var n;return e.starterKits&&e.starterKits.forEach(e=>{t.push(e)}),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new ht({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=r(Ul,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new cs({connector:e.connector,auth:e.auth})),n=((e,t)=>{for(var r in t||(t={}))Bl.call(t,r)&&Dl(e,r,t[r]);if(Fl)for(var r of Fl(t))ql.call(t,r)&&Dl(e,r,t[r]);return e})({},e),e=Rl(n,$l({starterKits:t,create:!1}))}var Gl=Object.defineProperty,zl=Object.defineProperties,Zl=Object.getOwnPropertyDescriptors,Wl=Object.getOwnPropertySymbols,Jl=Object.getPrototypeOf,Hl=Object.prototype.hasOwnProperty,Ql=Object.prototype.propertyIsEnumerable,Kl=Reflect.get,Xl=(e,t,r)=>t in e?Gl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yl=(e,t)=>{for(var r in t||(t={}))Hl.call(t,r)&&Xl(e,r,t[r]);if(Wl)for(var r of Wl(t))Ql.call(t,r)&&Xl(e,r,t[r]);return e},ec=(e,t)=>zl(e,Zl(t)),tc=(e,t,r)=>Xl(e,"symbol"!=typeof t?t+"":t,r),rc=(e,t,r)=>Kl(Jl(e),r,t),nc=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const oc=class e extends Ol{constructor(e){super(Vl(e)),tc(this,"emitter",new M),tc(this,"connector"),tc(this,"_ngwLayers",{}),tc(this,"$$selectFromNgwRaster"),tc(this,"$$selectFromNgwVector"),tc(this,"_promises",{select:[],identify:[]}),e.connector&&(this.connector=e.connector),this._createWebMap().then(()=>{const e=this.getContainer();e&&e.classList.add("ngw-map-container"),this.options.whitlabel&&this._whiteLabel()})}addControl(t,r,n){return nc(this,null,function*(){return yield this.onLoad("controls:create"),rc(e.prototype,this,"addControl").call(this,t,r,n)})}addNgwLayer(e){return nc(this,null,function*(){yield this.onMapLoad();const{keyname:t,resourceId:r,filters:o}=e;(t||void 0!==r)&&console.warn(`DEPRECATED WARN: ${"set `resource` options instead of `keyname` or `resourceId`"}`);const i=e.resource;if(!t&&!r&&!i)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(n(this.options.baseUrl))try{e.adapterOptions=e.adapterOptions||{},n(this.options.setViewDelay)&&(n(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay)),n(o)&&(e.adapterOptions.propertiesFilter=o);const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),ts(e,t,r)}(e,this,this.connector),r=Yl(Yl({visibility:!0},e),e.adapterOptions),i=yield this.addLayer(t,r),s=i&&this.getLayerId(i);if(i&&s&&(this._ngwLayers[s]={layer:i,resourceId:i.resourceId},i.options.name=i.options.name||i.item&&i.item.resource.display_name,i.options.baselayer)){if(this.getActiveBaseLayer())return i}return i}catch(s){const e=y(i)&&"id"in i?i.id:t||r||i;console.error(`Can't add NGW layer ${e}.`,s)}})}fit(){const{center:e,zoom:t,bounds:r}=this.options;e?(this.setCenter(e),t&&this.setZoom(t)):r&&this.fitBounds(r)}fetchNgwLayerItem(e){return Fr(Yl({connector:this.connector},e))}fetchNgwLayerItems(e){return Ir(Yl({connector:this.connector},e))}fetchNgwLayerFeature(e){return vs(Yl({connector:this.connector},e))}fetchNgwLayerFeatures(e){return ni(Yl({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=new AbortController,n=r.signal;(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",r.abort),(t=t||{}).signal=n;const o=function(e){const{connector:t,identify:r}=e,n=Cs(r);return n&&n.length?Fr(Es(Es({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",o,r),o}fetchIdentifyGeoJson(e,{multiple:t,signal:r}={}){const n=new AbortController;if(r){if(r.aborted)return Promise.reject(new ht.errors.AbortError);r.addEventListener("abort",()=>{n.abort("AbortError")})}const o=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const i in r){const e=Number(i);if(!isNaN(e)){const e=r[i];if("features"in e){const t=e.features.find(e=>e.geom);if(t&&t.geom){const e=t.geom;return Promise.resolve(ar(As(Es({},t),{geom:e})))}}}}const o=Cs(r);return o&&o.length?vs(Es(As(Es({},n),{connector:t}),o[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,multiple:t,requestOptions:{signal:n.signal}});return o&&"then"in o?(this._addPromise("identify",o,n),o):Promise.resolve(o)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,{multiple:t})}getNgwLayers(){return nc(this,null,function*(){return yield this.onLoad(),this._ngwLayers})}getNgwLayerByResourceId(e){return nc(this,null,function*(){for(const t in this._ngwLayers){const r=this._ngwLayers[t];if(r.resourceId===e)return r&&r.layer;if(r.layer.getIdentificationIds){const t=yield r.layer.getIdentificationIds();if(t&&t.some(t=>t===e))return r.layer}if(r.layer.getDependLayers){const t=r.layer.getDependLayers().find(t=>t.item&&"style_parent_id"in t.item&&void 0!==t.item.style_parent_id&&t.item.style_parent_id===e);if(t)return t.layer}}})}fitLayer(t,r){return nc(this,null,function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const o=n&&this._ngwLayers[n];if(o)if(o.layer.getBounds){const e=yield o.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(o.layer.item)e=o.layer.item;else{const t=o.resourceId;e=yield this.connector.getResource(t)}e&&this.fitResource(e.resource.id)}else rc(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)})}fitResource(e,t){return nc(this,null,function*(){const r=yield this.connector.resources.getIdOrFail(e),n=yield Pt({resourceId:r,connector:this.connector});n&&this.fitBounds(n,t)})}zoomToLayer(e){return nc(this,null,function*(){return this.fitLayer(e)})}onLoad(e="ngw-map:create"){return super.onLoad(e)}removeLayer(e){const t=this.getLayer(e);if(t){const e=this.getLayerId(t);e&&delete this._ngwLayers[e],super.removeLayer(t)}}enableSelection(){this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=e=>{this._getSelectListenersCount()&&this.selectFromNgwRaster(e)},this.$$selectFromNgwVector=e=>{this._getSelectListenersCount()&&this._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))}disableSelection(){this.$$selectFromNgwRaster&&(this.emitter.removeListener("click",this.$$selectFromNgwRaster),this.$$selectFromNgwRaster=void 0),this.$$selectFromNgwVector&&(this.emitter.removeListener("layer:click",this.$$selectFromNgwVector),this.$$selectFromNgwVector=void 0)}getNgwLayerItem(e){return this.fetchNgwLayerItem(e)}getNgwLayerItems(e){return this.fetchNgwLayerItems(e)}getNgwLayerFeature(e){return this.fetchNgwLayerFeature(e)}getNgwLayerFeatures(e){return this.fetchNgwLayerFeatures(e)}cancelPromise(...e){this.cancelPromises(...e)}cancelPromises(...e){e.length||(e=Object.keys(this._promises)),e.forEach(e=>{const t=this._promises[e];t&&(t.forEach(e=>e[1].abort()),this._promises[e]=[])})}selectFromNgwRaster(e){return nc(this,null,function*(){var t;this._emitStatusEvent("ngw:preselect");const r=[],n=Object.values(this._ngwLayers);n.sort((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1);for(const e of n){const n=e.layer,o="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,i=null==(t=n.options.interactive)||t;if(o&&n.options.selectable&&i&&this.isLayerVisible(n)){const e=o.call(n);r.push(e)}}const o=Promise.all(r),s=yield o,a=[];for(const e of s)e&&a.push(...e);if(!a.length)return void this._emitStatusEvent("ngw:select",null);const l=this.options.pixelRadius||10,c=this.getCenter();let u=this.getZoom();if(u=void 0!==u?u:20,!c||!u)return void this._emitStatusEvent("ngw:select",null);const h=function(e,t,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*e[1]/Math.PI))/Math.pow(2,t+8))*5e-4}(c,u,l);let d;if(this.options.highlightIdentification){const t=this.options.highlightIdentification,r="number"==typeof t?t:1e3,[n,o]=e.lngLat;d={type:"Polygon",coordinates:[p(n,o,h)]};const i=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:d}});r!==1/0&&setTimeout(()=>{this.removeLayer(i)},r)}const f=new AbortController,y=function(e,t){i(e);const[r,n]=e.lngLat,{geom:o,radius:s}=t,a=null!=o?o:p(r,n,s);return Ms(As(Es({},t),{geom:a}))}(e,{layers:a,connector:this.connector,radius:h,geom:d,signal:f.signal}).then(t=>{const r=ec(Yl({},t),{resources:a,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n});return this._addPromise("select",y,f),y})}_addPromise(e,t,r){const n=this._promises[e];if(n&&-1===n.findIndex(e=>e[0]===t)){const e=()=>{const e=n.findIndex(e=>e[0]===t);-1!==e&&n.splice(e,1)};t.then(e,e),n.push([t,r])}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}_createWebMap(){return nc(this,null,function*(){yield this.create(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer();const e=[],t=this._isFitFromResource();if(this.options.webmapId&&Tl(e,this.options.webmapId,{fit:t}),this.options.resources&&Array.isArray(this.options.resources))for(const n of this.options.resources){const r={};t||(r.fit=!1),Tl(e,n,{},r)}for(const n of e)try{yield this.addNgwLayer(n)}catch(r){console.warn(r)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()})}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const r={qmsId:e};t&&(r.id=t),this.addBaseLayer("QMS",r)}_selectFromNgwVector(e){const t=e.layer;if(!(t.options.selectable&&this.isLayerVisible(t)))return;const r=t.item&&t.item.resource.id,n=e.feature;if(void 0!==r&&n){const e=n.id;if(e){const t={featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]},o={featureCount:1,[r]:t};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(ec(Yl({},o),{resources:[r],sourceType:"vector"}))),o}}}_prepareToIdentify(e){return ec(Yl({},e),{getIdentifyItems:()=>Cs(e,!0).map(e=>new gs({feature:e.feature,connector:this.connector}))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return nc(this,null,function*(){const e=this.getContainer();if(e){const t=yield ws(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}})}};tc(oc,"getIcon",function(t={}){var r,n,o,i,s,a;const l=null!=(r=t.shape)?r:"circle",c=null!=(n=t.color)?n:"blue",u=null!=(o=t.strokeColor)?o:"white",p=null!=(i=t.size)?i:12,h=null!=(s=t.rotate)?s:0,d=null!=(a=t.anchor)?a:[p/2,p/2],f=void 0!==t.stroke?Number(t.stroke):.8,y=t.p||e[l]||"circle",m="string"==typeof y?y:y(t),b=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(t.svg||function({width:e,height:t,stroke:r=0,content:n}){const o=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${o} -${o} ${12+r} ${12+r}"\n >${n}</svg>`}({width:p,height:p,stroke:f,content:m}));return b.setAttribute("width",String(p)),b.setAttribute("height",String(p)),b.setAttribute("fill",c),f&&(b.setAttribute("stroke",u),b.setAttribute("stroke-width",String(f))),{type:"icon",iconSize:[p,p],iconAnchor:d,html:(new XMLSerializer).serializeToString(b),rotate:h,svg:b}});let ic=oc;function sc(e){return t=this,r=null,n=function*(){return new ic(e).onLoad()},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}export{ic as NgwMap,Ol as WebMap,yl as WebMapControls,ul as WebMapLayers,Xa as WebMapMain,sc as createNgwMap,Rs as createToggleControl,Pl as createWebMap,Ia as detectGeometryType,Pa as findMostFrequentGeomType,Ll as getDefaultControls,Ts as getWebMap,xa as paintTypeAlias,Ns as setWebMap,ja as typeAlias,Ea as updateGeoJsonAdapterOptions};
2
2
  //# sourceMappingURL=ngw-map.esm-browser.prod.js.map