@nextgis/ngw-map 3.0.0-alpha.12 → 3.0.0-alpha.14

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
- function e(){}function t(){t.init.call(this)}function r(e){return void 0===e._maxListeners?t.defaultMaxListeners:e._maxListeners}function n(t,n,o,i){var s,a,l,c;if("function"!=typeof o)throw new TypeError('"listener" argument must be a function');if((a=t._events)?(a.newListener&&(t.emit("newListener",n,o.listener?o.listener:o),a=t._events),l=a[n]):(a=t._events=new e,t._eventsCount=0),l){if("function"==typeof l?l=a[n]=i?[o,l]:[l,o]:i?l.unshift(o):l.push(o),!l.warned&&(s=r(t))&&s>0&&l.length>s){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+n+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=n,u.count=l.length,c=u,"function"==typeof console.warn?console.warn(c):console.log(c)}}else l=a[n]=o,++t._eventsCount;return t}function o(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function i(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 s(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}e.prototype=Object.create(null),t.EventEmitter=t,t.usingDomains=!1,t.prototype.domain=void 0,t.prototype._events=void 0,t.prototype._maxListeners=void 0,t.defaultMaxListeners=10,t.init=function(){this.domain=null,t.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new e,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},t.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},t.prototype.getMaxListeners=function(){return r(this)},t.prototype.emit=function(e){var t,r,n,o,i,a,l,c="error"===e;if(a=this._events)c=c&&null==a.error;else if(!c)return!1;if(l=this.domain,c){if(t=arguments[1],!l){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=l,t.domainThrown=!1,l.emit("error",t),!1}if(!(r=a[e]))return!1;var h="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=s(e,n),i=0;i<n;++i)o[i].call(r)}(r,h,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=s(e,o),a=0;a<o;++a)i[a].call(r,n)}(r,h,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,a=s(e,i),l=0;l<i;++l)a[l].call(r,n,o)}(r,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var a=e.length,l=s(e,a),c=0;c<a;++c)l[c].call(r,n,o,i)}(r,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=s(e,o),a=0;a<o;++a)i[a].apply(r,n)}(r,h,this,o)}return!0},t.prototype.on=t.prototype.addListener=function(e,t){return n(this,e,t,!1)},t.prototype.prependListener=function(e,t){return n(this,e,t,!0)},t.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,o(this,e,t)),this},t.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,o(this,e,t)),this},t.prototype.removeListener=function(t,r){var n,o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[t]))return this;if(n===r||n.listener&&n.listener===r)0==--this._eventsCount?this._events=new e:(delete o[t],o.removeListener&&this.emit("removeListener",t,n.listener||r));else if("function"!=typeof n){for(i=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new e,this;delete o[t]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(n,i);o.removeListener&&this.emit("removeListener",t,a||r)}return this},t.prototype.off=function(e,t){return this.removeListener(e,t)},t.prototype.removeAllListeners=function(t){var r,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new e,this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=new e:delete n[t]),this;if(0===arguments.length){for(var o,i=Object.keys(n),s=0;s<i.length;++s)"removeListener"!==(o=i[s])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=new e,this._eventsCount=0,this}if("function"==typeof(r=n[t]))this.removeListener(t,r);else if(r)do{this.removeListener(t,r[r.length-1])}while(r[0]);return this},t.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):[]},t.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):i.call(e,t)},t.prototype.listenerCount=i,t.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};const a={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"/>'},l=12;function c(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const o=void 0===r.replace||r.replace;t.forEach((t=>{Object.getOwnPropertyNames(t.prototype).forEach((r=>{const i=-1!==n.indexOf(r);if(!o&&!i||o){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}}))}))}function u(e){return null!=e}function h(e){return"string"==typeof e?!!e:u(e)}function p(e,t,r=!1){let n=e;const o=t,i=Array.isArray(o);let s=i&&[]||{};return i&&Array.isArray(o)?r?(n=n||[],s=s.concat(n),o.forEach(((e,t)=>{void 0===s[t]?s[t]=e:"object"==typeof e?s[t]=p(n[t],e,r):-1===n.indexOf(e)&&s.push(e)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(e){s[e]=n[e]})),Object.keys(o).forEach((function(e){s[e]="object"==typeof o[e]&&o[e]&&"object"==typeof n[e]&&"object"==typeof o[e]?p(n[e],o[e],r):o[e]}))),s}function d(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}const f=6371;function y(e){return{type:"Polygon",coordinates:[m(e)]}}function m(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const b=Math.PI/180,g=180/Math.PI;function v(e,t,r=10,n=6){const o=r/f*g,i=o/Math.cos(t*b),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+i*Math.cos(r),c=t+o*Math.sin(r);s.push([l,c])}return s}function w(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 _(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:O(e,t));return e===t}function O(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let o=0;o<r.length;o++){if(!_(e[r[o]],t[n[o]],e,t))return!1}return!0}function L(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]=L(e[r])})),t}function P(e){return"[object Object]"===Object.prototype.toString.call(e)}function I(e){return e.replace(/([^:]\/)\/+/g,"$1")}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 i,s;"object"==typeof r&&"valueToSet"in r?(i=r,n=i.onlyFull,o=i.expirationTime,s=i.props):s=r;const a=this._find(e,s);if(a)return a.value;{let r;r=t instanceof Function?t():t;const i=s&&JSON.parse(JSON.stringify(L(s)));o=o?Date.now()+o:void 0;const a={key:e,value:r,props:i,expirationTime:o};return n&&!h(r)?r:(this.cache.push(a),r instanceof Promise?(r.catch((t=>{this.delete(e,s)})),n&&r.then((t=>(h(t)||this.delete(e,s),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 O(e.props||{},L(r))}};j(E,"instance",{});let A=E;var C="3.0.0-alpha.8";const k=[];function M(e){k.push(e)}class S extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var N=Object.defineProperty,T=(e,t,r)=>((e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class R extends Error{constructor(e){super(),T(this,"name","NgwError"),T(this,"title"),T(this,"message"),T(this,"detail"),T(this,"exception"),T(this,"status_code"),T(this,"data"),T(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,R.prototype)}}var F=Object.defineProperty,B=(e,t,r)=>((e,t,r)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class $ extends R{constructor(e){super(e),B(this,"name","InsufficientPermissionsError"),B(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,$.prototype)}}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,t+"",r);class U extends Error{constructor(e){super(),D(this,"name","NetworkError"),Object.setPrototypeOf(this,U.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}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);let z=class e extends R{constructor(t){super(t),G(this,"message","There is no response from the server or problem connecting to server."),G(this,"title","Network error"),G(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.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);class H extends R{constructor(e){super(e),W(this,"name","ResourceNotFoundError"),W(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,H.prototype)}}var J=Object.freeze({__proto__:null,AbortError:S,InsufficientPermissionsError:$,NetworkError:U,NetworksResponseError:z,NgwError:R,ResourceNotFoundError:H,extractError:function(e){if(P(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 z({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!P(e)&&(e.status_code&&e.exception&&e.title)}}),Q=Object.defineProperty,K=(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 X extends Error{constructor(e){super(e||"Something went wrong."),K(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,X)}}class Y extends X{constructor(e){super(e||"There is no response from the server or problem connecting to server."),K(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class ee extends X{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class te extends X{constructor(e){super(e.message),K(this,"detail"),K(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class re extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),K(this,"title"),K(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,re)}}class ne extends re{constructor(e){super("Long-running request was cancelled.",e)}}class oe extends re{constructor(e){super(void 0,e)}}var ie=Object.defineProperty,se=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ce=(e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ue=(e,t)=>{for(var r in t||(t={}))ae.call(t,r)&&ce(e,r,t[r]);if(se)for(var r of se(t))le.call(t,r)&&ce(e,r,t[r]);return e},he=(e,t)=>{var r={};for(var n in e)ae.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&se)for(var n of se(e))t.indexOf(n)<0&&le.call(e,n)&&(r[n]=e[n]);return r},pe=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function de(e){return pe(this,null,(function*(){const t=yield function(e){return pe(this,null,(function*(){try{return e.json()}catch(t){throw new Error}}))}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise((t=>setTimeout(t,e)));let a=!1,l=!1;for(;!l;){let e,t;yield s(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(c){a=!0;continue}switch(t.status){case void 0:throw new re(void 0,t);case"ready":l=!0;break;case"cancelled":throw new ne(t);case"failed":throw new oe(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new re(void 0,t)}}return i}))}const fe=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ye(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function me(e,t,r){return pe(this,null,(function*(){var n;const o=ue(ue({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:i,responseType:s,cacheProps:a,cacheName:l,lunkwill:c,cache:u,query:h,json:p}=o,d=he(o,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);i&&(d.credentials="include");let f=!1;void 0!==c&&(c.toHeaders(d.headers||{}),f=!0);const y=!!d.lunkwillReturnUrl;if(delete d.lunkwillReturnUrl,void 0!==p){d.body=JSON.stringify(p);const e=d.headers||{};e["Content-Type"]="application/json",d.headers=e}const m=ye(e,h),b=()=>pe(this,null,(function*(){let e;try{e=yield fetch(m,d)}catch(o){if(d.signal&&d.signal.aborted)throw o;throw new Y}if(f&&function(e){const t=e.headers.get("content-type");return null!=t&&t.includes("application/vnd.lunkwill.request-summary+json")}(e)){const t=yield de(e);if(y)return t;e=yield function(e){return pe(this,null,(function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new Y}}))}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&fe.test(t);if("blob"===s||o)n=yield e.blob();else{if(!r)throw new ee;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof ee)throw o;throw new ee}if(400<=e.status&&e.status<=599)throw new te(n);return n}));if(r&&"GET"===(null==(n=d.method)?void 0:n.toUpperCase())){const e=a||ue({},L({withCredentials:i,responseType:s}));return r.add(l||m,b,{props:e,expirationTime:u?void 0:500})}return b()}))}var be=Object.defineProperty,ge=Object.defineProperties,ve=Object.getOwnPropertyDescriptors,we=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,Le=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t)=>{for(var r in t||(t={}))_e.call(t,r)&&Le(e,r,t[r]);if(we)for(var r of we(t))Oe.call(t,r)&&Le(e,r,t[r]);return e},Ie=(e,t)=>{var r={};for(var n in e)_e.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&we)for(var n of we(e))t.indexOf(n)<0&&Oe.call(e,n)&&(r[n]=e[n]);return r},xe=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function je(e,t,r,...n){const[o,...i]=r[e],s=n[0];let a;if(void 0===s)a=[];else if("object"==typeof s&&null!==s){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");a=[];for(const[e,t]of Object.entries(s))a[i.indexOf(e)]=String(t)}else a=n.map((e=>String(e)));return I(t+o.replace(/\{(\w+)\}/g,(function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)})))}function Ee(e){return"[object Object]"===Object.prototype.toString.call(e)}let Ae;Ae=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new R(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new U(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&i.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{i.abort()})),i.send(l)};const Ce=/\{ *([\w_-]+) *\}/g;function ke(e,t){return e.replace(Ce,((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 Me=Object.defineProperty,Se=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Te=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable,Be=(e,t,r)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t)=>{for(var r in t||(t={}))Re.call(t,r)&&Be(e,r,t[r]);if(Te)for(var r of Te(t))Fe.call(t,r)&&Be(e,r,t[r]);return e},qe=(e,t,r)=>Be(e,"symbol"!=typeof t?t+"":t,r),De=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let Ue=0,Ve=0;class Ge{constructor(e){this.options=e,qe(this,"id",Ue++),qe(this,"emitter",new t),qe(this,"user"),qe(this,"cache"),qe(this,"withCredentials"),qe(this,"client",`NextGIS-NGW-Connector/${C}`),qe(this,"routeStr","/api/component/pyramid/route"),qe(this,"activeRequests",{}),qe(this,"requestTransform");const r=function(e){return k.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return O(t.options.auth,e.auth)}}))}(e);if(this.cache=new A({namespace:e.cacheId}),r)return r;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),M(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,M(this)}connect(){return De(this,null,(function*(){const e=this.options.auth;if(e){const{login:t,password:r}=e;t&&r&&(yield this._login({login:t,password:r}))}const t=`${this.routeStr}?client=${this.client}`;return yield this.makeQuery(t,{},{cacheName:"route",cache:!0,cacheProps:{id:this.id,auth:e,baseUrl:this.options.baseUrl}})}))}login(e,t){return this.logout(),M(this),this._login(e,t)}logout(){this.abort(),function(e){const t=k.indexOf(e);-1!==t&&k.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return De(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=$e({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return $e({},this.activeRequests)}route(e,...t){return function(e,t,...r){const n={url:n=>xe(this,null,(function*(){var o;const i=yield t.connect();return ye(je(e,null!=(o=t.options.baseUrl)?o:"",i,...r),null==n?void 0:n.query)}))},o=["get","post","put","delete","patch"];for(const i of o){const o=n=>xe(this,null,(function*(){var o;const s=n||{},{headers:a}=s,l=Ie(s,["headers"]),c=yield t.connect(),u=je(e,null!=(o=t.options.baseUrl)?o:"",c,...r),h=L(Pe(Pe({},t.getAuthorizationHeaders()),null!=a?a:{}));return me(u,(p=Pe({headers:h},l),ge(p,ve({method:i}))),t.cache);var p}));n[i]=o}return n}(e,this,...t)}makeQuery(e,t){return De(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)Re.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Te)for(var n of Te(e))t.indexOf(n)<0&&Fe.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=ke(e,r)}e=encodeURI(I(e)),r=$e({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:h}=r,p=new AbortController,d=p.signal;if(i){if(i.aborted)throw new S;i.addEventListener("abort",(()=>{p.abort()}))}r.signal=d;const f=()=>De(this,null,(function*(){const t=Ve++;this.activeRequests[t]=p;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if("GET"===s){const r=c||(y=$e({},L({headers:a,withCredentials:h,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Se(y,Ne({params:t})));return this.cache.add(l||e,f,{props:r,expirationTime:o?void 0:500})}var y;return f()}))}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=$e($e({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;Ae(e,r,t,n,(e=>{i=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==i&&i(),n(new S)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return De(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 R){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new H(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new $(e)}return e}}qe(Ge,"errors",J);const ze=["description"];function Ze(e,t=""){t=t?t+"__":"";const r={};for(const[n,o]of Object.entries(e))if(-1===ze.indexOf(n))if(Ee(o))if("owner_user"===n){const e=Ze(o,n);Object.assign(r,e)}else"parent"===n&&"id"in o&&(r.parent_id=o.id);else u(o)&&(r[t+n]=o);return r}var We=Object.defineProperty,He=Object.defineProperties,Je=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Ye=(e,t,r)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t)=>{for(var r in t||(t={}))Ke.call(t,r)&&Ye(e,r,t[r]);if(Qe)for(var r of Qe(t))Xe.call(t,r)&&Ye(e,r,t[r]);return e},tt=(e,t)=>He(e,Je(t)),rt=(e,t,r)=>Ye(e,"symbol"!=typeof t?t+"":t,r),nt=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class ot{constructor({connector:e,cacheId:t}){rt(this,"cache"),rt(this,"connector"),this.connector=e,this.cache=new A({namespace:t})}getOne(e,t){const r=et({},t);return"string"==typeof e||"number"==typeof e||Ee(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Ee(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 H}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Ee(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,Ze(e)),this.connector.route("resource.search").get(tt(et({},t),{query:et({serialization:"full"},r)})).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)}))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t){return nt(this,arguments,(function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(tt(et({},t),{query:{parent:n}})),i=[];for(const s of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(s),{id:s.resource.id}),r.push(s),(null==t?void 0:t.recursive)&&s.resource.children&&i.push(this._getChildrenOf(s.resource.id,t,r));return i.length?Promise.all(i).then((()=>r)):r}))}_cleanResourceItemCache(e){return nt(this,null,(function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)}))}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then((t=>(t.filter((t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:u(e.id)&&u(t.resource.id)?e.id===t.resource.id:O(e,t.resource)})),[])))}}var it=Object.defineProperty,st=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable,ct=(e,t,r)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function ut(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=ke(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={}))at.call(t,r)&&ct(e,r,t[r]);if(st)for(var r of st(t))lt.call(t,r)&&ct(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var ht=Object.defineProperty,pt=(e,t,r)=>((e,t,r)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class dt extends Ge{constructor(e){super(e),pt(this,"resources"),this.resources=new ot({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 ut({name:e,params:L(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 ft=Object.defineProperty,yt=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,gt=(e,t,r)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))mt.call(t,r)&&gt(e,r,t[r]);if(yt)for(var r of yt(t))bt.call(t,r)&&gt(e,r,t[r]);return e};function wt(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const _t={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)=>wt(e,t),ilike:(e,t)=>wt(e,t,!0)};function Ot(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Lt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Ot(t)){const[r,n,o]=t,i=_t[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,i)=>(t=e[i],r.replace(i,o))));return i(t,n)}return i(e[r],o)}return!1}return Lt(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}const Pt={defaultRequestLimit:7e3};var It=Object.defineProperty,xt=Object.defineProperties,jt=Object.getOwnPropertyDescriptors,Et=Object.getOwnPropertySymbols,At=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,kt=(e,t,r)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Mt=(e,t)=>{for(var r in t||(t={}))At.call(t,r)&&kt(e,r,t[r]);if(Et)for(var r of Et(t))Ct.call(t,r)&&kt(e,r,t[r]);return e},St=(e,t)=>xt(e,jt(t)),Nt=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Tt={srs:4326,geom_format:"geojson"};function Rt(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function Ft(e,t){const{extensions:r,geom:n,fields:o,srs:i,ilike:s,like:a}=t;e.extensions=r||[],o&&(e.fields=o),void 0!==n&&(e.geom=n,n||(delete e.srs,delete e.geom_format)),u(s)?e.ilike=s:u(a)&&(e.like=a),u(i)&&(e.srs=i)}function Bt(e){return Nt(this,null,(function*(){const t=qt(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o}))}function $t(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,i=n,r)))}__${r}`,o+n+i]}function qt(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===s)for(const l of a)Ot(l)?t.push(Ut(St(Mt({},e),{paramList:[...r,...i,$t(l)]}))):qt(St(Mt({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)Ot(e)?n.push($t(e)):o.push(e);if(o.length)for(const i of o)qt(St(Mt({},e),{filters:i}),t,[...r,...n]);else t.push(Ut(St(Mt({},e),{paramList:[...r,...i,...n]})))}return t}function Dt(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=w(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function Ut(e){const t=Mt({},Tt),{limit:r,query:n,cache:o,signal:i,offset:s,orderBy:a,paramList:l,connector:c,geomFormat:u,intersects:h,resourceId:p}=e;if(t.limit=r&&r!==Number.POSITIVE_INFINITY?r:Pt.defaultRequestLimit,s&&(t.offset=s),u&&(t.geom_format=u),Ft(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)?m(h):h;t.intersects=Dt(e)}else"string"==typeof h&&(t.intersects=h);return l&&Object.assign(t,function(e){return e.reduce(((e,[t,r])=>(e[t]=r,e)),{})}(l)),c.route("feature_layer.feature.collection",{id:Number(p)}).get({query:Mt(Mt({},t),n),cache:o,signal:i})}var Vt=Object.defineProperty,Gt=Object.defineProperties,zt=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,Wt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable,Jt=(e,t,r)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qt=(e,t)=>{for(var r in t||(t={}))Wt.call(t,r)&&Jt(e,r,t[r]);if(Zt)for(var r of Zt(t))Ht.call(t,r)&&Jt(e,r,t[r]);return e},Kt=(e,t)=>Gt(e,zt(t)),Xt=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Yt(e){return Xt(this,null,(function*(){const t=Qt({},Tt);Ft(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Kt(Qt({},e),{query:t}));return Kt(Qt({},r),{toGeojson:()=>Xt(this,null,(function*(){if(r.geom)return Rt(r);{const t=(yield Yt(Kt(Qt({},e),{geom:!0,fields:null,extensions:null}))).geom;return Rt(Kt(Qt({},r),{geom:t}))}}))})}))}var er=Object.defineProperty,tr=Object.getOwnPropertySymbols,rr=Object.prototype.hasOwnProperty,nr=Object.prototype.propertyIsEnumerable,or=(e,t,r)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ir=(e,t,r)=>or(e,"symbol"!=typeof t?t+"":t,r);class sr{constructor(e){this.options=e,ir(this,"name"),ir(this,"resourceId"),ir(this,"item"),ir(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=>{const{minLat:t,minLon:r,maxLat:n,maxLon:o}=e.extent,i=[r,t,o,n];return this._extent=i,i}))}geoJson(e){return this.item.geom?Promise.resolve(Rt(this.item)):Yt(((e,t)=>{for(var r in t||(t={}))rr.call(t,r)&&or(e,r,t[r]);if(tr)for(var r of tr(t))nr.call(t,r)&&or(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,Rt(this.item))))}}function ar(e,t,r,n){return!!ur(e,t,r,hr)}function lr(e,t,r,n){return ur(e,t,r,pr)}function cr(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 ur(e,t=e=>!!e,r="children",n,o){return n(e,"function"==typeof t?t:e=>Lt(e,t),r)}function hr(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(t(e))return e;const n=cr(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){const e=hr(o[i],t,r,n);if(e)return e}}function pr(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{t(e)&&n.push(e);const i=cr(e,r);i&&(o=i)}for(let i=0;i<o.length;i++)o[i]&&pr(o[i],t,r,n);return n}function dr(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(!t(e))return!1;const n=cr(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){if(!dr(o[i],t,r,n))return!1}return!0}var fr=Object.defineProperty,yr=(e,t,r)=>((e,t,r)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class mr{constructor(e){yr(this,"item"),yr(this,"_children",[]),yr(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?lr(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 ur(this._children,e,(e=>e.tree.getChildren()),hr)}every(e){return!!ur(this._children,e,(e=>e.tree.getChildren()),dr)}some(e){return ar(this._children,e,(e=>e.tree.getChildren()))}all(e){return this.getDescendants(e)}getDescendants(e){return lr(this._children,e,(e=>e.tree.getChildren()))}getChildren(){return[...this._children]}}var br=Object.defineProperty,gr=(e,t,r)=>((e,t,r)=>t in e?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class vr{constructor(e,r,n){gr(this,"options"),gr(this,"emitter",new t),gr(this,"name"),gr(this,"item"),gr(this,"_blocked",!1),gr(this,"_container"),gr(this,"_value"),gr(this,"_removeEventsListener"),this.item=r,this.options=Object.assign({},n),this.name=e,this._value=this.getProperty()}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,_r=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Lr=Object.prototype.propertyIsEnumerable,Pr=(e,t,r)=>t in e?wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ir=(e,t)=>{for(var r in t||(t={}))Or.call(t,r)&&Pr(e,r,t[r]);if(_r)for(var r of _r(t))Lr.call(t,r)&&Pr(e,r,t[r]);return e};const xr=class e extends vr{constructor(t,r,n){super(t,r,Ir(Ir({},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(t)}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(t)}_propagation(e,t){if(this.isGroup()){const r=this.item.tree.getChildren();for(let n=0;n<r.length;n++){const o=r[n],i=o.properties&&o.properties.property(this.name);i&&i.set(e,Ir(Ir({},t),{propagation:!0,bubble:!1}))}}}};Pr(xr,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let jr=xr;var Er=Object.defineProperty,Ar=Object.getOwnPropertySymbols,Cr=Object.prototype.hasOwnProperty,kr=Object.prototype.propertyIsEnumerable,Mr=(e,t,r)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Sr=(e,t,r)=>Mr(e,"symbol"!=typeof t?t+"":t,r);const Nr=class e{constructor(e,t){this.item=e,Sr(this,"options",{}),Sr(this,"_properties",{}),Sr(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={}))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})({},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}};Sr(Nr,"handlers",{CheckProperty:jr});let Tr=Nr;var Rr=Object.defineProperty,Fr=Object.getOwnPropertySymbols,Br=Object.prototype.hasOwnProperty,$r=Object.prototype.propertyIsEnumerable,qr=(e,t,r)=>t in e?Rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Dr=(e,t,r)=>qr(e,"symbol"!=typeof t?t+"":t,r);let Ur=0;class Vr{constructor(e){Dr(this,"options",{}),Dr(this,"properties"),Dr(this,"tree"),Dr(this,"id",Ur),Ur+=1,this.options=((e,t)=>{for(var r in t||(t={}))Br.call(t,r)&&qr(e,r,t[r]);if(Fr)for(var r of Fr(t))$r.call(t,r)&&qr(e,r,t[r]);return e})({},e),this.tree=new mr(this)}initProperties(){this.properties=new Tr(this,this.options.properties)}}var Gr=Object.defineProperty,zr=Object.defineProperties,Zr=Object.getOwnPropertyDescriptors,Wr=Object.getOwnPropertySymbols,Hr=Object.prototype.hasOwnProperty,Jr=Object.prototype.propertyIsEnumerable,Qr=(e,t,r)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kr=(e,t)=>{for(var r in t||(t={}))Hr.call(t,r)&&Qr(e,r,t[r]);if(Wr)for(var r of Wr(t))Jr.call(t,r)&&Qr(e,r,t[r]);return e},Xr=(e,t)=>zr(e,Zr(t));function Yr(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,o=e.extent_right;if(t&&r&&n&&o){const e=[r,t,o,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function en({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.route("layer.extent",{id:Number(e)}).get({cache:r,signal:n}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}function tn(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then((t=>{if(t)return rn(t,e.connector,e)}))}function rn(e,t,r){if(e.webmap)return Promise.resolve(Yr(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 en(Xr(Kr({},r),{resourceId:e.resource.id,connector:t}))})):en(Xr(Kr({},r),{resourceId:n.id,connector:t}))}}var nn=Object.defineProperty,on=(e,t,r)=>((e,t,r)=>t in e?nn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),sn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class an{constructor(){on(this,"item"),on(this,"connector"),on(this,"_extent")}getExtent(){return sn(this,null,(function*(){return this.getBounds()}))}getBounds(e){return sn(this,null,(function*(){return this._extent?this._extent:this.item?(this._extent=yield rn(this.item,this.connector,e),this._extent):void 0}))}}var ln=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function cn(e,t){return ln(this,null,(function*(){const r=e.resource,n=r;let{keyname:o,resourceId:i}=e;if(r&&("string"==typeof r?o=r:i="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield cn(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i}))}const un={tms:"TILE"};var hn=Object.defineProperty,pn=Object.getOwnPropertySymbols,dn=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable,yn=(e,t,r)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mn=(e,t)=>{for(var r in t||(t={}))dn.call(t,r)&&yn(e,r,t[r]);if(pn)for(var r of pn(t))fn.call(t,r)&&yn(e,r,t[r]);return e},bn=(e,t,r)=>yn(e,"symbol"!=typeof t?t+"":t,r);const gn="https://qms.nextgis.com";function vn(e,t=gn,r={}){let n;if("webMap"in e){const o=e,{webMap:i,url:s}=o,a=((e,t)=>{var r={};for(var n in e)dn.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&pn)for(var n of pn(e))t.indexOf(n)<0&&fn.call(e,n)&&(r[n]=e[n]);return r})(o,["webMap","url"]);n=i,s&&(t=s),a&&(r=a)}else n=e;t||(t=gn);class o{constructor(e,t){bn(this,"qms"),bn(this,"options"),bn(this,"map"),this.map=e;const n=mn(mn({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,i=null,s=function*(){if(!this.qms&&e.qmsId)try{this.qms=yield function(e){return new Promise(((t,r)=>{const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState&&200===n.status&&n.responseText)try{t(JSON.parse(n.responseText))}catch(e){r(e)}},n.open("GET",I(e),!0),n.send()}))}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=un[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(i=o,s=a,["showLayer","hideLayer"].forEach((e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(i.prototype,e,t)})),"TILE"===t)){if(e=mn(mn({order:0,maxZoom:n.options.maxZoom,minZoom:n.options.minZoom},this.options),function(e){const t=("https:"===location.protocol?"https":"http")+"://";let r=e.url.replace(/^(https?|ftp):\/\//,t);return e.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:e.name,attribution:e.copyright_text,maxZoom:e.z_max,minZoom:e.z_min}}(r)),r.origin_url){const[t,n]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,((e,r)=>("string"==typeof r&&r.split(",").forEach((e=>t.push(e))),"{s}"))),t]}(r.origin_url);n.length&&(e.subdomains=n,e.url=t)}return this.options=e,new a(this.map,e).addLayer(e)}}var i,s},new Promise(((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},o=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,o);a((s=s.apply(r,i)).next())}));var r,i,s}}return o}var 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)=>{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},xn=(e,t,r)=>Pn(e,"symbol"!=typeof t?t+"":t,r);class jn{constructor(e){xn(this,"options",{url:"https://qms.nextgis.com"}),xn(this,"url"),this.options=In(In({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return vn({webMap:e,url:this.url})}}xn(jn,"utils",{createQmsAdapter:vn});var En=Object.defineProperty,An=Object.defineProperties,Cn=Object.getOwnPropertyDescriptors,kn=Object.getOwnPropertySymbols,Mn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Tn=Reflect.get,Rn=(e,t,r)=>t in e?En(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fn=(e,t)=>{for(var r in t||(t={}))Sn.call(t,r)&&Rn(e,r,t[r]);if(kn)for(var r of kn(t))Nn.call(t,r)&&Rn(e,r,t[r]);return e},Bn=(e,t)=>An(e,Cn(t)),$n=(e,t,r)=>Tn(Mn(e),r,t),qn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Dn(e){let t;for(t in e){const r=e[t];if(P(r)){const n=r;if(u(n.year)&&u(n.month)&&u(n.day)){const r=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach((e=>{r.push(e)})),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var Un=Object.defineProperty,Vn=Object.defineProperties,Gn=Object.getOwnPropertyDescriptors,zn=Object.getOwnPropertySymbols,Zn=Object.prototype.hasOwnProperty,Wn=Object.prototype.propertyIsEnumerable,Hn=(e,t,r)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Jn=(e,t)=>{for(var r in t||(t={}))Zn.call(t,r)&&Hn(e,r,t[r]);if(zn)for(var r of zn(t))Wn.call(t,r)&&Hn(e,r,t[r]);return e},Qn=(e,t)=>Vn(e,Gn(t)),Kn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Xn(e){return Kn(this,null,(function*(){var t;const r=e.filters;if(r){let n=yield Bt(Qn(Jn({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:Yn(r))&&(n=n.filter((e=>Lt(Dn(Qn(Jn({},e.fields),{id:e.id})),r)))),n}return Ut(e)}))}function Yn(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(Yn(r))return!0}}return!1}var eo=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function to(e){return function(e){return eo(this,null,(function*(){const t=yield Xn(e),r=[];return t.forEach((e=>{r.push(Rt(e))})),r}))}(e).then((e=>({type:"FeatureCollection",features:e})))}const ro=["fields","intersects","limit","orderBy","strategy"];function no(e){const t={};return ro.forEach((r=>{const n=e[r];void 0!==n&&(t[r]=n)})),t}var oo=Object.defineProperty,io=Object.defineProperties,so=Object.getOwnPropertyDescriptors,ao=Object.getOwnPropertySymbols,lo=Object.getPrototypeOf,co=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,ho=Reflect.get,po=(e,t,r)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fo=(e,t)=>{for(var r in t||(t={}))co.call(t,r)&&po(e,r,t[r]);if(ao)for(var r of ao(t))uo.call(t,r)&&po(e,r,t[r]);return e},yo=(e,t)=>io(e,so(t)),mo=(e,t,r)=>po(e,"symbol"!=typeof t?t+"":t,r),bo=(e,t,r)=>ho(lo(e),r,t),go=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function vo(e){return go(this,null,(function*(){var r,n;const{item:o,webMap:i,Adapter:s,connector:a,layerOptions:l,addLayerOptionsPriority:c}=e,u=null==c||c,h=l,p=s||l.Adapter||i.mapAdapter.layerAdapters.GEOJSON,d=[];let f,y,m=!1;const b=yield cn(h,a);(null==(n=null==(r=h.adapterOptions)?void 0:r.popupOptions)?void 0:n.fromProperties)&&(h.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,o));const g=(e,t)=>go(this,null,(function*(){w(),y=new AbortController;const r=y.signal;return(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",y.abort),(t=t||{}).signal=r,f={filters:e,options:t},to(fo({resourceId:b,filters:e,connector:a,cache:!0},t))}));let v=!1;const w=()=>{y&&(y.abort(),y=void 0)};class _ extends p{constructor(){super(...arguments),mo(this,"emitter",new t),mo(this,"__onMapMove"),mo(this,"__onMapMoveStart"),mo(this,"__enableMapMoveListener"),mo(this,"__disableMapMoveListener")}addLayer(e){return go(this,null,(function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==h.id&&(e.id=h.id),o&&o.vector_layer&&(e.type=si[o.vector_layer.geometry_type]),h.adapterOptions&&(e=u?fo(fo({},h.adapterOptions),e):fo(fo({},e),h.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const n=e.strategy||void 0;this.options.strategy=n;const i=bo(_.prototype,this,"addLayer").call(this,e);let s;return f={filters:e.propertiesFilter,options:no(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),n&&n.startsWith("BBOX")&&!m&&this._addBboxEventListener(),i}))}getExtent(){return this.getBounds()}getBounds(){return go(this,null,(function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?tn({connector:a,resourceId:o.resource.id}):bo(_.prototype,this,"getBounds")?bo(_.prototype,this,"getBounds").call(this):void 0}))}beforeRemove(){v=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,w()}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:a,resourceId:b,cache:!0})}updateLayer(e){return go(this,null,(function*(){var t;const r=e||f||{};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(m)return}}if(!v){try{this.emitter.emit("preupdate",r),i._emitLayerEvent("layer:preupdate",h.id||"",r);const e=yield g(r.filters,yo(fo({},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===d.indexOf(String(r.id))&&(d.push(String(r.id)),t.features.push(r));m=void 0!==n&&d.length>=n,yield i.addLayerData(this,t)}else m=void 0!==n&&e.features.length>=n,yield i.setLayerData(this,e);this.emitter.emit("updated",e),i._emitLayerEvent("layer:updated",h.id||"",{data:e,newData:t,isFull:m})}catch(n){if(n instanceof Error&&"AbortError"!==n.name)throw n}bo(_.prototype,this,"updateLayer")&&bo(_.prototype,this,"updateLayer").call(this)}}))}propertiesFilter(e,t){return go(this,null,(function*(){if(w(),this.filter&&m)this.filter((t=>{const r=t.feature&&t.feature.properties&&Dn(fo({},t.feature.properties));return!r||Lt(r,e)}));else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield g(e,yo(fo({},t),{srs:this.options.srs}));this.setData(r)}}))}removeFilter(){f=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(...o){n.clear(),r=setTimeout((()=>{r=null,e.apply(this,o)}),t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}((()=>this.updateLayer())),this.__onMapMoveStart=w,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 _}))}var wo=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function _o({options:e,webMap:t,baseUrl:r}){var n;let o,i=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===i){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const o=t+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:t=>(r&&(t.nd=r),ii(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});i="TILE"}if("WMS"===i){o=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:o,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===i)return o=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:o,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===i)return o=r+`/api/resource/${a}/terrain_provider`,{url:o,adapter:i};if("MODEL_3D"===i)return o=r+`/api/component/model_3d/${a}/data.glb`,{url:o};if("TILE"===i)return o=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:o,adapter:i}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var Oo=Object.defineProperty,Lo=Object.defineProperties,Po=Object.getOwnPropertyDescriptors,Io=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,Eo=(e,t,r)=>t in e?Oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ao=(e,t)=>{for(var r in t||(t={}))xo.call(t,r)&&Eo(e,r,t[r]);if(Io)for(var r of Io(t))jo.call(t,r)&&Eo(e,r,t[r]);return e},Co=(e,t)=>Lo(e,Po(t)),ko=(e,t,r)=>Eo(e,"symbol"!=typeof t?t+"":t,r),Mo=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class So{constructor({layerId:e,legend:t,onSymbolRenderChange:r}){ko(this,"layerId"),ko(this,"legend"),ko(this,"onSymbolRenderChange"),this.layerId=e,this.legend=this.createLegend(t),this.onSymbolRenderChange=r}createLegend(e){return e.map((e=>Co(Ao({},e),{name:e.display_name,symbol:e.icon})))}setSymbolRender(e,t){const r=this.legend.find((t=>t.index===e));if(r){r.render!==t&&(r.render=t,this.onSymbolRenderChange&&this.onSymbolRenderChange(this.legend.filter((e=>e.render)).map((e=>e.index))))}}}function No(e){return Mo(this,arguments,(function*({layerOptions:e,connector:t,webMap:r,item:n}){const o=n.resource.cls;let i=e.adapter||o&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[o]||"IMAGE";if(void 0!==i&&(e.adapter=i),"IMAGE"===i){const e=r.getLayerAdapters();!e||e.IMAGE||(i="TILE")}const s=r.mapAdapter.layerAdapters[i];if(s){const o=yield cn(e,t);return class extends s{constructor(i,s){super(i,s),this.map=i,ko(this,"item",n),ko(this,"resourceId",o),ko(this,"_blocked",!1),ko(this,"_layerVisibility");const a=_o({options:e,webMap:r,baseUrl:t.options.baseUrl||""});if(a){const t=Co(Ao(Ao({},a),e.adapterOptions),{params:{resource:o},layers:a.layers||String(o),resourceId:o});e.adapterOptions&&u(e.adapterOptions.setViewDelay)&&(t.setViewDelay=e.adapterOptions.setViewDelay),this.options=Ao(Ao({},this.options),t)}}addLayer(e){return super.addLayer(Ao(Ao({},this.options),e))}showLayer(){this._layerVisibility=!0,this.layer&&(this._blocked||r.mapAdapter.showLayer(this.layer))}hideLayer(){this._layerVisibility=!1,this.layer&&r.mapAdapter.hideLayer(this.layer)}getIdentificationIds(){return Mo(this,null,(function*(){if(this.item){if("MVT"===i)return[this.item.resource.id];if(this.item.resource.parent){const e=this.item.resource.parent.id;if(u(e))return[e]}}return[]}))}getLegend(e){return Mo(this,null,(function*(){const r=this.options.id;if(void 0!==r){const n=yield t.route("render.legend_symbols",{id:o}).get(Ao({cache:!0},e));return[new So({layerId:r,legend:n,onSymbolRenderChange:this._setLegendSymbol.bind(this)})]}return[]}))}_hideLayer(){this.options.id&&r.mapAdapter.hideLayer(this.layer)}_showLayer(){this.options.id&&this._layerVisibility&&r.showLayer(this.options.id,{silent:!0})}_setLegendSymbol(e){const t=this._consolidateIntervals(e);t.length?(this._blocked=!1,this._showLayer()):(this._hideLayer(),this._blocked=!0),this.updateLayer&&this.updateLayer({params:{[`symbols[${o}]`]:t.join(",")||void 0}})}_consolidateIntervals(e){const t=e.slice().sort(((e,t)=>e-t)),r=[];let n=t[0],o=n;for(let i=1;i<=t.length;i++)t[i]===o+1?o=t[i]:(r.push(n===o?`${n}`:`${n}-${o}`),n=t[i],o=n);return r}}}throw new Error(i+" not supported yet. Only TILE")}))}var To=Object.defineProperty,Ro=Object.defineProperties,Fo=Object.getOwnPropertyDescriptors,Bo=Object.getOwnPropertySymbols,$o=Object.prototype.hasOwnProperty,qo=Object.prototype.propertyIsEnumerable,Do=(e,t,r)=>t in e?To(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Uo=(e,t)=>{for(var r in t||(t={}))$o.call(t,r)&&Do(e,r,t[r]);if(Bo)for(var r of Bo(t))qo.call(t,r)&&Do(e,r,t[r]);return e},Vo=(e,t)=>Ro(e,Fo(t)),Go=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const zo={},Zo=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Wo(e){return Go(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const o=n.resource.id,i=yield r.getResourceChildren(o),s=i&&i[0];if(s)return Ho(Vo(Uo({},e),{resource:s.resource.id}),t,r)}))}function Ho(e,t,r){return Go(this,null,(function*(){let n,o;const i=e.adapter,s=yield cn(e,r);if(s){const a=e.resource;if(o=a&&a.resource&&void 0!==a.resource.id?a:yield r.getResource(s),!o)throw"Resource item is not found";{const a=o.resource.cls,l={layerOptions:Vo(Uo({},e),{resource:s}),connector:r,webMap:t,item:o};if(-1!==Zo.indexOf(a))if("webmap"===a)n=function(e){return wo(this,arguments,(function*({layerOptions:e,webMap:t,connector:r}){const n=yield cn(e,r);return class extends Di{constructor(e){super(e,{url:"",webMap:t,resourceId:n,connector:r})}}}))}(l);else if("vector_layer"===a||"postgis_layer"===a){const t=l.layerOptions.adapterOptions||{};if(t.type=t.type||o.vector_layer&&si[o.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==i&&"GEOJSON"!==i){if("MVT"!==i)return Wo(l);n=No(l)}else n=vo(l)}else{if("raster_layer"===a)return Wo(l);if("basemap_layer"===a)n=function(e){return qn(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(jn.utils.createQmsAdapter(e,void 0,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return qn(this,null,(function*(){if(n)return $n(e.prototype,this,"addLayer").call(this,Bn(Fn({},t),{url:n}))}))}}return e}}}}))}(l);else if("GEOJSON"===i&&o.resource.parent){const t=yield r.getResource(o.resource.parent.id);if(t){const r=Vo(Uo({},e),{resource:o.resource.parent.id});n=vo(Vo(Uo({},l),{item:t,layerOptions:r}))}}else n=No(l)}else{if(!zo[a])throw`Resource class '${a}' not yet supported.`;{const e=zo[a];let t;t=i&&"function"!=typeof t?e[i]:e,t&&(n=t(l))}}}}if(n)return n.then((e=>{if(e){const t=e;return o&&(t.prototype.item=o,t.prototype.resourceId=o.resource.id,t.prototype.connector=r),c(t,[an],{replace:!1}),t}}))}))}var Jo=Object.defineProperty,Qo=Object.defineProperties,Ko=Object.getOwnPropertyDescriptors,Xo=Object.getOwnPropertySymbols,Yo=Object.prototype.hasOwnProperty,ei=Object.prototype.propertyIsEnumerable,ti=(e,t,r)=>t in e?Jo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ri=(e,t)=>{for(var r in t||(t={}))Yo.call(t,r)&&ti(e,r,t[r]);if(Xo)for(var r of Xo(t))ei.call(t,r)&&ti(e,r,t[r]);return e},ni=(e,t)=>Qo(e,Ko(t)),oi=(e,t)=>{var r={};for(var n in e)Yo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Xo)for(var n of Xo(e))t.indexOf(n)<0&&ei.call(e,n)&&(r[n]=e[n]);return r};function ii(e,t){const r=e,{bbox:n,width:o,height:i,nd:s}=r,a=oi(r,["bbox","width","height","nd"]);return ni(ri({},a),{resource:Array.isArray(t)?t.join(","):t,extent:n,size:o+","+i,timestamp:Date.now(),nd:null!=s?s:200})}const si={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 ai;function li(e,t=0){const r=t,n=function(){if(void 0===ai){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),ai=t}return ai}()*function(e){return 12756274*Math.PI*Math.cos(e*Math.PI/180)}(r)/e,o=function(e){return Math.log(e/256)/Math.LN2}(n);return o}var ci=Object.defineProperty,ui=Object.defineProperties,hi=Object.getOwnPropertyDescriptors,pi=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(pi)for(var r of pi(t))fi.call(t,r)&&yi(e,r,t[r]);return e},bi=(e,t)=>ui(e,hi(t)),gi=(e,t,r)=>yi(e,"symbol"!=typeof t?t+"":t,r),vi=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const wi=class e extends Vr{constructor(r,n,o,i,s,a){if(super(mi(mi({},e.options),o)),this.webMap=r,gi(this,"item"),gi(this,"connector"),gi(this,"layer"),gi(this,"emitter",new t),gi(this,"_rootDescendantsCount",0),i&&(this.connector=i),s&&this.tree.setParent(s),this.item=n,"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(),a||this._init(n)}static create(t,r,n,o,i){return vi(this,null,(function*(){const s=new e(t,r,n,o,i,!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 vi(this,null,(function*(){var t;const r=null==(t=this.layer)?void 0:t.id;if(void 0!==r){const t=this.connector;if(t&&"resourceId"in this.item){return[{layerId:r,legend:(yield t.route("render.legend_symbols",{id:Number(this.item.resourceId)}).get(mi({},e))).map((e=>mi({name:e.display_name,symbol:e.icon},e)))}]}}return[]}))}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=bi(mi({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,bi(mi({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 li(e)}initGroupItem(e){if(e.children&&e.children.length){const t=this.getChildren(e);for(const e of t){const t=new this.constructor(this.webMap,e,this.options,this.connector,this);this.tree.addChild(t)}}return Promise.resolve()}initLayerItem(t){const r=this.getItemOptions(t),n=e=>{t._layer=e,this.layer=e;this.properties.get("visibility")&&this.properties.set("visibility",!0),null!=r.opacity&&this.webMap.setLayerOpacity(e,r.opacity)};let o;if("layer"===t.item_type)o=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){o=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return o?this.webMap.addLayer(o,r).then((e=>{n(e)})):t._layer?Promise.resolve(n(t._layer)):Promise.reject("No layer added")}_getZoomRange(e){const t=this.options.minZoom,r=this.options.maxZoom,n=e.layer_min_scale_denom?this._mapScaleToZoomLevel(e.layer_min_scale_denom):void 0,o=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,i=[t,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max(...i):void 0,maxZoom:s.length?Math.min(...s):void 0}}_init(e){this.initItem(e).then((()=>{this.emitter.emit("init")}))}_sumUp(e,t=0){for(const r of e)"layer"===r.item_type?(t+=1,r.draw_order_position=r.draw_order_position||t):"group"===r.item_type&&(t=this._sumUp(r.children,t));return t}};gi(wi,"GetAdapterFromLayerType",{}),gi(wi,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return ar(e.item,(e=>"layer_enabled"in e&&e.layer_enabled),(e=>e.children));if("layer"===e.item.item_type)return e.item.layer_enabled}return!1},onSet(e,t,r){r&&"layer"===r.item.item_type&&(r.layer&&(e?r.webMap.showLayer(r.layer):r.webMap.hideLayer(r.layer)),r.item.layer_enabled=e)}},{name:"opacity",handler:class extends vr{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 _i=wi;var Oi=Object.defineProperty,Li=Object.getOwnPropertySymbols,Pi=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable,xi=(e,t,r)=>t in e?Oi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ji=(e,t)=>{for(var r in t||(t={}))Pi.call(t,r)&&xi(e,r,t[r]);if(Li)for(var r of Li(t))Ii.call(t,r)&&xi(e,r,t[r]);return e},Ei=(e,t,r)=>xi(e,"symbol"!=typeof t?t+"":t,r),Ai=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Ci(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){const i=function(e){return Ai(this,arguments,(function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){Ei(this,"options",{}),Ei(this,"layer",[]),Ei(this,"_removed",!1),Ei(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 Ai(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 Ai(this,null,(function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)}))}loadLayer(){return Ai(this,null,(function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const o=yield n(this);if(o){const n=new o(e.mapAdapter.map,ji({},t)),i=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=i,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer}))}}}))}({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>Ho({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)});return i},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var ki=Object.defineProperty,Mi=Object.defineProperties,Si=Object.getOwnPropertyDescriptors,Ni=Object.getOwnPropertySymbols,Ti=Object.prototype.hasOwnProperty,Ri=Object.prototype.propertyIsEnumerable,Fi=(e,t,r)=>t in e?ki(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bi=(e,t)=>{for(var r in t||(t={}))Ti.call(t,r)&&Fi(e,r,t[r]);if(Ni)for(var r of Ni(t))Ri.call(t,r)&&Fi(e,r,t[r]);return e},$i=(e,t,r)=>Fi(e,"symbol"!=typeof t?t+"":t,r),qi=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Di{constructor(e,r){this.map=e,this.options=r,$i(this,"layer"),$i(this,"NgwWebmapItem",_i),$i(this,"pixelRadius",10),$i(this,"resourceId"),$i(this,"webmapClassName","webmap"),$i(this,"emitter",new t),$i(this,"_extent"),$i(this,"webmapResource"),$i(this,"_webmapBaselayersIds",[]),$i(this,"_lastActiveBaselayer");const n=r.resourceId;if(Array.isArray(n)?(this.resourceId=n[0],this.options.id=n[1]):this.resourceId=n,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}addLayer(e){return qi(this,null,(function*(){var t;this.options=Bi(Bi({},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 qi(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)}))}hideLayer(){return qi(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)}))}setOpacity(e){return qi(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 Yr(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.webmapResource;if(e&&e.bookmark_resource)return e.bookmark_resource.id}fetchBookmarks(e){const t=this.getBookmarksResourceId(),r=this.options.connector;if(t)return r.getResourceOrFail(t,e).then((n=>{var o;const i=null==(o=n.feature_layer)?void 0:o.fields.find((e=>e.label_field)),s=i&&i.keyname;return Xn(Bi({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then((e=>{const n=[];for(const o of e){const e=new sr({item:o,resourceId:t,labelField:s,connector:r});n.push(e)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(e){return qi(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 qi(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 qi(this,null,(function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise((t=>{var r;const n=this.options.connector,o=(null==n?void 0:n.options.auth)?n.getAuthorizationHeaders():void 0,i=n.withCredentials,s=(a=Bi({},this.options),l={withCredentials:i,headers:o,drawOrderEnabled:null!=(r=e.draw_order_enabled)&&r},Mi(a,Si(l)));var a,l;const c=new this.NgwWebmapItem(this.options.webMap,e.root_item,s,n);c.emitter.on("init",(()=>{t(c)}))})):void 0}))}getWebMapConfig(e){return qi(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)Ci({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then((e=>{const o=!r&&n.enabled;return n.enabled&&(r=!0),t.addBaseLayer(e,{id:"webmap-baselayer"+n.resource_id,name:n.display_name,opacity:n.opacity,visibility:o}).then((e=>{e.id&&this._webmapBaselayersIds.push(e.id)}))}))}_updateItemsParams(e,t,r){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=I(this.options.connector.options.baseUrl+"/api/component/render/image"),o=r.layer_style_id;r.url=n,r.resourceId=o,r.updateWmsParams=e=>ii(e,o);const i=_o({options:{adapter:r.layer_adapter.toUpperCase(),resource:o},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=Bi(Bi({},r),i)}return e}}var Ui=Object.defineProperty,Vi=Object.getOwnPropertySymbols,Gi=Object.prototype.hasOwnProperty,zi=Object.prototype.propertyIsEnumerable,Zi=(e,t,r)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wi=(e,t)=>{for(var r in t||(t={}))Gi.call(t,r)&&Zi(e,r,t[r]);if(Vi)for(var r of Vi(t))zi.call(t,r)&&Zi(e,r,t[r]);return e},Hi=(e,t,r)=>Zi(e,"symbol"!=typeof t?t+"":t,r);class Ji{constructor(e){if(this.options=e,Hi(this,"url"),Hi(this,"connector"),Hi(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 dt({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){zo[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(Di,Wi({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}getLayerAdapters(){return Promise.resolve([this._getLayerAdapter()])}_getLayerAdapter(){return{name:"WEBMAP",createAdapter:e=>Promise.resolve(this._createAdapter(e))}}_createAdapter(e){return t={webMap:e,connector:this.connector,baseUrl:this.url},class extends Di{constructor(e,r){super(e,r=ri(ri({},t),r))}};var t}}var Qi=Object.defineProperty,Ki=Object.getOwnPropertySymbols,Xi=Object.prototype.hasOwnProperty,Yi=Object.prototype.propertyIsEnumerable,es=(e,t,r)=>t in e?Qi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ts=(e,t)=>{for(var r in t||(t={}))Xi.call(t,r)&&es(e,r,t[r]);if(Ki)for(var r of Ki(t))Yi.call(t,r)&&es(e,r,t[r]);return e},rs=(e,t,r)=>es(e,"symbol"!=typeof t?t+"":t,r);class ns{constructor(e){rs(this,"id"),rs(this,"label"),rs(this,"layerId"),rs(this,"parent"),rs(this,"fields"),rs(this,"geom"),rs(this,"extensions"),rs(this,"connector"),rs(this,"_item"),rs(this,"_geojson"),rs(this,"_resource"),rs(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):Yt(ts({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 t=this,r=null,n=function*(){if(this._resource&&this._resource.feature_layer)return this._resource.feature_layer;const t=yield this.connector.getResource(this.layerId,e);if(!(null==t?void 0:t.feature_layer))throw new Error("Resource is not avector layer");return this._resource=t,t.feature_layer},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}getBounds(e){return this._extent?Promise.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0,signal:o}){return r.route("feature_layer.feature.item_extent",{id:Number(e),fid:t}).get({cache:n,signal:o}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}(ts({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)))))}}var os=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function is(e){return os(this,null,(function*(){return Rt(yield Yt(e))}))}var ss=Object.defineProperty,as=Object.defineProperties,ls=Object.getOwnPropertyDescriptors,cs=Object.getOwnPropertySymbols,us=Object.prototype.hasOwnProperty,hs=Object.prototype.propertyIsEnumerable,ps=(e,t,r)=>t in e?ss(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)&&ps(e,r,t[r]);if(cs)for(var r of cs(t))hs.call(t,r)&&ps(e,r,t[r]);return e},fs=(e,t)=>as(e,ls(t));function ys(e,t=!1){const r=[],n=[];for(const i in e){const e=Number(i);isNaN(e)||r.push(e)}const o=e.resources;o&&r.sort(((e,t)=>o.indexOf(e)-o.indexOf(t)));for(let i=0;i<r.length;i++){const o=r[i],s=e[o];if("features"in s){const e=ms(s.features,Number(o),t);if(e.length&&(n.push(...e),!t))break}}return n}function ms(e,t,r){const n=[];for(const o of e){if(n.push({featureId:o.id,resourceId:t,feature:o}),!r)break}return n}function bs(e){const{geom:t,signal:r,cache:n,layers:o}=e,i="string"==typeof t?t:function(e){const t=function(e){var t;if(Array.isArray(e))return e;if("Feature"===e.type)return null==(t=e.geometry)?void 0:t.coordinates[0];if("Polygon"===e.type)return e.coordinates[0];return null}(e);if(!t)return null;return`POLYGON((${t.map((([e,t])=>{const[r,n]=w(e,t);return`${r} ${n}`})).join(",")}))`}(t);if(!i)throw new Error("Not valid geometry format to make intersection");const s={geom:i,srs:3857,layers:o};return e.connector.route("feature_layer.identify").post({json:s,signal:r,cache:n})}function gs(e,t){return r=this,n=null,o=function*(){var r,n;const o=yield e.route("pyramid.settings").get({query:{component:"pyramid"}});if(o&&o.company_logo&&o.company_logo.enabled){const s=document.createElement("a");s.style.position="absolute",s.style.bottom="0",s.style.right="0",s.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",s.className="ngw-map-logo",t&&t.cssClass&&(s.className+=" "+t.cssClass);const a=new Image;a.style.maxHeight="100px",a.style.maxWidth="100px",a.src="";try{const t=null==(n=(yield e.route("pyramid.csettings").get()).pyramid)?void 0:n.header_logo;if(t){const[e,r]=t,n=atob(r),o=new Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);const i=new Uint8Array(o),s=new Blob([i],{type:e}),l=(window.URL||window.webkitURL).createObjectURL(s);a.src=l}}catch(i){console.warn(i)}return null!==o.company_logo.link&&""!==o.company_logo.link.trim()&&(s.href=o.company_logo.link,s.target="_blank",-1!==o.company_logo.link.search(/:\/\/nextgis/)&&(a.alt="Get your own Web GIS at nextgis.com")),s.appendChild(a),s}},new Promise(((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())}));var r,n,o}function vs(e){return"function"==typeof e}function ws(e){return(t,r)=>{const n=t.map((e=>e()));return e(n,r)}}const _s={"!":ws((function([e]){return!e})),"!=":ws((function([e,t]){return e!==t})),"<":ws((function([e,t]){return e<t})),"<=":ws((function([e,t]){return e<=t})),"==":ws((function([e,t]){return e===t})),">":ws((function([e,t]){return e>t})),">=":ws((function([e,t]){return e>=t})),coalesce:e=>{for(let t=0;t<e.length;t++){const r=e[t]();if(null!=r)return r}return null},all:e=>{for(let t=0;t<e.length;t++){if(!e[t]())return!1}return!0},any:e=>{for(let t=0;t<e.length;t++){if(e[t]())return!0}return!1},case:e=>{if(e.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(e.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(let t=0;t<e.length-1;t+=2){const r=e[t](),n=e[t+1]();if(r)return n}return(0,e[e.length-1])()},match:e=>{const[t,...r]=e,n=t(),o=r.splice(-1,r.length%2)[0];for(let i=0;i<r.length-1;i+=2){if(r[i]()===n)return r[i+1]()}return o()}},Os={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 Ls(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Ps(e);if("string"==typeof(t=e)&&t in Os)return function(e){return Ps(Os[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 Ps(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 Is(e,t,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(e-t)/(n-t)*(o-r);try{const i=Ls(r),s=Ls(o);return function(e){return`rgb(${e.join(",")})`}(i.map(((r,o)=>Math.ceil(Is(e,t,r,n,s[o])))))}catch(i){console.log(i)}throw new Error("Unsupported output type for linear interpolation.")}const xs={step:e=>{const[t,r,...n]=e,o=t();if("number"!=typeof o)return r();for(let i=0;i<n.length-2;i+=2){const e=n[i](),t=n[i+1](),r=n[i+2]();if(o>=e&&o<r)return t}return o>=n[n.length-2]()?n[n.length-1]():r()},interpolate:([e,t,...r])=>{if(r.length<2)throw new Error("At least two stops are required");if(r.length<2||r.length%2!=0)throw new Error("Invalid stops provided.");const n=t();if("number"!=typeof n)throw new Error("Input must be a number.");const o=e();for(let i=0;i<r.length-2;i+=2){const e=r[i](),t=r[i+1](),s=r[i+2](),a=r[i+3]();if(n>=e&&n<=s&&"linear"===o[0])return Is(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const js={get:ws((function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null})),length:ws((([e])=>{if("string"==typeof e||Array.isArray(e))return e.length})),at:ws((function([e,t]){return t[e]})),has:ws((function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))})),in:ws((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":ws((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:ws((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}.`)}))},Es={"+":ws((e=>e.reduce(((e,t)=>e+t),0))),"-":ws((e=>e.reduce(((e,t)=>e-t)))),"*":ws((e=>e.reduce(((e,t)=>e*t),1))),"/":ws((e=>e.reduce(((e,t)=>e/t)))),"%":ws((e=>e[0]%e[1])),"^":ws((e=>Math.pow(e[0],e[1]))),abs:ws((e=>Math.abs(e[0]))),acos:ws((e=>Math.acos(e[0]))),asin:ws((e=>Math.asin(e[0]))),atan:ws((e=>Math.atan(e[0]))),ceil:ws((e=>Math.ceil(e[0]))),cos:ws((e=>Math.cos(e[0]))),e:()=>Math.E,floor:ws((e=>Math.floor(e[0]))),ln:ws((e=>Math.log(e[0]))),ln2:()=>Math.LN2,log10:ws((e=>Math.log10(e[0]))),log2:ws((e=>Math.log2(e[0]))),max:ws((e=>Math.max(...e))),min:ws((e=>Math.min(...e))),pi:()=>Math.PI,round:ws((e=>Math.round(e[0]))),sin:ws((e=>Math.sin(e[0]))),sqrt:ws((e=>Math.sqrt(e[0]))),tan:ws((e=>Math.tan(e[0])))},As={concat:ws((e=>e.reduce(((e,t)=>String(e)+String(t)),""))),downcase:ws((e=>String(e[0]).toLowerCase())),upcase:ws((e=>String(e[0]).toUpperCase()))},Cs=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function ks(e){return(t,r)=>{for(const n of t){const t=Cs(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Ms={array:ws((e=>{const[t,r,n]=e;let o,i,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(o=t,"number"==typeof r?(i=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(o&&!s.every((e=>typeof e===o)))throw new Error(`Expected all items in array to be of type ${o}`);if(i&&s.length!==i)throw new Error(`Expected array of length ${i}`);return s})),boolean:ws(ks((e=>"boolean"==typeof e?e:void 0))),literal:ws((([e])=>e)),number:ws(ks((e=>"number"==typeof e?e:void 0))),object:ws(ks((e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e))),string:ws(ks((e=>"string"==typeof e?e:void 0))),"to-boolean":ws(ks(Boolean)),"to-number":ws(ks(Number)),"to-string":ws(ks(String)),typeof:ws((([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 Ss=Object.defineProperty,Ns=Object.getOwnPropertySymbols,Ts=Object.prototype.hasOwnProperty,Rs=Object.prototype.propertyIsEnumerable,Fs=(e,t,r)=>t in e?Ss(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bs=(e,t)=>{for(var r in t||(t={}))Ts.call(t,r)&&Fs(e,r,t[r]);if(Ns)for(var r of Ns(t))Rs.call(t,r)&&Fs(e,r,t[r]);return e};function $s(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in qs&&r.length>0}return!1}const qs=Bs(Bs(Bs(Bs(Bs(Bs({},Es),Ms),As),js),_s),xs);function Ds(e,t={}){const[r,...n]=e,o=qs[r];if(o)return o(n.map((e=>()=>$s(e)?Ds(e,t):e)),t);throw new Error(`Expression "${r}" is not supported.`)}var Us=Object.defineProperty,Vs=Object.getOwnPropertySymbols,Gs=Object.prototype.hasOwnProperty,zs=Object.prototype.propertyIsEnumerable,Zs=(e,t,r)=>t in e?Us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ws=(e,t)=>{for(var r in t||(t={}))Gs.call(t,r)&&Zs(e,r,t[r]);if(Vs)for(var r of Vs(t))zs.call(t,r)&&Zs(e,r,t[r]);return e};function Hs(e){return t=>{const r=t.properties;return!!r&&Ds(e,r)}}const Js=["iconSize","iconAnchor"];var Qs=Object.defineProperty,Ks=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,ea=(e,t,r)=>t in e?Qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ta=(e,t)=>{for(var r in t||(t={}))Xs.call(t,r)&&ea(e,r,t[r]);if(Ks)for(var r of Ks(t))Ys.call(t,r)&&ea(e,r,t[r]);return e};function ra(e){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=>function(e,t){const r=vt({},e.properties);return!!r&&(r.$id=e.id,Lt(r,t))}(e,t[0])));return n?ta(ta({},t),n[1]):t}}function na({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===Js.indexOf(n)){const o=n,i=e[o];$s(i)&&(t=!0,r[o]=Hs(i))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return Ws(Ws({},e),n)}}(e);if(r){const n=e=>ia({paint:r(e),defaultPaint:t});return n.paint=oa({paint:e,defaultPaint:t}),n}return oa({paint:e,defaultPaint:t})}function oa({paint:e,defaultPaint:t}){var r;let n=ta({},t);return n=ta(ta({},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 ia({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=ta({},t);if(vs(e)){const n=n=>{const o=ia({paint:e(n),defaultPaint:t,getPaintFunctions:r});return o.type=e.type,o};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>ia({paint:ra(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const o=function(e,t){if("function"==typeof e.from)return e.from(e.options);if("string"==typeof e.from&&t){const r=t[e.from];if(r)return r(e.options)}}(e,r);o&&(n=ia({paint:o,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=na({paint:e,defaultPaint:t})}return vs(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 sa=Object.defineProperty,aa=(e,t,r)=>((e,t,r)=>t in e?sa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class la{constructor(){aa(this,"backspace",8),aa(this,"tab",9),aa(this,"enter",13),aa(this,"shift",16),aa(this,"ctrl",17),aa(this,"alt",18),aa(this,"pause/break",19),aa(this,"caps_lock",20),aa(this,"escape",27),aa(this,"page_up",33),aa(this,"page_down",34),aa(this,"end",35),aa(this,"home",36),aa(this,"left_arrow",37),aa(this,"up_arrow",38),aa(this,"right_arrow",39),aa(this,"down_arrow",40),aa(this,"insert",45),aa(this,"delete",46),aa(this,"left_window_key",91),aa(this,"right_window_key",92),aa(this,"select_key",93),aa(this,"numpad_0",96),aa(this,"numpad_1",97),aa(this,"numpad_2",98),aa(this,"numpad_3",99),aa(this,"numpad_4",100),aa(this,"numpad_5",101),aa(this,"numpad_6",102),aa(this,"numpad_7",103),aa(this,"numpad_8",104),aa(this,"numpad_9",105),aa(this,"multiply",106),aa(this,"add",107),aa(this,"subtract",109),aa(this,"decimal_point",110),aa(this,"divide",111),aa(this,"f1",112),aa(this,"f2",113),aa(this,"f3",114),aa(this,"f4",115),aa(this,"f5",116),aa(this,"f6",117),aa(this,"f7",118),aa(this,"f8",119),aa(this,"f9",120),aa(this,"f10",121),aa(this,"f11",122),aa(this,"f12",123),aa(this,"num_lock",144),aa(this,"scroll_lock",145),aa(this,"semi-colon",186),aa(this,"equal_sign",187),aa(this,",",188),aa(this,"-",189),aa(this,".",190),aa(this,"/",191),aa(this,"`",192),aa(this,"[",219),aa(this,"\\",220),aa(this,"]",221),aa(this,"'",222)}}var ca=Object.defineProperty,ua=(e,t,r)=>((e,t,r)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var ha=Object.defineProperty,pa=(e,t,r)=>((e,t,r)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class da{constructor(e,t){this.webMap=e,pa(this,"name"),pa(this,"event"),pa(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 fa=Object.defineProperty,ya=(e,t,r)=>((e,t,r)=>t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ma extends da{constructor(){super(...arguments),ya(this,"name","bounds"),ya(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 ba=Object.defineProperty,ga=(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 va extends da{constructor(){super(...arguments),ga(this,"name","center"),ga(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 wa=Object.defineProperty,_a=(e,t,r)=>((e,t,r)=>t in e?wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Oa extends da{constructor(){super(...arguments),_a(this,"name","zoom"),_a(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 La=Object.defineProperty,Pa=(e,t,r)=>((e,t,r)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Ia=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let xa=0;const ja={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},Ea=class e{constructor(r){Pa(this,"options",ja),Pa(this,"emitter",new t),Pa(this,"keys",e.keys),Pa(this,"mapAdapter"),Pa(this,"runtimeParams",[]),Pa(this,"getPaintFunctions",e.getPaintFunctions),Pa(this,"mapStateItems",[va,Oa,ma]),Pa(this,"id",xa++),Pa(this,"mapState",[]),Pa(this,"_initMapState",{}),Pa(this,"_starterKits"),Pa(this,"_extent"),Pa(this,"_eventsStatus",{}),Pa(this,"_coordFromMapClickAbort"),Pa(this,"_mapEvents",{}),this.mapAdapter=r.mapAdapter,this._starterKits=r.starterKits||[],r&&(this.options=p(ja||{},r)),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 Ia(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:y(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&&u(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),u(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return function(e){const[t,r,n,o]=e,i=t<n&&r<o;if(!i){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${o}]`);const e=[Math.min(t,n),Math.min(r,o),Math.max(t,n),Math.max(o,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&o<=90;s&&a||console.log("Warning: The coordinates may not be within valid geographic ranges.")}(e),e.every((e=>u(e)))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,t)),this}getEventStatus(e){const t=this._eventsStatus[e];return null!=t&&t}onLoad(e="create"){return new Promise((t=>{this.getEventStatus(e)?t(this):this.emitter.once(e,(()=>{t(this)}))}))}onMapLoad(e){return new Promise((t=>{var r;const n=()=>{const r=this.mapAdapter;e&&e(r),r&&t(r)},o=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&o?n():this.mapAdapter.emitter.once("create",(()=>{n()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(e){return this.mapAdapter.layerAdapters[e]}locate(e,t){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(e,t);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickAbort&&(this._coordFromMapClickAbort(),this._coordFromMapClickAbort=void 0)}getCoordFromMapClick(){return this._coordFromMapClickAbort?this.getCoordFromMapClick():new Promise(((e,t)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const n=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickAbort=void 0},o=t=>{n(),d(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),this._coordFromMapClickAbort=n}))}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return Ia(this,null,(function*(){}))}_onLoadSync(){return Ia(this,null,(function*(){}))}_setupMap(){return Ia(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),u(e.maxzoom)&&(this.options.zoom=e.maxzoom),u(e.minzoom)&&(this.options.zoom=e.minzoom),u(e.maxzoom)&&u(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)}))}};Pa(Ea,"keys",new class{constructor(){ua(this,"keyCodeAlias",new la),ua(this,"keys",{}),ua(this,"_windowOnFocus"),ua(this,"_keysPressed"),ua(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={}}}),Pa(Ea,"getPaintFunctions");let Aa=Ea;function Ca(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 ka(e){let t;if("FeatureCollection"===e.type){t=Ca(e.features.map((e=>e.geometry.type)))}else if("GeometryCollection"===e.type){t=Ca(e.geometries.map((e=>e.type)))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const Ma={polygon:"path",line:"path",point:"circle"},Sa={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Na(e){if(e.data){const t=Sa[ka(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":Ma[t]),e.type=e.type||t}return e}var Ta=Object.defineProperty,Ra=Object.defineProperties,Fa=Object.getOwnPropertyDescriptors,Ba=Object.getOwnPropertySymbols,$a=Object.prototype.hasOwnProperty,qa=Object.prototype.propertyIsEnumerable,Da=(e,t,r)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ua=(e,t)=>{for(var r in t||(t={}))$a.call(t,r)&&Da(e,r,t[r]);if(Ba)for(var r of Ba(t))qa.call(t,r)&&Da(e,r,t[r]);return e},Va=(e,t)=>Ra(e,Fa(t)),Ga=(e,t,r)=>Da(e,"symbol"!=typeof t?t+"":t,r),za=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Za extends Aa{constructor(e){super(e),Ga(this,"_layersIdCounter",1),Ga(this,"_layersOrderCounter",1),Ga(this,"_baselayers",[]),Ga(this,"_layers",{}),Ga(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(t)))}fitLayer(e,t){return za(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 za(this,null,(function*(){return yield this.addLayer(e,Va(Ua({},t),{baselayer:!0}),void 0)}))}addLayer(e){return za(this,arguments,(function*(e,t={},r){var n,o;const i=this._layersIdCounter++,s=u(r)?r:void 0!==t.order?t.order:this.reserveOrder();let a;"string"==typeof e?a=this.getLayerAdapter(e):"function"==typeof e?a=e:"then"in e&&(a=yield e);const l=t;this._updateGeoJsonOptions(l);const c=null==(n=(t=Ua({id:String(i),order:s},t)).visibility)||n;if(t.visibility=!1,t.baselayer&&(t.order=0),this.options.onBeforeAddLayer){const e=this.options.onBeforeAddLayer({options:t,adapter:a});e&&(e.options&&(t=e.options),e.adapter&&(a=e.adapter))}if(void 0!==a){const e=new a(this.mapAdapter.map,t);let r;e.options=Ua(Ua({},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(i),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(o=e.options.order)?o:s,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,l.filter&&this.filterLayer(e,l.filter),t.baselayer&&this._baselayers.push(r),c&&(yield this.showLayer(r)));const u=t.opacity;null!=u&&u<=1&&this.setLayerOpacity(e,u);const h=n&&(e.getBounds||e.getExtent);if(t.fit&&h){const t=yield h.call(e);t&&(yield this.fitBounds(t))}return t.onAdded&&t.onAdded(e),this._emitLayerEvent("layer:add",r,e),e}return Promise.reject("No adapter")}))}addLayerFromAsyncAdapter(e,t,r){return za(this,null,(function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),o=e(),i=yield o;return i?this.addLayer(i,t,n):Promise.reject("No adapter")}))}removeLayers(e){for(const t in this._layers){let r=!0;e&&(r=e(t,this._layers[t])),r&&(this.removeLayer(t),delete this._layers[t])}}getLegend(e){return za(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=Na(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",Va(Ua({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",Va(Ua({},t),{url:r}))}showLayer(e,t={}){return this.toggleLayer(e,!0,t)}hideLayer(e,t={}){return this.toggleLayer(e,!1,t)}toggleLayer(e,t,r={}){const n=this.getLayer(e),o=void 0!==t?t:!(n&&n.options.visibility),i=void 0!==r.silent&&r.silent,s=e=>za(this,null,(function*(){const t=String(e.id),r=o?"layer:show":"layer:hide";if(i||(this._emitLayerEvent(o?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),o&&this.mapAdapter){const t=e.options.baselayer?0:e.options.order;if(e.options.baselayer&&this._baselayers.length){const t=this._baselayers.filter((t=>t!==e.id&&this.isLayerVisible(t)));for(const e of t)yield this.hideLayer(e)}e.showLayer?yield e.showLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.showLayer(e.layer)),void 0!==t&&this.mapAdapter.setLayerOrder(e.layer,t,this._layers)}else e.hideLayer?yield e.hideLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.hideLayer(e.layer));e.options.visibility=o,i||(this._emitLayerEvent(r,t,e),this._emitLayerEvent("layer:toggle",t,e))}));return n?this.onMapLoad().then((()=>s(n))):Promise.resolve()}updateLayer(e,t){const r=this.getLayer(e);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer(t));if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((()=>this.showLayer(r,{silent:!0})))}return Promise.resolve()}setLayerOpacity(e,t){const r=this.getLayer(e);r&&(r.setOpacity?r.setOpacity(t):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,t))}isLayerLabelVisible(e){var t;const r=this.getLayer(e);return r.isLabelVisible?r.isLabelVisible():null==(t=r.options.labelVisibility)||t}showLayerLabel(e){this.toggleLayerLabel(e,!0)}hideLayerLabel(e){this.toggleLayerLabel(e,!1)}toggleLayerLabel(e,t){const r=this.getLayer(e);return t=null!=t?t:!this.isLayerLabelVisible(e),r&&(t?r.showLabel&&(r.options.labelVisibility=!0,r.showLabel()):r.hideLabel&&(r.options.labelVisibility=!1,r.hideLabel()),r.id&&this._emitLayerEvent("layer:label:toggle",r.id,r)),t}selectLayer(e,t){const r=this.getLayer(e);if(r){r&&r.select&&r.select(t);const e=this.getLayerId(r);e&&this._selectedLayers.push(e)}}unSelectLayer(e,t){const r=this.getLayer(e);if(r){const e=r&&r;e.unselect&&e.unselect(t);const n=this.getLayerId(r);if(n){const e=this._selectedLayers.indexOf(n);-1!==e&&this._selectedLayers.splice(e,1)}}}unSelectLayers(){const e=Object.values(this.allLayers());let t;for(t of e)t.unselect&&t.unselect()}filterLayer(e,t){const r=this.getLayer(e);return r.filter?r.filter(t):[]}propertiesFilter(e,t,r){const n=this.getLayer(e);if(n){const e=n;if(e.propertiesFilter)return e.propertiesFilter(t,r);e.filter&&this.filterLayer(e,(e=>!e.feature||!e.feature.properties||Lt(e.feature.properties,t)))}return Promise.resolve()}removeLayerFilter(e){const t=this.getLayer(e);t.removeFilter?t.removeFilter():t.filter&&t.filter((()=>!0))}setLayerData(e,t){const r=this.getLayer(e);if(r){if(r.setData)return r.setData(t);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(t)}return Promise.resolve()}addLayerData(e,t){const r=this.getLayer(e);r.addData&&r.addData(t)}clearLayerData(e,t){const r=this.getLayer(e);r&&r.clearLayer&&r.clearLayer(t)}setLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.setPaint&&r.setPaint(t)}setLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.setSelectedPaint&&r.setSelectedPaint(t)}updateLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.updatePaint&&r.updatePaint(t)}updateLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(t)}getAttributions(e){const t=[];for(const r in this._layers){const n=this._layers[r];let o=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(o&&e.onlyBaselayer&&(o=this._baselayers.includes(r)),o){const e=n.options&&n.options.attribution;e&&t.push(e)}}return t}getActiveBaseLayer(){const e=this.getBaseLayers().find((e=>this.isLayerVisible(e)));if(e)return this.getLayer(e)}addTileJsonLayer(e){return this.addLayer("TILE",{url:e.tiles[0],maxZoom:e.maxzoom,minZoom:e.minzoom,subdomains:e.scheme,attribution:e.attribution})}_emitLayerEvent(e,t,r){const n=String(e);if(u(t)&&n.startsWith("layer:")){const e=n.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return za(this,null,(function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerDoubleClick(e){return za(this,null,(function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerSelect(e){return za(this,null,(function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)}))}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:n,onDoubleClick:o,onLayerClick:i,onMouseOut:s,onMouseOver:a}=e,l=n||i,c=o||i;e.onClick=e=>(l&&l(e),this._onLayerClick(e)),e.onDoubleClick=e=>(c&&c(e),this._onLayerDoubleClick(e)),e.onMouseOut=e=>{const t=e.layer.id;s&&s(e),u(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;a&&a(e),u(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const h=t||r;e.onSelect=e=>(h&&h(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=ia({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=ia({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}function Wa(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const o=t.title||"",i=t.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function l(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(e,t){e.split(" ").forEach((e=>{t?r.classList.add(e):r.classList.remove(e)}))}function u(){t.addClassOn&&c(t.addClassOn,n),t.addClassOff&&c(t.addClassOff,!n)}s(),l(),t.addClass&&c(t.addClass,!0),u();const h=e=>{void 0!==e&&(n=e),l(),s(),u()},p=e=>{if(n=void 0!==e?e:!n,t.onClick){const e=t.onClick(n);Promise.resolve(e).then((()=>h())).catch((()=>n=!n))}else h()},d=e({html:r,onClick:p});return d.onClick=p,d.changeStatus=h,d}var Ha=Object.defineProperty,Ja=(e,t,r)=>((e,t,r)=>t in e?Ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Qa=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Ka=class e extends Za{constructor(){super(...arguments),Ja(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),Ja(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return Qa(this,null,(function*(){let n;if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,r):e,n)return new Promise((e=>{this._setControlQueue(t,(()=>Qa(this,null,(function*(){const r=yield n,o=this.mapAdapter.addControl(r,t);e(o)}))))}))}))}createControl(e,t){return Qa(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)}))}createButtonControl(e){return Qa(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)}))}createToggleControl(e){return Qa(this,null,(function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?Wa(this.mapAdapter.createButtonControl,e):void 0}))}removeControl(e){"remove"in e?e.remove():this.mapAdapter.removeControl&&Promise.resolve(e).then((e=>{this.mapAdapter.removeControl(e)}))}getControl(t,r){const n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);{const n=e.controls[t];if(n)return n(this,r)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return Qa(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}))}};Ja(Ka,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let Xa=Ka;const Ya={};function el(e){return Ya[e]}function tl(e,t){Ya[e]=t}var rl=Object.getOwnPropertySymbols,nl=Object.prototype.hasOwnProperty,ol=Object.prototype.propertyIsEnumerable,il=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),sl=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())})),al=(e,t,r)=>(t=e[il("asyncIterator")])?t.call(e):(e=e[il("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:i})),o))))),r("next"),r("return"),t);class ll extends Xa{constructor(e){super(e),this._addControls(),tl(this.id,this)}static get(e){return el(e)}_addLayerProviders(){return sl(this,null,(function*(){try{for(var e,t,r,n=al(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.getLayerAdapters){const t=yield e.getLayerAdapters.call(e);if(t)try{for(var o,i,s,a=al(t);o=!(i=yield a.next()).done;o=!1){const e=i.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(i){s=[i]}finally{try{o&&(i=a.return)&&(yield i.call(a))}finally{if(s)throw s[0]}}}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_onLoadSync(){return sl(this,null,(function*(){try{for(var e,t,r,n=al(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.onLoadSync)try{yield e.onLoadSync.call(e,this)}catch(o){console.error(o)}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_addControls(){this.options.controls&&this.options.controls.forEach((e=>{let t=e,r={};"string"==typeof e&&this.options.controlsOptions&&this.options.controlsOptions[e]&&(r=this.options.controlsOptions[e],void 0!==r.control&&(t=r.control));const n=r,{position:o}=n,i=((e,t)=>{var r={};for(var n in e)nl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&rl)for(var n of rl(e))t.indexOf(n)<0&&ol.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,o||"top-left",i)})),this._emitStatusEvent("controls:create")}}function cl(){return["ZOOM","ATTRIBUTION"]}function ul(e){return t=this,r=null,n=function*(){return new ll(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var hl=Object.defineProperty,pl=Object.defineProperties,dl=Object.getOwnPropertyDescriptors,fl=Object.getOwnPropertySymbols,yl=Object.prototype.hasOwnProperty,ml=Object.prototype.propertyIsEnumerable,bl=(e,t,r)=>t in e?hl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gl=(e,t)=>{for(var r in t||(t={}))yl.call(t,r)&&bl(e,r,t[r]);if(fl)for(var r of fl(t))ml.call(t,r)&&bl(e,r,t[r]);return e},vl=(e,t)=>pl(e,dl(t));function wl(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(vl(gl({},r),{resource:t}));else if(Array.isArray(t)){const[o,i]=t;e.push(gl(vl(gl({},r),{resource:o,id:i}),n))}else"object"==typeof t&&e.push(gl(gl(gl({},r),t),n))}var _l=Object.defineProperty,Ol=Object.defineProperties,Ll=Object.getOwnPropertyDescriptors,Pl=Object.getOwnPropertySymbols,Il=Object.prototype.hasOwnProperty,xl=Object.prototype.propertyIsEnumerable,jl=(e,t,r)=>t in e?_l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const El={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 Al(e){const t=[new jn];var r;return e.starterKits&&e.starterKits.forEach((e=>{t.push(e)})),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new dt({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=p(El,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new Ji({connector:e.connector,auth:e.auth})),r=((e,t)=>{for(var r in t||(t={}))Il.call(t,r)&&jl(e,r,t[r]);if(Pl)for(var r of Pl(t))xl.call(t,r)&&jl(e,r,t[r]);return e})({},e),e=Ol(r,Ll({starterKits:t,create:!1}))}var Cl=Object.defineProperty,kl=Object.defineProperties,Ml=Object.getOwnPropertyDescriptors,Sl=Object.getOwnPropertySymbols,Nl=Object.getPrototypeOf,Tl=Object.prototype.hasOwnProperty,Rl=Object.prototype.propertyIsEnumerable,Fl=Reflect.get,Bl=(e,t,r)=>t in e?Cl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$l=(e,t)=>{for(var r in t||(t={}))Tl.call(t,r)&&Bl(e,r,t[r]);if(Sl)for(var r of Sl(t))Rl.call(t,r)&&Bl(e,r,t[r]);return e},ql=(e,t)=>kl(e,Ml(t)),Dl=(e,t,r)=>Bl(e,"symbol"!=typeof t?t+"":t,r),Ul=(e,t,r)=>Fl(Nl(e),r,t),Vl=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Gl=class e extends ll{constructor(e){super(Al(e)),Dl(this,"emitter",new t),Dl(this,"connector"),Dl(this,"_ngwLayers",{}),Dl(this,"$$selectFromNgwRaster"),Dl(this,"$$selectFromNgwVector"),Dl(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 Vl(this,null,(function*(){return yield this.onLoad("controls:create"),Ul(e.prototype,this,"addControl").call(this,t,r,n)}))}addNgwLayer(e){return Vl(this,null,(function*(){yield this.onMapLoad();const{keyname:t,resourceId:r}=e;(t||void 0!==r)&&console.warn(`DEPRECATED WARN: ${"set `resource` options instead of `keyname` or `resourceId`"}`);const n=e.resource;if(!t&&!r&&!n)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(u(this.options.baseUrl))try{u(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},u(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),Ho(e,t,r)}(e,this,this.connector),r=$l($l({visibility:!0},e),e.adapterOptions),n=yield this.addLayer(t,r),o=n&&this.getLayerId(n);if(n&&o&&(this._ngwLayers[o]={layer:n,resourceId:n.resourceId},n.options.name=n.options.name||n.item&&n.item.resource.display_name,n.options.baselayer)){if(this.getActiveBaseLayer())return n}return n}catch(o){const e=P(n)&&"id"in n?n.id:t||r||n;console.error(`Can't add NGW layer ${e}.`,o)}}))}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 Yt($l({connector:this.connector},e))}fetchNgwLayerItems(e){return Xn($l({connector:this.connector},e))}fetchNgwLayerFeature(e){return is($l({connector:this.connector},e))}fetchNgwLayerFeatures(e){return to($l({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=new AbortController,n=r.signal;(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",r.abort),(t=t||{}).signal=n;const o=function(e){const{connector:t,identify:r}=e,n=ys(r);return n&&n.length?Yt(ds(ds({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",o,r),o}fetchIdentifyGeoJson(e,{multiple:t,signal:r}={}){const n=new AbortController;if(r){if(r.aborted)return Promise.reject(new dt.errors.AbortError);r.addEventListener("abort",(()=>{n.abort("AbortError")}))}const o=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const i in r){const e=Number(i);if(!isNaN(e)){const e=r[i];if("features"in e){const t=e.features.find((e=>e.geom));if(t&&t.geom){const e=t.geom;return Promise.resolve(Rt(fs(ds({},t),{geom:e})))}}}}const o=ys(r);return o&&o.length?is(ds(fs(ds({},n),{connector:t}),o[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,multiple:t,requestOptions:{signal:n.signal}});return o&&"then"in o?(this._addPromise("identify",o,n),o):Promise.resolve(o)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,{multiple:t})}getNgwLayers(){return Vl(this,null,(function*(){return yield this.onLoad(),this._ngwLayers}))}getNgwLayerByResourceId(e){return Vl(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 Vl(this,null,(function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const o=n&&this._ngwLayers[n];if(o)if(o.layer.getBounds){const e=yield o.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(o.layer.item)e=o.layer.item;else{const t=o.resourceId;e=yield this.connector.getResource(t)}e&&this.fitResource(e.resource.id)}else Ul(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)}))}fitResource(e,t){return Vl(this,null,(function*(){const r=yield this.connector.resources.getIdOrFail(e),n=yield tn({resourceId:r,connector:this.connector});n&&this.fitBounds(n,t)}))}zoomToLayer(e){return Vl(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 Vl(this,null,(function*(){var t;this._emitStatusEvent("ngw:preselect");const r=[],n=Object.values(this._ngwLayers);n.sort(((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1));for(const e of n){const n=e.layer,o="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,i=null==(t=n.options.interactive)||t;o&&n.options.selectable&&i&&this.isLayerVisible(n)&&r.push(o.call(n))}const o=Promise.all(r),i=yield o,s=[];for(const e of i)e&&s.push(...e);if(!s.length)return void this._emitStatusEvent("ngw:select",null);const a=this.options.pixelRadius||10,l=this.getCenter();let c=this.getZoom();if(c=void 0!==c?c:20,!l||!c)return void this._emitStatusEvent("ngw:select",null);const u=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}(l,c,a);let h;if(this.options.highlightIdentification){const t=this.options.highlightIdentification,r="number"==typeof t?t:1e3,[n,o]=e.lngLat;h={type:"Polygon",coordinates:[v(n,o,u)]};const i=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:h}});r!==1/0&&setTimeout((()=>{this.removeLayer(i)}),r)}const p=new AbortController,f=function(e,t){d(e);const[r,n]=e.lngLat,{geom:o,radius:i}=t,s=null!=o?o:v(r,n,i);return bs(fs(ds({},t),{geom:s}))}(e,{layers:s,connector:this.connector,radius:u,geom:h,signal:p.signal}).then((t=>{const r=ql($l({},t),{resources:s,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n}));return this._addPromise("select",f,p),f}))}_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 Vl(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&&wl(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),wl(e,n,{},r)}for(const n of e)try{yield this.addNgwLayer(n)}catch(r){console.warn(r)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()}))}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const r={qmsId:e};t&&(r.id=t),this.addBaseLayer("QMS",r)}_selectFromNgwVector(e){const t=e.layer;if(!(t.options.selectable&&this.isLayerVisible(t)))return;const r=t.item&&t.item.resource.id,n=e.feature;if(void 0!==r&&n){const e=n.id;if(e){const t={featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]},o={featureCount:1,[r]:t};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(ql($l({},o),{resources:[r],sourceType:"vector"}))),o}}}_prepareToIdentify(e){return ql($l({},e),{getIdentifyItems:()=>ys(e,!0).map((e=>new ns({feature:e.feature,connector:this.connector})))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return Vl(this,null,(function*(){const e=this.getContainer();if(e){const t=yield gs(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}))}};Dl(Gl,"getIcon",(function(e={}){var t,r,n,o,i,s;const c=null!=(t=e.shape)?t:"circle",u=null!=(r=e.color)?r:"blue",h=null!=(n=e.strokeColor)?n:"white",p=null!=(o=e.size)?o:l,d=null!=(i=e.rotate)?i:0,f=null!=(s=e.anchor)?s:[p/2,p/2],y=void 0!==e.stroke?Number(e.stroke):.8,m=e.p||a[c]||"circle",b="string"==typeof m?m:m(e),g=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(e.svg||function({width:e,height:t,stroke:r=0,content:n}){const o=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${o} -${o} ${l+r} ${l+r}"\n >${n}</svg>`}({width:p,height:p,stroke:y,content:b}));return g.setAttribute("width",String(p)),g.setAttribute("height",String(p)),g.setAttribute("fill",u),y&&(g.setAttribute("stroke",h),g.setAttribute("stroke-width",String(y))),{type:"icon",iconSize:[p,p],iconAnchor:f,html:(new XMLSerializer).serializeToString(g),rotate:d,svg:g}}));let zl=Gl;function Zl(e){return t=this,r=null,n=function*(){return new zl(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}export{zl as NgwMap,ll as WebMap,Xa as WebMapControls,Za as WebMapLayers,Aa as WebMapMain,Zl as createNgwMap,Wa as createToggleControl,ul as createWebMap,ka as detectGeometryType,Ca as findMostFrequentGeomType,cl as getDefaultControls,el as getWebMap,Ma as paintTypeAlias,tl as setWebMap,Sa as typeAlias,Na as updateGeoJsonAdapterOptions};
1
+ const e={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'};function t(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const o=void 0===r.replace||r.replace;t.forEach((t=>{Object.getOwnPropertyNames(t.prototype).forEach((r=>{const i=-1!==n.indexOf(r);if(!o&&!i||o){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}}))}))}function r(e,t,n=!1){let o=e;const i=t,s=Array.isArray(i);let a=s&&[]||{};return s&&Array.isArray(i)?n?(o=o||[],a=a.concat(o),i.forEach(((e,t)=>{void 0===a[t]?a[t]=e:"object"==typeof e?a[t]=r(o[t],e,n):-1===o.indexOf(e)&&a.push(e)}))):a=i:(o&&"object"==typeof o&&Object.keys(o).forEach((function(e){a[e]=o[e]})),Object.keys(i).forEach((function(e){a[e]="object"==typeof i[e]&&i[e]&&"object"==typeof o[e]&&"object"==typeof i[e]?r(o[e],i[e],n):i[e]}))),a}function n(e){return null!=e}function o(e){return"string"==typeof e?!!e:n(e)}function i(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}function s(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}function a(e){return{type:"Polygon",coordinates:[l(e)]}}function l(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const c=Math.PI/180,u=180/Math.PI;function h(e,t,r=10,n=6){const o=r/6371*u,i=o/Math.cos(t*c),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+i*Math.cos(r),c=t+o*Math.sin(r);s.push([l,c])}return s}function p(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:d(e,t));return e===t}function d(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let o=0;o<r.length;o++){if(!p(e[r[o]],t[n[o]],e,t))return!1}return!0}function f(e){const t={};return Object.keys(e).forEach((r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=f(e[r])})),t}function y(e){return"[object Object]"===Object.prototype.toString.call(e)}function m(e){return e.replace(/([^:]\/)\/+/g,"$1")}const b=/\{ *([\w_-]+) *\}/g;function g(e,t){return e.replace(b,((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 v=Object.defineProperty,w=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,L=(e,t,r)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function P(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=g(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={}))_.call(t,r)&&L(e,r,t[r]);if(w)for(var r of w(t))O.call(t,r)&&L(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var I=Object.defineProperty,x=(e,t,r)=>((e,t,r)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const j=class e{constructor(t={}){var r;x(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,t,r,n,i){let s,a;"object"==typeof r&&"valueToSet"in r?(s=r,n=s.onlyFull,i=s.expirationTime,a=s.props):a=r;const l=this._find(e,a);if(l)return l.value;{let r;r=t instanceof Function?t():t;const s=a&&JSON.parse(JSON.stringify(f(a)));i=i?Date.now()+i:void 0;const l={key:e,value:r,props:s,expirationTime:i};return n&&!o(r)?r:(this.cache.push(l),r instanceof Promise?(r.catch((()=>{this.delete(e,a)})),n&&r.then((t=>(o(t)||this.delete(e,a),t))),r):r)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach((e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)})),e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){const r="string"==typeof e?this.cache.filter((r=>this._filter(r,e,t))):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find((r=>this._filter(r,e,t)))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return d(e.props||{},f(r))}};x(j,"instance",{});let E=j;function A(){}function C(){C.init.call(this)}function k(e){return void 0===e._maxListeners?C.defaultMaxListeners:e._maxListeners}function M(e,t,r,n){var o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]):(i=e._events=new A,e._eventsCount=0),s){if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(o=k(e))&&o>0&&s.length>o){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function S(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function N(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function T(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}A.prototype=Object.create(null),C.EventEmitter=C,C.usingDomains=!1,C.prototype.domain=void 0,C.prototype._events=void 0,C.prototype._maxListeners=void 0,C.defaultMaxListeners=10,C.init=function(){this.domain=null,C.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new A,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},C.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},C.prototype.getMaxListeners=function(){return k(this)},C.prototype.emit=function(e){var t,r,n,o,i,s,a,l="error"===e;if(s=this._events)l=l&&null==s.error;else if(!l)return!1;if(a=this.domain,l){if(t=arguments[1],!a){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=T(e,n),i=0;i<n;++i)o[i].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=T(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=T(e,i),a=0;a<i;++a)s[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,a=T(e,s),l=0;l<s;++l)a[l].call(r,n,o,i)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=T(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,u,this,o)}return!0},C.prototype.on=C.prototype.addListener=function(e,t){return M(this,e,t,!1)},C.prototype.prependListener=function(e,t){return M(this,e,t,!0)},C.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,S(this,e,t)),this},C.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,S(this,e,t)),this},C.prototype.removeListener=function(e,t){var r,n,o,i,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new A:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new A,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,s||t)}return this},C.prototype.off=function(e,t){return this.removeListener(e,t)},C.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new A,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new A:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new A,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},C.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):[]},C.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):N.call(e,t)},C.prototype.listenerCount=N,C.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var R="3.0.0-alpha.14";class F extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var B=Object.defineProperty,$=(e,t,r)=>((e,t,r)=>t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class q extends Error{constructor(e){super(),$(this,"name","NgwError"),$(this,"title"),$(this,"message"),$(this,"detail"),$(this,"exception"),$(this,"status_code"),$(this,"data"),$(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,q.prototype)}}var D=Object.defineProperty,U=(e,t,r)=>((e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class V extends q{constructor(e){super(e),U(this,"name","InsufficientPermissionsError"),U(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,V.prototype)}}var G=Object.defineProperty,z=(e,t,r)=>((e,t,r)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let Z=class e extends q{constructor(t){super(t),z(this,"message","There is no response from the server or problem connecting to server."),z(this,"title","Network error"),z(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var W=Object.defineProperty,H=(e,t,r)=>((e,t,r)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class J extends Error{constructor(e){super(),H(this,"name","NetworkError"),Object.setPrototypeOf(this,J.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var Q=Object.defineProperty,K=(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 X extends q{constructor(e){super(e),K(this,"name","ResourceNotFoundError"),K(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,X.prototype)}}var Y=Object.freeze({__proto__:null,AbortError:F,InsufficientPermissionsError:V,NetworkError:J,NetworksResponseError:Z,NgwError:q,ResourceNotFoundError:X,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 Z({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!y(e)&&(e.status_code&&e.exception&&e.title)}}),ee=Object.defineProperty,te=(e,t,r)=>((e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class re extends Error{constructor(e){super(e||"Something went wrong."),te(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,re)}}class ne extends re{constructor(e){super(e||"There is no response from the server or problem connecting to server."),te(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class oe extends re{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ie extends re{constructor(e){super(e.message),te(this,"detail"),te(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class se extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),te(this,"title"),te(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,se)}}class ae extends se{constructor(e){super("Long-running request was cancelled.",e)}}class le extends se{constructor(e){super(void 0,e)}}var ce=Object.defineProperty,ue=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,de=(e,t,r)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fe=(e,t)=>{for(var r in t||(t={}))he.call(t,r)&&de(e,r,t[r]);if(ue)for(var r of ue(t))pe.call(t,r)&&de(e,r,t[r]);return e},ye=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function me(e){return ye(this,null,(function*(){const t=yield function(e){return ye(this,null,(function*(){try{return e.json()}catch(t){throw new Error}}))}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise((t=>setTimeout(t,e)));let a=!1,l=!1;for(;!l;){let e,t;yield s(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(c){a=!0;continue}switch(t.status){case void 0:throw new se(void 0,t);case"ready":l=!0;break;case"cancelled":throw new ae(t);case"failed":throw new le(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new se(void 0,t)}}return i}))}const be=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ge(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function ve(e,t,r){return ye(this,null,(function*(){var n,o;const i=fe(fe({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:s,responseType:a,cacheProps:l,cacheName:c,lunkwill:u,cache:h,query:p,json:d}=i,y=((e,t)=>{var r={};for(var n in e)he.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&ue)for(var n of ue(e))t.indexOf(n)<0&&pe.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),s&&(y.credentials="include");let m=!1;void 0!==u&&(u.toHeaders(y.headers||{}),m=!0);const b=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=ge(e,p),v=()=>ye(this,null,(function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new ne}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 me(e);if(b)return t;e=yield function(e){return ye(this,null,(function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new ne}}))}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&be.test(t);if("blob"===a||o)n=yield e.blob();else{if(!r)throw new oe;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof oe)throw o;throw new oe}if(400<=e.status&&e.status<=599)throw new ie(n);return n}));if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==h){const e=l||fe({},f({withCredentials:s,responseType:a}));return r.add(c||g,v,{props:e,expirationTime:h?void 0:500})}}else r.clean();return v()}))}var we=Object.defineProperty,_e=Object.defineProperties,Oe=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,je=(e,t)=>{for(var r in t||(t={}))Pe.call(t,r)&&xe(e,r,t[r]);if(Le)for(var r of Le(t))Ie.call(t,r)&&xe(e,r,t[r]);return e},Ee=(e,t)=>{var r={};for(var n in e)Pe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Le)for(var n of Le(e))t.indexOf(n)<0&&Ie.call(e,n)&&(r[n]=e[n]);return r};function Ae(e,t,r,...n){const[o,...i]=r[e],s=n[0];let a;if(void 0===s)a=[];else if("object"==typeof s&&null!==s){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");a=[];for(const[e,t]of Object.entries(s))a[i.indexOf(e)]=String(t)}else a=n.map((e=>String(e)));return m(t+o.replace(/\{(\w+)\}/g,(function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)})))}function Ce(e,t,...r){const n={url:n=>{return o=this,i=null,s=function*(){var o;const i=yield t.connect();return ge(Ae(e,null!=(o=t.options.baseUrl)?o:"",i,...r),null==n?void 0:n.query)},new Promise(((e,t)=>{var r=e=>{try{a(s.next(e))}catch(r){t(r)}},n=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((s=s.apply(o,i)).next())}));var o,i,s}},o=["get","post","put","delete","patch"];for(const i of o){const o=n=>{var o;const s=n||{},{headers:a}=s,l=Ee(s,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new F;return t.connect().then((n=>{var o;const s=Ae(e,null!=(o=t.options.baseUrl)?o:"",n,...r),c=f(je(je({},t.getAuthorizationHeaders()),null!=a?a:{}));return ve(s,(u=je({headers:c},l),_e(u,Oe({method:i}))),t.cache);var u}))};n[i]=o}return n}function ke(e){return"[object Object]"===Object.prototype.toString.call(e)}let Me;Me=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new q(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new J(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&i.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{i.abort()})),i.send(l)};const Se=[];function Ne(e){Se.push(e)}var Te=Object.defineProperty,Re=Object.defineProperties,Fe=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,De=(e,t,r)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ue=(e,t)=>{for(var r in t||(t={}))$e.call(t,r)&&De(e,r,t[r]);if(Be)for(var r of Be(t))qe.call(t,r)&&De(e,r,t[r]);return e},Ve=(e,t,r)=>De(e,"symbol"!=typeof t?t+"":t,r),Ge=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let ze=0,Ze=0;class We{constructor(e){this.options=e,Ve(this,"id",ze++),Ve(this,"emitter",new C),Ve(this,"user"),Ve(this,"cache"),Ve(this,"withCredentials"),Ve(this,"client",`NextGIS-NGW-Connector/${R}`),Ve(this,"routeStr","/api/component/pyramid/route"),Ve(this,"activeRequests",{}),Ve(this,"requestTransform");const t=function(e){return Se.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 E({namespace:e.cacheId}),t)return t;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),Ne(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Ne(this)}connect(){return Ge(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}))}return this.makeQuery(`${this.routeStr}?client=${this.client}`,{},{cacheName:"route",signal:e,cache:!0,cacheProps:{id:this.id,auth:t,baseUrl:this.options.baseUrl}})}))}login(e,t){return this.logout(),Ne(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Se.indexOf(e);-1!==t&&Se.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return Ge(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ue({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Ue({},this.activeRequests)}route(e,...t){return Ce(e,this,...t)}makeQuery(e,t){return Ge(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)$e.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Be)for(var n of Be(e))t.indexOf(n)<0&&qe.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=g(e,r)}e=encodeURI(m(e)),r=Ue({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:h}=r,p=new AbortController,d=p.signal;if(i){if(i.aborted)throw new F;i.addEventListener("abort",(()=>{p.abort()}))}r.signal=d;const y=()=>Ge(this,null,(function*(){const t=Ze++;this.activeRequests[t]=p;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if("GET"===s){const r=c||(b=Ue({},f({headers:a,withCredentials:h,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Re(b,Fe({params:t})));return this.cache.add(l||e,y,{props:r,expirationTime:o?void 0:500})}var b;return y()}))}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Ue(Ue({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;Me(e,r,t,n,(e=>{i=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==i&&i(),n(new F)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return Ge(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 q){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new X(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new V(e)}return e}}Ve(We,"errors",Y);const He=["description"];function Je(e,t=""){t=t?t+"__":"";const r={};for(const[o,i]of Object.entries(e))if(-1===He.indexOf(o))if(ke(i))if("owner_user"===o){const e=Je(i,o);Object.assign(r,e)}else"parent"===o&&"id"in i&&(r.parent_id=i.id);else n(i)&&(r[t+o]=i);return r}var Qe=Object.defineProperty,Ke=Object.defineProperties,Xe=Object.getOwnPropertyDescriptors,Ye=Object.getOwnPropertySymbols,et=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,rt=(e,t,r)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nt=(e,t)=>{for(var r in t||(t={}))et.call(t,r)&&rt(e,r,t[r]);if(Ye)for(var r of Ye(t))tt.call(t,r)&&rt(e,r,t[r]);return e},ot=(e,t)=>Ke(e,Xe(t)),it=(e,t,r)=>rt(e,"symbol"!=typeof t?t+"":t,r),st=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class at{constructor({connector:e,cacheId:t}){it(this,"cache"),it(this,"connector"),this.connector=e,this.cache=new E({namespace:t})}getOne(e,t){const r=nt({},t);return"string"==typeof e||"number"==typeof e||ke(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):ke(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 X}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||ke(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,Je(e)),this.connector.route("resource.search").get(ot(nt({},t),{query:nt({serialization:"full"},r)})).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)}))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t){return st(this,arguments,(function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(ot(nt({},t),{query:{parent:n}})),i=[];for(const s of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(s),{id:s.resource.id}),r.push(s),(null==t?void 0:t.recursive)&&s.resource.children&&i.push(this._getChildrenOf(s.resource.id,t,r));return i.length?Promise.all(i).then((()=>r)):r}))}_cleanResourceItemCache(e){return st(this,null,(function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)}))}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then((t=>(t.filter((t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:n(e.id)&&n(t.resource.id)?e.id===t.resource.id:d(e,t.resource)})),[])))}}var lt=Object.defineProperty,ct=(e,t,r)=>((e,t,r)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ut extends We{constructor(e){super(e),ct(this,"resources"),this.resources=new at({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 P({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 ht=Object.defineProperty,pt=Object.defineProperties,dt=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,bt=(e,t,r)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gt=(e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&bt(e,r,t[r]);if(ft)for(var r of ft(t))mt.call(t,r)&&bt(e,r,t[r]);return e},vt=(e,t)=>pt(e,dt(t));function wt(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,o=e.extent_right;if(t&&r&&n&&o){const e=[r,t,o,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function _t({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.route("layer.extent",{id:Number(e)}).get({cache:r,signal:n}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}function Ot(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then((t=>{if(t)return Lt(t,e.connector,e)}))}function Lt(e,t,r){if(e.webmap)return Promise.resolve(wt(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 _t(vt(gt({},r),{resourceId:e.resource.id,connector:t}))})):_t(vt(gt({},r),{resourceId:n.id,connector:t}))}}var Pt=Object.defineProperty,It=(e,t,r)=>((e,t,r)=>t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),xt=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class jt{constructor(){It(this,"item"),It(this,"connector"),It(this,"_extent")}getExtent(){return xt(this,null,(function*(){return this.getBounds()}))}getBounds(e){return xt(this,null,(function*(){return this._extent?this._extent:this.item?(this._extent=yield Lt(this.item,this.connector,e),this._extent):void 0}))}}function Et(e,t){return r=this,n=null,o=function*(){const r=e.resource,n=r;let{keyname:o,resourceId:i}=e;if(r&&("string"==typeof r?o=r:i="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield Et(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i},new Promise(((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())}));var r,n,o}var At=Object.defineProperty,Ct=Object.getOwnPropertySymbols,kt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,St=(e,t,r)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nt=(e,t,r)=>St(e,"symbol"!=typeof t?t+"":t,r),Tt=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Rt(e){return Tt(this,arguments,(function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){Nt(this,"options",{}),Nt(this,"layer",[]),Nt(this,"_removed",!1),Nt(this,"_creatingInProgress",!1)}addLayer(){return this.layer}removeLayer(){this._removed=!0;for(const t of this.layer)e.removeLayer(t)}destroyed(){return this._removed}showLayer(){return 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 o=yield n(this);if(o){const n=new o(e.mapAdapter.map,((e,t)=>{for(var r in t||(t={}))kt.call(t,r)&&St(e,r,t[r]);if(Ct)for(var r of Ct(t))Mt.call(t,r)&&St(e,r,t[r]);return e})({},t)),i=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=i,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer}))}}}))}function Ft(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){return Rt({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>Ri({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)})},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var Bt=Object.defineProperty,$t=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,Ut=(e,t,r)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function Vt(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const Gt={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)=>Vt(e,t),ilike:(e,t)=>Vt(e,t,!0)};function zt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Zt(e,t){const r=((e,t)=>{for(var r in t||(t={}))qt.call(t,r)&&Ut(e,r,t[r]);if($t)for(var r of $t(t))Dt.call(t,r)&&Ut(e,r,t[r]);return e})({},e.properties);return!!r&&(r.$id=e.id,Wt(r,t))}function Wt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(zt(t)){const[r,n,o]=t,i=Gt[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,i)=>(t=e[i],r.replace(i,o))));return i(t,n)}return i(e[r],o)}return!1}return Wt(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}const Ht={defaultRequestLimit:7e3};var Jt=Object.defineProperty,Qt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Xt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,er=Object.prototype.propertyIsEnumerable,tr=(e,t,r)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rr=(e,t)=>{for(var r in t||(t={}))Yt.call(t,r)&&tr(e,r,t[r]);if(Xt)for(var r of Xt(t))er.call(t,r)&&tr(e,r,t[r]);return e},nr=(e,t)=>Qt(e,Kt(t)),or=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const ir={srs:4326,geom_format:"geojson"};function sr(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function ar(e,t){const{extensions:r,geom:o,fields:i,srs:s,ilike:a,like:l}=t;e.extensions=r||[],i&&(e.fields=i),void 0!==o&&(e.geom=o,o||(delete e.srs,delete e.geom_format)),n(a)?e.ilike=a:n(l)&&(e.like=l),n(s)&&(e.srs=s)}function lr(e){return or(this,null,(function*(){const t=ur(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o}))}function cr(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,i=n,r)))}__${r}`,o+n+i]}function ur(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===s)for(const l of a)zt(l)?t.push(pr(nr(rr({},e),{paramList:[...r,...i,cr(l)]}))):ur(nr(rr({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)zt(e)?n.push(cr(e)):o.push(e);if(o.length)for(const i of o)ur(nr(rr({},e),{filters:i}),t,[...r,...n]);else t.push(pr(nr(rr({},e),{paramList:[...r,...i,...n]})))}return t}function hr(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=s(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function pr(e){const t=rr({},ir),{limit:r,query:n,cache:o,signal:i,offset:s,orderBy:a,paramList:c,connector:u,geomFormat:h,intersects:p,resourceId:d}=e;if(t.limit=r&&r!==Number.POSITIVE_INFINITY?r:Ht.defaultRequestLimit,s&&(t.offset=s),h&&(t.geom_format=h),ar(t,e),a&&(t.order_by=a.join(",")),Array.isArray(p)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every((e=>"number"==typeof e))}(p)?l(p):p;t.intersects=hr(e)}else"string"==typeof p&&(t.intersects=p);return c&&Object.assign(t,function(e){return e.reduce(((e,[t,r])=>(e[t]=r,e)),{})}(c)),u.route("feature_layer.feature.collection",{id:Number(d)}).get({query:rr(rr({},t),n),cache:o,signal:i})}function dr(e){let t;for(t in e){const r=e[t];if(y(r)){const o=r;if(n(o.year)&&n(o.month)&&n(o.day)){const r=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach((e=>{r.push(e)})),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var fr=Object.defineProperty,yr=Object.defineProperties,mr=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,vr=Object.prototype.propertyIsEnumerable,wr=(e,t,r)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_r=(e,t)=>{for(var r in t||(t={}))gr.call(t,r)&&wr(e,r,t[r]);if(br)for(var r of br(t))vr.call(t,r)&&wr(e,r,t[r]);return e},Or=(e,t)=>yr(e,mr(t)),Lr=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Pr(e){return Lr(this,null,(function*(){var t;const r=e.filters;if(r){let n=yield lr(Or(_r({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:Ir(r))&&(n=n.filter((e=>Wt(dr(Or(_r({},e.fields),{id:e.id})),r)))),n}return pr(e)}))}function Ir(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(Ir(r))return!0}}return!1}function xr({options:e,webMap:t,baseUrl:r}){var n;let o,i=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===i){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const o=t+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:t=>(r&&(t.nd=r),co(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});i="TILE"}if("WMS"===i){o=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:o,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===i)return o=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:o,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===i)return o=r+`/api/resource/${a}/terrain_provider`,{url:o,adapter:i};if("MODEL_3D"===i)return o=r+`/api/component/model_3d/${a}/data.glb`,{url:o};if("TILE"===i)return o=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:o,adapter:i}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var jr=Object.defineProperty,Er=Object.defineProperties,Ar=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,Sr=(e,t,r)=>t in e?jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nr=(e,t)=>{for(var r in t||(t={}))kr.call(t,r)&&Sr(e,r,t[r]);if(Cr)for(var r of Cr(t))Mr.call(t,r)&&Sr(e,r,t[r]);return e},Tr=(e,t)=>Er(e,Ar(t)),Rr=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Fr(e){return Rr(this,null,(function*(){const t=Nr({},ir);ar(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Tr(Nr({},e),{query:t}));return Tr(Nr({},r),{toGeojson:()=>Rr(this,null,(function*(){if(r.geom)return sr(r);{const t=(yield Fr(Tr(Nr({},e),{geom:!0,fields:null,extensions:null}))).geom;return sr(Tr(Nr({},r),{geom:t}))}}))})}))}var Br=Object.defineProperty,$r=Object.getOwnPropertySymbols,qr=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,Ur=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Vr=(e,t,r)=>Ur(e,"symbol"!=typeof t?t+"":t,r);class Gr{constructor(e){this.options=e,Vr(this,"name"),Vr(this,"resourceId"),Vr(this,"item"),Vr(this,"_extent"),this.resourceId=e.resourceId;const t=e.item;this.item=t,this.name=e.labelField&&t.fields?t.fields[e.labelField]:String(t.id)}extent(e){return this._extent?Promise.resolve(this._extent):this.options.connector.route("feature_layer.feature.item_extent",{id:this.resourceId,fid:this.item.id}).get(e).then((e=>{const{minLat:t,minLon:r,maxLat:n,maxLon:o}=e.extent,i=[r,t,o,n];return this._extent=i,i}))}geoJson(e){return this.item.geom?Promise.resolve(sr(this.item)):Fr(((e,t)=>{for(var r in t||(t={}))qr.call(t,r)&&Ur(e,r,t[r]);if($r)for(var r of $r(t))Dr.call(t,r)&&Ur(e,r,t[r]);return e})({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null},e)).then((e=>(this.item.geom=e.geom,sr(this.item))))}}var zr=Object.defineProperty,Zr=(e,t,r)=>((e,t,r)=>t in e?zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Wr{constructor(e,t,r){Zr(this,"options"),Zr(this,"emitter",new C),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()}getProperty(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value}getParents(){return this.item.tree.getParents()||[]}getParent(){return this.item.tree.getParent()}getChildren(){return this.item.tree.getChildren()}isGroup(){return this.item.tree.getDescendants().length}isBlocked(){if(void 0!==this._blocked)return this._blocked;const e=this.item.tree.getParents();return this._blocked=this._calculateBlockedStatus(e),this._blocked}set(e,t){this._value=this._prepareValue(e),this.update(this._value,t),this._fireChangeEvent(this._value,t)}get(){return this.getValue()}update(e,t){this._callOnSet(e,t)}getContainer(){return this._container}destroy(){if(this._container){const e=this._container.parentNode;e&&e.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()}getValue(){return void 0!==this._value?this._value:this.getProperty()}_prepareValue(e){return e}_callOnSet(e,t){this.options.onSet&&this.options.onSet.call(this,e,t,this.item)}_fireChangeEvent(e,t){if(this.emitter){e=void 0!==e?e:this.getValue(),this.emitter.emit("change",{value:e,options:t});this.item.tree.getParents().forEach((r=>{const n=r.properties&&r.properties.property(this.name);n&&n.emitter.emit("change-tree",{value:e,options:t,item:this.item})}))}}_calculateBlockedStatus(e){return e.some((e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()}))}}var Hr=Object.defineProperty,Jr=Object.getOwnPropertySymbols,Qr=Object.prototype.hasOwnProperty,Kr=Object.prototype.propertyIsEnumerable,Xr=(e,t,r)=>t in e?Hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yr=(e,t)=>{for(var r in t||(t={}))Qr.call(t,r)&&Xr(e,r,t[r]);if(Jr)for(var r of Jr(t))Kr.call(t,r)&&Xr(e,r,t[r]);return e};const en=class e extends Wr{constructor(t,r,n){super(t,r,Yr(Yr({},e.options),n)),this.set(this.get())}update(e,t){if(e){if(t&&t.bubble||this.options.bubble){this.unBlock(t);const r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(e,Object.assign({},t,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(t)}else this._turnOff(t);(t&&t.propagation||this.options.propagation)&&this._propagation(e,t)}getHierarchyValue(){return this.get()&&this.getParents().every((e=>{const t=e.properties&&e.properties.get(this.name);return t&&t.get()}))}block(e){this._blocked=!0,this._block(e)}unBlock(e){this._blocked=!1,this.getValue()&&this._unBlock(e)}blockChild(e){this.item.tree.getDescendants().forEach((t=>this._blockChild(t,e)))}unblockChild(e){this.item.tree.getChildren().forEach((t=>this._unBlockChild(t,e)))}_prepareValue(e){return e}_turnOff(e){this.options.turnOff&&this.options.turnOff.call(this,e),this._callOnSet(!1,e),this.options.hierarchy&&this.isGroup()&&this.blockChild(e)}_turnOn(e){this.options.turnOn&&this.options.turnOn.call(this,e),this._callOnSet(!0,e),this.options.hierarchy&&this.isGroup()&&this.unblockChild(e)}_block(e){this._turnOff(e)}_unBlock(e){this._turnOn(e)}_blockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.block&&r.block(t)}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(t)}_propagation(e,t){if(this.isGroup()){const r=this.item.tree.getChildren();for(let n=0;n<r.length;n++){const o=r[n],i=o.properties&&o.properties.property(this.name);i&&i.set(e,Yr(Yr({},t),{propagation:!0,bubble:!1}))}}}};Xr(en,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let tn=en;var rn=Object.defineProperty,nn=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable,an=(e,t,r)=>t in e?rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ln=(e,t,r)=>an(e,"symbol"!=typeof t?t+"":t,r);const cn=class e{constructor(e,t){this.item=e,ln(this,"options",{}),ln(this,"_properties",{}),ln(this,"_propertiesList",[]),t&&t.forEach(this._setPropertyHandler.bind(this))}add(e){this._setPropertyHandler(e)}update(){this.list().forEach((e=>e.update()))}get(e){const t=this.property(e);return t?t.get():void 0}set(e,t,r){const n=this.property(e);n&&n.getValue()!==t&&n.set(t,r)}property(e){return this._properties[e]}list(){return this._propertiesList.map((e=>this._properties[e]))}destroy(){for(const e in this._properties){const t=this.property(e);t&&t.destroy&&t.destroy()}this._properties={},this._propertiesList=[]}_setPropertyHandler(e){const t=this._getHandler(e);if(t&&e.name){const r=((e,t)=>{for(var r in t||(t={}))on.call(t,r)&&an(e,r,t[r]);if(nn)for(var r of nn(t))sn.call(t,r)&&an(e,r,t[r]);return e})({},e);this._properties[e.name]=new t(e.name,this.item,r),this._propertiesList.push(e.name)}}_getHandler(t){const r=t.handler;return!r&&t.type?"boolean"===t.type?e.handlers.CheckProperty:e.handlers.BaseProperty:r}};ln(cn,"handlers",{CheckProperty:tn});let un=cn;function hn(e,t,r,n){return!!fn(e,t,r,yn)}function pn(e,t,r,n){return fn(e,t,r,mn)}function dn(e,t="children"){let r=[];const n=("function"==typeof t?t:e=>e[t])(e);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function fn(e,t=e=>!!e,r="children",n,o){return n(e,"function"==typeof t?t:e=>Wt(e,t),r)}function yn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(t(e))return e;const n=dn(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){const e=yn(o[i],t,r,n);if(e)return e}}function mn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{t(e)&&n.push(e);const i=dn(e,r);i&&(o=i)}for(let i=0;i<o.length;i++)o[i]&&mn(o[i],t,r,n);return n}function bn(e,t=e=>!!e,r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(!t(e))return!1;const n=dn(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){if(!bn(o[i],t,r,n))return!1}return!0}var gn=Object.defineProperty,vn=(e,t,r)=>((e,t,r)=>t in e?gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class wn{constructor(e){vn(this,"item"),vn(this,"_children",[]),vn(this,"_parent"),this.item=e}setParent(e){this._parent=e}addChild(e){this._children.push(e)}getParent(){return this._parent}getParents(e){const t=this.getParent();return t?pn(t,e,(e=>e.tree.getParent())):[]}getRoot(){let e=this.getParent(),t=e;for(;e;)e=e.tree.getParent(),e&&(t=e);return t}find(e){return fn(this._children,e,(e=>e.tree.getChildren()),yn)}every(e){return!!fn(this._children,e,(e=>e.tree.getChildren()),bn)}some(e){return hn(this._children,e,(e=>e.tree.getChildren()))}all(e){return this.getDescendants(e)}getDescendants(e){return pn(this._children,e,(e=>e.tree.getChildren()))}getChildren(){return[...this._children]}}var _n=Object.defineProperty,On=Object.getOwnPropertySymbols,Ln=Object.prototype.hasOwnProperty,Pn=Object.prototype.propertyIsEnumerable,In=(e,t,r)=>t in e?_n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xn=(e,t,r)=>In(e,"symbol"!=typeof t?t+"":t,r);let jn=0;class En{constructor(e){xn(this,"options",{}),xn(this,"properties"),xn(this,"tree"),xn(this,"id",jn),jn+=1,this.options=((e,t)=>{for(var r in t||(t={}))Ln.call(t,r)&&In(e,r,t[r]);if(On)for(var r of On(t))Pn.call(t,r)&&In(e,r,t[r]);return e})({},e),this.tree=new wn(this)}initProperties(){this.properties=new un(this,this.options.properties)}}var An=Object.defineProperty,Cn=Object.defineProperties,kn=Object.getOwnPropertyDescriptors,Mn=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Tn=(e,t,r)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Rn=(e,t)=>{for(var r in t||(t={}))Sn.call(t,r)&&Tn(e,r,t[r]);if(Mn)for(var r of Mn(t))Nn.call(t,r)&&Tn(e,r,t[r]);return e},Fn=(e,t)=>Cn(e,kn(t)),Bn=(e,t,r)=>Tn(e,"symbol"!=typeof t?t+"":t,r),$n=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const qn=class e extends En{constructor(t,r,n,o,i,s){if(super(Rn(Rn({},e.options),n)),this.webMap=t,Bn(this,"item"),Bn(this,"connector"),Bn(this,"layer"),Bn(this,"emitter",new C),Bn(this,"_rootDescendantsCount",0),o&&(this.connector=o),i&&this.tree.setParent(i),this.item=r,"root"===this.item.item_type)this._rootDescendantsCount=this._sumUp(this.item.children);else{const e=this.tree.getRoot();e&&(this._rootDescendantsCount=e._rootDescendantsCount)}this.initProperties(),s||this._init(r)}static create(t,r,n,o,i){return $n(this,null,(function*(){const s=new e(t,r,n,o,i,!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 $n(this,null,(function*(){var t;const r=null==(t=this.layer)?void 0:t.id;if(void 0!==r){const t=this.connector;if(t&&"resourceId"in this.item){return[{layerId:r,legend:(yield t.route("render.legend_symbols",{id:Number(this.item.resourceId)}).get(Rn({},e))).map((e=>Rn({name:e.display_name,symbol:e.icon},e)))}]}}return[]}))}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=Fn(Rn({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,Fn(Rn({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===ho){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),ho=t}return ho}()*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(this.webMap,e,this.options,this.connector,this);this.tree.addChild(t)}}return Promise.resolve()}initLayerItem(t){const r=this.getItemOptions(t),n=e=>{t._layer=e,this.layer=e;this.properties.get("visibility")&&this.properties.set("visibility",!0),null!=r.opacity&&this.webMap.setLayerOpacity(e,r.opacity)};let o;if("layer"===t.item_type)o=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){o=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return o?this.webMap.addLayer(o,r).then((e=>{n(e)})):t._layer?Promise.resolve(n(t._layer)):Promise.reject("No layer added")}_getZoomRange(e){const t=this.options.minZoom,r=this.options.maxZoom,n=e.layer_min_scale_denom?this._mapScaleToZoomLevel(e.layer_min_scale_denom):void 0,o=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,i=[t,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max(...i):void 0,maxZoom:s.length?Math.min(...s):void 0}}_init(e){this.initItem(e).then((()=>{this.emitter.emit("init")}))}_sumUp(e,t=0){for(const r of e)"layer"===r.item_type?(t+=1,r.draw_order_position=r.draw_order_position||t):"group"===r.item_type&&(t=this._sumUp(r.children,t));return t}};Bn(qn,"GetAdapterFromLayerType",{}),Bn(qn,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return hn(e.item,(e=>"layer_enabled"in e&&e.layer_enabled),(e=>e.children));if("layer"===e.item.item_type)return e.item.layer_enabled}return!1},onSet(e,t,r){r&&"layer"===r.item.item_type&&(r.layer&&(e?r.webMap.showLayer(r.layer):r.webMap.hideLayer(r.layer)),r.item.layer_enabled=e)}},{name:"opacity",handler:class extends Wr{getProperty(){const e=this.item.layer;return e&&e&&e.options&&null!=e.options.opacity?e.options.opacity:1}update(e,t){if(t=t||{},this.isGroup()){this._value=this._prepareValue(e,t);const r=this.getChildren();for(const n of r){const r=n.properties.property(this.name);r&&(t.propagation?r.set(e,t):r.update(r.get(),t))}}const r=this.item.layer;if(r){const t=this.getParents().reduce(((e,t)=>{const r=t.properties.property(this.name);return e*(r?r.getValue():1)}),1);this.item.webMap.setLayerOpacity(r,this._prepareValue(e*t))}}_prepareValue(e,t){return t&&t.propagation&&this.isGroup()?1:Number(e)}}}]});let Dn=qn;var Un=Object.defineProperty,Vn=Object.defineProperties,Gn=Object.getOwnPropertyDescriptors,zn=Object.getOwnPropertySymbols,Zn=Object.prototype.hasOwnProperty,Wn=Object.prototype.propertyIsEnumerable,Hn=(e,t,r)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Jn=(e,t)=>{for(var r in t||(t={}))Zn.call(t,r)&&Hn(e,r,t[r]);if(zn)for(var r of zn(t))Wn.call(t,r)&&Hn(e,r,t[r]);return e},Qn=(e,t,r)=>Hn(e,"symbol"!=typeof t?t+"":t,r),Kn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Xn{constructor(e,t){this.map=e,this.options=t,Qn(this,"layer"),Qn(this,"NgwWebmapItem",Dn),Qn(this,"pixelRadius",10),Qn(this,"resourceId"),Qn(this,"webmapClassName","webmap"),Qn(this,"emitter",new C),Qn(this,"_extent"),Qn(this,"webmapResource"),Qn(this,"_webmapBaselayersIds",[]),Qn(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 Kn(this,null,(function*(){var t;this.options=Jn(Jn({},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 Kn(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)}))}hideLayer(){return Kn(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)}))}setOpacity(e){return Kn(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 wt(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.webmapResource;if(e&&e.bookmark_resource)return e.bookmark_resource.id}fetchBookmarks(e){const t=this.getBookmarksResourceId(),r=this.options.connector;if(t)return r.getResourceOrFail(t,e).then((n=>{var o;const i=null==(o=n.feature_layer)?void 0:o.fields.find((e=>e.label_field)),s=i&&i.keyname;return Pr(Jn({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then((e=>{const n=[];for(const o of e){const e=new Gr({item:o,resourceId:t,labelField:s,connector:r});n.push(e)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(e){return Kn(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 Kn(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 Kn(this,null,(function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise((t=>{var r;const n=this.options.connector,o=(null==n?void 0:n.options.auth)?n.getAuthorizationHeaders():void 0,i=n.withCredentials,s=(a=Jn({},this.options),l={withCredentials:i,headers:o,drawOrderEnabled:null!=(r=e.draw_order_enabled)&&r},Vn(a,Gn(l)));var a,l;const c=new this.NgwWebmapItem(this.options.webMap,e.root_item,s,n);c.emitter.on("init",(()=>{t(c)}))})):void 0}))}getWebMapConfig(e){return Kn(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)Ft({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then((e=>{const o=!r&&n.enabled;return n.enabled&&(r=!0),t.addBaseLayer(e,{id:"webmap-baselayer"+n.resource_id,name:n.display_name,opacity:n.opacity,visibility:o}).then((e=>{e.id&&this._webmapBaselayersIds.push(e.id)}))}))}_updateItemsParams(e,t,r){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"),o=r.layer_style_id;r.url=n,r.resourceId=o,r.updateWmsParams=e=>co(e,o);const i=xr({options:{adapter:r.layer_adapter.toUpperCase(),resource:o},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=Jn(Jn({},r),i)}return e}}var Yn=Object.defineProperty,eo=Object.defineProperties,to=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertySymbols,no=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable,io=(e,t,r)=>t in e?Yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,so=(e,t)=>{for(var r in t||(t={}))no.call(t,r)&&io(e,r,t[r]);if(ro)for(var r of ro(t))oo.call(t,r)&&io(e,r,t[r]);return e},ao=(e,t)=>eo(e,to(t)),lo=(e,t)=>{var r={};for(var n in e)no.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&ro)for(var n of ro(e))t.indexOf(n)<0&&oo.call(e,n)&&(r[n]=e[n]);return r};function co(e,t){const r=e,{bbox:n,width:o,height:i,nd:s}=r,a=lo(r,["bbox","width","height","nd"]);return ao(so({},a),{resource:Array.isArray(t)?t.join(","):t,extent:n,size:o+","+i,timestamp:Date.now(),nd:null!=s?s:200})}const uo={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 ho;const po={tms:"TILE"};var fo=Object.defineProperty,yo=Object.getOwnPropertySymbols,mo=Object.prototype.hasOwnProperty,bo=Object.prototype.propertyIsEnumerable,go=(e,t,r)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vo=(e,t)=>{for(var r in t||(t={}))mo.call(t,r)&&go(e,r,t[r]);if(yo)for(var r of yo(t))bo.call(t,r)&&go(e,r,t[r]);return e},wo=(e,t,r)=>go(e,"symbol"!=typeof t?t+"":t,r);const _o="https://qms.nextgis.com";function Oo(e,t=_o,r={}){let n;if("webMap"in e){const o=e,{webMap:i,url:s}=o,a=((e,t)=>{var r={};for(var n in e)mo.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&yo)for(var n of yo(e))t.indexOf(n)<0&&bo.call(e,n)&&(r[n]=e[n]);return r})(o,["webMap","url"]);n=i,s&&(t=s),a&&(r=a)}else n=e;t||(t=_o);class o{constructor(e,t){wo(this,"qms"),wo(this,"options"),wo(this,"map"),this.map=e;const n=vo(vo({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,i=null,s=function*(){if(!this.qms&&e.qmsId)try{this.qms=yield function(e){return new Promise(((t,r)=>{const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState&&200===n.status&&n.responseText)try{t(JSON.parse(n.responseText))}catch(e){r(e)}},n.open("GET",m(e),!0),n.send()}))}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=po[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(i=o,s=a,["showLayer","hideLayer"].forEach((e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(i.prototype,e,t)})),"TILE"===t)){if(e=vo(vo({order:0,maxZoom:n.options.maxZoom,minZoom:n.options.minZoom},this.options),function(e){const t=("https:"===location.protocol?"https":"http")+"://";let r=e.url.replace(/^(https?|ftp):\/\//,t);return e.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:e.name,attribution:e.copyright_text,maxZoom:e.z_max,minZoom:e.z_min}}(r)),r.origin_url){const[t,n]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,((e,r)=>("string"==typeof r&&r.split(",").forEach((e=>t.push(e))),"{s}"))),t]}(r.origin_url);n.length&&(e.subdomains=n,e.url=t)}return this.options=e,new a(this.map,e).addLayer(e)}}var i,s},new Promise(((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},o=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,o);a((s=s.apply(r,i)).next())}));var r,i,s}}return o}var Lo=Object.defineProperty,Po=Object.getOwnPropertySymbols,Io=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,jo=(e,t,r)=>t in e?Lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Eo=(e,t)=>{for(var r in t||(t={}))Io.call(t,r)&&jo(e,r,t[r]);if(Po)for(var r of Po(t))xo.call(t,r)&&jo(e,r,t[r]);return e},Ao=(e,t,r)=>jo(e,"symbol"!=typeof t?t+"":t,r);class Co{constructor(e){Ao(this,"options",{url:"https://qms.nextgis.com"}),Ao(this,"url"),this.options=Eo(Eo({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return Oo({webMap:e,url:this.url})}}Ao(Co,"utils",{createQmsAdapter:Oo});var ko=Object.defineProperty,Mo=Object.defineProperties,So=Object.getOwnPropertyDescriptors,No=Object.getOwnPropertySymbols,To=Object.getPrototypeOf,Ro=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,Bo=Reflect.get,$o=(e,t,r)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qo=(e,t)=>{for(var r in t||(t={}))Ro.call(t,r)&&$o(e,r,t[r]);if(No)for(var r of No(t))Fo.call(t,r)&&$o(e,r,t[r]);return e},Do=(e,t)=>Mo(e,So(t)),Uo=(e,t,r)=>Bo(To(e),r,t),Vo=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));var Go=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function zo(e){return function(e){return Go(this,null,(function*(){const t=yield Pr(e),r=[];return t.forEach((e=>{r.push(sr(e))})),r}))}(e).then((e=>({type:"FeatureCollection",features:e})))}const Zo=["fields","intersects","limit","orderBy","strategy"];function Wo(e){const t={};return Zo.forEach((r=>{const n=e[r];void 0!==n&&(t[r]=n)})),t}var Ho=Object.defineProperty,Jo=Object.defineProperties,Qo=Object.getOwnPropertyDescriptors,Ko=Object.getOwnPropertySymbols,Xo=Object.getPrototypeOf,Yo=Object.prototype.hasOwnProperty,ei=Object.prototype.propertyIsEnumerable,ti=Reflect.get,ri=(e,t,r)=>t in e?Ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ni=(e,t)=>{for(var r in t||(t={}))Yo.call(t,r)&&ri(e,r,t[r]);if(Ko)for(var r of Ko(t))ei.call(t,r)&&ri(e,r,t[r]);return e},oi=(e,t)=>Jo(e,Qo(t)),ii=(e,t,r)=>ri(e,"symbol"!=typeof t?t+"":t,r),si=(e,t,r)=>ti(Xo(e),r,t),ai=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function li(e){return ai(this,null,(function*(){var t,r;const{item:n,webMap:o,Adapter:i,connector:s,layerOptions:a,addLayerOptionsPriority:l}=e,c=null==l||l,u=a,h=i||a.Adapter||o.mapAdapter.layerAdapters.GEOJSON,p=[];let d,f,y=!1;const m=yield Et(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)=>ai(this,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},zo(ni({resourceId:m,filters:e,connector:s,cache:!0},t))}));let g=!1;const v=()=>{f&&(f.abort(),f=void 0)};class w extends h{constructor(){super(...arguments),ii(this,"emitter",new C),ii(this,"__onMapMove"),ii(this,"__onMapMoveStart"),ii(this,"__enableMapMoveListener"),ii(this,"__disableMapMoveListener")}addLayer(e){return ai(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=uo[n.vector_layer.geometry_type]),u.adapterOptions&&(e=c?ni(ni({},u.adapterOptions),e):ni(ni({},e),u.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const o=e.strategy||void 0;this.options.strategy=o;const i=si(w.prototype,this,"addLayer").call(this,e);let s;return d={filters:e.propertiesFilter,options:Wo(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),o&&o.startsWith("BBOX")&&!y&&this._addBboxEventListener(),i}))}getExtent(){return this.getBounds()}getBounds(){return ai(this,null,(function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?Ot({connector:s,resourceId:n.resource.id}):si(w.prototype,this,"getBounds")?si(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 ai(this,null,(function*(){var t;const r=e||d||{};if(null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield o.onLoad("create"),r.options=r.options||{},r.options.intersects=o.getBounds();const{minZoom:e,maxZoom:t}=this.options,n=o.getZoom();if(void 0!==n){if(void 0!==e&&n<e)return;if(void 0!==t&&n>t)return;if(y)return}}if(!g){try{this.emitter.emit("preupdate",r),o._emitLayerEvent("layer:preupdate",u.id||"",r);const e=yield b(r.filters,oi(ni({},r.options),{srs:this.options.srs}));let t=e;const n=yield this.getCount();if("BBOX+"===this.options.strategy){t={type:"FeatureCollection",features:[]};for(const r of e.features)-1===p.indexOf(String(r.id))&&(p.push(String(r.id)),t.features.push(r));y=void 0!==n&&p.length>=n,yield o.addLayerData(this,t)}else y=void 0!==n&&e.features.length>=n,yield o.setLayerData(this,e);this.emitter.emit("updated",e),o._emitLayerEvent("layer:updated",u.id||"",{data:e,newData:t,isFull:y})}catch(n){if(n instanceof Error&&"AbortError"!==n.name)throw n}si(w.prototype,this,"updateLayer")&&si(w.prototype,this,"updateLayer").call(this)}}))}propertiesFilter(e,t){return ai(this,null,(function*(){if(v(),this.filter&&y)this.filter((t=>{const r=t.feature&&t.feature.properties&&dr(ni({},t.feature.properties));return!r||Wt(r,e)}));else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(e,oi(ni({},t),{srs:this.options.srs}));this.setData(r)}}))}removeFilter(){d=void 0,this.propertiesFilter([]),this.filter&&this.filter((()=>!0))}_addBboxEventListener(){this.__enableMapMoveListener=e=>{e===this&&(this._removeMoveEventListener(),this.updateLayer(),this._addMoveEventListener())},this.__disableMapMoveListener=e=>{e===this&&this._removeMoveEventListener()},o.emitter.on("layer:show",this.__enableMapMoveListener),o.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&o.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&o.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...o){n.clear(),r=setTimeout((()=>{r=null,e.apply(this,o)}),t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}((()=>this.updateLayer())),this.__onMapMoveStart=v,o.emitter.on("movestart",this.__onMapMoveStart),o.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&o.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&o.emitter.removeListener("movestart",this.__onMapMoveStart)}}return w}))}var ci=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));var ui=Object.defineProperty,hi=Object.defineProperties,pi=Object.getOwnPropertyDescriptors,di=Object.getOwnPropertySymbols,fi=Object.prototype.hasOwnProperty,yi=Object.prototype.propertyIsEnumerable,mi=(e,t,r)=>t in e?ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bi=(e,t)=>{for(var r in t||(t={}))fi.call(t,r)&&mi(e,r,t[r]);if(di)for(var r of di(t))yi.call(t,r)&&mi(e,r,t[r]);return e},gi=(e,t)=>hi(e,pi(t)),vi=(e,t,r)=>mi(e,"symbol"!=typeof t?t+"":t,r),wi=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class _i{constructor({layerId:e,legend:t,onSymbolRenderChange:r}){vi(this,"layerId"),vi(this,"legend"),vi(this,"onSymbolRenderChange"),this.layerId=e,this.legend=this.createLegend(t),this.onSymbolRenderChange=r}createLegend(e){return e.map((e=>gi(bi({},e),{name:e.display_name,symbol:e.icon})))}setSymbolRender(e,t){const r=this.legend.find((t=>t.index===e));if(r){r.render!==t&&(r.render=t,this.onSymbolRenderChange&&this.onSymbolRenderChange(this.legend.filter((e=>e.render)).map((e=>e.index))))}}}function Oi(e){return wi(this,arguments,(function*({layerOptions:e,connector:t,webMap:r,item:o}){const i=o.resource.cls;let s=e.adapter||i&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[i]||"IMAGE";if(void 0!==s&&(e.adapter=s),"IMAGE"===s){const e=r.getLayerAdapters();!e||e.IMAGE||(s="TILE")}const a=r.mapAdapter.layerAdapters[s];if(a){const i=yield Et(e,t);return class extends a{constructor(s,a){super(s,a),this.map=s,vi(this,"item",o),vi(this,"resourceId",i),vi(this,"_blocked",!1),vi(this,"_layerVisibility");const l=xr({options:e,webMap:r,baseUrl:t.options.baseUrl||""});if(l){const t=gi(bi(bi({},l),e.adapterOptions),{params:{resource:i},layers:l.layers||String(i),resourceId:i});e.adapterOptions&&n(e.adapterOptions.setViewDelay)&&(t.setViewDelay=e.adapterOptions.setViewDelay),this.options=bi(bi({},this.options),t)}}addLayer(e){return super.addLayer(bi(bi({},this.options),e))}showLayer(){this._layerVisibility=!0,this.layer&&(this._blocked||r.mapAdapter.showLayer(this.layer))}hideLayer(){this._layerVisibility=!1,this.layer&&r.mapAdapter.hideLayer(this.layer)}getIdentificationIds(){return wi(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 wi(this,null,(function*(){const r=this.options.id;if(void 0!==r){const n=yield t.route("render.legend_symbols",{id:i}).get(bi({cache:!0},e));return[new _i({layerId:r,legend:n,onSymbolRenderChange:this._setLegendSymbol.bind(this)})]}return[]}))}_hideLayer(){this.options.id&&r.mapAdapter.hideLayer(this.layer)}_showLayer(){this.options.id&&this._layerVisibility&&r.showLayer(this.options.id,{silent:!0})}_setLegendSymbol(e){const t=this._consolidateIntervals(e);t.length?(this._blocked=!1,this._showLayer()):(this._hideLayer(),this._blocked=!0),this.updateLayer&&this.updateLayer({params:{[`symbols[${i}]`]:t.join(",")||void 0}})}_consolidateIntervals(e){const t=e.slice().sort(((e,t)=>e-t)),r=[];let n=t[0],o=n;for(let i=1;i<=t.length;i++)t[i]===o+1?o=t[i]:(r.push(n===o?`${n}`:`${n}-${o}`),n=t[i],o=n);return r}}}throw new Error(s+" not supported yet. Only TILE")}))}var Li=Object.defineProperty,Pi=Object.defineProperties,Ii=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertySymbols,ji=Object.prototype.hasOwnProperty,Ei=Object.prototype.propertyIsEnumerable,Ai=(e,t,r)=>t in e?Li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ci=(e,t)=>{for(var r in t||(t={}))ji.call(t,r)&&Ai(e,r,t[r]);if(xi)for(var r of xi(t))Ei.call(t,r)&&Ai(e,r,t[r]);return e},ki=(e,t)=>Pi(e,Ii(t)),Mi=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Si={},Ni=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Ti(e){return Mi(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const o=n.resource.id,i=yield r.getResourceChildren(o),s=i&&i[0];if(s)return Ri(ki(Ci({},e),{resource:s.resource.id}),t,r)}))}function Ri(e,r,n){return Mi(this,null,(function*(){let o,i;const s=e.adapter,a=yield Et(e,n);if(a){const t=e.resource;if(i=t&&t.resource&&void 0!==t.resource.id?t:yield n.getResource(a),!i)throw"Resource item is not found";{const t=i.resource.cls,l={layerOptions:ki(Ci({},e),{resource:a}),connector:n,webMap:r,item:i};if(-1!==Ni.indexOf(t))if("webmap"===t)o=function(e){return ci(this,arguments,(function*({layerOptions:e,webMap:t,connector:r}){const n=yield Et(e,r);return class extends Xn{constructor(e){super(e,{url:"",webMap:t,resourceId:n,connector:r})}}}))}(l);else if("vector_layer"===t||"postgis_layer"===t){const t=l.layerOptions.adapterOptions||{};if(t.type=t.type||i.vector_layer&&uo[i.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==s&&"GEOJSON"!==s){if("MVT"!==s)return Ti(l);o=Oi(l)}else o=li(l)}else{if("raster_layer"===t)return Ti(l);if("basemap_layer"===t)o=function(e){return Vo(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(Co.utils.createQmsAdapter(e,void 0,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return Vo(this,null,(function*(){if(n)return Uo(e.prototype,this,"addLayer").call(this,Do(qo({},t),{url:n}))}))}}return e}}}}))}(l);else if("GEOJSON"===s&&i.resource.parent){const t=yield n.getResource(i.resource.parent.id);if(t){const r=ki(Ci({},e),{resource:i.resource.parent.id});o=li(ki(Ci({},l),{item:t,layerOptions:r}))}}else o=Oi(l)}else{if(!Si[t])throw`Resource class '${t}' not yet supported.`;{const e=Si[t];let r;r=s&&"function"!=typeof r?e[s]:e,r&&(o=r(l))}}}}if(o)return o.then((e=>{if(e){const r=e;return i&&(r.prototype.item=i,r.prototype.resourceId=i.resource.id,r.prototype.connector=n),t(r,[jt],{replace:!1}),r}}))}))}var Fi=Object.defineProperty,Bi=Object.getOwnPropertySymbols,$i=Object.prototype.hasOwnProperty,qi=Object.prototype.propertyIsEnumerable,Di=(e,t,r)=>t in e?Fi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ui=(e,t)=>{for(var r in t||(t={}))$i.call(t,r)&&Di(e,r,t[r]);if(Bi)for(var r of Bi(t))qi.call(t,r)&&Di(e,r,t[r]);return e},Vi=(e,t,r)=>Di(e,"symbol"!=typeof t?t+"":t,r);class Gi{constructor(e){if(this.options=e,Vi(this,"url"),Vi(this,"connector"),Vi(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 ut({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){Si[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(Xn,Ui({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}getLayerAdapters(){return Promise.resolve([this._getLayerAdapter()])}_getLayerAdapter(){return{name:"WEBMAP",createAdapter:e=>Promise.resolve(this._createAdapter(e))}}_createAdapter(e){return t={webMap:e,connector:this.connector,baseUrl:this.url},class extends Xn{constructor(e,r){super(e,r=so(so({},t),r))}};var t}}var zi=Object.defineProperty,Zi=Object.getOwnPropertySymbols,Wi=Object.prototype.hasOwnProperty,Hi=Object.prototype.propertyIsEnumerable,Ji=(e,t,r)=>t in e?zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qi=(e,t)=>{for(var r in t||(t={}))Wi.call(t,r)&&Ji(e,r,t[r]);if(Zi)for(var r of Zi(t))Hi.call(t,r)&&Ji(e,r,t[r]);return e},Ki=(e,t,r)=>Ji(e,"symbol"!=typeof t?t+"":t,r);class Xi{constructor(e){Ki(this,"id"),Ki(this,"label"),Ki(this,"layerId"),Ki(this,"parent"),Ki(this,"fields"),Ki(this,"geom"),Ki(this,"extensions"),Ki(this,"connector"),Ki(this,"_item"),Ki(this,"_geojson"),Ki(this,"_resource"),Ki(this,"_extent");const t=e.feature;this.id=t.id,this.geom=t.geom,this.label=t.label,this.parent=t.parent,this.fields=t.fields,this.layerId=t.layerId,this.connector=e.connector}identify(e={}){return this._item?Promise.resolve(this._item):Fr(Qi({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 t=this,r=null,n=function*(){if(this._resource&&this._resource.feature_layer)return this._resource.feature_layer;const t=yield this.connector.getResource(this.layerId,e);if(!(null==t?void 0:t.feature_layer))throw new Error("Resource is not avector layer");return this._resource=t,t.feature_layer},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}getBounds(e){return this._extent?Promise.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0,signal:o}){return r.route("feature_layer.feature.item_extent",{id:Number(e),fid:t}).get({cache:n,signal:o}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}(Qi({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 Yi(e){return t=this,r=null,n=function*(){return sr(yield Fr(e))},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}function es(e,t){return r=this,n=null,o=function*(){var r,n;const o=yield e.route("pyramid.settings").get({query:{component:"pyramid"}});if(o&&o.company_logo&&o.company_logo.enabled){const s=document.createElement("a");s.style.position="absolute",s.style.bottom="0",s.style.right="0",s.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",s.className="ngw-map-logo",t&&t.cssClass&&(s.className+=" "+t.cssClass);const a=new Image;a.style.maxHeight="100px",a.style.maxWidth="100px",a.src="";try{const t=null==(n=(yield e.route("pyramid.csettings").get()).pyramid)?void 0:n.header_logo;if(t){const[e,r]=t,n=atob(r),o=new Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);const i=new Uint8Array(o),s=new Blob([i],{type:e}),l=(window.URL||window.webkitURL).createObjectURL(s);a.src=l}}catch(i){console.warn(i)}return null!==o.company_logo.link&&""!==o.company_logo.link.trim()&&(s.href=o.company_logo.link,s.target="_blank",-1!==o.company_logo.link.search(/:\/\/nextgis/)&&(a.alt="Get your own Web GIS at nextgis.com")),s.appendChild(a),s}},new Promise(((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())}));var r,n,o}var ts=Object.defineProperty,rs=Object.defineProperties,ns=Object.getOwnPropertyDescriptors,os=Object.getOwnPropertySymbols,is=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable,as=(e,t,r)=>t in e?ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ls=(e,t)=>{for(var r in t||(t={}))is.call(t,r)&&as(e,r,t[r]);if(os)for(var r of os(t))ss.call(t,r)&&as(e,r,t[r]);return e},cs=(e,t)=>rs(e,ns(t));function us(e,t=!1){const r=[],n=[];for(const i in e){const e=Number(i);isNaN(e)||r.push(e)}const o=e.resources;o&&r.sort(((e,t)=>o.indexOf(e)-o.indexOf(t)));for(let i=0;i<r.length;i++){const o=r[i],s=e[o];if("features"in s){const e=hs(s.features,Number(o),t);if(e.length&&(n.push(...e),!t))break}}return n}function hs(e,t,r){const n=[];for(const o of e){if(n.push({featureId:o.id,resourceId:t,feature:o}),!r)break}return n}function ps(e){const{geom:t,signal:r,cache:n,layers:o}=e,i="string"==typeof t?t:function(e){const t=function(e){var t;if(Array.isArray(e))return e;if("Feature"===e.type)return null==(t=e.geometry)?void 0:t.coordinates[0];if("Polygon"===e.type)return e.coordinates[0];return null}(e);if(!t)return null;return`POLYGON((${t.map((([e,t])=>{const[r,n]=s(e,t);return`${r} ${n}`})).join(",")}))`}(t);if(!i)throw new Error("Not valid geometry format to make intersection");const a={geom:i,srs:3857,layers:o};return e.connector.route("feature_layer.identify").post({json:a,signal:r,cache:n})}const ds={};function fs(e){return ds[e]}function ys(e,t){ds[e]=t}function ms(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const o=t.title||"",i=t.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function l(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(e,t){e.split(" ").forEach((e=>{t?r.classList.add(e):r.classList.remove(e)}))}function u(){t.addClassOn&&c(t.addClassOn,n),t.addClassOff&&c(t.addClassOff,!n)}s(),l(),t.addClass&&c(t.addClass,!0),u();const h=e=>{void 0!==e&&(n=e),l(),s(),u()},p=e=>{if(n=void 0!==e?e:!n,t.onClick){const e=t.onClick(n);Promise.resolve(e).then((()=>h())).catch((()=>n=!n))}else h()},d=e({html:r,onClick:p});return d.onClick=p,d.changeStatus=h,d}function bs(e){return(t,r)=>{const n=t.map((e=>e()));return e(n,r)}}const gs={"!":bs((function([e]){return!e})),"!=":bs((function([e,t]){return e!==t})),"<":bs((function([e,t]){return e<t})),"<=":bs((function([e,t]){return e<=t})),"==":bs((function([e,t]){return e===t})),">":bs((function([e,t]){return e>t})),">=":bs((function([e,t]){return e>=t})),coalesce:e=>{for(let t=0;t<e.length;t++){const r=e[t]();if(null!=r)return r}return null},all:e=>{for(let t=0;t<e.length;t++){if(!e[t]())return!1}return!0},any:e=>{for(let t=0;t<e.length;t++){if(e[t]())return!0}return!1},case:e=>{if(e.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(e.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(let t=0;t<e.length-1;t+=2){const r=e[t](),n=e[t+1]();if(r)return n}return(0,e[e.length-1])()},match:e=>{const[t,...r]=e,n=t(),o=r.splice(-1,r.length%2)[0];for(let i=0;i<r.length-1;i+=2){if(r[i]()===n)return r[i+1]()}return o()}},vs={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 ws(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return _s(e);if("string"==typeof(t=e)&&t in vs)return function(e){return _s(vs[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 _s(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 Os(e,t,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(e-t)/(n-t)*(o-r);try{const i=ws(r),s=ws(o);return function(e){return`rgb(${e.join(",")})`}(i.map(((r,o)=>Math.ceil(Os(e,t,r,n,s[o])))))}catch(i){console.log(i)}throw new Error("Unsupported output type for linear interpolation.")}const Ls={step:e=>{const[t,r,...n]=e,o=t();if("number"!=typeof o)return r();for(let i=0;i<n.length-2;i+=2){const e=n[i](),t=n[i+1](),r=n[i+2]();if(o>=e&&o<r)return t}return o>=n[n.length-2]()?n[n.length-1]():r()},interpolate:([e,t,...r])=>{if(r.length<2)throw new Error("At least two stops are required");if(r.length<2||r.length%2!=0)throw new Error("Invalid stops provided.");const n=t();if("number"!=typeof n)throw new Error("Input must be a number.");const o=e();for(let i=0;i<r.length-2;i+=2){const e=r[i](),t=r[i+1](),s=r[i+2](),a=r[i+3]();if(n>=e&&n<=s&&"linear"===o[0])return Os(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Ps={get:bs((function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null})),length:bs((([e])=>{if("string"==typeof e||Array.isArray(e))return e.length})),at:bs((function([e,t]){return t[e]})),has:bs((function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))})),in:bs((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":bs((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:bs((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}.`)}))},Is={"+":bs((e=>e.reduce(((e,t)=>e+t),0))),"-":bs((e=>e.reduce(((e,t)=>e-t)))),"*":bs((e=>e.reduce(((e,t)=>e*t),1))),"/":bs((e=>e.reduce(((e,t)=>e/t)))),"%":bs((e=>e[0]%e[1])),"^":bs((e=>Math.pow(e[0],e[1]))),abs:bs((e=>Math.abs(e[0]))),acos:bs((e=>Math.acos(e[0]))),asin:bs((e=>Math.asin(e[0]))),atan:bs((e=>Math.atan(e[0]))),ceil:bs((e=>Math.ceil(e[0]))),cos:bs((e=>Math.cos(e[0]))),e:()=>Math.E,floor:bs((e=>Math.floor(e[0]))),ln:bs((e=>Math.log(e[0]))),ln2:()=>Math.LN2,log10:bs((e=>Math.log10(e[0]))),log2:bs((e=>Math.log2(e[0]))),max:bs((e=>Math.max(...e))),min:bs((e=>Math.min(...e))),pi:()=>Math.PI,round:bs((e=>Math.round(e[0]))),sin:bs((e=>Math.sin(e[0]))),sqrt:bs((e=>Math.sqrt(e[0]))),tan:bs((e=>Math.tan(e[0])))},xs={concat:bs((e=>e.reduce(((e,t)=>String(e)+String(t)),""))),downcase:bs((e=>String(e[0]).toLowerCase())),upcase:bs((e=>String(e[0]).toUpperCase()))},js=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function Es(e){return(t,r)=>{for(const n of t){const t=js(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const As={array:bs((e=>{const[t,r,n]=e;let o,i,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(o=t,"number"==typeof r?(i=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(o&&!s.every((e=>typeof e===o)))throw new Error(`Expected all items in array to be of type ${o}`);if(i&&s.length!==i)throw new Error(`Expected array of length ${i}`);return s})),boolean:bs(Es((e=>"boolean"==typeof e?e:void 0))),literal:bs((([e])=>e)),number:bs(Es((e=>"number"==typeof e?e:void 0))),object:bs(Es((e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e))),string:bs(Es((e=>"string"==typeof e?e:void 0))),"to-boolean":bs(Es(Boolean)),"to-number":bs(Es(Number)),"to-string":bs(Es(String)),typeof:bs((([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 Cs=Object.defineProperty,ks=Object.getOwnPropertySymbols,Ms=Object.prototype.hasOwnProperty,Ss=Object.prototype.propertyIsEnumerable,Ns=(e,t,r)=>t in e?Cs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ts=(e,t)=>{for(var r in t||(t={}))Ms.call(t,r)&&Ns(e,r,t[r]);if(ks)for(var r of ks(t))Ss.call(t,r)&&Ns(e,r,t[r]);return e};function Rs(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in Fs&&r.length>0}return!1}const Fs=Ts(Ts(Ts(Ts(Ts(Ts({},Is),As),xs),Ps),gs),Ls);function Bs(e,t={}){const[r,...n]=e,o=Fs[r];if(o)return o(n.map((e=>()=>Rs(e)?Bs(e,t):e)),t);throw new Error(`Expression "${r}" is not supported.`)}var $s=Object.defineProperty,qs=Object.getOwnPropertySymbols,Ds=Object.prototype.hasOwnProperty,Us=Object.prototype.propertyIsEnumerable,Vs=(e,t,r)=>t in e?$s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Gs=(e,t)=>{for(var r in t||(t={}))Ds.call(t,r)&&Vs(e,r,t[r]);if(qs)for(var r of qs(t))Us.call(t,r)&&Vs(e,r,t[r]);return e};function zs(e){return t=>{const r=t.properties;return!!r&&Bs(e,r)}}const Zs=["iconSize","iconAnchor"];function Ws(e){return"function"==typeof e}var Hs=Object.defineProperty,Js=Object.getOwnPropertySymbols,Qs=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable,Xs=(e,t,r)=>t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ys=(e,t)=>{for(var r in t||(t={}))Qs.call(t,r)&&Xs(e,r,t[r]);if(Js)for(var r of Js(t))Ks.call(t,r)&&Xs(e,r,t[r]);return e};function ea(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=>Zt(e,t[0])));return n?Ys(Ys({},t),n[1]):t}}function ta({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===Zs.indexOf(n)){const o=n,i=e[o];Rs(i)&&(t=!0,r[o]=zs(i))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return Gs(Gs({},e),n)}}(e);if(r){const n=e=>na({paint:r(e),defaultPaint:t});return n.paint=ra({paint:e,defaultPaint:t}),n}return ra({paint:e,defaultPaint:t})}function ra({paint:e,defaultPaint:t}){var r;let n=Ys({},t);return n=Ys(Ys({},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 na({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=Ys({},t);if(Ws(e)){const n=n=>{const o=na({paint:e(n),defaultPaint:t,getPaintFunctions:r});return o.type=e.type,o};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>na({paint:ea(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const o=function(e,t){if("function"==typeof e.from)return e.from(e.options);if("string"==typeof e.from&&t){const r=t[e.from];if(r)return r(e.options)}}(e,r);o&&(n=na({paint:o,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=ta({paint:e,defaultPaint:t})}return Ws(n)||("color"in n&&(n.strokeColor||(n.strokeColor=n.color),n.fillColor||(n.fillColor=n.color)),"opacity"in n&&(void 0===n.strokeOpacity&&(n.strokeOpacity=n.opacity),void 0===n.fillOpacity&&(n.fillOpacity=n.opacity))),n}function oa(e){const t={};for(let n=0;n<e.length;n++)t[e[n]]=1+(t[e[n]]||0);let r;for(const n in t){t[n]>((void 0!==r?t[r]:0)||0)&&(r=n)}return r}function ia(e){let t;if("FeatureCollection"===e.type){t=oa(e.features.map((e=>e.geometry.type)))}else if("GeometryCollection"===e.type){t=oa(e.geometries.map((e=>e.type)))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const sa={polygon:"path",line:"path",point:"circle"},aa={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function la(e){if(e.data){const t=aa[ia(e.data)],r=e.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===t||"line"===t?"path":"html"in r||"className"in r?"icon":sa[t]),e.type=e.type||t}return e}var ca=Object.defineProperty,ua=(e,t,r)=>((e,t,r)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ha{constructor(){ua(this,"backspace",8),ua(this,"tab",9),ua(this,"enter",13),ua(this,"shift",16),ua(this,"ctrl",17),ua(this,"alt",18),ua(this,"pause/break",19),ua(this,"caps_lock",20),ua(this,"escape",27),ua(this,"page_up",33),ua(this,"page_down",34),ua(this,"end",35),ua(this,"home",36),ua(this,"left_arrow",37),ua(this,"up_arrow",38),ua(this,"right_arrow",39),ua(this,"down_arrow",40),ua(this,"insert",45),ua(this,"delete",46),ua(this,"left_window_key",91),ua(this,"right_window_key",92),ua(this,"select_key",93),ua(this,"numpad_0",96),ua(this,"numpad_1",97),ua(this,"numpad_2",98),ua(this,"numpad_3",99),ua(this,"numpad_4",100),ua(this,"numpad_5",101),ua(this,"numpad_6",102),ua(this,"numpad_7",103),ua(this,"numpad_8",104),ua(this,"numpad_9",105),ua(this,"multiply",106),ua(this,"add",107),ua(this,"subtract",109),ua(this,"decimal_point",110),ua(this,"divide",111),ua(this,"f1",112),ua(this,"f2",113),ua(this,"f3",114),ua(this,"f4",115),ua(this,"f5",116),ua(this,"f6",117),ua(this,"f7",118),ua(this,"f8",119),ua(this,"f9",120),ua(this,"f10",121),ua(this,"f11",122),ua(this,"f12",123),ua(this,"num_lock",144),ua(this,"scroll_lock",145),ua(this,"semi-colon",186),ua(this,"equal_sign",187),ua(this,",",188),ua(this,"-",189),ua(this,".",190),ua(this,"/",191),ua(this,"`",192),ua(this,"[",219),ua(this,"\\",220),ua(this,"]",221),ua(this,"'",222)}}var pa=Object.defineProperty,da=(e,t,r)=>((e,t,r)=>t in e?pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var fa=Object.defineProperty,ya=(e,t,r)=>((e,t,r)=>t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ma{constructor(e,t){this.webMap=e,ya(this,"name"),ya(this,"event"),ya(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 ba=Object.defineProperty,ga=(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 va extends ma{constructor(){super(...arguments),ga(this,"name","bounds"),ga(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 wa=Object.defineProperty,_a=(e,t,r)=>((e,t,r)=>t in e?wa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Oa extends ma{constructor(){super(...arguments),_a(this,"name","center"),_a(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 La=Object.defineProperty,Pa=(e,t,r)=>((e,t,r)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ia extends ma{constructor(){super(...arguments),Pa(this,"name","zoom"),Pa(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 xa=Object.defineProperty,ja=(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),Ea=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let Aa=0;const Ca={minZoom:0,maxZoom:22,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},ka=class e{constructor(t){ja(this,"options",Ca),ja(this,"emitter",new C),ja(this,"keys",e.keys),ja(this,"mapAdapter"),ja(this,"runtimeParams",[]),ja(this,"getPaintFunctions",e.getPaintFunctions),ja(this,"mapStateItems",[Oa,Ia,va]),ja(this,"id",Aa++),ja(this,"mapState",[]),ja(this,"_initMapState",{}),ja(this,"_starterKits"),ja(this,"_extent"),ja(this,"_eventsStatus",{}),ja(this,"_coordFromMapClickAbort"),ja(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(Ca||{},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 Ea(this,null,(function*(){return this.getEventStatus("create")||(yield this._setInitMapState(this.mapStateItems),yield this._setupMap(),this._emitStatusEvent("create",this)),this}))}setRuntimeParams(e){this.runtimeParams.push(e)}destroy(){this._removeEventListeners(),function(e){for(const t in e)delete e[t]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}mapStateWithFunc(e){const t={};return this.mapState.forEach((r=>{t[r.name]=e(r)})),t}getStateAsString(){return this.mapStateWithFunc((e=>e.toString()))}getState(){return this.mapStateWithFunc((e=>e.getValue()))}getRuntimeParams(){const e={};return this.mapState.forEach((t=>{for(const r of this.runtimeParams){const n=r.get(t.name);if(void 0!==n){e[t.name]=t.parse(n);break}}})),e}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const e=document.getElementById(this.options.target);if(e)return e}}}setCursor(e){this.onLoad().then((()=>{this.mapAdapter.setCursor&&this.mapAdapter.setCursor(e)}))}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const e=this.getContainer();return e?e.style.cursor:void 0}setCenter(e){return this.mapAdapter.setCenter(e),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const e=this.getBounds();if(e){return{type:"Feature",properties:{},geometry:a(e)}}}setZoom(e){return this.mapAdapter.setZoom(e),this}getZoom(){const e=this.mapAdapter.getZoom();if("number"==typeof e)return e}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e-1)}}}setView(e,t){if(Array.isArray(e)){const r=e;this.mapAdapter.setView&&r&&n(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),n(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return function(e){const[t,r,n,o]=e,i=t<n&&r<o;if(!i){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${o}]`);const e=[Math.min(t,n),Math.min(r,o),Math.max(t,n),Math.max(o,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&o<=90;s&&a||console.log("Warning: The coordinates may not be within valid geographic ranges.")}(e),e.every((e=>n(e)))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,t)),this}getEventStatus(e){const t=this._eventsStatus[e];return null!=t&&t}onLoad(e="create"){return new Promise((t=>{this.getEventStatus(e)?t(this):this.emitter.once(e,(()=>{t(this)}))}))}onMapLoad(e){return new Promise((t=>{var r;const n=()=>{const r=this.mapAdapter;e&&e(r),r&&t(r)},o=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&o?n():this.mapAdapter.emitter.once("create",(()=>{n()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(e){return this.mapAdapter.layerAdapters[e]}locate(e,t){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(e,t);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickAbort&&(this._coordFromMapClickAbort(),this._coordFromMapClickAbort=void 0)}getCoordFromMapClick(){return this._coordFromMapClickAbort?this.getCoordFromMapClick():new Promise(((e,t)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const n=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickAbort=void 0},o=t=>{n(),i(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),this._coordFromMapClickAbort=n}))}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return Ea(this,null,(function*(){}))}_onLoadSync(){return Ea(this,null,(function*(){}))}_setupMap(){return Ea(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)}))}};ja(ka,"keys",new class{constructor(){da(this,"keyCodeAlias",new ha),da(this,"keys",{}),da(this,"_windowOnFocus"),da(this,"_keysPressed"),da(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={}}}),ja(ka,"getPaintFunctions");let Ma=ka;var Sa=Object.defineProperty,Na=Object.defineProperties,Ta=Object.getOwnPropertyDescriptors,Ra=Object.getOwnPropertySymbols,Fa=Object.prototype.hasOwnProperty,Ba=Object.prototype.propertyIsEnumerable,$a=(e,t,r)=>t in e?Sa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qa=(e,t)=>{for(var r in t||(t={}))Fa.call(t,r)&&$a(e,r,t[r]);if(Ra)for(var r of Ra(t))Ba.call(t,r)&&$a(e,r,t[r]);return e},Da=(e,t)=>Na(e,Ta(t)),Ua=(e,t,r)=>$a(e,"symbol"!=typeof t?t+"":t,r),Va=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Ga extends Ma{constructor(e){super(e),Ua(this,"_layersIdCounter",1),Ua(this,"_layersOrderCounter",1),Ua(this,"_baselayers",[]),Ua(this,"_layers",{}),Ua(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(t)))}fitLayer(e,t){return Va(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 Va(this,null,(function*(){return yield this.addLayer(e,Da(qa({},t),{baselayer:!0}),void 0)}))}addLayer(e){return Va(this,arguments,(function*(e,t={},r){var o,i;const s=this._layersIdCounter++,a=n(r)?r:void 0!==t.order?t.order:this.reserveOrder();let l;"string"==typeof e?l=this.getLayerAdapter(e):"function"==typeof e?l=e:"then"in e&&(l=yield e);const c=t;this._updateGeoJsonOptions(c);const u=null==(o=(t=qa({id:String(s),order:a},t)).visibility)||o;if(t.visibility=!1,t.baselayer&&(t.order=0),this.options.onBeforeAddLayer){const e=this.options.onBeforeAddLayer({options:t,adapter:l});e&&(e.options&&(t=e.options),e.adapter&&(l=e.adapter))}if(void 0!==l){const e=new l(this.mapAdapter.map,t);let r;e.options=qa(qa({},t),e.options),e.options.baselayer&&(t.baselayer=!0,t.order=0,e.options.order=0),e.options.id&&(r=String(e.options.id),this._layers[r]=e),this._emitLayerEvent("layer:preadd",r||"",e),yield this.onMapLoad(),e.map=this.mapAdapter.map;const n=yield e.addLayer(e.options);if(e.layer=n,e.id=e.options.id||String(s),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(i=e.options.order)?i:a,r&&delete this._layers[r],r=String(e.id),this._layers[r])throw Error(`layer with id '${r}' already exist`);r&&(this._layers[r]=e,c.filter&&this.filterLayer(e,c.filter),t.baselayer&&this._baselayers.push(r),u&&(yield this.showLayer(r)));const o=t.opacity;null!=o&&o<=1&&this.setLayerOpacity(e,o);const h=n&&(e.getBounds||e.getExtent);if(t.fit&&h){const t=yield h.call(e);t&&(yield this.fitBounds(t))}return t.onAdded&&t.onAdded(e),this._emitLayerEvent("layer:add",r,e),e}return Promise.reject("No adapter")}))}addLayerFromAsyncAdapter(e,t,r){return Va(this,null,(function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),o=e(),i=yield o;return i?this.addLayer(i,t,n):Promise.reject("No adapter")}))}removeLayers(e){for(const t in this._layers){let r=!0;e&&(r=e(t,this._layers[t])),r&&(this.removeLayer(t),delete this._layers[t])}}getLegend(e){return Va(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=la(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",Da(qa({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",Da(qa({},t),{url:r}))}showLayer(e,t={}){return this.toggleLayer(e,!0,t)}hideLayer(e,t={}){return this.toggleLayer(e,!1,t)}toggleLayer(e,t,r={}){const n=this.getLayer(e),o=void 0!==t?t:!(n&&n.options.visibility),i=void 0!==r.silent&&r.silent,s=e=>Va(this,null,(function*(){const t=String(e.id),r=o?"layer:show":"layer:hide";if(i||(this._emitLayerEvent(o?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),o&&this.mapAdapter){const t=e.options.baselayer?0:e.options.order;if(e.options.baselayer&&this._baselayers.length){const t=this._baselayers.filter((t=>t!==e.id&&this.isLayerVisible(t)));for(const e of t)yield this.hideLayer(e)}e.showLayer?yield e.showLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.showLayer(e.layer)),void 0!==t&&this.mapAdapter.setLayerOrder(e.layer,t,this._layers)}else e.hideLayer?yield e.hideLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.hideLayer(e.layer));e.options.visibility=o,i||(this._emitLayerEvent(r,t,e),this._emitLayerEvent("layer:toggle",t,e))}));return n?this.onMapLoad().then((()=>s(n))):Promise.resolve()}updateLayer(e,t){const r=this.getLayer(e);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer(t));if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((()=>this.showLayer(r,{silent:!0})))}return Promise.resolve()}setLayerOpacity(e,t){const r=this.getLayer(e);r&&(r.setOpacity?r.setOpacity(t):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,t))}isLayerLabelVisible(e){var t;const r=this.getLayer(e);return r.isLabelVisible?r.isLabelVisible():null==(t=r.options.labelVisibility)||t}showLayerLabel(e){this.toggleLayerLabel(e,!0)}hideLayerLabel(e){this.toggleLayerLabel(e,!1)}toggleLayerLabel(e,t){const r=this.getLayer(e);return t=null!=t?t:!this.isLayerLabelVisible(e),r&&(t?r.showLabel&&(r.options.labelVisibility=!0,r.showLabel()):r.hideLabel&&(r.options.labelVisibility=!1,r.hideLabel()),r.id&&this._emitLayerEvent("layer:label:toggle",r.id,r)),t}selectLayer(e,t){const r=this.getLayer(e);if(r){r&&r.select&&r.select(t);const e=this.getLayerId(r);e&&this._selectedLayers.push(e)}}unSelectLayer(e,t){const r=this.getLayer(e);if(r){const e=r&&r;e.unselect&&e.unselect(t);const n=this.getLayerId(r);if(n){const e=this._selectedLayers.indexOf(n);-1!==e&&this._selectedLayers.splice(e,1)}}}unSelectLayers(){const e=Object.values(this.allLayers());let t;for(t of e)t.unselect&&t.unselect()}filterLayer(e,t){const r=this.getLayer(e);return r.filter?r.filter(t):[]}propertiesFilter(e,t,r){const n=this.getLayer(e);if(n){const e=n;if(e.propertiesFilter)return e.propertiesFilter(t,r);e.filter&&this.filterLayer(e,(e=>!e.feature||!e.feature.properties||Wt(e.feature.properties,t)))}return Promise.resolve()}removeLayerFilter(e){const t=this.getLayer(e);t.removeFilter?t.removeFilter():t.filter&&t.filter((()=>!0))}setLayerData(e,t){const r=this.getLayer(e);if(r){if(r.setData)return r.setData(t);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(t)}return Promise.resolve()}addLayerData(e,t){const r=this.getLayer(e);r.addData&&r.addData(t)}clearLayerData(e,t){const r=this.getLayer(e);r&&r.clearLayer&&r.clearLayer(t)}setLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.setPaint&&r.setPaint(t)}setLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.setSelectedPaint&&r.setSelectedPaint(t)}updateLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.updatePaint&&r.updatePaint(t)}updateLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(t)}getAttributions(e){const t=[];for(const r in this._layers){const n=this._layers[r];let o=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(o&&e.onlyBaselayer&&(o=this._baselayers.includes(r)),o){const e=n.options&&n.options.attribution;e&&t.push(e)}}return t}getActiveBaseLayer(){const e=this.getBaseLayers().find((e=>this.isLayerVisible(e)));if(e)return this.getLayer(e)}addTileJsonLayer(e){return this.addLayer("TILE",{url:e.tiles[0],maxZoom:e.maxzoom,minZoom:e.minzoom,subdomains:e.scheme,attribution:e.attribution})}_emitLayerEvent(e,t,r){const o=String(e);if(n(t)&&o.startsWith("layer:")){const e=o.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return Va(this,null,(function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerDoubleClick(e){return Va(this,null,(function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerSelect(e){return Va(this,null,(function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)}))}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:o,onDoubleClick:i,onLayerClick:s,onMouseOut:a,onMouseOver:l}=e,c=o||s,u=i||s;e.onClick=e=>(c&&c(e),this._onLayerClick(e)),e.onDoubleClick=e=>(u&&u(e),this._onLayerDoubleClick(e)),e.onMouseOut=e=>{const t=e.layer.id;a&&a(e),n(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;l&&l(e),n(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const h=t||r;e.onSelect=e=>(h&&h(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=na({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=na({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}var za=Object.defineProperty,Za=(e,t,r)=>((e,t,r)=>t in e?za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Wa=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Ha=class e extends Ga{constructor(){super(...arguments),Za(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),Za(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return Wa(this,null,(function*(){let n;if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,r):e,n)return new Promise((e=>{this._setControlQueue(t,(()=>Wa(this,null,(function*(){const r=yield n,o=this.mapAdapter.addControl(r,t);e(o)}))))}))}))}createControl(e,t){return Wa(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)}))}createButtonControl(e){return Wa(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)}))}createToggleControl(e){return Wa(this,null,(function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?ms(this.mapAdapter.createButtonControl,e):void 0}))}removeControl(e){"remove"in e?e.remove():this.mapAdapter.removeControl&&Promise.resolve(e).then((e=>{this.mapAdapter.removeControl(e)}))}getControl(t,r){const n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);{const n=e.controls[t];if(n)return n(this,r)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return Wa(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}))}};Za(Ha,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let Ja=Ha;var Qa=Object.getOwnPropertySymbols,Ka=Object.prototype.hasOwnProperty,Xa=Object.prototype.propertyIsEnumerable,Ya=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),el=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())})),tl=(e,t,r)=>(t=e[Ya("asyncIterator")])?t.call(e):(e=e[Ya("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:i})),o))))),r("next"),r("return"),t);class rl extends Ja{constructor(e){super(e),this._addControls(),ys(this.id,this)}static get(e){return fs(e)}_addLayerProviders(){return el(this,null,(function*(){try{for(var e,t,r,n=tl(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.getLayerAdapters){const t=yield e.getLayerAdapters.call(e);if(t)try{for(var o,i,s,a=tl(t);o=!(i=yield a.next()).done;o=!1){const e=i.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(i){s=[i]}finally{try{o&&(i=a.return)&&(yield i.call(a))}finally{if(s)throw s[0]}}}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_onLoadSync(){return el(this,null,(function*(){try{for(var e,t,r,n=tl(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.onLoadSync)try{yield e.onLoadSync.call(e,this)}catch(o){console.error(o)}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_addControls(){this.options.controls&&this.options.controls.forEach((e=>{let t=e,r={};"string"==typeof e&&this.options.controlsOptions&&this.options.controlsOptions[e]&&(r=this.options.controlsOptions[e],void 0!==r.control&&(t=r.control));const n=r,{position:o}=n,i=((e,t)=>{var r={};for(var n in e)Ka.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Qa)for(var n of Qa(e))t.indexOf(n)<0&&Xa.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,o||"top-left",i)})),this._emitStatusEvent("controls:create")}}function nl(){return["ZOOM","ATTRIBUTION"]}function ol(e){return t=this,r=null,n=function*(){return new rl(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var il=Object.defineProperty,sl=Object.defineProperties,al=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,cl=Object.prototype.hasOwnProperty,ul=Object.prototype.propertyIsEnumerable,hl=(e,t,r)=>t in e?il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pl=(e,t)=>{for(var r in t||(t={}))cl.call(t,r)&&hl(e,r,t[r]);if(ll)for(var r of ll(t))ul.call(t,r)&&hl(e,r,t[r]);return e},dl=(e,t)=>sl(e,al(t));function fl(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(dl(pl({},r),{resource:t}));else if(Array.isArray(t)){const[o,i]=t;e.push(pl(dl(pl({},r),{resource:o,id:i}),n))}else"object"==typeof t&&e.push(pl(pl(pl({},r),t),n))}var yl=Object.defineProperty,ml=Object.defineProperties,bl=Object.getOwnPropertyDescriptors,gl=Object.getOwnPropertySymbols,vl=Object.prototype.hasOwnProperty,wl=Object.prototype.propertyIsEnumerable,_l=(e,t,r)=>t in e?yl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const Ol={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 Ll(e){const t=[new Co];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 ut({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=r(Ol,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new Gi({connector:e.connector,auth:e.auth})),n=((e,t)=>{for(var r in t||(t={}))vl.call(t,r)&&_l(e,r,t[r]);if(gl)for(var r of gl(t))wl.call(t,r)&&_l(e,r,t[r]);return e})({},e),e=ml(n,bl({starterKits:t,create:!1}))}var Pl=Object.defineProperty,Il=Object.defineProperties,xl=Object.getOwnPropertyDescriptors,jl=Object.getOwnPropertySymbols,El=Object.getPrototypeOf,Al=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,kl=Reflect.get,Ml=(e,t,r)=>t in e?Pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Sl=(e,t)=>{for(var r in t||(t={}))Al.call(t,r)&&Ml(e,r,t[r]);if(jl)for(var r of jl(t))Cl.call(t,r)&&Ml(e,r,t[r]);return e},Nl=(e,t)=>Il(e,xl(t)),Tl=(e,t,r)=>Ml(e,"symbol"!=typeof t?t+"":t,r),Rl=(e,t,r)=>kl(El(e),r,t),Fl=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Bl=class e extends rl{constructor(e){super(Ll(e)),Tl(this,"emitter",new C),Tl(this,"connector"),Tl(this,"_ngwLayers",{}),Tl(this,"$$selectFromNgwRaster"),Tl(this,"$$selectFromNgwVector"),Tl(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 Fl(this,null,(function*(){return yield this.onLoad("controls:create"),Rl(e.prototype,this,"addControl").call(this,t,r,n)}))}addNgwLayer(e){return Fl(this,null,(function*(){yield this.onMapLoad();const{keyname:t,resourceId:r}=e;(t||void 0!==r)&&console.warn(`DEPRECATED WARN: ${"set `resource` options instead of `keyname` or `resourceId`"}`);const o=e.resource;if(!t&&!r&&!o)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(n(this.options.baseUrl))try{n(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},n(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),Ri(e,t,r)}(e,this,this.connector),r=Sl(Sl({visibility:!0},e),e.adapterOptions),o=yield this.addLayer(t,r),i=o&&this.getLayerId(o);if(o&&i&&(this._ngwLayers[i]={layer:o,resourceId:o.resourceId},o.options.name=o.options.name||o.item&&o.item.resource.display_name,o.options.baselayer)){if(this.getActiveBaseLayer())return o}return o}catch(i){const e=y(o)&&"id"in o?o.id:t||r||o;console.error(`Can't add NGW layer ${e}.`,i)}}))}fit(){const{center:e,zoom:t,bounds:r}=this.options;e?(this.setCenter(e),t&&this.setZoom(t)):r&&this.fitBounds(r)}fetchNgwLayerItem(e){return Fr(Sl({connector:this.connector},e))}fetchNgwLayerItems(e){return Pr(Sl({connector:this.connector},e))}fetchNgwLayerFeature(e){return Yi(Sl({connector:this.connector},e))}fetchNgwLayerFeatures(e){return zo(Sl({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=new AbortController,n=r.signal;(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",r.abort),(t=t||{}).signal=n;const o=function(e){const{connector:t,identify:r}=e,n=us(r);return n&&n.length?Fr(ls(ls({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",o,r),o}fetchIdentifyGeoJson(e,{multiple:t,signal:r}={}){const n=new AbortController;if(r){if(r.aborted)return Promise.reject(new ut.errors.AbortError);r.addEventListener("abort",(()=>{n.abort("AbortError")}))}const o=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const i in r){const e=Number(i);if(!isNaN(e)){const e=r[i];if("features"in e){const t=e.features.find((e=>e.geom));if(t&&t.geom){const e=t.geom;return Promise.resolve(sr(cs(ls({},t),{geom:e})))}}}}const o=us(r);return o&&o.length?Yi(ls(cs(ls({},n),{connector:t}),o[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,multiple:t,requestOptions:{signal:n.signal}});return o&&"then"in o?(this._addPromise("identify",o,n),o):Promise.resolve(o)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,{multiple:t})}getNgwLayers(){return Fl(this,null,(function*(){return yield this.onLoad(),this._ngwLayers}))}getNgwLayerByResourceId(e){return Fl(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 Fl(this,null,(function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const o=n&&this._ngwLayers[n];if(o)if(o.layer.getBounds){const e=yield o.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(o.layer.item)e=o.layer.item;else{const t=o.resourceId;e=yield this.connector.getResource(t)}e&&this.fitResource(e.resource.id)}else Rl(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)}))}fitResource(e,t){return Fl(this,null,(function*(){const r=yield this.connector.resources.getIdOrFail(e),n=yield Ot({resourceId:r,connector:this.connector});n&&this.fitBounds(n,t)}))}zoomToLayer(e){return Fl(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 Fl(this,null,(function*(){var t;this._emitStatusEvent("ngw:preselect");const r=[],n=Object.values(this._ngwLayers);n.sort(((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1));for(const e of n){const n=e.layer,o="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,i=null==(t=n.options.interactive)||t;o&&n.options.selectable&&i&&this.isLayerVisible(n)&&r.push(o.call(n))}const o=Promise.all(r),s=yield o,a=[];for(const e of s)e&&a.push(...e);if(!a.length)return void this._emitStatusEvent("ngw:select",null);const l=this.options.pixelRadius||10,c=this.getCenter();let u=this.getZoom();if(u=void 0!==u?u:20,!c||!u)return void this._emitStatusEvent("ngw:select",null);const p=function(e,t,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*e[1]/Math.PI))/Math.pow(2,t+8))*5e-4}(c,u,l);let d;if(this.options.highlightIdentification){const t=this.options.highlightIdentification,r="number"==typeof t?t:1e3,[n,o]=e.lngLat;d={type:"Polygon",coordinates:[h(n,o,p)]};const i=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:d}});r!==1/0&&setTimeout((()=>{this.removeLayer(i)}),r)}const f=new AbortController,y=function(e,t){i(e);const[r,n]=e.lngLat,{geom:o,radius:s}=t,a=null!=o?o:h(r,n,s);return ps(cs(ls({},t),{geom:a}))}(e,{layers:a,connector:this.connector,radius:p,geom:d,signal:f.signal}).then((t=>{const r=Nl(Sl({},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 Fl(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&&fl(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),fl(e,n,{},r)}for(const n of e)try{yield this.addNgwLayer(n)}catch(r){console.warn(r)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()}))}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const r={qmsId:e};t&&(r.id=t),this.addBaseLayer("QMS",r)}_selectFromNgwVector(e){const t=e.layer;if(!(t.options.selectable&&this.isLayerVisible(t)))return;const r=t.item&&t.item.resource.id,n=e.feature;if(void 0!==r&&n){const e=n.id;if(e){const t={featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]},o={featureCount:1,[r]:t};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(Nl(Sl({},o),{resources:[r],sourceType:"vector"}))),o}}}_prepareToIdentify(e){return Nl(Sl({},e),{getIdentifyItems:()=>us(e,!0).map((e=>new Xi({feature:e.feature,connector:this.connector})))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return Fl(this,null,(function*(){const e=this.getContainer();if(e){const t=yield es(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}))}};Tl(Bl,"getIcon",(function(t={}){var r,n,o,i,s,a;const l=null!=(r=t.shape)?r:"circle",c=null!=(n=t.color)?n:"blue",u=null!=(o=t.strokeColor)?o:"white",h=null!=(i=t.size)?i:12,p=null!=(s=t.rotate)?s:0,d=null!=(a=t.anchor)?a:[h/2,h/2],f=void 0!==t.stroke?Number(t.stroke):.8,y=t.p||e[l]||"circle",m="string"==typeof y?y:y(t),b=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(t.svg||function({width:e,height:t,stroke:r=0,content:n}){const o=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${o} -${o} ${12+r} ${12+r}"\n >${n}</svg>`}({width:h,height:h,stroke:f,content:m}));return b.setAttribute("width",String(h)),b.setAttribute("height",String(h)),b.setAttribute("fill",c),f&&(b.setAttribute("stroke",u),b.setAttribute("stroke-width",String(f))),{type:"icon",iconSize:[h,h],iconAnchor:d,html:(new XMLSerializer).serializeToString(b),rotate:p,svg:b}}));let $l=Bl;function ql(e){return t=this,r=null,n=function*(){return new $l(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}export{$l as NgwMap,rl as WebMap,Ja as WebMapControls,Ga as WebMapLayers,Ma as WebMapMain,ql as createNgwMap,ms as createToggleControl,ol as createWebMap,ia as detectGeometryType,oa as findMostFrequentGeomType,nl as getDefaultControls,fs as getWebMap,sa as paintTypeAlias,ys as setWebMap,aa as typeAlias,la as updateGeoJsonAdapterOptions};
2
2
  //# sourceMappingURL=ngw-map.esm-browser.prod.js.map