@nextgis/ngw-map 1.16.2 → 1.16.3

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
- var NgwMap=function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(a){i=[6,a],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function u(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}var c,p={exports:{}},l="object"==typeof Reflect?Reflect:null,h=l&&"function"==typeof l.apply?l.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};c=l&&"function"==typeof l.ownKeys?l.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var f=Number.isNaN||function(t){return t!=t};function d(){d.init.call(this)}p.exports=d,p.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}C(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&C(t,"error",e,r)}(t,o,{once:!0})}))},d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var y=10;function v(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function m(t){return void 0===t._maxListeners?d.defaultMaxListeners:t._maxListeners}function g(t,e,r,n){var o,i,s,a;if(v(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=m(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function _(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=_.bind(n);return o.listener=r,n.wrapFn=o,o}function w(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):O(o,o.length)}function L(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function O(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function C(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return y},set:function(t){if("number"!=typeof t||t<0||f(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");y=t}}),d.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||f(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},d.prototype.getMaxListeners=function(){return m(this)},d.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)h(a,this,e);else{var u=a.length,c=O(a,u);for(r=0;r<u;++r)h(c[r],this,e)}return!0},d.prototype.on=d.prototype.addListener=function(t,e){return g(this,t,e,!1)},d.prototype.prependListener=function(t,e){return g(this,t,e,!0)},d.prototype.once=function(t,e){return v(e),this.on(t,b(this,t,e)),this},d.prototype.prependOnceListener=function(t,e){return v(e),this.prependListener(t,b(this,t,e)),this},d.prototype.off=d.prototype.removeListener=function(t,e){var r,n,o,i,s;if(v(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},d.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},d.prototype.listeners=function(t){return w(this,t,!0)},d.prototype.rawListeners=function(t){return w(this,t,!1)},d.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):L.call(t,e)},d.prototype.listenerCount=L,d.prototype.eventNames=function(){return this._eventsCount>0?c(this._events):[]};var I=function(t){function e(){var r=t.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),E=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return t=t||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=e(t);if(i)return i;var a=r(s.apply(this,n),t);return a},i}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),P=function(t){function e(){var r=t.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),A=function(t,e,r,n){try{t(r(n))}catch(o){e(o)}},M=0,x=function(){function t(e,r){var n=this;this.id=M++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new I)}}));var o=[this._cancelPromise,new Promise((function(r,o){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,o(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&o.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new P)}}),r)}))),this._promise=Promise.race(o)}return t.createControl=function(t){return new E(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,o=e;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,o=new t((function(t,o){if(n._promise){var i=function(e){r?A(t,o,r,e):o(e)};n._promise.then((function(r){n._isCanceled?i(r):e?A(t,o,e,r):t(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new I),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new I:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(n){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=I,t.TimeoutError=P,t.PromiseControl=E,t}();Object.setPrototypeOf(x.prototype,Promise.prototype);var k=x;function S(t,e,r){void 0===r&&(r={});var n=function(t,e){for(void 0===e&&(e=[]);null!==t;t=Object.getPrototypeOf(t))for(var r=Object.getOwnPropertyNames(t),n=0;n<r.length;n++)-1==e.indexOf(r[n])&&e.push(r[n]);return e}(t.prototype),o=void 0===r.replace||r.replace;e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(r){var i=-1!==n.indexOf(r);if(!o&&!i||o){var s=Object.getOwnPropertyDescriptor(e.prototype,r);s&&Object.defineProperty(t.prototype,r,s)}}))}))}function N(t){return null!=t}function T(t){return"string"==typeof t?!!t:N(t)}function R(t,e,r){void 0===r&&(r=!1);var n=t,o=e,i=Array.isArray(o),s=i&&[]||{};return i&&Array.isArray(o)?r?(s=s.concat(n=n||[]),o.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=R(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(o).forEach((function(t){s[t]="object"==typeof o[t]&&o[t]&&"object"==typeof n[t]&&"object"==typeof o[t]?R(n[t],o[t],r):o[t]}))),s}function B(t){!t.lngLat&&t.latLng&&(t.lngLat=[t.latLng.lng,t.latLng.lat]);return t}function j(t){return{type:"Polygon",coordinates:[F(t)]}}function F(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}var G=Math.PI/180,q=180/Math.PI;function D(t,e){e=e>85.06?85.06:e<-85.06?-85.06:e;var r=20037508.34*t/180,n=Math.log(Math.tan((90+e)*Math.PI/360))/(Math.PI/180);return[r,n=20037508.34*n/180]}function V(t,e,r,n){if(t instanceof Array)return e instanceof Array&&e.sort().join("")===t.sort().join("");if(t instanceof Date)return e instanceof Date&&""+t==""+e;if(t instanceof Function){if(!(e instanceof Function))return!1}else if(t instanceof Object)return e instanceof Object&&(t===r?e===n:z(t,e));return t===e}function z(t,e){var r=Object.keys(t).sort(),n=Object.keys(e).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(var o=0;o<r.length;o++){if(!V(t[r[o]],e[n[o]],t,e))return!1}return!0}function U(t){var e={};return Object.keys(t).forEach((function(r){t[r]instanceof Array||t[r]!==Object(t[r])?void 0!==t[r]&&(e[r]=t[r]):e[r]=U(t[r])})),e}function Z(t){return"[object Object]"===Object.prototype.toString.call(t)}function W(t){return t.replace(/([^:]\/)\/+/g,"$1")}function $(t){return"function"==typeof t}var H={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){var r=e[0],n=e.slice(1),o=r;Array.isArray(r)&&(o=J(t,r));for(var i=n.splice(-1,n.length%2)[0],s=0;s<n.length-1;s+=2){if(n[s]===o)return n[s+1]}return i}};function J(t,e){var r=e[0],n=e.slice(1),o=H[r];if(o)return o(t,n)}function Q(t){return function(e){return J(e,t)}}var K=["iconSize","iconAnchor"];function X(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,o="^".concat((n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")),"$").replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(t)}var Y={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return X(t,e)},ilike:function(t,e){return X(t,e,!0)}};function tt(t){return 3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]}function et(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(tt(e)){var r=e[0],n=e[1],o=e[2],i=Y[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,o)}));return i(s,a)}return i(t[r],o)}return!1}return et(t,e)},o=e.filter((function(t){return Array.isArray(t)}));return"any"===r?o.some(n):o.every(n)}function rt(t){for(var e={},r=[],o=0,i=t;o<i.length;o++){var s=i[o];s&&(Array.isArray(s)?r.push(s):e=s)}return function(t){var o=r.find((function(e){return function(t,e){var r=n({},t.properties);return!!r&&(r.$id=t.id,et(r,e))}(t,e[0])}));return o?n(n({},e),o[1]):e}}function nt(t,e,r){var o=function(t){var e=!1,r={};for(var o in t)if(-1===K.indexOf(o)){var i=o,s=t[i];Array.isArray(s)&&(e=!0,r[i]=Q(s))}if(e)return function(e){var o={};for(var i in r)o[i]=r[i](e);return n(n({},t),o)}}(t);if(o){var i=function(t){return ot(o(t),e,r)};return i.paint=t,i}var s=n({},e);return(s=n(n({},s),t)).fill=void 0===s.fill||s.fill,s.stroke=void 0!==s.stroke?s.stroke:!s.fill||!(!s.strokeColor&&!s.strokeOpacity),s}function ot(t,e,r){if(!t)throw new Error("paint is empty");var o=n({},e);if($(t)){var i=function(n){var o=ot(t(n),e,r);return o.type=t.type,o};return i.type=t.type,i}if(function(t){return!!Array.isArray(t)}(t))return function(n){return ot(rt(t)(n),e,r)};if("get-paint"===t.type){var s=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(t,r);s&&(o=ot(s,e,r))}else{if("icon"===t.type)return t;o=nt(t,e,r)}return $(o)||("color"in o&&(o.strokeColor||(o.strokeColor=o.color),o.fillColor||(o.fillColor=o.color)),"opacity"in o&&(void 0===o.strokeOpacity&&(o.strokeOpacity=o.opacity),void 0===o.fillOpacity&&(o.fillOpacity=o.opacity))),o}function it(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function st(t){var e;if("FeatureCollection"===t.type)e=it(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=it(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var at={polygon:"path",line:"path",point:"circle"},ut={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function ct(t){if(t.data){var e=ut[st(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":at[e]),t.type=t.type||e}return t}var pt=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},lt=function(){function t(){this.keyCodeAlias=new pt,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),ht=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),ft=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return r(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(ht),dt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return r(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(ht);var yt=0,vt={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},mt=function(){function t(e){this.options=vt,this.emitter=new p.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[ft,dt],this.id=yt++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=R(vt||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},t.prototype.getContainer=function(){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){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:j(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){if(Array.isArray(t)){var r=t;this.mapAdapter.setView&&r&&N(e)?this.mapAdapter.setView(r,e):(r&&this.mapAdapter.setCenter(r),N(e)&&this.mapAdapter.setZoom(e))}else{this.mapAdapter.setView&&this.mapAdapter.setView(t)}},t.prototype.fitBounds=function(t,e){return t.every((function(t){return N(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new k((function(e,r,n){var o=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var i=function(){t.setCursor(o),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){i(),B(t),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(i)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),N(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),N(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),N(t.maxzoom)&&N(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend","mousemove","mouseout","mouseover"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new lt,t}(),gt=function(t){function e(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return r(e,t),e.prototype.fitLayer=function(t,e){return o(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},e.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},e.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},e.prototype.getBaseLayersIds=function(){return this._baselayers},e.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},e.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},e.prototype.getLayers=function(){return Object.keys(this._layers)},e.prototype.allLayers=function(){return this._layers},e.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},e.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},e.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},e.prototype.addBaseLayer=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,n(n({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},e.prototype.addLayer=function(t,e,r){var s,a;return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var o,u,c,p,l,h,f,d,y,v,m,g;return i(this,(function(i){switch(i.label){case 0:return o=this._layersIdCounter++,u=N(r)?r:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(c=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(c=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:c=i.sent(),i.label=4;case 4:return this._updateGeoJsonOptions(p=e),e=n({id:String(o),order:u},e),l=null===(s=e.visibility)||void 0===s||s,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(h=this.options.onBeforeAddLayer({options:e,adapter:c}))&&(h.options&&(e=h.options),h.adapter&&(c=h.adapter)),void 0===c?[3,12]:((f=new c(this.mapAdapter.map,e)).options=n(n({},e),f.options),f.options.baselayer&&(e.baselayer=!0,e.order=0,f.options.order=0),d=void 0,f.options.id&&(d=String(f.options.id),this._layers[d]=f),this._emitLayerEvent("layer:preadd",d||"",f),[4,this.onMapLoad()]);case 5:return i.sent(),f.map=this.mapAdapter.map,[4,f.addLayer(f.options)];case 6:if(y=i.sent(),f.layer=y,f.id=f.options.id||String(o),f.options.id=f.id,e.baselayer&&(f.options.order=0),f.order=null!==(a=f.options.order)&&void 0!==a?a:u,d&&delete this._layers[d],d=String(f.id),this._layers[d])throw Error("layer with id '".concat(d,"' already exist"));return d?(this._layers[d]=f,p.filter&&this.filterLayer(f,p.filter),e.baselayer&&this._baselayers.push(d),l?[4,this.showLayer(d)]:[3,8]):[3,8];case 7:i.sent(),i.label=8;case 8:return void 0!==(v=e.opacity)&&v<=1&&this.setLayerOpacity(f,v),m=y&&(f.getBounds||f.getExtent),e.fit&&m?[4,m.call(f)]:[3,11];case 9:return(g=i.sent())?[4,this.fitBounds(g)]:[3,11];case 10:i.sent(),i.label=11;case 11:return e.onAdded&&e.onAdded(f),this._emitLayerEvent("layer:add",d,f),[2,f];case 12:return[2,Promise.reject("No adapter")]}}))}))},e.prototype.addLayerFromAsyncAdapter=function(t,e,r){return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},e.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},e.prototype.reserveOrder=function(){return this._layersOrderCounter++},e.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},e.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},e.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=ct(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},e.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},e.prototype.addTileLayer=function(t,e){return void 0===e&&(e={}),this.addLayer("TILE",n(n({},e),{url:t}))},e.prototype.addImageLayer=function(t,e){var r;return"string"==typeof t?r=t:(r=t.url,e=t),this.addLayer("IMAGE",n(n({},e),{url:r}))},e.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},e.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},e.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var s=this.getLayer(t),a=void 0!==e?e:!(s&&s.options.visibility),u=void 0!==r.silent&&r.silent;return s&&s.options.visibility!==a?this.onMapLoad().then((function(){return t=s,o(n,void 0,void 0,(function(){var e,r,n,o,s,c,p,l=this;return i(this,(function(i){switch(i.label){case 0:if(e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!a||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];s=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),c=0,p=s,i.label=1;case 1:return c<p.length?[4,this.hideLayer(p[c])]:[3,4];case 2:i.sent(),i.label=3;case 3:return c++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return i.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:i.sent(),i.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return i.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:i.sent(),i.label=13;case 13:return t.options.visibility=a,u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},e.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},e.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},e.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},e.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},e.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},e.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},e.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;o.propertiesFilter?o.propertiesFilter(e,r):o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||et(t.feature.properties,e)}))}},e.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},e.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},e.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},e.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},e.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},e.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},e.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},e.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},e.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},e.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},e.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},e.prototype._emitLayerEvent=function(t,e,r){var n=String(t);if(N(e)&&n.startsWith("layer:")){var o=n.replace("layer:","layer-"+e+":");this.emitter.emit(o,r)}this.emitter.emit(t,r)},e.prototype._onLayerClick=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._onLayerSelect=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,o=t.onMouseOut,i=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;o&&o(t),N(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;i&&i(t),N(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var a=r||n;t.onSelect=function(t){return a&&a(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=ot(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=ot(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},e}(mt);function _t(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},h=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},f=t({html:r,onClick:h});return f.onClick=h,f.changeStatus=l,f}var bt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return r(e,t),e.prototype.addControl=function(t,e,r){return o(this,void 0,void 0,(function(){var n,s=this;return i(this,(function(a){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){s._setControlQueue(e,(function(){return o(s,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,_t(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(gt),wt={};function Lt(t){return wt[t]}var Ot=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),wt[r.id]=r,r}return r(e,t),e.get=function(t){return Lt(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return o(this,void 0,void 0,(function(){var o,s,a,c,p,l,h,f,d,y;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,18,19,24]),o=u(this._starterKits),i.label=1;case 1:return[4,o.next()];case 2:return(s=i.sent()).done?[3,17]:(a=s.value).getLayerAdapters?[4,a.getLayerAdapters.call(a)]:[3,16];case 3:if(!(c=i.sent()))return[3,16];i.label=4;case 4:i.trys.push([4,10,11,16]),r=void 0,p=u(c),i.label=5;case 5:return[4,p.next()];case 6:return(l=i.sent()).done?[3,9]:[4,(h=l.value).createAdapter(this)];case 7:(f=i.sent())&&(this.mapAdapter.layerAdapters[h.name]=f),i.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return d=i.sent(),r={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l&&!l.done&&(n=p.return)?[4,n.call(p)]:[3,13];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=i.sent(),t={error:y},[3,24];case 19:return i.trys.push([19,,22,23]),s&&!s.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:i.sent(),i.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return o(this,void 0,void 0,(function(){var r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,14]),r=u(this._starterKits),i.label=1;case 1:return[4,r.next()];case 2:if((n=i.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return i.sent(),[3,6];case 5:return s=i.sent(),console.error(s),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return a=i.sent(),t={error:a},[3,14];case 9:return i.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(bt);var Ct,It=function(){function t(e){var r;void 0===e&&(e={}),this.cache=[];var n=null!==(r=e.namespace)&&void 0!==r?r:"default";return t.instance[n]?t.instance[n]:(t.instance[n]=this,this)}return t.prototype.clean=function(){this.cache.length=0},t.prototype.all=function(){return this.cache},t.prototype.addFull=function(t,e,r){return this.add(t,e,r,!0)},t.prototype.add=function(t,e,r,n){var o=this,i=this._find(t,r);if(i)return i.value;var s=void 0;s=e instanceof Function?e():e;var a=r&&JSON.parse(JSON.stringify(U(r))),u={key:t,value:s,props:a,options:a};return n&&!T(s)?s:(this.cache.push(u),s instanceof Promise?(s.catch((function(e){throw o.delete(t,r),e})),n&&s.then((function(e){return T(e)||o.delete(t,r),e})),s):s)},t.prototype.match=function(t,e){var r=this._find(t,e);if(r)return r.value},t.prototype.matchAll=function(t,e){var r=this;return t?this.cache.filter((function(n){return r._filter(n,t,e)})).map((function(t){return t.value})):this.cache.map((function(t){return t.value}))},t.prototype.delete=function(t,e){var r=this,n=[];"string"==typeof t?n=this.cache.filter((function(n){return r._filter(n,t,e)})):n.push(t);for(var o=0,i=n;o<i.length;o++){var s=this.cache.indexOf(i[o]);this.cache.splice(s,1)}},t.prototype._find=function(t,e){var r=this;return this.cache.find((function(n){return r._filter(n,t,e)}))},t.prototype._filter=function(t,e,r){return t.key===e&&(!r||z(t.props||t.options||{},U(r)))},t.instance={},t}(),Et=It,Pt=function(t){function e(r){var n=t.call(this)||this;return n.name="NetworkError",Object.setPrototypeOf(n,e.prototype),n.message="Unable to request ".concat(r,".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin),n}return r(e,t),e}(Error),At=function(t){function e(r){var n=t.call(this)||this;return n.name="NgwError",Object.assign(n,r),Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(Error);function Mt(t){return"[object Object]"===Object.prototype.toString.call(t)}Ct=function(t,e,r,n,o){void 0===r&&(r={}),r.method=r.method||"GET";var i=new XMLHttpRequest;i.open(r.method||"GET",t,!0),"blob"===r.responseType&&(i.responseType=r.responseType);var s=function(){try{return JSON.parse(i.responseText)}catch(t){return i.responseText}};i.onload=function(){-1!==[401,403,404,422,500].indexOf(i.status)&&n(new At(s())),function(t){void 0===t&&(t=!1);var o=t?n:e;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})}()},i.onerror=function(e){n(0===i.status?new Pt(t):e)},i.upload.onprogress=function(t){t.lengthComputable&&(r.onProgress&&r.onProgress(t.loaded/t.total*100,t))};var a,u=r.headers;if(u)for(var c in u){var p=u[c];"string"==typeof p&&i.setRequestHeader(c,p)}if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if((a=new FormData).append("file",r.file),r.data)for(var l in r.data)a.append(l,a[l])}else a=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((function(){i.abort()})),i.send(a)};var xt=/\{ *([\w_-]+) *\}/g;function kt(t,e){return t.replace(xt,(function(t,r){var n=e[r];if(void 0===n)throw new Error("No value provided for letiable "+t);return"function"==typeof n&&(n=n(e)),n}))}var St=function(t){function e(r){var n=t.call(this,r)||this;return n.name="ResourceNotFoundError",n.exception="nextgisweb.resource.exception.ResourceNotFound",Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(At),Nt=function(t){function e(r){var n=t.call(this,r)||this;return n.name="InsufficientPermissionsError",n.exception="nextgisweb.core.exception.InsufficientPermissions",Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(At),Tt=[];function Rt(t){Tt.push(t)}var Bt=["description"];function jt(t,e){void 0===e&&(e=""),e=e?e+"__":"";for(var r={},n=0,o=Object.entries(t);n<o.length;n++){var i=o[n],s=i[0],a=i[1];if(-1===Bt.indexOf(s))if(Mt(a))if("owner_user"===s){var u=jt(a,s);Object.assign(r,u)}else"parent"===s&&"id"in a&&(r.parent_id=a.id);else N(a)&&(r[e+s]=a)}return r}var Ft=function(){function t(t){this.connector=t,this.cache=new Et}return t.prototype.getOne=function(t,e){var r=this,o=new Et,i={},s=n(n({},e),{cache:!1});"string"==typeof t?i.keyname=t:"number"==typeof t?i.id=t:Mt(t)&&(void 0!==t.id?i.id=t.id:t.keyname&&(i.keyname=t.keyname));return o.addFull("resource",(function(){return"string"==typeof t?r._fetchResourceBy({keyname:t},s):"number"==typeof t?r._fetchResourceById(t,s):Mt(t)?r._fetchResourceBy(t,s):k.resolve(void 0)}),i)},t.prototype.getOneOrFail=function(t,e){return this.getOne(t,e).then((function(t){if(t)return t;throw new St}))},t.prototype.getId=function(t,e){return"number"==typeof t?k.resolve(t):"string"==typeof t||Mt(t)?this.getOne(t,e).then((function(t){if(t)return t.resource.id})):k.resolve(void 0)},t.prototype.getIdOrFail=function(t,e){return this.getId(t,e).then((function(t){if(void 0===t)throw new Error;return t}))},t.prototype.getMany=function(t,e){var r=this;return this._resourceCacheFilter(t).then((function(o){if(!o.length){var i={};return t.keyname?i.keyname=t.keyname:Object.assign(i,jt(t)),r.connector.get("resource.search",e,n({serialization:"full"},i)).then((function(t){if(t)for(var e=0,n=t;e<n.length;e++){var o=n[e];r.cache.add("resource.item",k.resolve(o),{id:o.resource.id})}return t}))}return o}))},t.prototype.getParent=function(t,e){var r=this;return this.getOne(t,e).then((function(t){return t?r.getOne(t.resource.parent.id,e):k.resolve(void 0)}))},t.prototype.getChildrenOf=function(t,e){var r=this;return this.getIdOrFail(t).then((function(t){return r._getChildrenOf(t,e)}))},t.prototype.update=function(t,e){var r=this;return this.getId(t).then((function(t){if(void 0!==t)return r.connector.put("resource.item",{data:e},{id:t})}))},t.prototype.delete=function(t){var e=this;return this.getId(t).then((function(t){if(void 0!==t)return e.connector.delete("resource.item",null,{id:t}).then((function(){e._cleanResourceItemCache(t)}))}))},t.prototype._getChildrenOf=function(t,e,r){var o=this;return void 0===r&&(r=[]),this.connector.get("resource.collection",n({cache:!0},e),{parent:t}).then((function(t){for(var n=[],i=0,s=t;i<s.length;i++){var a=s[i];o.cache.add("resource.item",k.resolve(a),{id:a.resource.id}),r.push(a),(null==e?void 0:e.recursive)&&a.resource.children&&n.push(o._getChildrenOf(a.resource.id,e,r))}return n.length?k.all(n).then((function(){return r})):r}))},t.prototype._cleanResourceItemCache=function(t){return o(this,void 0,void 0,(function(){var e,r,n,o,s,a,u,c;return i(this,(function(i){switch(i.label){case 0:e=this.cache.all(),r=[],n=0,o=e,i.label=1;case 1:return n<o.length?(a=(s=o[n]).options&&s.options.id,["resource.item","resource"].includes(s.key)&&void 0!==a?"number"!=typeof a?[3,2]:(a===t&&r.push(s),[3,4]):[3,4]):[3,5];case 2:return[4,this.getId(a)];case 3:i.sent()===t&&r.push(s),i.label=4;case 4:return n++,[3,1];case 5:for(u=0,c=r;u<c.length;u++)this.cache.delete(c[u]);return[2]}}))}))},t.prototype._fetchResourceById=function(t,e){var r=this;return this.cache.add("resource.item",(function(){return r.connector.get("resource.item",e,{id:t})}),{id:t}).catch((function(t){if(!(t instanceof St))throw t}))},t.prototype._fetchResourceBy=function(t,e){return this.getMany(t,e).then((function(t){return t[0]}))},t.prototype._resourceCacheFilter=function(t){return k.all(this.cache.matchAll("resource.item")).then((function(e){return e.filter((function(e){if(e)return t.keyname&&e.resource.keyname?t.keyname===e.resource.keyname:N(t.id)&&N(e.resource.id)?t.id===e.resource.id:z(t,e.resource)})),[]}))},t}(),Gt=0,qt=function(){function t(t){this.options=t,this.id=Gt++,this.emitter=new p.exports.EventEmitter,this.routeStr="/api/component/pyramid/route",this.activeRequests=[];var e=function(t){return Tt.find((function(e){if(e.options.baseUrl===t.baseUrl){if(!t.auth)return!0;if(e.options.auth)return z(e.options.auth,t.auth)}}))}(t);if(e)return e;this.options.route&&(this.routeStr=this.options.route),this.options.requestTransform&&(this.requestTransform=this.options.requestTransform),this.resources=new Ft(this),Rt(this)}return t.create=function(t){return new this(t)},t.prototype.setRequestTransform=function(t){this.requestTransform=t},t.prototype.setNgw=function(t){this.logout(),this.options.baseUrl=t,Rt(this)},t.prototype.connect=function(){var t=this,e=new Et,r=this.options.auth;return e.add("route",(function(){return new k((function(e,n){var o=function(){return t.makeQuery(t.routeStr,{},{}).then((function(t){e(t)})).catch((function(t){n(t)}))};if(r){var i=r.login,s=r.password;if(i&&s)return t._login({login:i,password:s}).then((function(){return o()})).catch((function(t){return n(t)}))}return o()}))}),{id:this.id,auth:r,baseUrl:this.options.baseUrl})},t.prototype.login=function(t,e){return this.logout(),Rt(this),this._login(t,e)},t.prototype.logout=function(){var t;this.abort(),-1!==(t=Tt.indexOf(this))&&Tt.splice(t,1),this.options.auth=void 0,this.user=void 0,this.emitter.emit("logout"),this.resources.cache.clean()},t.prototype.getUserInfo=function(t,e){if(this.user&&this.user.id)return k.resolve(this.user);t&&(this.options.auth=t);var r=n({headers:this.getAuthorizationHeaders(t)},e);return this.makeQuery("/api/component/auth/current_user",{},r)},t.prototype.getAuthorizationHeaders=function(t){var e=this.makeClientId(t);if(e)return{Authorization:"Basic "+e}},t.prototype.makeClientId=function(t){if(t=t||this.options.auth){var e=t.password,r=unescape(encodeURIComponent("".concat(t.login,":").concat(e)));return window.btoa(r)}},t.prototype.abort=function(){for(var t=0,e=this.activeRequests;t<e.length;t++){e[t].cancel()}this.activeRequests=[]},t.prototype.getActiveApiRequests=function(){return a([],this.activeRequests,!0)},t.prototype.apiRequest=function(t,e,r){var o,i=this;void 0===e&&(e={}),void 0===r&&(r={});var s=r.method,u=r.headers,c=r.withCredentials,p=r.responseType,l=U(e),h=function(){return function(t){var e=t.params;return new k((function(r,n){t.connector.connect().then((function(o){var i=o&&o[t.name];if(i){var s=(i=a([],i,!0)).shift();if(i.length){for(var u={},c=0;c<i.length;c++){var p=i[c];if(u[c]="{"+p+"}",void 0===e[p])throw new Error("`"+p+"` url api argument is not specified")}s&&(s=kt(s,u))}if(e){var l=[],h=e.paramList;for(var f in Array.isArray(h)&&(delete e.paramList,h.forEach((function(t){l.push("".concat(t[0],"=").concat(t[1]))}))),e)-1===i.indexOf(f)&&l.push("".concat(f,"=").concat(e[f]));l.length&&(s=s+"?"+l.join("&"))}s?r(t.connector.makeQuery(s,e,t.requestOptions)):n(new Error("request url is not set"))}else r(void 0)})).catch((function(t){n(t)}))}))}({name:t,params:l,requestOptions:r,connector:i})};return r.cache&&"GET"===s?(new Et).add(t,h,n({params:l},U({headers:u,withCredentials:c,responseType:p,baseUrl:this.options.baseUrl,userId:null===(o=this.user)||void 0===o?void 0:o.id}))):h()},t.prototype.post=function(t,e,r){return(e=e||{}).method="POST",this.apiRequest(t,r,e)},t.prototype.get=function(t,e,r){return(e=e||{}).method="GET",this.apiRequest(t,r,e)},t.prototype.patch=function(t,e,r){return(e=e||{}).method="PATCH",this.apiRequest(t,r,e)},t.prototype.put=function(t,e,r){return(e=e||{}).method="PUT",this.apiRequest(t,r,e)},t.prototype.delete=function(t,e,r){return(e=e||{}).method="DELETE",this.apiRequest(t,r,e)},t.prototype.makeQuery=function(t,e,r){if(void 0===r&&(r={}),t=(this.options.baseUrl?this.options.baseUrl:"")+t)return e&&(t=kt(t,e)),t=encodeURI(W(t)),this._loadData(t,r);throw new Error("Empty `url` not allowed")},t.prototype.getResource=function(t,e){return this.resources.getOne(t,e)},t.prototype.getResourceOrFail=function(t,e){return this.resources.getOneOrFail(t,e)},t.prototype.getResourceBy=function(t){return this.resources.getOne(t)},t.prototype.getResourceByKeyname=function(t){return this.resources.getOne(t)},t.prototype.getResourceById=function(t){return this.resources.getOne(t)},t.prototype.getResourceId=function(t,e){return this.resources.getId(t,e)},t.prototype.getResourceIdOrFail=function(t,e){return this.resources.getIdOrFail(t,e)},t.prototype.getResourcesBy=function(t,e){return this.resources.getMany(t,e)},t.prototype.getResourceParent=function(t,e){return this.resources.getParent(t,e)},t.prototype.getResourceChildren=function(t,e){return this.resources.getChildrenOf(t,e)},t.prototype.updateResource=function(t,e){return this.resources.update(t,e)},t.prototype.deleteResource=function(t){return this.resources.delete(t)},t.prototype._loadData=function(t,e){var r=this;e.responseType=e.responseType||"json";var o=new k((function(o,i,s){if(r.user&&((e=e||{}).headers=n(n({},r.getAuthorizationHeaders()),e.headers)),r.requestTransform){var a=r.requestTransform(t,e);t=a[0],e=a[1]}Ct(t,o,e,i,s)})).then((function(t){return r._cleanActiveRequests(o),t})).catch((function(t){if(r._cleanActiveRequests(o),t instanceof k.CancelError);else{var e=r._handleHttpError(t);if(e)throw e}}));return e.signal&&"function"==typeof e.signal.addEventListener&&e.signal.addEventListener("abort",(function(){o.cancel(),r._cleanActiveRequests(o)})),this.activeRequests.push(o),o},t.prototype._login=function(t,e){var r=this;return this.getUserInfo(t,e).then((function(t){return r.user=t,r.emitter.emit("login",t),t})).catch((function(t){throw r.emitter.emit("login:error",t),t}))},t.prototype._cleanActiveRequests=function(t){var e=this.activeRequests.indexOf(t);-1!==e&&this.activeRequests.splice(e,1)},t.prototype._handleHttpError=function(t){if(t&&t instanceof At){if("nextgisweb.resource.exception.ResourceNotFound"===t.exception)throw new St(t);if("nextgisweb.core.exception.InsufficientPermissions"===t.exception)throw new Nt(t)}return t},t.errors={NgwError:At,ResourceNotFoundError:St},t}(),Dt=qt;function Vt(t){var e=t.extent_bottom,r=t.extent_left,n=t.extent_top,o=t.extent_right;if(e&&r&&n&&o){var i=[r,e,o,n];return i[3]>82&&(i[3]=82),i[1]<-82&&(i[1]=-82),i}}function zt(t){var e=t.cache;return t.connector.get("layer.extent",{cache:void 0===e||e},{id:t.resourceId}).then((function(t){if(t){var e=t.extent;return[e.minLon,e.minLat,e.maxLon,e.maxLat]}}))}function Ut(t){return t.connector.getResource(t.resourceId).then((function(e){if(e)return Zt(e,t.connector,t)}))}function Zt(t,e,r){if(t.webmap)return k.resolve(Vt(t.webmap));var o=t.resource;return o.cls&&-1!==o.cls.indexOf("style")?e.getResource(o.parent.id).then((function(t){if(t)return zt(n(n({},r),{resourceId:t.resource.id,connector:e}))})):zt(n(n({},r),{resourceId:o.id,connector:e}))}var Wt=function(){function t(){}return t.prototype.getExtent=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.getBounds()]}))}))},t.prototype.getBounds=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return this._extent?[2,this._extent]:this.item?(e=this,[4,Zt(this.item,this.connector,t)]):[3,2];case 1:return e._extent=r.sent(),[2,this._extent];case 2:return[2]}}))}))},t}();var $t=["fields","intersects","limit","orderBy","strategy"];function Ht(t){var e={};return $t.forEach((function(r){var n=t[r];void 0!==n&&(e[r]=n)})),e}function Jt(t,e){return o(this,void 0,void 0,(function(){var r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return n=r=t.resource,o=t.keyname,s=t.resourceId,r?"string"!=typeof r?[3,1]:(o=r,[3,5]):[3,5];case 1:return"number"!=typeof r?[3,2]:(s=r,[3,5]);case 2:return n.resource&&void 0!==n.resource&&"resource"in n?(s=r.resource.id,[3,5]):[3,3];case 3:return[4,Jt(r,e)];case 4:s=i.sent(),i.label=5;case 5:return s||!o?[3,7]:[4,e.getResource(o)];case 6:(a=i.sent())&&(s=a.resource.id),i.label=7;case 7:return[2,s]}}))}))}var Qt={srs:4326,geom_format:"geojson"};function Kt(t){return{geometry:t.geom,id:t.id,type:"Feature",properties:t.fields}}function Xt(t,e){var r=e.extensions,n=e.geom,o=e.fields,i=e.srs;t.extensions=r?r.join(","):"",void 0!==o&&(t.fields=Array.isArray(o)?o.join(","):""),void 0!==n&&(t.geom=n?"yes":"no",n||(delete t.srs,delete t.geom_format)),N(i)&&(t.srs=i)}function Yt(t){var e=ee(t);return k.all(e).then((function(e){for(var r=[],n=[],o=0,i=e;o<i.length;o++)for(var s=0,a=i[o];s<a.length;s++){var u=a[s];r.includes(u.id)||(n.push(u),r.push(u.id))}return t.offset||t.limit?n.splice(void 0!==t.offset?t.offset:0,void 0!==t.limit?t.limit:n.length):n}))}function te(t){var e=t[0],r=t[1],n=t[2],o="id"!==e?"fld_":"",i="",s="",a=String(e).trim().replace(/^(%?)(.+?)(%?)$/,(function(t,e,r,n){return i=e,s=n,r})),u=i+n+s;return["".concat(o).concat(a,"__").concat(r),u]}function ee(t,e,r){void 0===e&&(e=[]),void 0===r&&(r=[]);var o=t.filters,i="string"==typeof o[0]?o[0]:"all",s=o.filter((function(t){return Array.isArray(t)}));if("any"===i)for(var u=0,c=s;u<c.length;u++){tt(d=c[u])?e.push(ne(n(n({},t),{paramList:a(a([],r,!0),[te(d)],!1)}))):ee(n(n({},t),{filters:d}),e,a([],r,!0))}else if("all"===i){for(var p=[],l=[],h=0,f=s;h<f.length;h++){var d;tt(d=f[h])?p.push(te(d)):l.push(d)}if(l.length)for(var y=0,v=l;y<v.length;y++){var m=v[y];ee(n(n({},t),{filters:m}),e,a(a([],r,!0),p,!0))}else e.push(ne(n(n({},t),{paramList:a(a([],r,!0),p,!0)})))}return e}function re(t){var e=t.map((function(t){var e=D(t[0],t[1]).map((function(t){return e=t,n=r?Number("1e+"+r):1,Math.round((e+Number.EPSILON)*n)/n;var e,r,n}));return e[0]+" "+e[1]}));return"POLYGON((".concat(e.join(", "),"))")}function ne(t){var e,r=n({},Qt),o=t.limit,i=t.cache,s=t.signal,a=t.offset,u=t.orderBy,c=t.paramList,p=t.connector,l=t.geomFormat,h=t.intersects,f=t.resourceId;if(o?o!==Number.POSITIVE_INFINITY&&(r.limit=o):r.limit=7e3,a&&(r.offset=a),l&&(r.geom_format=l),Xt(r,t),u&&(r.order_by=u.join(",")),Array.isArray(h)){var d=(e=h,Array.isArray(e)&&4===e.length&&e.every((function(t){return"number"==typeof t}))?F(h):h);r.intersects=re(d)}else"string"==typeof h&&(r.intersects=h);c&&(r.paramList=c);var y=n({id:f},r);return p.get("feature_layer.feature.collection",{cache:i,signal:s},y)}function oe(t){var e,r=function(){var r=t[e];if(Z(r)){var n=r;if(N(n.year)&&N(n.month)&&N(n.day)){var o=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach((function(t){o.push(t)})),t[e]=(new(Date.bind.apply(Date,a([void 0],o,!1)))).toISOString()}}else"id"===e&&"string"==typeof r&&(t[e]=r.split(",").map(Number))};for(e in t)r();return t}function ie(t){var e=t.filters;return e?Yt(n(n({},t),{filters:e})).then((function(r){var o;return(null!==(o=t.clientFilterValidate)&&void 0!==o?o:se(e))&&(r=r.filter((function(t){return et(oe(n(n({},t.fields),{id:t.id})),e)}))),r})):ne(t)}function se(t){if("any"===t[0])return!0;for(var e=1;e<t.length;e++){var r=t[e];if("[object Array]"===Object.prototype.toString.call(r))if(se(r))return!0}return!1}function ae(t){return function(t){return ie(t).then((function(t){var e=[];return t.forEach((function(t){e.push(Kt(t))})),e}))}(t).then((function(t){return{type:"FeatureCollection",features:t}}))}function ue(t){var e,s;return o(this,void 0,void 0,(function(){var a,u,c,l,h,f,d,y,v,m,g,_,b,w,L,O,C=this;return i(this,(function(I){switch(I.label){case 0:return a=t.item,u=t.webMap,h=null==(l=t.addLayerOptionsPriority)||l,d=t.Adapter||u.mapAdapter.layerAdapters.GEOJSON,y=[],v=!1,[4,Jt(f=t.layerOptions,c=t.connector)];case 1:return _=I.sent(),(null===(s=null===(e=f.adapterOptions)||void 0===e?void 0:e.popupOptions)||void 0===s?void 0:s.fromProperties)&&(f.adapterOptions.popupOptions.createPopupContent=function(t){var e=t.feature;return e&&function(t,e){var r=document.createElement("div");if(e&&e.feature_layer)e.feature_layer.fields.forEach((function(e){if(e.grid_visibility){var n=t.properties&&t.properties[e.keyname];if(n){var o=document.createElement("div");r.appendChild(o),o.innerHTML="<span>".concat(e.display_name,"</span>: ").concat(n,"<span></span>")}}}));else if(t.properties)for(var n in t.properties){var o=document.createElement("div");r.appendChild(o),o.innerHTML="<span>".concat(n,"</span>: ").concat(t.properties[n],"<span></span>")}return r}(e,a)}),b=function(t,e){return o(C,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return L(),m={filters:t,options:e},[4,g=ae(n({resourceId:_,filters:t,connector:c,cache:!0},e))];case 1:return[2,r.sent()]}}))}))},w=!1,L=function(){g&&(g.cancel(),g=void 0)},O=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.emitter=new p.exports.EventEmitter,e}return r(e,t),e.prototype.addLayer=function(e){return o(this,void 0,void 0,(function(){var r,o,s,u,c;return i(this,(function(i){switch(i.label){case 0:return r=!e.data,o=void 0===e.waitFullLoad||e.waitFullLoad,void 0!==f.id&&(e.id=f.id),a&&a.vector_layer&&(e.type=qe[a.vector_layer.geometry_type]),f.adapterOptions&&(e=h?n(n({},f.adapterOptions),e):n(n({},e),f.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,r=!1),this.options.strategy=s=e.strategy||void 0,u=t.prototype.addLayer.call(this,e),m={filters:e.propertiesFilter,options:Ht(e)},r&&(c=this.updateLayer()),o&&c?[4,c]:[3,2];case 1:i.sent(),i.label=2;case 2:return s&&s.startsWith("BBOX")&&!v&&this._addBboxEventListener(),[2,u]}}))}))},e.prototype.getExtent=function(){return this.getBounds()},e.prototype.getBounds=function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){return e=this.getLayers&&this.getLayers().length,(null==(r=this.options.strategy)?void 0:r.startsWith("BBOX"))||e?[2,Ut({connector:c,resourceId:a.resource.id})]:t.prototype.getBounds?[2,t.prototype.getBounds.call(this)]:[2]}))}))},e.prototype.beforeRemove=function(){w=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,L()},e.prototype.getCount=function(){return function(t){var e=t.cache;return t.connector.get("feature_layer.feature.count",{cache:void 0===e||e},{id:t.resourceId}).then((function(t){return t.total_count}))}({connector:c,resourceId:_,cache:!0})},e.prototype.updateLayer=function(e){var r;return o(this,void 0,void 0,(function(){var o,s,a,c,p,l,h,d,g,_,L;return i(this,(function(i){switch(i.label){case 0:return e=e||m||{},(null===(r=this.options.strategy)||void 0===r?void 0:r.startsWith("BBOX"))?[4,u.onLoad("create")]:[3,2];case 1:if(i.sent(),e.options=e.options||{},e.options.intersects=u.getBounds(),s=(o=this.options).minZoom,a=o.maxZoom,void 0!==(c=u.getZoom())){if(void 0!==s&&c<s)return[2];if(void 0!==a&&c>a)return[2];if(v)return[2]}i.label=2;case 2:if(w)return[2];i.label=3;case 3:return i.trys.push([3,10,,11]),this.emitter.emit("preupdate",e),u._emitLayerEvent("layer:preupdate",f.id||"",e),[4,b(e.filters,n(n({},e.options),{srs:this.options.srs}))];case 4:return p=i.sent(),l=p,[4,this.getCount()];case 5:if(h=i.sent(),"BBOX+"!==this.options.strategy)return[3,7];for(l={type:"FeatureCollection",features:[]},d=0,g=p.features;d<g.length;d++)_=g[d],-1===y.indexOf(String(_.id))&&(y.push(String(_.id)),l.features.push(_));return v=void 0!==h&&y.length>=h,[4,u.addLayerData(this,l)];case 6:return i.sent(),[3,9];case 7:return v=void 0!==h&&p.features.length>=h,[4,u.setLayerData(this,p)];case 8:i.sent(),i.label=9;case 9:return this.emitter.emit("updated",p),u._emitLayerEvent("layer:updated",f.id||"",{data:p,newData:l,isFull:v}),[3,11];case 10:if((L=i.sent())instanceof Error&&"CancelError"!==L.name)throw L;return[3,11];case 11:return t.prototype.updateLayer&&t.prototype.updateLayer.call(this),[2]}}))}))},e.prototype.propertiesFilter=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return L(),this.filter&&v?(this.filter((function(e){var r=e.feature&&e.feature.properties&&oe(n({},e.feature.properties));return!r||et(r,t)})),[3,3]):[3,1];case 1:return this.setData?(this.clearLayer&&this.clearLayer(),[4,b(t,n(n({},e),{srs:this.options.srs}))]):[3,3];case 2:r=o.sent(),this.setData(r),o.label=3;case 3:return[2]}}))}))},e.prototype.removeFilter=function(){m=void 0,this.propertiesFilter([]),this.filter&&this.filter((function(){return!0}))},e.prototype._addBboxEventListener=function(){var t=this;this.__enableMapMoveListener=function(e){e===t&&(t._removeMoveEventListener(),t.updateLayer(),t._addMoveEventListener())},this.__disableMapMoveListener=function(e){e===t&&t._removeMoveEventListener()},u.emitter.on("layer:show",this.__enableMapMoveListener),u.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)},e.prototype._removeBboxEventListener=function(){this.__enableMapMoveListener&&u.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&u.emitter.on("layer:hide",this.__disableMapMoveListener)},e.prototype._addMoveEventListener=function(){var t=this;this.__onMapMove=function(t,e){var r;function n(){for(var o=this,i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];n.clear(),r=setTimeout((function(){r=null,t.apply(o,i)}),e)}return void 0===e&&(e=10),n.clear=function(){r&&(clearTimeout(r),r=null)},n}((function(){return t.updateLayer()})),this.__onMapMoveStart=L,u.emitter.on("movestart",this.__onMapMoveStart),u.emitter.on("moveend",this.__onMapMove)},e.prototype._removeMoveEventListener=function(){this.__onMapMove&&u.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&u.emitter.removeListener("movestart",this.__onMapMoveStart)},e}(d),[2,O]}}))}))}function ce(t){var e,r,n=t.options,o=t.webMap,i=t.baseUrl,s=n.adapter||"IMAGE",a=o&&o.getLayerAdapters(),u=n.resource,c=n.tileNoData?n.tileNoData:200;if("number"==typeof u){if("IMAGE"===s){if(!a||a.IMAGE)return function(t){var e=t.resourceId,r=t.nd,n=t.headers,o=t.baseUrl+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:function(t){return r&&(t.nd=r),Fe(t,e)}}}({resourceId:u,headers:n.headers,nd:c,baseUrl:i});s="TILE"}if("WMS"===s){r="".concat(i,"/api/resource/").concat(u,"/wms");var p=n.adapterOptions;return{url:r,format:"image/png",version:"1.1.1",layers:p&&p.layers,headers:n.headers}}if("MVT"===s)return{url:r=i+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+u+"&simplification="+(null!==(e=n.simplification)&&void 0!==e?e:6),sourceLayer:"ngw:"+u,featureIdName:"$id"};if("TERRAIN"===s)return{url:r=i+"/api/resource/".concat(u,"/terrain_provider"),adapter:s};if("MODEL_3D"===s)return{url:r=i+"/api/component/model_3d/".concat(u,"/data.glb")};if("TILE"===s)return{url:r=i+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+u+"&nd="+c,adapter:s}}else{if(void 0!==u)throw new Error("Option `resource` must be number, not "+typeof u);console.log("Option `resource` not set")}}function pe(t){var e=t.layerOptions,s=t.webMap,a=t.connector,u=t.item;return o(this,void 0,void 0,(function(){var t,c,p,l,h,f;return i(this,(function(d){switch(d.label){case 0:return t=u.resource.cls,c={wmsserver_service:"WMS",tmsclient_layer:"IMAGE"},void 0!==(p=e.adapter||t&&c[t]||"IMAGE")&&(e.adapter=p),"IMAGE"===p&&(l=s.getLayerAdapters(),!l||l.IMAGE||(p="TILE")),(h=s.mapAdapter.layerAdapters[p])?[4,Jt(e,a)]:[3,2];case 1:return f=d.sent(),[2,function(t){function c(r,o){var i=t.call(this,r,o)||this;i.map=r,i.item=u,i.resourceId=f;var c=ce({options:e,webMap:s,baseUrl:a.options.baseUrl||""});if(c){var p=n(n(n({},c),e.adapterOptions),{params:{resource:f},layers:c.layers||String(f),resourceId:f});e.adapterOptions&&N(e.adapterOptions.setViewDelay)&&(p.setViewDelay=e.adapterOptions.setViewDelay),i.options=n(n({},i.options),p)}return i}return r(c,t),c.prototype.addLayer=function(e){return t.prototype.addLayer.call(this,n(n({},this.options),e))},c.prototype.getIdentificationIds=function(){return o(this,void 0,void 0,(function(){var t;return i(this,(function(e){if(this.item){if("MVT"===p)return[2,[this.item.resource.id]];if(N(t=this.item.resource.parent.id))return[2,[t]]}return[2,[]]}))}))},c}(h)];case 2:throw new Error(p+" not supported yet. Only TILE")}}))}))}function le(t,e,r,n){return!!de(t,e,r,ye,n)}function he(t,e,r,n){return de(t,e,r,ve,n)}function fe(t,e){void 0===e&&(e="children");var r=[],n=("function"==typeof e?e:function(t){return t[e]})(t);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function de(t,e,r,n,o){void 0===e&&(e=function(t){return!!t}),void 0===r&&(r="children");var i="function"==typeof e?e:function(t){return et(t,e)};return n(t,o?function(t){return i(o(t))}:i,r)}function ye(t,e,r,n){void 0===e&&(e=function(t){return!!t});var o=[];if(Array.isArray(t))o=t;else{if(e(t))return t;var i=fe(t,r);i&&(o=i)}for(var s=0;s<o.length;s++)if(o[s]){var a=ye(o[s],e,r);if(a)return a}}function ve(t,e,r,n){void 0===e&&(e=function(t){return!!t}),void 0===n&&(n=[]);var o=[];if(Array.isArray(t))o=t;else{e(t)&&n.push(t);var i=fe(t,r);i&&(o=i)}for(var s=0;s<o.length;s++)o[s]&&ve(o[s],e,r,n);return n}function me(t,e,r,n){void 0===e&&(e=function(t){return!!t});var o=[];if(Array.isArray(t))o=t;else{if(!e(t))return!1;var i=fe(t,r);i&&(o=i)}for(var s=0;s<o.length;s++){if(o[s])if(!me(o[s],e,r))return!1}return!0}var ge=function(){function t(t){this._children=[],this.item=t}return t.prototype.setParent=function(t){this._parent=t},t.prototype.addChild=function(t){this._children.push(t)},t.prototype.getParent=function(){return this._parent},t.prototype.getParents=function(t){var e=this.getParent();return e?he(e,t,(function(t){return t.tree.getParent()})):[]},t.prototype.getRoot=function(){for(var t=this.getParent(),e=t;t;)(t=t.tree.getParent())&&(e=t);return e},t.prototype.find=function(t){return de(this._children,t,(function(t){return t.tree.getChildren()}),ye,e);var e},t.prototype.every=function(t){return!!de(this._children,t,(function(t){return t.tree.getChildren()}),me,e);var e},t.prototype.some=function(t){return le(this._children,t,(function(t){return t.tree.getChildren()}))},t.prototype.all=function(t){return this.getDescendants(t)},t.prototype.getDescendants=function(t){return he(this._children,t,(function(t){return t.tree.getChildren()}))},t.prototype.getChildren=function(){return a([],this._children,!0)},t}(),_e=function(){function t(t,e,r){this.emitter=new p.exports.EventEmitter,this._blocked=!1,this.item=e,this.options=Object.assign({},r),this.name=t,this._value=this.getProperty()}return t.prototype.getProperty=function(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value},t.prototype.getParents=function(){return this.item.tree.getParents()||[]},t.prototype.getParent=function(){return this.item.tree.getParent()},t.prototype.getChildren=function(){return this.item.tree.getChildren()},t.prototype.isGroup=function(){return this.item.tree.getDescendants().length},t.prototype.isBlocked=function(){var t=this;if(void 0===this._blocked){var e=this.item.tree.getParents();if(e){var r=e.find((function(e){var r=e.properties&&e.properties.property(t.name);return!!r&&!r.get()}));this._blocked=!!r}else this._blocked=!1}return this._blocked},t.prototype.set=function(t,e){this._value=this._prepareValue(t),this.update(this._value,e),this._fireChangeEvent(this._value,e)},t.prototype.get=function(){return this.getValue()},t.prototype.update=function(t,e){this._callOnSet(t,e)},t.prototype.getContainer=function(){return this._container},t.prototype.destroy=function(){if(this._container){var t=this._container.parentNode;t&&t.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()},t.prototype.getValue=function(){return void 0!==this._value?this._value:this.getProperty()},t.prototype._prepareValue=function(t){return t},t.prototype._callOnSet=function(t,e){this.options.onSet&&this.options.onSet.call(this,t,e,this.item)},t.prototype._fireChangeEvent=function(t,e){var r=this;this.emitter&&(t=void 0!==t?t:this.getValue(),this.emitter.emit("change",{value:t,options:e}),this.item.tree.getParents().forEach((function(n){var o=n.properties&&n.properties.property(r.name);o&&o.emitter.emit("change-tree",{value:t,options:e,item:r.item})})))},t}(),be=function(t){function e(r,o,i){var s=t.call(this,r,o,n(n({},e.options),i))||this;return s.set(s.get()),s}return r(e,t),e.prototype.update=function(t,e){if(t){if(e&&e.bubble||this.options.bubble){this.unBlock(e);var r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(t,Object.assign({},e,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(e)}else this._turnOff(e);(e&&e.propagation||this.options.propagation)&&this._propagation(t,e)},e.prototype.getHierarchyValue=function(){var t=this;return this.get()&&this.getParents().every((function(e){var r=e.properties&&e.properties.get(t.name);return r&&r.get()}))},e.prototype.block=function(t){this._blocked=!0,this._block(t)},e.prototype.unBlock=function(t){this._blocked=!1,this.getValue()&&this._unBlock(t)},e.prototype.blockChild=function(t){var e=this;this.item.tree.getDescendants().forEach((function(r){return e._blockChild(r,t)}))},e.prototype.unblockChild=function(t){var e=this;this.item.tree.getChildren().forEach((function(r){return e._unBlockChild(r,t)}))},e.prototype._prepareValue=function(t){return t},e.prototype._turnOff=function(t){this.options.turnOff&&this.options.turnOff.call(this,t),this._callOnSet(!1,t),this.options.hierarchy&&this.isGroup()&&this.blockChild(t)},e.prototype._turnOn=function(t){this.options.turnOn&&this.options.turnOn.call(this,t),this._callOnSet(!0,t),this.options.hierarchy&&this.isGroup()&&this.unblockChild(t)},e.prototype._block=function(t){this._turnOff(t)},e.prototype._unBlock=function(t){this._turnOn(t)},e.prototype._blockChild=function(t,e){var r=t.properties&&t.properties.property(this.name);r&&r.block&&r.block(e)},e.prototype._unBlockChild=function(t,e){var r=t.properties&&t.properties.property(this.name);r&&r.unBlock&&r.unBlock(e)},e.prototype._propagation=function(t,e){if(this.isGroup())for(var r=this.item.tree.getChildren(),o=0;o<r.length;o++){var i=r[o],s=i.properties&&i.properties.property(this.name);s&&s.set(t,n(n({},e),{propagation:!0,bubble:!1}))}},e.options={hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"},e}(_e),we=function(){function t(t,e){this.item=t,this.options={},this._properties={},this._propertiesList=[],e&&e.forEach(this._setPropertyHandler.bind(this))}return t.prototype.add=function(t){this._setPropertyHandler(t)},t.prototype._setPropertyHandler=function(e){var r=t.handlers,o=e.handler;if(!o&&e.type)if("boolean"===e.type)o=r.CheckProperty;else o=r.BaseProperty;if(o&&e.name){var i=n({},e||{});this._properties[e.name]=new o(e.name,this.item,i),this._propertiesList.push(e.name)}},t.prototype.update=function(){this.list().forEach((function(t){t.update()}))},t.prototype.get=function(t){var e=this.property(t);if(e)return e.get()},t.prototype.set=function(t,e,r){var n=this.property(t);if(n)return n.set(e,r)},t.prototype.property=function(t){return this._properties[t]},t.prototype.list=function(){var t=this;return this._propertiesList.map((function(e){return t._properties[e]}))},t.prototype.destroy=function(){for(var t in this._properties){var e=this.property(t);e&&e.destroy&&e.destroy()}this._properties={},this._propertiesList=[]},t.handlers={CheckProperty:be},t}(),Le=0,Oe=function(){function t(t){this.options={},this.id=Le,Le+=1,this.options=n({},t),this.tree=new ge(this)}return t.prototype.initProperties=function(){this.properties=new we(this,this.options.properties)},t}(),Ce=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.getProperty=function(){var t=this.item.layer;return t&&t&&t.options&&void 0!==t.options.opacity?t.options.opacity:1},e.prototype.update=function(t,e){var r=this;if(e=e||{},this.isGroup()){this._value=this._prepareValue(t,e);for(var n=0,o=this.getChildren();n<o.length;n++){var i=o[n].properties.property(this.name);i&&(e.propagation?i.set(t,e):i.update(i.get(),e))}}var s=this.item.layer;if(s){var a=this.getParents().reduce((function(t,e){var n=e.properties.property(r.name);return t*(n?n.getValue():1)}),1);this.item.webMap.setLayerOpacity(s,this._prepareValue(t*a))}},e.prototype._prepareValue=function(t,e){return e&&e.propagation&&this.isGroup()?1:Number(t)},e}(_e),Ie=function(t){function e(r,o,i,s,a,u){var c=t.call(this,n(n({},e.options),i))||this;if(c.webMap=r,c.emitter=new p.exports.EventEmitter,c._rootDescendantsCount=0,s&&(c.connector=s),a&&c.tree.setParent(a),c.item=o,"root"===c.item.item_type)c._rootDescendantsCount=c._sumUp(c.item.children);else{var l=c.tree.getRoot();l&&(c._rootDescendantsCount=l._rootDescendantsCount)}return c.initProperties(),u||c._init(o),c}return r(e,t),e.create=function(t,r,n,s,a){return o(this,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return[4,(o=new e(t,r,n,s,a,!0))._init(r)];case 1:return i.sent(),[2,o]}}))}))},e.prototype.initItem=function(t){var r=this,n=t,o=this.getItemOptions(t),i=function(t){n._layer=t,r.layer=t,r.properties.get("visibility")&&r.properties.set("visibility",!0),void 0!==o.opacity&&r.webMap.setLayerOpacity(t,o.opacity)};if("group"===t.item_type||"root"===t.item_type){if(t.children&&t.children.length)for(var s=0,a=this.getChildren(t);s<a.length;s++){var u=new this.constructor(this.webMap,a[s],this.options,this.connector,this);this.tree.addChild(u)}return Promise.resolve()}var c=void 0;if("layer"===t.item_type)c=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){c=(0,e.GetAdapterFromLayerType[t.item_type])(t,o,this.webMap,this.connector)}return c?this.webMap.addLayer(c,o).then((function(t){i(t)})):t._layer?Promise.resolve(i(t._layer)):Promise.reject("No layer added")},e.prototype.bringToFront=function(){},e.prototype.fit=function(){},e.prototype.getLayer=function(){return this.layer},e.prototype.getItemOptions=function(t){var e="layer"===t.item_type&&t.layer_transparency,r="number"==typeof e?(100-e)/100:void 0,n={visibility:!1,headers:this.options.headers,crossOrigin:this.options.crossOrigin,setViewDelay:this.options.setViewDelay,params:{resource:this.item.resourceId,item:this.item}};if(this.options.order){var o=String(this.options.drawOrderEnabled&&"draw_order_position"in t?this._rootDescendantsCount-t.draw_order_position:this.id).padStart(4,"0");n.order=Number((0|this.options.order)+"."+o)}if(this.options.popupOptions&&(n.popupOptions=this.options.popupOptions),"layer"===t.item_type){var i=this._getZoomRange(t);!function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0,o=e;n<o.length;n++)for(var i=o[n],s=0,a=Object.getOwnPropertyNames(i);s<a.length;s++){var u=a[s];t[u]=i[u]}}(n,{updateWmsParams:t.updateWmsParams,url:t.url,headers:this.options.headers,ratio:this.options.ratio,maxZoom:i.maxZoom,minZoom:i.minZoom,minScale:t.layer_min_scale_denom,maxScale:t.layer_max_scale_denom})}return void 0!==r&&(n.opacity=r),n},e.prototype.getChildren=function(t){return a([],t.children,!0).reverse()},e.prototype._mapScaleToZoomLevel=function(t){return function(t,e){void 0===e&&(e=0);var r=e;return function(t){return Math.log(t/256)/Math.LN2}(function(){if(void 0===Ge){var t=document.createElement("div");t.style.cssText="position: absolute; left: -100%; top: -100%; width: 100cm;",document.body.appendChild(t);var e=t.offsetWidth;document.body.removeChild(t),Ge=e}return Ge}()*function(t){return 12756274*Math.PI*Math.cos(t*Math.PI/180)}(r)/t)}(t)},e.prototype._getZoomRange=function(t){var e=this.options.minZoom,r=this.options.maxZoom,n=t.layer_min_scale_denom?this._mapScaleToZoomLevel(t.layer_min_scale_denom):void 0,o=t.layer_max_scale_denom?this._mapScaleToZoomLevel(t.layer_max_scale_denom):void 0,i=[e,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max.apply(Math,i):void 0,maxZoom:s.length?Math.min.apply(Math,s):void 0}},e.prototype._init=function(t){var e=this;this.initItem(t).then((function(){e.emitter.emit("init")}))},e.prototype._sumUp=function(t,e){void 0===e&&(e=0);for(var r=0,n=t;r<n.length;r++){var o=n[r];"layer"===o.item_type?(e+=1,o.draw_order_position=o.draw_order_position||e):"group"===o.item_type&&(e=this._sumUp(o.children,e))}return e},e.GetAdapterFromLayerType={},e.options={properties:[{type:"boolean",name:"visibility",getProperty:function(t){if(t){if("group"===t.item.item_type||"root"===t.item.item_type)return le(t.item,(function(t){return"layer_enabled"in t&&t.layer_enabled}),(function(t){return t.children}));if("layer"===t.item.item_type)return t.item.layer_enabled}return!1},onSet:function(t,e,r){r&&"layer"===r.item.item_type&&(r.layer&&(t?r.webMap.showLayer(r.layer):r.webMap.hideLayer(r.layer)),r.item.layer_enabled=t)}},{name:"opacity",handler:Ce}]},e}(Oe);function Ee(t){var e=t.webMap,r=t.connector,s=t.item,a=t.adapterOptions,u=void 0===a?{}:a,c=t.idPrefix,p=void 0===c?"first-show-adapter":c;return o(this,void 0,void 0,(function(){var t;return i(this,(function(a){return t=function(t){var e=t.webMap,r=t.adapterOptions,s=void 0===r?{}:r,a=t.onLayerAdded,u=t.createAdapter;return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){return t=function(){function t(){this.options={},this.layer=[],this._removed=!1,this._creatingInProgress=!1}return t.prototype.addLayer=function(){return this.layer},t.prototype.removeLayer=function(){this._removed=!0;for(var t=0,r=this.layer;t<r.length;t++)e.removeLayer(r[t])},t.prototype.destroyed=function(){return this._removed},t.prototype.showLayer=function(){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(this.options.visibility=!0,!this.layer.length)return[3,5];t=0,r=this.layer,n.label=1;case 1:return t<r.length?[4,e.showLayer(r[t])]:[3,4];case 2:n.sent(),n.label=3;case 3:return t++,[3,1];case 4:return[3,7];case 5:return[4,this.loadLayer()];case 6:n.sent(),n.label=7;case 7:return[2]}}))}))},t.prototype.hideLayer=function(){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(this.options.visibility=!1,!this.layer)return[3,4];t=0,r=this.layer,n.label=1;case 1:return t<r.length?[4,e.hideLayer(r[t])]:[3,4];case 2:n.sent(),n.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},t.prototype.loadLayer=function(){return o(this,void 0,void 0,(function(){var t,r,o;return i(this,(function(i){switch(i.label){case 0:return this.layer.length||this._creatingInProgress?[3,5]:(this._creatingInProgress=!0,[4,u(this)]);case 1:return(t=i.sent())?[4,(r=new t(e.mapAdapter.map,n({},s))).addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer})]:[3,5];case 2:return o=i.sent(),a&&a(r),Object.assign(r.options,s),r.layer=o,this._removed&&e.removeLayer(r),this.layer.push(r),this.options.visibility?[4,e.showLayer(r)]:[3,4];case 3:i.sent(),i.label=4;case 4:this._creatingInProgress=!1,i.label=5;case 5:return[2,this.layer]}}))}))},t}(),[2,t]}))}))}({webMap:e,adapterOptions:u,onLayerAdded:function(t){t.options.baselayer=!1,t.id=p+"-"+s.resource_id},createAdapter:function(){return je({resource:s.resource_id,adapterOptions:{name:s.display_name,opacity:s.opacity}},e,r)}}),[2,t]}))}))}var Pe=function(){function t(t){this.options=t,this.resourceId=t.resourceId;var e=t.item;this.item=e,this.name=t.labelField&&e.fields?e.fields[t.labelField]:String(e.id)}return t.prototype.extent=function(){var t=this;return this._extent?k.resolve(this._extent):this.options.connector.get("feature_layer.feature.item_extent",null,{id:this.resourceId,fid:this.item.id}).then((function(e){var r=e.extent,n=[r.minLon,r.minLat,r.maxLon,r.maxLat];return t._extent=n,n}))},t.prototype.geoJson=function(){var t=this;return this.item.geom?k.resolve(Kt(this.item)):Ue({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null}).then((function(e){return t.item.geom=e.geom,Kt(t.item)}))},t}(),Ae=function(){function t(t,e){this.map=t,this.options=e,this.NgwWebmapItem=Ie,this.pixelRadius=10,this.webmapClassName="webmap",this.emitter=new p.exports.EventEmitter,this._webmapBaselayersIds=[];var r=e.resourceId;if(Array.isArray(r)?(this.resourceId=r[0],this.options.id=r[1]):this.resourceId=r,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}return t.prototype.addLayer=function(t){var e,r;return o(this,void 0,void 0,(function(){var o,s;return i(this,(function(i){switch(i.label){case 0:return this.options=n(n({},this.options),t),o=this,[4,this._getWebMapLayerItem()];case 1:return o.layer=i.sent(),s=null===(r=null===(e=this.response)||void 0===e?void 0:e.webmap)||void 0===r?void 0:r.extent_constrained,this.options.useExtentConstrained&&this._extent&&s&&this.options.webMap.setView({maxBounds:this._extent}),[2,this.layer]}}))}))},t.prototype.removeLayer=function(){var t=this.options.webMap.mapAdapter;if(this.getDependLayers().forEach((function(e){"layer"in e&&t.removeLayer(e.layer.layer)})),this._webmapBaselayersIds.length){for(var e=0,r=this._webmapBaselayersIds;e<r.length;e++){this.options.webMap.removeLayer(r[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},t.prototype.showLayer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return this.layer&&this.layer.properties?[2,this.layer.properties.property("visibility").set(!0)]:[2]}))}))},t.prototype.hideLayer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return this.layer&&this.layer.properties?[2,this.layer.properties.property("visibility").set(!1)]:[2]}))}))},t.prototype.setOpacity=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this.layer&&this.layer.properties?[2,this.layer.properties.property("opacity").set(t)]:[2]}))}))},t.prototype.getExtent=function(){return this.getBounds()},t.prototype.getBounds=function(){var t=this.response&&this.response.webmap;if(t)return Vt(t)},t.prototype.getDependLayers=function(){return this.layer&&this.layer.tree.getDescendants()||[]},t.prototype.getBookmarksResourceId=function(){var t=this.response&&this.response.webmap;if(t)return t.bookmark_resource.id},t.prototype.fetchBookmarks=function(){var t=this.getBookmarksResourceId(),e=this.options.connector;if(t)return e.getResourceOrFail(t).then((function(r){var n,o=null===(n=r.feature_layer)||void 0===n?void 0:n.fields.find((function(t){return t.label_field})),i=o&&o.keyname;return ie({connector:e,resourceId:t,geom:!1,fields:i?[i]:void 0}).then((function(r){for(var n=[],o=0,s=r;o<s.length;o++){var a=new Pe({item:s[o],resourceId:t,labelField:i,connector:e});n.push(a)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")},t.prototype.getIdentificationIds=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return t=[],(e=this._webmapLayersIds)?[3,2]:[4,this._getWebMapIds()];case 1:e=r.sent(),this._webmapLayersIds=e,r.label=2;case 2:return e&&e.length&&this.getDependLayers().sort((function(t,e){return e.id-t.id})).forEach((function(e){var r=e.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type){var o=e.properties.property("visibility");o.get()&&!o.isBlocked()&&t.push(n)}})),[2,t]}}))}))},t.prototype._getWebMapLayerItem=function(){return o(this,void 0,void 0,(function(){var t,e=this;return i(this,(function(r){switch(r.label){case 0:return this.resourceId?[4,this.getWebMapConfig(this.resourceId)]:[3,2];case 1:if((t=r.sent())&&t.root_item)return[2,new Promise((function(r){var n={};if(e.options.connector&&e.options.connector.options.auth){var o=e.options.connector.getAuthorizationHeaders();o&&(n.headers=o)}n.setViewDelay=e.options.setViewDelay,n.order=e.options.order,n.ratio=e.options.ratio,n.crossOrigin=e.options.crossOrigin,n.minZoom=e.options.minZoom,n.maxZoom=e.options.maxZoom,n.drawOrderEnabled=t.draw_order_enabled,n.popupOptions=e.options.popupOptions;var i=new e.NgwWebmapItem(e.options.webMap,t.root_item,n,e.options.connector);i.emitter.on("init",(function(){return r(i)}))}))];r.label=2;case 2:return[2]}}))}))},t.prototype.getWebMapConfig=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return[4,this.options.connector.getResource(t)];case 1:return(e=n.sent())&&(this.response=e,r=e[this.webmapClassName],this._setupBaselayers(e),r)?(this._extent=[r.extent_left,r.extent_bottom,r.extent_right,r.extent_top],this._updateItemsParams(r.root_item,this.options.webMap,e),[2,r]):[2]}}))}))},t.prototype._setupBaselayers=function(t){var e,r=this.options.webMap;if(null===(e=this.options.useBasemap)||void 0===e||e)if(t.basemap_webmap&&t.basemap_webmap.basemaps.length){var n=r.getActiveBaseLayer();this._lastActiveBaselayer=n?n.id:void 0,this._setBasemaps(t.basemap_webmap)}else this.options.defaultBasemap&&r.addBaseLayer("OSM",{id:"webmap-default-baselayer",name:"OpenStreetMap"})},t.prototype._setBasemaps=function(t){for(var e=this,r=this.options.webMap,n=!1,o=function(t){Ee({webMap:r,connector:i.options.connector,item:t,adapterOptions:{crossOrigin:i.options.crossOrigin}}).then((function(o){var i=!n&&t.enabled;return t.enabled&&(n=!0),r.addBaseLayer(o,{id:ze+t.resource_id,name:t.display_name,opacity:t.opacity,visibility:i}).then((function(t){t.id&&e._webmapBaselayersIds.push(t.id)}))}))},i=this,s=0,a=t.basemaps;s<a.length;s++){o(a[s])}},t.prototype._updateItemsParams=function(t,e,r){var o=this;if(t)if("group"===t.item_type||"root"===t.item_type)t.children&&(t.children=t.children.map((function(t){return o._updateItemsParams(t,e,r)}))),"root"===t.item_type&&(t.display_name=r.resource.display_name);else if("layer"===t.item_type){var i=W(this.options.connector.options.baseUrl+"/api/component/render/image"),s=t.layer_style_id;t.url=i,t.resourceId=s,t.updateWmsParams=function(t){return Fe(t,s)};var a=ce({options:{adapter:t.layer_adapter.toUpperCase(),resource:s},webMap:e,baseUrl:this.options.connector.options.baseUrl||""});t=n(n({},t),a)}return t},t.prototype._getWebMapIds=function(){return o(this,void 0,void 0,(function(){var t,e,r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:if(!(t=this.layer)||"root"!==t.item.item_type)return[3,2];for(e=t.tree.getDescendants(),r=[],n=function(t){var e=t.item;if("layer"===e.item_type){var n=o.options.connector.getResource(e.layer_style_id).then((function(t){if(t){var r=Number(t.resource.parent.id);return e.parentId=r,r}}));r.push(n)}},o=this,s=0,a=e;s<a.length;s++)n(a[s]);return[4,Promise.all(r)];case 1:return[2,i.sent().filter((function(t){return void 0!==t}))];case 2:return[2]}}))}))},t}();var Me={tms:"TILE"};function xe(t){return new Promise((function(e,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState&&200===n.status&&n.responseText)try{e(JSON.parse(n.responseText))}catch(t){r(t)}},n.open("GET",W(t),!0),n.send()}))}var ke="https://qms.nextgis.com";function Se(t,e,r){return void 0===e&&(e=ke),void 0===r&&(r={}),e||(e=ke),function(){function s(t,e){this.map=t;var o=n(n({},r),e);this.options=o,this.options.baselayer=!0,o.qms&&(this.qms=o.qms)}return s.prototype.addLayer=function(r){return o(this,void 0,void 0,(function(){var o,a,u,c,p,l,h,f;return i(this,(function(i){switch(i.label){case 0:if(this.qms||!r.qmsId)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),o=this,[4,xe(e+"/api/v1/geoservices/"+r.qmsId)];case 2:return o.qms=i.sent(),[3,4];case 3:return a=i.sent(),console.error(a),[3,4];case 4:return(u=this.qms)&&(p=t.mapAdapter.layerAdapters[c=Me[u.type||"tms"]])&&(y=s,v=p,["showLayer","hideLayer"].forEach((function(t){var e=Object.getOwnPropertyDescriptor(v.prototype,t);e&&Object.defineProperty(y.prototype,t,e)})),"TILE"===c)?(r=n(n({order:0,maxZoom:t.options.maxZoom,minZoom:t.options.minZoom},this.options),function(t){var e=("https:"===location.protocol?"https":"http")+"://",r=t.url.replace(/^(https?|ftp):\/\//,e);return t.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:t.name,attribution:t.copyright_text,maxZoom:t.z_max,minZoom:t.z_min}}(u)),u.origin_url&&(d=[],l=[u.origin_url.replace(/{switch:(.*?)}/,(function(t,e){return"string"==typeof e&&e.split(",").forEach((function(t){return d.push(t)})),"{s}"})),d],h=l[0],(f=l[1]).length&&(r.subdomains=f,r.url=h)),this.options=r,[2,new p(this.map,r).addLayer(r)]):[2]}var d,y,v}))}))},s}()}var Ne=function(){function t(t){this.options={url:"https://qms.nextgis.com"},this.options=n(n({},this.options),t),this.url=this.options.url}return t.prototype.getLayerAdapters=function(){var t=this;return Promise.resolve([{name:"QMS",createAdapter:function(e){return Promise.resolve(t._createAdapter(e))}}])},t.prototype._createAdapter=function(t){return Se(t,this.url)},t.utils={createQmsAdapter:Se},t}();var Te={},Re=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","webmap","tmsclient_layer"];function Be(t){var e=t.layerOptions,r=t.webMap,s=t.connector,a=t.item;return o(this,void 0,void 0,(function(){var t,o;return i(this,(function(i){switch(i.label){case 0:return[4,s.getResourceChildren(a.resource.id)];case 1:return t=i.sent(),(o=t&&t[0])?[2,je(n(n({},e),{resource:o.resource.id}),r,s)]:[2]}}))}))}function je(t,e,s){return o(this,void 0,void 0,(function(){var a,u,c,p,l,h,f,d,y,v,m,g,_,b;return i(this,(function(w){switch(w.label){case 0:return c=t.adapter,[4,Jt(t,s)];case 1:return(p=w.sent())?(l=t.resource)&&l.resource&&void 0!==l.resource.id?(u=l,[3,4]):[3,2]:[3,15];case 2:return[4,s.getResource(p)];case 3:u=w.sent(),w.label=4;case 4:return u?(h=u.resource.cls,f=n(n({},t),{resource:p}),d={layerOptions:f,webMap:e,connector:s,item:u},-1===Re.indexOf(h)?[3,12]:"webmap"!==h?[3,5]:(a=function(t){var e=t.layerOptions,n=t.webMap,s=t.connector;return o(this,void 0,void 0,(function(){var t;return i(this,(function(o){switch(o.label){case 0:return[4,Jt(e,s)];case 1:return t=o.sent(),[2,function(e){function o(r){return e.call(this,r,{url:"",webMap:n,resourceId:t,connector:s})||this}return r(o,e),o}(Ae)]}}))}))}(d),[3,11])):[3,14];case 5:if("vector_layer"!==h)return[3,6];if(y=u.vector_layer&&qe[u.vector_layer.geometry_type],(v=d.layerOptions.adapterOptions||{}).type=v.type||y,d.layerOptions.adapterOptions=v,t.adapterOptions=d,void 0!==c&&"GEOJSON"!==c){if("MVT"!==c)return[2,Be(d)];a=pe(d)}else a=ue(d);return[3,11];case 6:return"raster_layer"!==h?[3,7]:[2,Be(d)];case 7:return"basemap_layer"!==h?[3,8]:(a=function(t){var e=t.webMap,s=t.item;return o(this,void 0,void 0,(function(){var t,a,u,c,p;return i(this,(function(l){if(s.basemap_layer){if(a=s.basemap_layer.url,t=s.basemap_layer.qms)return u=JSON.parse(t),[2,Promise.resolve(Ne.utils.createQmsAdapter(e,void 0,{qms:u,baselayer:!0}))];if(a&&(c=e.mapAdapter.layerAdapters.TILE))return p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.addLayer=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,t.prototype.addLayer.call(this,n(n({},e),{url:a}))]}))}))},e}(c),[2,p]}return[2]}))}))}(d),[3,11]);case 8:return"GEOJSON"!==c?[3,10]:[4,s.getResource(u.resource.parent.id)];case 9:return(m=w.sent())&&(g=n(n({},t),{resource:u.resource.parent.id}),a=ue(n(n({},d),{item:m,layerOptions:g}))),[3,11];case 10:a=pe(d),w.label=11;case 11:return[3,13];case 12:if(!Te[h])throw"Resource class '".concat(h,"' not yet supported.");_=Te[h],b=void 0,(b=c&&"function"!=typeof b?_[c]:_)&&(a=b(d)),w.label=13;case 13:return[3,15];case 14:throw"Resource item is not found";case 15:return a?[2,a.then((function(t){if(t){var e=t;return u&&(e.prototype.item=u,e.prototype.resourceId=u.resource.id,e.prototype.connector=s),S(e,[Wt],{replace:!1}),e}}))]:[2]}}))}))}function Fe(t,e){var r=t.bbox,n=t.width,o=t.height,i=t.nd;return{resource:Array.isArray(e)?e.join(","):e,extent:r,size:n+","+o,timestamp:Date.now(),nd:i}}var Ge,qe={POINT:"point",LINESTRING:"line",POLYGON:"polygon",MULTIPOINT:"point",MULTILINESTRING:"line",MULTIPOLYGON:"polygon",POINTZ:"point",LINESTRINGZ:"line",POLYGONZ:"polygon",MULTIPOINTZ:"point",MULTILINESTRINGZ:"line",MULTIPOLYGONZ:"polygon"};var De=function(){function t(t){if(this.options=t,this.options.connector)this.url=this.options.connector.options.baseUrl||"",this.connector=this.options.connector;else{if(!this.options.baseUrl)throw new Error("url is not defined");this.url=this.options.baseUrl,this.connector=new Dt({baseUrl:this.url,auth:this.options.auth})}}return t.addClassAdapters=function(t,e){Te[t]=e},t.prototype.onLoadSync=function(t){return o(this,void 0,void 0,(function(){var e,r,o;return i(this,(function(i){switch(i.label){case 0:if(!this.options.resourceId||!this.url)return[3,4];if(!(e=[this.options.resourceId]).length)return[3,4];r=0,o=e,i.label=1;case 1:return r<o.length?[4,t.addLayer(Ae,n({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},{resourceId:o[r],connector:this.connector,webMap:t}))]:[3,4];case 2:return[2,i.sent()];case 3:return r++,[3,1];case 4:return[2]}}))}))},t.prototype.getLayerAdapters=function(){return Promise.resolve([this._getLayerAdapter()])},t.prototype._getLayerAdapter=function(){var t=this;return{name:"WEBMAP",createAdapter:function(e){return Promise.resolve(t._createAdapter(e))}}},t.prototype._createAdapter=function(t){var e;return e={webMap:t,connector:this.connector,baseUrl:this.url},function(t){function o(r,o){return o=n(n({},e),o),t.call(this,r,o)||this}return r(o,t),o}(Ae)},t}(),Ve=function(){function t(t){var e=t.feature;this.id=e.id,this.geom=e.geom,this.label=e.label,this.parent=e.parent,this.fields=e.fields,this.layerId=e.layerId,this.connector=t.connector}return t.prototype.identify=function(t){var e=this;return void 0===t&&(t={}),this._item?k.resolve(this._item):Ue(n({connector:this.connector,featureId:this.id,resourceId:this.layerId,fields:null,extensions:["attachment","description"]},t)).then((function(t){return e._item=t,e.geom=t.geom,e.extensions=t.extensions,t}))},t.prototype.resource=function(){var t=this;return this._resource?k.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId).then((function(e){return t._resource=e,t._resource.feature_layer}))},t.prototype.getBounds=function(){return this._extent?k.resolve(this._extent):(t={connector:this.connector,featureId:this.id,resourceId:this.layerId}).connector.get("feature_layer.feature.item_extent",{cache:void 0===(e=t.cache)||e},{id:t.resourceId,fid:t.featureId}).then((function(t){if(t){var e=t.extent;return[e.minLon,e.minLat,e.maxLon,e.maxLat]}}));var t,e},t.prototype.geojson=function(){var t=this;return this._geojson?k.resolve(this._geojson):this.identify().then((function(e){return e.toGeojson().then((function(e){return t._geojson=e,e}))}))},t}(),ze="webmap-baselayer";function Ue(t){var e=n({},Qt);Xt(e,t);var r=n({id:t.resourceId,fid:t.featureId},e);return t.connector.get("feature_layer.feature.item",{cache:t.cache||!0},r).then((function(e){return n(n({},e),{toGeojson:function(){return e.geom?k.resolve(Kt(e)):Ue(n(n({},t),{geom:!0,fields:null,extensions:null})).then((function(t){var r=t.geom;return Kt(n(n({},e),{geom:r}))}))}})}))}function Ze(t){return Ue(t).then((function(t){return Kt(t)}))}function We(t,e){void 0===e&&(e=!1);var r=[],n=[];for(var o in t){var i=Number(o);isNaN(i)||r.push(i)}var s=t.resources;s&&r.sort((function(t,e){return s.indexOf(t)-s.indexOf(e)}));for(var a=0;a<r.length;a++){var u=t[o=r[a]];if("features"in u){var c=$e(u.features,Number(o),e);if(c.length&&(n.push.apply(n,c),!e))break}}return n}function $e(t,e,r){for(var n=[],o=0,i=t;o<i.length;o++){var s=i[o];if(n.push({featureId:s.id,resourceId:e,feature:s}),!r)break}return n}function He(t,e){B(t);var r=t.lngLat,o=e.geom,i=e.signal,s=e.cache,a=null!=o?o:function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n=6);for(var o=r/6371*q,i=o/Math.cos(e*G),s=[],a=0;a<n+1;a++){var u=Math.PI*(a/(n/2)),c=t+i*Math.cos(u),p=e+o*Math.sin(u);s.push([c,p])}return s}(r[0],r[1],e.radius);return function(t){var e=t.geom,r=t.signal,n=t.cache,o=[];if(Array.isArray(e))o=e;else{var i="Feature"===e.type?e.geometry:"Polygon"===e.type&&e;i&&(o=i.coordinates[0])}if(o){for(var s=[],a=0,u=o;a<u.length;a++){var c=u[a],p=D(c[0],c[1]);s.push(p[0]+" "+p[1])}var l="POLYGON((".concat(s.join(", "),"))");return t.connector.post("feature_layer.identify",{data:{geom:l,srs:3857,layers:t.layers},signal:r,cache:n})}throw new Error("Not valid geometry format to make intersection")}(n(n({},e),{geom:a,signal:i,cache:s}))}function Je(t,e){var r;return o(this,void 0,void 0,(function(){var n,o,s,a,u,c,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.get("pyramid.settings",null,{component:"pyramid"})];case 1:if(!((n=i.sent())&&n.company_logo&&n.company_logo.enabled))return[3,6];(o=document.createElement("a")).style.position="absolute",o.style.bottom="0",o.style.right="0",o.style.padding=null!==(r=null==e?void 0:e.padding)&&void 0!==r?r:"10px",o.className="ngw-map-logo",e&&e.cssClass&&(o.className+=" "+e.cssClass),(s=new Image).style.maxHeight="100px",s.style.maxWidth="100px",s.src="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,t.get("pyramid.company_logo",{responseType:"blob"})];case 3:return a=i.sent(),u=window.URL||window.webkitURL,c=u.createObjectURL(a),s.src=c,[3,5];case 4:return p=i.sent(),console.warn(p),[3,5];case 5: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),[2,o];case 6:return[2]}}))}))}var Qe={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'};function Ke(t){void 0===t&&(t={});var e=t.color||"blue",r=t.strokeColor||"white",n=t.size||12,o=n/2,i="number"==typeof t.stroke?t.stroke:.8,s=n/12,a=Qe[t.shape||"circle"]||"circle",u=function(t,e,r,n){void 0===r&&(r=0);var o=r/2,i='<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="'.concat(t,'"\n height="').concat(e,'"\n viewBox="-').concat(o," -").concat(o," ").concat(t+r," ").concat(e+r,'"\n >').concat(n,"</svg>");return(new DOMParser).parseFromString(i,"image/svg+xml").documentElement}(n,n,i*s,"string"==typeof a?a:a(t)),c=u.firstChild,p="scale(".concat(s,")");return c.setAttribute("fill",e),i&&(c.setAttribute("stroke",r),c.setAttribute("stroke-width",String(i))),c.setAttribute("transform",p),{type:"icon",iconSize:[n,n],iconAnchor:[o,o],html:(new XMLSerializer).serializeToString(u),svg:u}}function Xe(t,e,r,o){if("number"==typeof e||"string"==typeof e)e=Number(e),t.push(n(n({},r),{resource:e}));else if(Array.isArray(e)){var i=e[0],s=e[1];t.push(n(n(n({},r),{resource:i,id:s}),o))}else"object"==typeof e&&t.push(n(n(n({},r),e),o))}var Ye={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};var tr=function(t){function e(e){var r=t.call(this,function(t){var e=[new Ne];return t.starterKits&&t.starterKits.forEach((function(t){e.push(t)})),t.connector?t.connector&&(t.baseUrl=t.connector.options.baseUrl):t.connector=new Dt({baseUrl:t.baseUrl||"",auth:t.auth}),(t=R(Ye,t)).center||t.bounds||(t.bounds=[-179,-90,180,90]),t.connector&&e.push(new De({connector:t.connector,auth:t.auth})),n(n({},t),{starterKits:e,create:!1})}(e))||this;return r.emitter=new p.exports.EventEmitter,r._ngwLayers={},r._promises={select:[],identify:[]},e.connector&&(r.connector=e.connector),r._createWebMap().then((function(){var t=r.getContainer();t&&t.classList.add("ngw-map-container"),r.options.whitlabel&&r._whiteLabel()})),r}return r(e,t),e.prototype.addControl=function(e,r,n){return o(this,void 0,void 0,(function(){return i(this,(function(o){switch(o.label){case 0:return[4,this.onLoad("controls:create")];case 1:return o.sent(),[2,t.prototype.addControl.call(this,e,r,n)]}}))}))},e.prototype.addNgwLayer=function(t){return o(this,void 0,void 0,(function(){var e,r,o,s,a,u,c,p,l;return i(this,(function(i){switch(i.label){case 0:return[4,this.onMapLoad()];case 1:if(i.sent(),r=t.resourceId,((e=t.keyname)||void 0!==r)&&console.warn("DEPRECATED WARN: ".concat("set `resource` options instead of `keyname` or `resourceId`")),o=t.resource,!e&&!r&&!o)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(!N(this.options.baseUrl))return[3,5];i.label=2;case 2:return i.trys.push([2,4,,5]),N(this.options.setViewDelay)&&(t.adapterOptions=t.adapterOptions||{},N(t.adapterOptions.setViewDelay)||(t.adapterOptions.setViewDelay=this.options.setViewDelay)),s=function(t,e,r){var n=r.getAuthorizationHeaders();return n&&(t.headers=n),je(t,e,r)}(t,this,this.connector),a=n(n({visibility:!0},t),t.adapterOptions),[4,this.addLayer(s,a)];case 3:return u=i.sent(),c=u&&this.getLayerId(u),u&&c&&(this._ngwLayers[c]={layer:u,resourceId:u.resourceId},u.options.name=u.options.name||u.item&&u.item.resource.display_name,u.options.baselayer&&this.getActiveBaseLayer()),[2,u];case 4:return p=i.sent(),l=Z(o)&&"id"in o?o.id:e||r||o,console.error("Can't add NGW layer ".concat(l,"."),p),[3,5];case 5:return[2]}}))}))},e.prototype.fit=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;e?(this.setCenter(e),r&&this.setZoom(r)):n&&this.fitBounds(n)},e.prototype.fetchNgwLayerItem=function(t){return Ue(n({connector:this.connector},t))},e.prototype.fetchNgwLayerItems=function(t){return ie(n({connector:this.connector},t))},e.prototype.fetchNgwLayerFeature=function(t){return Ze(n({connector:this.connector},t))},e.prototype.fetchNgwLayerFeatures=function(t){return ae(n({connector:this.connector},t))},e.prototype.fetchIdentifyItem=function(t,e){var r,o,i,s=(o=(r={identify:t,connector:this.connector,requestOptions:e}).connector,(i=We(r.identify))&&i.length?Ue(n(n({connector:o},r.requestOptions),i[0])):k.resolve(void 0));return this._addPromise("identify",s),s},e.prototype.fetchIdentifyGeoJson=function(t,e){void 0===e&&(e=!1);var r=function(t){var e=t.connector,r=t.identify,o=t.requestOptions;for(var i in r){var s=Number(i);if(!isNaN(s)){var a=r[i];if("features"in a){var u=a.features.find((function(t){return t.geom}));if(u&&u.geom){var c=u.geom;return k.resolve(Kt(n(n({},u),{geom:c})))}}}}var p=We(r);return p&&p.length?Ze(n(n(n({},o),{connector:e}),p[0])):k.resolve(void 0)}({identify:t,connector:this.connector,multiple:e});return r&&"then"in r?(this._addPromise("identify",r),r):k.resolve(r)},e.prototype.getIdentifyGeoJson=function(t,e){return void 0===e&&(e=!1),this.fetchIdentifyGeoJson(t,e)},e.prototype.getNgwLayers=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.onLoad()];case 1:return t.sent(),[2,this._ngwLayers]}}))}))},e.prototype.getNgwLayerByResourceId=function(t){return o(this,void 0,void 0,(function(){var e,r,n,o,s,a,u;return i(this,(function(i){switch(i.label){case 0:for(r in e=[],this._ngwLayers)e.push(r);n=0,i.label=1;case 1:return n<e.length?(o=this._ngwLayers[e[n]]).resourceId!==t?[3,2]:[2,o&&o.layer]:[3,6];case 2:return o.layer.getIdentificationIds?[4,o.layer.getIdentificationIds()]:[3,4];case 3:if((s=i.sent())&&s.some((function(e){return e===t})))return[2,o.layer];i.label=4;case 4:if(o.layer.getDependLayers&&(a=o.layer.getDependLayers(),u=a.find((function(e){return e.item&&e.item.parentId===t}))))return[2,u.layer];i.label=5;case 5:return n++,[3,1];case 6:return[2]}}))}))},e.prototype.fitLayer=function(e,r){return o(this,void 0,void 0,(function(){var n,o,s,a,u=this;return i(this,(function(i){switch(i.label){case 0:return n="string"==typeof e||"number"==typeof e?String(n):e.id,(o=n&&this._ngwLayers[n])?o.layer.getBounds?[4,o.layer.getBounds()]:[3,2]:[3,7];case 1:return(s=i.sent())&&this.fitBounds(s,r),[3,6];case 2:return a=void 0,o.layer.item?(a=o.layer.item,[3,5]):[3,3];case 3:return[4,this.connector.getResource(o.resourceId)];case 4:a=i.sent(),i.label=5;case 5:a&&Zt(a,this.connector).then((function(t){t&&u.fitBounds(t,r)})),i.label=6;case 6:return[3,8];case 7:t.prototype.fitLayer.call(this,e,r),i.label=8;case 8:return[2]}}))}))},e.prototype.zoomToLayer=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.fitLayer(t)]}))}))},e.prototype.onLoad=function(e){return void 0===e&&(e="ngw-map:create"),t.prototype.onLoad.call(this,e)},e.prototype.removeLayer=function(e){var r=this.getLayer(e);if(r){var n=this.getLayerId(r);n&&delete this._ngwLayers[n],t.prototype.removeLayer.call(this,r)}},e.prototype.enableSelection=function(){var t=this;this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=function(e){t._getSelectListenersCount()&&t.selectFromNgwRaster(e)},this.$$selectFromNgwVector=function(e){t._getSelectListenersCount()&&t._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))},e.prototype.disableSelection=function(){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)},e.prototype.getNgwLayerItem=function(t){return this.fetchNgwLayerItem(t)},e.prototype.getNgwLayerItems=function(t){return this.fetchNgwLayerItems(t)},e.prototype.getNgwLayerFeature=function(t){return this.fetchNgwLayerFeature(t)},e.prototype.getNgwLayerFeatures=function(t){return this.fetchNgwLayerFeatures(t)},e.prototype.cancelPromise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.cancelPromises.apply(this,t)},e.prototype.cancelPromises=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];e.length||(e=Object.keys(this._promises)),e.forEach((function(e){var r=t._promises[e];r&&(r.forEach((function(t){return t.cancel()})),t._promises[e]=[])}))},e.prototype.selectFromNgwRaster=function(t){return o(this,void 0,void 0,(function(){var e,r,o,s,a,u,c,p,l,h,f,d,y,v,m,g,_=this;return i(this,(function(i){switch(i.label){case 0:for(this._emitStatusEvent("ngw:preselect"),e=[],(r=Object.values(this._ngwLayers)).sort((function(t,e){return t.layer.order&&e.layer.order?e.layer.order-t.layer.order:1})),o=0,s=r;o<s.length;o++)(u="function"==typeof(a=s[o].layer).getIdentificationIds&&a.getIdentificationIds)&&a.options.selectable&&this.isLayerVisible(a)&&e.push(u.call(a));return[4,Promise.all(e)];case 1:for(c=i.sent(),p=[],l=0,h=c;l<h.length;l++)(f=h[l])&&p.push.apply(p,f);return p.length?(d=this.options.pixelRadius||10,y=this.getCenter(),v=void 0!==(v=this.getZoom())?v:20,y&&v?(m=function(t,e,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*t[1]/Math.PI))/Math.pow(2,e+8))*5e-4}(y,v,d),g=He(t,{layers:p,connector:this.connector,radius:m}).then((function(e){var r=n(n({},e),{resources:p,sourceType:"raster",event:t}),o=_._prepareToIdentify(r);return _._emitStatusEvent("ngw:select",r),o})),this._addPromise("select",g),[2,g]):(this._emitStatusEvent("ngw:select",null),[2])):(this._emitStatusEvent("ngw:select",null),[2])}}))}))},e.prototype._addPromise=function(t,e){var r=this._promises[t];if(r&&-1===r.indexOf(e)){var n=function(){var t=r.indexOf(e);-1!==t&&r.splice(t,1)};e.then(n),e.catch(n),r.push(e)}},e.prototype._isFitFromResource=function(){var t=this._initMapState;return!t.zoom||!t.center},e.prototype._createWebMap=function(){return o(this,void 0,void 0,(function(){var t,e,r,n,o,s,a,u,c,p;return i(this,(function(i){switch(i.label){case 0:return[4,this.create()];case 1:if(i.sent(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer(),t=[],e=this._isFitFromResource(),this.options.webmapId&&Xe(t,this.options.webmapId,{fit:e}),this.options.resources&&Array.isArray(this.options.resources))for(r=0,n=this.options.resources;r<n.length;r++)o=n[r],s={},e||(s.fit=!1),Xe(t,o,{},s);a=0,u=t,i.label=2;case 2:if(!(a<u.length))return[3,7];c=u[a],i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.addNgwLayer(c)];case 4:return i.sent(),[3,6];case 5:return p=i.sent(),console.warn(p),[3,6];case 6:return a++,[3,2];case 7:return this._emitStatusEvent("ngw-map:create",this),this.enableSelection(),[2]}}))}))},e.prototype._addOsmBaseLayer=function(){this.addBaseLayer("OSM")},e.prototype._addQmsBaseLayer=function(){var t,e;Array.isArray(this.options.qmsId)?(t=this.options.qmsId[0],e=this.options.qmsId[1]):t=Number(this.options.qmsId);var r={qmsId:t};e&&(r.id=e),this.addBaseLayer("QMS",r)},e.prototype._selectFromNgwVector=function(t){var e,r=t.layer;if(r.options.selectable&&this.isLayerVisible(r)){var o=r.item&&r.item.resource.id,i=t.feature;if(void 0!==o&&i){var s=i.id;if(s){var a={id:Number(s),fields:i.properties||{},label:"#".concat(o),layerId:Number(o),parent:"",geom:i.geometry},u=((e={featureCount:1})[o]={featureCount:1,features:[a]},e);return this._emitStatusEvent("ngw:select",this._prepareToIdentify(n(n({},u),{resources:[o],sourceType:"vector"}))),u}}}},e.prototype._prepareToIdentify=function(t){var e=this;return n(n({},t),{getIdentifyItems:function(){return We(t,!0).map((function(t){return new Ve({feature:t.feature,connector:e.connector})}))}})},e.prototype._getSelectListenersCount=function(){return this.emitter.listenerCount("ngw:select")},e.prototype._whiteLabel=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return(t=this.getContainer())?[4,Je(this.connector,this.options.companyLogoOptions)]:[3,2];case 1:(e=r.sent())&&t.appendChild(e),r.label=2;case 2:return[2]}}))}))},e.getIcon=Ke,e}(Ot);return t.NgwMap=tr,t.WebMap=Ot,t.WebMapControls=bt,t.WebMapLayers=gt,t.WebMapMain=mt,t.createNgwMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new tr(t).onLoad()]}))}))},t.createToggleControl=_t,t.createWebMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Ot(t).onLoad()]}))}))},t.detectGeometryType=st,t.findMostFrequentGeomType=it,t.getWebMap=Lt,t.updateGeoJsonAdapterOptions=ct,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
1
+ var NgwMap=function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(a){i=[6,a],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function u(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}var c,p={exports:{}},l="object"==typeof Reflect?Reflect:null,h=l&&"function"==typeof l.apply?l.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};c=l&&"function"==typeof l.ownKeys?l.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var f=Number.isNaN||function(t){return t!=t};function d(){d.init.call(this)}p.exports=d,p.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}C(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&C(t,"error",e,r)}(t,o,{once:!0})}))},d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var y=10;function v(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function m(t){return void 0===t._maxListeners?d.defaultMaxListeners:t._maxListeners}function g(t,e,r,n){var o,i,s,a;if(v(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=m(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function _(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=_.bind(n);return o.listener=r,n.wrapFn=o,o}function w(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):O(o,o.length)}function L(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function O(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function C(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return y},set:function(t){if("number"!=typeof t||t<0||f(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");y=t}}),d.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||f(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},d.prototype.getMaxListeners=function(){return m(this)},d.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)h(a,this,e);else{var u=a.length,c=O(a,u);for(r=0;r<u;++r)h(c[r],this,e)}return!0},d.prototype.on=d.prototype.addListener=function(t,e){return g(this,t,e,!1)},d.prototype.prependListener=function(t,e){return g(this,t,e,!0)},d.prototype.once=function(t,e){return v(e),this.on(t,b(this,t,e)),this},d.prototype.prependOnceListener=function(t,e){return v(e),this.prependListener(t,b(this,t,e)),this},d.prototype.off=d.prototype.removeListener=function(t,e){var r,n,o,i,s;if(v(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},d.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},d.prototype.listeners=function(t){return w(this,t,!0)},d.prototype.rawListeners=function(t){return w(this,t,!1)},d.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):L.call(t,e)},d.prototype.listenerCount=L,d.prototype.eventNames=function(){return this._eventsCount>0?c(this._events):[]};var I=function(t){function e(){var r=t.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),E=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return t=t||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=e(t);if(i)return i;var a=r(s.apply(this,n),t);return a},i}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),P=function(t){function e(){var r=t.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),A=function(t,e,r,n){try{t(r(n))}catch(o){e(o)}},M=0,x=function(){function t(e,r){var n=this;this.id=M++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new I)}}));var o=[this._cancelPromise,new Promise((function(r,o){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,o(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&o.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new P)}}),r)}))),this._promise=Promise.race(o)}return t.createControl=function(t){return new E(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,o=e;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,o=new t((function(t,o){if(n._promise){var i=function(e){r?A(t,o,r,e):o(e)};n._promise.then((function(r){n._isCanceled?i(r):e?A(t,o,e,r):t(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new I),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new I:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(n){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=I,t.TimeoutError=P,t.PromiseControl=E,t}();Object.setPrototypeOf(x.prototype,Promise.prototype);var k=x;function S(t,e,r){void 0===r&&(r={});var n=function(t,e){for(void 0===e&&(e=[]);null!==t;t=Object.getPrototypeOf(t))for(var r=Object.getOwnPropertyNames(t),n=0;n<r.length;n++)-1==e.indexOf(r[n])&&e.push(r[n]);return e}(t.prototype),o=void 0===r.replace||r.replace;e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(r){var i=-1!==n.indexOf(r);if(!o&&!i||o){var s=Object.getOwnPropertyDescriptor(e.prototype,r);s&&Object.defineProperty(t.prototype,r,s)}}))}))}function N(t){return null!=t}function T(t){return"string"==typeof t?!!t:N(t)}function R(t,e,r){void 0===r&&(r=!1);var n=t,o=e,i=Array.isArray(o),s=i&&[]||{};return i&&Array.isArray(o)?r?(s=s.concat(n=n||[]),o.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=R(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(o).forEach((function(t){s[t]="object"==typeof o[t]&&o[t]&&"object"==typeof n[t]&&"object"==typeof o[t]?R(n[t],o[t],r):o[t]}))),s}function B(t){!t.lngLat&&t.latLng&&(t.lngLat=[t.latLng.lng,t.latLng.lat]);return t}function j(t){return{type:"Polygon",coordinates:[F(t)]}}function F(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}var G=Math.PI/180,q=180/Math.PI;function D(t,e){e=e>85.06?85.06:e<-85.06?-85.06:e;var r=20037508.34*t/180,n=Math.log(Math.tan((90+e)*Math.PI/360))/(Math.PI/180);return[r,n=20037508.34*n/180]}function V(t,e,r,n){if(t instanceof Array)return e instanceof Array&&e.sort().join("")===t.sort().join("");if(t instanceof Date)return e instanceof Date&&""+t==""+e;if(t instanceof Function){if(!(e instanceof Function))return!1}else if(t instanceof Object)return e instanceof Object&&(t===r?e===n:z(t,e));return t===e}function z(t,e){var r=Object.keys(t).sort(),n=Object.keys(e).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(var o=0;o<r.length;o++){if(!V(t[r[o]],e[n[o]],t,e))return!1}return!0}function U(t){var e={};return Object.keys(t).forEach((function(r){t[r]instanceof Array||t[r]!==Object(t[r])?void 0!==t[r]&&(e[r]=t[r]):e[r]=U(t[r])})),e}function Z(t){return"[object Object]"===Object.prototype.toString.call(t)}function W(t){return t.replace(/([^:]\/)\/+/g,"$1")}function $(t){return"function"==typeof t}var H={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){var r=e[0],n=e.slice(1),o=r;Array.isArray(r)&&(o=J(t,r));for(var i=n.splice(-1,n.length%2)[0],s=0;s<n.length-1;s+=2){if(n[s]===o)return n[s+1]}return i}};function J(t,e){var r=e[0],n=e.slice(1),o=H[r];if(o)return o(t,n)}function Q(t){return function(e){return J(e,t)}}var K=["iconSize","iconAnchor"];function X(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,o="^".concat((n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")),"$").replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(t)}var Y={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return X(t,e)},ilike:function(t,e){return X(t,e,!0)}};function tt(t){return 3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]}function et(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(tt(e)){var r=e[0],n=e[1],o=e[2],i=Y[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,o)}));return i(s,a)}return i(t[r],o)}return!1}return et(t,e)},o=e.filter((function(t){return Array.isArray(t)}));return"any"===r?o.some(n):o.every(n)}function rt(t){for(var e={},r=[],o=0,i=t;o<i.length;o++){var s=i[o];s&&(Array.isArray(s)?r.push(s):e=s)}return function(t){var o=r.find((function(e){return function(t,e){var r=n({},t.properties);return!!r&&(r.$id=t.id,et(r,e))}(t,e[0])}));return o?n(n({},e),o[1]):e}}function nt(t,e,r){var o=function(t){var e=!1,r={};for(var o in t)if(-1===K.indexOf(o)){var i=o,s=t[i];Array.isArray(s)&&(e=!0,r[i]=Q(s))}if(e)return function(e){var o={};for(var i in r)o[i]=r[i](e);return n(n({},t),o)}}(t);if(o){var i=function(t){return ot(o(t),e,r)};return i.paint=t,i}var s=n({},e);return(s=n(n({},s),t)).fill=void 0===s.fill||s.fill,s.stroke=void 0!==s.stroke?s.stroke:!s.fill||!(!s.strokeColor&&!s.strokeOpacity),s}function ot(t,e,r){if(!t)throw new Error("paint is empty");var o=n({},e);if($(t)){var i=function(n){var o=ot(t(n),e,r);return o.type=t.type,o};return i.type=t.type,i}if(function(t){return!!Array.isArray(t)}(t))return function(n){return ot(rt(t)(n),e,r)};if("get-paint"===t.type){var s=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(t,r);s&&(o=ot(s,e,r))}else{if("icon"===t.type)return t;o=nt(t,e,r)}return $(o)||("color"in o&&(o.strokeColor||(o.strokeColor=o.color),o.fillColor||(o.fillColor=o.color)),"opacity"in o&&(void 0===o.strokeOpacity&&(o.strokeOpacity=o.opacity),void 0===o.fillOpacity&&(o.fillOpacity=o.opacity))),o}function it(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function st(t){var e;if("FeatureCollection"===t.type)e=it(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=it(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var at={polygon:"path",line:"path",point:"circle"},ut={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function ct(t){if(t.data){var e=ut[st(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":at[e]),t.type=t.type||e}return t}var pt=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},lt=function(){function t(){this.keyCodeAlias=new pt,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),ht=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),ft=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return r(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(ht),dt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return r(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(ht);var yt=0,vt={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},mt=function(){function t(e){this.options=vt,this.emitter=new p.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[ft,dt],this.id=yt++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=R(vt||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},t.prototype.getContainer=function(){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){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:j(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){if(Array.isArray(t)){var r=t;this.mapAdapter.setView&&r&&N(e)?this.mapAdapter.setView(r,e):(r&&this.mapAdapter.setCenter(r),N(e)&&this.mapAdapter.setZoom(e))}else{this.mapAdapter.setView&&this.mapAdapter.setView(t)}},t.prototype.fitBounds=function(t,e){return t.every((function(t){return N(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new k((function(e,r,n){var o=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var i=function(){t.setCursor(o),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){i(),B(t),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(i)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),N(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),N(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),N(t.maxzoom)&&N(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend","mousemove","mouseout","mouseover"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new lt,t}(),gt=function(t){function e(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return r(e,t),e.prototype.fitLayer=function(t,e){return o(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},e.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},e.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},e.prototype.getBaseLayersIds=function(){return this._baselayers},e.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},e.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},e.prototype.getLayers=function(){return Object.keys(this._layers)},e.prototype.allLayers=function(){return this._layers},e.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},e.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},e.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},e.prototype.addBaseLayer=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,n(n({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},e.prototype.addLayer=function(t,e,r){var s,a;return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var o,u,c,p,l,h,f,d,y,v,m,g;return i(this,(function(i){switch(i.label){case 0:return o=this._layersIdCounter++,u=N(r)?r:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(c=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(c=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:c=i.sent(),i.label=4;case 4:return this._updateGeoJsonOptions(p=e),e=n({id:String(o),order:u},e),l=null===(s=e.visibility)||void 0===s||s,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(h=this.options.onBeforeAddLayer({options:e,adapter:c}))&&(h.options&&(e=h.options),h.adapter&&(c=h.adapter)),void 0===c?[3,12]:((f=new c(this.mapAdapter.map,e)).options=n(n({},e),f.options),f.options.baselayer&&(e.baselayer=!0,e.order=0,f.options.order=0),d=void 0,f.options.id&&(d=String(f.options.id),this._layers[d]=f),this._emitLayerEvent("layer:preadd",d||"",f),[4,this.onMapLoad()]);case 5:return i.sent(),f.map=this.mapAdapter.map,[4,f.addLayer(f.options)];case 6:if(y=i.sent(),f.layer=y,f.id=f.options.id||String(o),f.options.id=f.id,e.baselayer&&(f.options.order=0),f.order=null!==(a=f.options.order)&&void 0!==a?a:u,d&&delete this._layers[d],d=String(f.id),this._layers[d])throw Error("layer with id '".concat(d,"' already exist"));return d?(this._layers[d]=f,p.filter&&this.filterLayer(f,p.filter),e.baselayer&&this._baselayers.push(d),l?[4,this.showLayer(d)]:[3,8]):[3,8];case 7:i.sent(),i.label=8;case 8:return void 0!==(v=e.opacity)&&v<=1&&this.setLayerOpacity(f,v),m=y&&(f.getBounds||f.getExtent),e.fit&&m?[4,m.call(f)]:[3,11];case 9:return(g=i.sent())?[4,this.fitBounds(g)]:[3,11];case 10:i.sent(),i.label=11;case 11:return e.onAdded&&e.onAdded(f),this._emitLayerEvent("layer:add",d,f),[2,f];case 12:return[2,Promise.reject("No adapter")]}}))}))},e.prototype.addLayerFromAsyncAdapter=function(t,e,r){return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},e.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},e.prototype.reserveOrder=function(){return this._layersOrderCounter++},e.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},e.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},e.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=ct(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},e.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},e.prototype.addTileLayer=function(t,e){return void 0===e&&(e={}),this.addLayer("TILE",n(n({},e),{url:t}))},e.prototype.addImageLayer=function(t,e){var r;return"string"==typeof t?r=t:(r=t.url,e=t),this.addLayer("IMAGE",n(n({},e),{url:r}))},e.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},e.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},e.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var s=this.getLayer(t),a=void 0!==e?e:!(s&&s.options.visibility),u=void 0!==r.silent&&r.silent;return s&&s.options.visibility!==a?this.onMapLoad().then((function(){return t=s,o(n,void 0,void 0,(function(){var e,r,n,o,s,c,p,l=this;return i(this,(function(i){switch(i.label){case 0:if(e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!a||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];s=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),c=0,p=s,i.label=1;case 1:return c<p.length?[4,this.hideLayer(p[c])]:[3,4];case 2:i.sent(),i.label=3;case 3:return c++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return i.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:i.sent(),i.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return i.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:i.sent(),i.label=13;case 13:return t.options.visibility=a,u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},e.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},e.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},e.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},e.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},e.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},e.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},e.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;o.propertiesFilter?o.propertiesFilter(e,r):o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||et(t.feature.properties,e)}))}},e.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},e.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},e.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},e.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},e.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},e.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},e.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},e.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},e.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},e.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},e.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},e.prototype._emitLayerEvent=function(t,e,r){var n=String(t);if(N(e)&&n.startsWith("layer:")){var o=n.replace("layer:","layer-"+e+":");this.emitter.emit(o,r)}this.emitter.emit(t,r)},e.prototype._onLayerClick=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._onLayerSelect=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,o=t.onMouseOut,i=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;o&&o(t),N(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;i&&i(t),N(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var a=r||n;t.onSelect=function(t){return a&&a(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=ot(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=ot(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},e}(mt);function _t(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},h=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},f=t({html:r,onClick:h});return f.onClick=h,f.changeStatus=l,f}var bt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return r(e,t),e.prototype.addControl=function(t,e,r){return o(this,void 0,void 0,(function(){var n,s=this;return i(this,(function(a){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){s._setControlQueue(e,(function(){return o(s,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,_t(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(gt),wt={};function Lt(t){return wt[t]}var Ot=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),wt[r.id]=r,r}return r(e,t),e.get=function(t){return Lt(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return o(this,void 0,void 0,(function(){var o,s,a,c,p,l,h,f,d,y;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,18,19,24]),o=u(this._starterKits),i.label=1;case 1:return[4,o.next()];case 2:return(s=i.sent()).done?[3,17]:(a=s.value).getLayerAdapters?[4,a.getLayerAdapters.call(a)]:[3,16];case 3:if(!(c=i.sent()))return[3,16];i.label=4;case 4:i.trys.push([4,10,11,16]),r=void 0,p=u(c),i.label=5;case 5:return[4,p.next()];case 6:return(l=i.sent()).done?[3,9]:[4,(h=l.value).createAdapter(this)];case 7:(f=i.sent())&&(this.mapAdapter.layerAdapters[h.name]=f),i.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return d=i.sent(),r={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l&&!l.done&&(n=p.return)?[4,n.call(p)]:[3,13];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=i.sent(),t={error:y},[3,24];case 19:return i.trys.push([19,,22,23]),s&&!s.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:i.sent(),i.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return o(this,void 0,void 0,(function(){var r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,14]),r=u(this._starterKits),i.label=1;case 1:return[4,r.next()];case 2:if((n=i.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return i.sent(),[3,6];case 5:return s=i.sent(),console.error(s),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return a=i.sent(),t={error:a},[3,14];case 9:return i.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(bt);var Ct,It=function(){function t(e){var r;void 0===e&&(e={}),this.cache=[];var n=null!==(r=e.namespace)&&void 0!==r?r:"default";return t.instance[n]?t.instance[n]:(t.instance[n]=this,this)}return t.prototype.clean=function(){this.cache.length=0},t.prototype.all=function(){return this.cache},t.prototype.addFull=function(t,e,r){return this.add(t,e,r,!0)},t.prototype.add=function(t,e,r,n){var o=this,i=this._find(t,r);if(i)return i.value;var s=void 0;s=e instanceof Function?e():e;var a=r&&JSON.parse(JSON.stringify(U(r))),u={key:t,value:s,props:a,options:a};return n&&!T(s)?s:(this.cache.push(u),s instanceof Promise?(s.catch((function(e){throw o.delete(t,r),e})),n&&s.then((function(e){return T(e)||o.delete(t,r),e})),s):s)},t.prototype.match=function(t,e){var r=this._find(t,e);if(r)return r.value},t.prototype.matchAll=function(t,e){var r=this;return t?this.cache.filter((function(n){return r._filter(n,t,e)})).map((function(t){return t.value})):this.cache.map((function(t){return t.value}))},t.prototype.delete=function(t,e){var r=this,n=[];"string"==typeof t?n=this.cache.filter((function(n){return r._filter(n,t,e)})):n.push(t);for(var o=0,i=n;o<i.length;o++){var s=this.cache.indexOf(i[o]);this.cache.splice(s,1)}},t.prototype._find=function(t,e){var r=this;return this.cache.find((function(n){return r._filter(n,t,e)}))},t.prototype._filter=function(t,e,r){return t.key===e&&(!r||z(t.props||t.options||{},U(r)))},t.instance={},t}(),Et=It,Pt=function(t){function e(r){var n=t.call(this)||this;return n.name="NetworkError",Object.setPrototypeOf(n,e.prototype),n.message="Unable to request ".concat(r,".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin),n}return r(e,t),e}(Error),At=function(t){function e(r){var n=t.call(this)||this;return n.name="NgwError",Object.assign(n,r),Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(Error);function Mt(t){return"[object Object]"===Object.prototype.toString.call(t)}Ct=function(t,e,r,n,o){void 0===r&&(r={}),r.method=r.method||"GET";var i=new XMLHttpRequest;i.open(r.method||"GET",t,!0),"blob"===r.responseType&&(i.responseType=r.responseType);var s=function(){try{return JSON.parse(i.responseText)}catch(t){return i.responseText}};i.onload=function(){-1!==[401,403,404,422,500].indexOf(i.status)&&n(new At(s())),function(t){void 0===t&&(t=!1);var o=t?n:e;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})}()},i.onerror=function(e){n(0===i.status?new Pt(t):e)},i.upload.onprogress=function(t){t.lengthComputable&&(r.onProgress&&r.onProgress(t.loaded/t.total*100,t))};var a,u=r.headers;if(u)for(var c in u){var p=u[c];"string"==typeof p&&i.setRequestHeader(c,p)}if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if((a=new FormData).append("file",r.file),r.data)for(var l in r.data)a.append(l,a[l])}else a=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((function(){i.abort()})),i.send(a)};var xt=/\{ *([\w_-]+) *\}/g;function kt(t,e){return t.replace(xt,(function(t,r){var n=e[r];if(void 0===n)throw new Error("No value provided for letiable "+t);return"function"==typeof n&&(n=n(e)),n}))}var St=function(t){function e(r){var n=t.call(this,r)||this;return n.name="ResourceNotFoundError",n.exception="nextgisweb.resource.exception.ResourceNotFound",Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(At),Nt=function(t){function e(r){var n=t.call(this,r)||this;return n.name="InsufficientPermissionsError",n.exception="nextgisweb.core.exception.InsufficientPermissions",Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(At),Tt=[];function Rt(t){Tt.push(t)}var Bt=["description"];function jt(t,e){void 0===e&&(e=""),e=e?e+"__":"";for(var r={},n=0,o=Object.entries(t);n<o.length;n++){var i=o[n],s=i[0],a=i[1];if(-1===Bt.indexOf(s))if(Mt(a))if("owner_user"===s){var u=jt(a,s);Object.assign(r,u)}else"parent"===s&&"id"in a&&(r.parent_id=a.id);else N(a)&&(r[e+s]=a)}return r}var Ft=function(){function t(t){this.connector=t,this.cache=new Et}return t.prototype.getOne=function(t,e){var r=this,o=new Et,i={},s=n(n({},e),{cache:!1});"string"==typeof t?i.keyname=t:"number"==typeof t?i.id=t:Mt(t)&&(void 0!==t.id?i.id=t.id:t.keyname&&(i.keyname=t.keyname));return o.addFull("resource",(function(){return"string"==typeof t?r._fetchResourceBy({keyname:t},s):"number"==typeof t?r._fetchResourceById(t,s):Mt(t)?r._fetchResourceBy(t,s):k.resolve(void 0)}),i)},t.prototype.getOneOrFail=function(t,e){return this.getOne(t,e).then((function(t){if(t)return t;throw new St}))},t.prototype.getId=function(t,e){return"number"==typeof t?k.resolve(t):"string"==typeof t||Mt(t)?this.getOne(t,e).then((function(t){if(t)return t.resource.id})):k.resolve(void 0)},t.prototype.getIdOrFail=function(t,e){return this.getId(t,e).then((function(t){if(void 0===t)throw new Error;return t}))},t.prototype.getMany=function(t,e){var r=this;return this._resourceCacheFilter(t).then((function(o){if(!o.length){var i={};return t.keyname?i.keyname=t.keyname:Object.assign(i,jt(t)),r.connector.get("resource.search",e,n({serialization:"full"},i)).then((function(t){if(t)for(var e=0,n=t;e<n.length;e++){var o=n[e];r.cache.add("resource.item",k.resolve(o),{id:o.resource.id})}return t}))}return o}))},t.prototype.getParent=function(t,e){var r=this;return this.getOne(t,e).then((function(t){return t?r.getOne(t.resource.parent.id,e):k.resolve(void 0)}))},t.prototype.getChildrenOf=function(t,e){var r=this;return this.getIdOrFail(t).then((function(t){return r._getChildrenOf(t,e)}))},t.prototype.update=function(t,e){var r=this;return this.getId(t).then((function(t){if(void 0!==t)return r.connector.put("resource.item",{data:e},{id:t})}))},t.prototype.delete=function(t){var e=this;return this.getId(t).then((function(t){if(void 0!==t)return e.connector.delete("resource.item",null,{id:t}).then((function(){e._cleanResourceItemCache(t)}))}))},t.prototype._getChildrenOf=function(t,e,r){var o=this;return void 0===r&&(r=[]),this.connector.get("resource.collection",n({cache:!0},e),{parent:t}).then((function(t){for(var n=[],i=0,s=t;i<s.length;i++){var a=s[i];o.cache.add("resource.item",k.resolve(a),{id:a.resource.id}),r.push(a),(null==e?void 0:e.recursive)&&a.resource.children&&n.push(o._getChildrenOf(a.resource.id,e,r))}return n.length?k.all(n).then((function(){return r})):r}))},t.prototype._cleanResourceItemCache=function(t){return o(this,void 0,void 0,(function(){var e,r,n,o,s,a,u,c;return i(this,(function(i){switch(i.label){case 0:e=this.cache.all(),r=[],n=0,o=e,i.label=1;case 1:return n<o.length?(a=(s=o[n]).options&&s.options.id,["resource.item","resource"].includes(s.key)&&void 0!==a?"number"!=typeof a?[3,2]:(a===t&&r.push(s),[3,4]):[3,4]):[3,5];case 2:return[4,this.getId(a)];case 3:i.sent()===t&&r.push(s),i.label=4;case 4:return n++,[3,1];case 5:for(u=0,c=r;u<c.length;u++)this.cache.delete(c[u]);return[2]}}))}))},t.prototype._fetchResourceById=function(t,e){var r=this;return this.cache.add("resource.item",(function(){return r.connector.get("resource.item",e,{id:t})}),{id:t}).catch((function(t){if(!(t instanceof St))throw t}))},t.prototype._fetchResourceBy=function(t,e){return this.getMany(t,e).then((function(t){return t[0]}))},t.prototype._resourceCacheFilter=function(t){return k.all(this.cache.matchAll("resource.item")).then((function(e){return e.filter((function(e){if(e)return t.keyname&&e.resource.keyname?t.keyname===e.resource.keyname:N(t.id)&&N(e.resource.id)?t.id===e.resource.id:z(t,e.resource)})),[]}))},t}(),Gt=0,qt=function(){function t(t){this.options=t,this.id=Gt++,this.emitter=new p.exports.EventEmitter,this.routeStr="/api/component/pyramid/route",this.activeRequests=[];var e=function(t){return Tt.find((function(e){if(e.options.baseUrl===t.baseUrl){if(!t.auth)return!0;if(e.options.auth)return z(e.options.auth,t.auth)}}))}(t);if(e)return e;this.options.route&&(this.routeStr=this.options.route),this.options.requestTransform&&(this.requestTransform=this.options.requestTransform),this.resources=new Ft(this),Rt(this)}return t.create=function(t){return new this(t)},t.prototype.setRequestTransform=function(t){this.requestTransform=t},t.prototype.setNgw=function(t){this.logout(),this.options.baseUrl=t,Rt(this)},t.prototype.connect=function(){var t=this,e=new Et,r=this.options.auth;return e.add("route",(function(){return new k((function(e,n){var o=function(){return t.makeQuery(t.routeStr,{},{}).then((function(t){e(t)})).catch((function(t){n(t)}))};if(r){var i=r.login,s=r.password;if(i&&s)return t._login({login:i,password:s}).then((function(){return o()})).catch((function(t){return n(t)}))}return o()}))}),{id:this.id,auth:r,baseUrl:this.options.baseUrl})},t.prototype.login=function(t,e){return this.logout(),Rt(this),this._login(t,e)},t.prototype.logout=function(){var t;this.abort(),-1!==(t=Tt.indexOf(this))&&Tt.splice(t,1),this.options.auth=void 0,this.user=void 0,this.emitter.emit("logout"),this.resources.cache.clean()},t.prototype.getUserInfo=function(t,e){if(this.user&&this.user.id)return k.resolve(this.user);t&&(this.options.auth=t);var r=n({headers:this.getAuthorizationHeaders(t)},e);return this.makeQuery("/api/component/auth/current_user",{},r)},t.prototype.getAuthorizationHeaders=function(t){var e=this.makeClientId(t);if(e)return{Authorization:"Basic "+e}},t.prototype.makeClientId=function(t){if(t=t||this.options.auth){var e=t.password,r=unescape(encodeURIComponent("".concat(t.login,":").concat(e)));return window.btoa(r)}},t.prototype.abort=function(){for(var t=0,e=this.activeRequests;t<e.length;t++){e[t].cancel()}this.activeRequests=[]},t.prototype.getActiveApiRequests=function(){return a([],this.activeRequests,!0)},t.prototype.apiRequest=function(t,e,r){var o,i=this;void 0===e&&(e={}),void 0===r&&(r={});var s=r.method,u=r.headers,c=r.withCredentials,p=r.responseType,l=U(e),h=function(){return function(t){var e=t.params;return new k((function(r,n){t.connector.connect().then((function(o){var i=o&&o[t.name];if(i){var s=(i=a([],i,!0)).shift();if(i.length){for(var u={},c=0;c<i.length;c++){var p=i[c];if(u[c]="{"+p+"}",void 0===e[p])throw new Error("`"+p+"` url api argument is not specified")}s&&(s=kt(s,u))}if(e){var l=[],h=e.paramList;for(var f in Array.isArray(h)&&(delete e.paramList,h.forEach((function(t){l.push("".concat(t[0],"=").concat(t[1]))}))),e)-1===i.indexOf(f)&&l.push("".concat(f,"=").concat(e[f]));l.length&&(s=s+"?"+l.join("&"))}s?r(t.connector.makeQuery(s,e,t.requestOptions)):n(new Error("request url is not set"))}else r(void 0)})).catch((function(t){n(t)}))}))}({name:t,params:l,requestOptions:r,connector:i})};return r.cache&&"GET"===s?(new Et).add(t,h,n({params:l},U({headers:u,withCredentials:c,responseType:p,baseUrl:this.options.baseUrl,userId:null===(o=this.user)||void 0===o?void 0:o.id}))):h()},t.prototype.post=function(t,e,r){return(e=e||{}).method="POST",this.apiRequest(t,r,e)},t.prototype.get=function(t,e,r){return(e=e||{}).method="GET",this.apiRequest(t,r,e)},t.prototype.patch=function(t,e,r){return(e=e||{}).method="PATCH",this.apiRequest(t,r,e)},t.prototype.put=function(t,e,r){return(e=e||{}).method="PUT",this.apiRequest(t,r,e)},t.prototype.delete=function(t,e,r){return(e=e||{}).method="DELETE",this.apiRequest(t,r,e)},t.prototype.makeQuery=function(t,e,r){if(void 0===r&&(r={}),t=(this.options.baseUrl?this.options.baseUrl:"")+t)return e&&(t=kt(t,e)),t=encodeURI(W(t)),this._loadData(t,r);throw new Error("Empty `url` not allowed")},t.prototype.getResource=function(t,e){return this.resources.getOne(t,e)},t.prototype.getResourceOrFail=function(t,e){return this.resources.getOneOrFail(t,e)},t.prototype.getResourceBy=function(t){return this.resources.getOne(t)},t.prototype.getResourceByKeyname=function(t){return this.resources.getOne(t)},t.prototype.getResourceById=function(t){return this.resources.getOne(t)},t.prototype.getResourceId=function(t,e){return this.resources.getId(t,e)},t.prototype.getResourceIdOrFail=function(t,e){return this.resources.getIdOrFail(t,e)},t.prototype.getResourcesBy=function(t,e){return this.resources.getMany(t,e)},t.prototype.getResourceParent=function(t,e){return this.resources.getParent(t,e)},t.prototype.getResourceChildren=function(t,e){return this.resources.getChildrenOf(t,e)},t.prototype.updateResource=function(t,e){return this.resources.update(t,e)},t.prototype.deleteResource=function(t){return this.resources.delete(t)},t.prototype._loadData=function(t,e){var r=this;e.responseType=e.responseType||"json";var o=new k((function(o,i,s){if(r.user&&((e=e||{}).headers=n(n({},r.getAuthorizationHeaders()),e.headers)),r.requestTransform){var a=r.requestTransform(t,e);t=a[0],e=a[1]}Ct(t,o,e,i,s)})).then((function(t){return r._cleanActiveRequests(o),t})).catch((function(t){if(r._cleanActiveRequests(o),t instanceof k.CancelError);else{var e=r._handleHttpError(t);if(e)throw e}}));return e.signal&&"function"==typeof e.signal.addEventListener&&e.signal.addEventListener("abort",(function(){o.cancel(),r._cleanActiveRequests(o)})),this.activeRequests.push(o),o},t.prototype._login=function(t,e){var r=this;return this.getUserInfo(t,e).then((function(t){return r.user=t,r.emitter.emit("login",t),t})).catch((function(t){throw r.emitter.emit("login:error",t),t}))},t.prototype._cleanActiveRequests=function(t){var e=this.activeRequests.indexOf(t);-1!==e&&this.activeRequests.splice(e,1)},t.prototype._handleHttpError=function(t){if(t&&t instanceof At){if("nextgisweb.resource.exception.ResourceNotFound"===t.exception)throw new St(t);if("nextgisweb.core.exception.InsufficientPermissions"===t.exception)throw new Nt(t)}return t},t.errors={NgwError:At,ResourceNotFoundError:St},t}(),Dt=qt;function Vt(t){var e=t.extent_bottom,r=t.extent_left,n=t.extent_top,o=t.extent_right;if(e&&r&&n&&o){var i=[r,e,o,n];return i[3]>82&&(i[3]=82),i[1]<-82&&(i[1]=-82),i}}function zt(t){var e=t.cache;return t.connector.get("layer.extent",{cache:void 0===e||e},{id:t.resourceId}).then((function(t){if(t){var e=t.extent;return[e.minLon,e.minLat,e.maxLon,e.maxLat]}}))}function Ut(t){return t.connector.getResource(t.resourceId).then((function(e){if(e)return Zt(e,t.connector,t)}))}function Zt(t,e,r){if(t.webmap)return k.resolve(Vt(t.webmap));var o=t.resource;return o.cls&&-1!==o.cls.indexOf("style")?e.getResource(o.parent.id).then((function(t){if(t)return zt(n(n({},r),{resourceId:t.resource.id,connector:e}))})):zt(n(n({},r),{resourceId:o.id,connector:e}))}var Wt=function(){function t(){}return t.prototype.getExtent=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.getBounds()]}))}))},t.prototype.getBounds=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return this._extent?[2,this._extent]:this.item?(e=this,[4,Zt(this.item,this.connector,t)]):[3,2];case 1:return e._extent=r.sent(),[2,this._extent];case 2:return[2]}}))}))},t}();var $t=["fields","intersects","limit","orderBy","strategy"];function Ht(t){var e={};return $t.forEach((function(r){var n=t[r];void 0!==n&&(e[r]=n)})),e}function Jt(t,e){return o(this,void 0,void 0,(function(){var r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return n=r=t.resource,o=t.keyname,s=t.resourceId,r?"string"!=typeof r?[3,1]:(o=r,[3,5]):[3,5];case 1:return"number"!=typeof r?[3,2]:(s=r,[3,5]);case 2:return n.resource&&void 0!==n.resource&&"resource"in n?(s=r.resource.id,[3,5]):[3,3];case 3:return[4,Jt(r,e)];case 4:s=i.sent(),i.label=5;case 5:return s||!o?[3,7]:[4,e.getResource(o)];case 6:(a=i.sent())&&(s=a.resource.id),i.label=7;case 7:return[2,s]}}))}))}var Qt={srs:4326,geom_format:"geojson"};function Kt(t){return{geometry:t.geom,id:t.id,type:"Feature",properties:t.fields}}function Xt(t,e){var r=e.extensions,n=e.geom,o=e.fields,i=e.srs;t.extensions=r?r.join(","):"",void 0!==o&&(t.fields=Array.isArray(o)?o.join(","):""),void 0!==n&&(t.geom=n?"yes":"no",n||(delete t.srs,delete t.geom_format)),N(i)&&(t.srs=i)}function Yt(t){var e=ee(t);return k.all(e).then((function(e){for(var r=[],n=[],o=0,i=e;o<i.length;o++)for(var s=0,a=i[o];s<a.length;s++){var u=a[s];r.includes(u.id)||(n.push(u),r.push(u.id))}return t.offset||t.limit?n.splice(void 0!==t.offset?t.offset:0,void 0!==t.limit?t.limit:n.length):n}))}function te(t){var e=t[0],r=t[1],n=t[2],o="id"!==e?"fld_":"",i="",s="",a=String(e).trim().replace(/^(%?)(.+?)(%?)$/,(function(t,e,r,n){return i=e,s=n,r})),u=i+n+s;return["".concat(o).concat(a,"__").concat(r),u]}function ee(t,e,r){void 0===e&&(e=[]),void 0===r&&(r=[]);var o=t.filters,i="string"==typeof o[0]?o[0]:"all",s=o.filter((function(t){return Array.isArray(t)}));if("any"===i)for(var u=0,c=s;u<c.length;u++){tt(d=c[u])?e.push(ne(n(n({},t),{paramList:a(a([],r,!0),[te(d)],!1)}))):ee(n(n({},t),{filters:d}),e,a([],r,!0))}else if("all"===i){for(var p=[],l=[],h=0,f=s;h<f.length;h++){var d;tt(d=f[h])?p.push(te(d)):l.push(d)}if(l.length)for(var y=0,v=l;y<v.length;y++){var m=v[y];ee(n(n({},t),{filters:m}),e,a(a([],r,!0),p,!0))}else e.push(ne(n(n({},t),{paramList:a(a([],r,!0),p,!0)})))}return e}function re(t){var e=t.map((function(t){var e=D(t[0],t[1]).map((function(t){return e=t,n=r?Number("1e+"+r):1,Math.round((e+Number.EPSILON)*n)/n;var e,r,n}));return e[0]+" "+e[1]}));return"POLYGON((".concat(e.join(", "),"))")}function ne(t){var e,r=n({},Qt),o=t.limit,i=t.cache,s=t.signal,a=t.offset,u=t.orderBy,c=t.paramList,p=t.connector,l=t.geomFormat,h=t.intersects,f=t.resourceId;if(o?o!==Number.POSITIVE_INFINITY&&(r.limit=o):r.limit=7e3,a&&(r.offset=a),l&&(r.geom_format=l),Xt(r,t),u&&(r.order_by=u.join(",")),Array.isArray(h)){var d=(e=h,Array.isArray(e)&&4===e.length&&e.every((function(t){return"number"==typeof t}))?F(h):h);r.intersects=re(d)}else"string"==typeof h&&(r.intersects=h);c&&(r.paramList=c);var y=n({id:f},r);return p.get("feature_layer.feature.collection",{cache:i,signal:s},y)}function oe(t){var e,r=function(){var r=t[e];if(Z(r)){var n=r;if(N(n.year)&&N(n.month)&&N(n.day)){var o=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach((function(t){o.push(t)})),t[e]=(new(Date.bind.apply(Date,a([void 0],o,!1)))).toISOString()}}else"id"===e&&"string"==typeof r&&(t[e]=r.split(",").map(Number))};for(e in t)r();return t}function ie(t){var e=t.filters;return e?Yt(n(n({},t),{filters:e})).then((function(r){var o;return(null!==(o=t.clientFilterValidate)&&void 0!==o?o:se(e))&&(r=r.filter((function(t){return et(oe(n(n({},t.fields),{id:t.id})),e)}))),r})):ne(t)}function se(t){if("any"===t[0])return!0;for(var e=1;e<t.length;e++){var r=t[e];if("[object Array]"===Object.prototype.toString.call(r))if(se(r))return!0}return!1}function ae(t){return function(t){return ie(t).then((function(t){var e=[];return t.forEach((function(t){e.push(Kt(t))})),e}))}(t).then((function(t){return{type:"FeatureCollection",features:t}}))}function ue(t){var e,s;return o(this,void 0,void 0,(function(){var a,u,c,l,h,f,d,y,v,m,g,_,b,w,L,O,C=this;return i(this,(function(I){switch(I.label){case 0:return a=t.item,u=t.webMap,h=null==(l=t.addLayerOptionsPriority)||l,d=t.Adapter||u.mapAdapter.layerAdapters.GEOJSON,y=[],v=!1,[4,Jt(f=t.layerOptions,c=t.connector)];case 1:return _=I.sent(),(null===(s=null===(e=f.adapterOptions)||void 0===e?void 0:e.popupOptions)||void 0===s?void 0:s.fromProperties)&&(f.adapterOptions.popupOptions.createPopupContent=function(t){var e=t.feature;return e&&function(t,e){var r=document.createElement("div");if(e&&e.feature_layer)e.feature_layer.fields.forEach((function(e){if(e.grid_visibility){var n=t.properties&&t.properties[e.keyname];if(n){var o=document.createElement("div");r.appendChild(o),o.innerHTML="<span>".concat(e.display_name,"</span>: ").concat(n,"<span></span>")}}}));else if(t.properties)for(var n in t.properties){var o=document.createElement("div");r.appendChild(o),o.innerHTML="<span>".concat(n,"</span>: ").concat(t.properties[n],"<span></span>")}return r}(e,a)}),b=function(t,e){return o(C,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return L(),m={filters:t,options:e},[4,g=ae(n({resourceId:_,filters:t,connector:c,cache:!0},e))];case 1:return[2,r.sent()]}}))}))},w=!1,L=function(){g&&(g.cancel(),g=void 0)},O=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.emitter=new p.exports.EventEmitter,e}return r(e,t),e.prototype.addLayer=function(e){return o(this,void 0,void 0,(function(){var r,o,s,u,c;return i(this,(function(i){switch(i.label){case 0:return r=!e.data,o=void 0===e.waitFullLoad||e.waitFullLoad,void 0!==f.id&&(e.id=f.id),a&&a.vector_layer&&(e.type=qe[a.vector_layer.geometry_type]),f.adapterOptions&&(e=h?n(n({},f.adapterOptions),e):n(n({},e),f.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,r=!1),this.options.strategy=s=e.strategy||void 0,u=t.prototype.addLayer.call(this,e),m={filters:e.propertiesFilter,options:Ht(e)},r&&(c=this.updateLayer()),o&&c?[4,c]:[3,2];case 1:i.sent(),i.label=2;case 2:return s&&s.startsWith("BBOX")&&!v&&this._addBboxEventListener(),[2,u]}}))}))},e.prototype.getExtent=function(){return this.getBounds()},e.prototype.getBounds=function(){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){return e=this.getLayers&&this.getLayers().length,(null==(r=this.options.strategy)?void 0:r.startsWith("BBOX"))||e?[2,Ut({connector:c,resourceId:a.resource.id})]:t.prototype.getBounds?[2,t.prototype.getBounds.call(this)]:[2]}))}))},e.prototype.beforeRemove=function(){w=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,L()},e.prototype.getCount=function(){return function(t){var e=t.cache;return t.connector.get("feature_layer.feature.count",{cache:void 0===e||e},{id:t.resourceId}).then((function(t){return t.total_count}))}({connector:c,resourceId:_,cache:!0})},e.prototype.updateLayer=function(e){var r;return o(this,void 0,void 0,(function(){var o,s,a,c,p,l,h,d,g,_,L;return i(this,(function(i){switch(i.label){case 0:return e=e||m||{},(null===(r=this.options.strategy)||void 0===r?void 0:r.startsWith("BBOX"))?[4,u.onLoad("create")]:[3,2];case 1:if(i.sent(),e.options=e.options||{},e.options.intersects=u.getBounds(),s=(o=this.options).minZoom,a=o.maxZoom,void 0!==(c=u.getZoom())){if(void 0!==s&&c<s)return[2];if(void 0!==a&&c>a)return[2];if(v)return[2]}i.label=2;case 2:if(w)return[2];i.label=3;case 3:return i.trys.push([3,10,,11]),this.emitter.emit("preupdate",e),u._emitLayerEvent("layer:preupdate",f.id||"",e),[4,b(e.filters,n(n({},e.options),{srs:this.options.srs}))];case 4:return p=i.sent(),l=p,[4,this.getCount()];case 5:if(h=i.sent(),"BBOX+"!==this.options.strategy)return[3,7];for(l={type:"FeatureCollection",features:[]},d=0,g=p.features;d<g.length;d++)_=g[d],-1===y.indexOf(String(_.id))&&(y.push(String(_.id)),l.features.push(_));return v=void 0!==h&&y.length>=h,[4,u.addLayerData(this,l)];case 6:return i.sent(),[3,9];case 7:return v=void 0!==h&&p.features.length>=h,[4,u.setLayerData(this,p)];case 8:i.sent(),i.label=9;case 9:return this.emitter.emit("updated",p),u._emitLayerEvent("layer:updated",f.id||"",{data:p,newData:l,isFull:v}),[3,11];case 10:if((L=i.sent())instanceof Error&&"CancelError"!==L.name)throw L;return[3,11];case 11:return t.prototype.updateLayer&&t.prototype.updateLayer.call(this),[2]}}))}))},e.prototype.propertiesFilter=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return L(),this.filter&&v?(this.filter((function(e){var r=e.feature&&e.feature.properties&&oe(n({},e.feature.properties));return!r||et(r,t)})),[3,3]):[3,1];case 1:return this.setData?(this.clearLayer&&this.clearLayer(),[4,b(t,n(n({},e),{srs:this.options.srs}))]):[3,3];case 2:r=o.sent(),this.setData(r),o.label=3;case 3:return[2]}}))}))},e.prototype.removeFilter=function(){m=void 0,this.propertiesFilter([]),this.filter&&this.filter((function(){return!0}))},e.prototype._addBboxEventListener=function(){var t=this;this.__enableMapMoveListener=function(e){e===t&&(t._removeMoveEventListener(),t.updateLayer(),t._addMoveEventListener())},this.__disableMapMoveListener=function(e){e===t&&t._removeMoveEventListener()},u.emitter.on("layer:show",this.__enableMapMoveListener),u.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)},e.prototype._removeBboxEventListener=function(){this.__enableMapMoveListener&&u.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&u.emitter.on("layer:hide",this.__disableMapMoveListener)},e.prototype._addMoveEventListener=function(){var t=this;this.__onMapMove=function(t,e){var r;function n(){for(var o=this,i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];n.clear(),r=setTimeout((function(){r=null,t.apply(o,i)}),e)}return void 0===e&&(e=10),n.clear=function(){r&&(clearTimeout(r),r=null)},n}((function(){return t.updateLayer()})),this.__onMapMoveStart=L,u.emitter.on("movestart",this.__onMapMoveStart),u.emitter.on("moveend",this.__onMapMove)},e.prototype._removeMoveEventListener=function(){this.__onMapMove&&u.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&u.emitter.removeListener("movestart",this.__onMapMoveStart)},e}(d),[2,O]}}))}))}function ce(t){var e,r,n=t.options,o=t.webMap,i=t.baseUrl,s=n.adapter||"IMAGE",a=o&&o.getLayerAdapters(),u=n.resource,c=n.tileNoData?n.tileNoData:200;if("number"==typeof u){if("IMAGE"===s){if(!a||a.IMAGE)return function(t){var e=t.resourceId,r=t.nd,n=t.headers,o=t.baseUrl+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:function(t){return r&&(t.nd=r),Fe(t,e)}}}({resourceId:u,headers:n.headers,nd:c,baseUrl:i});s="TILE"}if("WMS"===s){r="".concat(i,"/api/resource/").concat(u,"/wms");var p=n.adapterOptions;return{url:r,format:"image/png",version:"1.1.1",layers:p&&p.layers,headers:n.headers}}if("MVT"===s)return{url:r=i+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+u+"&simplification="+(null!==(e=n.simplification)&&void 0!==e?e:6),sourceLayer:"ngw:"+u,featureIdName:"$id"};if("TERRAIN"===s)return{url:r=i+"/api/resource/".concat(u,"/terrain_provider"),adapter:s};if("MODEL_3D"===s)return{url:r=i+"/api/component/model_3d/".concat(u,"/data.glb")};if("TILE"===s)return{url:r=i+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+u+"&nd="+c,adapter:s}}else{if(void 0!==u)throw new Error("Option `resource` must be number, not "+typeof u);console.log("Option `resource` not set")}}function pe(t){var e=t.layerOptions,s=t.webMap,a=t.connector,u=t.item;return o(this,void 0,void 0,(function(){var t,c,p,l,h,f;return i(this,(function(d){switch(d.label){case 0:return t=u.resource.cls,c={wmsserver_service:"WMS",tmsclient_layer:"IMAGE"},void 0!==(p=e.adapter||t&&c[t]||"IMAGE")&&(e.adapter=p),"IMAGE"===p&&(l=s.getLayerAdapters(),!l||l.IMAGE||(p="TILE")),(h=s.mapAdapter.layerAdapters[p])?[4,Jt(e,a)]:[3,2];case 1:return f=d.sent(),[2,function(t){function c(r,o){var i=t.call(this,r,o)||this;i.map=r,i.item=u,i.resourceId=f;var c=ce({options:e,webMap:s,baseUrl:a.options.baseUrl||""});if(c){var p=n(n(n({},c),e.adapterOptions),{params:{resource:f},layers:c.layers||String(f),resourceId:f});e.adapterOptions&&N(e.adapterOptions.setViewDelay)&&(p.setViewDelay=e.adapterOptions.setViewDelay),i.options=n(n({},i.options),p)}return i}return r(c,t),c.prototype.addLayer=function(e){return t.prototype.addLayer.call(this,n(n({},this.options),e))},c.prototype.getIdentificationIds=function(){return o(this,void 0,void 0,(function(){var t;return i(this,(function(e){if(this.item){if("MVT"===p)return[2,[this.item.resource.id]];if(N(t=this.item.resource.parent.id))return[2,[t]]}return[2,[]]}))}))},c}(h)];case 2:throw new Error(p+" not supported yet. Only TILE")}}))}))}function le(t,e,r,n){return!!de(t,e,r,ye,n)}function he(t,e,r,n){return de(t,e,r,ve,n)}function fe(t,e){void 0===e&&(e="children");var r=[],n=("function"==typeof e?e:function(t){return t[e]})(t);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function de(t,e,r,n,o){void 0===e&&(e=function(t){return!!t}),void 0===r&&(r="children");var i="function"==typeof e?e:function(t){return et(t,e)};return n(t,o?function(t){return i(o(t))}:i,r)}function ye(t,e,r,n){void 0===e&&(e=function(t){return!!t});var o=[];if(Array.isArray(t))o=t;else{if(e(t))return t;var i=fe(t,r);i&&(o=i)}for(var s=0;s<o.length;s++)if(o[s]){var a=ye(o[s],e,r);if(a)return a}}function ve(t,e,r,n){void 0===e&&(e=function(t){return!!t}),void 0===n&&(n=[]);var o=[];if(Array.isArray(t))o=t;else{e(t)&&n.push(t);var i=fe(t,r);i&&(o=i)}for(var s=0;s<o.length;s++)o[s]&&ve(o[s],e,r,n);return n}function me(t,e,r,n){void 0===e&&(e=function(t){return!!t});var o=[];if(Array.isArray(t))o=t;else{if(!e(t))return!1;var i=fe(t,r);i&&(o=i)}for(var s=0;s<o.length;s++){if(o[s])if(!me(o[s],e,r))return!1}return!0}var ge=function(){function t(t){this._children=[],this.item=t}return t.prototype.setParent=function(t){this._parent=t},t.prototype.addChild=function(t){this._children.push(t)},t.prototype.getParent=function(){return this._parent},t.prototype.getParents=function(t){var e=this.getParent();return e?he(e,t,(function(t){return t.tree.getParent()})):[]},t.prototype.getRoot=function(){for(var t=this.getParent(),e=t;t;)(t=t.tree.getParent())&&(e=t);return e},t.prototype.find=function(t){return de(this._children,t,(function(t){return t.tree.getChildren()}),ye,e);var e},t.prototype.every=function(t){return!!de(this._children,t,(function(t){return t.tree.getChildren()}),me,e);var e},t.prototype.some=function(t){return le(this._children,t,(function(t){return t.tree.getChildren()}))},t.prototype.all=function(t){return this.getDescendants(t)},t.prototype.getDescendants=function(t){return he(this._children,t,(function(t){return t.tree.getChildren()}))},t.prototype.getChildren=function(){return a([],this._children,!0)},t}(),_e=function(){function t(t,e,r){this.emitter=new p.exports.EventEmitter,this._blocked=!1,this.item=e,this.options=Object.assign({},r),this.name=t,this._value=this.getProperty()}return t.prototype.getProperty=function(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value},t.prototype.getParents=function(){return this.item.tree.getParents()||[]},t.prototype.getParent=function(){return this.item.tree.getParent()},t.prototype.getChildren=function(){return this.item.tree.getChildren()},t.prototype.isGroup=function(){return this.item.tree.getDescendants().length},t.prototype.isBlocked=function(){var t=this;if(void 0===this._blocked){var e=this.item.tree.getParents();if(e){var r=e.find((function(e){var r=e.properties&&e.properties.property(t.name);return!!r&&!r.get()}));this._blocked=!!r}else this._blocked=!1}return this._blocked},t.prototype.set=function(t,e){this._value=this._prepareValue(t),this.update(this._value,e),this._fireChangeEvent(this._value,e)},t.prototype.get=function(){return this.getValue()},t.prototype.update=function(t,e){this._callOnSet(t,e)},t.prototype.getContainer=function(){return this._container},t.prototype.destroy=function(){if(this._container){var t=this._container.parentNode;t&&t.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()},t.prototype.getValue=function(){return void 0!==this._value?this._value:this.getProperty()},t.prototype._prepareValue=function(t){return t},t.prototype._callOnSet=function(t,e){this.options.onSet&&this.options.onSet.call(this,t,e,this.item)},t.prototype._fireChangeEvent=function(t,e){var r=this;this.emitter&&(t=void 0!==t?t:this.getValue(),this.emitter.emit("change",{value:t,options:e}),this.item.tree.getParents().forEach((function(n){var o=n.properties&&n.properties.property(r.name);o&&o.emitter.emit("change-tree",{value:t,options:e,item:r.item})})))},t}(),be=function(t){function e(r,o,i){var s=t.call(this,r,o,n(n({},e.options),i))||this;return s.set(s.get()),s}return r(e,t),e.prototype.update=function(t,e){if(t){if(e&&e.bubble||this.options.bubble){this.unBlock(e);var r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(t,Object.assign({},e,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(e)}else this._turnOff(e);(e&&e.propagation||this.options.propagation)&&this._propagation(t,e)},e.prototype.getHierarchyValue=function(){var t=this;return this.get()&&this.getParents().every((function(e){var r=e.properties&&e.properties.get(t.name);return r&&r.get()}))},e.prototype.block=function(t){this._blocked=!0,this._block(t)},e.prototype.unBlock=function(t){this._blocked=!1,this.getValue()&&this._unBlock(t)},e.prototype.blockChild=function(t){var e=this;this.item.tree.getDescendants().forEach((function(r){return e._blockChild(r,t)}))},e.prototype.unblockChild=function(t){var e=this;this.item.tree.getChildren().forEach((function(r){return e._unBlockChild(r,t)}))},e.prototype._prepareValue=function(t){return t},e.prototype._turnOff=function(t){this.options.turnOff&&this.options.turnOff.call(this,t),this._callOnSet(!1,t),this.options.hierarchy&&this.isGroup()&&this.blockChild(t)},e.prototype._turnOn=function(t){this.options.turnOn&&this.options.turnOn.call(this,t),this._callOnSet(!0,t),this.options.hierarchy&&this.isGroup()&&this.unblockChild(t)},e.prototype._block=function(t){this._turnOff(t)},e.prototype._unBlock=function(t){this._turnOn(t)},e.prototype._blockChild=function(t,e){var r=t.properties&&t.properties.property(this.name);r&&r.block&&r.block(e)},e.prototype._unBlockChild=function(t,e){var r=t.properties&&t.properties.property(this.name);r&&r.unBlock&&r.unBlock(e)},e.prototype._propagation=function(t,e){if(this.isGroup())for(var r=this.item.tree.getChildren(),o=0;o<r.length;o++){var i=r[o],s=i.properties&&i.properties.property(this.name);s&&s.set(t,n(n({},e),{propagation:!0,bubble:!1}))}},e.options={hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"},e}(_e),we=function(){function t(t,e){this.item=t,this.options={},this._properties={},this._propertiesList=[],e&&e.forEach(this._setPropertyHandler.bind(this))}return t.prototype.add=function(t){this._setPropertyHandler(t)},t.prototype._setPropertyHandler=function(e){var r=t.handlers,o=e.handler;if(!o&&e.type)if("boolean"===e.type)o=r.CheckProperty;else o=r.BaseProperty;if(o&&e.name){var i=n({},e||{});this._properties[e.name]=new o(e.name,this.item,i),this._propertiesList.push(e.name)}},t.prototype.update=function(){this.list().forEach((function(t){t.update()}))},t.prototype.get=function(t){var e=this.property(t);if(e)return e.get()},t.prototype.set=function(t,e,r){var n=this.property(t);if(n)return n.set(e,r)},t.prototype.property=function(t){return this._properties[t]},t.prototype.list=function(){var t=this;return this._propertiesList.map((function(e){return t._properties[e]}))},t.prototype.destroy=function(){for(var t in this._properties){var e=this.property(t);e&&e.destroy&&e.destroy()}this._properties={},this._propertiesList=[]},t.handlers={CheckProperty:be},t}(),Le=0,Oe=function(){function t(t){this.options={},this.id=Le,Le+=1,this.options=n({},t),this.tree=new ge(this)}return t.prototype.initProperties=function(){this.properties=new we(this,this.options.properties)},t}(),Ce=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.getProperty=function(){var t=this.item.layer;return t&&t&&t.options&&void 0!==t.options.opacity?t.options.opacity:1},e.prototype.update=function(t,e){var r=this;if(e=e||{},this.isGroup()){this._value=this._prepareValue(t,e);for(var n=0,o=this.getChildren();n<o.length;n++){var i=o[n].properties.property(this.name);i&&(e.propagation?i.set(t,e):i.update(i.get(),e))}}var s=this.item.layer;if(s){var a=this.getParents().reduce((function(t,e){var n=e.properties.property(r.name);return t*(n?n.getValue():1)}),1);this.item.webMap.setLayerOpacity(s,this._prepareValue(t*a))}},e.prototype._prepareValue=function(t,e){return e&&e.propagation&&this.isGroup()?1:Number(t)},e}(_e),Ie=function(t){function e(r,o,i,s,a,u){var c=t.call(this,n(n({},e.options),i))||this;if(c.webMap=r,c.emitter=new p.exports.EventEmitter,c._rootDescendantsCount=0,s&&(c.connector=s),a&&c.tree.setParent(a),c.item=o,"root"===c.item.item_type)c._rootDescendantsCount=c._sumUp(c.item.children);else{var l=c.tree.getRoot();l&&(c._rootDescendantsCount=l._rootDescendantsCount)}return c.initProperties(),u||c._init(o),c}return r(e,t),e.create=function(t,r,n,s,a){return o(this,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return[4,(o=new e(t,r,n,s,a,!0))._init(r)];case 1:return i.sent(),[2,o]}}))}))},e.prototype.initItem=function(t){var r=this,n=t,o=this.getItemOptions(t),i=function(t){n._layer=t,r.layer=t,r.properties.get("visibility")&&r.properties.set("visibility",!0),void 0!==o.opacity&&r.webMap.setLayerOpacity(t,o.opacity)};if("group"===t.item_type||"root"===t.item_type){if(t.children&&t.children.length)for(var s=0,a=this.getChildren(t);s<a.length;s++){var u=new this.constructor(this.webMap,a[s],this.options,this.connector,this);this.tree.addChild(u)}return Promise.resolve()}var c=void 0;if("layer"===t.item_type)c=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){c=(0,e.GetAdapterFromLayerType[t.item_type])(t,o,this.webMap,this.connector)}return c?this.webMap.addLayer(c,o).then((function(t){i(t)})):t._layer?Promise.resolve(i(t._layer)):Promise.reject("No layer added")},e.prototype.bringToFront=function(){},e.prototype.fit=function(){},e.prototype.getLayer=function(){return this.layer},e.prototype.getItemOptions=function(t){var e="layer"===t.item_type&&t.layer_transparency,r="number"==typeof e?(100-e)/100:void 0,n={visibility:!1,headers:this.options.headers,crossOrigin:this.options.crossOrigin,setViewDelay:this.options.setViewDelay,params:{resource:this.item.resourceId,item:this.item}};if(this.options.order){var o=String(this.options.drawOrderEnabled&&"draw_order_position"in t?this._rootDescendantsCount-t.draw_order_position:this.id).padStart(4,"0");n.order=Number((0|this.options.order)+"."+o)}if(this.options.popupOptions&&(n.popupOptions=this.options.popupOptions),"layer"===t.item_type){var i=this._getZoomRange(t);!function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0,o=e;n<o.length;n++)for(var i=o[n],s=0,a=Object.getOwnPropertyNames(i);s<a.length;s++){var u=a[s];t[u]=i[u]}}(n,{updateWmsParams:t.updateWmsParams,url:t.url,headers:this.options.headers,ratio:this.options.ratio,maxZoom:i.maxZoom,minZoom:i.minZoom,minScale:t.layer_min_scale_denom,maxScale:t.layer_max_scale_denom})}return void 0!==r&&(n.opacity=r),n},e.prototype.getChildren=function(t){return a([],t.children,!0).reverse()},e.prototype._mapScaleToZoomLevel=function(t){return function(t,e){void 0===e&&(e=0);var r=e;return function(t){return Math.log(t/256)/Math.LN2}(function(){if(void 0===Ge){var t=document.createElement("div");t.style.cssText="position: absolute; left: -100%; top: -100%; width: 100cm;",document.body.appendChild(t);var e=t.offsetWidth;document.body.removeChild(t),Ge=e}return Ge}()*function(t){return 12756274*Math.PI*Math.cos(t*Math.PI/180)}(r)/t)}(t)},e.prototype._getZoomRange=function(t){var e=this.options.minZoom,r=this.options.maxZoom,n=t.layer_min_scale_denom?this._mapScaleToZoomLevel(t.layer_min_scale_denom):void 0,o=t.layer_max_scale_denom?this._mapScaleToZoomLevel(t.layer_max_scale_denom):void 0,i=[e,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max.apply(Math,i):void 0,maxZoom:s.length?Math.min.apply(Math,s):void 0}},e.prototype._init=function(t){var e=this;this.initItem(t).then((function(){e.emitter.emit("init")}))},e.prototype._sumUp=function(t,e){void 0===e&&(e=0);for(var r=0,n=t;r<n.length;r++){var o=n[r];"layer"===o.item_type?(e+=1,o.draw_order_position=o.draw_order_position||e):"group"===o.item_type&&(e=this._sumUp(o.children,e))}return e},e.GetAdapterFromLayerType={},e.options={properties:[{type:"boolean",name:"visibility",getProperty:function(t){if(t){if("group"===t.item.item_type||"root"===t.item.item_type)return le(t.item,(function(t){return"layer_enabled"in t&&t.layer_enabled}),(function(t){return t.children}));if("layer"===t.item.item_type)return t.item.layer_enabled}return!1},onSet:function(t,e,r){r&&"layer"===r.item.item_type&&(r.layer&&(t?r.webMap.showLayer(r.layer):r.webMap.hideLayer(r.layer)),r.item.layer_enabled=t)}},{name:"opacity",handler:Ce}]},e}(Oe);function Ee(t){var e=t.webMap,r=t.connector,s=t.item,a=t.adapterOptions,u=void 0===a?{}:a,c=t.idPrefix,p=void 0===c?"first-show-adapter":c;return o(this,void 0,void 0,(function(){var t;return i(this,(function(a){return t=function(t){var e=t.webMap,r=t.adapterOptions,s=void 0===r?{}:r,a=t.onLayerAdded,u=t.createAdapter;return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){return t=function(){function t(){this.options={},this.layer=[],this._removed=!1,this._creatingInProgress=!1}return t.prototype.addLayer=function(){return this.layer},t.prototype.removeLayer=function(){this._removed=!0;for(var t=0,r=this.layer;t<r.length;t++)e.removeLayer(r[t])},t.prototype.destroyed=function(){return this._removed},t.prototype.showLayer=function(){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(this.options.visibility=!0,!this.layer.length)return[3,5];t=0,r=this.layer,n.label=1;case 1:return t<r.length?[4,e.showLayer(r[t])]:[3,4];case 2:n.sent(),n.label=3;case 3:return t++,[3,1];case 4:return[3,7];case 5:return[4,this.loadLayer()];case 6:n.sent(),n.label=7;case 7:return[2]}}))}))},t.prototype.hideLayer=function(){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(this.options.visibility=!1,!this.layer)return[3,4];t=0,r=this.layer,n.label=1;case 1:return t<r.length?[4,e.hideLayer(r[t])]:[3,4];case 2:n.sent(),n.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},t.prototype.loadLayer=function(){return o(this,void 0,void 0,(function(){var t,r,o;return i(this,(function(i){switch(i.label){case 0:return this.layer.length||this._creatingInProgress?[3,5]:(this._creatingInProgress=!0,[4,u(this)]);case 1:return(t=i.sent())?[4,(r=new t(e.mapAdapter.map,n({},s))).addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer})]:[3,5];case 2:return o=i.sent(),a&&a(r),Object.assign(r.options,s),r.layer=o,this._removed&&e.removeLayer(r),this.layer.push(r),this.options.visibility?[4,e.showLayer(r)]:[3,4];case 3:i.sent(),i.label=4;case 4:this._creatingInProgress=!1,i.label=5;case 5:return[2,this.layer]}}))}))},t}(),[2,t]}))}))}({webMap:e,adapterOptions:u,onLayerAdded:function(t){t.options.baselayer=!1,t.id=p+"-"+s.resource_id},createAdapter:function(){return je({resource:s.resource_id,adapterOptions:{name:s.display_name,opacity:s.opacity}},e,r)}}),[2,t]}))}))}var Pe=function(){function t(t){this.options=t,this.resourceId=t.resourceId;var e=t.item;this.item=e,this.name=t.labelField&&e.fields?e.fields[t.labelField]:String(e.id)}return t.prototype.extent=function(){var t=this;return this._extent?k.resolve(this._extent):this.options.connector.get("feature_layer.feature.item_extent",null,{id:this.resourceId,fid:this.item.id}).then((function(e){var r=e.extent,n=[r.minLon,r.minLat,r.maxLon,r.maxLat];return t._extent=n,n}))},t.prototype.geoJson=function(){var t=this;return this.item.geom?k.resolve(Kt(this.item)):Ue({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null}).then((function(e){return t.item.geom=e.geom,Kt(t.item)}))},t}(),Ae=function(){function t(t,e){this.map=t,this.options=e,this.NgwWebmapItem=Ie,this.pixelRadius=10,this.webmapClassName="webmap",this.emitter=new p.exports.EventEmitter,this._webmapBaselayersIds=[];var r=e.resourceId;if(Array.isArray(r)?(this.resourceId=r[0],this.options.id=r[1]):this.resourceId=r,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}return t.prototype.addLayer=function(t){var e,r;return o(this,void 0,void 0,(function(){var o,s;return i(this,(function(i){switch(i.label){case 0:return this.options=n(n({},this.options),t),o=this,[4,this._getWebMapLayerItem()];case 1:return o.layer=i.sent(),s=null===(r=null===(e=this.response)||void 0===e?void 0:e.webmap)||void 0===r?void 0:r.extent_constrained,this.options.useExtentConstrained&&this._extent&&s&&this.options.webMap.setView({maxBounds:this._extent}),[2,this.layer]}}))}))},t.prototype.removeLayer=function(){var t=this.options.webMap.mapAdapter;if(this.getDependLayers().forEach((function(e){"layer"in e&&t.removeLayer(e.layer.layer)})),this._webmapBaselayersIds.length){for(var e=0,r=this._webmapBaselayersIds;e<r.length;e++){this.options.webMap.removeLayer(r[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},t.prototype.showLayer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return this.layer&&this.layer.properties?[2,this.layer.properties.property("visibility").set(!0)]:[2]}))}))},t.prototype.hideLayer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return this.layer&&this.layer.properties?[2,this.layer.properties.property("visibility").set(!1)]:[2]}))}))},t.prototype.setOpacity=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this.layer&&this.layer.properties?[2,this.layer.properties.property("opacity").set(t)]:[2]}))}))},t.prototype.getExtent=function(){return this.getBounds()},t.prototype.getBounds=function(){var t=this.response&&this.response.webmap;if(t)return Vt(t)},t.prototype.getDependLayers=function(){return this.layer&&this.layer.tree.getDescendants()||[]},t.prototype.getBookmarksResourceId=function(){var t=this.response&&this.response.webmap;if(t)return t.bookmark_resource.id},t.prototype.fetchBookmarks=function(){var t=this.getBookmarksResourceId(),e=this.options.connector;if(t)return e.getResourceOrFail(t).then((function(r){var n,o=null===(n=r.feature_layer)||void 0===n?void 0:n.fields.find((function(t){return t.label_field})),i=o&&o.keyname;return ie({connector:e,resourceId:t,geom:!1,fields:i?[i]:void 0}).then((function(r){for(var n=[],o=0,s=r;o<s.length;o++){var a=new Pe({item:s[o],resourceId:t,labelField:i,connector:e});n.push(a)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")},t.prototype.getIdentificationIds=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return t=[],(e=this._webmapLayersIds)?[3,2]:[4,this._getWebMapIds()];case 1:e=r.sent(),this._webmapLayersIds=e,r.label=2;case 2:return e&&e.length&&this.getDependLayers().sort((function(t,e){return e.id-t.id})).forEach((function(e){var r=e.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type){var o=e.properties.property("visibility");o.get()&&!o.isBlocked()&&t.push(n)}})),[2,t]}}))}))},t.prototype._getWebMapLayerItem=function(){return o(this,void 0,void 0,(function(){var t,e=this;return i(this,(function(r){switch(r.label){case 0:return this.resourceId?[4,this.getWebMapConfig(this.resourceId)]:[3,2];case 1:if((t=r.sent())&&t.root_item)return[2,new Promise((function(r){var n={};if(e.options.connector&&e.options.connector.options.auth){var o=e.options.connector.getAuthorizationHeaders();o&&(n.headers=o)}n.setViewDelay=e.options.setViewDelay,n.order=e.options.order,n.ratio=e.options.ratio,n.crossOrigin=e.options.crossOrigin,n.minZoom=e.options.minZoom,n.maxZoom=e.options.maxZoom,n.drawOrderEnabled=t.draw_order_enabled,n.popupOptions=e.options.popupOptions;var i=new e.NgwWebmapItem(e.options.webMap,t.root_item,n,e.options.connector);i.emitter.on("init",(function(){return r(i)}))}))];r.label=2;case 2:return[2]}}))}))},t.prototype.getWebMapConfig=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return[4,this.options.connector.getResource(t)];case 1:return(e=n.sent())&&(this.response=e,r=e[this.webmapClassName],this._setupBaselayers(e),r)?(this._extent=[r.extent_left,r.extent_bottom,r.extent_right,r.extent_top],this._updateItemsParams(r.root_item,this.options.webMap,e),[2,r]):[2]}}))}))},t.prototype._setupBaselayers=function(t){var e,r=this.options.webMap;if(null===(e=this.options.useBasemap)||void 0===e||e)if(t.basemap_webmap&&t.basemap_webmap.basemaps.length){var n=r.getActiveBaseLayer();this._lastActiveBaselayer=n?n.id:void 0,this._setBasemaps(t.basemap_webmap)}else this.options.defaultBasemap&&r.addBaseLayer("OSM",{id:"webmap-default-baselayer",name:"OpenStreetMap"})},t.prototype._setBasemaps=function(t){for(var e=this,r=this.options.webMap,n=!1,o=function(t){Ee({webMap:r,connector:i.options.connector,item:t,adapterOptions:{crossOrigin:i.options.crossOrigin}}).then((function(o){var i=!n&&t.enabled;return t.enabled&&(n=!0),r.addBaseLayer(o,{id:ze+t.resource_id,name:t.display_name,opacity:t.opacity,visibility:i}).then((function(t){t.id&&e._webmapBaselayersIds.push(t.id)}))}))},i=this,s=0,a=t.basemaps;s<a.length;s++){o(a[s])}},t.prototype._updateItemsParams=function(t,e,r){var o=this;if(t)if("group"===t.item_type||"root"===t.item_type)t.children&&(t.children=t.children.map((function(t){return o._updateItemsParams(t,e,r)}))),"root"===t.item_type&&(t.display_name=r.resource.display_name);else if("layer"===t.item_type){var i=W(this.options.connector.options.baseUrl+"/api/component/render/image"),s=t.layer_style_id;t.url=i,t.resourceId=s,t.updateWmsParams=function(t){return Fe(t,s)};var a=ce({options:{adapter:t.layer_adapter.toUpperCase(),resource:s},webMap:e,baseUrl:this.options.connector.options.baseUrl||""});t=n(n({},t),a)}return t},t.prototype._getWebMapIds=function(){return o(this,void 0,void 0,(function(){var t,e,r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:if(!(t=this.layer)||"root"!==t.item.item_type)return[3,2];for(e=t.tree.getDescendants(),r=[],n=function(t){var e=t.item;if("layer"===e.item_type){var n=o.options.connector.getResource(e.layer_style_id).then((function(t){if(t){var r=Number(t.resource.parent.id);return e.parentId=r,r}}));r.push(n)}},o=this,s=0,a=e;s<a.length;s++)n(a[s]);return[4,Promise.all(r)];case 1:return[2,i.sent().filter((function(t){return void 0!==t}))];case 2:return[2]}}))}))},t}();var Me={tms:"TILE"};function xe(t){return new Promise((function(e,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState&&200===n.status&&n.responseText)try{e(JSON.parse(n.responseText))}catch(t){r(t)}},n.open("GET",W(t),!0),n.send()}))}var ke="https://qms.nextgis.com";function Se(t,e,r){return void 0===e&&(e=ke),void 0===r&&(r={}),e||(e=ke),function(){function s(t,e){this.map=t;var o=n(n({},r),e);this.options=o,this.options.baselayer=!0,o.qms&&(this.qms=o.qms)}return s.prototype.addLayer=function(r){return o(this,void 0,void 0,(function(){var o,a,u,c,p,l,h,f;return i(this,(function(i){switch(i.label){case 0:if(this.qms||!r.qmsId)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),o=this,[4,xe(e+"/api/v1/geoservices/"+r.qmsId)];case 2:return o.qms=i.sent(),[3,4];case 3:return a=i.sent(),console.error(a),[3,4];case 4:return(u=this.qms)&&(p=t.mapAdapter.layerAdapters[c=Me[u.type||"tms"]])&&(y=s,v=p,["showLayer","hideLayer"].forEach((function(t){var e=Object.getOwnPropertyDescriptor(v.prototype,t);e&&Object.defineProperty(y.prototype,t,e)})),"TILE"===c)?(r=n(n({order:0,maxZoom:t.options.maxZoom,minZoom:t.options.minZoom},this.options),function(t){var e=("https:"===location.protocol?"https":"http")+"://",r=t.url.replace(/^(https?|ftp):\/\//,e);return t.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:t.name,attribution:t.copyright_text,maxZoom:t.z_max,minZoom:t.z_min}}(u)),u.origin_url&&(d=[],l=[u.origin_url.replace(/{switch:(.*?)}/,(function(t,e){return"string"==typeof e&&e.split(",").forEach((function(t){return d.push(t)})),"{s}"})),d],h=l[0],(f=l[1]).length&&(r.subdomains=f,r.url=h)),this.options=r,[2,new p(this.map,r).addLayer(r)]):[2]}var d,y,v}))}))},s}()}var Ne=function(){function t(t){this.options={url:"https://qms.nextgis.com"},this.options=n(n({},this.options),t),this.url=this.options.url}return t.prototype.getLayerAdapters=function(){var t=this;return Promise.resolve([{name:"QMS",createAdapter:function(e){return Promise.resolve(t._createAdapter(e))}}])},t.prototype._createAdapter=function(t){return Se(t,this.url)},t.utils={createQmsAdapter:Se},t}();var Te={},Re=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Be(t){var e=t.layerOptions,r=t.webMap,s=t.connector,a=t.item;return o(this,void 0,void 0,(function(){var t,o;return i(this,(function(i){switch(i.label){case 0:return[4,s.getResourceChildren(a.resource.id)];case 1:return t=i.sent(),(o=t&&t[0])?[2,je(n(n({},e),{resource:o.resource.id}),r,s)]:[2]}}))}))}function je(t,e,s){return o(this,void 0,void 0,(function(){var a,u,c,p,l,h,f,d,y,v,m,g,_,b;return i(this,(function(w){switch(w.label){case 0:return c=t.adapter,[4,Jt(t,s)];case 1:return(p=w.sent())?(l=t.resource)&&l.resource&&void 0!==l.resource.id?(u=l,[3,4]):[3,2]:[3,15];case 2:return[4,s.getResource(p)];case 3:u=w.sent(),w.label=4;case 4:return u?(h=u.resource.cls,f=n(n({},t),{resource:p}),d={layerOptions:f,webMap:e,connector:s,item:u},-1===Re.indexOf(h)?[3,12]:"webmap"!==h?[3,5]:(a=function(t){var e=t.layerOptions,n=t.webMap,s=t.connector;return o(this,void 0,void 0,(function(){var t;return i(this,(function(o){switch(o.label){case 0:return[4,Jt(e,s)];case 1:return t=o.sent(),[2,function(e){function o(r){return e.call(this,r,{url:"",webMap:n,resourceId:t,connector:s})||this}return r(o,e),o}(Ae)]}}))}))}(d),[3,11])):[3,14];case 5:if("vector_layer"!==h&&"postgis_layer"!==h)return[3,6];if(y=u.vector_layer&&qe[u.vector_layer.geometry_type],(v=d.layerOptions.adapterOptions||{}).type=v.type||y,d.layerOptions.adapterOptions=v,t.adapterOptions=d,void 0!==c&&"GEOJSON"!==c){if("MVT"!==c)return[2,Be(d)];a=pe(d)}else a=ue(d);return[3,11];case 6:return"raster_layer"!==h?[3,7]:[2,Be(d)];case 7:return"basemap_layer"!==h?[3,8]:(a=function(t){var e=t.webMap,s=t.item;return o(this,void 0,void 0,(function(){var t,a,u,c,p;return i(this,(function(l){if(s.basemap_layer){if(a=s.basemap_layer.url,t=s.basemap_layer.qms)return u=JSON.parse(t),[2,Promise.resolve(Ne.utils.createQmsAdapter(e,void 0,{qms:u,baselayer:!0}))];if(a&&(c=e.mapAdapter.layerAdapters.TILE))return p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.addLayer=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,t.prototype.addLayer.call(this,n(n({},e),{url:a}))]}))}))},e}(c),[2,p]}return[2]}))}))}(d),[3,11]);case 8:return"GEOJSON"!==c?[3,10]:[4,s.getResource(u.resource.parent.id)];case 9:return(m=w.sent())&&(g=n(n({},t),{resource:u.resource.parent.id}),a=ue(n(n({},d),{item:m,layerOptions:g}))),[3,11];case 10:a=pe(d),w.label=11;case 11:return[3,13];case 12:if(!Te[h])throw"Resource class '".concat(h,"' not yet supported.");_=Te[h],b=void 0,(b=c&&"function"!=typeof b?_[c]:_)&&(a=b(d)),w.label=13;case 13:return[3,15];case 14:throw"Resource item is not found";case 15:return a?[2,a.then((function(t){if(t){var e=t;return u&&(e.prototype.item=u,e.prototype.resourceId=u.resource.id,e.prototype.connector=s),S(e,[Wt],{replace:!1}),e}}))]:[2]}}))}))}function Fe(t,e){var r=t.bbox,n=t.width,o=t.height,i=t.nd;return{resource:Array.isArray(e)?e.join(","):e,extent:r,size:n+","+o,timestamp:Date.now(),nd:i}}var Ge,qe={POINT:"point",LINESTRING:"line",POLYGON:"polygon",MULTIPOINT:"point",MULTILINESTRING:"line",MULTIPOLYGON:"polygon",POINTZ:"point",LINESTRINGZ:"line",POLYGONZ:"polygon",MULTIPOINTZ:"point",MULTILINESTRINGZ:"line",MULTIPOLYGONZ:"polygon"};var De=function(){function t(t){if(this.options=t,this.options.connector)this.url=this.options.connector.options.baseUrl||"",this.connector=this.options.connector;else{if(!this.options.baseUrl)throw new Error("url is not defined");this.url=this.options.baseUrl,this.connector=new Dt({baseUrl:this.url,auth:this.options.auth})}}return t.addClassAdapters=function(t,e){Te[t]=e},t.prototype.onLoadSync=function(t){return o(this,void 0,void 0,(function(){var e,r,o;return i(this,(function(i){switch(i.label){case 0:if(!this.options.resourceId||!this.url)return[3,4];if(!(e=[this.options.resourceId]).length)return[3,4];r=0,o=e,i.label=1;case 1:return r<o.length?[4,t.addLayer(Ae,n({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},{resourceId:o[r],connector:this.connector,webMap:t}))]:[3,4];case 2:return[2,i.sent()];case 3:return r++,[3,1];case 4:return[2]}}))}))},t.prototype.getLayerAdapters=function(){return Promise.resolve([this._getLayerAdapter()])},t.prototype._getLayerAdapter=function(){var t=this;return{name:"WEBMAP",createAdapter:function(e){return Promise.resolve(t._createAdapter(e))}}},t.prototype._createAdapter=function(t){var e;return e={webMap:t,connector:this.connector,baseUrl:this.url},function(t){function o(r,o){return o=n(n({},e),o),t.call(this,r,o)||this}return r(o,t),o}(Ae)},t}(),Ve=function(){function t(t){var e=t.feature;this.id=e.id,this.geom=e.geom,this.label=e.label,this.parent=e.parent,this.fields=e.fields,this.layerId=e.layerId,this.connector=t.connector}return t.prototype.identify=function(t){var e=this;return void 0===t&&(t={}),this._item?k.resolve(this._item):Ue(n({connector:this.connector,featureId:this.id,resourceId:this.layerId,fields:null,extensions:["attachment","description"]},t)).then((function(t){return e._item=t,e.geom=t.geom,e.extensions=t.extensions,t}))},t.prototype.resource=function(){var t=this;return this._resource?k.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId).then((function(e){return t._resource=e,t._resource.feature_layer}))},t.prototype.getBounds=function(){return this._extent?k.resolve(this._extent):(t={connector:this.connector,featureId:this.id,resourceId:this.layerId}).connector.get("feature_layer.feature.item_extent",{cache:void 0===(e=t.cache)||e},{id:t.resourceId,fid:t.featureId}).then((function(t){if(t){var e=t.extent;return[e.minLon,e.minLat,e.maxLon,e.maxLat]}}));var t,e},t.prototype.geojson=function(){var t=this;return this._geojson?k.resolve(this._geojson):this.identify().then((function(e){return e.toGeojson().then((function(e){return t._geojson=e,e}))}))},t}(),ze="webmap-baselayer";function Ue(t){var e=n({},Qt);Xt(e,t);var r=n({id:t.resourceId,fid:t.featureId},e);return t.connector.get("feature_layer.feature.item",{cache:t.cache||!0},r).then((function(e){return n(n({},e),{toGeojson:function(){return e.geom?k.resolve(Kt(e)):Ue(n(n({},t),{geom:!0,fields:null,extensions:null})).then((function(t){var r=t.geom;return Kt(n(n({},e),{geom:r}))}))}})}))}function Ze(t){return Ue(t).then((function(t){return Kt(t)}))}function We(t,e){void 0===e&&(e=!1);var r=[],n=[];for(var o in t){var i=Number(o);isNaN(i)||r.push(i)}var s=t.resources;s&&r.sort((function(t,e){return s.indexOf(t)-s.indexOf(e)}));for(var a=0;a<r.length;a++){var u=t[o=r[a]];if("features"in u){var c=$e(u.features,Number(o),e);if(c.length&&(n.push.apply(n,c),!e))break}}return n}function $e(t,e,r){for(var n=[],o=0,i=t;o<i.length;o++){var s=i[o];if(n.push({featureId:s.id,resourceId:e,feature:s}),!r)break}return n}function He(t,e){B(t);var r=t.lngLat,o=e.geom,i=e.signal,s=e.cache,a=null!=o?o:function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n=6);for(var o=r/6371*q,i=o/Math.cos(e*G),s=[],a=0;a<n+1;a++){var u=Math.PI*(a/(n/2)),c=t+i*Math.cos(u),p=e+o*Math.sin(u);s.push([c,p])}return s}(r[0],r[1],e.radius);return function(t){var e=t.geom,r=t.signal,n=t.cache,o=[];if(Array.isArray(e))o=e;else{var i="Feature"===e.type?e.geometry:"Polygon"===e.type&&e;i&&(o=i.coordinates[0])}if(o){for(var s=[],a=0,u=o;a<u.length;a++){var c=u[a],p=D(c[0],c[1]);s.push(p[0]+" "+p[1])}var l="POLYGON((".concat(s.join(", "),"))");return t.connector.post("feature_layer.identify",{data:{geom:l,srs:3857,layers:t.layers},signal:r,cache:n})}throw new Error("Not valid geometry format to make intersection")}(n(n({},e),{geom:a,signal:i,cache:s}))}function Je(t,e){var r;return o(this,void 0,void 0,(function(){var n,o,s,a,u,c,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.get("pyramid.settings",null,{component:"pyramid"})];case 1:if(!((n=i.sent())&&n.company_logo&&n.company_logo.enabled))return[3,6];(o=document.createElement("a")).style.position="absolute",o.style.bottom="0",o.style.right="0",o.style.padding=null!==(r=null==e?void 0:e.padding)&&void 0!==r?r:"10px",o.className="ngw-map-logo",e&&e.cssClass&&(o.className+=" "+e.cssClass),(s=new Image).style.maxHeight="100px",s.style.maxWidth="100px",s.src="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,t.get("pyramid.company_logo",{responseType:"blob"})];case 3:return a=i.sent(),u=window.URL||window.webkitURL,c=u.createObjectURL(a),s.src=c,[3,5];case 4:return p=i.sent(),console.warn(p),[3,5];case 5: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),[2,o];case 6:return[2]}}))}))}var Qe={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'};function Ke(t){void 0===t&&(t={});var e=t.color||"blue",r=t.strokeColor||"white",n=t.size||12,o=n/2,i="number"==typeof t.stroke?t.stroke:.8,s=n/12,a=Qe[t.shape||"circle"]||"circle",u=function(t,e,r,n){void 0===r&&(r=0);var o=r/2,i='<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="'.concat(t,'"\n height="').concat(e,'"\n viewBox="-').concat(o," -").concat(o," ").concat(t+r," ").concat(e+r,'"\n >').concat(n,"</svg>");return(new DOMParser).parseFromString(i,"image/svg+xml").documentElement}(n,n,i*s,"string"==typeof a?a:a(t)),c=u.firstChild,p="scale(".concat(s,")");return c.setAttribute("fill",e),i&&(c.setAttribute("stroke",r),c.setAttribute("stroke-width",String(i))),c.setAttribute("transform",p),{type:"icon",iconSize:[n,n],iconAnchor:[o,o],html:(new XMLSerializer).serializeToString(u),svg:u}}function Xe(t,e,r,o){if("number"==typeof e||"string"==typeof e)e=Number(e),t.push(n(n({},r),{resource:e}));else if(Array.isArray(e)){var i=e[0],s=e[1];t.push(n(n(n({},r),{resource:i,id:s}),o))}else"object"==typeof e&&t.push(n(n(n({},r),e),o))}var Ye={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};var tr=function(t){function e(e){var r=t.call(this,function(t){var e=[new Ne];return t.starterKits&&t.starterKits.forEach((function(t){e.push(t)})),t.connector?t.connector&&(t.baseUrl=t.connector.options.baseUrl):t.connector=new Dt({baseUrl:t.baseUrl||"",auth:t.auth}),(t=R(Ye,t)).center||t.bounds||(t.bounds=[-179,-90,180,90]),t.connector&&e.push(new De({connector:t.connector,auth:t.auth})),n(n({},t),{starterKits:e,create:!1})}(e))||this;return r.emitter=new p.exports.EventEmitter,r._ngwLayers={},r._promises={select:[],identify:[]},e.connector&&(r.connector=e.connector),r._createWebMap().then((function(){var t=r.getContainer();t&&t.classList.add("ngw-map-container"),r.options.whitlabel&&r._whiteLabel()})),r}return r(e,t),e.prototype.addControl=function(e,r,n){return o(this,void 0,void 0,(function(){return i(this,(function(o){switch(o.label){case 0:return[4,this.onLoad("controls:create")];case 1:return o.sent(),[2,t.prototype.addControl.call(this,e,r,n)]}}))}))},e.prototype.addNgwLayer=function(t){return o(this,void 0,void 0,(function(){var e,r,o,s,a,u,c,p,l;return i(this,(function(i){switch(i.label){case 0:return[4,this.onMapLoad()];case 1:if(i.sent(),r=t.resourceId,((e=t.keyname)||void 0!==r)&&console.warn("DEPRECATED WARN: ".concat("set `resource` options instead of `keyname` or `resourceId`")),o=t.resource,!e&&!r&&!o)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(!N(this.options.baseUrl))return[3,5];i.label=2;case 2:return i.trys.push([2,4,,5]),N(this.options.setViewDelay)&&(t.adapterOptions=t.adapterOptions||{},N(t.adapterOptions.setViewDelay)||(t.adapterOptions.setViewDelay=this.options.setViewDelay)),s=function(t,e,r){var n=r.getAuthorizationHeaders();return n&&(t.headers=n),je(t,e,r)}(t,this,this.connector),a=n(n({visibility:!0},t),t.adapterOptions),[4,this.addLayer(s,a)];case 3:return u=i.sent(),c=u&&this.getLayerId(u),u&&c&&(this._ngwLayers[c]={layer:u,resourceId:u.resourceId},u.options.name=u.options.name||u.item&&u.item.resource.display_name,u.options.baselayer&&this.getActiveBaseLayer()),[2,u];case 4:return p=i.sent(),l=Z(o)&&"id"in o?o.id:e||r||o,console.error("Can't add NGW layer ".concat(l,"."),p),[3,5];case 5:return[2]}}))}))},e.prototype.fit=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;e?(this.setCenter(e),r&&this.setZoom(r)):n&&this.fitBounds(n)},e.prototype.fetchNgwLayerItem=function(t){return Ue(n({connector:this.connector},t))},e.prototype.fetchNgwLayerItems=function(t){return ie(n({connector:this.connector},t))},e.prototype.fetchNgwLayerFeature=function(t){return Ze(n({connector:this.connector},t))},e.prototype.fetchNgwLayerFeatures=function(t){return ae(n({connector:this.connector},t))},e.prototype.fetchIdentifyItem=function(t,e){var r,o,i,s=(o=(r={identify:t,connector:this.connector,requestOptions:e}).connector,(i=We(r.identify))&&i.length?Ue(n(n({connector:o},r.requestOptions),i[0])):k.resolve(void 0));return this._addPromise("identify",s),s},e.prototype.fetchIdentifyGeoJson=function(t,e){void 0===e&&(e=!1);var r=function(t){var e=t.connector,r=t.identify,o=t.requestOptions;for(var i in r){var s=Number(i);if(!isNaN(s)){var a=r[i];if("features"in a){var u=a.features.find((function(t){return t.geom}));if(u&&u.geom){var c=u.geom;return k.resolve(Kt(n(n({},u),{geom:c})))}}}}var p=We(r);return p&&p.length?Ze(n(n(n({},o),{connector:e}),p[0])):k.resolve(void 0)}({identify:t,connector:this.connector,multiple:e});return r&&"then"in r?(this._addPromise("identify",r),r):k.resolve(r)},e.prototype.getIdentifyGeoJson=function(t,e){return void 0===e&&(e=!1),this.fetchIdentifyGeoJson(t,e)},e.prototype.getNgwLayers=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.onLoad()];case 1:return t.sent(),[2,this._ngwLayers]}}))}))},e.prototype.getNgwLayerByResourceId=function(t){return o(this,void 0,void 0,(function(){var e,r,n,o,s,a,u;return i(this,(function(i){switch(i.label){case 0:for(r in e=[],this._ngwLayers)e.push(r);n=0,i.label=1;case 1:return n<e.length?(o=this._ngwLayers[e[n]]).resourceId!==t?[3,2]:[2,o&&o.layer]:[3,6];case 2:return o.layer.getIdentificationIds?[4,o.layer.getIdentificationIds()]:[3,4];case 3:if((s=i.sent())&&s.some((function(e){return e===t})))return[2,o.layer];i.label=4;case 4:if(o.layer.getDependLayers&&(a=o.layer.getDependLayers(),u=a.find((function(e){return e.item&&e.item.parentId===t}))))return[2,u.layer];i.label=5;case 5:return n++,[3,1];case 6:return[2]}}))}))},e.prototype.fitLayer=function(e,r){return o(this,void 0,void 0,(function(){var n,o,s,a,u=this;return i(this,(function(i){switch(i.label){case 0:return n="string"==typeof e||"number"==typeof e?String(n):e.id,(o=n&&this._ngwLayers[n])?o.layer.getBounds?[4,o.layer.getBounds()]:[3,2]:[3,7];case 1:return(s=i.sent())&&this.fitBounds(s,r),[3,6];case 2:return a=void 0,o.layer.item?(a=o.layer.item,[3,5]):[3,3];case 3:return[4,this.connector.getResource(o.resourceId)];case 4:a=i.sent(),i.label=5;case 5:a&&Zt(a,this.connector).then((function(t){t&&u.fitBounds(t,r)})),i.label=6;case 6:return[3,8];case 7:t.prototype.fitLayer.call(this,e,r),i.label=8;case 8:return[2]}}))}))},e.prototype.zoomToLayer=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.fitLayer(t)]}))}))},e.prototype.onLoad=function(e){return void 0===e&&(e="ngw-map:create"),t.prototype.onLoad.call(this,e)},e.prototype.removeLayer=function(e){var r=this.getLayer(e);if(r){var n=this.getLayerId(r);n&&delete this._ngwLayers[n],t.prototype.removeLayer.call(this,r)}},e.prototype.enableSelection=function(){var t=this;this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=function(e){t._getSelectListenersCount()&&t.selectFromNgwRaster(e)},this.$$selectFromNgwVector=function(e){t._getSelectListenersCount()&&t._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))},e.prototype.disableSelection=function(){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)},e.prototype.getNgwLayerItem=function(t){return this.fetchNgwLayerItem(t)},e.prototype.getNgwLayerItems=function(t){return this.fetchNgwLayerItems(t)},e.prototype.getNgwLayerFeature=function(t){return this.fetchNgwLayerFeature(t)},e.prototype.getNgwLayerFeatures=function(t){return this.fetchNgwLayerFeatures(t)},e.prototype.cancelPromise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.cancelPromises.apply(this,t)},e.prototype.cancelPromises=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];e.length||(e=Object.keys(this._promises)),e.forEach((function(e){var r=t._promises[e];r&&(r.forEach((function(t){return t.cancel()})),t._promises[e]=[])}))},e.prototype.selectFromNgwRaster=function(t){return o(this,void 0,void 0,(function(){var e,r,o,s,a,u,c,p,l,h,f,d,y,v,m,g,_=this;return i(this,(function(i){switch(i.label){case 0:for(this._emitStatusEvent("ngw:preselect"),e=[],(r=Object.values(this._ngwLayers)).sort((function(t,e){return t.layer.order&&e.layer.order?e.layer.order-t.layer.order:1})),o=0,s=r;o<s.length;o++)(u="function"==typeof(a=s[o].layer).getIdentificationIds&&a.getIdentificationIds)&&a.options.selectable&&this.isLayerVisible(a)&&e.push(u.call(a));return[4,Promise.all(e)];case 1:for(c=i.sent(),p=[],l=0,h=c;l<h.length;l++)(f=h[l])&&p.push.apply(p,f);return p.length?(d=this.options.pixelRadius||10,y=this.getCenter(),v=void 0!==(v=this.getZoom())?v:20,y&&v?(m=function(t,e,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*t[1]/Math.PI))/Math.pow(2,e+8))*5e-4}(y,v,d),g=He(t,{layers:p,connector:this.connector,radius:m}).then((function(e){var r=n(n({},e),{resources:p,sourceType:"raster",event:t}),o=_._prepareToIdentify(r);return _._emitStatusEvent("ngw:select",r),o})),this._addPromise("select",g),[2,g]):(this._emitStatusEvent("ngw:select",null),[2])):(this._emitStatusEvent("ngw:select",null),[2])}}))}))},e.prototype._addPromise=function(t,e){var r=this._promises[t];if(r&&-1===r.indexOf(e)){var n=function(){var t=r.indexOf(e);-1!==t&&r.splice(t,1)};e.then(n),e.catch(n),r.push(e)}},e.prototype._isFitFromResource=function(){var t=this._initMapState;return!t.zoom||!t.center},e.prototype._createWebMap=function(){return o(this,void 0,void 0,(function(){var t,e,r,n,o,s,a,u,c,p;return i(this,(function(i){switch(i.label){case 0:return[4,this.create()];case 1:if(i.sent(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer(),t=[],e=this._isFitFromResource(),this.options.webmapId&&Xe(t,this.options.webmapId,{fit:e}),this.options.resources&&Array.isArray(this.options.resources))for(r=0,n=this.options.resources;r<n.length;r++)o=n[r],s={},e||(s.fit=!1),Xe(t,o,{},s);a=0,u=t,i.label=2;case 2:if(!(a<u.length))return[3,7];c=u[a],i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.addNgwLayer(c)];case 4:return i.sent(),[3,6];case 5:return p=i.sent(),console.warn(p),[3,6];case 6:return a++,[3,2];case 7:return this._emitStatusEvent("ngw-map:create",this),this.enableSelection(),[2]}}))}))},e.prototype._addOsmBaseLayer=function(){this.addBaseLayer("OSM")},e.prototype._addQmsBaseLayer=function(){var t,e;Array.isArray(this.options.qmsId)?(t=this.options.qmsId[0],e=this.options.qmsId[1]):t=Number(this.options.qmsId);var r={qmsId:t};e&&(r.id=e),this.addBaseLayer("QMS",r)},e.prototype._selectFromNgwVector=function(t){var e,r=t.layer;if(r.options.selectable&&this.isLayerVisible(r)){var o=r.item&&r.item.resource.id,i=t.feature;if(void 0!==o&&i){var s=i.id;if(s){var a={id:Number(s),fields:i.properties||{},label:"#".concat(o),layerId:Number(o),parent:"",geom:i.geometry},u=((e={featureCount:1})[o]={featureCount:1,features:[a]},e);return this._emitStatusEvent("ngw:select",this._prepareToIdentify(n(n({},u),{resources:[o],sourceType:"vector"}))),u}}}},e.prototype._prepareToIdentify=function(t){var e=this;return n(n({},t),{getIdentifyItems:function(){return We(t,!0).map((function(t){return new Ve({feature:t.feature,connector:e.connector})}))}})},e.prototype._getSelectListenersCount=function(){return this.emitter.listenerCount("ngw:select")},e.prototype._whiteLabel=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return(t=this.getContainer())?[4,Je(this.connector,this.options.companyLogoOptions)]:[3,2];case 1:(e=r.sent())&&t.appendChild(e),r.label=2;case 2:return[2]}}))}))},e.getIcon=Ke,e}(Ot);return t.NgwMap=tr,t.WebMap=Ot,t.WebMapControls=bt,t.WebMapLayers=gt,t.WebMapMain=mt,t.createNgwMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new tr(t).onLoad()]}))}))},t.createToggleControl=_t,t.createWebMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Ot(t).onLoad()]}))}))},t.detectGeometryType=st,t.findMostFrequentGeomType=it,t.getWebMap=Lt,t.updateGeoJsonAdapterOptions=ct,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
2
2
  //# sourceMappingURL=ngw-map.global.prod.js.map