@nextgis/ngw-map 4.0.0-rc.2 → 4.0.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 i=void 0===r.replace||r.replace;t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{const o=-1!==n.indexOf(r);if(!i&&!o||i){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}})})}function r(e,t,n=!1){let i=e;const o=t,s=Array.isArray(o);let a=s&&[]||{};return s&&Array.isArray(o)?n?(i=i||[],a=a.concat(i),o.forEach((e,t)=>{void 0===a[t]?a[t]=e:"object"==typeof e?a[t]=r(i[t],e,n):-1===i.indexOf(e)&&a.push(e)})):a=o:(i&&"object"==typeof i&&Object.keys(i).forEach(function(e){a[e]=i[e]}),Object.keys(o).forEach(function(e){a[e]="object"==typeof o[e]&&o[e]&&"object"==typeof i[e]&&"object"==typeof o[e]?r(i[e],o[e],n):o[e]})),a}function n(e){return null!=e}function i(e){return"string"==typeof e?!!e:n(e)}function o(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 i=r/6371*u,o=i/Math.cos(t*c),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+o*Math.cos(r),c=t+i*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 i=0;i<r.length;i++){if(!h(e[r[i]],t[n[i]],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 e.replace(/([^:]\/)\/+/g,"$1")}function b(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 i=[...n.entries()].map(([e,t])=>`${e}=${t}`).join("&");return`${r.origin}${r.pathname}?${i}`}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:i}=e,o=yield n.connect();let s=o&&o[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},i));throw new Error("Request URL is not set")}},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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,o){let s,a;"object"==typeof r&&"valueToSet"in r?(s=r,n=s.onlyFull,o=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)));o=o?Date.now()+o:void 0;const l={key:e,value:r,props:s,expirationTime:o};return n&&!i(r)?r:(this.cache.push(l),r instanceof Promise?(r.catch(()=>{this.delete(e,a)}),n&&r.then(t=>(i(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;var C;function k(){}function M(){M.init.call(this)}function S(e){return void 0===e._maxListeners?M.defaultMaxListeners:e._maxListeners}function N(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new k,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=S(e))&&i>0&&s.length>i){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=o[t]=r,++e._eventsCount;return e}function R(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function $(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 T(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&&(!C.active||this instanceof C.Domain||(this.domain=C.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,i,o,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,i=T(e,n),o=0;o<n;++o)i[o].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=T(e,i),s=0;s<i;++s)o[s].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=T(e,o),a=0;a<o;++a)s[a].call(r,n,i)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=T(e,s),l=0;l<s;++l)a[l].call(r,n,i,o)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=T(e,i),s=0;s<i;++s)o[s].apply(r,n)}(r,u,this,i)}return!0},M.prototype.on=M.prototype.addListener=function(e,t){return N(this,e,t,!1)},M.prototype.prependListener=function(e,t){return N(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,R(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,R(this,e,t)),this},M.prototype.removeListener=function(e,t){var r,n,i,o,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(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<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,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);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,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&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):$.call(e,t)},M.prototype.listenerCount=$,M.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var F="4.0.0-rc.2";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 Y=Object.defineProperty,X=(e,t,r)=>((e,t,r)=>t in e?Y(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),X(this,"name","ResourceNotFoundError"),X(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 ie 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,ie)}}class oe extends ie{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 ie{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ae extends ie{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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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,i=`/api/lunkwill/${t.id}/summary`,o=`/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(i,{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 o})}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,i]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof i||"number"==typeof i||"boolean"==typeof i)t.push(`${n}=${encodeURIComponent(i)}`);else if(Array.isArray(i)){const e=i.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,i;const o=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}=o,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})(o,["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(i){if(y.signal&&y.signal.aborted)throw i;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 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(i){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 i=t&&ve.test(t);if("blob"===a||i)n=yield e.blob();else{if(!r)throw new se;n=yield e.json()}}catch(i){if("AbortError"===i.name||i instanceof se)throw i;throw new se}if(400<=e.status&&e.status<=599)throw new ae(n);return n});if(r)if("GET"===(null==(i=y.method)?void 0:i.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[i,...o]=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[o.indexOf(e)]=String(t)}else a=n.map(e=>String(e));return m(t+i.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${i}".`)}return String(n)}))}function Me(e,t,...r){const n={url:n=>{return i=null,o=null,s=function*(){var i;const o=yield t.connect();return we(ke(e,null!=(i=t.options.baseUrl)?i:"",o,...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(i,o)).next())});var i,o,s}},i=["get","post","put","delete","patch"];for(const o of i){const i=n=>{var i;const s=n||{},{headers:a}=s,l=Ce(s,["headers"]);if(null==(i=null==n?void 0:n.signal)?void 0:i.aborted)throw new B;return t.connect().then(n=>{var i;const s=ke(e,null!=(i=t.options.baseUrl)?i:"",n,...r),c=f(Ae(Ae({},t.getAuthorizationHeaders()),null!=a?a:{}));return _e(s,(u=Ae({headers:c},l),Le(u,Pe({method:o}))),t.cache);var u})};n[o]=i}return n}function Se(e){return"[object Object]"===Object.prototype.toString.call(e)}let Ne;Ne=(e,t,r={},n,i)=>{r.method=r.method||"GET";const o=new XMLHttpRequest;o.open(r.method||"GET",e,!0),"blob"===r.responseType&&(o.responseType=r.responseType);const s=()=>{try{return JSON.parse(o.responseText)}catch(e){return o.responseText}};o.onload=()=>{-1!==[401,403,404,422,500].indexOf(o.status)&&n(new U(s())),((e=!1)=>{const i=e?n:t;"blob"===r.responseType?i(o.response):o.responseText?i(s()):n({message:""})})()},o.onerror=t=>{n(0===o.status?new K(e):t)},o.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&&o.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(o.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;i&&i(()=>{o.abort()}),o.send(l)};const Re=[];function $e(e){Re.push(e)}var Te=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?Te(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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});let We=0,Je=0;class He{constructor(e){ze(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 Re.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),$e(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,$e(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(),$e(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Re.indexOf(e);-1!==t&&Re.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=t,n=((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})(r,["paramList"]);e=v(e,n)}e=encodeURI(m(e)),r=Ge({withCredentials:this.withCredentials},r);const{cache:i,signal:o,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:p}=r,h=new AbortController,d=h.signal;if(o){if(o.aborted)throw new B;o.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!==i){const r=c||(b=Ge({},f({headers:a,withCredentials:p,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Fe(b,Be({params:t})));return this.cache.add(l||e,y,{props:r,expirationTime:i?void 0:500})}var b;return y()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var i;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 o;Ne(e,r,t,n,e=>{o=e}),null==(i=t.signal)||i.addEventListener("abort",()=>{void 0!==o&&o(),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[i,o]of Object.entries(e))if(-1===Qe.indexOf(i))if(Se(o))if("owner_user"===i){const e=Ke(o,i);Object.assign(r,e)}else"parent"===i&&"id"in o&&(r.parent_id=o.id);else n(o)&&(r[t+i]=o);return r}var Ye=Object.defineProperty,Xe=Object.defineProperties,et=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,it=(e,t,r)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ot=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&it(e,r,t[r]);if(tt)for(var r of tt(t))nt.call(t,r)&&it(e,r,t[r]);return e},st=(e,t)=>Xe(e,et(t)),at=(e,t,r)=>it(e,"symbol"!=typeof t?t+"":t,r),lt=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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 A({namespace:t})}getOne(e,t){const r=ot({},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(ot({},t),{query:ot({serialization:"full"},r)})).then(e=>{const r=Array.isArray(e)?e:e.items;if(null==t?void 0:t.cache)for(const t of r)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return r})}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 i=yield this.connector.route("resource.collection").get(st(ot({},t),{query:{parent:n}})),o=[];for(const s of i)(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&&o.push(this._getChildrenOf(s.resource.id,t,r));return o.length?Promise.all(o).then(()=>r):r})}_cleanResourceItemCache(e){return lt(this,null,function*(){var t;const r=this.cache.all(),n=[];for(const i of r){const r=null==(t=i.props)?void 0:t.id;if(["resource.item","resource"].includes(i.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(i);else{(yield this.getId(r))===e&&n.push(i)}}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 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 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,i=e.extent_right;if(t&&r&&n&&i){const e=[r,t,i,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:i}=e.extent;return[i,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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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,i=function*(){const r=e.resource,n=r;let{keyname:i,resourceId:o}=e;if(r&&("string"==typeof r?i=r:o="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield Ct(r,t)),!o&&i){const e=yield t.getResource(i);e&&(o=e.resource.id)}return o},new Promise((e,t)=>{var o=e=>{try{a(i.next(e))}catch(r){t(r)}},s=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((i=i.apply(r,n)).next())});var r,n,i}var kt=Object.defineProperty,Mt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,Rt=(e,t,r)=>t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$t=(e,t,r)=>Rt(e,"symbol"!=typeof t?t+"":t,r),Tt=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function Ft(e){return Tt(this,arguments,function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){$t(this,"options",{}),$t(this,"layer",[]),$t(this,"_removed",!1),$t(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 Tt(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 Tt(this,null,function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)})}loadLayer(){return Tt(this,null,function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const i=yield n(this);if(i){const n=new i(e.mapAdapter.map,((e,t)=>{for(var r in t||(t={}))St.call(t,r)&&Rt(e,r,t[r]);if(Mt)for(var r of Mt(t))Nt.call(t,r)&&Rt(e,r,t[r]);return e})({},t)),o=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=o,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:i="first-show-adapter"}){return Ft({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=i+"-"+r.resource_id},createAdapter:()=>Xo({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)})},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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=`^${i=t,i.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var i;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,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,Jt(r,t))}function Jt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(3===(r=t).length&&"string"==typeof r[0]&&"string"==typeof r[1]){const[r,n,i]=t,o=Zt[n];if(o){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,(n,o)=>(t=e[o],r.replace(o,i)));return o(t,n)}return o(e[r],i)}return!1}return Jt(e,t);var r},i=t.filter(e=>Array.isArray(e));return"any"===r?i.some(n):i.every(n)}var Ht=Object.defineProperty,Qt=Object.getOwnPropertySymbols,Kt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,Xt=(e,t,r)=>t in e?Ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,er=(e,t)=>{for(var r in t||(t={}))Kt.call(t,r)&&Xt(e,r,t[r]);if(Qt)for(var r of Qt(t))Yt.call(t,r)&&Xt(e,r,t[r]);return e};const tr={srs:4326,geom_format:"geojson",dt_format:"iso"};function rr(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function nr(e,t){const{extensions:r,geom:i,fields:o,srs:s,ilike:a,like:l}=t;e.extensions=r||[],o&&(e.fields=o),void 0!==i&&(e.geom=i,i||(delete e.srs,delete e.geom_format)),n(a)?e.ilike=a:n(l)&&(e.like=l),n(s)&&(e.srs=s)}function ir(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 or(e){const t=er({},tr),{limit:r,query:n,cache:i,signal:o,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),nr(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=ir(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:er(er({},t),n),cache:i,signal:o})}function sr(e){let t;for(t in e){const r=e[t];if(y(r)){const i=r;if(n(i.year)&&n(i.month)&&n(i.day)){const r=[i.year,i.month-1,i.day];"hour"in i&&[i.hour,i.minute,i.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}function ar(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function lr(e){return Array.isArray(e)&&!ar(e)}function cr(e){return"id"===e?["fid"]:["get",e]}function ur(e){const[t,r,n]=e,i=String(t),o=cr(i);switch(r){case"eq":return null===n?["is_null",o]:["==",o,n];case"ne":return null===n?["!is_null",o]:["!=",o,n];case"gt":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "gt" requires number or string for "${i}"`);return[">",o,n];case"lt":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "lt" requires number or string for "${i}"`);return["<",o,n];case"ge":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "ge" requires number or string for "${i}"`);return[">=",o,n];case"le":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "le" requires number or string for "${i}"`);return["<=",o,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 "${i}"`);if(!n.length)throw new Error(`Operator "in" requires non-empty array for "${i}"`);return["in",o,...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 "${i}"`);if(!n.length)throw new Error(`Operator "notin" requires non-empty array for "${i}"`);return["!in",o,...n];case"ilike":{if("string"!=typeof n)throw new Error(`Operator "ilike" requires string for "${i}"`);const e=function(e){const t=e.startsWith("%"),r=e.endsWith("%");return{field:e.slice(t?1:0,r?-1:void 0),leadingWildcard:t,trailingWildcard:r}}(i),t=`${e.leadingWildcard?"%":""}${n}${e.trailingWildcard?"%":""}`;return["ilike",cr(e.field),t]}case"like":throw new Error(`Operator "${r}" is not supported by server FilterExpression`);default:throw new Error(`Unsupported operator: ${r}`)}}function pr(e){let t="all";const r=[];for(const n of e)if("all"!==n&&"any"!==n)if(ar(n))r.push(ur(n));else{if(!lr(n))throw new Error("Invalid PropertiesFilter node");r.push(pr(n))}else t=n;return[t,...r]}function hr(e){return(null==e?void 0:e.length)?pr(e):[]}function dr(e){if(null==e?void 0:e.length)return JSON.stringify(hr(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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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 or(Or(_r({},e),{query:Or(_r({},e.query),{filter:dr(r)})}));return null!=(t=e.clientFilterValidate)&&t&&(n=n.filter(e=>Jt(sr(Or(_r({},e.fields),{id:e.id})),r))),n}return or(e)})}function Ir({options:e,webMap:t,baseUrl:r}){var n;let i,o=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===o){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const i=t+"/api/component/render/image",o={resource:e};return r&&(o.nd=r),{url:i,resourceId:e,headers:n,params:o,updateWmsParams:t=>(r&&(t.nd=r),vi(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});o="TILE"}if("WMS"===o){i=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:i,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===o)return i=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:i,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===o)return i=r+`/api/resource/${a}/terrain_provider`,{url:i,adapter:o};if("MODEL_3D"===o)return i=r+`/api/component/model_3d/${a}/data.glb`,{url:i};if("TILE"===o)return i=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:i,adapter:o}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var xr=Object.defineProperty,jr=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,Ar=Object.getOwnPropertySymbols,Cr=Object.prototype.hasOwnProperty,kr=Object.prototype.propertyIsEnumerable,Mr=(e,t,r)=>t in e?xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Sr=(e,t)=>{for(var r in t||(t={}))Cr.call(t,r)&&Mr(e,r,t[r]);if(Ar)for(var r of Ar(t))kr.call(t,r)&&Mr(e,r,t[r]);return e},Nr=(e,t)=>jr(e,Er(t)),Rr=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function $r(e){return Rr(this,null,function*(){const t=Sr({},tr);nr(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Nr(Sr({},e),{query:t}));return Nr(Sr({},r),{toGeojson:()=>Rr(null,null,function*(){if(r.geom)return rr(r);{const t=(yield $r(Nr(Sr({},e),{geom:!0,fields:null,extensions:null}))).geom;return rr(Nr(Sr({},r),{geom:t}))}})})})}var Tr=Object.defineProperty,Fr=Object.getOwnPropertySymbols,Br=Object.prototype.hasOwnProperty,qr=Object.prototype.propertyIsEnumerable,Dr=(e,t,r)=>t in e?Tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ur=(e,t,r)=>Dr(e,"symbol"!=typeof t?t+"":t,r);class Vr{constructor(e){Ur(this,"options",e),Ur(this,"name"),Ur(this,"resourceId"),Ur(this,"item"),Ur(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:i}=e.extent,o=[r,t,i,n];return this._extent=o,o}})}geoJson(e){return this.item.geom?Promise.resolve(rr(this.item)):$r(((e,t)=>{for(var r in t||(t={}))Br.call(t,r)&&Dr(e,r,t[r]);if(Fr)for(var r of Fr(t))qr.call(t,r)&&Dr(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,rr(this.item)))}}var Gr=Object.defineProperty,zr=(e,t,r)=>((e,t,r)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Zr{constructor(e,t,r){zr(this,"options"),zr(this,"emitter",new M),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 Wr=Object.defineProperty,Jr=Object.getOwnPropertySymbols,Hr=Object.prototype.hasOwnProperty,Qr=Object.prototype.propertyIsEnumerable,Kr=(e,t,r)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yr=(e,t)=>{for(var r in t||(t={}))Hr.call(t,r)&&Kr(e,r,t[r]);if(Jr)for(var r of Jr(t))Qr.call(t,r)&&Kr(e,r,t[r]);return e};const Xr=class e extends Zr{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 i=r[n],o=i.properties&&i.properties.property(this.name);o&&o.set(e,Yr(Yr({},t),{propagation:!0,bubble:!1}))}}}};Kr(Xr,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let en=Xr;var tn=Object.defineProperty,rn=Object.getOwnPropertySymbols,nn=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable,sn=(e,t,r)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,an=(e,t,r)=>sn(e,"symbol"!=typeof t?t+"":t,r);const ln=class e{constructor(e,t){an(this,"item",e),an(this,"options",{}),an(this,"_properties",{}),an(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={}))nn.call(t,r)&&sn(e,r,t[r]);if(rn)for(var r of rn(t))on.call(t,r)&&sn(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}};an(ln,"handlers",{CheckProperty:en});let cn=ln;function un(e,t,r,n){return!!dn(e,t,r,fn)}function pn(e,t,r,n){return dn(e,t,r,yn)}function hn(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 dn(e,t=e=>!!e,r="children",n,i){return n(e,"function"==typeof t?t:e=>Jt(e,t),r)}function fn(e,t=e=>!!e,r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(t(e))return e;const n=hn(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){const e=fn(i[o],t,r,n);if(e)return e}}function yn(e,t=e=>!!e,r,n=[]){let i=[];if(Array.isArray(e))i=e;else{t(e)&&n.push(e);const o=hn(e,r);o&&(i=o)}for(let o=0;o<i.length;o++)i[o]&&yn(i[o],t,r,n);return n}function mn(e,t=e=>!!e,r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(!t(e))return!1;const n=hn(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){if(!mn(i[o],t,r,n))return!1}return!0}var bn=Object.defineProperty,gn=(e,t,r)=>((e,t,r)=>t in e?bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class vn{constructor(e){gn(this,"item"),gn(this,"_children",[]),gn(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 dn(this._children,e,e=>e.tree.getChildren(),fn)}every(e){return!!dn(this._children,e,e=>e.tree.getChildren(),mn)}some(e){return un(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 wn=Object.defineProperty,_n=Object.getOwnPropertySymbols,On=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable,Pn=(e,t,r)=>t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,In=(e,t,r)=>Pn(e,"symbol"!=typeof t?t+"":t,r);let xn=0;class jn{constructor(e){In(this,"options",{}),In(this,"properties"),In(this,"tree"),In(this,"id",xn),xn+=1,this.options=((e,t)=>{for(var r in t||(t={}))On.call(t,r)&&Pn(e,r,t[r]);if(_n)for(var r of _n(t))Ln.call(t,r)&&Pn(e,r,t[r]);return e})({},e),this.tree=new vn(this)}initProperties(){this.properties=new cn(this,this.options.properties)}}function En(e,t){return{[`symbols[${e}]`]:t.join(",")||void 0}}var An=Object.defineProperty,Cn=Object.defineProperties,kn=Object.getOwnPropertyDescriptors,Mn=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Rn=(e,t,r)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$n=(e,t)=>{for(var r in t||(t={}))Sn.call(t,r)&&Rn(e,r,t[r]);if(Mn)for(var r of Mn(t))Nn.call(t,r)&&Rn(e,r,t[r]);return e},Tn=(e,t,r)=>Rn(e,"symbol"!=typeof t?t+"":t,r);class Fn{constructor({legendSymbols:e,resourceId:t,connector:r,layerId:n,legend:i,webMap:o,layer:s,onSymbolRenderChange:a}){Tn(this,"layerId"),Tn(this,"layer"),Tn(this,"resourceId"),Tn(this,"legendSymbols","expand"),Tn(this,"legend"),Tn(this,"layerVisibility",!0),Tn(this,"onSymbolRenderChange"),Tn(this,"webMap"),Tn(this,"connector"),e&&(this.legendSymbols=e),this.connector=r,this.layer=s,this.layerId=n,i&&(this.legend=this.createLegend(i)),this.resourceId=t,this.webMap=o,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($n({},e));return this.legend=t,this.createLegend(t)}},new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});var e,t,r}createLegend(e){return e.map(e=>{return t=$n({},e),Cn(t,kn({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:$n({},En(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],i=n;for(let o=1;o<=t.length;o++)t[o]===i+1?i=t[o]:(r.push(n===i?`${n}`:`${n}-${i}`),n=t[o],i=n);return r}}var Bn=Object.defineProperty,qn=Object.defineProperties,Dn=Object.getOwnPropertyDescriptors,Un=Object.getOwnPropertySymbols,Vn=Object.prototype.hasOwnProperty,Gn=Object.prototype.propertyIsEnumerable,zn=(e,t,r)=>t in e?Bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Zn=(e,t)=>{for(var r in t||(t={}))Vn.call(t,r)&&zn(e,r,t[r]);if(Un)for(var r of Un(t))Gn.call(t,r)&&zn(e,r,t[r]);return e},Wn=(e,t)=>qn(e,Dn(t)),Jn=(e,t,r)=>zn(e,"symbol"!=typeof t?t+"":t,r),Hn=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Qn=class e extends jn{constructor({webMap:t,item:r,options:n,connector:i,parent:o,noInit:s}){if(super(Zn(Zn({},e.options),n)),Jn(this,"item"),Jn(this,"webMap"),Jn(this,"connector"),Jn(this,"layer"),Jn(this,"legend"),Jn(this,"emitter",new M),Jn(this,"_rootDescendantsCount",0),this.webMap=t,i&&(this.connector=i),o&&this.tree.setParent(o),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,i,o){return Hn(this,null,function*(){const s=new e({webMap:t,item:r,options:n,connector:i,parent:o,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 Hn(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 i=new Fn({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 i.create(e),[i]}return[]}}return[]})}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=Wn(Zn({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,Wn(Zn({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===_i){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),_i=t}return _i}()*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"group"!==this.item.item_type||e.group_enabled||this.properties.property("visibility").set(!1),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 i;if("layer"===t.item_type)i=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){i=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return i?this.webMap.addLayer(i,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,i=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,o=[t,n].filter(Boolean),s=[r,i].filter(Boolean);return{minZoom:o.length?Math.max(...o):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(Qn,"GetAdapterFromLayerType",{}),Jn(Qn,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type)return e.item.group_enabled;if("root"===e.item.item_type)return un(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){"group"===(null==r?void 0:r.item.item_type)?r.item.group_enabled=e:"layer"===(null==r?void 0: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 Zr{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 Kn=Qn;var Yn=Object.defineProperty,Xn=Object.defineProperties,ei=Object.getOwnPropertyDescriptors,ti=Object.getOwnPropertySymbols,ri=Object.prototype.hasOwnProperty,ni=Object.prototype.propertyIsEnumerable,ii=(e,t,r)=>t in e?Yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oi=(e,t)=>{for(var r in t||(t={}))ri.call(t,r)&&ii(e,r,t[r]);if(ti)for(var r of ti(t))ni.call(t,r)&&ii(e,r,t[r]);return e},si=(e,t,r)=>ii(e,"symbol"!=typeof t?t+"":t,r),ai=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});class li{constructor(e,t){si(this,"map",e),si(this,"options",t),si(this,"layer"),si(this,"NgwWebmapItem",Kn),si(this,"pixelRadius",10),si(this,"resourceId"),si(this,"webmapClassName","webmap"),si(this,"emitter",new M),si(this,"_extent"),si(this,"webmapResource"),si(this,"_webmapBaselayersIds",[]),si(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 ai(this,null,function*(){var t;this.options=oi(oi({},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 ai(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)})}hideLayer(){return ai(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)})}setOpacity(e){return ai(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 i;const o=null==(i=n.feature_layer)?void 0:i.fields.find(e=>e.label_field),s=o&&o.keyname;return Pr(oi({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then(e=>{const n=[];for(const i of e){const e=new Vr({item:i,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 ai(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 ai(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 ai(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,i=(null==n?void 0:n.options.auth)?n.getAuthorizationHeaders():void 0,o=n.withCredentials,s=(a=oi({},this.options),l={withCredentials:o,headers:i,drawOrderEnabled:null!=(r=e.draw_order_enabled)&&r},Xn(a,ei(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 ai(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 i=!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:i}).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=m(this.options.connector.options.baseUrl+"/api/component/render/image"),i=r.layer_style_id;r.url=n,r.resourceId=i,r.updateWmsParams=e=>vi(e,i);const o=Ir({options:{adapter:r.layer_adapter.toUpperCase(),resource:i},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=oi(oi({},r),o)}return"function"==typeof(null==(n=this.options.nativeOptions)?void 0:n.beforeItemCreated)&&(e=this.options.nativeOptions.beforeItemCreated(e)),e}}var ci=Object.defineProperty,ui=Object.defineProperties,pi=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,di=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,yi=(e,t,r)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mi=(e,t)=>{for(var r in t||(t={}))di.call(t,r)&&yi(e,r,t[r]);if(hi)for(var r of hi(t))fi.call(t,r)&&yi(e,r,t[r]);return e},bi=(e,t)=>ui(e,pi(t)),gi=(e,t)=>{var r={};for(var n in e)di.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&hi)for(var n of hi(e))t.indexOf(n)<0&&fi.call(e,n)&&(r[n]=e[n]);return r};function vi(e,t){const r=e,{bbox:n,width:i,height:o,nd:s}=r,a=gi(r,["bbox","width","height","nd"]);return bi(mi({},a),{resource:Array.isArray(t)?t.join(","):t,extent:n,size:i+","+o,timestamp:Date.now(),nd:null!=s?s:200})}const wi={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 _i;function Oi(e){if(!e)return;const t=e.match(/^(?:SRID=(\d+);)?POLYGON\s*\(\((.+)\)\)\s*$/i);if(!t||t[1]&&"4326"!==t[1])return;const r=t[2].split(",").map(e=>e.trim().split(/\s+/).map(Number)).filter(e=>e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]));if(!r.length)return;const n=r.map(e=>e[0]),i=r.map(e=>e[1]);return[Math.min(...n),Math.min(...i),Math.max(...n),Math.max(...i)]}function Li(e){return e.replace(/^(http|ftp):\/\//,"https://")}function Pi(e){const t=function(e){return e?Object.fromEntries(new URLSearchParams(e).entries()):{}}(e.params),r=Object.entries(t).find(([e])=>"version"===e.toLowerCase());return{type:"wms",service:e,url:Li(e.url),layers:e.layers,format:e.format||"image/png",version:(null==r?void 0:r[1])||"1.3.0",params:t,name:e.name,attribution:e.copyright_text||void 0,extent:Oi(e.extent)}}var Ii=Object.defineProperty,xi=(e,t,r)=>((e,t,r)=>t in e?Ii(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r),ji=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Ei=class e{constructor(){xi(this,"url"),this.url=e.url.replace(/\/$/,"").trim()}getService(e){return ji(this,arguments,function*(e,t={}){const r=yield this._getJson(`${this.url}/api/v1/geoservices/${e}`,t);if("tms"!==r.type&&"wms"!==r.type)throw new Error("Unsupported QMS service type.");return r})}getLayer(e){return ji(this,arguments,function*(e,t={}){const r=yield this.getService(e,t);return"tms"===r.type?function(e){var t,r;const[n,i]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,(e,r)=>("string"==typeof r&&r.split(",").forEach(e=>t.push(e)),"{s}")),t]}(Li(e.origin_url||e.url));return{type:"tms",service:e,url:n,subdomains:i,scheme:e.y_origin_top?"xyz":"tms",name:e.name,attribution:e.copyright_text||void 0,extent:Oi(e.extent),minZoom:null!=(t=e.z_min)?t:void 0,maxZoom:null!=(r=e.z_max)?r:void 0}}(r):Pi(r)})}searchServices(e,t){return ji(this,arguments,function*(e,{limit:t=10,offset:r,signal:n,type:i}){const o=new URLSearchParams({search:e,limit:String(t),type:i});void 0!==r&&o.set("offset",String(r));return(yield this._getJson(`${this.url}/api/v1/geoservices/?${o}`,{signal:n})).results})}_getJson(e,t){return ji(this,arguments,function*(e,{signal:t}){const r=yield fetch(e,{signal:t});if(!r.ok)throw new Error(`QMS request failed with status ${r.status}: ${e}`);return r.json()})}};xi(Ei,"url","https://qms.nextgis.com");let Ai=Ei;var Ci=Object.defineProperty,ki=Object.defineProperties,Mi=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,Ni=Object.prototype.hasOwnProperty,Ri=Object.prototype.propertyIsEnumerable,$i=(e,t,r)=>t in e?Ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ti=(e,t)=>{for(var r in t||(t={}))Ni.call(t,r)&&$i(e,r,t[r]);if(Si)for(var r of Si(t))Ri.call(t,r)&&$i(e,r,t[r]);return e},Fi=(e,t)=>ki(e,Mi(t)),Bi=(e,t)=>{var r={};for(var n in e)Ni.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Si)for(var n of Si(e))t.indexOf(n)<0&&Ri.call(e,n)&&(r[n]=e[n]);return r},qi=(e,t,r)=>$i(e,"symbol"!=typeof t?t+"":t,r),Di=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Ui={tms:"TILE",wms:"WMS"};function Vi(e,t={}){let r;if("webMap"in e){const n=e,{webMap:i}=n,o=Bi(n,["webMap"]);r=i,t=o}else r=e;const n=new Ai;class i{constructor(e,r){qi(this,"qms"),qi(this,"options"),qi(this,"map"),this.map=e;const n=Ti(Ti({},t),r);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return Di(this,null,function*(){var t,o,s;const a=null!=(t=e.signal)?t:this.options.signal,l=null!=(s=e.qmsId)?s:null==(o=this.qms)?void 0:o.id;var c,u;if("number"==typeof l)try{const t=yield n.getLayer(l,{signal:a});this.qms=t.service;const o=Ui[t.type],s=r.mapAdapter.layerAdapters[o];if(s){c=i,u=s,["showLayer","hideLayer"].forEach(e=>{const t=Object.getOwnPropertyDescriptor(u.prototype,e);t&&Object.defineProperty(c.prototype,e,t)}),e=Fi(Ti(Ti(Ti({},"TILE"===o?{order:0,maxZoom:r.options.maxZoom,minZoom:r.options.minZoom}:{}),this.options),function(e){return"tms"===e.type?{url:"tms"===e.scheme?e.url.replace("{y}","{-y}"):e.url,subdomains:e.subdomains,maxZoom:e.maxZoom,minZoom:e.minZoom,name:e.name,attribution:e.attribution}:{url:e.url,layers:e.layers,format:e.format,version:e.version,params:e.params,name:e.name,attribution:e.attribution}}(t)),{signal:a}),this.options=e;return new s(this.map,e).addLayer(e)}}catch(p){if(null==a?void 0:a.aborted)throw p;console.error(p)}})}}return i}var Gi=Object.defineProperty;class zi{getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return Vi({webMap:e})}}((e,t,r)=>{((e,t,r)=>{t in e?Gi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,t+"",r)})(zi,"utils",{createQmsAdapter:Vi});var Zi=Object.defineProperty,Wi=Object.defineProperties,Ji=Object.getOwnPropertyDescriptors,Hi=Object.getOwnPropertySymbols,Qi=Object.getPrototypeOf,Ki=Object.prototype.hasOwnProperty,Yi=Object.prototype.propertyIsEnumerable,Xi=Reflect.get,eo=(e,t,r)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,to=(e,t)=>{for(var r in t||(t={}))Ki.call(t,r)&&eo(e,r,t[r]);if(Hi)for(var r of Hi(t))Yi.call(t,r)&&eo(e,r,t[r]);return e},ro=(e,t)=>Wi(e,Ji(t)),no=(e,t,r)=>Xi(Qi(e),r,t),io=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});var oo=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function so(e){return function(e){return oo(this,null,function*(){const t=yield Pr(e),r=[];return t.forEach(e=>{r.push(rr(e))}),r})}(e).then(e=>({type:"FeatureCollection",features:e}))}const ao=["fields","intersects","limit","orderBy","strategy"];function lo(e){const t={};return ao.forEach(r=>{const n=e[r];void 0!==n&&(t[r]=n)}),t}var co=Object.defineProperty,uo=Object.defineProperties,po=Object.getOwnPropertyDescriptors,ho=Object.getOwnPropertySymbols,fo=Object.getPrototypeOf,yo=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,bo=Reflect.get,go=(e,t,r)=>t in e?co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vo=(e,t)=>{for(var r in t||(t={}))yo.call(t,r)&&go(e,r,t[r]);if(ho)for(var r of ho(t))mo.call(t,r)&&go(e,r,t[r]);return e},wo=(e,t)=>uo(e,po(t)),_o=(e,t,r)=>go(e,"symbol"!=typeof t?t+"":t,r),Oo=(e,t,r)=>bo(fo(e),r,t),Lo=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function Po(e){return Lo(this,null,function*(){var t,r;const{item:n,webMap:i,Adapter:o,connector:s,layerOptions:a,addLayerOptionsPriority:l}=e,c=null==l||l,u=a,p=o||a.Adapter||i.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)=>Lo(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},so(vo({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),_o(this,"emitter",new M),_o(this,"__onMapMove"),_o(this,"__onMapMoveStart"),_o(this,"__enableMapMoveListener"),_o(this,"__disableMapMoveListener")}addLayer(e){return Lo(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=wi[n.vector_layer.geometry_type]),u.adapterOptions&&(e=c?vo(vo({},u.adapterOptions),e):vo(vo({},e),u.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const i=e.strategy||void 0;this.options.strategy=i;const o=Oo(w.prototype,this,"addLayer").call(this,e);let s;return d={filters:e.propertiesFilter,options:lo(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),i&&i.startsWith("BBOX")&&!y&&this._addBboxEventListener(),o})}getExtent(){return this.getBounds()}getBounds(){return Lo(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}):Oo(w.prototype,this,"getBounds")?Oo(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 Lo(this,null,function*(){var t;const r=e||d||{};if(null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield i.onLoad("create"),r.options=r.options||{},r.options.intersects=i.getBounds();const{minZoom:e,maxZoom:t}=this.options,n=i.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),i._emitLayerEvent("layer:preupdate",u.id||"",r);const e=yield b(r.filters,wo(vo({},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 i.addLayerData(this,t)}else y=void 0!==n&&e.features.length>=n,yield i.setLayerData(this,e);this.emitter.emit("updated",e),i._emitLayerEvent("layer:updated",u.id||"",{data:e,newData:t,isFull:y})}catch(n){if(n instanceof Error&&"AbortError"!==n.name)throw n}Oo(w.prototype,this,"updateLayer")&&Oo(w.prototype,this,"updateLayer").call(this)}})}propertiesFilter(e,t){return Lo(this,null,function*(){if(v(),this.filter&&y)this.filter(t=>{if(!e)return!0;const r=t.feature&&t.feature.properties&&sr(vo({},t.feature.properties));return!r||Jt(r,e)});else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(null!=e?e:void 0,wo(vo({},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()},i.emitter.on("layer:show",this.__enableMapMoveListener),i.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&i.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&i.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...i){n.clear(),r=setTimeout(()=>{r=null,e.apply(this,i)},t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}(()=>this.updateLayer()),this.__onMapMoveStart=v,i.emitter.on("movestart",this.__onMapMoveStart),i.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&i.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&i.emitter.removeListener("movestart",this.__onMapMoveStart)}}return w})}var Io=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function xo(e,t){const r=dr(t);return void 0===r?{}:{[`filter[${e}]`]:r}}var jo=Object.defineProperty,Eo=Object.defineProperties,Ao=Object.getOwnPropertyDescriptors,Co=Object.getOwnPropertySymbols,ko=Object.prototype.hasOwnProperty,Mo=Object.prototype.propertyIsEnumerable,So=(e,t,r)=>t in e?jo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,No=(e,t)=>{for(var r in t||(t={}))ko.call(t,r)&&So(e,r,t[r]);if(Co)for(var r of Co(t))Mo.call(t,r)&&So(e,r,t[r]);return e},Ro=(e,t)=>Eo(e,Ao(t)),$o=(e,t)=>{var r={};for(var n in e)ko.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Co)for(var n of Co(e))t.indexOf(n)<0&&Mo.call(e,n)&&(r[n]=e[n]);return r},To=(e,t,r)=>So(e,"symbol"!=typeof t?t+"":t,r),Fo=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function Bo(e){return Fo(this,arguments,function*({layerOptions:e,connector:t,webMap:r,item:i}){const o=i.resource.cls;let s=e.adapter||o&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[o]||"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 o=yield Ct(e,t);return class extends a{constructor(a,l){super(a,l),To(this,"map",a),To(this,"item",i),To(this,"resourceId",o),To(this,"blocked",!1),To(this,"layerVisibility");const c=Ir({options:e,webMap:r,baseUrl:t.options.baseUrl||""});if(c){const t=e.adapterOptions||{},{propertiesFilter:r}=t,i=$o(t,["propertiesFilter"]),a=xo(o,r),l=Ro(No(No({},c),i),{params:No({resource:o},a),url:"TILE"===s&&c.url?b(c.url,No({resource:String(o)},a)):c.url,layers:c.layers||String(o),resourceId:o});e.adapterOptions&&n(e.adapterOptions.setViewDelay)&&(l.setViewDelay=e.adapterOptions.setViewDelay),this.options=No(No({},this.options),l)}}addLayer(e){return super.addLayer(No(No({},this.options),e))}propertiesFilter(e){return Fo(this,null,function*(){var t;const r=this.options,n=`filter[${this.resourceId}]`,i=No(No({},r.params||{}),xo(this.resourceId,null!=e?e:void 0));e||delete i[n],r.params=i,null==(t=this.updateLayer)||t.call(this,{params:i})})}getIdentificationIds(){return Fo(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 Fo(this,null,function*(){const n=this.options.id;if(void 0!==n){const i=yield t.route("render.legend_symbols",{id:o}).get(No({cache:!0},e));return[new Fn({layerId:n,layer:this,resourceId:o,webMap:r,legend:i})]}return[]})}}}throw new Error(s+" not supported yet. Only TILE")})}var qo=Object.defineProperty,Do=Object.defineProperties,Uo=Object.getOwnPropertyDescriptors,Vo=Object.getOwnPropertySymbols,Go=Object.prototype.hasOwnProperty,zo=Object.prototype.propertyIsEnumerable,Zo=(e,t,r)=>t in e?qo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wo=(e,t)=>{for(var r in t||(t={}))Go.call(t,r)&&Zo(e,r,t[r]);if(Vo)for(var r of Vo(t))zo.call(t,r)&&Zo(e,r,t[r]);return e},Jo=(e,t)=>Do(e,Uo(t)),Ho=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Qo={},Ko=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Yo(e){return Ho(this,arguments,function*({layerOptions:e,webMap:t,connector:r,item:n}){const i=n.resource.id,o=yield r.getResourceChildren(i),s=o&&o[0];if(s)return Xo(Jo(Wo({},e),{resource:s.resource.id}),t,r)})}function Xo(e,r,n){return Ho(this,null,function*(){let i,o;const s=e.adapter,a=yield Ct(e,n);if(a){const t=e.resource;if(o=t&&t.resource&&void 0!==t.resource.id?t:yield n.getResource(a),!o)throw"Resource item is not found";{const t=o.resource.cls,l={layerOptions:Jo(Wo({},e),{resource:a}),connector:n,webMap:r,item:o};if(-1!==Ko.indexOf(t))if("webmap"===t)i=function(e){return Io(this,arguments,function*({layerOptions:e,webMap:t,connector:r}){const n=yield Ct(e,r);return class extends li{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||o.vector_layer&&wi[o.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==s&&"GEOJSON"!==s){if("MVT"!==s)return Yo(l);i=Bo(l)}else i=Po(l)}else{if("raster_layer"===t)return Yo(l);if("basemap_layer"===t)i=function(e){return io(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(Vi(e,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return io(this,null,function*(){if(n)return no(e.prototype,this,"addLayer").call(this,ro(to({},t),{url:n}))})}}return e}}}})}(l);else if("GEOJSON"===s&&o.resource.parent){const t=yield n.getResource(o.resource.parent.id);if(t){const r=Jo(Wo({},e),{resource:o.resource.parent.id});i=Po(Jo(Wo({},l),{item:t,layerOptions:r}))}}else i=Bo(l)}else{if(!Qo[t])throw`Resource class '${t}' not yet supported.`;{const e=Qo[t];let r;r=s&&"function"!=typeof r?e[s]:e,r&&(i=r(l))}}}}if(i)return i.then(e=>{if(e){const r=e;return o&&(r.prototype.item=o,r.prototype.resourceId=o.resource.id,r.prototype.connector=n),t(r,[At],{replace:!1}),r}})})}var es=Object.defineProperty,ts=Object.getOwnPropertySymbols,rs=Object.prototype.hasOwnProperty,ns=Object.prototype.propertyIsEnumerable,is=(e,t,r)=>t in e?es(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,os=(e,t)=>{for(var r in t||(t={}))rs.call(t,r)&&is(e,r,t[r]);if(ts)for(var r of ts(t))ns.call(t,r)&&is(e,r,t[r]);return e},ss=(e,t,r)=>is(e,"symbol"!=typeof t?t+"":t,r);class as{constructor(e){if(ss(this,"options",e),ss(this,"url"),ss(this,"connector"),ss(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){Qo[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(li,os({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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 li{constructor(e,r){super(e,r=mi(mi({},t),r))}};var t}}var ls=Object.defineProperty,cs=Object.getOwnPropertySymbols,us=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable,hs=(e,t,r)=>t in e?ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ds=(e,t)=>{for(var r in t||(t={}))us.call(t,r)&&hs(e,r,t[r]);if(cs)for(var r of cs(t))ps.call(t,r)&&hs(e,r,t[r]);return e},fs=(e,t,r)=>hs(e,"symbol"!=typeof t?t+"":t,r),ys=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});class ms{constructor(e){fs(this,"id"),fs(this,"label"),fs(this,"layerId"),fs(this,"parent"),fs(this,"fields"),fs(this,"geom"),fs(this,"extensions"),fs(this,"connector"),fs(this,"_item"),fs(this,"_geojson"),fs(this,"_resource"),fs(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):$r(ds({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 ys(this,null,function*(){return(yield this.composite(e)).feature_layer})}composite(e){return ys(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:i}){return r.route("feature_layer.feature.item_extent",{id:Number(e),fid:t}).get({cache:n,signal:i}).then(e=>{if(e&&e.extent){const{maxLat:t,maxLon:r,minLat:n,minLon:i}=e.extent;return[i,n,r,t]}})}(ds({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 bs(e){return t=this,r=null,n=function*(){return rr(yield $r(e))},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())});var t,r,n}function gs(e,t){return r=this,n=null,i=function*(){var r,n;const i=yield e.route("pyramid.settings").get({query:{component:"pyramid"}}),o=i&&"company_logo"in i?i.company_logo:void 0;if(o&&o.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 i=new Uint8Array(n),o=new Blob([i],{type:e}),l=(window.URL||window.webkitURL).createObjectURL(o);s.src=l}return null!==o.link&&""!==o.link.trim()&&(i.href=o.link,i.target="_blank",-1!==o.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),i.appendChild(s),i}},new Promise((e,t)=>{var o=e=>{try{a(i.next(e))}catch(r){t(r)}},s=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((i=i.apply(r,n)).next())});var r,n,i}var vs=Object.defineProperty,ws=Object.defineProperties,_s=Object.getOwnPropertyDescriptors,Os=Object.getOwnPropertySymbols,Ls=Object.prototype.hasOwnProperty,Ps=Object.prototype.propertyIsEnumerable,Is=(e,t,r)=>t in e?vs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xs=(e,t)=>{for(var r in t||(t={}))Ls.call(t,r)&&Is(e,r,t[r]);if(Os)for(var r of Os(t))Ps.call(t,r)&&Is(e,r,t[r]);return e},js=(e,t)=>ws(e,_s(t));function Es(e,t=!1){const r=[],n=[];for(const o in e){const e=Number(o);isNaN(e)||r.push(e)}const i=e.resources;i&&r.sort((e,t)=>i.indexOf(e)-i.indexOf(t));for(let o=0;o<r.length;o++){const i=r[o],s=e[i];if("features"in s){const e=As(s.features,Number(i),t);if(e.length&&(n.push(...e),!t))break}}return n}function As(e,t,r){const n=[];for(const i of e){if(n.push({featureId:i.id,resourceId:t,feature:i}),!r)break}return n}function Cs(e){const{geom:t,signal:r,cache:n,layers:i}=e,o="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(!o)throw new Error("Not valid geometry format to make intersection");const a={geom:o,srs:3857,layers:i};return e.connector.route("feature_layer.identify").post({json:a,signal:r,cache:n})}const ks={};function Ms(e){return ks[e]}function Ss(e,t){ks[e]=t}function Ns(e,t){const r=document.createElement("div"),n=new Set;let i=!1;t.getStatus?i=t.getStatus():t.status&&(i=t.status);const o=t.title||"",s=t.html;function a(){o&&(r.title="string"==typeof o?o:i?o.on:o.off,r.setAttribute("aria-label",r.title))}function l(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function c(){s&&("string"==typeof s||s instanceof HTMLElement?l(s):l(i?s.on:s.off),r.setAttribute("aria-label",r.title))}function u(e,t){e.split(" ").forEach(e=>{t?r.classList.add(e):r.classList.remove(e)})}function p(){t.addClassOn&&u(t.addClassOn,i),t.addClassOff&&u(t.addClassOff,!i)}function h(e){n.forEach(t=>t(i,e))}a(),c(),t.addClass&&u(t.addClass,!0),p();const d=e=>{void 0!==e&&(i=e),c(),a(),p()},f=e=>{if(void 0===e&&i&&y.disableOnSecondClick)return;const r=i;if(i=void 0!==e?e:!i,t.onClick){let e;try{e=t.onClick(i)}catch(n){throw i=r,d(),n}Promise.resolve(e).then(()=>{d(),r!==i&&h(y)}).catch(()=>{i=r,d()})}else d(),r!==i&&h(y)},y=e({html:r,onClick:f});return y.onClick=f,y.changeStatus=d,y.getStatus=()=>i,y.switch=t.switch,void 0!==t.disableOnSecondClick&&(y.disableOnSecondClick=t.disableOnSecondClick),y.onStatusChange=e=>(n.add(e),()=>n.delete(e)),y}function Rs(e){return(t,r)=>{const n=t.map(e=>e());return e(n,r)}}const $s={"!":Rs(function([e]){return!e}),"!=":Rs(function([e,t]){return e!==t}),"<":Rs(function([e,t]){return e<t}),"<=":Rs(function([e,t]){return e<=t}),"==":Rs(function([e,t]){return e===t}),">":Rs(function([e,t]){return e>t}),">=":Rs(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(),i=r.splice(-1,r.length%2)[0];for(let o=0;o<r.length-1;o+=2){if(r[o]()===n)return r[o+1]()}return i()}},Ts={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 Fs(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Bs(e);if("string"==typeof(t=e)&&t in Ts)return function(e){return Bs(Ts[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 Bs(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 qs(e,t,r,n,i){if("number"==typeof r&&"number"==typeof i)return r+(e-t)/(n-t)*(i-r);try{const o=Fs(r),s=Fs(i);return function(e){return`rgb(${e.join(",")})`}(o.map((r,i)=>Math.ceil(qs(e,t,r,n,s[i]))))}catch(o){console.log(o)}throw new Error("Unsupported output type for linear interpolation.")}const Ds={step:e=>{const[t,r,...n]=e,i=t();if("number"!=typeof i)return r();for(let o=0;o<n.length-2;o+=2){const e=n[o](),t=n[o+1](),r=n[o+2]();if(i>=e&&i<r)return t}return i>=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 i=e();for(let o=0;o<r.length-2;o+=2){const e=r[o](),t=r[o+1](),s=r[o+2](),a=r[o+3]();if(n>=e&&n<=s&&"linear"===i[0])return qs(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Us={get:Rs(function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null}),length:Rs(([e])=>{if("string"==typeof e||Array.isArray(e))return e.length}),at:Rs(function([e,t]){return t[e]}),has:Rs(function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))}),in:Rs(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":Rs(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:Rs(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}.`)})},Vs={"+":Rs(e=>e.reduce((e,t)=>e+t,0)),"-":Rs(e=>e.reduce((e,t)=>e-t)),"*":Rs(e=>e.reduce((e,t)=>e*t,1)),"/":Rs(e=>e.reduce((e,t)=>e/t)),"%":Rs(e=>e[0]%e[1]),"^":Rs(e=>Math.pow(e[0],e[1])),abs:Rs(e=>Math.abs(e[0])),acos:Rs(e=>Math.acos(e[0])),asin:Rs(e=>Math.asin(e[0])),atan:Rs(e=>Math.atan(e[0])),ceil:Rs(e=>Math.ceil(e[0])),cos:Rs(e=>Math.cos(e[0])),e:()=>Math.E,floor:Rs(e=>Math.floor(e[0])),ln:Rs(e=>Math.log(e[0])),ln2:()=>Math.LN2,log10:Rs(e=>Math.log10(e[0])),log2:Rs(e=>Math.log2(e[0])),max:Rs(e=>Math.max(...e)),min:Rs(e=>Math.min(...e)),pi:()=>Math.PI,round:Rs(e=>Math.round(e[0])),sin:Rs(e=>Math.sin(e[0])),sqrt:Rs(e=>Math.sqrt(e[0])),tan:Rs(e=>Math.tan(e[0]))},Gs={concat:Rs(e=>e.reduce((e,t)=>String(e)+String(t),"")),downcase:Rs(e=>String(e[0]).toLowerCase()),upcase:Rs(e=>String(e[0]).toUpperCase())},zs=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function Zs(e){return(t,r)=>{for(const n of t){const t=zs(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Ws={array:Rs(e=>{const[t,r,n]=e;let i,o,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(i=t,"number"==typeof r?(o=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(i&&!s.every(e=>typeof e===i))throw new Error(`Expected all items in array to be of type ${i}`);if(o&&s.length!==o)throw new Error(`Expected array of length ${o}`);return s}),boolean:Rs(Zs(e=>"boolean"==typeof e?e:void 0)),literal:Rs(([e])=>e),number:Rs(Zs(e=>"number"==typeof e?e:void 0)),object:Rs(Zs(e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e)),string:Rs(Zs(e=>"string"==typeof e?e:void 0)),"to-boolean":Rs(Zs(Boolean)),"to-number":Rs(Zs(Number)),"to-string":Rs(Zs(String)),typeof:Rs(([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 Js=Object.defineProperty,Hs=Object.getOwnPropertySymbols,Qs=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable,Ys=(e,t,r)=>t in e?Js(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xs=(e,t)=>{for(var r in t||(t={}))Qs.call(t,r)&&Ys(e,r,t[r]);if(Hs)for(var r of Hs(t))Ks.call(t,r)&&Ys(e,r,t[r]);return e};function ea(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in ta&&r.length>0}return!1}const ta=Xs(Xs(Xs(Xs(Xs(Xs({},Vs),Ws),Gs),Us),$s),Ds);function ra(e,t={}){const[r,...n]=e,i=ta[r];if(i)return i(n.map(e=>()=>ea(e)?ra(e,t):e),t);throw new Error(`Expression "${r}" is not supported.`)}var na=Object.defineProperty,ia=Object.getOwnPropertySymbols,oa=Object.prototype.hasOwnProperty,sa=Object.prototype.propertyIsEnumerable,aa=(e,t,r)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,la=(e,t)=>{for(var r in t||(t={}))oa.call(t,r)&&aa(e,r,t[r]);if(ia)for(var r of ia(t))sa.call(t,r)&&aa(e,r,t[r]);return e};function ca(e){return t=>{const r=t.properties;return!!r&&ra(e,r)}}const ua=["iconSize","iconAnchor"];function pa(e){return"function"==typeof e}var ha=Object.defineProperty,da=Object.getOwnPropertySymbols,fa=Object.prototype.hasOwnProperty,ya=Object.prototype.propertyIsEnumerable,ma=(e,t,r)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ba=(e,t)=>{for(var r in t||(t={}))fa.call(t,r)&&ma(e,r,t[r]);if(da)for(var r of da(t))ya.call(t,r)&&ma(e,r,t[r]);return e};function ga(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?ba(ba({},t),n[1]):t}}function va({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===ua.indexOf(n)){const i=n,o=e[i];ea(o)&&(t=!0,r[i]=ca(o))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return la(la({},e),n)}}(e);if(r){const n=e=>_a({paint:r(e),defaultPaint:t});return n.paint=wa({paint:e,defaultPaint:t}),n}return wa({paint:e,defaultPaint:t})}function wa({paint:e,defaultPaint:t}){var r;let n=ba({},t);return n=ba(ba({},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 _a({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=ba({},t);if(pa(e)){const n=n=>{const i=_a({paint:e(n),defaultPaint:t,getPaintFunctions:r});return i.type=e.type,i};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>_a({paint:ga(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const i=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);i&&(n=_a({paint:i,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=va({paint:e,defaultPaint:t})}return pa(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}var Oa=Object.defineProperty,La=Object.defineProperties,Pa=Object.getOwnPropertyDescriptors,Ia=Object.getOwnPropertySymbols,xa=Object.prototype.hasOwnProperty,ja=Object.prototype.propertyIsEnumerable,Ea=(e,t,r)=>t in e?Oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Aa=(e,t)=>{for(var r in t||(t={}))xa.call(t,r)&&Ea(e,r,t[r]);if(Ia)for(var r of Ia(t))ja.call(t,r)&&Ea(e,r,t[r]);return e};function Ca(e){return!!e&&Object.keys(e).length>0}function ka(e){if(!e)return;const t=Aa({},e);return function(e){return!(!e||!(Ca(e.headers)||void 0!==e.credentials||void 0!==e.cache&&"default"!==e.cache))}(t)?t:void 0}function Ma(e){const t=null==e?void 0:e.request,r=Aa(Aa({},(null==e?void 0:e.headers)||{}),(null==t?void 0:t.headers)||{}),n={};return Ca(r)&&(n.headers=r),(null==e?void 0:e.withCredentials)&&(n.credentials="include"),void 0!==(null==t?void 0:t.credentials)&&(n.credentials=t.credentials),void 0!==(null==t?void 0:t.cache)&&(n.cache=t.cache),ka(n)}function Sa(e){const t=Ma(e);return r=Aa({},e),La(r,Pa({request:t}));var r}function Na(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 Ra(e){let t;if("FeatureCollection"===e.type){t=Na(e.features.map(e=>e.geometry.type))}else if("GeometryCollection"===e.type){t=Na(e.geometries.map(e=>e.type))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const $a={polygon:"path",line:"path",point:"circle"},Ta={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Fa(e){if(e.data){const t=Ta[Ra(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":$a[t]),e.type=e.type||t}return e}var Ba=Object.defineProperty,qa=(e,t,r)=>((e,t,r)=>t in e?Ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Da{constructor(){qa(this,"backspace",8),qa(this,"tab",9),qa(this,"enter",13),qa(this,"shift",16),qa(this,"ctrl",17),qa(this,"alt",18),qa(this,"pause/break",19),qa(this,"caps_lock",20),qa(this,"escape",27),qa(this,"page_up",33),qa(this,"page_down",34),qa(this,"end",35),qa(this,"home",36),qa(this,"left_arrow",37),qa(this,"up_arrow",38),qa(this,"right_arrow",39),qa(this,"down_arrow",40),qa(this,"insert",45),qa(this,"delete",46),qa(this,"left_window_key",91),qa(this,"right_window_key",92),qa(this,"select_key",93),qa(this,"numpad_0",96),qa(this,"numpad_1",97),qa(this,"numpad_2",98),qa(this,"numpad_3",99),qa(this,"numpad_4",100),qa(this,"numpad_5",101),qa(this,"numpad_6",102),qa(this,"numpad_7",103),qa(this,"numpad_8",104),qa(this,"numpad_9",105),qa(this,"multiply",106),qa(this,"add",107),qa(this,"subtract",109),qa(this,"decimal_point",110),qa(this,"divide",111),qa(this,"f1",112),qa(this,"f2",113),qa(this,"f3",114),qa(this,"f4",115),qa(this,"f5",116),qa(this,"f6",117),qa(this,"f7",118),qa(this,"f8",119),qa(this,"f9",120),qa(this,"f10",121),qa(this,"f11",122),qa(this,"f12",123),qa(this,"num_lock",144),qa(this,"scroll_lock",145),qa(this,"semi-colon",186),qa(this,"equal_sign",187),qa(this,",",188),qa(this,"-",189),qa(this,".",190),qa(this,"/",191),qa(this,"`",192),qa(this,"[",219),qa(this,"\\",220),qa(this,"]",221),qa(this,"'",222)}}var Ua=Object.defineProperty,Va=(e,t,r)=>((e,t,r)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var Ga=Object.defineProperty,za=(e,t,r)=>((e,t,r)=>t in e?Ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Za{constructor(e,t){za(this,"webMap",e),za(this,"name"),za(this,"event"),za(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 Wa=Object.defineProperty,Ja=(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 Ha extends Za{constructor(){super(...arguments),Ja(this,"name","bounds"),Ja(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,Ka=(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 Ya extends Za{constructor(){super(...arguments),Ka(this,"name","center"),Ka(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 Xa=Object.defineProperty,el=(e,t,r)=>((e,t,r)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class tl extends Za{constructor(){super(...arguments),el(this,"name","zoom"),el(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 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),il=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});let ol=0;const sl={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},al=class e{constructor(t){nl(this,"options",sl),nl(this,"emitter",new M),nl(this,"keys",e.keys),nl(this,"mapAdapter"),nl(this,"runtimeParams",[]),nl(this,"getPaintFunctions",e.getPaintFunctions),nl(this,"mapStateItems",[Ya,tl,Ha]),nl(this,"id",ol++),nl(this,"mapState",[]),nl(this,"_initMapState",{}),nl(this,"_starterKits"),nl(this,"_extent"),nl(this,"_eventsStatus",{}),nl(this,"_coordFromMapClickAbort"),nl(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(sl||{},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 il(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,i]=e,o=t<n&&r<i;if(!o){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${i}]`);const e=[Math.min(t,n),Math.min(r,i),Math.max(t,n),Math.max(i,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&i<=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)},i=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&i?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",i),this._coordFromMapClickAbort=void 0},i=t=>{n(),o(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",i),this._coordFromMapClickAbort=n})}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return il(this,null,function*(){})}_onLoadSync(){return il(this,null,function*(){})}_setupMap(){return il(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)})}};nl(al,"keys",new class{constructor(){Va(this,"keyCodeAlias",new Da),Va(this,"keys",{}),Va(this,"_windowOnFocus"),Va(this,"_keysPressed"),Va(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={}}}),nl(al,"getPaintFunctions");let ll=al;var cl=Object.defineProperty,ul=Object.defineProperties,pl=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,dl=Object.prototype.hasOwnProperty,fl=Object.prototype.propertyIsEnumerable,yl=(e,t,r)=>t in e?cl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ml=(e,t)=>{for(var r in t||(t={}))dl.call(t,r)&&yl(e,r,t[r]);if(hl)for(var r of hl(t))fl.call(t,r)&&yl(e,r,t[r]);return e},bl=(e,t)=>ul(e,pl(t)),gl=(e,t,r)=>yl(e,"symbol"!=typeof t?t+"":t,r),vl=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});class wl extends ll{constructor(e){super(e),gl(this,"_layersIdCounter",1),gl(this,"_layersOrderCounter",1),gl(this,"_baselayers",[]),gl(this,"_layers",{}),gl(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",()=>this.addTileJsonLayer(t))}fitLayer(e,t){return vl(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 vl(this,null,function*(){return yield this.addLayer(e,bl(ml({},t),{baselayer:!0}),void 0)})}addLayer(e){return vl(this,arguments,function*(e,t={},r){var i,o;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==(i=(t=ml({id:String(s),order:a},t)).visibility)||i;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(t=bl(ml({},t),{request:this._getLayerRequestOptions(t)}),void 0!==l){const e=new l(this.mapAdapter.map,t);let r;e.options=ml(ml({},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!=(o=e.options.order)?o: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 i=t.opacity;null!=i&&i<=1&&this.setLayerOpacity(e,i);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 vl(this,null,function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),i=e(),o=yield i;return o?this.addLayer(o,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 vl(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=Fa(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",bl(ml({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",bl(ml({},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),i=void 0!==t?t:!(n&&n.options.visibility),o=void 0!==r.silent&&r.silent,s=e=>vl(this,null,function*(){const t=String(e.id),r=i?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(i?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),i&&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=i,o||(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=>!t||(!e.feature||!e.feature.properties||Jt(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 i=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(i&&e.onlyBaselayer&&(i=this._baselayers.includes(r)),i){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,request:e.request})}_getLayerRequestOptions(e){var t,r,n,i;const o=ka(this.options.layerRequest),s=Ma(e),a=ml(ml({},(null==o?void 0:o.headers)||{}),(null==s?void 0:s.headers)||{}),l=!1===e.withCredentials&&void 0===(null==(t=e.request)?void 0:t.credentials)&&void 0!==(null==o?void 0:o.credentials)?"same-origin":null!=(r=null==s?void 0:s.credentials)?r:null==o?void 0:o.credentials,c=void 0!==(null==(n=e.request)?void 0:n.cache)?e.request.cache:null!=(i=null==s?void 0:s.cache)?i:null==o?void 0:o.cache;return ka(ml(ml(ml(ml(ml({},o),s),Object.keys(a).length?{headers:a}:{}),void 0!==l?{credentials:l}:{}),void 0!==c?{cache:c}:{}))}_emitLayerEvent(e,t,r){const i=String(e);if(n(t)&&i.startsWith("layer:")){const e=i.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return vl(this,null,function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)})}_onLayerDoubleClick(e){return vl(this,null,function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)})}_onLayerSelect(e){return vl(this,null,function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)})}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:i,onDoubleClick:o,onLayerClick:s,onMouseOut:a,onMouseOver:l}=e,c=i||s,u=o||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=_a({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=_a({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}var _l=Object.defineProperty,Ol=Object.getOwnPropertySymbols,Ll=Object.prototype.hasOwnProperty,Pl=Object.prototype.propertyIsEnumerable,Il=(e,t,r)=>((e,t,r)=>t in e?_l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),xl=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const jl=class e extends wl{constructor(){super(...arguments),Il(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[],inside:[]}),Il(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1,inside:!1})}addControl(e,t,r){return xl(this,null,function*(){let n;const{addOptions:i,createOptions:o}=this._splitControlOptions(r);if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,o):e,n)return new Promise(e=>{this._setControlQueue(this._getControlQueueKey(t),()=>xl(this,null,function*(){const r=yield n,o=this.mapAdapter.addControl(r,t,i);e(o)}))})})}createControl(e,t){return xl(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)})}createButtonControl(e){return xl(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)})}createToggleControl(e){return xl(this,null,function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?Ns(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()}_getControlQueueKey(e){return"string"==typeof e?e:"inside"}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return xl(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})}_splitControlOptions(e){if(!e)return{};const t=e,{id:r,order:n}=t,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&&Ol)for(var n of Ol(e))t.indexOf(n)<0&&Pl.call(e,n)&&(r[n]=e[n]);return r})(t,["id","order"]);return{addOptions:this._getAddControlOptions(r,n),createOptions:i}}_getAddControlOptions(e,t){return void 0!==e||void 0!==t?{id:e,order:t}:void 0}};Il(jl,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let El=jl;var Al=Object.defineProperty,Cl=Object.defineProperties,kl=Object.getOwnPropertyDescriptors,Ml=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,Nl=Object.prototype.propertyIsEnumerable,Rl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),$l=(e,t,r)=>t in e?Al(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tl=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}),Fl=(e,t,r)=>(t=e[Rl("asyncIterator")])?t.call(e):(e=e[Rl("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise((r,i,o)=>(t=n.call(e,t),o=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:o}),i)))),r("next"),r("return"),t);class Bl extends El{constructor(e){super(e),this._addControls(),Ss(this.id,this)}static get(e){return Ms(e)}_addLayerProviders(){return Tl(this,null,function*(){try{for(var e,t,r,n=Fl(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 i,o,s,a=Fl(t);i=!(o=yield a.next()).done;i=!1){const e=o.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(o){s=[o]}finally{try{i&&(o=a.return)&&(yield o.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 Tl(this,null,function*(){try{for(var e,t,r,n=Fl(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(i){console.error(i)}}}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,{id:i,order:o,position:s}=n,a=((e,t)=>{var r={};for(var n in e)Sl.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&&Nl.call(e,n)&&(r[n]=e[n]);return r})(n,["id","order","position"]);var l;this.addControl(t,s||"top-left",(l=((e,t)=>{for(var r in t||(t={}))Sl.call(t,r)&&$l(e,r,t[r]);if(Ml)for(var r of Ml(t))Nl.call(t,r)&&$l(e,r,t[r]);return e})({},a),Cl(l,kl({id:i,order:o}))))}),this._emitStatusEvent("controls:create")}}function ql(){return["ZOOM","ATTRIBUTION"]}function Dl(e){return t=this,r=null,n=function*(){return new Bl(e).onLoad()},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())});var t,r,n}var Ul=Object.defineProperty,Vl=Object.defineProperties,Gl=Object.getOwnPropertyDescriptors,zl=Object.getOwnPropertySymbols,Zl=Object.prototype.hasOwnProperty,Wl=Object.prototype.propertyIsEnumerable,Jl=(e,t,r)=>t in e?Ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hl=(e,t)=>{for(var r in t||(t={}))Zl.call(t,r)&&Jl(e,r,t[r]);if(zl)for(var r of zl(t))Wl.call(t,r)&&Jl(e,r,t[r]);return e},Ql=(e,t)=>Vl(e,Gl(t));function Kl(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(Ql(Hl({},r),{resource:t}));else if(Array.isArray(t)){const[i,o]=t;e.push(Hl(Ql(Hl({},r),{resource:i,id:o}),n))}else"object"==typeof t&&e.push(Hl(Hl(Hl({},r),t),n))}var Yl=Object.defineProperty,Xl=Object.defineProperties,ec=Object.getOwnPropertyDescriptors,tc=Object.getOwnPropertySymbols,rc=Object.prototype.hasOwnProperty,nc=Object.prototype.propertyIsEnumerable,ic=(e,t,r)=>t in e?Yl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const oc={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 sc(e){const t=[new zi];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(oc,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new as({connector:e.connector,auth:e.auth})),n=((e,t)=>{for(var r in t||(t={}))rc.call(t,r)&&ic(e,r,t[r]);if(tc)for(var r of tc(t))nc.call(t,r)&&ic(e,r,t[r]);return e})({},e),e=Xl(n,ec({starterKits:t,create:!1}))}var ac=Object.defineProperty,lc=Object.defineProperties,cc=Object.getOwnPropertyDescriptors,uc=Object.getOwnPropertySymbols,pc=Object.getPrototypeOf,hc=Object.prototype.hasOwnProperty,dc=Object.prototype.propertyIsEnumerable,fc=Reflect.get,yc=(e,t,r)=>t in e?ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mc=(e,t)=>{for(var r in t||(t={}))hc.call(t,r)&&yc(e,r,t[r]);if(uc)for(var r of uc(t))dc.call(t,r)&&yc(e,r,t[r]);return e},bc=(e,t)=>lc(e,cc(t)),gc=(e,t,r)=>yc(e,"symbol"!=typeof t?t+"":t,r),vc=(e,t,r)=>fc(pc(e),r,t),wc=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const _c=class e extends Bl{constructor(e){super(sc(e)),gc(this,"emitter",new M),gc(this,"connector"),gc(this,"_ngwLayers",{}),gc(this,"$$selectFromNgwRaster"),gc(this,"$$selectFromNgwVector"),gc(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 wc(this,null,function*(){return yield this.onLoad("controls:create"),vc(e.prototype,this,"addControl").call(this,t,r,n)})}addNgwLayer(e){return wc(this,null,function*(){yield this.onMapLoad();const{keyname:t,resourceId:r,filters:i}=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{e.adapterOptions=e.adapterOptions||{},n(this.options.setViewDelay)&&(n(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay)),n(i)&&(e.adapterOptions.propertiesFilter=i);const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),Xo(e,t,r)}(e,this,this.connector),r=mc(mc({visibility:!0},e),e.adapterOptions),o=yield this.addLayer(t,r),s=o&&this.getLayerId(o);if(o&&s&&(this._ngwLayers[s]={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(s){const e=y(o)&&"id"in o?o.id:t||r||o;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 $r(mc({connector:this.connector},e))}fetchNgwLayerItems(e){return Pr(mc({connector:this.connector},e))}fetchNgwLayerFeature(e){return bs(mc({connector:this.connector},e))}fetchNgwLayerFeatures(e){return so(mc({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 i=function(e){const{connector:t,identify:r}=e,n=Es(r);return n&&n.length?$r(xs(xs({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",i,r),i}fetchIdentifyGeoJson(e,{signal:t}={}){const r=new AbortController;if(t){if(t.aborted)return Promise.reject(new ht.errors.AbortError);t.addEventListener("abort",()=>{r.abort("AbortError")})}const n=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const o in r){const e=Number(o);if(!isNaN(e)){const e=r[o];if("features"in e){const t=e.features.find(e=>e.geom);if(t&&t.geom){const e=t.geom;return Promise.resolve(rr(js(xs({},t),{geom:e})))}}}}const i=Es(r);return i&&i.length?bs(xs(js(xs({},n),{connector:t}),i[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:{signal:r.signal}});return n&&"then"in n?(this._addPromise("identify",n,r),n):Promise.resolve(n)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,{multiple:t})}getNgwLayers(){return wc(this,null,function*(){return yield this.onLoad(),this._ngwLayers})}getNgwLayerByResourceId(e){return wc(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 wc(this,null,function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const i=n&&this._ngwLayers[n];if(i)if(i.layer.getBounds){const e=yield i.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(i.layer.item)e=i.layer.item;else{const t=i.resourceId;e=yield this.connector.getResource(t)}e&&this.fitResource(e.resource.id)}else vc(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)})}fitResource(e,t){return wc(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 wc(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 wc(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,i="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,o=null==(t=n.options.interactive)||t;if(i&&n.options.selectable&&o&&this.isLayerVisible(n)){const e=i.call(n);r.push(e)}}const i=Promise.all(r),s=yield i,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,i]=e.lngLat;d={type:"Polygon",coordinates:[p(n,i,h)]};const o=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:d}});r!==1/0&&setTimeout(()=>{this.removeLayer(o)},r)}const f=new AbortController,y=function(e,t){o(e);const[r,n]=e.lngLat,{geom:i,radius:s}=t,a=null!=i?i:p(r,n,s);return Cs(js(xs({},t),{geom:a}))}(e,{layers:a,connector:this.connector,radius:h,geom:d,signal:f.signal}).then(t=>{const r=bc(mc({},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 wc(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&&Kl(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),Kl(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}]},i={featureCount:1,[r]:t};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(bc(mc({},i),{resources:[r],sourceType:"vector"}))),i}}}_prepareToIdentify(e){return bc(mc({},e),{getIdentifyItems:()=>Es(e,!0).map(e=>new ms({feature:e.feature,connector:this.connector}))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return wc(this,null,function*(){const e=this.getContainer();if(e){const t=yield gs(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}})}};gc(_c,"getIcon",function(t={}){var r,n,i,o,s,a;const l=null!=(r=t.shape)?r:"circle",c=null!=(n=t.color)?n:"blue",u=null!=(i=t.strokeColor)?i:"white",p=null!=(o=t.size)?o: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 i=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${i} -${i} ${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 Oc=_c;function Lc(e){return t=this,r=null,n=function*(){return new Oc(e).onLoad()},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())});var t,r,n}export{Oc as NgwMap,Bl as WebMap,El as WebMapControls,wl as WebMapLayers,ll as WebMapMain,Sa as applyLayerRequestOptions,Lc as createNgwMap,Ns as createToggleControl,Dl as createWebMap,Ra as detectGeometryType,Na as findMostFrequentGeomType,ql as getDefaultControls,Ma as getLayerRequestOptions,Ms as getWebMap,ka as normalizeLayerRequestOptions,$a as paintTypeAlias,Ss as setWebMap,Ta as typeAlias,Fa 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 i=void 0===r.replace||r.replace;t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{const o=-1!==n.indexOf(r);if(!i&&!o||i){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}})})}function r(e,t,n=!1){let i=e;const o=t,s=Array.isArray(o);let a=s&&[]||{};return s&&Array.isArray(o)?n?(i=i||[],a=a.concat(i),o.forEach((e,t)=>{void 0===a[t]?a[t]=e:"object"==typeof e?a[t]=r(i[t],e,n):-1===i.indexOf(e)&&a.push(e)})):a=o:(i&&"object"==typeof i&&Object.keys(i).forEach(function(e){a[e]=i[e]}),Object.keys(o).forEach(function(e){a[e]="object"==typeof o[e]&&o[e]&&"object"==typeof i[e]&&"object"==typeof o[e]?r(i[e],o[e],n):o[e]})),a}function n(e){return null!=e}function i(e){return"string"==typeof e?!!e:n(e)}function o(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 i=r/6371*u,o=i/Math.cos(t*c),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+o*Math.cos(r),c=t+i*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 i=0;i<r.length;i++){if(!h(e[r[i]],t[n[i]],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 e.replace(/([^:]\/)\/+/g,"$1")}function b(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 i=[...n.entries()].map(([e,t])=>`${e}=${t}`).join("&");return`${r.origin}${r.pathname}?${i}`}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:i}=e,o=yield n.connect();let s=o&&o[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},i));throw new Error("Request URL is not set")}},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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,o){let s,a;"object"==typeof r&&"valueToSet"in r?(s=r,n=s.onlyFull,o=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)));o=o?Date.now()+o:void 0;const l={key:e,value:r,props:s,expirationTime:o};return n&&!i(r)?r:(this.cache.push(l),r instanceof Promise?(r.catch(()=>{this.delete(e,a)}),n&&r.then(t=>(i(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;var C;function k(){}function M(){M.init.call(this)}function S(e){return void 0===e._maxListeners?M.defaultMaxListeners:e._maxListeners}function N(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new k,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=S(e))&&i>0&&s.length>i){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=o[t]=r,++e._eventsCount;return e}function R(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function $(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 T(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&&(!C.active||this instanceof C.Domain||(this.domain=C.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,i,o,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,i=T(e,n),o=0;o<n;++o)i[o].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=T(e,i),s=0;s<i;++s)o[s].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=T(e,o),a=0;a<o;++a)s[a].call(r,n,i)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,a=T(e,s),l=0;l<s;++l)a[l].call(r,n,i,o)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=T(e,i),s=0;s<i;++s)o[s].apply(r,n)}(r,u,this,i)}return!0},M.prototype.on=M.prototype.addListener=function(e,t){return N(this,e,t,!1)},M.prototype.prependListener=function(e,t){return N(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,R(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,R(this,e,t)),this},M.prototype.removeListener=function(e,t){var r,n,i,o,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(i=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<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,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);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,i=Object.keys(r),o=0;o<i.length;++o)"removeListener"!==(n=i[o])&&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):$.call(e,t)},M.prototype.listenerCount=$,M.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var F="4.0.0";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 Y=Object.defineProperty,X=(e,t,r)=>((e,t,r)=>t in e?Y(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),X(this,"name","ResourceNotFoundError"),X(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 ie 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,ie)}}class oe extends ie{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 ie{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ae extends ie{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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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,i=`/api/lunkwill/${t.id}/summary`,o=`/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(i,{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 o})}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,i]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof i||"number"==typeof i||"boolean"==typeof i)t.push(`${n}=${encodeURIComponent(i)}`);else if(Array.isArray(i)){const e=i.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,i;const o=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}=o,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})(o,["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(i){if(y.signal&&y.signal.aborted)throw i;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 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(i){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 i=t&&ve.test(t);if("blob"===a||i)n=yield e.blob();else{if(!r)throw new se;n=yield e.json()}}catch(i){if("AbortError"===i.name||i instanceof se)throw i;throw new se}if(400<=e.status&&e.status<=599)throw new ae(n);return n});if(r)if("GET"===(null==(i=y.method)?void 0:i.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[i,...o]=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[o.indexOf(e)]=String(t)}else a=n.map(e=>String(e));return m(t+i.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${i}".`)}return String(n)}))}function Me(e,t,...r){const n={url:n=>{return i=null,o=null,s=function*(){var i;const o=yield t.connect();return we(ke(e,null!=(i=t.options.baseUrl)?i:"",o,...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(i,o)).next())});var i,o,s}},i=["get","post","put","delete","patch"];for(const o of i){const i=n=>{var i;const s=n||{},{headers:a}=s,l=Ce(s,["headers"]);if(null==(i=null==n?void 0:n.signal)?void 0:i.aborted)throw new B;return t.connect().then(n=>{var i;const s=ke(e,null!=(i=t.options.baseUrl)?i:"",n,...r),c=f(Ae(Ae({},t.getAuthorizationHeaders()),null!=a?a:{}));return _e(s,(u=Ae({headers:c},l),Le(u,Pe({method:o}))),t.cache);var u})};n[o]=i}return n}function Se(e){return"[object Object]"===Object.prototype.toString.call(e)}let Ne;Ne=(e,t,r={},n,i)=>{r.method=r.method||"GET";const o=new XMLHttpRequest;o.open(r.method||"GET",e,!0),"blob"===r.responseType&&(o.responseType=r.responseType);const s=()=>{try{return JSON.parse(o.responseText)}catch(e){return o.responseText}};o.onload=()=>{-1!==[401,403,404,422,500].indexOf(o.status)&&n(new U(s())),((e=!1)=>{const i=e?n:t;"blob"===r.responseType?i(o.response):o.responseText?i(s()):n({message:""})})()},o.onerror=t=>{n(0===o.status?new K(e):t)},o.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&&o.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(o.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;i&&i(()=>{o.abort()}),o.send(l)};const Re=[];function $e(e){Re.push(e)}var Te=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?Te(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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});let We=0,Je=0;class He{constructor(e){ze(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 Re.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),$e(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,$e(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(),$e(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Re.indexOf(e);-1!==t&&Re.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=t,n=((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})(r,["paramList"]);e=v(e,n)}e=encodeURI(m(e)),r=Ge({withCredentials:this.withCredentials},r);const{cache:i,signal:o,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:p}=r,h=new AbortController,d=h.signal;if(o){if(o.aborted)throw new B;o.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!==i){const r=c||(b=Ge({},f({headers:a,withCredentials:p,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Fe(b,Be({params:t})));return this.cache.add(l||e,y,{props:r,expirationTime:i?void 0:500})}var b;return y()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var i;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 o;Ne(e,r,t,n,e=>{o=e}),null==(i=t.signal)||i.addEventListener("abort",()=>{void 0!==o&&o(),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[i,o]of Object.entries(e))if(-1===Qe.indexOf(i))if(Se(o))if("owner_user"===i){const e=Ke(o,i);Object.assign(r,e)}else"parent"===i&&"id"in o&&(r.parent_id=o.id);else n(o)&&(r[t+i]=o);return r}var Ye=Object.defineProperty,Xe=Object.defineProperties,et=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,it=(e,t,r)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ot=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&it(e,r,t[r]);if(tt)for(var r of tt(t))nt.call(t,r)&&it(e,r,t[r]);return e},st=(e,t)=>Xe(e,et(t)),at=(e,t,r)=>it(e,"symbol"!=typeof t?t+"":t,r),lt=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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 A({namespace:t})}getOne(e,t){const r=ot({},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(ot({},t),{query:ot({serialization:"full"},r)})).then(e=>{const r=Array.isArray(e)?e:e.items;if(null==t?void 0:t.cache)for(const t of r)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return r})}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 i=yield this.connector.route("resource.collection").get(st(ot({},t),{query:{parent:n}})),o=[];for(const s of i)(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&&o.push(this._getChildrenOf(s.resource.id,t,r));return o.length?Promise.all(o).then(()=>r):r})}_cleanResourceItemCache(e){return lt(this,null,function*(){var t;const r=this.cache.all(),n=[];for(const i of r){const r=null==(t=i.props)?void 0:t.id;if(["resource.item","resource"].includes(i.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(i);else{(yield this.getId(r))===e&&n.push(i)}}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 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 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,i=e.extent_right;if(t&&r&&n&&i){const e=[r,t,i,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:i}=e.extent;return[i,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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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,i=function*(){const r=e.resource,n=r;let{keyname:i,resourceId:o}=e;if(r&&("string"==typeof r?i=r:o="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield Ct(r,t)),!o&&i){const e=yield t.getResource(i);e&&(o=e.resource.id)}return o},new Promise((e,t)=>{var o=e=>{try{a(i.next(e))}catch(r){t(r)}},s=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((i=i.apply(r,n)).next())});var r,n,i}var kt=Object.defineProperty,Mt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,Rt=(e,t,r)=>t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$t=(e,t,r)=>Rt(e,"symbol"!=typeof t?t+"":t,r),Tt=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function Ft(e){return Tt(this,arguments,function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){$t(this,"options",{}),$t(this,"layer",[]),$t(this,"_removed",!1),$t(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 Tt(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 Tt(this,null,function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)})}loadLayer(){return Tt(this,null,function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const i=yield n(this);if(i){const n=new i(e.mapAdapter.map,((e,t)=>{for(var r in t||(t={}))St.call(t,r)&&Rt(e,r,t[r]);if(Mt)for(var r of Mt(t))Nt.call(t,r)&&Rt(e,r,t[r]);return e})({},t)),o=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=o,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:i="first-show-adapter"}){return Ft({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=i+"-"+r.resource_id},createAdapter:()=>Xo({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)})},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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=`^${i=t,i.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var i;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,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,Jt(r,t))}function Jt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(3===(r=t).length&&"string"==typeof r[0]&&"string"==typeof r[1]){const[r,n,i]=t,o=Zt[n];if(o){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,(n,o)=>(t=e[o],r.replace(o,i)));return o(t,n)}return o(e[r],i)}return!1}return Jt(e,t);var r},i=t.filter(e=>Array.isArray(e));return"any"===r?i.some(n):i.every(n)}var Ht=Object.defineProperty,Qt=Object.getOwnPropertySymbols,Kt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,Xt=(e,t,r)=>t in e?Ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,er=(e,t)=>{for(var r in t||(t={}))Kt.call(t,r)&&Xt(e,r,t[r]);if(Qt)for(var r of Qt(t))Yt.call(t,r)&&Xt(e,r,t[r]);return e};const tr={srs:4326,geom_format:"geojson",dt_format:"iso"};function rr(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function nr(e,t){const{extensions:r,geom:i,fields:o,srs:s,ilike:a,like:l}=t;e.extensions=r||[],o&&(e.fields=o),void 0!==i&&(e.geom=i,i||(delete e.srs,delete e.geom_format)),n(a)?e.ilike=a:n(l)&&(e.like=l),n(s)&&(e.srs=s)}function ir(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 or(e){const t=er({},tr),{limit:r,query:n,cache:i,signal:o,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),nr(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=ir(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:er(er({},t),n),cache:i,signal:o})}function sr(e){let t;for(t in e){const r=e[t];if(y(r)){const i=r;if(n(i.year)&&n(i.month)&&n(i.day)){const r=[i.year,i.month-1,i.day];"hour"in i&&[i.hour,i.minute,i.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}function ar(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function lr(e){return Array.isArray(e)&&!ar(e)}function cr(e){return"id"===e?["fid"]:["get",e]}function ur(e){const[t,r,n]=e,i=String(t),o=cr(i);switch(r){case"eq":return null===n?["is_null",o]:["==",o,n];case"ne":return null===n?["!is_null",o]:["!=",o,n];case"gt":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "gt" requires number or string for "${i}"`);return[">",o,n];case"lt":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "lt" requires number or string for "${i}"`);return["<",o,n];case"ge":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "ge" requires number or string for "${i}"`);return[">=",o,n];case"le":if("number"!=typeof n&&"string"!=typeof n)throw new Error(`Operator "le" requires number or string for "${i}"`);return["<=",o,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 "${i}"`);if(!n.length)throw new Error(`Operator "in" requires non-empty array for "${i}"`);return["in",o,...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 "${i}"`);if(!n.length)throw new Error(`Operator "notin" requires non-empty array for "${i}"`);return["!in",o,...n];case"ilike":{if("string"!=typeof n)throw new Error(`Operator "ilike" requires string for "${i}"`);const e=function(e){const t=e.startsWith("%"),r=e.endsWith("%");return{field:e.slice(t?1:0,r?-1:void 0),leadingWildcard:t,trailingWildcard:r}}(i),t=`${e.leadingWildcard?"%":""}${n}${e.trailingWildcard?"%":""}`;return["ilike",cr(e.field),t]}case"like":throw new Error(`Operator "${r}" is not supported by server FilterExpression`);default:throw new Error(`Unsupported operator: ${r}`)}}function pr(e){let t="all";const r=[];for(const n of e)if("all"!==n&&"any"!==n)if(ar(n))r.push(ur(n));else{if(!lr(n))throw new Error("Invalid PropertiesFilter node");r.push(pr(n))}else t=n;return[t,...r]}function hr(e){return(null==e?void 0:e.length)?pr(e):[]}function dr(e){if(null==e?void 0:e.length)return JSON.stringify(hr(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,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,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 or(Or(_r({},e),{query:Or(_r({},e.query),{filter:dr(r)})}));return null!=(t=e.clientFilterValidate)&&t&&(n=n.filter(e=>Jt(sr(Or(_r({},e.fields),{id:e.id})),r))),n}return or(e)})}function Ir({options:e,webMap:t,baseUrl:r}){var n;let i,o=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===o){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const i=t+"/api/component/render/image",o={resource:e};return r&&(o.nd=r),{url:i,resourceId:e,headers:n,params:o,updateWmsParams:t=>(r&&(t.nd=r),vi(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});o="TILE"}if("WMS"===o){i=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:i,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===o)return i=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:i,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===o)return i=r+`/api/resource/${a}/terrain_provider`,{url:i,adapter:o};if("MODEL_3D"===o)return i=r+`/api/component/model_3d/${a}/data.glb`,{url:i};if("TILE"===o)return i=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:i,adapter:o}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var xr=Object.defineProperty,jr=Object.defineProperties,Er=Object.getOwnPropertyDescriptors,Ar=Object.getOwnPropertySymbols,Cr=Object.prototype.hasOwnProperty,kr=Object.prototype.propertyIsEnumerable,Mr=(e,t,r)=>t in e?xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Sr=(e,t)=>{for(var r in t||(t={}))Cr.call(t,r)&&Mr(e,r,t[r]);if(Ar)for(var r of Ar(t))kr.call(t,r)&&Mr(e,r,t[r]);return e},Nr=(e,t)=>jr(e,Er(t)),Rr=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function $r(e){return Rr(this,null,function*(){const t=Sr({},tr);nr(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Nr(Sr({},e),{query:t}));return Nr(Sr({},r),{toGeojson:()=>Rr(null,null,function*(){if(r.geom)return rr(r);{const t=(yield $r(Nr(Sr({},e),{geom:!0,fields:null,extensions:null}))).geom;return rr(Nr(Sr({},r),{geom:t}))}})})})}var Tr=Object.defineProperty,Fr=Object.getOwnPropertySymbols,Br=Object.prototype.hasOwnProperty,qr=Object.prototype.propertyIsEnumerable,Dr=(e,t,r)=>t in e?Tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ur=(e,t,r)=>Dr(e,"symbol"!=typeof t?t+"":t,r);class Vr{constructor(e){Ur(this,"options",e),Ur(this,"name"),Ur(this,"resourceId"),Ur(this,"item"),Ur(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:i}=e.extent,o=[r,t,i,n];return this._extent=o,o}})}geoJson(e){return this.item.geom?Promise.resolve(rr(this.item)):$r(((e,t)=>{for(var r in t||(t={}))Br.call(t,r)&&Dr(e,r,t[r]);if(Fr)for(var r of Fr(t))qr.call(t,r)&&Dr(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,rr(this.item)))}}var Gr=Object.defineProperty,zr=(e,t,r)=>((e,t,r)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Zr{constructor(e,t,r){zr(this,"options"),zr(this,"emitter",new M),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 Wr=Object.defineProperty,Jr=Object.getOwnPropertySymbols,Hr=Object.prototype.hasOwnProperty,Qr=Object.prototype.propertyIsEnumerable,Kr=(e,t,r)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yr=(e,t)=>{for(var r in t||(t={}))Hr.call(t,r)&&Kr(e,r,t[r]);if(Jr)for(var r of Jr(t))Qr.call(t,r)&&Kr(e,r,t[r]);return e};const Xr=class e extends Zr{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 i=r[n],o=i.properties&&i.properties.property(this.name);o&&o.set(e,Yr(Yr({},t),{propagation:!0,bubble:!1}))}}}};Kr(Xr,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let en=Xr;var tn=Object.defineProperty,rn=Object.getOwnPropertySymbols,nn=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable,sn=(e,t,r)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,an=(e,t,r)=>sn(e,"symbol"!=typeof t?t+"":t,r);const ln=class e{constructor(e,t){an(this,"item",e),an(this,"options",{}),an(this,"_properties",{}),an(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={}))nn.call(t,r)&&sn(e,r,t[r]);if(rn)for(var r of rn(t))on.call(t,r)&&sn(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}};an(ln,"handlers",{CheckProperty:en});let cn=ln;function un(e,t,r,n){return!!dn(e,t,r,fn)}function pn(e,t,r,n){return dn(e,t,r,yn)}function hn(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 dn(e,t=e=>!!e,r="children",n,i){return n(e,"function"==typeof t?t:e=>Jt(e,t),r)}function fn(e,t=e=>!!e,r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(t(e))return e;const n=hn(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){const e=fn(i[o],t,r,n);if(e)return e}}function yn(e,t=e=>!!e,r,n=[]){let i=[];if(Array.isArray(e))i=e;else{t(e)&&n.push(e);const o=hn(e,r);o&&(i=o)}for(let o=0;o<i.length;o++)i[o]&&yn(i[o],t,r,n);return n}function mn(e,t=e=>!!e,r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(!t(e))return!1;const n=hn(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){if(!mn(i[o],t,r,n))return!1}return!0}var bn=Object.defineProperty,gn=(e,t,r)=>((e,t,r)=>t in e?bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class vn{constructor(e){gn(this,"item"),gn(this,"_children",[]),gn(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 dn(this._children,e,e=>e.tree.getChildren(),fn)}every(e){return!!dn(this._children,e,e=>e.tree.getChildren(),mn)}some(e){return un(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 wn=Object.defineProperty,_n=Object.getOwnPropertySymbols,On=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable,Pn=(e,t,r)=>t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,In=(e,t,r)=>Pn(e,"symbol"!=typeof t?t+"":t,r);let xn=0;class jn{constructor(e){In(this,"options",{}),In(this,"properties"),In(this,"tree"),In(this,"id",xn),xn+=1,this.options=((e,t)=>{for(var r in t||(t={}))On.call(t,r)&&Pn(e,r,t[r]);if(_n)for(var r of _n(t))Ln.call(t,r)&&Pn(e,r,t[r]);return e})({},e),this.tree=new vn(this)}initProperties(){this.properties=new cn(this,this.options.properties)}}function En(e,t){return{[`symbols[${e}]`]:t.join(",")||void 0}}var An=Object.defineProperty,Cn=Object.defineProperties,kn=Object.getOwnPropertyDescriptors,Mn=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Rn=(e,t,r)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$n=(e,t)=>{for(var r in t||(t={}))Sn.call(t,r)&&Rn(e,r,t[r]);if(Mn)for(var r of Mn(t))Nn.call(t,r)&&Rn(e,r,t[r]);return e},Tn=(e,t,r)=>Rn(e,"symbol"!=typeof t?t+"":t,r);class Fn{constructor({legendSymbols:e,resourceId:t,connector:r,layerId:n,legend:i,webMap:o,layer:s,onSymbolRenderChange:a}){Tn(this,"layerId"),Tn(this,"layer"),Tn(this,"resourceId"),Tn(this,"legendSymbols","expand"),Tn(this,"legend"),Tn(this,"layerVisibility",!0),Tn(this,"onSymbolRenderChange"),Tn(this,"webMap"),Tn(this,"connector"),e&&(this.legendSymbols=e),this.connector=r,this.layer=s,this.layerId=n,i&&(this.legend=this.createLegend(i)),this.resourceId=t,this.webMap=o,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($n({},e));return this.legend=t,this.createLegend(t)}},new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});var e,t,r}createLegend(e){return e.map(e=>{return t=$n({},e),Cn(t,kn({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:$n({},En(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],i=n;for(let o=1;o<=t.length;o++)t[o]===i+1?i=t[o]:(r.push(n===i?`${n}`:`${n}-${i}`),n=t[o],i=n);return r}}var Bn=Object.defineProperty,qn=Object.defineProperties,Dn=Object.getOwnPropertyDescriptors,Un=Object.getOwnPropertySymbols,Vn=Object.prototype.hasOwnProperty,Gn=Object.prototype.propertyIsEnumerable,zn=(e,t,r)=>t in e?Bn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Zn=(e,t)=>{for(var r in t||(t={}))Vn.call(t,r)&&zn(e,r,t[r]);if(Un)for(var r of Un(t))Gn.call(t,r)&&zn(e,r,t[r]);return e},Wn=(e,t)=>qn(e,Dn(t)),Jn=(e,t,r)=>zn(e,"symbol"!=typeof t?t+"":t,r),Hn=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Qn=class e extends jn{constructor({webMap:t,item:r,options:n,connector:i,parent:o,noInit:s}){if(super(Zn(Zn({},e.options),n)),Jn(this,"item"),Jn(this,"webMap"),Jn(this,"connector"),Jn(this,"layer"),Jn(this,"legend"),Jn(this,"emitter",new M),Jn(this,"_rootDescendantsCount",0),this.webMap=t,i&&(this.connector=i),o&&this.tree.setParent(o),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,i,o){return Hn(this,null,function*(){const s=new e({webMap:t,item:r,options:n,connector:i,parent:o,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 Hn(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 i=new Fn({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 i.create(e),[i]}return[]}}return[]})}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=Wn(Zn({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,Wn(Zn({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===_i){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),_i=t}return _i}()*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"group"!==this.item.item_type||e.group_enabled||this.properties.property("visibility").set(!1),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 i;if("layer"===t.item_type)i=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){i=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return i?this.webMap.addLayer(i,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,i=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,o=[t,n].filter(Boolean),s=[r,i].filter(Boolean);return{minZoom:o.length?Math.max(...o):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(Qn,"GetAdapterFromLayerType",{}),Jn(Qn,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type)return e.item.group_enabled;if("root"===e.item.item_type)return un(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){"group"===(null==r?void 0:r.item.item_type)?r.item.group_enabled=e:"layer"===(null==r?void 0: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 Zr{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 Kn=Qn;var Yn=Object.defineProperty,Xn=Object.defineProperties,ei=Object.getOwnPropertyDescriptors,ti=Object.getOwnPropertySymbols,ri=Object.prototype.hasOwnProperty,ni=Object.prototype.propertyIsEnumerable,ii=(e,t,r)=>t in e?Yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oi=(e,t)=>{for(var r in t||(t={}))ri.call(t,r)&&ii(e,r,t[r]);if(ti)for(var r of ti(t))ni.call(t,r)&&ii(e,r,t[r]);return e},si=(e,t,r)=>ii(e,"symbol"!=typeof t?t+"":t,r),ai=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});class li{constructor(e,t){si(this,"map",e),si(this,"options",t),si(this,"layer"),si(this,"NgwWebmapItem",Kn),si(this,"pixelRadius",10),si(this,"resourceId"),si(this,"webmapClassName","webmap"),si(this,"emitter",new M),si(this,"_extent"),si(this,"webmapResource"),si(this,"_webmapBaselayersIds",[]),si(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 ai(this,null,function*(){var t;this.options=oi(oi({},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 ai(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)})}hideLayer(){return ai(this,null,function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)})}setOpacity(e){return ai(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 i;const o=null==(i=n.feature_layer)?void 0:i.fields.find(e=>e.label_field),s=o&&o.keyname;return Pr(oi({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then(e=>{const n=[];for(const i of e){const e=new Vr({item:i,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 ai(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 ai(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 ai(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,i=(null==n?void 0:n.options.auth)?n.getAuthorizationHeaders():void 0,o=n.withCredentials,s=(a=oi({},this.options),l={withCredentials:o,headers:i,drawOrderEnabled:null!=(r=e.draw_order_enabled)&&r},Xn(a,ei(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 ai(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 i=!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:i}).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=m(this.options.connector.options.baseUrl+"/api/component/render/image"),i=r.layer_style_id;r.url=n,r.resourceId=i,r.updateWmsParams=e=>vi(e,i);const o=Ir({options:{adapter:r.layer_adapter.toUpperCase(),resource:i},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=oi(oi({},r),o)}return"function"==typeof(null==(n=this.options.nativeOptions)?void 0:n.beforeItemCreated)&&(e=this.options.nativeOptions.beforeItemCreated(e)),e}}var ci=Object.defineProperty,ui=Object.defineProperties,pi=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,di=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,yi=(e,t,r)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mi=(e,t)=>{for(var r in t||(t={}))di.call(t,r)&&yi(e,r,t[r]);if(hi)for(var r of hi(t))fi.call(t,r)&&yi(e,r,t[r]);return e},bi=(e,t)=>ui(e,pi(t)),gi=(e,t)=>{var r={};for(var n in e)di.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&hi)for(var n of hi(e))t.indexOf(n)<0&&fi.call(e,n)&&(r[n]=e[n]);return r};function vi(e,t){const r=e,{bbox:n,width:i,height:o,nd:s}=r,a=gi(r,["bbox","width","height","nd"]);return bi(mi({},a),{resource:Array.isArray(t)?t.join(","):t,extent:n,size:i+","+o,timestamp:Date.now(),nd:null!=s?s:200})}const wi={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 _i;function Oi(e){if(!e)return;const t=e.match(/^(?:SRID=(\d+);)?POLYGON\s*\(\((.+)\)\)\s*$/i);if(!t||t[1]&&"4326"!==t[1])return;const r=t[2].split(",").map(e=>e.trim().split(/\s+/).map(Number)).filter(e=>e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1]));if(!r.length)return;const n=r.map(e=>e[0]),i=r.map(e=>e[1]);return[Math.min(...n),Math.min(...i),Math.max(...n),Math.max(...i)]}function Li(e){return e.replace(/^(http|ftp):\/\//,"https://")}function Pi(e){const t=function(e){return e?Object.fromEntries(new URLSearchParams(e).entries()):{}}(e.params),r=Object.entries(t).find(([e])=>"version"===e.toLowerCase());return{type:"wms",service:e,url:Li(e.url),layers:e.layers,format:e.format||"image/png",version:(null==r?void 0:r[1])||"1.3.0",params:t,name:e.name,attribution:e.copyright_text||void 0,extent:Oi(e.extent)}}var Ii=Object.defineProperty,xi=(e,t,r)=>((e,t,r)=>t in e?Ii(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r),ji=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Ei=class e{constructor(){xi(this,"url"),this.url=e.url.replace(/\/$/,"").trim()}getService(e){return ji(this,arguments,function*(e,t={}){const r=yield this._getJson(`${this.url}/api/v1/geoservices/${e}`,t);if("tms"!==r.type&&"wms"!==r.type)throw new Error("Unsupported QMS service type.");return r})}getLayer(e){return ji(this,arguments,function*(e,t={}){const r=yield this.getService(e,t);return"tms"===r.type?function(e){var t,r;const[n,i]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,(e,r)=>("string"==typeof r&&r.split(",").forEach(e=>t.push(e)),"{s}")),t]}(Li(e.origin_url||e.url));return{type:"tms",service:e,url:n,subdomains:i,scheme:e.y_origin_top?"xyz":"tms",name:e.name,attribution:e.copyright_text||void 0,extent:Oi(e.extent),minZoom:null!=(t=e.z_min)?t:void 0,maxZoom:null!=(r=e.z_max)?r:void 0}}(r):Pi(r)})}searchServices(e,t){return ji(this,arguments,function*(e,{limit:t=10,offset:r,signal:n,type:i}){const o=new URLSearchParams({search:e,limit:String(t),type:i});void 0!==r&&o.set("offset",String(r));return(yield this._getJson(`${this.url}/api/v1/geoservices/?${o}`,{signal:n})).results})}_getJson(e,t){return ji(this,arguments,function*(e,{signal:t}){const r=yield fetch(e,{signal:t});if(!r.ok)throw new Error(`QMS request failed with status ${r.status}: ${e}`);return r.json()})}};xi(Ei,"url","https://qms.nextgis.com");let Ai=Ei;var Ci=Object.defineProperty,ki=Object.defineProperties,Mi=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,Ni=Object.prototype.hasOwnProperty,Ri=Object.prototype.propertyIsEnumerable,$i=(e,t,r)=>t in e?Ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ti=(e,t)=>{for(var r in t||(t={}))Ni.call(t,r)&&$i(e,r,t[r]);if(Si)for(var r of Si(t))Ri.call(t,r)&&$i(e,r,t[r]);return e},Fi=(e,t)=>ki(e,Mi(t)),Bi=(e,t)=>{var r={};for(var n in e)Ni.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Si)for(var n of Si(e))t.indexOf(n)<0&&Ri.call(e,n)&&(r[n]=e[n]);return r},qi=(e,t,r)=>$i(e,"symbol"!=typeof t?t+"":t,r),Di=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Ui={tms:"TILE",wms:"WMS"};function Vi(e,t={}){let r;if("webMap"in e){const n=e,{webMap:i}=n,o=Bi(n,["webMap"]);r=i,t=o}else r=e;const n=new Ai;class i{constructor(e,r){qi(this,"qms"),qi(this,"options"),qi(this,"map"),this.map=e;const n=Ti(Ti({},t),r);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return Di(this,null,function*(){var t,o,s;const a=null!=(t=e.signal)?t:this.options.signal,l=null!=(s=e.qmsId)?s:null==(o=this.qms)?void 0:o.id;var c,u;if("number"==typeof l)try{const t=yield n.getLayer(l,{signal:a});this.qms=t.service;const o=Ui[t.type],s=r.mapAdapter.layerAdapters[o];if(s){c=i,u=s,["showLayer","hideLayer"].forEach(e=>{const t=Object.getOwnPropertyDescriptor(u.prototype,e);t&&Object.defineProperty(c.prototype,e,t)}),e=Fi(Ti(Ti(Ti({},"TILE"===o?{order:0,maxZoom:r.options.maxZoom,minZoom:r.options.minZoom}:{}),this.options),function(e){return"tms"===e.type?{url:"tms"===e.scheme?e.url.replace("{y}","{-y}"):e.url,subdomains:e.subdomains,maxZoom:e.maxZoom,minZoom:e.minZoom,name:e.name,attribution:e.attribution}:{url:e.url,layers:e.layers,format:e.format,version:e.version,params:e.params,name:e.name,attribution:e.attribution}}(t)),{signal:a}),this.options=e;return new s(this.map,e).addLayer(e)}}catch(p){if(null==a?void 0:a.aborted)throw p;console.error(p)}})}}return i}var Gi=Object.defineProperty;class zi{getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return Vi({webMap:e})}}((e,t,r)=>{((e,t,r)=>{t in e?Gi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,t+"",r)})(zi,"utils",{createQmsAdapter:Vi});var Zi=Object.defineProperty,Wi=Object.defineProperties,Ji=Object.getOwnPropertyDescriptors,Hi=Object.getOwnPropertySymbols,Qi=Object.getPrototypeOf,Ki=Object.prototype.hasOwnProperty,Yi=Object.prototype.propertyIsEnumerable,Xi=Reflect.get,eo=(e,t,r)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,to=(e,t)=>{for(var r in t||(t={}))Ki.call(t,r)&&eo(e,r,t[r]);if(Hi)for(var r of Hi(t))Yi.call(t,r)&&eo(e,r,t[r]);return e},ro=(e,t)=>Wi(e,Ji(t)),no=(e,t,r)=>Xi(Qi(e),r,t),io=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});var oo=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function so(e){return function(e){return oo(this,null,function*(){const t=yield Pr(e),r=[];return t.forEach(e=>{r.push(rr(e))}),r})}(e).then(e=>({type:"FeatureCollection",features:e}))}const ao=["fields","intersects","limit","orderBy","strategy"];function lo(e){const t={};return ao.forEach(r=>{const n=e[r];void 0!==n&&(t[r]=n)}),t}var co=Object.defineProperty,uo=Object.defineProperties,po=Object.getOwnPropertyDescriptors,ho=Object.getOwnPropertySymbols,fo=Object.getPrototypeOf,yo=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,bo=Reflect.get,go=(e,t,r)=>t in e?co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vo=(e,t)=>{for(var r in t||(t={}))yo.call(t,r)&&go(e,r,t[r]);if(ho)for(var r of ho(t))mo.call(t,r)&&go(e,r,t[r]);return e},wo=(e,t)=>uo(e,po(t)),_o=(e,t,r)=>go(e,"symbol"!=typeof t?t+"":t,r),Oo=(e,t,r)=>bo(fo(e),r,t),Lo=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function Po(e){return Lo(this,null,function*(){var t,r;const{item:n,webMap:i,Adapter:o,connector:s,layerOptions:a,addLayerOptionsPriority:l}=e,c=null==l||l,u=a,p=o||a.Adapter||i.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)=>Lo(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},so(vo({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),_o(this,"emitter",new M),_o(this,"__onMapMove"),_o(this,"__onMapMoveStart"),_o(this,"__enableMapMoveListener"),_o(this,"__disableMapMoveListener")}addLayer(e){return Lo(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=wi[n.vector_layer.geometry_type]),u.adapterOptions&&(e=c?vo(vo({},u.adapterOptions),e):vo(vo({},e),u.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const i=e.strategy||void 0;this.options.strategy=i;const o=Oo(w.prototype,this,"addLayer").call(this,e);let s;return d={filters:e.propertiesFilter,options:lo(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),i&&i.startsWith("BBOX")&&!y&&this._addBboxEventListener(),o})}getExtent(){return this.getBounds()}getBounds(){return Lo(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}):Oo(w.prototype,this,"getBounds")?Oo(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 Lo(this,null,function*(){var t;const r=e||d||{};if(null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield i.onLoad("create"),r.options=r.options||{},r.options.intersects=i.getBounds();const{minZoom:e,maxZoom:t}=this.options,n=i.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),i._emitLayerEvent("layer:preupdate",u.id||"",r);const e=yield b(r.filters,wo(vo({},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 i.addLayerData(this,t)}else y=void 0!==n&&e.features.length>=n,yield i.setLayerData(this,e);this.emitter.emit("updated",e),i._emitLayerEvent("layer:updated",u.id||"",{data:e,newData:t,isFull:y})}catch(n){if(n instanceof Error&&"AbortError"!==n.name)throw n}Oo(w.prototype,this,"updateLayer")&&Oo(w.prototype,this,"updateLayer").call(this)}})}propertiesFilter(e,t){return Lo(this,null,function*(){if(v(),this.filter&&y)this.filter(t=>{if(!e)return!0;const r=t.feature&&t.feature.properties&&sr(vo({},t.feature.properties));return!r||Jt(r,e)});else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(null!=e?e:void 0,wo(vo({},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()},i.emitter.on("layer:show",this.__enableMapMoveListener),i.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&i.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&i.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...i){n.clear(),r=setTimeout(()=>{r=null,e.apply(this,i)},t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}(()=>this.updateLayer()),this.__onMapMoveStart=v,i.emitter.on("movestart",this.__onMapMoveStart),i.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&i.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&i.emitter.removeListener("movestart",this.__onMapMoveStart)}}return w})}var Io=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function xo(e,t){const r=dr(t);return void 0===r?{}:{[`filter[${e}]`]:r}}var jo=Object.defineProperty,Eo=Object.defineProperties,Ao=Object.getOwnPropertyDescriptors,Co=Object.getOwnPropertySymbols,ko=Object.prototype.hasOwnProperty,Mo=Object.prototype.propertyIsEnumerable,So=(e,t,r)=>t in e?jo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,No=(e,t)=>{for(var r in t||(t={}))ko.call(t,r)&&So(e,r,t[r]);if(Co)for(var r of Co(t))Mo.call(t,r)&&So(e,r,t[r]);return e},Ro=(e,t)=>Eo(e,Ao(t)),$o=(e,t)=>{var r={};for(var n in e)ko.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Co)for(var n of Co(e))t.indexOf(n)<0&&Mo.call(e,n)&&(r[n]=e[n]);return r},To=(e,t,r)=>So(e,"symbol"!=typeof t?t+"":t,r),Fo=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});function Bo(e){return Fo(this,arguments,function*({layerOptions:e,connector:t,webMap:r,item:i}){const o=i.resource.cls;let s=e.adapter||o&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[o]||"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 o=yield Ct(e,t);return class extends a{constructor(a,l){super(a,l),To(this,"map",a),To(this,"item",i),To(this,"resourceId",o),To(this,"blocked",!1),To(this,"layerVisibility");const c=Ir({options:e,webMap:r,baseUrl:t.options.baseUrl||""});if(c){const t=e.adapterOptions||{},{propertiesFilter:r}=t,i=$o(t,["propertiesFilter"]),a=xo(o,r),l=Ro(No(No({},c),i),{params:No({resource:o},a),url:"TILE"===s&&c.url?b(c.url,No({resource:String(o)},a)):c.url,layers:c.layers||String(o),resourceId:o});e.adapterOptions&&n(e.adapterOptions.setViewDelay)&&(l.setViewDelay=e.adapterOptions.setViewDelay),this.options=No(No({},this.options),l)}}addLayer(e){return super.addLayer(No(No({},this.options),e))}propertiesFilter(e){return Fo(this,null,function*(){var t;const r=this.options,n=`filter[${this.resourceId}]`,i=No(No({},r.params||{}),xo(this.resourceId,null!=e?e:void 0));e||delete i[n],r.params=i,null==(t=this.updateLayer)||t.call(this,{params:i})})}getIdentificationIds(){return Fo(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 Fo(this,null,function*(){const n=this.options.id;if(void 0!==n){const i=yield t.route("render.legend_symbols",{id:o}).get(No({cache:!0},e));return[new Fn({layerId:n,layer:this,resourceId:o,webMap:r,legend:i})]}return[]})}}}throw new Error(s+" not supported yet. Only TILE")})}var qo=Object.defineProperty,Do=Object.defineProperties,Uo=Object.getOwnPropertyDescriptors,Vo=Object.getOwnPropertySymbols,Go=Object.prototype.hasOwnProperty,zo=Object.prototype.propertyIsEnumerable,Zo=(e,t,r)=>t in e?qo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wo=(e,t)=>{for(var r in t||(t={}))Go.call(t,r)&&Zo(e,r,t[r]);if(Vo)for(var r of Vo(t))zo.call(t,r)&&Zo(e,r,t[r]);return e},Jo=(e,t)=>Do(e,Uo(t)),Ho=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const Qo={},Ko=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Yo(e){return Ho(this,arguments,function*({layerOptions:e,webMap:t,connector:r,item:n}){const i=n.resource.id,o=yield r.getResourceChildren(i),s=o&&o[0];if(s)return Xo(Jo(Wo({},e),{resource:s.resource.id}),t,r)})}function Xo(e,r,n){return Ho(this,null,function*(){let i,o;const s=e.adapter,a=yield Ct(e,n);if(a){const t=e.resource;if(o=t&&t.resource&&void 0!==t.resource.id?t:yield n.getResource(a),!o)throw"Resource item is not found";{const t=o.resource.cls,l={layerOptions:Jo(Wo({},e),{resource:a}),connector:n,webMap:r,item:o};if(-1!==Ko.indexOf(t))if("webmap"===t)i=function(e){return Io(this,arguments,function*({layerOptions:e,webMap:t,connector:r}){const n=yield Ct(e,r);return class extends li{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||o.vector_layer&&wi[o.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==s&&"GEOJSON"!==s){if("MVT"!==s)return Yo(l);i=Bo(l)}else i=Po(l)}else{if("raster_layer"===t)return Yo(l);if("basemap_layer"===t)i=function(e){return io(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(Vi(e,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return io(this,null,function*(){if(n)return no(e.prototype,this,"addLayer").call(this,ro(to({},t),{url:n}))})}}return e}}}})}(l);else if("GEOJSON"===s&&o.resource.parent){const t=yield n.getResource(o.resource.parent.id);if(t){const r=Jo(Wo({},e),{resource:o.resource.parent.id});i=Po(Jo(Wo({},l),{item:t,layerOptions:r}))}}else i=Bo(l)}else{if(!Qo[t])throw`Resource class '${t}' not yet supported.`;{const e=Qo[t];let r;r=s&&"function"!=typeof r?e[s]:e,r&&(i=r(l))}}}}if(i)return i.then(e=>{if(e){const r=e;return o&&(r.prototype.item=o,r.prototype.resourceId=o.resource.id,r.prototype.connector=n),t(r,[At],{replace:!1}),r}})})}var es=Object.defineProperty,ts=Object.getOwnPropertySymbols,rs=Object.prototype.hasOwnProperty,ns=Object.prototype.propertyIsEnumerable,is=(e,t,r)=>t in e?es(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,os=(e,t)=>{for(var r in t||(t={}))rs.call(t,r)&&is(e,r,t[r]);if(ts)for(var r of ts(t))ns.call(t,r)&&is(e,r,t[r]);return e},ss=(e,t,r)=>is(e,"symbol"!=typeof t?t+"":t,r);class as{constructor(e){if(ss(this,"options",e),ss(this,"url"),ss(this,"connector"),ss(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){Qo[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(li,os({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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 li{constructor(e,r){super(e,r=mi(mi({},t),r))}};var t}}var ls=Object.defineProperty,cs=Object.getOwnPropertySymbols,us=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable,hs=(e,t,r)=>t in e?ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ds=(e,t)=>{for(var r in t||(t={}))us.call(t,r)&&hs(e,r,t[r]);if(cs)for(var r of cs(t))ps.call(t,r)&&hs(e,r,t[r]);return e},fs=(e,t,r)=>hs(e,"symbol"!=typeof t?t+"":t,r),ys=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});class ms{constructor(e){fs(this,"id"),fs(this,"label"),fs(this,"layerId"),fs(this,"parent"),fs(this,"fields"),fs(this,"geom"),fs(this,"extensions"),fs(this,"connector"),fs(this,"_item"),fs(this,"_geojson"),fs(this,"_resource"),fs(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):$r(ds({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 ys(this,null,function*(){return(yield this.composite(e)).feature_layer})}composite(e){return ys(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:i}){return r.route("feature_layer.feature.item_extent",{id:Number(e),fid:t}).get({cache:n,signal:i}).then(e=>{if(e&&e.extent){const{maxLat:t,maxLon:r,minLat:n,minLon:i}=e.extent;return[i,n,r,t]}})}(ds({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 bs(e){return t=this,r=null,n=function*(){return rr(yield $r(e))},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())});var t,r,n}function gs(e,t){return r=this,n=null,i=function*(){var r,n;const i=yield e.route("pyramid.settings").get({query:{component:"pyramid"}}),o=i&&"company_logo"in i?i.company_logo:void 0;if(o&&o.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 i=new Uint8Array(n),o=new Blob([i],{type:e}),l=(window.URL||window.webkitURL).createObjectURL(o);s.src=l}return null!==o.link&&""!==o.link.trim()&&(i.href=o.link,i.target="_blank",-1!==o.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),i.appendChild(s),i}},new Promise((e,t)=>{var o=e=>{try{a(i.next(e))}catch(r){t(r)}},s=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((i=i.apply(r,n)).next())});var r,n,i}var vs=Object.defineProperty,ws=Object.defineProperties,_s=Object.getOwnPropertyDescriptors,Os=Object.getOwnPropertySymbols,Ls=Object.prototype.hasOwnProperty,Ps=Object.prototype.propertyIsEnumerable,Is=(e,t,r)=>t in e?vs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xs=(e,t)=>{for(var r in t||(t={}))Ls.call(t,r)&&Is(e,r,t[r]);if(Os)for(var r of Os(t))Ps.call(t,r)&&Is(e,r,t[r]);return e},js=(e,t)=>ws(e,_s(t));function Es(e,t=!1){const r=[],n=[];for(const o in e){const e=Number(o);isNaN(e)||r.push(e)}const i=e.resources;i&&r.sort((e,t)=>i.indexOf(e)-i.indexOf(t));for(let o=0;o<r.length;o++){const i=r[o],s=e[i];if("features"in s){const e=As(s.features,Number(i),t);if(e.length&&(n.push(...e),!t))break}}return n}function As(e,t,r){const n=[];for(const i of e){if(n.push({featureId:i.id,resourceId:t,feature:i}),!r)break}return n}function Cs(e){const{geom:t,signal:r,cache:n,layers:i}=e,o="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(!o)throw new Error("Not valid geometry format to make intersection");const a={geom:o,srs:3857,layers:i};return e.connector.route("feature_layer.identify").post({json:a,signal:r,cache:n})}const ks={};function Ms(e){return ks[e]}function Ss(e,t){ks[e]=t}function Ns(e,t){const r=document.createElement("div"),n=new Set;let i=!1;t.getStatus?i=t.getStatus():t.status&&(i=t.status);const o=t.title||"",s=t.html;function a(){o&&(r.title="string"==typeof o?o:i?o.on:o.off,r.setAttribute("aria-label",r.title))}function l(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function c(){s&&("string"==typeof s||s instanceof HTMLElement?l(s):l(i?s.on:s.off),r.setAttribute("aria-label",r.title))}function u(e,t){e.split(" ").forEach(e=>{t?r.classList.add(e):r.classList.remove(e)})}function p(){t.addClassOn&&u(t.addClassOn,i),t.addClassOff&&u(t.addClassOff,!i)}function h(e){n.forEach(t=>t(i,e))}a(),c(),t.addClass&&u(t.addClass,!0),p();const d=e=>{void 0!==e&&(i=e),c(),a(),p()},f=e=>{if(void 0===e&&i&&y.disableOnSecondClick)return;const r=i;if(i=void 0!==e?e:!i,t.onClick){let e;try{e=t.onClick(i)}catch(n){throw i=r,d(),n}Promise.resolve(e).then(()=>{d(),r!==i&&h(y)}).catch(()=>{i=r,d()})}else d(),r!==i&&h(y)},y=e({html:r,onClick:f});return y.onClick=f,y.changeStatus=d,y.getStatus=()=>i,y.switch=t.switch,void 0!==t.disableOnSecondClick&&(y.disableOnSecondClick=t.disableOnSecondClick),y.onStatusChange=e=>(n.add(e),()=>n.delete(e)),y}function Rs(e){return(t,r)=>{const n=t.map(e=>e());return e(n,r)}}const $s={"!":Rs(function([e]){return!e}),"!=":Rs(function([e,t]){return e!==t}),"<":Rs(function([e,t]){return e<t}),"<=":Rs(function([e,t]){return e<=t}),"==":Rs(function([e,t]){return e===t}),">":Rs(function([e,t]){return e>t}),">=":Rs(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(),i=r.splice(-1,r.length%2)[0];for(let o=0;o<r.length-1;o+=2){if(r[o]()===n)return r[o+1]()}return i()}},Ts={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 Fs(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Bs(e);if("string"==typeof(t=e)&&t in Ts)return function(e){return Bs(Ts[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 Bs(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 qs(e,t,r,n,i){if("number"==typeof r&&"number"==typeof i)return r+(e-t)/(n-t)*(i-r);try{const o=Fs(r),s=Fs(i);return function(e){return`rgb(${e.join(",")})`}(o.map((r,i)=>Math.ceil(qs(e,t,r,n,s[i]))))}catch(o){console.log(o)}throw new Error("Unsupported output type for linear interpolation.")}const Ds={step:e=>{const[t,r,...n]=e,i=t();if("number"!=typeof i)return r();for(let o=0;o<n.length-2;o+=2){const e=n[o](),t=n[o+1](),r=n[o+2]();if(i>=e&&i<r)return t}return i>=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 i=e();for(let o=0;o<r.length-2;o+=2){const e=r[o](),t=r[o+1](),s=r[o+2](),a=r[o+3]();if(n>=e&&n<=s&&"linear"===i[0])return qs(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Us={get:Rs(function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null}),length:Rs(([e])=>{if("string"==typeof e||Array.isArray(e))return e.length}),at:Rs(function([e,t]){return t[e]}),has:Rs(function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))}),in:Rs(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":Rs(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:Rs(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}.`)})},Vs={"+":Rs(e=>e.reduce((e,t)=>e+t,0)),"-":Rs(e=>e.reduce((e,t)=>e-t)),"*":Rs(e=>e.reduce((e,t)=>e*t,1)),"/":Rs(e=>e.reduce((e,t)=>e/t)),"%":Rs(e=>e[0]%e[1]),"^":Rs(e=>Math.pow(e[0],e[1])),abs:Rs(e=>Math.abs(e[0])),acos:Rs(e=>Math.acos(e[0])),asin:Rs(e=>Math.asin(e[0])),atan:Rs(e=>Math.atan(e[0])),ceil:Rs(e=>Math.ceil(e[0])),cos:Rs(e=>Math.cos(e[0])),e:()=>Math.E,floor:Rs(e=>Math.floor(e[0])),ln:Rs(e=>Math.log(e[0])),ln2:()=>Math.LN2,log10:Rs(e=>Math.log10(e[0])),log2:Rs(e=>Math.log2(e[0])),max:Rs(e=>Math.max(...e)),min:Rs(e=>Math.min(...e)),pi:()=>Math.PI,round:Rs(e=>Math.round(e[0])),sin:Rs(e=>Math.sin(e[0])),sqrt:Rs(e=>Math.sqrt(e[0])),tan:Rs(e=>Math.tan(e[0]))},Gs={concat:Rs(e=>e.reduce((e,t)=>String(e)+String(t),"")),downcase:Rs(e=>String(e[0]).toLowerCase()),upcase:Rs(e=>String(e[0]).toUpperCase())},zs=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function Zs(e){return(t,r)=>{for(const n of t){const t=zs(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Ws={array:Rs(e=>{const[t,r,n]=e;let i,o,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(i=t,"number"==typeof r?(o=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(i&&!s.every(e=>typeof e===i))throw new Error(`Expected all items in array to be of type ${i}`);if(o&&s.length!==o)throw new Error(`Expected array of length ${o}`);return s}),boolean:Rs(Zs(e=>"boolean"==typeof e?e:void 0)),literal:Rs(([e])=>e),number:Rs(Zs(e=>"number"==typeof e?e:void 0)),object:Rs(Zs(e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e)),string:Rs(Zs(e=>"string"==typeof e?e:void 0)),"to-boolean":Rs(Zs(Boolean)),"to-number":Rs(Zs(Number)),"to-string":Rs(Zs(String)),typeof:Rs(([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 Js=Object.defineProperty,Hs=Object.getOwnPropertySymbols,Qs=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable,Ys=(e,t,r)=>t in e?Js(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xs=(e,t)=>{for(var r in t||(t={}))Qs.call(t,r)&&Ys(e,r,t[r]);if(Hs)for(var r of Hs(t))Ks.call(t,r)&&Ys(e,r,t[r]);return e};function ea(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in ta&&r.length>0}return!1}const ta=Xs(Xs(Xs(Xs(Xs(Xs({},Vs),Ws),Gs),Us),$s),Ds);function ra(e,t={}){const[r,...n]=e,i=ta[r];if(i)return i(n.map(e=>()=>ea(e)?ra(e,t):e),t);throw new Error(`Expression "${r}" is not supported.`)}var na=Object.defineProperty,ia=Object.getOwnPropertySymbols,oa=Object.prototype.hasOwnProperty,sa=Object.prototype.propertyIsEnumerable,aa=(e,t,r)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,la=(e,t)=>{for(var r in t||(t={}))oa.call(t,r)&&aa(e,r,t[r]);if(ia)for(var r of ia(t))sa.call(t,r)&&aa(e,r,t[r]);return e};function ca(e){return t=>{const r=t.properties;return!!r&&ra(e,r)}}const ua=["iconSize","iconAnchor"];function pa(e){return"function"==typeof e}var ha=Object.defineProperty,da=Object.getOwnPropertySymbols,fa=Object.prototype.hasOwnProperty,ya=Object.prototype.propertyIsEnumerable,ma=(e,t,r)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ba=(e,t)=>{for(var r in t||(t={}))fa.call(t,r)&&ma(e,r,t[r]);if(da)for(var r of da(t))ya.call(t,r)&&ma(e,r,t[r]);return e};function ga(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?ba(ba({},t),n[1]):t}}function va({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===ua.indexOf(n)){const i=n,o=e[i];ea(o)&&(t=!0,r[i]=ca(o))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return la(la({},e),n)}}(e);if(r){const n=e=>_a({paint:r(e),defaultPaint:t});return n.paint=wa({paint:e,defaultPaint:t}),n}return wa({paint:e,defaultPaint:t})}function wa({paint:e,defaultPaint:t}){var r;let n=ba({},t);return n=ba(ba({},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 _a({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=ba({},t);if(pa(e)){const n=n=>{const i=_a({paint:e(n),defaultPaint:t,getPaintFunctions:r});return i.type=e.type,i};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>_a({paint:ga(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const i=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);i&&(n=_a({paint:i,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=va({paint:e,defaultPaint:t})}return pa(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}var Oa=Object.defineProperty,La=Object.defineProperties,Pa=Object.getOwnPropertyDescriptors,Ia=Object.getOwnPropertySymbols,xa=Object.prototype.hasOwnProperty,ja=Object.prototype.propertyIsEnumerable,Ea=(e,t,r)=>t in e?Oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Aa=(e,t)=>{for(var r in t||(t={}))xa.call(t,r)&&Ea(e,r,t[r]);if(Ia)for(var r of Ia(t))ja.call(t,r)&&Ea(e,r,t[r]);return e};function Ca(e){return!!e&&Object.keys(e).length>0}function ka(e){if(!e)return;const t=Aa({},e);return function(e){return!(!e||!(Ca(e.headers)||void 0!==e.credentials||void 0!==e.cache&&"default"!==e.cache))}(t)?t:void 0}function Ma(e){const t=null==e?void 0:e.request,r=Aa(Aa({},(null==e?void 0:e.headers)||{}),(null==t?void 0:t.headers)||{}),n={};return Ca(r)&&(n.headers=r),(null==e?void 0:e.withCredentials)&&(n.credentials="include"),void 0!==(null==t?void 0:t.credentials)&&(n.credentials=t.credentials),void 0!==(null==t?void 0:t.cache)&&(n.cache=t.cache),ka(n)}function Sa(e){const t=Ma(e);return r=Aa({},e),La(r,Pa({request:t}));var r}function Na(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 Ra(e){let t;if("FeatureCollection"===e.type){t=Na(e.features.map(e=>e.geometry.type))}else if("GeometryCollection"===e.type){t=Na(e.geometries.map(e=>e.type))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const $a={polygon:"path",line:"path",point:"circle"},Ta={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Fa(e){if(e.data){const t=Ta[Ra(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":$a[t]),e.type=e.type||t}return e}var Ba=Object.defineProperty,qa=(e,t,r)=>((e,t,r)=>t in e?Ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Da{constructor(){qa(this,"backspace",8),qa(this,"tab",9),qa(this,"enter",13),qa(this,"shift",16),qa(this,"ctrl",17),qa(this,"alt",18),qa(this,"pause/break",19),qa(this,"caps_lock",20),qa(this,"escape",27),qa(this,"page_up",33),qa(this,"page_down",34),qa(this,"end",35),qa(this,"home",36),qa(this,"left_arrow",37),qa(this,"up_arrow",38),qa(this,"right_arrow",39),qa(this,"down_arrow",40),qa(this,"insert",45),qa(this,"delete",46),qa(this,"left_window_key",91),qa(this,"right_window_key",92),qa(this,"select_key",93),qa(this,"numpad_0",96),qa(this,"numpad_1",97),qa(this,"numpad_2",98),qa(this,"numpad_3",99),qa(this,"numpad_4",100),qa(this,"numpad_5",101),qa(this,"numpad_6",102),qa(this,"numpad_7",103),qa(this,"numpad_8",104),qa(this,"numpad_9",105),qa(this,"multiply",106),qa(this,"add",107),qa(this,"subtract",109),qa(this,"decimal_point",110),qa(this,"divide",111),qa(this,"f1",112),qa(this,"f2",113),qa(this,"f3",114),qa(this,"f4",115),qa(this,"f5",116),qa(this,"f6",117),qa(this,"f7",118),qa(this,"f8",119),qa(this,"f9",120),qa(this,"f10",121),qa(this,"f11",122),qa(this,"f12",123),qa(this,"num_lock",144),qa(this,"scroll_lock",145),qa(this,"semi-colon",186),qa(this,"equal_sign",187),qa(this,",",188),qa(this,"-",189),qa(this,".",190),qa(this,"/",191),qa(this,"`",192),qa(this,"[",219),qa(this,"\\",220),qa(this,"]",221),qa(this,"'",222)}}var Ua=Object.defineProperty,Va=(e,t,r)=>((e,t,r)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var Ga=Object.defineProperty,za=(e,t,r)=>((e,t,r)=>t in e?Ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Za{constructor(e,t){za(this,"webMap",e),za(this,"name"),za(this,"event"),za(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 Wa=Object.defineProperty,Ja=(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 Ha extends Za{constructor(){super(...arguments),Ja(this,"name","bounds"),Ja(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,Ka=(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 Ya extends Za{constructor(){super(...arguments),Ka(this,"name","center"),Ka(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 Xa=Object.defineProperty,el=(e,t,r)=>((e,t,r)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class tl extends Za{constructor(){super(...arguments),el(this,"name","zoom"),el(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 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),il=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});let ol=0;const sl={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},al=class e{constructor(t){nl(this,"options",sl),nl(this,"emitter",new M),nl(this,"keys",e.keys),nl(this,"mapAdapter"),nl(this,"runtimeParams",[]),nl(this,"getPaintFunctions",e.getPaintFunctions),nl(this,"mapStateItems",[Ya,tl,Ha]),nl(this,"id",ol++),nl(this,"mapState",[]),nl(this,"_initMapState",{}),nl(this,"_starterKits"),nl(this,"_extent"),nl(this,"_eventsStatus",{}),nl(this,"_coordFromMapClickAbort"),nl(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(sl||{},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 il(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,i]=e,o=t<n&&r<i;if(!o){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${i}]`);const e=[Math.min(t,n),Math.min(r,i),Math.max(t,n),Math.max(i,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&i<=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)},i=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&i?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",i),this._coordFromMapClickAbort=void 0},i=t=>{n(),o(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",i),this._coordFromMapClickAbort=n})}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return il(this,null,function*(){})}_onLoadSync(){return il(this,null,function*(){})}_setupMap(){return il(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)})}};nl(al,"keys",new class{constructor(){Va(this,"keyCodeAlias",new Da),Va(this,"keys",{}),Va(this,"_windowOnFocus"),Va(this,"_keysPressed"),Va(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={}}}),nl(al,"getPaintFunctions");let ll=al;var cl=Object.defineProperty,ul=Object.defineProperties,pl=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,dl=Object.prototype.hasOwnProperty,fl=Object.prototype.propertyIsEnumerable,yl=(e,t,r)=>t in e?cl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ml=(e,t)=>{for(var r in t||(t={}))dl.call(t,r)&&yl(e,r,t[r]);if(hl)for(var r of hl(t))fl.call(t,r)&&yl(e,r,t[r]);return e},bl=(e,t)=>ul(e,pl(t)),gl=(e,t,r)=>yl(e,"symbol"!=typeof t?t+"":t,r),vl=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});class wl extends ll{constructor(e){super(e),gl(this,"_layersIdCounter",1),gl(this,"_layersOrderCounter",1),gl(this,"_baselayers",[]),gl(this,"_layers",{}),gl(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",()=>this.addTileJsonLayer(t))}fitLayer(e,t){return vl(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 vl(this,null,function*(){return yield this.addLayer(e,bl(ml({},t),{baselayer:!0}),void 0)})}addLayer(e){return vl(this,arguments,function*(e,t={},r){var i,o;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==(i=(t=ml({id:String(s),order:a},t)).visibility)||i;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(t=bl(ml({},t),{request:this._getLayerRequestOptions(t)}),void 0!==l){const e=new l(this.mapAdapter.map,t);let r;e.options=ml(ml({},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!=(o=e.options.order)?o: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 i=t.opacity;null!=i&&i<=1&&this.setLayerOpacity(e,i);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 vl(this,null,function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),i=e(),o=yield i;return o?this.addLayer(o,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 vl(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=Fa(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",bl(ml({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",bl(ml({},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),i=void 0!==t?t:!(n&&n.options.visibility),o=void 0!==r.silent&&r.silent,s=e=>vl(this,null,function*(){const t=String(e.id),r=i?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(i?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),i&&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=i,o||(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=>!t||(!e.feature||!e.feature.properties||Jt(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 i=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(i&&e.onlyBaselayer&&(i=this._baselayers.includes(r)),i){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,request:e.request})}_getLayerRequestOptions(e){var t,r,n,i;const o=ka(this.options.layerRequest),s=Ma(e),a=ml(ml({},(null==o?void 0:o.headers)||{}),(null==s?void 0:s.headers)||{}),l=!1===e.withCredentials&&void 0===(null==(t=e.request)?void 0:t.credentials)&&void 0!==(null==o?void 0:o.credentials)?"same-origin":null!=(r=null==s?void 0:s.credentials)?r:null==o?void 0:o.credentials,c=void 0!==(null==(n=e.request)?void 0:n.cache)?e.request.cache:null!=(i=null==s?void 0:s.cache)?i:null==o?void 0:o.cache;return ka(ml(ml(ml(ml(ml({},o),s),Object.keys(a).length?{headers:a}:{}),void 0!==l?{credentials:l}:{}),void 0!==c?{cache:c}:{}))}_emitLayerEvent(e,t,r){const i=String(e);if(n(t)&&i.startsWith("layer:")){const e=i.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return vl(this,null,function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)})}_onLayerDoubleClick(e){return vl(this,null,function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)})}_onLayerSelect(e){return vl(this,null,function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)})}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:i,onDoubleClick:o,onLayerClick:s,onMouseOut:a,onMouseOver:l}=e,c=i||s,u=o||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=_a({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=_a({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}var _l=Object.defineProperty,Ol=Object.getOwnPropertySymbols,Ll=Object.prototype.hasOwnProperty,Pl=Object.prototype.propertyIsEnumerable,Il=(e,t,r)=>((e,t,r)=>t in e?_l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),xl=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const jl=class e extends wl{constructor(){super(...arguments),Il(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[],inside:[]}),Il(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1,inside:!1})}addControl(e,t,r){return xl(this,null,function*(){let n;const{addOptions:i,createOptions:o}=this._splitControlOptions(r);if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,o):e,n)return new Promise(e=>{this._setControlQueue(this._getControlQueueKey(t),()=>xl(this,null,function*(){const r=yield n,o=this.mapAdapter.addControl(r,t,i);e(o)}))})})}createControl(e,t){return xl(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)})}createButtonControl(e){return xl(this,null,function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)})}createToggleControl(e){return xl(this,null,function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?Ns(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()}_getControlQueueKey(e){return"string"==typeof e?e:"inside"}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return xl(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})}_splitControlOptions(e){if(!e)return{};const t=e,{id:r,order:n}=t,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&&Ol)for(var n of Ol(e))t.indexOf(n)<0&&Pl.call(e,n)&&(r[n]=e[n]);return r})(t,["id","order"]);return{addOptions:this._getAddControlOptions(r,n),createOptions:i}}_getAddControlOptions(e,t){return void 0!==e||void 0!==t?{id:e,order:t}:void 0}};Il(jl,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let El=jl;var Al=Object.defineProperty,Cl=Object.defineProperties,kl=Object.getOwnPropertyDescriptors,Ml=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,Nl=Object.prototype.propertyIsEnumerable,Rl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),$l=(e,t,r)=>t in e?Al(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tl=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}),Fl=(e,t,r)=>(t=e[Rl("asyncIterator")])?t.call(e):(e=e[Rl("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise((r,i,o)=>(t=n.call(e,t),o=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:o}),i)))),r("next"),r("return"),t);class Bl extends El{constructor(e){super(e),this._addControls(),Ss(this.id,this)}static get(e){return Ms(e)}_addLayerProviders(){return Tl(this,null,function*(){try{for(var e,t,r,n=Fl(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 i,o,s,a=Fl(t);i=!(o=yield a.next()).done;i=!1){const e=o.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(o){s=[o]}finally{try{i&&(o=a.return)&&(yield o.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 Tl(this,null,function*(){try{for(var e,t,r,n=Fl(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(i){console.error(i)}}}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,{id:i,order:o,position:s}=n,a=((e,t)=>{var r={};for(var n in e)Sl.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&&Nl.call(e,n)&&(r[n]=e[n]);return r})(n,["id","order","position"]);var l;this.addControl(t,s||"top-left",(l=((e,t)=>{for(var r in t||(t={}))Sl.call(t,r)&&$l(e,r,t[r]);if(Ml)for(var r of Ml(t))Nl.call(t,r)&&$l(e,r,t[r]);return e})({},a),Cl(l,kl({id:i,order:o}))))}),this._emitStatusEvent("controls:create")}}function ql(){return["ZOOM","ATTRIBUTION"]}function Dl(e){return t=this,r=null,n=function*(){return new Bl(e).onLoad()},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())});var t,r,n}var Ul=Object.defineProperty,Vl=Object.defineProperties,Gl=Object.getOwnPropertyDescriptors,zl=Object.getOwnPropertySymbols,Zl=Object.prototype.hasOwnProperty,Wl=Object.prototype.propertyIsEnumerable,Jl=(e,t,r)=>t in e?Ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hl=(e,t)=>{for(var r in t||(t={}))Zl.call(t,r)&&Jl(e,r,t[r]);if(zl)for(var r of zl(t))Wl.call(t,r)&&Jl(e,r,t[r]);return e},Ql=(e,t)=>Vl(e,Gl(t));function Kl(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(Ql(Hl({},r),{resource:t}));else if(Array.isArray(t)){const[i,o]=t;e.push(Hl(Ql(Hl({},r),{resource:i,id:o}),n))}else"object"==typeof t&&e.push(Hl(Hl(Hl({},r),t),n))}var Yl=Object.defineProperty,Xl=Object.defineProperties,ec=Object.getOwnPropertyDescriptors,tc=Object.getOwnPropertySymbols,rc=Object.prototype.hasOwnProperty,nc=Object.prototype.propertyIsEnumerable,ic=(e,t,r)=>t in e?Yl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const oc={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 sc(e){const t=[new zi];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(oc,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new as({connector:e.connector,auth:e.auth})),n=((e,t)=>{for(var r in t||(t={}))rc.call(t,r)&&ic(e,r,t[r]);if(tc)for(var r of tc(t))nc.call(t,r)&&ic(e,r,t[r]);return e})({},e),e=Xl(n,ec({starterKits:t,create:!1}))}var ac=Object.defineProperty,lc=Object.defineProperties,cc=Object.getOwnPropertyDescriptors,uc=Object.getOwnPropertySymbols,pc=Object.getPrototypeOf,hc=Object.prototype.hasOwnProperty,dc=Object.prototype.propertyIsEnumerable,fc=Reflect.get,yc=(e,t,r)=>t in e?ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mc=(e,t)=>{for(var r in t||(t={}))hc.call(t,r)&&yc(e,r,t[r]);if(uc)for(var r of uc(t))dc.call(t,r)&&yc(e,r,t[r]);return e},bc=(e,t)=>lc(e,cc(t)),gc=(e,t,r)=>yc(e,"symbol"!=typeof t?t+"":t,r),vc=(e,t,r)=>fc(pc(e),r,t),wc=(e,t,r)=>new Promise((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())});const _c=class e extends Bl{constructor(e){super(sc(e)),gc(this,"emitter",new M),gc(this,"connector"),gc(this,"_ngwLayers",{}),gc(this,"$$selectFromNgwRaster"),gc(this,"$$selectFromNgwVector"),gc(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 wc(this,null,function*(){return yield this.onLoad("controls:create"),vc(e.prototype,this,"addControl").call(this,t,r,n)})}addNgwLayer(e){return wc(this,null,function*(){yield this.onMapLoad();const{keyname:t,resourceId:r,filters:i}=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{e.adapterOptions=e.adapterOptions||{},n(this.options.setViewDelay)&&(n(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay)),n(i)&&(e.adapterOptions.propertiesFilter=i);const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),Xo(e,t,r)}(e,this,this.connector),r=mc(mc({visibility:!0},e),e.adapterOptions),o=yield this.addLayer(t,r),s=o&&this.getLayerId(o);if(o&&s&&(this._ngwLayers[s]={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(s){const e=y(o)&&"id"in o?o.id:t||r||o;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 $r(mc({connector:this.connector},e))}fetchNgwLayerItems(e){return Pr(mc({connector:this.connector},e))}fetchNgwLayerFeature(e){return bs(mc({connector:this.connector},e))}fetchNgwLayerFeatures(e){return so(mc({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 i=function(e){const{connector:t,identify:r}=e,n=Es(r);return n&&n.length?$r(xs(xs({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",i,r),i}fetchIdentifyGeoJson(e,{signal:t}={}){const r=new AbortController;if(t){if(t.aborted)return Promise.reject(new ht.errors.AbortError);t.addEventListener("abort",()=>{r.abort("AbortError")})}const n=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const o in r){const e=Number(o);if(!isNaN(e)){const e=r[o];if("features"in e){const t=e.features.find(e=>e.geom);if(t&&t.geom){const e=t.geom;return Promise.resolve(rr(js(xs({},t),{geom:e})))}}}}const i=Es(r);return i&&i.length?bs(xs(js(xs({},n),{connector:t}),i[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:{signal:r.signal}});return n&&"then"in n?(this._addPromise("identify",n,r),n):Promise.resolve(n)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,{multiple:t})}getNgwLayers(){return wc(this,null,function*(){return yield this.onLoad(),this._ngwLayers})}getNgwLayerByResourceId(e){return wc(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 wc(this,null,function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const i=n&&this._ngwLayers[n];if(i)if(i.layer.getBounds){const e=yield i.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(i.layer.item)e=i.layer.item;else{const t=i.resourceId;e=yield this.connector.getResource(t)}e&&this.fitResource(e.resource.id)}else vc(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)})}fitResource(e,t){return wc(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 wc(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 wc(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,i="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,o=null==(t=n.options.interactive)||t;if(i&&n.options.selectable&&o&&this.isLayerVisible(n)){const e=i.call(n);r.push(e)}}const i=Promise.all(r),s=yield i,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,i]=e.lngLat;d={type:"Polygon",coordinates:[p(n,i,h)]};const o=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:d}});r!==1/0&&setTimeout(()=>{this.removeLayer(o)},r)}const f=new AbortController,y=function(e,t){o(e);const[r,n]=e.lngLat,{geom:i,radius:s}=t,a=null!=i?i:p(r,n,s);return Cs(js(xs({},t),{geom:a}))}(e,{layers:a,connector:this.connector,radius:h,geom:d,signal:f.signal}).then(t=>{const r=bc(mc({},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 wc(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&&Kl(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),Kl(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}]},i={featureCount:1,[r]:t};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(bc(mc({},i),{resources:[r],sourceType:"vector"}))),i}}}_prepareToIdentify(e){return bc(mc({},e),{getIdentifyItems:()=>Es(e,!0).map(e=>new ms({feature:e.feature,connector:this.connector}))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return wc(this,null,function*(){const e=this.getContainer();if(e){const t=yield gs(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}})}};gc(_c,"getIcon",function(t={}){var r,n,i,o,s,a;const l=null!=(r=t.shape)?r:"circle",c=null!=(n=t.color)?n:"blue",u=null!=(i=t.strokeColor)?i:"white",p=null!=(o=t.size)?o: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 i=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${i} -${i} ${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 Oc=_c;function Lc(e){return t=this,r=null,n=function*(){return new Oc(e).onLoad()},new Promise((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())});var t,r,n}export{Oc as NgwMap,Bl as WebMap,El as WebMapControls,wl as WebMapLayers,ll as WebMapMain,Sa as applyLayerRequestOptions,Lc as createNgwMap,Ns as createToggleControl,Dl as createWebMap,Ra as detectGeometryType,Na as findMostFrequentGeomType,ql as getDefaultControls,Ma as getLayerRequestOptions,Ms as getWebMap,ka as normalizeLayerRequestOptions,$a as paintTypeAlias,Ss as setWebMap,Ta as typeAlias,Fa as updateGeoJsonAdapterOptions};
2
2
  //# sourceMappingURL=ngw-map.esm-browser.prod.js.map