@nextgis/ngw-map 2.5.0 → 3.0.0-alpha.1

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,i,o){var s,a,l,c;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((a=t._events)?(a.newListener&&(t.emit("newListener",n,i.listener?i.listener:i),a=t._events),l=a[n]):(a=t._events=new e,t._eventsCount=0),l){if("function"==typeof l?l=a[n]=o?[i,l]:[l,i]:o?l.unshift(i):l.push(i),!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]=i,++t._eventsCount;return t}function i(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function o(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,i,o,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,i=s(e,n),o=0;o<n;++o)i[o].call(r)}(r,h,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=s(e,i),a=0;a<i;++a)o[a].call(r,n)}(r,h,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,a=s(e,o),l=0;l<o;++l)a[l].call(r,n,i)}(r,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var a=e.length,l=s(e,a),c=0;c<a;++c)l[c].call(r,n,i,o)}(r,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=s(e,i),a=0;a<i;++a)o[a].apply(r,n)}(r,h,this,i)}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,i(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,i(this,e,t)),this},t.prototype.removeListener=function(t,r){var n,i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(n=i[t]))return this;if(n===r||n.listener&&n.listener===r)0==--this._eventsCount?this._events=new e:(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if("function"!=typeof n){for(o=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new e,this;delete i[t]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(n,o);i.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 i,o=Object.keys(n),s=0;s<o.length;++s)"removeListener"!==(i=o[s])&&this.removeAllListeners(i);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):o.call(e,t)},t.prototype.listenerCount=o,t.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var a=Object.defineProperty,l=(e,t,r)=>((e,t,r)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class c extends Error{constructor(){super(),l(this,"name","CancelError"),Object.setPrototypeOf(this,c.prototype)}}var u=Object.defineProperty,h=(e,t,r)=>((e,t,r)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class p{constructor(e={}){this.options=e,h(this,"_promises",new Map)}get isLoaded(){return this._promises.size>0}remove(e){this._promises.has(e)&&(this._promises.delete(e),this._onStop())}get(e){return this._promises.get(e)}add(e,t){const r=t||e,n=this._promises.get(r);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),n||(this._promises.set(r,e),e.finally((()=>{this.remove(r)})),e)}abort(){this.isLoaded&&(this._promises.forEach((e=>{e.cancel&&e.cancel()})),this._promises.clear(),this._onStop())}waitFunc(e,t=""){const r=this.get(t=t||e.name);return r||this.add(e(),t)}WaitForMe(e=""){const t=this.get.bind(this),r=this.add.bind(this);return function(n,i,o){const s=o.value;return e=e||i,o.value=function(...n){const i=t(e);if(i)return i;return r(s.apply(this,n),e)},o}}GetOrCreateDecorator(e=""){return this.WaitForMe(e)}_onStop(){this.options.onStop&&!this.isLoaded&&this.options.onStop()}}var d=Object.defineProperty,f=(e,t,r)=>((e,t,r)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class y extends Error{constructor(){super(),f(this,"name","TimeoutError"),Object.setPrototypeOf(this,y.prototype)}}var m,g=Object.defineProperty,b=(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);const v=(e,t,r,n)=>{try{e(r(n))}catch(i){t(i)}};let _=0;m=Symbol.toStringTag;const w=class e{constructor(t,r){b(this,m),b(this,"id",_++),b(this,"_isCanceled",!1),b(this,"_isPending",!0),b(this,"_promise"),b(this,"_cancelPromise"),b(this,"_cancelHandlers",[]),b(this,"_setCanceledCallback"),b(this,"_parentPromise"),b(this,"_children",[]),this._cancelPromise=new Promise(((e,t)=>{this._setCanceledCallback=t=>e(t||new c)}));const n=[this._cancelPromise,new Promise(((r,n)=>t((t=>{t instanceof e?this.attach(t):this._isPending=!1,r(t)}),(e=>{this._isPending=!1,n(e)}),(e=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(e)}))))];r&&n.push(new Promise(((e,t)=>{setTimeout((()=>{if(this._isPending)try{this.cancel()}finally{t(new y)}}),r)}))),this._promise=Promise.race(n)}static createControl(e){return new p(e)}static resolve(t){return new e((e=>e(t)))}static reject(t){return new e(((e,r)=>r(t)))}static all(t){return new e(((e,r)=>{Promise.all(t).then(e).catch(r)})).catch((e=>{if(e instanceof this.CancelError)for(const r of t){"cancel"in r&&r.cancel()}throw e}))}attach(e){this._isCanceled?e.cancel():this._children.push(e)}then(t,r){const n=new e(((e,n)=>{if(this._promise){const i=t=>{r?v(e,n,r,t):n(t)};this._promise.then((r=>{this._isCanceled?i(r):t?v(e,n,t,r):e(r)}),i)}}));return n._parentPromise=this,this._children.push(n),n}catch(e){return this._isCanceled&&e&&e(new c),this.then(void 0,e)}finally(e){return this._promise?this._promise.finally(e):Promise.reject(this._isCanceled?new c:e)}cancel(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;const e=this._getTopParent();if(e&&e.cancel(),this._children&&this._children.forEach((e=>e.cancel())),this._isPending){if(this._cancelHandlers.length)try{for(const e of this._cancelHandlers)e()}catch(t){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this}_getTopParent(){let e=this._parentPromise,t=!!e;for(;t;)e&&e._parentPromise?(e=e._parentPromise,t=!!e):t=!1;return e}_destroy(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0}};b(w,"CancelError",c),b(w,"TimeoutError",y),b(w,"PromiseControl",p);let O=w;Object.setPrototypeOf(O.prototype,Promise.prototype);const L={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"/>'},P=12;function I(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const i=void 0===r.replace||r.replace;t.forEach((t=>{Object.getOwnPropertyNames(t.prototype).forEach((r=>{const o=-1!==n.indexOf(r);if(!i&&!o||i){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}}))}))}function E(e){return null!=e}function j(e){return"string"==typeof e?!!e:E(e)}function x(e,t,r=!1){let n=e;const i=t,o=Array.isArray(i);let s=o&&[]||{};return o&&Array.isArray(i)?r?(n=n||[],s=s.concat(n),i.forEach(((e,t)=>{void 0===s[t]?s[t]=e:"object"==typeof e?s[t]=x(n[t],e,r):-1===n.indexOf(e)&&s.push(e)}))):s=i:(n&&"object"==typeof n&&Object.keys(n).forEach((function(e){s[e]=n[e]})),Object.keys(i).forEach((function(e){s[e]="object"==typeof i[e]&&i[e]&&"object"==typeof n[e]&&"object"==typeof i[e]?x(n[e],i[e],r):i[e]}))),s}function C(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}const A=6371;function k(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 S=Math.PI/180,N=180/Math.PI;function T(e,t,r=10,n=6){const i=r/A*N,o=i/Math.cos(t*S),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+o*Math.cos(r),c=t+i*Math.sin(r);s.push([l,c])}return s}function F(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 B(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:R(e,t));return e===t}function R(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let i=0;i<r.length;i++){if(!B(e[r[i]],t[n[i]],e,t))return!1}return!0}function $(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]=$(e[r])})),t}function D(e){return"[object Object]"===Object.prototype.toString.call(e)}function q(e){return e.replace(/([^:]\/)\/+/g,"$1")}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);const U=class e{constructor(t={}){var r;G(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){return this.add(e,t,r,!0)}add(e,t,r,n){const i=this._find(e,r);if(i)return i.value;{let i;i=t instanceof Function?t():t;const o=r&&JSON.parse(JSON.stringify($(r))),s={key:e,value:i,props:o,options:o};return n&&!j(i)?i:(this.cache.push(s),i instanceof Promise?(i.catch((t=>{throw this.delete(e,r),t})),n&&i.then((t=>(j(t)||this.delete(e,r),t))),i):i)}}match(e,t){const r=this._find(e,t);if(r)return r.value}matchAll(e,t){return e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){let r=[];"string"==typeof e?r=this.cache.filter((r=>this._filter(r,e,t))):r.push(e);for(const n of r){const e=this.cache.indexOf(n);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){if(r){return R(e.props||e.options||{},$(r))}return!0}return!1}};G(U,"instance",{});let z=U;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 Error{constructor(e){super(),W(this,"name","NgwError"),W(this,"title"),W(this,"message"),W(this,"detail"),W(this,"exception"),W(this,"status_code"),W(this,"data"),W(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,H.prototype)}}var J=Object.defineProperty,Q=(e,t,r)=>((e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class K extends H{constructor(e){super(e),Q(this,"name","ResourceNotFoundError"),Q(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,K.prototype)}}function X(e){return"[object Object]"===Object.prototype.toString.call(e)}const Y=["description"];function ee(e,t=""){t=t?t+"__":"";const r={};for(const[n,i]of Object.entries(e))if(-1===Y.indexOf(n))if(X(i))if("owner_user"===n){const e=ee(i,n);Object.assign(r,e)}else"parent"===n&&"id"in i&&(r.parent_id=i.id);else E(i)&&(r[t+n]=i);return r}var te=Object.defineProperty,re=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,ae=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,le=(e,t)=>{for(var r in t||(t={}))oe.call(t,r)&&ae(e,r,t[r]);if(ie)for(var r of ie(t))se.call(t,r)&&ae(e,r,t[r]);return e},ce=(e,t,r)=>ae(e,"symbol"!=typeof t?t+"":t,r);class ue{constructor({connector:e,cacheId:t}){ce(this,"cache"),ce(this,"connector"),this.connector=e,this.cache=new z({namespace:t})}getOne(e,t){const r=this.cache,n={},i=(o=le({},t),re(o,ne({cache:!1})));var o;"string"==typeof e?n.keyname=e:"number"==typeof e?n.id=e:X(e)&&(void 0!==e.id?n.id=e.id:(e.keyname&&(n.keyname=e.keyname),e.display_name&&(n.display_name=e.display_name)));const s=()=>"string"==typeof e?this._fetchResourceBy({keyname:e},i):"number"==typeof e?this._fetchResourceById(e,i):X(e)?this._fetchResourceBy(e,i):O.resolve(void 0);return(null==t?void 0:t.cache)?r.addFull("resource",s,n):s()}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new K}))}getId(e,t){return"number"==typeof e?O.resolve(e):"string"==typeof e||X(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):O.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,ee(e)),this.connector.get("resource.search",t,le({serialization:"full"},r)).then((e=>{if(e)for(const t of e)this.cache.add("resource.item",O.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>e?this.getOne(e.resource.parent.id,t):O.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,r=[]){return this.connector.get("resource.collection",le({cache:!0},t),{parent:e}).then((e=>{const n=[];for(const i of e)this.cache.add("resource.item",O.resolve(i),{id:i.resource.id}),r.push(i),(null==t?void 0:t.recursive)&&i.resource.children&&n.push(this._getChildrenOf(i.resource.id,t,r));return n.length?O.all(n).then((()=>r)):r}))}_cleanResourceItemCache(e){return t=this,r=null,n=function*(){const t=this.cache.all(),r=[];for(const n of t){const t=n.options&&n.options.id;["resource.item","resource"].includes(n.key)&&void 0!==t&&("number"==typeof t?t===e&&r.push(n):(yield this.getId(t))===e&&r.push(n))}for(const e of r)this.cache.delete(e)},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n}_fetchResourceById(e,t){const r=()=>this.connector.get("resource.item",t,{id:e});return(null==t?void 0:t.cache)?this.cache.add("resource.item",r,{id:e}).catch((e=>{if(!(e instanceof K))throw e})):r()}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return O.all(this.cache.matchAll("resource.item")).then((t=>(t.filter((t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:E(e.id)&&E(t.resource.id)?e.id===t.resource.id:R(e,t.resource)})),[])))}}const he=[];function pe(e){he.push(e)}var de=Object.defineProperty,fe=(e,t,r)=>((e,t,r)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ye extends H{constructor(e){super(e),fe(this,"name","InsufficientPermissionsError"),fe(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,ye.prototype)}}const me=/\{ *([\w_-]+) *\}/g;function ge(e,t){return e.replace(me,((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 be=Object.defineProperty,ve=(e,t,r)=>((e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class _e extends Error{constructor(e){super(),ve(this,"name","NetworkError"),Object.setPrototypeOf(this,_e.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}let we;we=(e,t,r={},n,i)=>{r.method=r.method||"GET";const o=new XMLHttpRequest;o.open(r.method||"GET",e,!0),"blob"===r.responseType&&(o.responseType=r.responseType);const s=()=>{try{return JSON.parse(o.responseText)}catch(e){return o.responseText}};o.onload=()=>{-1!==[401,403,404,422,500].indexOf(o.status)&&n(new H(s())),((e=!1)=>{const i=e?n:t;"blob"===r.responseType?i(o.response):o.responseText?i(s()):n({message:""})})()},o.onerror=t=>{n(0===o.status?new _e(e):t)},o.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&o.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(o.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;i&&i((()=>{o.abort()})),o.send(l)};var Oe=Object.defineProperty,Le=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Ee=(e,t,r)=>t in e?Oe(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)&&Ee(e,r,t[r]);if(Le)for(var r of Le(t))Ie.call(t,r)&&Ee(e,r,t[r]);return e},xe=(e,t,r)=>Ee(e,"symbol"!=typeof t?t+"":t,r);let Ce=0;class Ae{constructor(e){this.options=e,xe(this,"id",Ce++),xe(this,"emitter",new t),xe(this,"user"),xe(this,"resources"),xe(this,"cache"),xe(this,"withCredentials"),xe(this,"routeStr","/api/component/pyramid/route"),xe(this,"activeRequests",[]),xe(this,"requestTransform");const r=function(e){return he.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return R(t.options.auth,e.auth)}}))}(e);if(this.cache=new z({namespace:e.cacheId}),r)return r;{const{route:t,requestTransform:r,withCredentials:n}=this.options;t&&(this.routeStr=t),r&&(this.requestTransform=r),void 0!==n&&(this.withCredentials=n),this.resources=new ue({connector:this,cacheId:e.cacheId}),pe(this)}}static create(e){return new this(e)}clearCache(){this.cache.clean(),this.resources.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,pe(this)}connect(){const e=this.options.auth;return this.cache.add("route",(()=>new O(((t,r)=>{const n=()=>this.makeQuery(this.routeStr,{},{}).then((e=>{t(e)})).catch((e=>{r(e)}));if(e){const{login:t,password:i}=e;if(t&&i)return this._login({login:t,password:i}).then((()=>n())).catch((e=>r(e)))}return n()}))),{id:this.id,auth:e,baseUrl:this.options.baseUrl})}login(e,t){return this.logout(),pe(this),this._login(e,t)}logout(){this.abort(),function(e){const t=he.indexOf(e);-1!==t&&he.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){if(this.user&&this.user.id)return O.resolve(this.user);e&&(this.options.auth=e);const r=je({headers:this.getAuthorizationHeaders(e)},t);return this.makeQuery("/api/component/auth/current_user",{},r)}getAuthorizationHeaders(e){const t=this.makeClientId(e);if(t)return{Authorization:"Basic "+t}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=unescape(encodeURIComponent(`${t}:${r}`));return window.btoa(n)}}abort(){for(const e of this.activeRequests)e.cancel();this.activeRequests=[]}getActiveApiRequests(){return[...this.activeRequests]}apiRequest(e,t={},r={}){var n,i;r=je({withCredentials:this.withCredentials},r);const{method:o,headers:s,withCredentials:a,responseType:l}=r,c=$(t=null!=(n=r.params)?n:t),u=()=>function(e){const t=e.params;return new O(((r,n)=>e.connector.connect().then((i=>{let o=i&&i[e.name];if(o){o=[...o];let i=o.shift();if(o.length){const e={};for(let r=0;r<o.length;r++){const n=o[r];if(e[r]="{"+n+"}",void 0===t[n])throw new Error("`"+n+"` url api argument is not specified")}i&&(i=ge(i,e))}if(t){const e=[],r=t.paramList;Array.isArray(r)&&(delete t.paramList,r.forEach((t=>{e.push(`${t[0]}=${t[1]}`)})));for(const n in t)-1===o.indexOf(n)&&e.push(`${n}=${t[n]}`);e.length&&(i=i+"?"+e.join("&"))}i?r(e.connector.makeQuery(i,t,e.requestOptions)):n(new Error("request url is not set"))}else r(void 0)})).catch((e=>{n(e)}))))}({name:e,params:c,requestOptions:r,connector:this});return r.cache&&"GET"===o?this.cache.add(e,u,je({params:c},$({headers:s,withCredentials:a,responseType:l,baseUrl:this.options.baseUrl,userId:null==(i=this.user)?void 0:i.id}))):u()}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)}makeQuery(e,t,r={}){if(e=(this.options.baseUrl?this.options.baseUrl:"")+e)return t&&(e=ge(e,t)),e=encodeURI(q(e)),this._loadData(e,r);throw new Error("Empty `url` not allowed")}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)}_loadData(e,t){if(t.responseType=t.responseType||"json",t.signal&&t.signal.aborted)return O.reject(new O.CancelError);const r=new O(((r,n,i)=>{if(this.user&&((t=t||{}).headers=je(je({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}we(e,r,t,n,i)})).then((e=>(this._cleanActiveRequests(r),e))).catch((e=>{if(this._cleanActiveRequests(r),e instanceof O.CancelError);else{const t=this._handleHttpError(e);if(t)throw t}}));return t.signal&&"function"==typeof t.signal.addEventListener&&t.signal.addEventListener("abort",(()=>{r.cancel(),this._cleanActiveRequests(r)})),this.activeRequests.push(r),r}_login(e,t){return this.getUserInfo(e,t).then((e=>(this.user=e,this.emitter.emit("login",e),e))).catch((e=>{throw this.emitter.emit("login:error",e),e}))}_cleanActiveRequests(e){const t=this.activeRequests.indexOf(e);-1!==t&&this.activeRequests.splice(t,1)}_handleHttpError(e){if(e&&e instanceof H){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new K(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new ye(e)}return e}}xe(Ae,"errors",{NgwError:H,ResourceNotFoundError:K});var ke=Object.defineProperty,Me=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,Te=(e,t,r)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fe=(e,t)=>{for(var r in t||(t={}))Se.call(t,r)&&Te(e,r,t[r]);if(Me)for(var r of Me(t))Ne.call(t,r)&&Te(e,r,t[r]);return e};function Be(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${i=t,i.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var i;return null!==new RegExp(n,r?"i":"").exec(e)}const Re={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)=>Be(e,t),ilike:(e,t)=>Be(e,t,!0)};function $e(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function De(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if($e(t)){const[r,n,i]=t,o=Re[n];if(o){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,o)=>(t=e[o],r.replace(o,i))));return o(t,n)}return o(e[r],i)}return!1}return De(e,t)},i=t.filter((e=>Array.isArray(e)));return"any"===r?i.some(n):i.every(n)}var qe=Object.defineProperty,Ve=Object.defineProperties,Ge=Object.getOwnPropertyDescriptors,Ue=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,We=(e,t,r)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,He=(e,t)=>{for(var r in t||(t={}))ze.call(t,r)&&We(e,r,t[r]);if(Ue)for(var r of Ue(t))Ze.call(t,r)&&We(e,r,t[r]);return e},Je=(e,t)=>Ve(e,Ge(t));const Qe={srs:4326,geom_format:"geojson"};function Ke(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function Xe(e,t){const{extensions:r,geom:n,fields:i,srs:o,ilike:s,like:a}=t,l=r?r.join(","):"";"*"!==l&&(e.extensions=l),void 0!==i&&(e.fields=Array.isArray(i)?i.join(","):""),void 0!==n&&(e.geom=n?"yes":"no",n||(delete e.srs,delete e.geom_format)),E(s)?e.ilike=s:E(a)&&(e.like=a),E(o)&&(e.srs=o)}function Ye(e){const t=tt(e);return O.all(t).then((t=>{const r=[],n=[];for(const e of t)for(const t of e)r.includes(t.id)||(n.push(t),r.push(t.id));return e.offset||e.limit?n.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:n.length):n}))}function et(e){const[t,r,n]=e;let i="",o="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(i=t,o=n,r)))}__${r}`,i+n+o]}function tt(e,t=[],r=[]){var n;const{filters:i}=e,o=null!=(n=e.paramList)?n:[],s="string"==typeof i[0]?i[0]:"all",a=i.filter((e=>Array.isArray(e)));if("any"===s)for(const l of a)$e(l)?t.push(nt(Je(He({},e),{paramList:[...r,...o,et(l)]}))):tt(Je(He({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],i=[];for(const e of a)$e(e)?n.push(et(e)):i.push(e);if(i.length)for(const o of i)tt(Je(He({},e),{filters:o}),t,[...r,...n]);else t.push(nt(Je(He({},e),{paramList:[...r,...o,...n]})))}return t}function rt(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=F(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function nt(e){const t=He({},Qe),{limit:r,cache:n,signal:i,offset:o,orderBy:s,paramList:a,connector:l,geomFormat:c,intersects:u,resourceId:h}=e;if(r?r!==Number.POSITIVE_INFINITY&&(t.limit=r):t.limit=7e3,o&&(t.offset=o),c&&(t.geom_format=c),Xe(t,e),s&&(t.order_by=s.join(",")),Array.isArray(u)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every((e=>"number"==typeof e))}(u)?M(u):u;t.intersects=rt(e)}else"string"==typeof u&&(t.intersects=u);a&&(t.paramList=a);const p=He({id:h},t);return l.get("feature_layer.feature.collection",{cache:n,signal:i},p)}var it=Object.defineProperty,ot=Object.defineProperties,st=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,ut=(e,t,r)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ht=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&ut(e,r,t[r]);if(at)for(var r of at(t))ct.call(t,r)&&ut(e,r,t[r]);return e},pt=(e,t)=>ot(e,st(t));function dt(e){const t=ht({},Qe);Xe(t,e);const r=ht({id:e.resourceId,fid:e.featureId},t);return e.connector.get("feature_layer.feature.item",{cache:e.cache||!0},r).then((t=>pt(ht({},t),{toGeojson:()=>t.geom?O.resolve(Ke(t)):dt(pt(ht({},e),{geom:!0,fields:null,extensions:null})).then((e=>{const r=e.geom;return Ke(pt(ht({},t),{geom:r}))}))})))}var ft=Object.defineProperty,yt=(e,t,r)=>((e,t,r)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class mt{constructor(e){this.options=e,yt(this,"name"),yt(this,"resourceId"),yt(this,"item"),yt(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(){return this._extent?O.resolve(this._extent):this.options.connector.get("feature_layer.feature.item_extent",null,{id:this.resourceId,fid:this.item.id}).then((e=>{const{minLat:t,minLon:r,maxLat:n,maxLon:i}=e.extent,o=[r,t,i,n];return this._extent=o,o}))}geoJson(){return this.item.geom?O.resolve(Ke(this.item)):dt({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null}).then((e=>(this.item.geom=e.geom,Ke(this.item))))}}function gt(e,t,r,n){return!!_t(e,t,r,wt)}function bt(e,t,r,n){return _t(e,t,r,Ot)}function vt(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 _t(e,t=(e=>!!e),r="children",n,i){return n(e,"function"==typeof t?t:e=>De(e,t),r)}function wt(e,t=(e=>!!e),r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(t(e))return e;const n=vt(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){const e=wt(i[o],t,r,n);if(e)return e}}function Ot(e,t=(e=>!!e),r,n=[]){let i=[];if(Array.isArray(e))i=e;else{t(e)&&n.push(e);const o=vt(e,r);o&&(i=o)}for(let o=0;o<i.length;o++)i[o]&&Ot(i[o],t,r,n);return n}function Lt(e,t=(e=>!!e),r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(!t(e))return!1;const n=vt(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){if(!Lt(i[o],t,r,n))return!1}return!0}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);class Et{constructor(e){It(this,"item"),It(this,"_children",[]),It(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?bt(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 _t(this._children,e,(e=>e.tree.getChildren()),wt)}every(e){return!!_t(this._children,e,(e=>e.tree.getChildren()),Lt)}some(e){return gt(this._children,e,(e=>e.tree.getChildren()))}all(e){return this.getDescendants(e)}getDescendants(e){return bt(this._children,e,(e=>e.tree.getChildren()))}getChildren(){return[...this._children]}}var jt=Object.defineProperty,xt=(e,t,r)=>((e,t,r)=>t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ct{constructor(e,r,n){xt(this,"options"),xt(this,"emitter",new t),xt(this,"name"),xt(this,"item"),xt(this,"_blocked",!1),xt(this,"_container"),xt(this,"_value"),xt(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){const t=e.some((e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()}));return t}}var At=Object.defineProperty,kt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Nt=(e,t,r)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))Mt.call(t,r)&&Nt(e,r,t[r]);if(kt)for(var r of kt(t))St.call(t,r)&&Nt(e,r,t[r]);return e};const Ft=class e extends Ct{constructor(t,r,n){super(t,r,Tt(Tt({},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 i=r[n],o=i.properties&&i.properties.property(this.name);o&&o.set(e,Tt(Tt({},t),{propagation:!0,bubble:!1}))}}}};Nt(Ft,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let Bt=Ft;var Rt=Object.defineProperty,$t=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Gt=(e,t,r)=>Vt(e,"symbol"!=typeof t?t+"":t,r);const Ut=class e{constructor(e,t){this.item=e,Gt(this,"options",{}),Gt(this,"_properties",{}),Gt(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={}))Dt.call(t,r)&&Vt(e,r,t[r]);if($t)for(var r of $t(t))qt.call(t,r)&&Vt(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}};Gt(Ut,"handlers",{CheckProperty:Bt});let zt=Ut;var Zt=Object.defineProperty,Wt=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Qt=(e,t,r)=>t in e?Zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kt=(e,t,r)=>Qt(e,"symbol"!=typeof t?t+"":t,r);let Xt=0;class Yt{constructor(e){Kt(this,"options",{}),Kt(this,"properties"),Kt(this,"tree"),Kt(this,"id",Xt),Xt+=1,this.options=((e,t)=>{for(var r in t||(t={}))Ht.call(t,r)&&Qt(e,r,t[r]);if(Wt)for(var r of Wt(t))Jt.call(t,r)&&Qt(e,r,t[r]);return e})({},e),this.tree=new Et(this)}initProperties(){this.properties=new zt(this,this.options.properties)}}var er=Object.defineProperty,tr=Object.defineProperties,rr=Object.getOwnPropertyDescriptors,nr=Object.getOwnPropertySymbols,ir=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,sr=(e,t,r)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ar=(e,t)=>{for(var r in t||(t={}))ir.call(t,r)&&sr(e,r,t[r]);if(nr)for(var r of nr(t))or.call(t,r)&&sr(e,r,t[r]);return e},lr=(e,t)=>tr(e,rr(t));function cr(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,i=e.extent_right;if(t&&r&&n&&i){const e=[r,t,i,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function ur({resourceId:e,connector:t,cache:r=!0}){return t.get("layer.extent",{cache:r},{id:e}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:i}=e.extent;return[i,n,r,t]}}))}function hr(e){return e.connector.getResource(e.resourceId).then((t=>{if(t)return pr(t,e.connector,e)}))}function pr(e,t,r){if(e.webmap)return O.resolve(cr(e.webmap));{const n=e.resource;return n.cls&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id).then((e=>{if(e)return ur(lr(ar({},r),{resourceId:e.resource.id,connector:t}))})):ur(lr(ar({},r),{resourceId:n.id,connector:t}))}}var dr=Object.defineProperty,fr=(e,t,r)=>((e,t,r)=>t in e?dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),yr=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));class mr{constructor(){fr(this,"item"),fr(this,"connector"),fr(this,"_extent")}getExtent(){return yr(this,null,(function*(){return this.getBounds()}))}getBounds(e){return yr(this,null,(function*(){return this._extent?this._extent:this.item?(this._extent=yield pr(this.item,this.connector,e),this._extent):void 0}))}}var gr=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function br(e,t){return gr(this,null,(function*(){const r=e.resource,n=r;let{keyname:i,resourceId:o}=e;if(r&&("string"==typeof r?i=r:o="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield br(r,t)),!o&&i){const e=yield t.getResource(i);e&&(o=e.resource.id)}return o}))}const vr={tms:"TILE"};var _r=Object.defineProperty,wr=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Lr=Object.prototype.propertyIsEnumerable,Pr=(e,t,r)=>t in e?_r(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(wr)for(var r of wr(t))Lr.call(t,r)&&Pr(e,r,t[r]);return e},Er=(e,t,r)=>Pr(e,"symbol"!=typeof t?t+"":t,r);const jr="https://qms.nextgis.com";function xr(e,t=jr,r={}){let n;if("webMap"in e){const i=e,{webMap:o,url:s}=i,a=((e,t)=>{var r={};for(var n in e)Or.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&wr)for(var n of wr(e))t.indexOf(n)<0&&Lr.call(e,n)&&(r[n]=e[n]);return r})(i,["webMap","url"]);n=o,s&&(t=s),a&&(r=a)}else n=e;t||(t=jr);class i{constructor(e,t){Er(this,"qms"),Er(this,"options"),Er(this,"map"),this.map=e;const n=Ir(Ir({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,o=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",q(e),!0),n.send()}))}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=vr[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(o=i,s=a,["showLayer","hideLayer"].forEach((e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(o.prototype,e,t)})),"TILE"===t)){if(e=Ir(Ir({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 o,s},new Promise(((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},i=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,i);a((s=s.apply(r,o)).next())}));var r,o,s}}return i}var Cr=Object.defineProperty,Ar=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,Sr=(e,t,r)=>t in e?Cr(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(Ar)for(var r of Ar(t))Mr.call(t,r)&&Sr(e,r,t[r]);return e},Tr=(e,t,r)=>Sr(e,"symbol"!=typeof t?t+"":t,r);class Fr{constructor(e){Tr(this,"options",{url:"https://qms.nextgis.com"}),Tr(this,"url"),this.options=Nr(Nr({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return xr({webMap:e,url:this.url})}}Tr(Fr,"utils",{createQmsAdapter:xr});var Br=Object.defineProperty,Rr=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,Dr=Object.getOwnPropertySymbols,qr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty,Gr=Object.prototype.propertyIsEnumerable,Ur=Reflect.get,zr=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Zr=(e,t)=>{for(var r in t||(t={}))Vr.call(t,r)&&zr(e,r,t[r]);if(Dr)for(var r of Dr(t))Gr.call(t,r)&&zr(e,r,t[r]);return e},Wr=(e,t)=>Rr(e,$r(t)),Hr=(e,t,r)=>Ur(qr(e),r,t),Jr=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function Qr(e){let t;for(t in e){const r=e[t];if(D(r)){const n=r;if(E(n.year)&&E(n.month)&&E(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 Kr=Object.defineProperty,Xr=Object.defineProperties,Yr=Object.getOwnPropertyDescriptors,en=Object.getOwnPropertySymbols,tn=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable,nn=(e,t,r)=>t in e?Kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,on=(e,t)=>{for(var r in t||(t={}))tn.call(t,r)&&nn(e,r,t[r]);if(en)for(var r of en(t))rn.call(t,r)&&nn(e,r,t[r]);return e},sn=(e,t)=>Xr(e,Yr(t));function an(e){const t=e.filters;return t?Ye(sn(on({},e),{filters:t})).then((r=>{var n;return(null!=(n=e.clientFilterValidate)?n:ln(t))&&(r=r.filter((e=>De(Qr(sn(on({},e.fields),{id:e.id})),t)))),r})):nt(e)}function ln(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(ln(r))return!0}}return!1}function cn(e){return function(e){return an(e).then((e=>{const t=[];return e.forEach((e=>{t.push(Ke(e))})),t}))}(e).then((e=>({type:"FeatureCollection",features:e})))}const un=["fields","intersects","limit","orderBy","strategy"];function hn(e){const t={};return un.forEach((r=>{const n=e[r];void 0!==n&&(t[r]=n)})),t}var pn=Object.defineProperty,dn=Object.defineProperties,fn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertySymbols,mn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable,vn=Reflect.get,_n=(e,t,r)=>t in e?pn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wn=(e,t)=>{for(var r in t||(t={}))gn.call(t,r)&&_n(e,r,t[r]);if(yn)for(var r of yn(t))bn.call(t,r)&&_n(e,r,t[r]);return e},On=(e,t)=>dn(e,fn(t)),Ln=(e,t,r)=>_n(e,"symbol"!=typeof t?t+"":t,r),Pn=(e,t,r)=>vn(mn(e),r,t),In=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function En(e){return In(this,null,(function*(){var r,n;const{item:i,webMap:o,Adapter:s,connector:a,layerOptions:l,addLayerOptionsPriority:c}=e,u=null==c||c,h=l,p=s||l.Adapter||o.mapAdapter.layerAdapters.GEOJSON,d=[];let f,y,m=!1;const g=yield br(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,i));const b=(e,t)=>In(this,null,(function*(){return _(),f={filters:e,options:t},y=cn(wn({resourceId:g,filters:e,connector:a,cache:!0},t)),yield y}));let v=!1;const _=()=>{y&&(y.cancel(),y=void 0)};class w extends p{constructor(){super(...arguments),Ln(this,"emitter",new t),Ln(this,"__onMapMove"),Ln(this,"__onMapMoveStart"),Ln(this,"__enableMapMoveListener"),Ln(this,"__disableMapMoveListener")}addLayer(e){return In(this,null,(function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==h.id&&(e.id=h.id),i&&i.vector_layer&&(e.type=li[i.vector_layer.geometry_type]),h.adapterOptions&&(e=u?wn(wn({},h.adapterOptions),e):wn(wn({},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 o=Pn(w.prototype,this,"addLayer").call(this,e);let s;return f={filters:e.propertiesFilter,options:hn(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),n&&n.startsWith("BBOX")&&!m&&this._addBboxEventListener(),o}))}getExtent(){return this.getBounds()}getBounds(){return In(this,null,(function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?hr({connector:a,resourceId:i.resource.id}):Pn(w.prototype,this,"getBounds")?Pn(w.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,_()}getCount(){return function({connector:e,resourceId:t,cache:r=!0}){return e.get("feature_layer.feature.count",{cache:r},{id:t}).then((e=>e.total_count))}({connector:a,resourceId:g,cache:!0})}updateLayer(e){return In(this,null,(function*(){var t;if(e=e||f||{},null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield o.onLoad("create"),e.options=e.options||{},e.options.intersects=o.getBounds();const{minZoom:t,maxZoom:r}=this.options,n=o.getZoom();if(void 0!==n){if(void 0!==t&&n<t)return;if(void 0!==r&&n>r)return;if(m)return}}if(!v){try{this.emitter.emit("preupdate",e),o._emitLayerEvent("layer:preupdate",h.id||"",e);const t=yield b(e.filters,On(wn({},e.options),{srs:this.options.srs}));let r=t;const n=yield this.getCount();if("BBOX+"===this.options.strategy){r={type:"FeatureCollection",features:[]};for(const e of t.features)-1===d.indexOf(String(e.id))&&(d.push(String(e.id)),r.features.push(e));m=void 0!==n&&d.length>=n,yield o.addLayerData(this,r)}else m=void 0!==n&&t.features.length>=n,yield o.setLayerData(this,t);this.emitter.emit("updated",t),o._emitLayerEvent("layer:updated",h.id||"",{data:t,newData:r,isFull:m})}catch(r){if(r instanceof Error&&"CancelError"!==r.name)throw r}Pn(w.prototype,this,"updateLayer")&&Pn(w.prototype,this,"updateLayer").call(this)}}))}propertiesFilter(e,t){return In(this,null,(function*(){if(_(),this.filter&&m)this.filter((t=>{const r=t.feature&&t.feature.properties&&Qr(wn({},t.feature.properties));return!r||De(r,e)}));else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(e,On(wn({},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()},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(...i){n.clear(),r=setTimeout((()=>{r=null,e.apply(this,i)}),t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}((()=>this.updateLayer())),this.__onMapMoveStart=_,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 jn=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function xn({options:e,webMap:t,baseUrl:r}){var n;let i,o=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===o){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const i=t+"/api/component/render/image",o={resource:e};return r&&(o.nd=r),{url:i,resourceId:e,headers:n,params:o,updateWmsParams:t=>(r&&(t.nd=r),ai(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});o="TILE"}if("WMS"===o){i=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:i,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===o)return i=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:i,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===o)return i=r+`/api/resource/${a}/terrain_provider`,{url:i,adapter:o};if("MODEL_3D"===o)return i=r+`/api/component/model_3d/${a}/data.glb`,{url:i};if("TILE"===o)return i=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:i,adapter:o}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var Cn=Object.defineProperty,An=Object.defineProperties,kn=Object.getOwnPropertyDescriptors,Mn=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Tn=(e,t,r)=>t in e?Cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fn=(e,t)=>{for(var r in t||(t={}))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},Bn=(e,t)=>An(e,kn(t)),Rn=(e,t,r)=>Tn(e,"symbol"!=typeof t?t+"":t,r),$n=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function Dn(e){return $n(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const i=n.resource.cls;let o=e.adapter||i&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[i]||"IMAGE";if(void 0!==o&&(e.adapter=o),"IMAGE"===o){const e=t.getLayerAdapters();!e||e.IMAGE||(o="TILE")}const s=t.mapAdapter.layerAdapters[o];if(s){const i=yield br(e,r);return class extends s{constructor(o,s){super(o,s),this.map=o,Rn(this,"item",n),Rn(this,"resourceId",i);const a=xn({options:e,webMap:t,baseUrl:r.options.baseUrl||""});if(a){const t=Bn(Fn(Fn({},a),e.adapterOptions),{params:{resource:i},layers:a.layers||String(i),resourceId:i});e.adapterOptions&&E(e.adapterOptions.setViewDelay)&&(t.setViewDelay=e.adapterOptions.setViewDelay),this.options=Fn(Fn({},this.options),t)}}addLayer(e){return super.addLayer(Fn(Fn({},this.options),e))}getLegend(e){return $n(this,null,(function*(){const t=yield r.get("render.legend_symbols",Fn({params:{id:i},cache:!0},e)),n=this.options.id;if(void 0!==n){return[{layerId:n,legend:t.map((({display_name:e,icon:t})=>({name:e,symbol:t})))}]}return[]}))}getIdentificationIds(){return $n(this,null,(function*(){if(this.item){if("MVT"===o)return[this.item.resource.id];const e=this.item.resource.parent.id;if(E(e))return[e]}return[]}))}}}throw new Error(o+" not supported yet. Only TILE")}))}var qn=Object.defineProperty,Vn=Object.defineProperties,Gn=Object.getOwnPropertyDescriptors,Un=Object.getOwnPropertySymbols,zn=Object.prototype.hasOwnProperty,Zn=Object.prototype.propertyIsEnumerable,Wn=(e,t,r)=>t in e?qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hn=(e,t)=>{for(var r in t||(t={}))zn.call(t,r)&&Wn(e,r,t[r]);if(Un)for(var r of Un(t))Zn.call(t,r)&&Wn(e,r,t[r]);return e},Jn=(e,t)=>Vn(e,Gn(t)),Qn=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const Kn={},Xn=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Yn(e){return Qn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const i=n.resource.id,o=yield r.getResourceChildren(i),s=o&&o[0];if(s)return ei(Jn(Hn({},e),{resource:s.resource.id}),t,r)}))}function ei(e,t,r){return Qn(this,null,(function*(){let n,i;const o=e.adapter,s=yield br(e,r);if(s){const a=e.resource;if(i=a&&a.resource&&void 0!==a.resource.id?a:yield r.getResource(s),!i)throw"Resource item is not found";{const a=i.resource.cls,l={layerOptions:Jn(Hn({},e),{resource:s}),connector:r,webMap:t,item:i};if(-1!==Xn.indexOf(a))if("webmap"===a)n=function(e){return jn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r}){const n=yield br(e,r);return class extends Gi{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||i.vector_layer&&li[i.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==o&&"GEOJSON"!==o){if("MVT"!==o)return Yn(l);n=Dn(l)}else n=En(l)}else{if("raster_layer"===a)return Yn(l);if("basemap_layer"===a)n=function(e){return Jr(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(Fr.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 Jr(this,null,(function*(){return Hr(e.prototype,this,"addLayer").call(this,Wr(Zr({},t),{url:n}))}))}}return e}}}}))}(l);else if("GEOJSON"===o){const t=yield r.getResource(i.resource.parent.id);if(t){const r=Jn(Hn({},e),{resource:i.resource.parent.id});n=En(Jn(Hn({},l),{item:t,layerOptions:r}))}}else n=Dn(l)}else{if(!Kn[a])throw`Resource class '${a}' not yet supported.`;{const e=Kn[a];let t;t=o&&"function"!=typeof t?e[o]:e,t&&(n=t(l))}}}}if(n)return n.then((e=>{if(e){const t=e;return i&&(t.prototype.item=i,t.prototype.resourceId=i.resource.id,t.prototype.connector=r),I(t,[mr],{replace:!1}),t}}))}))}var ti=Object.defineProperty,ri=Object.getOwnPropertySymbols,ni=Object.prototype.hasOwnProperty,ii=Object.prototype.propertyIsEnumerable,oi=(e,t,r)=>t in e?ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,si=(e,t)=>{for(var r in t||(t={}))ni.call(t,r)&&oi(e,r,t[r]);if(ri)for(var r of ri(t))ii.call(t,r)&&oi(e,r,t[r]);return e};function ai(e,t){const{bbox:r,width:n,height:i,nd:o}=e;return{resource:Array.isArray(t)?t.join(","):t,extent:r,size:n+","+i,timestamp:Date.now(),nd:null!=o?o:200}}const li={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 ci;function ui(e,t=0){const r=t,n=function(){if(void 0===ci){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),ci=t}return ci}()*function(e){return 12756274*Math.PI*Math.cos(e*Math.PI/180)}(r)/e,i=function(e){return Math.log(e/256)/Math.LN2}(n);return i}var hi=Object.defineProperty,pi=Object.defineProperties,di=Object.getOwnPropertyDescriptors,fi=Object.getOwnPropertySymbols,yi=Object.prototype.hasOwnProperty,mi=Object.prototype.propertyIsEnumerable,gi=(e,t,r)=>t in e?hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bi=(e,t)=>{for(var r in t||(t={}))yi.call(t,r)&&gi(e,r,t[r]);if(fi)for(var r of fi(t))mi.call(t,r)&&gi(e,r,t[r]);return e},vi=(e,t)=>pi(e,di(t)),_i=(e,t,r)=>gi(e,"symbol"!=typeof t?t+"":t,r),wi=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const Oi=class e extends Yt{constructor(r,n,i,o,s,a){if(super(bi(bi({},e.options),i)),this.webMap=r,_i(this,"item"),_i(this,"connector"),_i(this,"layer"),_i(this,"emitter",new t),_i(this,"_rootDescendantsCount",0),o&&(this.connector=o),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,i,o){return wi(this,null,(function*(){const s=new e(t,r,n,i,o,!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 wi(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){return[{layerId:r,legend:(yield t.get("render.legend_symbols",bi({params:{id:this.item.resourceId},cache:!0},e))).map((({display_name:e,icon:t})=>({name:e,symbol:t})))}]}}return[]}))}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=vi(bi({visibility:!1,name:e.display_name},this.options),{params:{resource:this.item.resourceId,item:this.item}});if(this.options.order){const t=String(this.options.drawOrderEnabled&&"draw_order_position"in e?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,vi(bi({updateWmsParams:e.updateWmsParams},this.options),{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 ui(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),void 0!==r.opacity&&this.webMap.setLayerOpacity(e,r.opacity)};let i;if("layer"===t.item_type)i=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){i=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return i?this.webMap.addLayer(i,r).then((e=>{n(e)})):t._layer?Promise.resolve(n(t._layer)):Promise.reject("No layer added")}_getZoomRange(e){const t=this.options.minZoom,r=this.options.maxZoom,n=e.layer_min_scale_denom?this._mapScaleToZoomLevel(e.layer_min_scale_denom):void 0,i=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,o=[t,n].filter(Boolean),s=[r,i].filter(Boolean);return{minZoom:o.length?Math.max(...o):void 0,maxZoom:s.length?Math.min(...s):void 0}}_init(e){this.initItem(e).then((()=>{this.emitter.emit("init")}))}_sumUp(e,t=0){for(const r of e)"layer"===r.item_type?(t+=1,r.draw_order_position=r.draw_order_position||t):"group"===r.item_type&&(t=this._sumUp(r.children,t));return t}};_i(Oi,"GetAdapterFromLayerType",{}),_i(Oi,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return gt(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 Ct{getProperty(){const e=this.item.layer;return e&&e&&e.options&&void 0!==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 Li=Oi;var Pi=Object.defineProperty,Ii=Object.getOwnPropertySymbols,Ei=Object.prototype.hasOwnProperty,ji=Object.prototype.propertyIsEnumerable,xi=(e,t,r)=>t in e?Pi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ci=(e,t)=>{for(var r in t||(t={}))Ei.call(t,r)&&xi(e,r,t[r]);if(Ii)for(var r of Ii(t))ji.call(t,r)&&xi(e,r,t[r]);return e},Ai=(e,t,r)=>xi(e,"symbol"!=typeof t?t+"":t,r),ki=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function Mi(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:i="first-show-adapter"}){const o=function(e){return ki(this,arguments,(function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){Ai(this,"options",{}),Ai(this,"layer",[]),Ai(this,"_removed",!1),Ai(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 ki(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 ki(this,null,(function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)}))}loadLayer(){return ki(this,null,(function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const i=yield n(this);if(i){const n=new i(e.mapAdapter.map,Ci({},t)),o=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=o,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer}))}}}))}({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=i+"-"+r.resource_id},createAdapter:()=>ei({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)});return o},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n}var Si=Object.defineProperty,Ni=Object.defineProperties,Ti=Object.getOwnPropertyDescriptors,Fi=Object.getOwnPropertySymbols,Bi=Object.prototype.hasOwnProperty,Ri=Object.prototype.propertyIsEnumerable,$i=(e,t,r)=>t in e?Si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Di=(e,t)=>{for(var r in t||(t={}))Bi.call(t,r)&&$i(e,r,t[r]);if(Fi)for(var r of Fi(t))Ri.call(t,r)&&$i(e,r,t[r]);return e},qi=(e,t,r)=>$i(e,"symbol"!=typeof t?t+"":t,r),Vi=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));class Gi{constructor(e,r){this.map=e,this.options=r,qi(this,"layer"),qi(this,"NgwWebmapItem",Li),qi(this,"pixelRadius",10),qi(this,"resourceId"),qi(this,"webmapClassName","webmap"),qi(this,"emitter",new t),qi(this,"_extent"),qi(this,"response"),qi(this,"_webmapLayersIds"),qi(this,"_webmapBaselayersIds",[]),qi(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 Vi(this,null,(function*(){var t,r;this.options=Di(Di({},this.options),e),this.layer=yield this._getWebMapLayerItem();const n=null==(r=null==(t=this.response)?void 0:t.webmap)?void 0:r.extent_constrained;return this.options.useExtentConstrained&&this._extent&&n&&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.response,delete this._webmapLayersIds}showLayer(){return Vi(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)}))}hideLayer(){return Vi(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)}))}setOpacity(e){return Vi(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.response&&this.response.webmap;if(e)return cr(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.response&&this.response.webmap;if(e)return e.bookmark_resource.id}fetchBookmarks(){const e=this.getBookmarksResourceId(),t=this.options.connector;if(e)return t.getResourceOrFail(e).then((r=>{var n;const i=null==(n=r.feature_layer)?void 0:n.fields.find((e=>e.label_field)),o=i&&i.keyname;return an({connector:t,resourceId:e,geom:!1,fields:o?[o]:void 0}).then((r=>{const n=[];for(const i of r){const r=new mt({item:i,resourceId:e,labelField:o,connector:t});n.push(r)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(){return Vi(this,null,(function*(){const e=[];let t=this.getDependLayers();t=t.sort(((e,t)=>t.id-e.id));for(const r of t){const t=yield r.getLegend();e.push(...t)}return e}))}getIdentificationIds(){return Vi(this,null,(function*(){const e=[];let t=this._webmapLayersIds;if(t||(t=yield this._getWebMapIds(),this._webmapLayersIds=t),t&&t.length){let t=this.getDependLayers();t=t.sort(((e,t)=>t.id-e.id)),t.forEach((t=>{const r=t.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type&&r.layer_identifiable){const r=t.properties.property("visibility");r.get()&&!r.isBlocked()&&e.push(n)}}))}return e}))}_getWebMapLayerItem(){return Vi(this,null,(function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise((t=>{const r=this.options.connector,n=(null==r?void 0:r.options.auth)?r.getAuthorizationHeaders():void 0,i=r.withCredentials,o=(s=Di({},this.options),Ni(s,Ti({withCredentials:i,headers:n,drawOrderEnabled:e.draw_order_enabled})));var s;const a=new this.NgwWebmapItem(this.options.webMap,e.root_item,o,r);a.emitter.on("init",(()=>{t(a)}))})):void 0}))}getWebMapConfig(e){return Vi(this,null,(function*(){const t=yield this.options.connector.getResource(e);if(t){this.response=t;const e=t[this.webmapClassName];if(this._setupBaselayers(t),e)return this._extent=[e.extent_left,e.extent_bottom,e.extent_right,e.extent_top],this._updateItemsParams(e.root_item,this.options.webMap,t),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)Mi({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then((e=>{const i=!r&&n.enabled;return n.enabled&&(r=!0),t.addBaseLayer(e,{id:"webmap-baselayer"+n.resource_id,name:n.display_name,opacity:n.opacity,visibility:i}).then((e=>{e.id&&this._webmapBaselayersIds.push(e.id)}))}))}_updateItemsParams(e,t,r){if(e)if("group"===e.item_type||"root"===e.item_type)e.children&&(e.children=e.children.map((e=>this._updateItemsParams(e,t,r)))),"root"===e.item_type&&(e.display_name=r.resource.display_name);else if("layer"===e.item_type){const r=q(this.options.connector.options.baseUrl+"/api/component/render/image"),n=e.layer_style_id;e.url=r,e.resourceId=n,e.updateWmsParams=e=>ai(e,n);const i=xn({options:{adapter:e.layer_adapter.toUpperCase(),resource:n},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=Di(Di({},e),i)}return e}_getWebMapIds(){return Vi(this,null,(function*(){const e=this.layer;if(e&&"root"===e.item.item_type){const t=e.tree.getDescendants(),r=[];for(const e of t){const t=e.item;if("layer"===t.item_type){const e=this.options.connector.getResource(t.layer_style_id).then((e=>{if(e){const r=Number(e.resource.parent.id);return t.parentId=r,r}}));r.push(e)}}return(yield Promise.all(r)).filter((e=>void 0!==e))}}))}}var Ui=Object.defineProperty,zi=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Wi=Object.prototype.propertyIsEnumerable,Hi=(e,t,r)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ji=(e,t)=>{for(var r in t||(t={}))Zi.call(t,r)&&Hi(e,r,t[r]);if(zi)for(var r of zi(t))Wi.call(t,r)&&Hi(e,r,t[r]);return e},Qi=(e,t,r)=>Hi(e,"symbol"!=typeof t?t+"":t,r);class Ki{constructor(e){if(this.options=e,Qi(this,"url"),Qi(this,"connector"),Qi(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 Ae({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){Kn[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(Gi,Ji({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n}getLayerAdapters(){return Promise.resolve([this._getLayerAdapter()])}_getLayerAdapter(){return{name:"WEBMAP",createAdapter:e=>Promise.resolve(this._createAdapter(e))}}_createAdapter(e){return t={webMap:e,connector:this.connector,baseUrl:this.url},class extends Gi{constructor(e,r){super(e,r=si(si({},t),r))}};var t}}var Xi=Object.defineProperty,Yi=Object.getOwnPropertySymbols,eo=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,ro=(e,t,r)=>t in e?Xi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,no=(e,t,r)=>ro(e,"symbol"!=typeof t?t+"":t,r);class io{constructor(e){no(this,"id"),no(this,"label"),no(this,"layerId"),no(this,"parent"),no(this,"fields"),no(this,"geom"),no(this,"extensions"),no(this,"connector"),no(this,"_item"),no(this,"_geojson"),no(this,"_resource"),no(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?O.resolve(this._item):dt(((e,t)=>{for(var r in t||(t={}))eo.call(t,r)&&ro(e,r,t[r]);if(Yi)for(var r of Yi(t))to.call(t,r)&&ro(e,r,t[r]);return e})({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(){return this._resource?O.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId).then((e=>(this._resource=e,this._resource.feature_layer)))}getBounds(){return this._extent?O.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0}){return r.get("feature_layer.feature.item_extent",{cache:n},{id:e,fid:t}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:i}=e.extent;return[i,n,r,t]}}))}({connector:this.connector,featureId:this.id,resourceId:this.layerId})}geojson(){return this._geojson?O.resolve(this._geojson):this.identify().then((e=>e.toGeojson().then((e=>(this._geojson=e,e)))))}}function oo(e){return dt(e).then((e=>Ke(e)))}var so=Object.defineProperty,ao=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,co=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,po=(e,t,r)=>t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fo=(e,t)=>{for(var r in t||(t={}))uo.call(t,r)&&po(e,r,t[r]);if(co)for(var r of co(t))ho.call(t,r)&&po(e,r,t[r]);return e},yo=(e,t)=>ao(e,lo(t));function mo(e,t=!1){const r=[],n=[];for(const o in e){const e=Number(o);isNaN(e)||r.push(e)}const i=e.resources;i&&r.sort(((e,t)=>i.indexOf(e)-i.indexOf(t)));for(let o=0;o<r.length;o++){const i=r[o],s=e[i];if("features"in s){const e=go(s.features,Number(i),t);if(e.length&&(n.push(...e),!t))break}}return n}function go(e,t,r){const n=[];for(const i of e){if(n.push({featureId:i.id,resourceId:t,feature:i}),!r)break}return n}function bo(e){const{geom:t,signal:r,cache:n,layers:i}=e,o="string"==typeof t?t:function(e){const t=function(e){var t;if(Array.isArray(e))return e;if("Feature"===e.type)return null==(t=e.geometry)?void 0:t.coordinates[0];if("Polygon"===e.type)return e.coordinates[0];return null}(e);if(!t)return null;return`POLYGON((${t.map((([e,t])=>{const[r,n]=F(e,t);return`${r} ${n}`})).join(",")}))`}(t);if(!o)throw new Error("Not valid geometry format to make intersection");return e.connector.post("feature_layer.identify",{data:{geom:o,srs:3857,layers:i},signal:r,cache:n})}function vo(e,t){return r=this,n=null,i=function*(){var r;const n=yield e.get("pyramid.settings",null,{component:"pyramid"});if(n&&n.company_logo&&n.company_logo.enabled){const o=document.createElement("a");o.style.position="absolute",o.style.bottom="0",o.style.right="0",o.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",o.className="ngw-map-logo",t&&t.cssClass&&(o.className+=" "+t.cssClass);const s=new Image;s.style.maxHeight="100px",s.style.maxWidth="100px",s.src="";try{const t=yield e.get("pyramid.company_logo",{responseType:"blob"}),r=(window.URL||window.webkitURL).createObjectURL(t);s.src=r}catch(i){console.warn(i)}return null!==n.company_logo.link&&""!==n.company_logo.link.trim()&&(o.href=n.company_logo.link,o.target="_blank",-1!==n.company_logo.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),o.appendChild(s),o}},new Promise(((e,t)=>{var o=e=>{try{a(i.next(e))}catch(r){t(r)}},s=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((i=i.apply(r,n)).next())}));var r,n,i}function _o(e){return"function"==typeof e}function wo(e){return(t,r)=>{const n=t.map((e=>e()));return e(n,r)}}const Oo={"!":wo((function([e]){return!e})),"!=":wo((function([e,t]){return e!==t})),"<":wo((function([e,t]){return e<t})),"<=":wo((function([e,t]){return e<=t})),"==":wo((function([e,t]){return e===t})),">":wo((function([e,t]){return e>t})),">=":wo((function([e,t]){return e>=t})),coalesce:e=>{for(let t=0;t<e.length;t++){const r=e[t]();if(null!=r)return r}return null},all:e=>{for(let t=0;t<e.length;t++){if(!e[t]())return!1}return!0},any:e=>{for(let t=0;t<e.length;t++){if(e[t]())return!0}return!1},case:e=>{if(e.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(e.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(let t=0;t<e.length-1;t+=2){const r=e[t](),n=e[t+1]();if(r)return n}return(0,e[e.length-1])()},match:e=>{const[t,...r]=e,n=t(),i=r.splice(-1,r.length%2)[0];for(let o=0;o<r.length-1;o+=2){if(r[o]()===n)return r[o+1]()}return i()}},Lo={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 Po(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Io(e);if("string"==typeof(t=e)&&t in Lo)return function(e){return Io(Lo[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 Io(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 Eo(e,t,r,n,i){if("number"==typeof r&&"number"==typeof i)return r+(e-t)/(n-t)*(i-r);try{const o=Po(r),s=Po(i);return function(e){return`rgb(${e.join(",")})`}(o.map(((r,i)=>Math.ceil(Eo(e,t,r,n,s[i])))))}catch(o){console.log(o)}throw new Error("Unsupported output type for linear interpolation.")}const jo={step:e=>{const[t,r,...n]=e,i=t();if("number"!=typeof i)return r();for(let o=0;o<n.length-2;o+=2){const e=n[o](),t=n[o+1](),r=n[o+2]();if(i>=e&&i<r)return t}return i>=n[n.length-2]()?n[n.length-1]():r()},interpolate:([e,t,...r])=>{if(r.length<2)throw new Error("At least two stops are required");if(r.length<2||r.length%2!=0)throw new Error("Invalid stops provided.");const n=t();if("number"!=typeof n)throw new Error("Input must be a number.");const i=e();for(let o=0;o<r.length-2;o+=2){const e=r[o](),t=r[o+1](),s=r[o+2](),a=r[o+3]();if(n>=e&&n<=s&&"linear"===i[0])return Eo(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const xo={get:wo((function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null})),length:wo((([e])=>{if("string"==typeof e||Array.isArray(e))return e.length})),at:wo((function([e,t]){return t[e]})),has:wo((function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))})),in:wo((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":wo((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:wo((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}.`)}))},Co={"+":wo((e=>e.reduce(((e,t)=>e+t),0))),"-":wo((e=>e.reduce(((e,t)=>e-t)))),"*":wo((e=>e.reduce(((e,t)=>e*t),1))),"/":wo((e=>e.reduce(((e,t)=>e/t)))),"%":wo((e=>e[0]%e[1])),"^":wo((e=>Math.pow(e[0],e[1]))),abs:wo((e=>Math.abs(e[0]))),acos:wo((e=>Math.acos(e[0]))),asin:wo((e=>Math.asin(e[0]))),atan:wo((e=>Math.atan(e[0]))),ceil:wo((e=>Math.ceil(e[0]))),cos:wo((e=>Math.cos(e[0]))),e:()=>Math.E,floor:wo((e=>Math.floor(e[0]))),ln:wo((e=>Math.log(e[0]))),ln2:()=>Math.LN2,log10:wo((e=>Math.log10(e[0]))),log2:wo((e=>Math.log2(e[0]))),max:wo((e=>Math.max(...e))),min:wo((e=>Math.min(...e))),pi:()=>Math.PI,round:wo((e=>Math.round(e[0]))),sin:wo((e=>Math.sin(e[0]))),sqrt:wo((e=>Math.sqrt(e[0]))),tan:wo((e=>Math.tan(e[0])))},Ao={concat:wo((e=>e.reduce(((e,t)=>String(e)+String(t)),""))),downcase:wo((e=>String(e[0]).toLowerCase())),upcase:wo((e=>String(e[0]).toUpperCase()))},ko=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function Mo(e){return(t,r)=>{for(const n of t){const t=ko(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const So={array:wo((e=>{const[t,r,n]=e;let i,o,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(i=t,"number"==typeof r?(o=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(i&&!s.every((e=>typeof e===i)))throw new Error(`Expected all items in array to be of type ${i}`);if(o&&s.length!==o)throw new Error(`Expected array of length ${o}`);return s})),boolean:wo(Mo((e=>"boolean"==typeof e?e:void 0))),literal:wo((([e])=>e)),number:wo(Mo((e=>"number"==typeof e?e:void 0))),object:wo(Mo((e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e))),string:wo(Mo((e=>"string"==typeof e?e:void 0))),"to-boolean":wo(Mo(Boolean)),"to-number":wo(Mo(Number)),"to-string":wo(Mo(String)),typeof:wo((([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 No=Object.defineProperty,To=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty,Bo=Object.prototype.propertyIsEnumerable,Ro=(e,t,r)=>t in e?No(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$o=(e,t)=>{for(var r in t||(t={}))Fo.call(t,r)&&Ro(e,r,t[r]);if(To)for(var r of To(t))Bo.call(t,r)&&Ro(e,r,t[r]);return e};function Do(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in qo&&r.length>0}return!1}const qo=$o($o($o($o($o($o({},Co),So),Ao),xo),Oo),jo);function Vo(e,t={}){const[r,...n]=e,i=qo[r];if(i)return i(n.map((e=>()=>Do(e)?Vo(e,t):e)),t);throw new Error(`Expression "${r}" is not supported.`)}var Go=Object.defineProperty,Uo=Object.getOwnPropertySymbols,zo=Object.prototype.hasOwnProperty,Zo=Object.prototype.propertyIsEnumerable,Wo=(e,t,r)=>t in e?Go(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ho=(e,t)=>{for(var r in t||(t={}))zo.call(t,r)&&Wo(e,r,t[r]);if(Uo)for(var r of Uo(t))Zo.call(t,r)&&Wo(e,r,t[r]);return e};function Jo(e){return t=>{const r=t.properties;return!!r&&Vo(e,r)}}const Qo=["iconSize","iconAnchor"];var Ko=Object.defineProperty,Xo=Object.getOwnPropertySymbols,Yo=Object.prototype.hasOwnProperty,es=Object.prototype.propertyIsEnumerable,ts=(e,t,r)=>t in e?Ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rs=(e,t)=>{for(var r in t||(t={}))Yo.call(t,r)&&ts(e,r,t[r]);if(Xo)for(var r of Xo(t))es.call(t,r)&&ts(e,r,t[r]);return e};function ns(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=Fe({},e.properties);return!!r&&(r.$id=e.id,De(r,t))}(e,t[0])));return n?rs(rs({},t),n[1]):t}}function is({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===Qo.indexOf(n)){const i=n,o=e[i];Do(o)&&(t=!0,r[i]=Jo(o))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return Ho(Ho({},e),n)}}(e);if(r){const n=e=>ss({paint:r(e),defaultPaint:t});return n.paint=os({paint:e,defaultPaint:t}),n}return os({paint:e,defaultPaint:t})}function os({paint:e,defaultPaint:t}){var r;let n=rs({},t);return n=rs(rs({},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 ss({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=rs({},t);if(_o(e)){const n=n=>{const i=ss({paint:e(n),defaultPaint:t,getPaintFunctions:r});return i.type=e.type,i};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>ss({paint:ns(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const i=function(e,t){if("function"==typeof e.from)return e.from(e.options);if("string"==typeof e.from&&t){const r=t[e.from];if(r)return r(e.options)}}(e,r);i&&(n=ss({paint:i,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=is({paint:e,defaultPaint:t})}return _o(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 as=Object.defineProperty,ls=(e,t,r)=>((e,t,r)=>t in e?as(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class cs{constructor(){ls(this,"backspace",8),ls(this,"tab",9),ls(this,"enter",13),ls(this,"shift",16),ls(this,"ctrl",17),ls(this,"alt",18),ls(this,"pause/break",19),ls(this,"caps_lock",20),ls(this,"escape",27),ls(this,"page_up",33),ls(this,"page_down",34),ls(this,"end",35),ls(this,"home",36),ls(this,"left_arrow",37),ls(this,"up_arrow",38),ls(this,"right_arrow",39),ls(this,"down_arrow",40),ls(this,"insert",45),ls(this,"delete",46),ls(this,"left_window_key",91),ls(this,"right_window_key",92),ls(this,"select_key",93),ls(this,"numpad_0",96),ls(this,"numpad_1",97),ls(this,"numpad_2",98),ls(this,"numpad_3",99),ls(this,"numpad_4",100),ls(this,"numpad_5",101),ls(this,"numpad_6",102),ls(this,"numpad_7",103),ls(this,"numpad_8",104),ls(this,"numpad_9",105),ls(this,"multiply",106),ls(this,"add",107),ls(this,"subtract",109),ls(this,"decimal_point",110),ls(this,"divide",111),ls(this,"f1",112),ls(this,"f2",113),ls(this,"f3",114),ls(this,"f4",115),ls(this,"f5",116),ls(this,"f6",117),ls(this,"f7",118),ls(this,"f8",119),ls(this,"f9",120),ls(this,"f10",121),ls(this,"f11",122),ls(this,"f12",123),ls(this,"num_lock",144),ls(this,"scroll_lock",145),ls(this,"semi-colon",186),ls(this,"equal_sign",187),ls(this,",",188),ls(this,"-",189),ls(this,".",190),ls(this,"/",191),ls(this,"`",192),ls(this,"[",219),ls(this,"\\",220),ls(this,"]",221),ls(this,"'",222)}}var us=Object.defineProperty,hs=(e,t,r)=>((e,t,r)=>t in e?us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var ps=Object.defineProperty,ds=(e,t,r)=>((e,t,r)=>t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class fs{constructor(e,t){this.webMap=e,ds(this,"name"),ds(this,"event"),ds(this,"value"),t&&(t.value&&this.setValue(t.value),t.name&&(this.name=t.name),t.event&&(this.event=t.event))}getValue(){return this.value}setValue(e){this.value=e}}var ys=Object.defineProperty,ms=(e,t,r)=>((e,t,r)=>t in e?ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class gs extends fs{constructor(){super(...arguments),ms(this,"name","center"),ms(this,"event","moveend")}getValue(){return this.webMap.getCenter()}setValue(e){this.webMap.setCenter(e)}toString(e){const t=e.map((e=>e.toFixed(5)));return t[0]+"_"+t[1]}parse(e){return e.split("_").map(Number)}}var bs=Object.defineProperty,vs=(e,t,r)=>((e,t,r)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class _s extends fs{constructor(){super(...arguments),vs(this,"name","zoom"),vs(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(e){return String(e)}parse(e){return Number(e)}}var ws=Object.defineProperty,Os=(e,t,r)=>((e,t,r)=>t in e?ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Ls=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));let Ps=0;const Is={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},Es=class e{constructor(r){Os(this,"options",Is),Os(this,"emitter",new t),Os(this,"keys",e.keys),Os(this,"mapAdapter"),Os(this,"runtimeParams",[]),Os(this,"getPaintFunctions",e.getPaintFunctions),Os(this,"mapState",[gs,_s]),Os(this,"id",Ps++),Os(this,"_initMapState",{}),Os(this,"_starterKits"),Os(this,"_mapState",[]),Os(this,"_extent"),Os(this,"_eventsStatus",{}),Os(this,"_coordFromMapClickPromise"),Os(this,"_mapEvents",{}),this.mapAdapter=r.mapAdapter,this._starterKits=r.starterKits||[],r&&(this.options=x(Is||{},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 Ls(this,null,(function*(){return this.getEventStatus("create")||(yield this._setInitMapState(this.mapState),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()}getState(){const e={};return this._mapState.forEach((t=>{e[t.name]=t.getValue()})),e}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.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:k(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&&E(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),E(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return function(e){const[t,r,n,i]=e,o=t<n&&r<i;if(!o){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${i}]`);const e=[Math.min(t,n),Math.min(r,i),Math.max(t,n),Math.max(i,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&i<=90;s&&a||console.log("Warning: The coordinates may not be within valid geographic ranges.")}(e),e.every((e=>E(e)))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,t)),this}getEventStatus(e){const t=this._eventsStatus[e];return null!=t&&t}onLoad(e="create"){return new Promise((t=>{this.getEventStatus(e)?t(this):this.emitter.once(e,(()=>{t(this)}))}))}onMapLoad(e){return new Promise((t=>{var r;const n=()=>{const r=this.mapAdapter;e&&e(r),r&&t(r)},i=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&i?n():this.mapAdapter.emitter.once("create",(()=>{n()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(e){return this.mapAdapter.layerAdapters[e]}locate(e,t){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(e,t);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new O(((e,t,r)=>{const n=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const i=()=>{this.setCursor(n),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickPromise=void 0},o=t=>{i(),C(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),r(i)})),this._coordFromMapClickPromise)}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return Ls(this,null,(function*(){}))}_onLoadSync(){return Ls(this,null,(function*(){}))}_setupMap(){return Ls(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),E(e.maxzoom)&&(this.options.zoom=e.maxzoom),E(e.minzoom)&&(this.options.zoom=e.minzoom),E(e.maxzoom)&&E(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){const t=this._mapState.find((t=>t.event===e));if(t){const e=t.toString(t.getValue());this.runtimeParams.forEach((r=>{r.set(t.name,e)}))}}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)}))}};Os(Es,"keys",new class{constructor(){hs(this,"keyCodeAlias",new cs),hs(this,"keys",{}),hs(this,"_windowOnFocus"),hs(this,"_keysPressed"),hs(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={}}}),Os(Es,"getPaintFunctions");let js=Es;function xs(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 Cs(e){let t;if("FeatureCollection"===e.type){t=xs(e.features.map((e=>e.geometry.type)))}else if("GeometryCollection"===e.type){t=xs(e.geometries.map((e=>e.type)))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const As={polygon:"path",line:"path",point:"circle"},ks={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Ms(e){if(e.data){const t=ks[Cs(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":As[t]),e.type=e.type||t}return e}var Ss=Object.defineProperty,Ns=Object.defineProperties,Ts=Object.getOwnPropertyDescriptors,Fs=Object.getOwnPropertySymbols,Bs=Object.prototype.hasOwnProperty,Rs=Object.prototype.propertyIsEnumerable,$s=(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={}))Bs.call(t,r)&&$s(e,r,t[r]);if(Fs)for(var r of Fs(t))Rs.call(t,r)&&$s(e,r,t[r]);return e},qs=(e,t)=>Ns(e,Ts(t)),Vs=(e,t,r)=>$s(e,"symbol"!=typeof t?t+"":t,r),Gs=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));class Us extends js{constructor(e){super(e),Vs(this,"_layersIdCounter",1),Vs(this,"_layersOrderCounter",1),Vs(this,"_baselayers",[]),Vs(this,"_layers",{}),Vs(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(t)))}fitLayer(e,t){return Gs(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 Gs(this,null,(function*(){return yield this.addLayer(e,qs(Ds({},t),{baselayer:!0}),void 0)}))}addLayer(e){return Gs(this,arguments,(function*(e,t={},r){var n,i;const o=this._layersIdCounter++,s=E(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=Ds({id:String(o),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=Ds(Ds({},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(o),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(i=e.options.order)?i: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;void 0!==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 Gs(this,null,(function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),i=e(),o=yield i;return o?this.addLayer(o,t,n):Promise.reject("No adapter")}))}removeLayers(e){for(const t in this._layers){let r=!0;e&&(r=e(t,this._layers[t])),r&&(this.removeLayer(t),delete this._layers[t])}}getLegend(e){return Gs(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=Ms(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",qs(Ds({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",qs(Ds({},t),{url:r}))}showLayer(e,t={}){return this.toggleLayer(e,!0,t)}hideLayer(e,t={}){return this.toggleLayer(e,!1,t)}toggleLayer(e,t,r={}){const n=this.getLayer(e),i=void 0!==t?t:!(n&&n.options.visibility),o=void 0!==r.silent&&r.silent,s=e=>Gs(this,null,(function*(){const t=String(e.id),r=i?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(i?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),i&&this.mapAdapter){const t=e.options.baselayer?0:e.options.order;if(e.options.baselayer&&this._baselayers.length){const t=this._baselayers.filter((t=>t!==e.id&&this.isLayerVisible(t)));for(const e of t)yield this.hideLayer(e)}e.showLayer?yield e.showLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.showLayer(e.layer)),void 0!==t&&this.mapAdapter.setLayerOrder(e.layer,t,this._layers)}else e.hideLayer?yield e.hideLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.hideLayer(e.layer));e.options.visibility=i,o||(this._emitLayerEvent(r,t,e),this._emitLayerEvent("layer:toggle",t,e))}));return n?this.onMapLoad().then((()=>s(n))):Promise.resolve()}updateLayer(e){const t=this.getLayer(e);if(t){if(t.updateLayer)return Promise.resolve(t.updateLayer());if(this.isLayerVisible(t))return this.hideLayer(t,{silent:!0}).then((()=>this.showLayer(t,{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||De(e.feature.properties,t)))}return Promise.resolve()}removeLayerFilter(e){const t=this.getLayer(e);t.removeFilter?t.removeFilter():t.filter&&t.filter((()=>!0))}setLayerData(e,t){const r=this.getLayer(e);if(r){if(r.setData)return r.setData(t);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(t)}return Promise.resolve()}addLayerData(e,t){const r=this.getLayer(e);r.addData&&r.addData(t)}clearLayerData(e,t){const r=this.getLayer(e);r&&r.clearLayer&&r.clearLayer(t)}setLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.setPaint&&r.setPaint(t)}setLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.setSelectedPaint&&r.setSelectedPaint(t)}updateLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.updatePaint&&r.updatePaint(t)}updateLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(t)}getAttributions(e){const t=[];for(const r in this._layers){const n=this._layers[r];let i=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(i&&e.onlyBaselayer&&(i=this._baselayers.includes(r)),i){const e=n.options&&n.options.attribution;e&&t.push(e)}}return t}getActiveBaseLayer(){const e=this.getBaseLayers().find((e=>this.isLayerVisible(e)));if(e)return this.getLayer(e)}addTileJsonLayer(e){return this.addLayer("TILE",{url:e.tiles[0],maxZoom:e.maxzoom,minZoom:e.minzoom,subdomains:e.scheme,attribution:e.attribution})}_emitLayerEvent(e,t,r){const n=String(e);if(E(t)&&n.startsWith("layer:")){const e=n.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return Gs(this,null,(function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerDoubleClick(e){return Gs(this,null,(function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerSelect(e){return Gs(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:i,onLayerClick:o,onMouseOut:s,onMouseOver:a}=e,l=n||o,c=i||o;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),E(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;a&&a(e),E(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const u=t||r;e.onSelect=e=>(u&&u(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=ss({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=ss({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}function zs(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const i=t.title||"",o=t.html;function s(){i&&(r.title="string"==typeof i?i:n?i.on:i.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(){o&&("string"==typeof o||o instanceof HTMLElement?a(o):a(n?o.on:o.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 Zs=Object.defineProperty,Ws=(e,t,r)=>((e,t,r)=>t in e?Zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Hs=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const Js=class e extends Us{constructor(){super(...arguments),Ws(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),Ws(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return Hs(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,(()=>Hs(this,null,(function*(){const r=yield n,i=this.mapAdapter.addControl(r,t);e(i)}))))}))}))}createControl(e,t){return Hs(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)}))}createButtonControl(e){return Hs(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)}))}createToggleControl(e){return Hs(this,null,(function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?zs(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 Hs(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}))}};Ws(Js,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let Qs=Js;const Ks={};function Xs(e){return Ks[e]}function Ys(e,t){Ks[e]=t}var ea=Object.getOwnPropertySymbols,ta=Object.prototype.hasOwnProperty,ra=Object.prototype.propertyIsEnumerable,na=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ia=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())})),oa=(e,t,r)=>(t=e[na("asyncIterator")])?t.call(e):(e=e[na("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,i,o)=>(t=n.call(e,t),o=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:o})),i))))),r("next"),r("return"),t);class sa extends Qs{constructor(e){super(e),this._addControls(),Ys(this.id,this)}static get(e){return Xs(e)}_addLayerProviders(){return ia(this,null,(function*(){try{for(var e,t,r,n=oa(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.getLayerAdapters){const t=yield e.getLayerAdapters.call(e);if(t)try{for(var i,o,s,a=oa(t);i=!(o=yield a.next()).done;i=!1){const e=o.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(o){s=[o]}finally{try{i&&(o=a.return)&&(yield o.call(a))}finally{if(s)throw s[0]}}}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_onLoadSync(){return ia(this,null,(function*(){try{for(var e,t,r,n=oa(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.onLoadSync)try{yield e.onLoadSync.call(e,this)}catch(i){console.error(i)}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_addControls(){this.options.controls&&this.options.controls.forEach((e=>{let t=e,r={};"string"==typeof e&&this.options.controlsOptions&&this.options.controlsOptions[e]&&(r=this.options.controlsOptions[e],void 0!==r.control&&(t=r.control));const n=r,{position:i}=n,o=((e,t)=>{var r={};for(var n in e)ta.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&ea)for(var n of ea(e))t.indexOf(n)<0&&ra.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,i||"top-left",o)})),this._emitStatusEvent("controls:create")}}function aa(){return["ZOOM","ATTRIBUTION"]}function la(e){return t=this,r=null,n=function*(){return new sa(e).onLoad()},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n}var ca=Object.defineProperty,ua=Object.defineProperties,ha=Object.getOwnPropertyDescriptors,pa=Object.getOwnPropertySymbols,da=Object.prototype.hasOwnProperty,fa=Object.prototype.propertyIsEnumerable,ya=(e,t,r)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ma=(e,t)=>{for(var r in t||(t={}))da.call(t,r)&&ya(e,r,t[r]);if(pa)for(var r of pa(t))fa.call(t,r)&&ya(e,r,t[r]);return e},ga=(e,t)=>ua(e,ha(t));function ba(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(ga(ma({},r),{resource:t}));else if(Array.isArray(t)){const[i,o]=t;e.push(ma(ga(ma({},r),{resource:i,id:o}),n))}else"object"==typeof t&&e.push(ma(ma(ma({},r),t),n))}var va=Object.defineProperty,_a=Object.defineProperties,wa=Object.getOwnPropertyDescriptors,Oa=Object.getOwnPropertySymbols,La=Object.prototype.hasOwnProperty,Pa=Object.prototype.propertyIsEnumerable,Ia=(e,t,r)=>t in e?va(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const Ea={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 ja(e){const t=[new Fr];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 Ae({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=x(Ea,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new Ki({connector:e.connector,auth:e.auth})),r=((e,t)=>{for(var r in t||(t={}))La.call(t,r)&&Ia(e,r,t[r]);if(Oa)for(var r of Oa(t))Pa.call(t,r)&&Ia(e,r,t[r]);return e})({},e),e=_a(r,wa({starterKits:t,create:!1}))}var xa=Object.defineProperty,Ca=Object.defineProperties,Aa=Object.getOwnPropertyDescriptors,ka=Object.getOwnPropertySymbols,Ma=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty,Na=Object.prototype.propertyIsEnumerable,Ta=Reflect.get,Fa=(e,t,r)=>t in e?xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ba=(e,t)=>{for(var r in t||(t={}))Sa.call(t,r)&&Fa(e,r,t[r]);if(ka)for(var r of ka(t))Na.call(t,r)&&Fa(e,r,t[r]);return e},Ra=(e,t)=>Ca(e,Aa(t)),$a=(e,t,r)=>Fa(e,"symbol"!=typeof t?t+"":t,r),Da=(e,t,r)=>Ta(Ma(e),r,t),qa=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const Va=class e extends sa{constructor(e){super(ja(e)),$a(this,"emitter",new t),$a(this,"connector"),$a(this,"_ngwLayers",{}),$a(this,"$$selectFromNgwRaster"),$a(this,"$$selectFromNgwVector"),$a(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 qa(this,null,(function*(){return yield this.onLoad("controls:create"),Da(e.prototype,this,"addControl").call(this,t,r,n)}))}addNgwLayer(e){return qa(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(E(this.options.baseUrl))try{E(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},E(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),ei(e,t,r)}(e,this,this.connector),r=Ba(Ba({visibility:!0},e),e.adapterOptions),n=yield this.addLayer(t,r),i=n&&this.getLayerId(n);if(n&&i&&(this._ngwLayers[i]={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(i){const e=D(n)&&"id"in n?n.id:t||r||n;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 dt(Ba({connector:this.connector},e))}fetchNgwLayerItems(e){return an(Ba({connector:this.connector},e))}fetchNgwLayerFeature(e){return oo(Ba({connector:this.connector},e))}fetchNgwLayerFeatures(e){return cn(Ba({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=function(e){const{connector:t,identify:r}=e,n=mo(r);return n&&n.length?dt(fo(fo({connector:t},e.requestOptions),n[0])):O.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",r),r}fetchIdentifyGeoJson(e,t=!1){const r=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const o in r){const e=Number(o);if(!isNaN(e)){const e=r[o];if("features"in e){const t=e.features.find((e=>e.geom));if(t&&t.geom){const e=t.geom;return O.resolve(Ke(yo(fo({},t),{geom:e})))}}}}const i=mo(r);return i&&i.length?oo(fo(yo(fo({},n),{connector:t}),i[0])):O.resolve(void 0)}({identify:e,connector:this.connector,multiple:t});return r&&"then"in r?(this._addPromise("identify",r),r):O.resolve(r)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,t)}getNgwLayers(){return qa(this,null,(function*(){return yield this.onLoad(),this._ngwLayers}))}getNgwLayerByResourceId(e){return qa(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&&t.item.parentId===e));if(t)return t.layer}}}))}fitLayer(t,r){return qa(this,null,(function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const i=n&&this._ngwLayers[n];if(i)if(i.layer.getBounds){const e=yield i.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(i.layer.item)e=i.layer.item;else{const t=i.resourceId;e=yield this.connector.getResource(t)}e&&hr({resourceId:e.resource.id,connector:this.connector}).then((e=>{e&&this.fitBounds(e,r)}))}else Da(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)}))}zoomToLayer(e){return qa(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.cancel())),this._promises[e]=[])}))}selectFromNgwRaster(e){return qa(this,null,(function*(){var t;this._emitStatusEvent("ngw:preselect");const r=[],n=Object.values(this._ngwLayers);n.sort(((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1));for(const e of n){const n=e.layer,i="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,o=null==(t=n.options.interactive)||t;i&&n.options.selectable&&o&&this.isLayerVisible(n)&&r.push(i.call(n))}const i=Promise.all(r),o=yield i,s=[];for(const e of o)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,i]=e.lngLat;h={type:"Polygon",coordinates:[T(n,i,u)]};const o=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:h}});r!==1/0&&setTimeout((()=>{this.removeLayer(o)}),r)}const p=function(e,t){C(e);const[r,n]=e.lngLat,{geom:i,radius:o,signal:s,cache:a}=t,l=null!=i?i:T(r,n,o);return bo(yo(fo({},t),{geom:l,signal:s,cache:a}))}(e,{layers:s,connector:this.connector,radius:u,geom:h}).then((t=>{const r=Ra(Ba({},t),{resources:s,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n}));return this._addPromise("select",p),p}))}_addPromise(e,t){const r=this._promises[e];if(r&&-1===r.indexOf(t)){const e=()=>{const e=r.indexOf(t);-1!==e&&r.splice(e,1)};t.then(e),t.catch(e),r.push(t)}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}_createWebMap(){return qa(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&&ba(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),ba(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,[r]:{featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]}};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(Ra(Ba({},t),{resources:[r],sourceType:"vector"}))),t}}}_prepareToIdentify(e){return Ra(Ba({},e),{getIdentifyItems:()=>mo(e,!0).map((e=>new io({feature:e.feature,connector:this.connector})))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return qa(this,null,(function*(){const e=this.getContainer();if(e){const t=yield vo(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}))}};$a(Va,"getIcon",(function(e={}){var t,r,n,i,o,s;const a=null!=(t=e.shape)?t:"circle",l=null!=(r=e.color)?r:"blue",c=null!=(n=e.strokeColor)?n:"white",u=null!=(i=e.size)?i:P,h=null!=(o=e.rotate)?o:0,p=null!=(s=e.anchor)?s:[u/2,u/2],d=void 0!==e.stroke?Number(e.stroke):.8,f=e.p||L[a]||"circle",y="string"==typeof f?f:f(e),m=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(e.svg||function({width:e,height:t,stroke:r=0,content:n}){const i=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${i} -${i} ${P+r} ${P+r}"\n >${n}</svg>`}({width:u,height:u,stroke:d,content:y}));return m.setAttribute("width",String(u)),m.setAttribute("height",String(u)),m.setAttribute("fill",l),d&&(m.setAttribute("stroke",c),m.setAttribute("stroke-width",String(d))),{type:"icon",iconSize:[u,u],iconAnchor:p,html:(new XMLSerializer).serializeToString(m),rotate:h,svg:m}}));let Ga=Va;function Ua(e){return t=this,r=null,n=function*(){return new Ga(e).onLoad()},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n}export{Ga as NgwMap,sa as WebMap,Qs as WebMapControls,Us as WebMapLayers,js as WebMapMain,Ua as createNgwMap,zs as createToggleControl,la as createWebMap,Cs as detectGeometryType,xs as findMostFrequentGeomType,aa as getDefaultControls,Xs as getWebMap,As as paintTypeAlias,Ys as setWebMap,ks as typeAlias,Ms as updateGeoJsonAdapterOptions};
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 p="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,p,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,p,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,p,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,p,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,p,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 p(e){return"string"==typeof e?!!e:u(e)}function h(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]=h(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]?h(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 g=Math.PI/180,b=180/Math.PI;function v(e,t,r=10,n=6){const o=r/f*b,i=o/Math.cos(t*g),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,E=(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 j=class e{constructor(t={}){var r;E(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r){return this.add(e,t,r,!0)}add(e,t,r,n){const o=this._find(e,r);if(o)return o.value;{let o;o=t instanceof Function?t():t;const i=r&&JSON.parse(JSON.stringify(L(r))),s={key:e,value:o,props:i};return n&&!p(o)?o:(this.cache.push(s),o instanceof Promise?(o.catch((t=>{this.delete(e,r)})),n&&o.then((t=>(p(t)||this.delete(e,r),t))),o):o)}}match(e,t){const r=this._find(e,t);return null==r?void 0:r.value}matchAll(e,t){return 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))}};E(j,"instance",{});let A=j;var C=Object.defineProperty,M=(e,t,r)=>((e,t,r)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class k extends Error{constructor(e){super(),M(this,"name","NgwError"),M(this,"title"),M(this,"message"),M(this,"detail"),M(this,"exception"),M(this,"status_code"),M(this,"data"),M(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,k.prototype)}}var S=Object.defineProperty,N=(e,t,r)=>((e,t,r)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class F extends k{constructor(e){super(e),N(this,"name","ResourceNotFoundError"),N(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,F.prototype)}}function T(e){return"[object Object]"===Object.prototype.toString.call(e)}const B=["description"];function R(e,t=""){t=t?t+"__":"";const r={};for(const[n,o]of Object.entries(e))if(-1===B.indexOf(n))if(T(o))if("owner_user"===n){const e=R(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 $=Object.defineProperty,D=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,U=(e,t,r)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,G=(e,t)=>{for(var r in t||(t={}))q.call(t,r)&&U(e,r,t[r]);if(D)for(var r of D(t))V.call(t,r)&&U(e,r,t[r]);return e},z=(e,t,r)=>U(e,"symbol"!=typeof t?t+"":t,r);class Z{constructor({connector:e,cacheId:t}){z(this,"cache"),z(this,"connector"),this.connector=e,this.cache=new A({namespace:t})}getOne(e,t){const r=G({},t);return"string"==typeof e||"number"==typeof e||T(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):T(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 F}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||T(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,R(e)),this.connector.get("resource.search",t,G({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=>e?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,r=[]){return this.connector.get("resource.collection",t,{parent:e}).then((e=>{const n=[];for(const o of e)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(o),{id:o.resource.id}),r.push(o),(null==t?void 0:t.recursive)&&o.resource.children&&n.push(this._getChildrenOf(o.resource.id,t,r));return n.length?Promise.all(n).then((()=>r)):r}))}_cleanResourceItemCache(e){return t=this,r=null,n=function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;["resource.item","resource"].includes(o.key)&&void 0!==r&&("number"==typeof r?r===e&&n.push(o):(yield this.getId(r))===e&&n.push(o))}for(const e of n)this.cache.delete(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}_fetchResourceById(e,t){return this.connector.get("resource.item",t,{id:e})}_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)})),[])))}}const W=[];function J(e){W.push(e)}class H extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}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 k{constructor(e){super(e),K(this,"name","InsufficientPermissionsError"),K(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,X.prototype)}}const Y=/\{ *([\w_-]+) *\}/g;function ee(e,t){return e.replace(Y,((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 te=Object.defineProperty,re=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,ie=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function se(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=ee(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={}))ne.call(t,r)&&ie(e,r,t[r]);if(re)for(var r of re(t))oe.call(t,r)&&ie(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 ae=Object.defineProperty,le=(e,t,r)=>((e,t,r)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ce extends Error{constructor(e){super(),le(this,"name","NetworkError"),Object.setPrototypeOf(this,ce.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}let ue;ue=(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 k(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 ce(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)};var pe=Object.defineProperty,he=Object.defineProperties,de=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,ge=(e,t,r)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,be=(e,t)=>{for(var r in t||(t={}))ye.call(t,r)&&ge(e,r,t[r]);if(fe)for(var r of fe(t))me.call(t,r)&&ge(e,r,t[r]);return e},ve=(e,t,r)=>ge(e,"symbol"!=typeof t?t+"":t,r),we=(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 _e=0,Oe=0;class Le{constructor(e){this.options=e,ve(this,"id",_e++),ve(this,"emitter",new t),ve(this,"user"),ve(this,"resources"),ve(this,"cache"),ve(this,"withCredentials"),ve(this,"routeStr","/api/component/pyramid/route"),ve(this,"activeRequests",{}),ve(this,"requestTransform");const r=function(e){return W.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:t,requestTransform:r,withCredentials:n}=this.options;t&&(this.routeStr=t),r&&(this.requestTransform=r),void 0!==n&&(this.withCredentials=n),this.resources=new Z({connector:this,cacheId:e.cacheId}),J(this)}}static create(e){return new this(e)}clearCache(){this.cache.clean(),this.resources.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,J(this)}connect(){return we(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}))}return yield this.makeQuery(this.routeStr,{},{cacheName:"route",cache:!0,cacheProps:{id:this.id,auth:e,baseUrl:this.options.baseUrl}})}))}login(e,t){return this.logout(),J(this),this._login(e,t)}logout(){this.abort(),function(e){const t=W.indexOf(e);-1!==t&&W.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return we(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=be({headers:this.getAuthorizationHeaders(e)},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);if(t)return{Authorization:`Basic ${t}`}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=encodeURIComponent(`${t}:${r}`);return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return be({},this.activeRequests)}apiRequest(e,t={},r={}){var n;return se({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)}makeQuery(e,t){return we(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)ye.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&fe)for(var n of fe(e))t.indexOf(n)<0&&me.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=ee(e,r)}e=encodeURI(I(e)),r=be({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:p}=r,h=new AbortController,d=h.signal;if(i){if(i.aborted)throw new H;i.addEventListener("abort",(()=>{h.abort()}))}r.signal=d;const f=()=>we(this,null,(function*(){const t=Oe++;this.activeRequests[t]=h;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if(o&&"GET"===s){const r=c||(y=be({},L({headers:a,withCredentials:p,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),he(y,de({params:t})));return this.cache.add(l||e,f,r,!1)}var y;return f()}))}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)}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=be(be({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;ue(e,r,t,n,(e=>{i=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==i&&i(),n(new H)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return we(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 k){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new F(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new X(e)}return e}}ve(Le,"errors",{NgwError:k,ResourceNotFoundError:F});var Pe=Object.defineProperty,Ie=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,je=(e,t,r)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ae=(e,t)=>{for(var r in t||(t={}))xe.call(t,r)&&je(e,r,t[r]);if(Ie)for(var r of Ie(t))Ee.call(t,r)&&je(e,r,t[r]);return e};function Ce(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 Me={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)=>Ce(e,t),ilike:(e,t)=>Ce(e,t,!0)};function ke(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Se(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(ke(t)){const[r,n,o]=t,i=Me[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 Se(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}var Ne=Object.defineProperty,Fe=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,De=(e,t,r)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qe=(e,t)=>{for(var r in t||(t={}))Re.call(t,r)&&De(e,r,t[r]);if(Be)for(var r of Be(t))$e.call(t,r)&&De(e,r,t[r]);return e},Ve=(e,t)=>Fe(e,Te(t)),Ue=(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 Ge={srs:4326,geom_format:"geojson"};function ze(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function Ze(e,t){const{extensions:r,geom:n,fields:o,srs:i,ilike:s,like:a}=t,l=r?r.join(","):"";"*"!==l&&(e.extensions=l),void 0!==o&&(e.fields=Array.isArray(o)?o.join(","):""),void 0!==n&&(e.geom=n?"yes":"no",n||(delete e.srs,delete e.geom_format)),u(s)?e.ilike=s:u(a)&&(e.like=a),u(i)&&(e.srs=i)}function We(e){return Ue(this,null,(function*(){const t=He(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 Je(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 He(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)ke(l)?t.push(Ke(Ve(qe({},e),{paramList:[...r,...i,Je(l)]}))):He(Ve(qe({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)ke(e)?n.push(Je(e)):o.push(e);if(o.length)for(const i of o)He(Ve(qe({},e),{filters:i}),t,[...r,...n]);else t.push(Ke(Ve(qe({},e),{paramList:[...r,...i,...n]})))}return t}function Qe(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 Ke(e){const t=qe({},Ge),{limit:r,cache:n,signal:o,offset:i,orderBy:s,paramList:a,connector:l,geomFormat:c,intersects:u,resourceId:p}=e;if(r?r!==Number.POSITIVE_INFINITY&&(t.limit=r):t.limit=7e3,i&&(t.offset=i),c&&(t.geom_format=c),Ze(t,e),s&&(t.order_by=s.join(",")),Array.isArray(u)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every((e=>"number"==typeof e))}(u)?m(u):u;t.intersects=Qe(e)}else"string"==typeof u&&(t.intersects=u);a&&(t.paramList=a);const h=qe({id:p},t);return l.get("feature_layer.feature.collection",{cache:n,signal:o},h)}var Xe=Object.defineProperty,Ye=Object.defineProperties,et=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,ot=(e,t,r)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,it=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&ot(e,r,t[r]);if(tt)for(var r of tt(t))nt.call(t,r)&&ot(e,r,t[r]);return e},st=(e,t)=>Ye(e,et(t)),at=(e,t,r)=>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 lt(e){return at(this,null,(function*(){const t=it({},Ge);Ze(t,e);const r=it({id:e.resourceId,fid:e.featureId},t),n=yield e.connector.get("feature_layer.feature.item",e,r);return st(it({},n),{toGeojson:()=>at(this,null,(function*(){if(n.geom)return ze(n);{const t=(yield lt(st(it({},e),{geom:!0,fields:null,extensions:null}))).geom;return ze(st(it({},n),{geom:t}))}}))})}))}var ct=Object.defineProperty,ut=Object.getOwnPropertySymbols,pt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,dt=(e,t,r)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t,r)=>dt(e,"symbol"!=typeof t?t+"":t,r);class yt{constructor(e){this.options=e,ft(this,"name"),ft(this,"resourceId"),ft(this,"item"),ft(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.get("feature_layer.feature.item_extent",e,{id:this.resourceId,fid:this.item.id}).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(ze(this.item)):lt(((e,t)=>{for(var r in t||(t={}))pt.call(t,r)&&dt(e,r,t[r]);if(ut)for(var r of ut(t))ht.call(t,r)&&dt(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,ze(this.item))))}}function mt(e,t,r,n){return!!vt(e,t,r,wt)}function gt(e,t,r,n){return vt(e,t,r,_t)}function bt(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 vt(e,t=(e=>!!e),r="children",n,o){return n(e,"function"==typeof t?t:e=>Se(e,t),r)}function wt(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(t(e))return e;const n=bt(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){const e=wt(o[i],t,r,n);if(e)return e}}function _t(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{t(e)&&n.push(e);const i=bt(e,r);i&&(o=i)}for(let i=0;i<o.length;i++)o[i]&&_t(o[i],t,r,n);return n}function Ot(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(!t(e))return!1;const n=bt(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){if(!Ot(o[i],t,r,n))return!1}return!0}var Lt=Object.defineProperty,Pt=(e,t,r)=>((e,t,r)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class It{constructor(e){Pt(this,"item"),Pt(this,"_children",[]),Pt(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?gt(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 vt(this._children,e,(e=>e.tree.getChildren()),wt)}every(e){return!!vt(this._children,e,(e=>e.tree.getChildren()),Ot)}some(e){return mt(this._children,e,(e=>e.tree.getChildren()))}all(e){return this.getDescendants(e)}getDescendants(e){return gt(this._children,e,(e=>e.tree.getChildren()))}getChildren(){return[...this._children]}}var xt=Object.defineProperty,Et=(e,t,r)=>((e,t,r)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class jt{constructor(e,r,n){Et(this,"options"),Et(this,"emitter",new t),Et(this,"name"),Et(this,"item"),Et(this,"_blocked",!1),Et(this,"_container"),Et(this,"_value"),Et(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 At=Object.defineProperty,Ct=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,kt=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)=>{for(var r in t||(t={}))Mt.call(t,r)&&St(e,r,t[r]);if(Ct)for(var r of Ct(t))kt.call(t,r)&&St(e,r,t[r]);return e};const Ft=class e extends jt{constructor(t,r,n){super(t,r,Nt(Nt({},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,Nt(Nt({},t),{propagation:!0,bubble:!1}))}}}};St(Ft,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let Tt=Ft;var Bt=Object.defineProperty,Rt=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,qt=(e,t,r)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Vt=(e,t,r)=>qt(e,"symbol"!=typeof t?t+"":t,r);const Ut=class e{constructor(e,t){this.item=e,Vt(this,"options",{}),Vt(this,"_properties",{}),Vt(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={}))$t.call(t,r)&&qt(e,r,t[r]);if(Rt)for(var r of Rt(t))Dt.call(t,r)&&qt(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}};Vt(Ut,"handlers",{CheckProperty:Tt});let Gt=Ut;var zt=Object.defineProperty,Zt=Object.getOwnPropertySymbols,Wt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Ht=(e,t,r)=>t in e?zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qt=(e,t,r)=>Ht(e,"symbol"!=typeof t?t+"":t,r);let Kt=0;class Xt{constructor(e){Qt(this,"options",{}),Qt(this,"properties"),Qt(this,"tree"),Qt(this,"id",Kt),Kt+=1,this.options=((e,t)=>{for(var r in t||(t={}))Wt.call(t,r)&&Ht(e,r,t[r]);if(Zt)for(var r of Zt(t))Jt.call(t,r)&&Ht(e,r,t[r]);return e})({},e),this.tree=new It(this)}initProperties(){this.properties=new Gt(this,this.options.properties)}}var Yt=Object.defineProperty,er=Object.defineProperties,tr=Object.getOwnPropertyDescriptors,rr=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,ir=(e,t,r)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,sr=(e,t)=>{for(var r in t||(t={}))nr.call(t,r)&&ir(e,r,t[r]);if(rr)for(var r of rr(t))or.call(t,r)&&ir(e,r,t[r]);return e},ar=(e,t)=>er(e,tr(t));function lr(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 cr({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.get("layer.extent",{cache:r,signal:n},{id:e}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}function ur(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then((t=>{if(t)return pr(t,e.connector,e)}))}function pr(e,t,r){if(e.webmap)return Promise.resolve(lr(e.webmap));{const n=e.resource;return n.cls&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id,r).then((e=>{if(e)return cr(ar(sr({},r),{resourceId:e.resource.id,connector:t}))})):cr(ar(sr({},r),{resourceId:n.id,connector:t}))}}var hr=Object.defineProperty,dr=(e,t,r)=>((e,t,r)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),fr=(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 yr{constructor(){dr(this,"item"),dr(this,"connector"),dr(this,"_extent")}getExtent(){return fr(this,null,(function*(){return this.getBounds()}))}getBounds(e){return fr(this,null,(function*(){return this._extent?this._extent:this.item?(this._extent=yield pr(this.item,this.connector,e),this._extent):void 0}))}}var mr=(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 gr(e,t){return mr(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 gr(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i}))}const br={tms:"TILE"};var vr=Object.defineProperty,wr=Object.getOwnPropertySymbols,_r=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable,Lr=(e,t,r)=>t in e?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pr=(e,t)=>{for(var r in t||(t={}))_r.call(t,r)&&Lr(e,r,t[r]);if(wr)for(var r of wr(t))Or.call(t,r)&&Lr(e,r,t[r]);return e},Ir=(e,t,r)=>Lr(e,"symbol"!=typeof t?t+"":t,r);const xr="https://qms.nextgis.com";function Er(e,t=xr,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)_r.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&wr)for(var n of wr(e))t.indexOf(n)<0&&Or.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=xr);class o{constructor(e,t){Ir(this,"qms"),Ir(this,"options"),Ir(this,"map"),this.map=e;const n=Pr(Pr({},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=br[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=Pr(Pr({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 jr=Object.defineProperty,Ar=Object.getOwnPropertySymbols,Cr=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,kr=(e,t,r)=>t in e?jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Sr=(e,t)=>{for(var r in t||(t={}))Cr.call(t,r)&&kr(e,r,t[r]);if(Ar)for(var r of Ar(t))Mr.call(t,r)&&kr(e,r,t[r]);return e},Nr=(e,t,r)=>kr(e,"symbol"!=typeof t?t+"":t,r);class Fr{constructor(e){Nr(this,"options",{url:"https://qms.nextgis.com"}),Nr(this,"url"),this.options=Sr(Sr({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return Er({webMap:e,url:this.url})}}Nr(Fr,"utils",{createQmsAdapter:Er});var Tr=Object.defineProperty,Br=Object.defineProperties,Rr=Object.getOwnPropertyDescriptors,$r=Object.getOwnPropertySymbols,Dr=Object.getPrototypeOf,qr=Object.prototype.hasOwnProperty,Vr=Object.prototype.propertyIsEnumerable,Ur=Reflect.get,Gr=(e,t,r)=>t in e?Tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,zr=(e,t)=>{for(var r in t||(t={}))qr.call(t,r)&&Gr(e,r,t[r]);if($r)for(var r of $r(t))Vr.call(t,r)&&Gr(e,r,t[r]);return e},Zr=(e,t)=>Br(e,Rr(t)),Wr=(e,t,r)=>Ur(Dr(e),r,t),Jr=(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 Hr(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 Qr=Object.defineProperty,Kr=Object.defineProperties,Xr=Object.getOwnPropertyDescriptors,Yr=Object.getOwnPropertySymbols,en=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable,rn=(e,t,r)=>t in e?Qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nn=(e,t)=>{for(var r in t||(t={}))en.call(t,r)&&rn(e,r,t[r]);if(Yr)for(var r of Yr(t))tn.call(t,r)&&rn(e,r,t[r]);return e},on=(e,t)=>Kr(e,Xr(t)),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())}));function an(e){return sn(this,null,(function*(){var t;const r=e.filters;if(r){let n=yield We(on(nn({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:ln(r))&&(n=n.filter((e=>Se(Hr(on(nn({},e.fields),{id:e.id})),r)))),n}return Ke(e)}))}function ln(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(ln(r))return!0}}return!1}var cn=(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 un(e){return function(e){return cn(this,null,(function*(){const t=yield an(e),r=[];return t.forEach((e=>{r.push(ze(e))})),r}))}(e).then((e=>({type:"FeatureCollection",features:e})))}const pn=["fields","intersects","limit","orderBy","strategy"];function hn(e){const t={};return pn.forEach((r=>{const n=e[r];void 0!==n&&(t[r]=n)})),t}var dn=Object.defineProperty,fn=Object.defineProperties,yn=Object.getOwnPropertyDescriptors,mn=Object.getOwnPropertySymbols,gn=Object.getPrototypeOf,bn=Object.prototype.hasOwnProperty,vn=Object.prototype.propertyIsEnumerable,wn=Reflect.get,_n=(e,t,r)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,On=(e,t)=>{for(var r in t||(t={}))bn.call(t,r)&&_n(e,r,t[r]);if(mn)for(var r of mn(t))vn.call(t,r)&&_n(e,r,t[r]);return e},Ln=(e,t)=>fn(e,yn(t)),Pn=(e,t,r)=>_n(e,"symbol"!=typeof t?t+"":t,r),In=(e,t,r)=>wn(gn(e),r,t),xn=(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 En(e){return xn(this,null,(function*(){var r,n;const{item:o,webMap:i,Adapter:s,connector:a,layerOptions:l,addLayerOptionsPriority:c}=e,u=null==c||c,p=l,h=s||l.Adapter||i.mapAdapter.layerAdapters.GEOJSON,d=[];let f,y,m=!1;const g=yield gr(p,a);(null==(n=null==(r=p.adapterOptions)?void 0:r.popupOptions)?void 0:n.fromProperties)&&(p.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 b=(e,t)=>xn(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},un(On({resourceId:g,filters:e,connector:a,cache:!0},t))}));let v=!1;const w=()=>{y&&(y.abort(),y=void 0)};class _ extends h{constructor(){super(...arguments),Pn(this,"emitter",new t),Pn(this,"__onMapMove"),Pn(this,"__onMapMoveStart"),Pn(this,"__enableMapMoveListener"),Pn(this,"__disableMapMoveListener")}addLayer(e){return xn(this,null,(function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==p.id&&(e.id=p.id),o&&o.vector_layer&&(e.type=co[o.vector_layer.geometry_type]),p.adapterOptions&&(e=u?On(On({},p.adapterOptions),e):On(On({},e),p.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=In(_.prototype,this,"addLayer").call(this,e);let s;return f={filters:e.propertiesFilter,options:hn(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),n&&n.startsWith("BBOX")&&!m&&this._addBboxEventListener(),i}))}getExtent(){return this.getBounds()}getBounds(){return xn(this,null,(function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?ur({connector:a,resourceId:o.resource.id}):In(_.prototype,this,"getBounds")?In(_.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.get("feature_layer.feature.count",{cache:r,signal:n},{id:t}).then((e=>e.total_count))}({connector:a,resourceId:g,cache:!0})}updateLayer(e){return xn(this,null,(function*(){var t;if(e=e||f||{},null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield i.onLoad("create"),e.options=e.options||{},e.options.intersects=i.getBounds();const{minZoom:t,maxZoom:r}=this.options,n=i.getZoom();if(void 0!==n){if(void 0!==t&&n<t)return;if(void 0!==r&&n>r)return;if(m)return}}if(!v){try{this.emitter.emit("preupdate",e),i._emitLayerEvent("layer:preupdate",p.id||"",e);const t=yield b(e.filters,Ln(On({},e.options),{srs:this.options.srs}));let r=t;const n=yield this.getCount();if("BBOX+"===this.options.strategy){r={type:"FeatureCollection",features:[]};for(const e of t.features)-1===d.indexOf(String(e.id))&&(d.push(String(e.id)),r.features.push(e));m=void 0!==n&&d.length>=n,yield i.addLayerData(this,r)}else m=void 0!==n&&t.features.length>=n,yield i.setLayerData(this,t);this.emitter.emit("updated",t),i._emitLayerEvent("layer:updated",p.id||"",{data:t,newData:r,isFull:m})}catch(r){if(r instanceof Error&&"CancelError"!==r.name)throw r}In(_.prototype,this,"updateLayer")&&In(_.prototype,this,"updateLayer").call(this)}}))}propertiesFilter(e,t){return xn(this,null,(function*(){if(w(),this.filter&&m)this.filter((t=>{const r=t.feature&&t.feature.properties&&Hr(On({},t.feature.properties));return!r||Se(r,e)}));else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(e,Ln(On({},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 jn=(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 An({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),lo(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 Cn=Object.defineProperty,Mn=Object.defineProperties,kn=Object.getOwnPropertyDescriptors,Sn=Object.getOwnPropertySymbols,Nn=Object.prototype.hasOwnProperty,Fn=Object.prototype.propertyIsEnumerable,Tn=(e,t,r)=>t in e?Cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bn=(e,t)=>{for(var r in t||(t={}))Nn.call(t,r)&&Tn(e,r,t[r]);if(Sn)for(var r of Sn(t))Fn.call(t,r)&&Tn(e,r,t[r]);return e},Rn=(e,t)=>Mn(e,kn(t)),$n=(e,t,r)=>Tn(e,"symbol"!=typeof t?t+"":t,r),Dn=(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 qn(e){return Dn(this,arguments,(function*({layerOptions:e,webMap:t,connector: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=t.getLayerAdapters();!e||e.IMAGE||(i="TILE")}const s=t.mapAdapter.layerAdapters[i];if(s){const o=yield gr(e,r);return class extends s{constructor(i,s){super(i,s),this.map=i,$n(this,"item",n),$n(this,"resourceId",o);const a=An({options:e,webMap:t,baseUrl:r.options.baseUrl||""});if(a){const t=Rn(Bn(Bn({},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=Bn(Bn({},this.options),t)}}addLayer(e){return super.addLayer(Bn(Bn({},this.options),e))}getLegend(e){return Dn(this,null,(function*(){const t=yield r.get("render.legend_symbols",Bn({params:{id:o},cache:!0},e)),n=this.options.id;if(void 0!==n){return[{layerId:n,legend:t.map((({display_name:e,icon:t})=>({name:e,symbol:t})))}]}return[]}))}getIdentificationIds(){return Dn(this,null,(function*(){if(this.item){if("MVT"===i)return[this.item.resource.id];const e=this.item.resource.parent.id;if(u(e))return[e]}return[]}))}}}throw new Error(i+" not supported yet. Only TILE")}))}var Vn=Object.defineProperty,Un=Object.defineProperties,Gn=Object.getOwnPropertyDescriptors,zn=Object.getOwnPropertySymbols,Zn=Object.prototype.hasOwnProperty,Wn=Object.prototype.propertyIsEnumerable,Jn=(e,t,r)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hn=(e,t)=>{for(var r in t||(t={}))Zn.call(t,r)&&Jn(e,r,t[r]);if(zn)for(var r of zn(t))Wn.call(t,r)&&Jn(e,r,t[r]);return e},Qn=(e,t)=>Un(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())}));const Xn={},Yn=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function eo(e){return Kn(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 to(Qn(Hn({},e),{resource:s.resource.id}),t,r)}))}function to(e,t,r){return Kn(this,null,(function*(){let n,o;const i=e.adapter,s=yield gr(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:Qn(Hn({},e),{resource:s}),connector:r,webMap:t,item:o};if(-1!==Yn.indexOf(a))if("webmap"===a)n=function(e){return jn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r}){const n=yield gr(e,r);return class extends zo{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&&co[o.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==i&&"GEOJSON"!==i){if("MVT"!==i)return eo(l);n=qn(l)}else n=En(l)}else{if("raster_layer"===a)return eo(l);if("basemap_layer"===a)n=function(e){return Jr(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(Fr.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 Jr(this,null,(function*(){return Wr(e.prototype,this,"addLayer").call(this,Zr(zr({},t),{url:n}))}))}}return e}}}}))}(l);else if("GEOJSON"===i){const t=yield r.getResource(o.resource.parent.id);if(t){const r=Qn(Hn({},e),{resource:o.resource.parent.id});n=En(Qn(Hn({},l),{item:t,layerOptions:r}))}}else n=qn(l)}else{if(!Xn[a])throw`Resource class '${a}' not yet supported.`;{const e=Xn[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,[yr],{replace:!1}),t}}))}))}var ro=Object.defineProperty,no=Object.getOwnPropertySymbols,oo=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable,so=(e,t,r)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ao=(e,t)=>{for(var r in t||(t={}))oo.call(t,r)&&so(e,r,t[r]);if(no)for(var r of no(t))io.call(t,r)&&so(e,r,t[r]);return e};function lo(e,t){const{bbox:r,width:n,height:o,nd:i}=e;return{resource:Array.isArray(t)?t.join(","):t,extent:r,size:n+","+o,timestamp:Date.now(),nd:null!=i?i:200}}const co={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 uo;function po(e,t=0){const r=t,n=function(){if(void 0===uo){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),uo=t}return uo}()*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 ho=Object.defineProperty,fo=Object.defineProperties,yo=Object.getOwnPropertyDescriptors,mo=Object.getOwnPropertySymbols,go=Object.prototype.hasOwnProperty,bo=Object.prototype.propertyIsEnumerable,vo=(e,t,r)=>t in e?ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wo=(e,t)=>{for(var r in t||(t={}))go.call(t,r)&&vo(e,r,t[r]);if(mo)for(var r of mo(t))bo.call(t,r)&&vo(e,r,t[r]);return e},_o=(e,t)=>fo(e,yo(t)),Oo=(e,t,r)=>vo(e,"symbol"!=typeof t?t+"":t,r),Lo=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Po=class e extends Xt{constructor(r,n,o,i,s,a){if(super(wo(wo({},e.options),o)),this.webMap=r,Oo(this,"item"),Oo(this,"connector"),Oo(this,"layer"),Oo(this,"emitter",new t),Oo(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 Lo(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 Lo(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){return[{layerId:r,legend:(yield t.get("render.legend_symbols",wo({params:{id:this.item.resourceId}},e))).map((({display_name:e,icon:t})=>({name:e,symbol:t})))}]}}return[]}))}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=_o(wo({visibility:!1,name:e.display_name},this.options),{params:{resource:this.item.resourceId,item:this.item}});if(this.options.order){const t=String(this.options.drawOrderEnabled&&"draw_order_position"in e?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,_o(wo({updateWmsParams:e.updateWmsParams},this.options),{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 po(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),void 0!==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}};Oo(Po,"GetAdapterFromLayerType",{}),Oo(Po,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return mt(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 jt{getProperty(){const e=this.item.layer;return e&&e&&e.options&&void 0!==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 Io=Po;var xo=Object.defineProperty,Eo=Object.getOwnPropertySymbols,jo=Object.prototype.hasOwnProperty,Ao=Object.prototype.propertyIsEnumerable,Co=(e,t,r)=>t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Mo=(e,t)=>{for(var r in t||(t={}))jo.call(t,r)&&Co(e,r,t[r]);if(Eo)for(var r of Eo(t))Ao.call(t,r)&&Co(e,r,t[r]);return e},ko=(e,t,r)=>Co(e,"symbol"!=typeof t?t+"":t,r),So=(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 No(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 So(this,arguments,(function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){ko(this,"options",{}),ko(this,"layer",[]),ko(this,"_removed",!1),ko(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 So(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 So(this,null,(function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)}))}loadLayer(){return So(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,Mo({},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:()=>to({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 Fo=Object.defineProperty,To=Object.defineProperties,Bo=Object.getOwnPropertyDescriptors,Ro=Object.getOwnPropertySymbols,$o=Object.prototype.hasOwnProperty,Do=Object.prototype.propertyIsEnumerable,qo=(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={}))$o.call(t,r)&&qo(e,r,t[r]);if(Ro)for(var r of Ro(t))Do.call(t,r)&&qo(e,r,t[r]);return e},Uo=(e,t,r)=>qo(e,"symbol"!=typeof t?t+"":t,r),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())}));class zo{constructor(e,r){this.map=e,this.options=r,Uo(this,"layer"),Uo(this,"NgwWebmapItem",Io),Uo(this,"pixelRadius",10),Uo(this,"resourceId"),Uo(this,"webmapClassName","webmap"),Uo(this,"emitter",new t),Uo(this,"_extent"),Uo(this,"response"),Uo(this,"_webmapLayersIds"),Uo(this,"_webmapBaselayersIds",[]),Uo(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 Go(this,null,(function*(){var t,r;this.options=Vo(Vo({},this.options),e),this.layer=yield this._getWebMapLayerItem();const n=null==(r=null==(t=this.response)?void 0:t.webmap)?void 0:r.extent_constrained;return this.options.useExtentConstrained&&this._extent&&n&&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.response,delete this._webmapLayersIds}showLayer(){return Go(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)}))}hideLayer(){return Go(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)}))}setOpacity(e){return Go(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.response&&this.response.webmap;if(e)return lr(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.response&&this.response.webmap;if(e)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 an(Vo({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then((e=>{const n=[];for(const o of e){const e=new yt({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 Go(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 Go(this,null,(function*(){const t=[];let r=this._webmapLayersIds;if(r||(r=yield this._getWebMapIds(e),this._webmapLayersIds=r),r&&r.length){let e=this.getDependLayers();e=e.sort(((e,t)=>t.id-e.id)),e.forEach((e=>{const r=e.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type&&r.layer_identifiable){const r=e.properties.property("visibility");r.get()&&!r.isBlocked()&&t.push(n)}}))}return t}))}_getWebMapLayerItem(){return Go(this,null,(function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise((t=>{const r=this.options.connector,n=(null==r?void 0:r.options.auth)?r.getAuthorizationHeaders():void 0,o=r.withCredentials,i=(s=Vo({},this.options),To(s,Bo({withCredentials:o,headers:n,drawOrderEnabled:e.draw_order_enabled})));var s;const a=new this.NgwWebmapItem(this.options.webMap,e.root_item,i,r);a.emitter.on("init",(()=>{t(a)}))})):void 0}))}getWebMapConfig(e){return Go(this,null,(function*(){const t=yield this.options.connector.getResource(e);if(t){this.response=t;const e=t[this.webmapClassName];if(this._setupBaselayers(t),e)return this._extent=[e.extent_left,e.extent_bottom,e.extent_right,e.extent_top],this._updateItemsParams(e.root_item,this.options.webMap,t),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)No({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)e.children&&(e.children=e.children.map((e=>this._updateItemsParams(e,t,r)))),"root"===e.item_type&&(e.display_name=r.resource.display_name);else if("layer"===e.item_type){const r=I(this.options.connector.options.baseUrl+"/api/component/render/image"),n=e.layer_style_id;e.url=r,e.resourceId=n,e.updateWmsParams=e=>lo(e,n);const o=An({options:{adapter:e.layer_adapter.toUpperCase(),resource:n},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=Vo(Vo({},e),o)}return e}_getWebMapIds(e){return Go(this,null,(function*(){const t=this.layer;if(t&&"root"===t.item.item_type){const r=t.tree.getDescendants(),n=[];for(const t of r){const r=t.item;if("layer"===r.item_type){const t=this.options.connector.getResource(r.layer_style_id,e).then((e=>{if(e){const t=Number(e.resource.parent.id);return r.parentId=t,t}}));n.push(t)}}return(yield Promise.all(n)).filter((e=>void 0!==e))}}))}}var Zo=Object.defineProperty,Wo=Object.getOwnPropertySymbols,Jo=Object.prototype.hasOwnProperty,Ho=Object.prototype.propertyIsEnumerable,Qo=(e,t,r)=>t in e?Zo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ko=(e,t)=>{for(var r in t||(t={}))Jo.call(t,r)&&Qo(e,r,t[r]);if(Wo)for(var r of Wo(t))Ho.call(t,r)&&Qo(e,r,t[r]);return e},Xo=(e,t,r)=>Qo(e,"symbol"!=typeof t?t+"":t,r);class Yo{constructor(e){if(this.options=e,Xo(this,"url"),Xo(this,"connector"),Xo(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 Le({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){Xn[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(zo,Ko({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 zo{constructor(e,r){super(e,r=ao(ao({},t),r))}};var t}}var ei=Object.defineProperty,ti=Object.getOwnPropertySymbols,ri=Object.prototype.hasOwnProperty,ni=Object.prototype.propertyIsEnumerable,oi=(e,t,r)=>t in e?ei(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ii=(e,t)=>{for(var r in t||(t={}))ri.call(t,r)&&oi(e,r,t[r]);if(ti)for(var r of ti(t))ni.call(t,r)&&oi(e,r,t[r]);return e},si=(e,t,r)=>oi(e,"symbol"!=typeof t?t+"":t,r);class ai{constructor(e){si(this,"id"),si(this,"label"),si(this,"layerId"),si(this,"parent"),si(this,"fields"),si(this,"geom"),si(this,"extensions"),si(this,"connector"),si(this,"_item"),si(this,"_geojson"),si(this,"_resource"),si(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):lt(ii({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 this._resource?Promise.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId,e).then((e=>(this._resource=e,this._resource.feature_layer)))}getBounds(e){return this._extent?Promise.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0,signal:o}){return r.get("feature_layer.feature.item_extent",{cache:n,signal:o},{id:e,fid:t}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}(ii({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 li=(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 li(this,null,(function*(){return ze(yield lt(e))}))}var ui=Object.defineProperty,pi=Object.defineProperties,hi=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,gi=(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},bi=(e,t)=>pi(e,hi(t));function vi(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=wi(s.features,Number(o),t);if(e.length&&(n.push(...e),!t))break}}return n}function wi(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 _i(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");return e.connector.post("feature_layer.identify",{data:{geom:i,srs:3857,layers:o},signal:r,cache:n})}function Oi(e,t){return r=this,n=null,o=function*(){var r;const n=yield e.get("pyramid.settings",null,{component:"pyramid"});if(n&&n.company_logo&&n.company_logo.enabled){const i=document.createElement("a");i.style.position="absolute",i.style.bottom="0",i.style.right="0",i.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",i.className="ngw-map-logo",t&&t.cssClass&&(i.className+=" "+t.cssClass);const s=new Image;s.style.maxHeight="100px",s.style.maxWidth="100px",s.src="";try{const t=yield e.get("pyramid.company_logo",{responseType:"blob"}),r=(window.URL||window.webkitURL).createObjectURL(t);s.src=r}catch(o){console.warn(o)}return null!==n.company_logo.link&&""!==n.company_logo.link.trim()&&(i.href=n.company_logo.link,i.target="_blank",-1!==n.company_logo.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),i.appendChild(s),i}},new Promise(((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())}));var r,n,o}function Li(e){return"function"==typeof e}function Pi(e){return(t,r)=>{const n=t.map((e=>e()));return e(n,r)}}const Ii={"!":Pi((function([e]){return!e})),"!=":Pi((function([e,t]){return e!==t})),"<":Pi((function([e,t]){return e<t})),"<=":Pi((function([e,t]){return e<=t})),"==":Pi((function([e,t]){return e===t})),">":Pi((function([e,t]){return e>t})),">=":Pi((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()}},xi={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 Ei(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return ji(e);if("string"==typeof(t=e)&&t in xi)return function(e){return ji(xi[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 ji(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 Ai(e,t,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(e-t)/(n-t)*(o-r);try{const i=Ei(r),s=Ei(o);return function(e){return`rgb(${e.join(",")})`}(i.map(((r,o)=>Math.ceil(Ai(e,t,r,n,s[o])))))}catch(i){console.log(i)}throw new Error("Unsupported output type for linear interpolation.")}const Ci={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 Ai(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Mi={get:Pi((function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null})),length:Pi((([e])=>{if("string"==typeof e||Array.isArray(e))return e.length})),at:Pi((function([e,t]){return t[e]})),has:Pi((function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))})),in:Pi((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":Pi((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:Pi((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}.`)}))},ki={"+":Pi((e=>e.reduce(((e,t)=>e+t),0))),"-":Pi((e=>e.reduce(((e,t)=>e-t)))),"*":Pi((e=>e.reduce(((e,t)=>e*t),1))),"/":Pi((e=>e.reduce(((e,t)=>e/t)))),"%":Pi((e=>e[0]%e[1])),"^":Pi((e=>Math.pow(e[0],e[1]))),abs:Pi((e=>Math.abs(e[0]))),acos:Pi((e=>Math.acos(e[0]))),asin:Pi((e=>Math.asin(e[0]))),atan:Pi((e=>Math.atan(e[0]))),ceil:Pi((e=>Math.ceil(e[0]))),cos:Pi((e=>Math.cos(e[0]))),e:()=>Math.E,floor:Pi((e=>Math.floor(e[0]))),ln:Pi((e=>Math.log(e[0]))),ln2:()=>Math.LN2,log10:Pi((e=>Math.log10(e[0]))),log2:Pi((e=>Math.log2(e[0]))),max:Pi((e=>Math.max(...e))),min:Pi((e=>Math.min(...e))),pi:()=>Math.PI,round:Pi((e=>Math.round(e[0]))),sin:Pi((e=>Math.sin(e[0]))),sqrt:Pi((e=>Math.sqrt(e[0]))),tan:Pi((e=>Math.tan(e[0])))},Si={concat:Pi((e=>e.reduce(((e,t)=>String(e)+String(t)),""))),downcase:Pi((e=>String(e[0]).toLowerCase())),upcase:Pi((e=>String(e[0]).toUpperCase()))},Ni=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function Fi(e){return(t,r)=>{for(const n of t){const t=Ni(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Ti={array:Pi((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:Pi(Fi((e=>"boolean"==typeof e?e:void 0))),literal:Pi((([e])=>e)),number:Pi(Fi((e=>"number"==typeof e?e:void 0))),object:Pi(Fi((e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e))),string:Pi(Fi((e=>"string"==typeof e?e:void 0))),"to-boolean":Pi(Fi(Boolean)),"to-number":Pi(Fi(Number)),"to-string":Pi(Fi(String)),typeof:Pi((([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 Bi=Object.defineProperty,Ri=Object.getOwnPropertySymbols,$i=Object.prototype.hasOwnProperty,Di=Object.prototype.propertyIsEnumerable,qi=(e,t,r)=>t in e?Bi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Vi=(e,t)=>{for(var r in t||(t={}))$i.call(t,r)&&qi(e,r,t[r]);if(Ri)for(var r of Ri(t))Di.call(t,r)&&qi(e,r,t[r]);return e};function Ui(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in Gi&&r.length>0}return!1}const Gi=Vi(Vi(Vi(Vi(Vi(Vi({},ki),Ti),Si),Mi),Ii),Ci);function zi(e,t={}){const[r,...n]=e,o=Gi[r];if(o)return o(n.map((e=>()=>Ui(e)?zi(e,t):e)),t);throw new Error(`Expression "${r}" is not supported.`)}var Zi=Object.defineProperty,Wi=Object.getOwnPropertySymbols,Ji=Object.prototype.hasOwnProperty,Hi=Object.prototype.propertyIsEnumerable,Qi=(e,t,r)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ki=(e,t)=>{for(var r in t||(t={}))Ji.call(t,r)&&Qi(e,r,t[r]);if(Wi)for(var r of Wi(t))Hi.call(t,r)&&Qi(e,r,t[r]);return e};function Xi(e){return t=>{const r=t.properties;return!!r&&zi(e,r)}}const Yi=["iconSize","iconAnchor"];var es=Object.defineProperty,ts=Object.getOwnPropertySymbols,rs=Object.prototype.hasOwnProperty,ns=Object.prototype.propertyIsEnumerable,os=(e,t,r)=>t in e?es(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,is=(e,t)=>{for(var r in t||(t={}))rs.call(t,r)&&os(e,r,t[r]);if(ts)for(var r of ts(t))ns.call(t,r)&&os(e,r,t[r]);return e};function ss(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=Ae({},e.properties);return!!r&&(r.$id=e.id,Se(r,t))}(e,t[0])));return n?is(is({},t),n[1]):t}}function as({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===Yi.indexOf(n)){const o=n,i=e[o];Ui(i)&&(t=!0,r[o]=Xi(i))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return Ki(Ki({},e),n)}}(e);if(r){const n=e=>cs({paint:r(e),defaultPaint:t});return n.paint=ls({paint:e,defaultPaint:t}),n}return ls({paint:e,defaultPaint:t})}function ls({paint:e,defaultPaint:t}){var r;let n=is({},t);return n=is(is({},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 cs({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=is({},t);if(Li(e)){const n=n=>{const o=cs({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=>cs({paint:ss(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=cs({paint:o,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=as({paint:e,defaultPaint:t})}return Li(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 us=Object.defineProperty,ps=(e,t,r)=>((e,t,r)=>t in e?us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class hs{constructor(){ps(this,"backspace",8),ps(this,"tab",9),ps(this,"enter",13),ps(this,"shift",16),ps(this,"ctrl",17),ps(this,"alt",18),ps(this,"pause/break",19),ps(this,"caps_lock",20),ps(this,"escape",27),ps(this,"page_up",33),ps(this,"page_down",34),ps(this,"end",35),ps(this,"home",36),ps(this,"left_arrow",37),ps(this,"up_arrow",38),ps(this,"right_arrow",39),ps(this,"down_arrow",40),ps(this,"insert",45),ps(this,"delete",46),ps(this,"left_window_key",91),ps(this,"right_window_key",92),ps(this,"select_key",93),ps(this,"numpad_0",96),ps(this,"numpad_1",97),ps(this,"numpad_2",98),ps(this,"numpad_3",99),ps(this,"numpad_4",100),ps(this,"numpad_5",101),ps(this,"numpad_6",102),ps(this,"numpad_7",103),ps(this,"numpad_8",104),ps(this,"numpad_9",105),ps(this,"multiply",106),ps(this,"add",107),ps(this,"subtract",109),ps(this,"decimal_point",110),ps(this,"divide",111),ps(this,"f1",112),ps(this,"f2",113),ps(this,"f3",114),ps(this,"f4",115),ps(this,"f5",116),ps(this,"f6",117),ps(this,"f7",118),ps(this,"f8",119),ps(this,"f9",120),ps(this,"f10",121),ps(this,"f11",122),ps(this,"f12",123),ps(this,"num_lock",144),ps(this,"scroll_lock",145),ps(this,"semi-colon",186),ps(this,"equal_sign",187),ps(this,",",188),ps(this,"-",189),ps(this,".",190),ps(this,"/",191),ps(this,"`",192),ps(this,"[",219),ps(this,"\\",220),ps(this,"]",221),ps(this,"'",222)}}var ds=Object.defineProperty,fs=(e,t,r)=>((e,t,r)=>t in e?ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var ys=Object.defineProperty,ms=(e,t,r)=>((e,t,r)=>t in e?ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class gs{constructor(e,t){this.webMap=e,ms(this,"name"),ms(this,"event"),ms(this,"value"),t&&(t.value&&this.setValue(t.value),t.name&&(this.name=t.name),t.event&&(this.event=t.event))}getValue(){return this.value}setValue(e){this.value=e}}var bs=Object.defineProperty,vs=(e,t,r)=>((e,t,r)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ws extends gs{constructor(){super(...arguments),vs(this,"name","center"),vs(this,"event","moveend")}getValue(){return this.webMap.getCenter()}setValue(e){this.webMap.setCenter(e)}toString(e){const t=e.map((e=>e.toFixed(5)));return t[0]+"_"+t[1]}parse(e){return e.split("_").map(Number)}}var _s=Object.defineProperty,Os=(e,t,r)=>((e,t,r)=>t in e?_s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ls extends gs{constructor(){super(...arguments),Os(this,"name","zoom"),Os(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(e){return String(e)}parse(e){return Number(e)}}var Ps=Object.defineProperty,Is=(e,t,r)=>((e,t,r)=>t in e?Ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),xs=(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 Es=0;const js={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},As=class e{constructor(r){Is(this,"options",js),Is(this,"emitter",new t),Is(this,"keys",e.keys),Is(this,"mapAdapter"),Is(this,"runtimeParams",[]),Is(this,"getPaintFunctions",e.getPaintFunctions),Is(this,"mapState",[ws,Ls]),Is(this,"id",Es++),Is(this,"_initMapState",{}),Is(this,"_starterKits"),Is(this,"_mapState",[]),Is(this,"_extent"),Is(this,"_eventsStatus",{}),Is(this,"_coordFromMapClickAbort"),Is(this,"_mapEvents",{}),this.mapAdapter=r.mapAdapter,this._starterKits=r.starterKits||[],r&&(this.options=h(js||{},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 xs(this,null,(function*(){return this.getEventStatus("create")||(yield this._setInitMapState(this.mapState),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()}getState(){const e={};return this._mapState.forEach((t=>{e[t.name]=t.getValue()})),e}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.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 xs(this,null,(function*(){}))}_onLoadSync(){return xs(this,null,(function*(){}))}_setupMap(){return xs(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){const t=this._mapState.find((t=>t.event===e));if(t){const e=t.toString(t.getValue());this.runtimeParams.forEach((r=>{r.set(t.name,e)}))}}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)}))}};Is(As,"keys",new class{constructor(){fs(this,"keyCodeAlias",new hs),fs(this,"keys",{}),fs(this,"_windowOnFocus"),fs(this,"_keysPressed"),fs(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={}}}),Is(As,"getPaintFunctions");let Cs=As;function Ms(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 ks(e){let t;if("FeatureCollection"===e.type){t=Ms(e.features.map((e=>e.geometry.type)))}else if("GeometryCollection"===e.type){t=Ms(e.geometries.map((e=>e.type)))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const Ss={polygon:"path",line:"path",point:"circle"},Ns={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Fs(e){if(e.data){const t=Ns[ks(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":Ss[t]),e.type=e.type||t}return e}var Ts=Object.defineProperty,Bs=Object.defineProperties,Rs=Object.getOwnPropertyDescriptors,$s=Object.getOwnPropertySymbols,Ds=Object.prototype.hasOwnProperty,qs=Object.prototype.propertyIsEnumerable,Vs=(e,t,r)=>t in e?Ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Us=(e,t)=>{for(var r in t||(t={}))Ds.call(t,r)&&Vs(e,r,t[r]);if($s)for(var r of $s(t))qs.call(t,r)&&Vs(e,r,t[r]);return e},Gs=(e,t)=>Bs(e,Rs(t)),zs=(e,t,r)=>Vs(e,"symbol"!=typeof t?t+"":t,r),Zs=(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 Ws extends Cs{constructor(e){super(e),zs(this,"_layersIdCounter",1),zs(this,"_layersOrderCounter",1),zs(this,"_baselayers",[]),zs(this,"_layers",{}),zs(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(t)))}fitLayer(e,t){return Zs(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 Zs(this,null,(function*(){return yield this.addLayer(e,Gs(Us({},t),{baselayer:!0}),void 0)}))}addLayer(e){return Zs(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=Us({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=Us(Us({},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;void 0!==u&&u<=1&&this.setLayerOpacity(e,u);const p=n&&(e.getBounds||e.getExtent);if(t.fit&&p){const t=yield p.call(e);t&&(yield this.fitBounds(t))}return t.onAdded&&t.onAdded(e),this._emitLayerEvent("layer:add",r,e),e}return Promise.reject("No adapter")}))}addLayerFromAsyncAdapter(e,t,r){return Zs(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 Zs(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=Fs(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",Gs(Us({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",Gs(Us({},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=>Zs(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){const t=this.getLayer(e);if(t){if(t.updateLayer)return Promise.resolve(t.updateLayer());if(this.isLayerVisible(t))return this.hideLayer(t,{silent:!0}).then((()=>this.showLayer(t,{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||Se(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 Zs(this,null,(function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerDoubleClick(e){return Zs(this,null,(function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerSelect(e){return Zs(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 p=t||r;e.onSelect=e=>(p&&p(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=cs({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=cs({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}function Js(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const o=t.title||"",i=t.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function l(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(e,t){e.split(" ").forEach((e=>{t?r.classList.add(e):r.classList.remove(e)}))}function u(){t.addClassOn&&c(t.addClassOn,n),t.addClassOff&&c(t.addClassOff,!n)}s(),l(),t.addClass&&c(t.addClass,!0),u();const p=e=>{void 0!==e&&(n=e),l(),s(),u()},h=e=>{if(n=void 0!==e?e:!n,t.onClick){const e=t.onClick(n);Promise.resolve(e).then((()=>p())).catch((()=>n=!n))}else p()},d=e({html:r,onClick:h});return d.onClick=h,d.changeStatus=p,d}var Hs=Object.defineProperty,Qs=(e,t,r)=>((e,t,r)=>t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Ks=(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 Xs=class e extends Ws{constructor(){super(...arguments),Qs(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),Qs(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return Ks(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,(()=>Ks(this,null,(function*(){const r=yield n,o=this.mapAdapter.addControl(r,t);e(o)}))))}))}))}createControl(e,t){return Ks(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)}))}createButtonControl(e){return Ks(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)}))}createToggleControl(e){return Ks(this,null,(function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?Js(this.mapAdapter.createButtonControl,e):void 0}))}removeControl(e){"remove"in e?e.remove():this.mapAdapter.removeControl&&Promise.resolve(e).then((e=>{this.mapAdapter.removeControl(e)}))}getControl(t,r){const n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);{const n=e.controls[t];if(n)return n(this,r)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return Ks(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}))}};Qs(Xs,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let Ys=Xs;const ea={};function ta(e){return ea[e]}function ra(e,t){ea[e]=t}var na=Object.getOwnPropertySymbols,oa=Object.prototype.hasOwnProperty,ia=Object.prototype.propertyIsEnumerable,sa=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),aa=(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())})),la=(e,t,r)=>(t=e[sa("asyncIterator")])?t.call(e):(e=e[sa("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 ca extends Ys{constructor(e){super(e),this._addControls(),ra(this.id,this)}static get(e){return ta(e)}_addLayerProviders(){return aa(this,null,(function*(){try{for(var e,t,r,n=la(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=la(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 aa(this,null,(function*(){try{for(var e,t,r,n=la(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)oa.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&na)for(var n of na(e))t.indexOf(n)<0&&ia.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,o||"top-left",i)})),this._emitStatusEvent("controls:create")}}function ua(){return["ZOOM","ATTRIBUTION"]}function pa(e){return t=this,r=null,n=function*(){return new ca(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 ha=Object.defineProperty,da=Object.defineProperties,fa=Object.getOwnPropertyDescriptors,ya=Object.getOwnPropertySymbols,ma=Object.prototype.hasOwnProperty,ga=Object.prototype.propertyIsEnumerable,ba=(e,t,r)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,va=(e,t)=>{for(var r in t||(t={}))ma.call(t,r)&&ba(e,r,t[r]);if(ya)for(var r of ya(t))ga.call(t,r)&&ba(e,r,t[r]);return e},wa=(e,t)=>da(e,fa(t));function _a(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(wa(va({},r),{resource:t}));else if(Array.isArray(t)){const[o,i]=t;e.push(va(wa(va({},r),{resource:o,id:i}),n))}else"object"==typeof t&&e.push(va(va(va({},r),t),n))}var Oa=Object.defineProperty,La=Object.defineProperties,Pa=Object.getOwnPropertyDescriptors,Ia=Object.getOwnPropertySymbols,xa=Object.prototype.hasOwnProperty,Ea=Object.prototype.propertyIsEnumerable,ja=(e,t,r)=>t in e?Oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const Aa={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 Ca(e){const t=[new Fr];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 Le({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=h(Aa,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new Yo({connector:e.connector,auth:e.auth})),r=((e,t)=>{for(var r in t||(t={}))xa.call(t,r)&&ja(e,r,t[r]);if(Ia)for(var r of Ia(t))Ea.call(t,r)&&ja(e,r,t[r]);return e})({},e),e=La(r,Pa({starterKits:t,create:!1}))}var Ma=Object.defineProperty,ka=Object.defineProperties,Sa=Object.getOwnPropertyDescriptors,Na=Object.getOwnPropertySymbols,Fa=Object.getPrototypeOf,Ta=Object.prototype.hasOwnProperty,Ba=Object.prototype.propertyIsEnumerable,Ra=Reflect.get,$a=(e,t,r)=>t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Da=(e,t)=>{for(var r in t||(t={}))Ta.call(t,r)&&$a(e,r,t[r]);if(Na)for(var r of Na(t))Ba.call(t,r)&&$a(e,r,t[r]);return e},qa=(e,t)=>ka(e,Sa(t)),Va=(e,t,r)=>$a(e,"symbol"!=typeof t?t+"":t,r),Ua=(e,t,r)=>Ra(Fa(e),r,t),Ga=(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 za=class e extends ca{constructor(e){super(Ca(e)),Va(this,"emitter",new t),Va(this,"connector"),Va(this,"_ngwLayers",{}),Va(this,"$$selectFromNgwRaster"),Va(this,"$$selectFromNgwVector"),Va(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 Ga(this,null,(function*(){return yield this.onLoad("controls:create"),Ua(e.prototype,this,"addControl").call(this,t,r,n)}))}addNgwLayer(e){return Ga(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),to(e,t,r)}(e,this,this.connector),r=Da(Da({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 lt(Da({connector:this.connector},e))}fetchNgwLayerItems(e){return an(Da({connector:this.connector},e))}fetchNgwLayerFeature(e){return ci(Da({connector:this.connector},e))}fetchNgwLayerFeatures(e){return un(Da({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=vi(r);return n&&n.length?lt(gi(gi({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,t=!1){const r=new AbortController,n=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(ze(bi(gi({},t),{geom:e})))}}}}const o=vi(r);return o&&o.length?ci(gi(bi(gi({},n),{connector:t}),o[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,multiple:t,requestOptions:{signal:r.signal}});return n&&"then"in n?(this._addPromise("identify",n,r),n):Promise.resolve(n)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,t)}getNgwLayers(){return Ga(this,null,(function*(){return yield this.onLoad(),this._ngwLayers}))}getNgwLayerByResourceId(e){return Ga(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&&t.item.parentId===e));if(t)return t.layer}}}))}fitLayer(t,r){return Ga(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&&ur({resourceId:e.resource.id,connector:this.connector}).then((e=>{e&&this.fitBounds(e,r)}))}else Ua(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)}))}zoomToLayer(e){return Ga(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 Ga(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 p;if(this.options.highlightIdentification){const t=this.options.highlightIdentification,r="number"==typeof t?t:1e3,[n,o]=e.lngLat;p={type:"Polygon",coordinates:[v(n,o,u)]};const i=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:p}});r!==1/0&&setTimeout((()=>{this.removeLayer(i)}),r)}const h=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 _i(bi(gi({},t),{geom:s}))}(e,{layers:s,connector:this.connector,radius:u,geom:p,signal:h.signal}).then((t=>{const r=qa(Da({},t),{resources:s,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n}));return this._addPromise("select",f,h),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),t.catch(e),n.push([t,r])}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}_createWebMap(){return Ga(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&&_a(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),_a(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,[r]:{featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]}};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(qa(Da({},t),{resources:[r],sourceType:"vector"}))),t}}}_prepareToIdentify(e){return qa(Da({},e),{getIdentifyItems:()=>vi(e,!0).map((e=>new ai({feature:e.feature,connector:this.connector})))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return Ga(this,null,(function*(){const e=this.getContainer();if(e){const t=yield Oi(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}))}};Va(za,"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",p=null!=(n=e.strokeColor)?n:"white",h=null!=(o=e.size)?o:l,d=null!=(i=e.rotate)?i:0,f=null!=(s=e.anchor)?s:[h/2,h/2],y=void 0!==e.stroke?Number(e.stroke):.8,m=e.p||a[c]||"circle",g="string"==typeof m?m:m(e),b=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:h,height:h,stroke:y,content:g}));return b.setAttribute("width",String(h)),b.setAttribute("height",String(h)),b.setAttribute("fill",u),y&&(b.setAttribute("stroke",p),b.setAttribute("stroke-width",String(y))),{type:"icon",iconSize:[h,h],iconAnchor:f,html:(new XMLSerializer).serializeToString(b),rotate:d,svg:b}}));let Za=za;function Wa(e){return t=this,r=null,n=function*(){return new Za(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{Za as NgwMap,ca as WebMap,Ys as WebMapControls,Ws as WebMapLayers,Cs as WebMapMain,Wa as createNgwMap,Js as createToggleControl,pa as createWebMap,ks as detectGeometryType,Ms as findMostFrequentGeomType,ua as getDefaultControls,ta as getWebMap,Ss as paintTypeAlias,ra as setWebMap,Ns as typeAlias,Fs as updateGeoJsonAdapterOptions};
2
2
  //# sourceMappingURL=ngw-map.esm-browser.prod.js.map