@nextgis/geocoder 3.0.0-alpha.17 → 3.0.0-alpha.18

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,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.16; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.17; author: NextGIS */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.16; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.17; author: NextGIS */
2
2
  function defined(val) {
3
3
  return val !== void 0 && val !== null;
4
4
  }
@@ -1017,7 +1017,7 @@ function unwrapListeners(arr) {
1017
1017
 
1018
1018
  var pkg = {
1019
1019
  name: "@nextgis/ngw-connector",
1020
- version: "3.0.0-alpha.16",
1020
+ version: "3.0.0-alpha.17",
1021
1021
  _priority: 12,
1022
1022
  description: "A lightweight HTTP client optimized for use with NextGIS Web API",
1023
1023
  main: "index.js",
@@ -1026,15 +1026,15 @@ var pkg = {
1026
1026
  jsdelivr: "lib/ngw-connector.global.prod.js",
1027
1027
  types: "lib/index.d.ts",
1028
1028
  dependencies: {
1029
- "@nextgis/cache": "^3.0.0-alpha.13",
1030
- "@nextgis/cancelable-promise": "^3.0.0-alpha.13",
1031
- "@nextgis/utils": "^3.0.0-alpha.13",
1029
+ "@nextgis/cache": "^3.0.0-alpha.17",
1030
+ "@nextgis/cancelable-promise": "^3.0.0-alpha.17",
1031
+ "@nextgis/utils": "^3.0.0-alpha.17",
1032
1032
  "@types/events": "^3.0.0",
1033
1033
  events: "*",
1034
1034
  "form-data": "^4.0.0"
1035
1035
  },
1036
1036
  devDependencies: {
1037
- "@nextgis/build-tools": "^3.0.0-alpha.13"
1037
+ "@nextgis/build-tools": "^3.0.0-alpha.17"
1038
1038
  },
1039
1039
  scripts: {
1040
1040
  clean: "rimraf ./lib",
@@ -1,2 +1,2 @@
1
- function e(e){return null!=e}function t(t){return"string"==typeof t?!!t:e(t)}function r(e,t,r,o){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===o:n(e,t));return e===t}function n(e,t){const n=Object.keys(e).sort(),o=Object.keys(t).sort();if(n.length!==o.length)return!1;if(n.join("")!==o.join(""))return!1;for(let s=0;s<n.length;s++){if(!r(e[n[s]],t[o[s]],e,t))return!1}return!0}function o(e){const t={};return Object.keys(e).forEach((r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=o(e[r])})),t}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function i(e){return e.replace(/([^:]\/)\/+/g,"$1")}class a{constructor(e){e&&function(e,...t){for(const r of t)for(const t of Object.getOwnPropertyNames(r))e[t]=r[t]}(this,e)}}var c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),y=(e,t,r)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,m=(e,t)=>{for(var r in t||(t={}))f.call(t,r)&&y(e,r,t[r]);if(h)for(var r of h(t))p.call(t,r)&&y(e,r,t[r]);return e},v=(e,t)=>l(e,u(t)),g=function(e,t){this[0]=e,this[1]=t},b=(e,t,r)=>{var n=(e,t,o,s)=>{try{var i=r[e](t),a=(t=i.value)instanceof g,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?n("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,o,s):o({value:r,done:c}))).catch((e=>n("throw",e,o,s)))}catch(l){s(l)}},o=e=>s[e]=t=>new Promise(((r,o)=>n(e,t,r,o))),s={};return r=r.apply(e,t),s[d("asyncIterator")]=()=>s,o("next"),o("throw"),o("return"),s},w=(e,t,r)=>(t=e[d("asyncIterator")])?t.call(e):(e=e[d("iterator")](),t={},(r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,s)=>(t=n.call(e,t),s=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:s})),o))))))("next"),r("return"),t);let O=0;class x extends a{constructor(e){super(e),y(this,"providers"+"",[]),e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach((e=>{e.abort&&e.abort()}))}search(e){return b(this,null,(function*(){this.abort();let t=!0;const r=[];for(const c of this.providers)try{const r=c.search(e);try{for(var n,o,s,i=w(r);n=!(o=yield new g(i.next())).done;n=!1){const e=o.value;t=!1,yield v(m({},e),{provider:c,_id:O++})}}catch(o){s=[o]}finally{try{n&&(o=i.return)&&(yield new g(o.call(i)))}finally{if(s)throw s[0]}}}catch(a){"AbortError"!==a.name&&r.push(a)}if(t&&r.length)throw new Error(`All providers failed: ${r.map((e=>e.message)).join("; ")}`)}))}result(e){return e.provider?e.provider.result(e):Promise.resolve(void 0)}reverse(e){return b(this,null,(function*(){for(const i of this.providers)if(i.reverse)try{const s=i.reverse(e);try{for(var t,r,n,o=w(s);t=!(r=yield new g(o.next())).done;t=!1){const e=r.value;yield v(m({},e),{provider:i,_id:O++})}}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield new g(r.call(o)))}finally{if(n)throw n[0]}}}catch(s){}}))}reverseGeocodeFirstResult(e){return t=this,r=null,n=function*(){for(const i of this.providers)if("function"==typeof i.reverse)try{try{for(var t,r,n,o=w(i.reverse(e));t=!(r=yield o.next()).done;t=!1)return r.value}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n[0]}}}catch(s){console.error("Error in reverse geocoding:",s)}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}}var j=Object.defineProperty,P=(e,t,r)=>((e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class _ extends a{constructor(){super(...arguments),P(this,"searchUrl"),P(this,"label")}}const E=/\{ *([\w_-]+) *\}/g;function C(e,t){return e.replace(E,((e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n}))}var I=Object.defineProperty,k=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,T=(e,t,r)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function L(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,s=yield n.connect();let i=s&&s[r];if(i){i=[...i];let e=i.shift();if(i.length){const r={};for(let e=0;e<i.length;e++){const n=i[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=C(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach((([e,t])=>{r.push(`${e}=${t}`)}));for(const e in t)-1===i.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))R.call(t,r)&&T(e,r,t[r]);if(k)for(var r of k(t))S.call(t,r)&&T(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}var A=Object.defineProperty,U=(e,t,r)=>((e,t,r)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const $=class e{constructor(t={}){var r;U(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,r,n,s,i){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,s=a.onlyFull,i=a.expirationTime,c=a.props):c=n;const l=this._find(e,c);if(l)return l.value;{let n;n=r instanceof Function?r():r;const a=c&&JSON.parse(JSON.stringify(o(c)));i=i?Date.now()+i:void 0;const l={key:e,value:n,props:a,expirationTime:i};return s&&!t(n)?n:(this.cache.push(l),n instanceof Promise?(n.catch((()=>{this.delete(e,c)})),s&&n.then((r=>(t(r)||this.delete(e,c),r))),n):n)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach((e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)})),e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){const r="string"==typeof e?this.cache.filter((r=>this._filter(r,e,t))):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find((r=>this._filter(r,e,t)))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return n(e.props||{},o(r))}};U($,"instance",{});let q=$;function N(){}function F(){F.init.call(this)}function D(e){return void 0===e._maxListeners?F.defaultMaxListeners:e._maxListeners}function M(e,t,r,n){var o,s,i,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]):(s=e._events=new N,e._eventsCount=0),i){if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),!i.warned&&(o=D(e))&&o>0&&i.length>o){i.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=i.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else i=s[t]=r,++e._eventsCount;return e}function B(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function G(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function H(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}N.prototype=Object.create(null),F.EventEmitter=F,F.usingDomains=!1,F.prototype.domain=void 0,F.prototype._events=void 0,F.prototype._maxListeners=void 0,F.defaultMaxListeners=10,F.init=function(){this.domain=null,F.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new N,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},F.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},F.prototype.getMaxListeners=function(){return D(this)},F.prototype.emit=function(e){var t,r,n,o,s,i,a,c="error"===e;if(i=this._events)c=c&&null==i.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=i[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=H(e,n),s=0;s<n;++s)o[s].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,s=H(e,o),i=0;i<o;++i)s[i].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var s=e.length,i=H(e,s),a=0;a<s;++a)i[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,s){if(t)e.call(r,n,o,s);else for(var i=e.length,a=H(e,i),c=0;c<i;++c)a[c].call(r,n,o,s)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),s=1;s<n;s++)o[s-1]=arguments[s];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,s=H(e,o),i=0;i<o;++i)s[i].apply(r,n)}(r,u,this,o)}return!0},F.prototype.on=F.prototype.addListener=function(e,t){return M(this,e,t,!1)},F.prototype.prependListener=function(e,t){return M(this,e,t,!0)},F.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,B(this,e,t)),this},F.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,B(this,e,t)),this},F.prototype.removeListener=function(e,t){var r,n,o,s,i;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new N:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new N,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,i||t)}return this},F.prototype.off=function(e,t){return this.removeListener(e,t)},F.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new N,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new N:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),s=0;s<o.length;++s)"removeListener"!==(n=o[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new N,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},F.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},F.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):G.call(e,t)},F.prototype.listenerCount=G,F.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var z="3.0.0-alpha.16";class J extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var Q=Object.defineProperty,W=(e,t,r)=>((e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class K extends Error{constructor(e){super(),W(this,"name","NgwError"),W(this,"title"),W(this,"message"),W(this,"detail"),W(this,"exception"),W(this,"status_code"),W(this,"data"),W(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,K.prototype)}}var V=Object.defineProperty,Y=(e,t,r)=>((e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class X extends K{constructor(e){super(e),Y(this,"name","InsufficientPermissionsError"),Y(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,X.prototype)}}var Z=Object.defineProperty,ee=(e,t,r)=>((e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let te=class e extends K{constructor(t){super(t),ee(this,"message","There is no response from the server or problem connecting to server."),ee(this,"title","Network error"),ee(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var re=Object.defineProperty,ne=(e,t,r)=>((e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class oe extends Error{constructor(e){super(),ne(this,"name","NetworkError"),Object.setPrototypeOf(this,oe.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var se=Object.defineProperty,ie=(e,t,r)=>((e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ae extends K{constructor(e){super(e),ie(this,"name","ResourceNotFoundError"),ie(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ae.prototype)}}var ce=Object.freeze({__proto__:null,AbortError:J,InsufficientPermissionsError:X,NetworkError:oe,NetworksResponseError:te,NgwError:K,ResourceNotFoundError:ae,extractError:function(e){if(s(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new te({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!s(e)&&(e.status_code&&e.exception&&e.title)}}),le=Object.defineProperty,ue=(e,t,r)=>((e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class he extends Error{constructor(e){super(e||"Something went wrong."),ue(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,he)}}class fe extends he{constructor(e){super(e||"There is no response from the server or problem connecting to server."),ue(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class pe extends he{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class de extends he{constructor(e){super(e.message),ue(this,"detail"),ue(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ye extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),ue(this,"title"),ue(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ye)}}class me extends ye{constructor(e){super("Long-running request was cancelled.",e)}}class ve extends ye{constructor(e){super(void 0,e)}}var ge=Object.defineProperty,be=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,je=(e,t)=>{for(var r in t||(t={}))we.call(t,r)&&xe(e,r,t[r]);if(be)for(var r of be(t))Oe.call(t,r)&&xe(e,r,t[r]);return e},Pe=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));function _e(e){return Pe(this,null,(function*(){const t=yield function(e){return Pe(this,null,(function*(){try{return e.json()}catch(t){throw new Error}}))}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,s=`/api/lunkwill/${t.id}/response`,i=e=>new Promise((t=>setTimeout(t,e)));let a=!1,c=!1;for(;!c;){let e,t;yield i(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(l){a=!0;continue}switch(t.status){case void 0:throw new ye(void 0,t);case"ready":c=!0;break;case"cancelled":throw new me(t);case"failed":throw new ve(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ye(void 0,t)}}return s}))}const Ee=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function Ce(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function Ie(e,t,r){return Pe(this,null,(function*(){var n,s;const i=je(je({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:l,cacheName:u,lunkwill:h,cache:f,query:p,json:d}=i,y=((e,t)=>{var r={};for(var n in e)we.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&be)for(var n of be(e))t.indexOf(n)<0&&Oe.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),a&&(y.credentials="include");let m=!1;void 0!==h&&(h.toHeaders(y.headers||{}),m=!0);const v=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=Ce(e,p),b=()=>Pe(this,null,(function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new fe}if(m&&function(e){const t=e.headers.get("content-type");return null!=t&&t.includes("application/vnd.lunkwill.request-summary+json")}(e)){const t=yield _e(e);if(v)return t;e=yield function(e){return Pe(this,null,(function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new fe}}))}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&Ee.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new pe;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof pe)throw o;throw new pe}if(400<=e.status&&e.status<=599)throw new de(n);return n}));if(r)if("GET"===(null==(s=y.method)?void 0:s.toUpperCase())){if(!1!==f){const e=l||je({},o({withCredentials:a,responseType:c}));return r.add(u||g,b,{props:e,expirationTime:f?void 0:500})}}else{["api/feature_layer/identify"].every((t=>!e.includes(t)))&&r.clean()}return b()}))}var ke=Object.defineProperty,Re=Object.defineProperties,Se=Object.getOwnPropertyDescriptors,Te=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,Ue=(e,t,r)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t)=>{for(var r in t||(t={}))Le.call(t,r)&&Ue(e,r,t[r]);if(Te)for(var r of Te(t))Ae.call(t,r)&&Ue(e,r,t[r]);return e},qe=(e,t)=>{var r={};for(var n in e)Le.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Te)for(var n of Te(e))t.indexOf(n)<0&&Ae.call(e,n)&&(r[n]=e[n]);return r};function Ne(e,t,r,...n){const[o,...s]=r[e],a=n[0];let c;if(void 0===a)c=[];else if("object"==typeof a&&null!==a){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");c=[];for(const[e,t]of Object.entries(a))c[s.indexOf(e)]=String(t)}else c=n.map((e=>String(e)));return i(t+o.replace(/\{(\w+)\}/g,(function(e,t){const r=parseInt(t),n=c[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)})))}function Fe(e,t,...r){const n={url:n=>{return o=this,s=null,i=function*(){var o;const s=yield t.connect();return Ce(Ne(e,null!=(o=t.options.baseUrl)?o:"",s,...r),null==n?void 0:n.query)},new Promise(((e,t)=>{var r=e=>{try{a(i.next(e))}catch(r){t(r)}},n=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((i=i.apply(o,s)).next())}));var o,s,i}},s=["get","post","put","delete","patch"];for(const i of s){const s=n=>{var s;const a=n||{},{headers:c}=a,l=qe(a,["headers"]);if(null==(s=null==n?void 0:n.signal)?void 0:s.aborted)throw new J;return t.connect().then((n=>{var s;const a=Ne(e,null!=(s=t.options.baseUrl)?s:"",n,...r),u=o($e($e({},t.getAuthorizationHeaders()),null!=c?c:{}));return Ie(a,(h=$e({headers:u},l),Re(h,Se({method:i}))),t.cache);var h}))};n[i]=s}return n}function De(e){return"[object Object]"===Object.prototype.toString.call(e)}let Me;Me=(e,t,r={},n,o)=>{r.method=r.method||"GET";const s=new XMLHttpRequest;s.open(r.method||"GET",e,!0),"blob"===r.responseType&&(s.responseType=r.responseType);const i=()=>{try{return JSON.parse(s.responseText)}catch(e){return s.responseText}};s.onload=()=>{-1!==[401,403,404,422,500].indexOf(s.status)&&n(new K(i())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(s.response):s.responseText?o(i()):n({message:""})})()},s.onerror=t=>{n(0===s.status?new oe(e):t)},s.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const l in a){const e=a[l];"string"==typeof e&&s.setRequestHeader(l,e)}let c;if(void 0!==r.withCredentials&&(s.withCredentials=r.withCredentials),r.file){if(c=new FormData,c.append("file",r.file),r.data)for(const l in r.data)c.append(l,c[l])}else c=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{s.abort()})),s.send(c)};const Be=[];function Ge(e){Be.push(e)}var He=Object.defineProperty,ze=Object.defineProperties,Je=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,Ve=(e,t,r)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ye=(e,t)=>{for(var r in t||(t={}))We.call(t,r)&&Ve(e,r,t[r]);if(Qe)for(var r of Qe(t))Ke.call(t,r)&&Ve(e,r,t[r]);return e},Xe=(e,t,r)=>Ve(e,"symbol"!=typeof t?t+"":t,r),Ze=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));let et=0,tt=0;class rt{constructor(e){this.options=e,Xe(this,"id",et++),Xe(this,"emitter",new F),Xe(this,"user"),Xe(this,"cache"),Xe(this,"withCredentials"),Xe(this,"routeCache"),Xe(this,"client",`NextGIS-NGW-Connector/${z}`),Xe(this,"routeStr","/api/component/pyramid/route"),Xe(this,"activeRequests",{}),Xe(this,"requestTransform");const t=function(e){return Be.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return n(t.options.auth,e.auth)}}))}(e);if(this.cache=new q({namespace:e.cacheId}),this.routeCache=new q({namespace:"routecache"}),t)return t;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),Ge(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Ge(this)}connect(){return Ze(this,arguments,(function*({signal:e}={}){const t=this.options.auth;if(t){const{login:e,password:r}=t;e&&r&&(yield this._login({login:e,password:r}))}const r=`${this.routeStr}?client=${this.client}`;return this.routeCache.add(this.options.baseUrl||String(this.id),(()=>this.makeQuery(r,null,{signal:e,cache:!1})))}))}login(e,t){return this.logout(),Ge(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Be.indexOf(e);-1!==t&&Be.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return Ze(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ye({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Ye({},this.activeRequests)}route(e,...t){return Fe(e,this,...t)}makeQuery(e,t){return Ze(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)We.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Qe)for(var n of Qe(e))t.indexOf(n)<0&&Ke.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=C(e,r)}e=encodeURI(i(e)),r=Ye({withCredentials:this.withCredentials},r);const{cache:s,signal:a,method:c="GET",headers:l,cacheName:u,cacheProps:h,responseType:f,withCredentials:p}=r,d=new AbortController,y=d.signal;if(a){if(a.aborted)throw new J;a.addEventListener("abort",(()=>{d.abort()}))}r.signal=y;const m=()=>Ze(this,null,(function*(){const t=tt++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if("GET"===c&&!1!==s){const r=h||(v=Ye({},o({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),ze(v,Je({params:t})));return this.cache.add(u||e,m,{props:r,expirationTime:s?void 0:500})}var v;return m()}))}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Ye(Ye({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let s;Me(e,r,t,n,(e=>{s=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==s&&s(),n(new J)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return Ze(this,null,(function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}}))}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof K){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ae(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new X(e)}return e}}Xe(rt,"errors",ce);const nt=["description"];function ot(t,r=""){r=r?r+"__":"";const n={};for(const[o,s]of Object.entries(t))if(-1===nt.indexOf(o))if(De(s))if("owner_user"===o){const e=ot(s,o);Object.assign(n,e)}else"parent"===o&&"id"in s&&(n.parent_id=s.id);else e(s)&&(n[r+o]=s);return n}var st=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ht=(e,t,r)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&ht(e,r,t[r]);if(ct)for(var r of ct(t))ut.call(t,r)&&ht(e,r,t[r]);return e},pt=(e,t)=>it(e,at(t)),dt=(e,t,r)=>ht(e,"symbol"!=typeof t?t+"":t,r),yt=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));class mt{constructor({connector:e,cacheId:t}){dt(this,"cache"),dt(this,"connector"),this.connector=e,this.cache=new q({namespace:t})}getOne(e,t){const r=ft({},t);return"string"==typeof e||"number"==typeof e||De(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):De(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new ae}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||De(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then((e=>{if(void 0===e)throw new Error;return e}))}getMany(e,t){return this._resourceCacheFilter(e).then((r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,ot(e)),this.connector.route("resource.search").get(pt(ft({},t),{query:ft({serialization:"full"},r)})).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)}))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t){return yt(this,arguments,(function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(pt(ft({},t),{query:{parent:n}})),s=[];for(const i of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(i),{id:i.resource.id}),r.push(i),(null==t?void 0:t.recursive)&&i.resource.children&&s.push(this._getChildrenOf(i.resource.id,t,r));return s.length?Promise.all(s).then((()=>r)):r}))}_cleanResourceItemCache(e){return yt(this,null,(function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)}))}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(t){return Promise.all(this.cache.matchAll("resource.item")).then((r=>(r.filter((r=>{if(r)return t.keyname&&r.resource.keyname?t.keyname===r.resource.keyname:e(t.id)&&e(r.resource.id)?t.id===r.resource.id:n(t,r.resource)})),[])))}}var vt=Object.defineProperty,gt=(e,t,r)=>((e,t,r)=>t in e?vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class bt extends rt{constructor(e){super(e),gt(this,"resources"),this.resources=new mt({connector:this,cacheId:e.cacheId})}static create(e){return new this(e)}clearCache(){super.clearCache(),this.resources.cache.clean()}apiRequest(e,t={},r={}){var n;return L({name:e,params:o(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}function wt(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const Ot={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>wt(e,t),ilike:(e,t)=>wt(e,t,!0)};function xt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function jt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(xt(t)){const[r,n,o]=t,s=Ot[n];if(s){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,s)=>(t=e[s],r.replace(s,o))));return s(t,n)}return s(e[r],o)}return!1}return jt(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}const Pt=7e3;var _t=Object.defineProperty,Et=Object.defineProperties,Ct=Object.getOwnPropertyDescriptors,It=Object.getOwnPropertySymbols,kt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,St=(e,t,r)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))kt.call(t,r)&&St(e,r,t[r]);if(It)for(var r of It(t))Rt.call(t,r)&&St(e,r,t[r]);return e},Lt=(e,t)=>Et(e,Ct(t));const At={srs:4326,geom_format:"geojson",dt_format:"iso"};function Ut(e){return t=this,r=null,n=function*(){const t=qt(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}function $t(e){const[t,r,n]=e;let o="",s="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,s=n,r)))}__${r}`,o+n+s]}function qt(e,t=[],r=[]){var n;const{filters:o}=e,s=null!=(n=e.paramList)?n:[],i="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===i)for(const c of a)xt(c)?t.push(Ft(Lt(Tt({},e),{paramList:[...r,...s,$t(c)]}))):qt(Lt(Tt({},e),{filters:c}),t,[...r]);else if("all"===i){const n=[],o=[];for(const e of a)xt(e)?n.push($t(e)):o.push(e);if(o.length)for(const s of o)qt(Lt(Tt({},e),{filters:s}),t,[...r,...n]);else t.push(Ft(Lt(Tt({},e),{paramList:[...r,...s,...n]})))}return t}function Nt(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=function(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function Ft(t){const r=Tt({},At),{limit:n,query:o,cache:s,signal:i,offset:a,orderBy:c,paramList:l,connector:u,geomFormat:h,intersects:f,resourceId:p}=t;if(r.limit=n&&n!==Number.POSITIVE_INFINITY?n:Pt,a&&(r.offset=a),h&&(r.geom_format=h),function(t,r){const{extensions:n,geom:o,fields:s,srs:i,ilike:a,like:c}=r;t.extensions=n||[],s&&(t.fields=s),void 0!==o&&(t.geom=o,o||(delete t.srs,delete t.geom_format)),e(a)?t.ilike=a:e(c)&&(t.like=c),e(i)&&(t.srs=i)}(r,t),c&&(r.order_by=c.join(",")),Array.isArray(f)){const e=(d=f,Array.isArray(d)&&4===d.length&&d.every((e=>"number"==typeof e))?function(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}(f):f);r.intersects=Nt(e)}else"string"==typeof f&&(r.intersects=f);var d;return l&&Object.assign(r,function(e){return e.reduce(((e,[t,r])=>(e[t]=r,e)),{})}(l)),u.route("feature_layer.feature.collection",{id:Number(p)}).get({query:Tt(Tt({},r),o),cache:s,signal:i})}var Dt=Object.defineProperty,Mt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,Gt=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable,Jt=(e,t,r)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qt=(e,t)=>{for(var r in t||(t={}))Ht.call(t,r)&&Jt(e,r,t[r]);if(Gt)for(var r of Gt(t))zt.call(t,r)&&Jt(e,r,t[r]);return e},Wt=(e,t)=>Mt(e,Bt(t));function Kt(t){return r=this,n=null,o=function*(){var r;const n=t.filters;if(n){let o=yield Ut(Wt(Qt({},t),{filters:n}));return(null!=(r=t.clientFilterValidate)?r:Vt(n))&&(o=o.filter((t=>jt(function(t){let r;for(r in t){const n=t[r];if(s(n)){const o=n;if(e(o.year)&&e(o.month)&&e(o.day)){const e=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach((t=>{e.push(t)})),t[r]=new Date(...e).toISOString()}}else"id"===r&&"string"==typeof n&&(t[r]=n.split(",").map(Number))}return t}(Wt(Qt({},t.fields),{id:t.id})),n)))),o}return Ft(t)},new Promise(((e,t)=>{var s=e=>{try{a(o.next(e))}catch(r){t(r)}},i=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((o=o.apply(r,n)).next())}));var r,n,o}function Vt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(Vt(r))return!0}}return!1}var Yt=Object.defineProperty,Xt=Object.getOwnPropertySymbols,Zt=Object.prototype.hasOwnProperty,er=Object.prototype.propertyIsEnumerable,tr=(e,t,r)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rr=(e,t,r)=>tr(e,"symbol"!=typeof t?t+"":t,r),nr=function(e,t){this[0]=e,this[1]=t},or=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof nr,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};const sr=class e extends _{constructor(e){var t;if(super(e),rr(this,"searchResources",[]),rr(this,"connector"),rr(this,"_abortControllers",[]),!e.searchUrl&&!(null==(t=e.connectorOptions)?void 0:t.baseUrl))throw new Error("The `searchUrl` of `connectorOptions.baseUrl` are required");this.connector=e.connector||new bt(((e,t)=>{for(var r in t||(t={}))Zt.call(t,r)&&tr(e,r,t[r]);if(Xt)for(var r of Xt(t))er.call(t,r)&&tr(e,r,t[r]);return e})({baseUrl:this.searchUrl},e.connectorOptions)),this.searchResources=e.searchResources}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers.length=0}search(t){return or(this,null,(function*(){var r,n;const o=this._makeSignal();for(const i of this.searchResources){if(o.aborted)break;const{searchMethod:a}=i,c=null!=(r=i.limit)?r:e.limit,l=null!=(n=i.id)?n:i.resourceId;try{const e=yield new nr(this.connector.getResourceOrFail(l,{cache:!0})),r={connector:this.connector,resourceId:l,signal:o,limit:c};"like"===a?r.like=t:r.ilike=t;const n=Kt(r),s=yield new nr(n);for(const o of this._items({entries:s,query:t,config:i,resourceItem:e}))o.result=()=>this.result(o),yield o}catch(s){s&&"name"in s&&"AbortError"!==s.name&&console.warn(s)}}}))}result(e){const t=this._makeSignal();return this.connector.route("feature_layer.feature.item_extent",{id:e.resourceId,fid:e.featureId}).get({signal:t}).then((t=>{const r=t.extent;return{text:e.text,extent:[r.minLon,r.minLat,r.maxLon,r.maxLat]}}))}reverse(e){return or(this,null,(function*(){throw new Error("Not implemented")}))}_makeSignal(){const e=new AbortController;return this._abortControllers.push(e),e.signal}_items({entries:e,query:t,config:r,resourceItem:n}){var o;const s=[];let i;n.feature_layer&&(i=null==(o=n.feature_layer.fields.find((e=>e.label_field)))?void 0:o.keyname);return this.searchResources.find((e=>{var t;return null!=(t=e.id)?t:e.resourceId===n.resource.id}))&&e.forEach((e=>{let o=i?e.fields[i]:e.id;r.renderSearch?o=r.renderSearch({item:e,resourceItem:n}):i&&(o=e.fields[i]),s.push({query:t,text:o,featureId:e.id,resourceId:n.resource.id,item:e,resourceItem:n})})),s}};rr(sr,"limit",300);let ir=sr;var ar=Object.defineProperty,cr=(e,t,r)=>((e,t,r)=>t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),lr=function(e,t){this[0]=e,this[1]=t},ur=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof lr,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};class hr extends _{constructor(e){super(),this.options=e,cr(this,"searchUrl","https://nominatim.openstreetmap.org"),cr(this,"_abortControllers",[]),e&&e.searchUrl&&(this.searchUrl=e.searchUrl)}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers=[]}search(e){return ur(this,null,(function*(){var t,r,n,o,s,a,c;const l=new URLSearchParams({format:"geojson",polygon_geojson:"1",q:e,limit:(null==(r=null==(t=this.options)?void 0:t.limit)?void 0:r.toString())||"10"});if((null==(n=this.options)?void 0:n.countrycodes)&&l.append("countrycodes",this.options.countrycodes),(null==(o=this.options)?void 0:o.addressdetails)&&l.append("addressdetails","1"),(null==(s=this.options)?void 0:s.language)&&l.append("accept-language",this.options.language),(null==(a=this.options)?void 0:a.bounded)&&l.append("bounded","1"),null==(c=this.options)?void 0:c.viewbox){const[e,t,r,n]=this.options.viewbox;l.append("viewbox",`${e},${t},${r},${n}`)}const u=i(`${this.searchUrl}/search?${l.toString()}`),h=new AbortController;this._abortControllers.push(h);try{const t=yield new lr(fetch(u,{signal:h.signal}));if(!t.ok)throw new Error(`Network response was not ok: ${t.statusText}`);const r=(yield new lr(t.json())).features.map((t=>({geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:e})));for(const e of r)e.result=()=>this.result(e),yield e}catch(f){if("AbortError"!==f.name)throw f}}))}result(e){return Promise.resolve({text:e.text,extent:e.extent||[],geom:e.geom})}reverse(e){return ur(this,null,(function*(){var t,r;const[n,o]=e,s=new URLSearchParams({format:"geojson",lat:o.toString(),lon:n.toString()});(null==(t=this.options)?void 0:t.addressdetails)&&s.append("addressdetails","1"),(null==(r=this.options)?void 0:r.language)&&s.append("accept-language",this.options.language);const a=i(`${this.searchUrl}/reverse?${s.toString()}`),c=new AbortController;this._abortControllers.push(c);try{const e=yield new lr(fetch(a,{signal:c.signal}));if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);const t=(yield new lr(e.json())).features[0],r={geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:`${o}, ${n}`};r.result=()=>this.result(r),yield r}catch(l){if("AbortError"!==l.name)throw l}}))}}function fr(e){return new x(e)}export{_ as BaseProvider,x as Geocoder,ir as NgwProvider,hr as NominatimProvider,fr as create};
1
+ function e(e){return null!=e}function t(t){return"string"==typeof t?!!t:e(t)}function r(e,t,r,o){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===o:n(e,t));return e===t}function n(e,t){const n=Object.keys(e).sort(),o=Object.keys(t).sort();if(n.length!==o.length)return!1;if(n.join("")!==o.join(""))return!1;for(let s=0;s<n.length;s++){if(!r(e[n[s]],t[o[s]],e,t))return!1}return!0}function o(e){const t={};return Object.keys(e).forEach((r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=o(e[r])})),t}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function i(e){return e.replace(/([^:]\/)\/+/g,"$1")}class a{constructor(e){e&&function(e,...t){for(const r of t)for(const t of Object.getOwnPropertyNames(r))e[t]=r[t]}(this,e)}}var c=Object.defineProperty,l=Object.defineProperties,u=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,d=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),y=(e,t,r)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,m=(e,t)=>{for(var r in t||(t={}))f.call(t,r)&&y(e,r,t[r]);if(h)for(var r of h(t))p.call(t,r)&&y(e,r,t[r]);return e},v=(e,t)=>l(e,u(t)),g=function(e,t){this[0]=e,this[1]=t},b=(e,t,r)=>{var n=(e,t,o,s)=>{try{var i=r[e](t),a=(t=i.value)instanceof g,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?n("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,o,s):o({value:r,done:c}))).catch((e=>n("throw",e,o,s)))}catch(l){s(l)}},o=e=>s[e]=t=>new Promise(((r,o)=>n(e,t,r,o))),s={};return r=r.apply(e,t),s[d("asyncIterator")]=()=>s,o("next"),o("throw"),o("return"),s},w=(e,t,r)=>(t=e[d("asyncIterator")])?t.call(e):(e=e[d("iterator")](),t={},(r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,s)=>(t=n.call(e,t),s=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:s})),o))))))("next"),r("return"),t);let O=0;class x extends a{constructor(e){super(e),y(this,"providers"+"",[]),e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach((e=>{e.abort&&e.abort()}))}search(e){return b(this,null,(function*(){this.abort();let t=!0;const r=[];for(const c of this.providers)try{const r=c.search(e);try{for(var n,o,s,i=w(r);n=!(o=yield new g(i.next())).done;n=!1){const e=o.value;t=!1,yield v(m({},e),{provider:c,_id:O++})}}catch(o){s=[o]}finally{try{n&&(o=i.return)&&(yield new g(o.call(i)))}finally{if(s)throw s[0]}}}catch(a){"AbortError"!==a.name&&r.push(a)}if(t&&r.length)throw new Error(`All providers failed: ${r.map((e=>e.message)).join("; ")}`)}))}result(e){return e.provider?e.provider.result(e):Promise.resolve(void 0)}reverse(e){return b(this,null,(function*(){for(const i of this.providers)if(i.reverse)try{const s=i.reverse(e);try{for(var t,r,n,o=w(s);t=!(r=yield new g(o.next())).done;t=!1){const e=r.value;yield v(m({},e),{provider:i,_id:O++})}}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield new g(r.call(o)))}finally{if(n)throw n[0]}}}catch(s){}}))}reverseGeocodeFirstResult(e){return t=this,r=null,n=function*(){for(const i of this.providers)if("function"==typeof i.reverse)try{try{for(var t,r,n,o=w(i.reverse(e));t=!(r=yield o.next()).done;t=!1)return r.value}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n[0]}}}catch(s){console.error("Error in reverse geocoding:",s)}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}}var j=Object.defineProperty,P=(e,t,r)=>((e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class _ extends a{constructor(){super(...arguments),P(this,"searchUrl"),P(this,"label")}}const E=/\{ *([\w_-]+) *\}/g;function C(e,t){return e.replace(E,((e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n}))}var I=Object.defineProperty,k=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,T=(e,t,r)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function L(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,s=yield n.connect();let i=s&&s[r];if(i){i=[...i];let e=i.shift();if(i.length){const r={};for(let e=0;e<i.length;e++){const n=i[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=C(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach((([e,t])=>{r.push(`${e}=${t}`)}));for(const e in t)-1===i.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))R.call(t,r)&&T(e,r,t[r]);if(k)for(var r of k(t))S.call(t,r)&&T(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}var A=Object.defineProperty,U=(e,t,r)=>((e,t,r)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const $=class e{constructor(t={}){var r;U(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,r,n,s,i){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,s=a.onlyFull,i=a.expirationTime,c=a.props):c=n;const l=this._find(e,c);if(l)return l.value;{let n;n=r instanceof Function?r():r;const a=c&&JSON.parse(JSON.stringify(o(c)));i=i?Date.now()+i:void 0;const l={key:e,value:n,props:a,expirationTime:i};return s&&!t(n)?n:(this.cache.push(l),n instanceof Promise?(n.catch((()=>{this.delete(e,c)})),s&&n.then((r=>(t(r)||this.delete(e,c),r))),n):n)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach((e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)})),e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){const r="string"==typeof e?this.cache.filter((r=>this._filter(r,e,t))):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find((r=>this._filter(r,e,t)))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return n(e.props||{},o(r))}};U($,"instance",{});let q=$;function N(){}function F(){F.init.call(this)}function D(e){return void 0===e._maxListeners?F.defaultMaxListeners:e._maxListeners}function M(e,t,r,n){var o,s,i,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]):(s=e._events=new N,e._eventsCount=0),i){if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),!i.warned&&(o=D(e))&&o>0&&i.length>o){i.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=i.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else i=s[t]=r,++e._eventsCount;return e}function B(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function G(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function H(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}N.prototype=Object.create(null),F.EventEmitter=F,F.usingDomains=!1,F.prototype.domain=void 0,F.prototype._events=void 0,F.prototype._maxListeners=void 0,F.defaultMaxListeners=10,F.init=function(){this.domain=null,F.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new N,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},F.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},F.prototype.getMaxListeners=function(){return D(this)},F.prototype.emit=function(e){var t,r,n,o,s,i,a,c="error"===e;if(i=this._events)c=c&&null==i.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=i[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=H(e,n),s=0;s<n;++s)o[s].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,s=H(e,o),i=0;i<o;++i)s[i].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var s=e.length,i=H(e,s),a=0;a<s;++a)i[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,s){if(t)e.call(r,n,o,s);else for(var i=e.length,a=H(e,i),c=0;c<i;++c)a[c].call(r,n,o,s)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),s=1;s<n;s++)o[s-1]=arguments[s];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,s=H(e,o),i=0;i<o;++i)s[i].apply(r,n)}(r,u,this,o)}return!0},F.prototype.on=F.prototype.addListener=function(e,t){return M(this,e,t,!1)},F.prototype.prependListener=function(e,t){return M(this,e,t,!0)},F.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,B(this,e,t)),this},F.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,B(this,e,t)),this},F.prototype.removeListener=function(e,t){var r,n,o,s,i;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new N:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new N,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,i||t)}return this},F.prototype.off=function(e,t){return this.removeListener(e,t)},F.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new N,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new N:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),s=0;s<o.length;++s)"removeListener"!==(n=o[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new N,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},F.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},F.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):G.call(e,t)},F.prototype.listenerCount=G,F.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var z="3.0.0-alpha.17";class J extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var Q=Object.defineProperty,W=(e,t,r)=>((e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class K extends Error{constructor(e){super(),W(this,"name","NgwError"),W(this,"title"),W(this,"message"),W(this,"detail"),W(this,"exception"),W(this,"status_code"),W(this,"data"),W(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,K.prototype)}}var V=Object.defineProperty,Y=(e,t,r)=>((e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class X extends K{constructor(e){super(e),Y(this,"name","InsufficientPermissionsError"),Y(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,X.prototype)}}var Z=Object.defineProperty,ee=(e,t,r)=>((e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let te=class e extends K{constructor(t){super(t),ee(this,"message","There is no response from the server or problem connecting to server."),ee(this,"title","Network error"),ee(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var re=Object.defineProperty,ne=(e,t,r)=>((e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class oe extends Error{constructor(e){super(),ne(this,"name","NetworkError"),Object.setPrototypeOf(this,oe.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var se=Object.defineProperty,ie=(e,t,r)=>((e,t,r)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ae extends K{constructor(e){super(e),ie(this,"name","ResourceNotFoundError"),ie(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ae.prototype)}}var ce=Object.freeze({__proto__:null,AbortError:J,InsufficientPermissionsError:X,NetworkError:oe,NetworksResponseError:te,NgwError:K,ResourceNotFoundError:ae,extractError:function(e){if(s(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new te({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!s(e)&&(e.status_code&&e.exception&&e.title)}}),le=Object.defineProperty,ue=(e,t,r)=>((e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class he extends Error{constructor(e){super(e||"Something went wrong."),ue(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,he)}}class fe extends he{constructor(e){super(e||"There is no response from the server or problem connecting to server."),ue(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class pe extends he{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class de extends he{constructor(e){super(e.message),ue(this,"detail"),ue(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ye extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),ue(this,"title"),ue(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ye)}}class me extends ye{constructor(e){super("Long-running request was cancelled.",e)}}class ve extends ye{constructor(e){super(void 0,e)}}var ge=Object.defineProperty,be=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,je=(e,t)=>{for(var r in t||(t={}))we.call(t,r)&&xe(e,r,t[r]);if(be)for(var r of be(t))Oe.call(t,r)&&xe(e,r,t[r]);return e},Pe=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));function _e(e){return Pe(this,null,(function*(){const t=yield function(e){return Pe(this,null,(function*(){try{return e.json()}catch(t){throw new Error}}))}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,s=`/api/lunkwill/${t.id}/response`,i=e=>new Promise((t=>setTimeout(t,e)));let a=!1,c=!1;for(;!c;){let e,t;yield i(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(l){a=!0;continue}switch(t.status){case void 0:throw new ye(void 0,t);case"ready":c=!0;break;case"cancelled":throw new me(t);case"failed":throw new ve(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ye(void 0,t)}}return s}))}const Ee=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function Ce(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function Ie(e,t,r){return Pe(this,null,(function*(){var n,s;const i=je(je({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:l,cacheName:u,lunkwill:h,cache:f,query:p,json:d}=i,y=((e,t)=>{var r={};for(var n in e)we.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&be)for(var n of be(e))t.indexOf(n)<0&&Oe.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),a&&(y.credentials="include");let m=!1;void 0!==h&&(h.toHeaders(y.headers||{}),m=!0);const v=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=Ce(e,p),b=()=>Pe(this,null,(function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new fe}if(m&&function(e){const t=e.headers.get("content-type");return null!=t&&t.includes("application/vnd.lunkwill.request-summary+json")}(e)){const t=yield _e(e);if(v)return t;e=yield function(e){return Pe(this,null,(function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new fe}}))}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&Ee.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new pe;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof pe)throw o;throw new pe}if(400<=e.status&&e.status<=599)throw new de(n);return n}));if(r)if("GET"===(null==(s=y.method)?void 0:s.toUpperCase())){if(!1!==f){const e=l||je({},o({withCredentials:a,responseType:c}));return r.add(u||g,b,{props:e,expirationTime:f?void 0:500})}}else{["api/feature_layer/identify"].every((t=>!e.includes(t)))&&r.clean()}return b()}))}var ke=Object.defineProperty,Re=Object.defineProperties,Se=Object.getOwnPropertyDescriptors,Te=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,Ue=(e,t,r)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$e=(e,t)=>{for(var r in t||(t={}))Le.call(t,r)&&Ue(e,r,t[r]);if(Te)for(var r of Te(t))Ae.call(t,r)&&Ue(e,r,t[r]);return e},qe=(e,t)=>{var r={};for(var n in e)Le.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Te)for(var n of Te(e))t.indexOf(n)<0&&Ae.call(e,n)&&(r[n]=e[n]);return r};function Ne(e,t,r,...n){const[o,...s]=r[e],a=n[0];let c;if(void 0===a)c=[];else if("object"==typeof a&&null!==a){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");c=[];for(const[e,t]of Object.entries(a))c[s.indexOf(e)]=String(t)}else c=n.map((e=>String(e)));return i(t+o.replace(/\{(\w+)\}/g,(function(e,t){const r=parseInt(t),n=c[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)})))}function Fe(e,t,...r){const n={url:n=>{return o=this,s=null,i=function*(){var o;const s=yield t.connect();return Ce(Ne(e,null!=(o=t.options.baseUrl)?o:"",s,...r),null==n?void 0:n.query)},new Promise(((e,t)=>{var r=e=>{try{a(i.next(e))}catch(r){t(r)}},n=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((i=i.apply(o,s)).next())}));var o,s,i}},s=["get","post","put","delete","patch"];for(const i of s){const s=n=>{var s;const a=n||{},{headers:c}=a,l=qe(a,["headers"]);if(null==(s=null==n?void 0:n.signal)?void 0:s.aborted)throw new J;return t.connect().then((n=>{var s;const a=Ne(e,null!=(s=t.options.baseUrl)?s:"",n,...r),u=o($e($e({},t.getAuthorizationHeaders()),null!=c?c:{}));return Ie(a,(h=$e({headers:u},l),Re(h,Se({method:i}))),t.cache);var h}))};n[i]=s}return n}function De(e){return"[object Object]"===Object.prototype.toString.call(e)}let Me;Me=(e,t,r={},n,o)=>{r.method=r.method||"GET";const s=new XMLHttpRequest;s.open(r.method||"GET",e,!0),"blob"===r.responseType&&(s.responseType=r.responseType);const i=()=>{try{return JSON.parse(s.responseText)}catch(e){return s.responseText}};s.onload=()=>{-1!==[401,403,404,422,500].indexOf(s.status)&&n(new K(i())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(s.response):s.responseText?o(i()):n({message:""})})()},s.onerror=t=>{n(0===s.status?new oe(e):t)},s.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const l in a){const e=a[l];"string"==typeof e&&s.setRequestHeader(l,e)}let c;if(void 0!==r.withCredentials&&(s.withCredentials=r.withCredentials),r.file){if(c=new FormData,c.append("file",r.file),r.data)for(const l in r.data)c.append(l,c[l])}else c=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{s.abort()})),s.send(c)};const Be=[];function Ge(e){Be.push(e)}var He=Object.defineProperty,ze=Object.defineProperties,Je=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,Ve=(e,t,r)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ye=(e,t)=>{for(var r in t||(t={}))We.call(t,r)&&Ve(e,r,t[r]);if(Qe)for(var r of Qe(t))Ke.call(t,r)&&Ve(e,r,t[r]);return e},Xe=(e,t,r)=>Ve(e,"symbol"!=typeof t?t+"":t,r),Ze=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));let et=0,tt=0;class rt{constructor(e){this.options=e,Xe(this,"id",et++),Xe(this,"emitter",new F),Xe(this,"user"),Xe(this,"cache"),Xe(this,"withCredentials"),Xe(this,"routeCache"),Xe(this,"client",`NextGIS-NGW-Connector/${z}`),Xe(this,"routeStr","/api/component/pyramid/route"),Xe(this,"activeRequests",{}),Xe(this,"requestTransform");const t=function(e){return Be.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return n(t.options.auth,e.auth)}}))}(e);if(this.cache=new q({namespace:e.cacheId}),this.routeCache=new q({namespace:"routecache"}),t)return t;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),Ge(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Ge(this)}connect(){return Ze(this,arguments,(function*({signal:e}={}){const t=this.options.auth;if(t){const{login:e,password:r}=t;e&&r&&(yield this._login({login:e,password:r}))}const r=`${this.routeStr}?client=${this.client}`;return this.routeCache.add(this.options.baseUrl||String(this.id),(()=>this.makeQuery(r,null,{signal:e,cache:!1})))}))}login(e,t){return this.logout(),Ge(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Be.indexOf(e);-1!==t&&Be.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return Ze(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ye({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Ye({},this.activeRequests)}route(e,...t){return Fe(e,this,...t)}makeQuery(e,t){return Ze(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)We.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Qe)for(var n of Qe(e))t.indexOf(n)<0&&Ke.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=C(e,r)}e=encodeURI(i(e)),r=Ye({withCredentials:this.withCredentials},r);const{cache:s,signal:a,method:c="GET",headers:l,cacheName:u,cacheProps:h,responseType:f,withCredentials:p}=r,d=new AbortController,y=d.signal;if(a){if(a.aborted)throw new J;a.addEventListener("abort",(()=>{d.abort()}))}r.signal=y;const m=()=>Ze(this,null,(function*(){const t=tt++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if("GET"===c&&!1!==s){const r=h||(v=Ye({},o({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),ze(v,Je({params:t})));return this.cache.add(u||e,m,{props:r,expirationTime:s?void 0:500})}var v;return m()}))}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Ye(Ye({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let s;Me(e,r,t,n,(e=>{s=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==s&&s(),n(new J)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return Ze(this,null,(function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}}))}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof K){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ae(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new X(e)}return e}}Xe(rt,"errors",ce);const nt=["description"];function ot(t,r=""){r=r?r+"__":"";const n={};for(const[o,s]of Object.entries(t))if(-1===nt.indexOf(o))if(De(s))if("owner_user"===o){const e=ot(s,o);Object.assign(n,e)}else"parent"===o&&"id"in s&&(n.parent_id=s.id);else e(s)&&(n[r+o]=s);return n}var st=Object.defineProperty,it=Object.defineProperties,at=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,ht=(e,t,r)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ft=(e,t)=>{for(var r in t||(t={}))lt.call(t,r)&&ht(e,r,t[r]);if(ct)for(var r of ct(t))ut.call(t,r)&&ht(e,r,t[r]);return e},pt=(e,t)=>it(e,at(t)),dt=(e,t,r)=>ht(e,"symbol"!=typeof t?t+"":t,r),yt=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));class mt{constructor({connector:e,cacheId:t}){dt(this,"cache"),dt(this,"connector"),this.connector=e,this.cache=new q({namespace:t})}getOne(e,t){const r=ft({},t);return"string"==typeof e||"number"==typeof e||De(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):De(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new ae}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||De(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then((e=>{if(void 0===e)throw new Error;return e}))}getMany(e,t){return this._resourceCacheFilter(e).then((r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,ot(e)),this.connector.route("resource.search").get(pt(ft({},t),{query:ft({serialization:"full"},r)})).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)}))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t){return yt(this,arguments,(function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(pt(ft({},t),{query:{parent:n}})),s=[];for(const i of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(i),{id:i.resource.id}),r.push(i),(null==t?void 0:t.recursive)&&i.resource.children&&s.push(this._getChildrenOf(i.resource.id,t,r));return s.length?Promise.all(s).then((()=>r)):r}))}_cleanResourceItemCache(e){return yt(this,null,(function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)}))}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(t){return Promise.all(this.cache.matchAll("resource.item")).then((r=>(r.filter((r=>{if(r)return t.keyname&&r.resource.keyname?t.keyname===r.resource.keyname:e(t.id)&&e(r.resource.id)?t.id===r.resource.id:n(t,r.resource)})),[])))}}var vt=Object.defineProperty,gt=(e,t,r)=>((e,t,r)=>t in e?vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class bt extends rt{constructor(e){super(e),gt(this,"resources"),this.resources=new mt({connector:this,cacheId:e.cacheId})}static create(e){return new this(e)}clearCache(){super.clearCache(),this.resources.cache.clean()}apiRequest(e,t={},r={}){var n;return L({name:e,params:o(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}function wt(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const Ot={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>wt(e,t),ilike:(e,t)=>wt(e,t,!0)};function xt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function jt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(xt(t)){const[r,n,o]=t,s=Ot[n];if(s){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,s)=>(t=e[s],r.replace(s,o))));return s(t,n)}return s(e[r],o)}return!1}return jt(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}const Pt=7e3;var _t=Object.defineProperty,Et=Object.defineProperties,Ct=Object.getOwnPropertyDescriptors,It=Object.getOwnPropertySymbols,kt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,St=(e,t,r)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))kt.call(t,r)&&St(e,r,t[r]);if(It)for(var r of It(t))Rt.call(t,r)&&St(e,r,t[r]);return e},Lt=(e,t)=>Et(e,Ct(t));const At={srs:4326,geom_format:"geojson",dt_format:"iso"};function Ut(e){return t=this,r=null,n=function*(){const t=qt(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}function $t(e){const[t,r,n]=e;let o="",s="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,s=n,r)))}__${r}`,o+n+s]}function qt(e,t=[],r=[]){var n;const{filters:o}=e,s=null!=(n=e.paramList)?n:[],i="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===i)for(const c of a)xt(c)?t.push(Ft(Lt(Tt({},e),{paramList:[...r,...s,$t(c)]}))):qt(Lt(Tt({},e),{filters:c}),t,[...r]);else if("all"===i){const n=[],o=[];for(const e of a)xt(e)?n.push($t(e)):o.push(e);if(o.length)for(const s of o)qt(Lt(Tt({},e),{filters:s}),t,[...r,...n]);else t.push(Ft(Lt(Tt({},e),{paramList:[...r,...s,...n]})))}return t}function Nt(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=function(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function Ft(t){const r=Tt({},At),{limit:n,query:o,cache:s,signal:i,offset:a,orderBy:c,paramList:l,connector:u,geomFormat:h,intersects:f,resourceId:p}=t;if(r.limit=n&&n!==Number.POSITIVE_INFINITY?n:Pt,a&&(r.offset=a),h&&(r.geom_format=h),function(t,r){const{extensions:n,geom:o,fields:s,srs:i,ilike:a,like:c}=r;t.extensions=n||[],s&&(t.fields=s),void 0!==o&&(t.geom=o,o||(delete t.srs,delete t.geom_format)),e(a)?t.ilike=a:e(c)&&(t.like=c),e(i)&&(t.srs=i)}(r,t),c&&(r.order_by=c.join(",")),Array.isArray(f)){const e=(d=f,Array.isArray(d)&&4===d.length&&d.every((e=>"number"==typeof e))?function(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}(f):f);r.intersects=Nt(e)}else"string"==typeof f&&(r.intersects=f);var d;return l&&Object.assign(r,function(e){return e.reduce(((e,[t,r])=>(e[t]=r,e)),{})}(l)),u.route("feature_layer.feature.collection",{id:Number(p)}).get({query:Tt(Tt({},r),o),cache:s,signal:i})}var Dt=Object.defineProperty,Mt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,Gt=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable,Jt=(e,t,r)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qt=(e,t)=>{for(var r in t||(t={}))Ht.call(t,r)&&Jt(e,r,t[r]);if(Gt)for(var r of Gt(t))zt.call(t,r)&&Jt(e,r,t[r]);return e},Wt=(e,t)=>Mt(e,Bt(t));function Kt(t){return r=this,n=null,o=function*(){var r;const n=t.filters;if(n){let o=yield Ut(Wt(Qt({},t),{filters:n}));return(null!=(r=t.clientFilterValidate)?r:Vt(n))&&(o=o.filter((t=>jt(function(t){let r;for(r in t){const n=t[r];if(s(n)){const o=n;if(e(o.year)&&e(o.month)&&e(o.day)){const e=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach((t=>{e.push(t)})),t[r]=new Date(...e).toISOString()}}else"id"===r&&"string"==typeof n&&(t[r]=n.split(",").map(Number))}return t}(Wt(Qt({},t.fields),{id:t.id})),n)))),o}return Ft(t)},new Promise(((e,t)=>{var s=e=>{try{a(o.next(e))}catch(r){t(r)}},i=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((o=o.apply(r,n)).next())}));var r,n,o}function Vt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(Vt(r))return!0}}return!1}var Yt=Object.defineProperty,Xt=Object.getOwnPropertySymbols,Zt=Object.prototype.hasOwnProperty,er=Object.prototype.propertyIsEnumerable,tr=(e,t,r)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rr=(e,t,r)=>tr(e,"symbol"!=typeof t?t+"":t,r),nr=function(e,t){this[0]=e,this[1]=t},or=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof nr,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};const sr=class e extends _{constructor(e){var t;if(super(e),rr(this,"searchResources",[]),rr(this,"connector"),rr(this,"_abortControllers",[]),!e.searchUrl&&!(null==(t=e.connectorOptions)?void 0:t.baseUrl))throw new Error("The `searchUrl` of `connectorOptions.baseUrl` are required");this.connector=e.connector||new bt(((e,t)=>{for(var r in t||(t={}))Zt.call(t,r)&&tr(e,r,t[r]);if(Xt)for(var r of Xt(t))er.call(t,r)&&tr(e,r,t[r]);return e})({baseUrl:this.searchUrl},e.connectorOptions)),this.searchResources=e.searchResources}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers.length=0}search(t){return or(this,null,(function*(){var r,n;const o=this._makeSignal();for(const i of this.searchResources){if(o.aborted)break;const{searchMethod:a}=i,c=null!=(r=i.limit)?r:e.limit,l=null!=(n=i.id)?n:i.resourceId;try{const e=yield new nr(this.connector.getResourceOrFail(l,{cache:!0})),r={connector:this.connector,resourceId:l,signal:o,limit:c};"like"===a?r.like=t:r.ilike=t;const n=Kt(r),s=yield new nr(n);for(const o of this._items({entries:s,query:t,config:i,resourceItem:e}))o.result=()=>this.result(o),yield o}catch(s){s&&"name"in s&&"AbortError"!==s.name&&console.warn(s)}}}))}result(e){const t=this._makeSignal();return this.connector.route("feature_layer.feature.item_extent",{id:e.resourceId,fid:e.featureId}).get({signal:t}).then((t=>{const r=t.extent;return{text:e.text,extent:[r.minLon,r.minLat,r.maxLon,r.maxLat]}}))}reverse(e){return or(this,null,(function*(){throw new Error("Not implemented")}))}_makeSignal(){const e=new AbortController;return this._abortControllers.push(e),e.signal}_items({entries:e,query:t,config:r,resourceItem:n}){var o;const s=[];let i;n.feature_layer&&(i=null==(o=n.feature_layer.fields.find((e=>e.label_field)))?void 0:o.keyname);return this.searchResources.find((e=>{var t;return null!=(t=e.id)?t:e.resourceId===n.resource.id}))&&e.forEach((e=>{let o=i?e.fields[i]:e.id;r.renderSearch?o=r.renderSearch({item:e,resourceItem:n}):i&&(o=e.fields[i]),s.push({query:t,text:o,featureId:e.id,resourceId:n.resource.id,item:e,resourceItem:n})})),s}};rr(sr,"limit",300);let ir=sr;var ar=Object.defineProperty,cr=(e,t,r)=>((e,t,r)=>t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),lr=function(e,t){this[0]=e,this[1]=t},ur=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof lr,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};class hr extends _{constructor(e){super(),this.options=e,cr(this,"searchUrl","https://nominatim.openstreetmap.org"),cr(this,"_abortControllers",[]),e&&e.searchUrl&&(this.searchUrl=e.searchUrl)}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers=[]}search(e){return ur(this,null,(function*(){var t,r,n,o,s,a,c;const l=new URLSearchParams({format:"geojson",polygon_geojson:"1",q:e,limit:(null==(r=null==(t=this.options)?void 0:t.limit)?void 0:r.toString())||"10"});if((null==(n=this.options)?void 0:n.countrycodes)&&l.append("countrycodes",this.options.countrycodes),(null==(o=this.options)?void 0:o.addressdetails)&&l.append("addressdetails","1"),(null==(s=this.options)?void 0:s.language)&&l.append("accept-language",this.options.language),(null==(a=this.options)?void 0:a.bounded)&&l.append("bounded","1"),null==(c=this.options)?void 0:c.viewbox){const[e,t,r,n]=this.options.viewbox;l.append("viewbox",`${e},${t},${r},${n}`)}const u=i(`${this.searchUrl}/search?${l.toString()}`),h=new AbortController;this._abortControllers.push(h);try{const t=yield new lr(fetch(u,{signal:h.signal}));if(!t.ok)throw new Error(`Network response was not ok: ${t.statusText}`);const r=(yield new lr(t.json())).features.map((t=>({geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:e})));for(const e of r)e.result=()=>this.result(e),yield e}catch(f){if("AbortError"!==f.name)throw f}}))}result(e){return Promise.resolve({text:e.text,extent:e.extent||[],geom:e.geom})}reverse(e){return ur(this,null,(function*(){var t,r;const[n,o]=e,s=new URLSearchParams({format:"geojson",lat:o.toString(),lon:n.toString()});(null==(t=this.options)?void 0:t.addressdetails)&&s.append("addressdetails","1"),(null==(r=this.options)?void 0:r.language)&&s.append("accept-language",this.options.language);const a=i(`${this.searchUrl}/reverse?${s.toString()}`),c=new AbortController;this._abortControllers.push(c);try{const e=yield new lr(fetch(a,{signal:c.signal}));if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);const t=(yield new lr(e.json())).features[0],r={geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:`${o}, ${n}`};r.result=()=>this.result(r),yield r}catch(l){if("AbortError"!==l.name)throw l}}))}}function fr(e){return new x(e)}export{_ as BaseProvider,x as Geocoder,ir as NgwProvider,hr as NominatimProvider,fr as create};
2
2
  //# sourceMappingURL=geocoder.esm-browser.prod.js.map
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.16; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.17; author: NextGIS */
2
2
  import { objectAssign, fixUrlStr } from '@nextgis/utils';
3
3
  import NgwConnector from '@nextgis/ngw-connector';
4
4
  import { fetchNgwLayerItems } from '@nextgis/ngw-kit';
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.16; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 3.0.0-alpha.17; author: NextGIS */
2
2
  var Geocoder = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1020,7 +1020,7 @@ var Geocoder = (function (exports) {
1020
1020
 
1021
1021
  var pkg = {
1022
1022
  name: "@nextgis/ngw-connector",
1023
- version: "3.0.0-alpha.16",
1023
+ version: "3.0.0-alpha.17",
1024
1024
  _priority: 12,
1025
1025
  description: "A lightweight HTTP client optimized for use with NextGIS Web API",
1026
1026
  main: "index.js",
@@ -1029,15 +1029,15 @@ var Geocoder = (function (exports) {
1029
1029
  jsdelivr: "lib/ngw-connector.global.prod.js",
1030
1030
  types: "lib/index.d.ts",
1031
1031
  dependencies: {
1032
- "@nextgis/cache": "^3.0.0-alpha.13",
1033
- "@nextgis/cancelable-promise": "^3.0.0-alpha.13",
1034
- "@nextgis/utils": "^3.0.0-alpha.13",
1032
+ "@nextgis/cache": "^3.0.0-alpha.17",
1033
+ "@nextgis/cancelable-promise": "^3.0.0-alpha.17",
1034
+ "@nextgis/utils": "^3.0.0-alpha.17",
1035
1035
  "@types/events": "^3.0.0",
1036
1036
  events: "*",
1037
1037
  "form-data": "^4.0.0"
1038
1038
  },
1039
1039
  devDependencies: {
1040
- "@nextgis/build-tools": "^3.0.0-alpha.13"
1040
+ "@nextgis/build-tools": "^3.0.0-alpha.17"
1041
1041
  },
1042
1042
  scripts: {
1043
1043
  clean: "rimraf ./lib",
@@ -1,2 +1,2 @@
1
- var Geocoder=function(e){"use strict";function t(e){return null!=e}function r(e){return"string"==typeof e?!!e:t(e)}function n(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:o(e,t));return e===t}function o(e,t){const r=Object.keys(e).sort(),o=Object.keys(t).sort();if(r.length!==o.length)return!1;if(r.join("")!==o.join(""))return!1;for(let s=0;s<r.length;s++){if(!n(e[r[s]],t[o[s]],e,t))return!1}return!0}function s(e){const t={};return Object.keys(e).forEach((r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=s(e[r])})),t}function i(e){return"[object Object]"===Object.prototype.toString.call(e)}function a(e){return e.replace(/([^:]\/)\/+/g,"$1")}class c{constructor(e){e&&function(e,...t){for(const r of t)for(const t of Object.getOwnPropertyNames(r))e[t]=r[t]}(this,e)}}var l=Object.defineProperty,u=Object.defineProperties,h=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,y=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),m=(e,t,r)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))p.call(t,r)&&m(e,r,t[r]);if(f)for(var r of f(t))d.call(t,r)&&m(e,r,t[r]);return e},g=(e,t)=>u(e,h(t)),b=function(e,t){this[0]=e,this[1]=t},w=(e,t,r)=>{var n=(e,t,o,s)=>{try{var i=r[e](t),a=(t=i.value)instanceof b,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?n("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,o,s):o({value:r,done:c}))).catch((e=>n("throw",e,o,s)))}catch(l){s(l)}},o=e=>s[e]=t=>new Promise(((r,o)=>n(e,t,r,o))),s={};return r=r.apply(e,t),s[y("asyncIterator")]=()=>s,o("next"),o("throw"),o("return"),s},O=(e,t,r)=>(t=e[y("asyncIterator")])?t.call(e):(e=e[y("iterator")](),t={},(r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,s)=>(t=n.call(e,t),s=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:s})),o))))))("next"),r("return"),t);let x=0;class j extends c{constructor(e){super(e),m(this,"providers"+"",[]),e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach((e=>{e.abort&&e.abort()}))}search(e){return w(this,null,(function*(){this.abort();let t=!0;const r=[];for(const c of this.providers)try{const r=c.search(e);try{for(var n,o,s,i=O(r);n=!(o=yield new b(i.next())).done;n=!1){const e=o.value;t=!1,yield g(v({},e),{provider:c,_id:x++})}}catch(o){s=[o]}finally{try{n&&(o=i.return)&&(yield new b(o.call(i)))}finally{if(s)throw s[0]}}}catch(a){"AbortError"!==a.name&&r.push(a)}if(t&&r.length)throw new Error(`All providers failed: ${r.map((e=>e.message)).join("; ")}`)}))}result(e){return e.provider?e.provider.result(e):Promise.resolve(void 0)}reverse(e){return w(this,null,(function*(){for(const i of this.providers)if(i.reverse)try{const s=i.reverse(e);try{for(var t,r,n,o=O(s);t=!(r=yield new b(o.next())).done;t=!1){const e=r.value;yield g(v({},e),{provider:i,_id:x++})}}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield new b(r.call(o)))}finally{if(n)throw n[0]}}}catch(s){}}))}reverseGeocodeFirstResult(e){return t=this,r=null,n=function*(){for(const i of this.providers)if("function"==typeof i.reverse)try{try{for(var t,r,n,o=O(i.reverse(e));t=!(r=yield o.next()).done;t=!1)return r.value}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n[0]}}}catch(s){console.error("Error in reverse geocoding:",s)}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}}var P=Object.defineProperty,_=(e,t,r)=>((e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class E extends c{constructor(){super(...arguments),_(this,"searchUrl"),_(this,"label")}}const C=/\{ *([\w_-]+) *\}/g;function I(e,t){return e.replace(C,((e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n}))}var k=Object.defineProperty,R=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,L=(e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function A(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,s=yield n.connect();let i=s&&s[r];if(i){i=[...i];let e=i.shift();if(i.length){const r={};for(let e=0;e<i.length;e++){const n=i[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=I(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach((([e,t])=>{r.push(`${e}=${t}`)}));for(const e in t)-1===i.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))S.call(t,r)&&L(e,r,t[r]);if(R)for(var r of R(t))T.call(t,r)&&L(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}var U=Object.defineProperty,$=(e,t,r)=>((e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const q=class e{constructor(t={}){var r;$(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,t,n,o,i){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,o=a.onlyFull,i=a.expirationTime,c=a.props):c=n;const l=this._find(e,c);if(l)return l.value;{let n;n=t instanceof Function?t():t;const a=c&&JSON.parse(JSON.stringify(s(c)));i=i?Date.now()+i:void 0;const l={key:e,value:n,props:a,expirationTime:i};return o&&!r(n)?n:(this.cache.push(l),n instanceof Promise?(n.catch((()=>{this.delete(e,c)})),o&&n.then((t=>(r(t)||this.delete(e,c),t))),n):n)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach((e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)})),e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){const r="string"==typeof e?this.cache.filter((r=>this._filter(r,e,t))):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find((r=>this._filter(r,e,t)))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return o(e.props||{},s(r))}};$(q,"instance",{});let N=q;function F(){}function D(){D.init.call(this)}function M(e){return void 0===e._maxListeners?D.defaultMaxListeners:e._maxListeners}function G(e,t,r,n){var o,s,i,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]):(s=e._events=new F,e._eventsCount=0),i){if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),!i.warned&&(o=M(e))&&o>0&&i.length>o){i.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=i.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else i=s[t]=r,++e._eventsCount;return e}function B(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function H(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function z(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}F.prototype=Object.create(null),D.EventEmitter=D,D.usingDomains=!1,D.prototype.domain=void 0,D.prototype._events=void 0,D.prototype._maxListeners=void 0,D.defaultMaxListeners=10,D.init=function(){this.domain=null,D.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new F,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},D.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},D.prototype.getMaxListeners=function(){return M(this)},D.prototype.emit=function(e){var t,r,n,o,s,i,a,c="error"===e;if(i=this._events)c=c&&null==i.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=i[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=z(e,n),s=0;s<n;++s)o[s].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,s=z(e,o),i=0;i<o;++i)s[i].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var s=e.length,i=z(e,s),a=0;a<s;++a)i[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,s){if(t)e.call(r,n,o,s);else for(var i=e.length,a=z(e,i),c=0;c<i;++c)a[c].call(r,n,o,s)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),s=1;s<n;s++)o[s-1]=arguments[s];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,s=z(e,o),i=0;i<o;++i)s[i].apply(r,n)}(r,u,this,o)}return!0},D.prototype.on=D.prototype.addListener=function(e,t){return G(this,e,t,!1)},D.prototype.prependListener=function(e,t){return G(this,e,t,!0)},D.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,B(this,e,t)),this},D.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,B(this,e,t)),this},D.prototype.removeListener=function(e,t){var r,n,o,s,i;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new F:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new F,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,i||t)}return this},D.prototype.off=function(e,t){return this.removeListener(e,t)},D.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new F,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new F:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),s=0;s<o.length;++s)"removeListener"!==(n=o[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new F,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},D.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},D.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):H.call(e,t)},D.prototype.listenerCount=H,D.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var J="3.0.0-alpha.16";class Q extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var W=Object.defineProperty,K=(e,t,r)=>((e,t,r)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class V extends Error{constructor(e){super(),K(this,"name","NgwError"),K(this,"title"),K(this,"message"),K(this,"detail"),K(this,"exception"),K(this,"status_code"),K(this,"data"),K(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,V.prototype)}}var Y=Object.defineProperty,X=(e,t,r)=>((e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Z extends V{constructor(e){super(e),X(this,"name","InsufficientPermissionsError"),X(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,Z.prototype)}}var ee=Object.defineProperty,te=(e,t,r)=>((e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let re=class e extends V{constructor(t){super(t),te(this,"message","There is no response from the server or problem connecting to server."),te(this,"title","Network error"),te(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var ne=Object.defineProperty,oe=(e,t,r)=>((e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class se extends Error{constructor(e){super(),oe(this,"name","NetworkError"),Object.setPrototypeOf(this,se.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var ie=Object.defineProperty,ae=(e,t,r)=>((e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ce extends V{constructor(e){super(e),ae(this,"name","ResourceNotFoundError"),ae(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ce.prototype)}}var le=Object.freeze({__proto__:null,AbortError:Q,InsufficientPermissionsError:Z,NetworkError:se,NetworksResponseError:re,NgwError:V,ResourceNotFoundError:ce,extractError:function(e){if(i(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new re({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!i(e)&&(e.status_code&&e.exception&&e.title)}}),ue=Object.defineProperty,he=(e,t,r)=>((e,t,r)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class fe extends Error{constructor(e){super(e||"Something went wrong."),he(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,fe)}}class pe extends fe{constructor(e){super(e||"There is no response from the server or problem connecting to server."),he(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class de extends fe{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ye extends fe{constructor(e){super(e.message),he(this,"detail"),he(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class me extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),he(this,"title"),he(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,me)}}class ve extends me{constructor(e){super("Long-running request was cancelled.",e)}}class ge extends me{constructor(e){super(void 0,e)}}var be=Object.defineProperty,we=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,je=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t)=>{for(var r in t||(t={}))Oe.call(t,r)&&je(e,r,t[r]);if(we)for(var r of we(t))xe.call(t,r)&&je(e,r,t[r]);return e},_e=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));function Ee(e){return _e(this,null,(function*(){const t=yield function(e){return _e(this,null,(function*(){try{return e.json()}catch(t){throw new Error}}))}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,s=`/api/lunkwill/${t.id}/response`,i=e=>new Promise((t=>setTimeout(t,e)));let a=!1,c=!1;for(;!c;){let e,t;yield i(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(l){a=!0;continue}switch(t.status){case void 0:throw new me(void 0,t);case"ready":c=!0;break;case"cancelled":throw new ve(t);case"failed":throw new ge(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new me(void 0,t)}}return s}))}const Ce=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function Ie(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function ke(e,t,r){return _e(this,null,(function*(){var n,o;const i=Pe(Pe({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:l,cacheName:u,lunkwill:h,cache:f,query:p,json:d}=i,y=((e,t)=>{var r={};for(var n in e)Oe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&we)for(var n of we(e))t.indexOf(n)<0&&xe.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),a&&(y.credentials="include");let m=!1;void 0!==h&&(h.toHeaders(y.headers||{}),m=!0);const v=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=Ie(e,p),b=()=>_e(this,null,(function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new pe}if(m&&function(e){const t=e.headers.get("content-type");return null!=t&&t.includes("application/vnd.lunkwill.request-summary+json")}(e)){const t=yield Ee(e);if(v)return t;e=yield function(e){return _e(this,null,(function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new pe}}))}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&Ce.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new de;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof de)throw o;throw new de}if(400<=e.status&&e.status<=599)throw new ye(n);return n}));if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==f){const e=l||Pe({},s({withCredentials:a,responseType:c}));return r.add(u||g,b,{props:e,expirationTime:f?void 0:500})}}else{["api/feature_layer/identify"].every((t=>!e.includes(t)))&&r.clean()}return b()}))}var Re=Object.defineProperty,Se=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,$e=(e,t,r)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qe=(e,t)=>{for(var r in t||(t={}))Ae.call(t,r)&&$e(e,r,t[r]);if(Le)for(var r of Le(t))Ue.call(t,r)&&$e(e,r,t[r]);return e},Ne=(e,t)=>{var r={};for(var n in e)Ae.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Le)for(var n of Le(e))t.indexOf(n)<0&&Ue.call(e,n)&&(r[n]=e[n]);return r};function Fe(e,t,r,...n){const[o,...s]=r[e],i=n[0];let c;if(void 0===i)c=[];else if("object"==typeof i&&null!==i){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");c=[];for(const[e,t]of Object.entries(i))c[s.indexOf(e)]=String(t)}else c=n.map((e=>String(e)));return a(t+o.replace(/\{(\w+)\}/g,(function(e,t){const r=parseInt(t),n=c[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)})))}function De(e,t,...r){const n={url:n=>{return o=this,s=null,i=function*(){var o;const s=yield t.connect();return Ie(Fe(e,null!=(o=t.options.baseUrl)?o:"",s,...r),null==n?void 0:n.query)},new Promise(((e,t)=>{var r=e=>{try{a(i.next(e))}catch(r){t(r)}},n=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((i=i.apply(o,s)).next())}));var o,s,i}},o=["get","post","put","delete","patch"];for(const i of o){const o=n=>{var o;const a=n||{},{headers:c}=a,l=Ne(a,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new Q;return t.connect().then((n=>{var o;const a=Fe(e,null!=(o=t.options.baseUrl)?o:"",n,...r),u=s(qe(qe({},t.getAuthorizationHeaders()),null!=c?c:{}));return ke(a,(h=qe({headers:u},l),Se(h,Te({method:i}))),t.cache);var h}))};n[i]=o}return n}function Me(e){return"[object Object]"===Object.prototype.toString.call(e)}let Ge;Ge=(e,t,r={},n,o)=>{r.method=r.method||"GET";const s=new XMLHttpRequest;s.open(r.method||"GET",e,!0),"blob"===r.responseType&&(s.responseType=r.responseType);const i=()=>{try{return JSON.parse(s.responseText)}catch(e){return s.responseText}};s.onload=()=>{-1!==[401,403,404,422,500].indexOf(s.status)&&n(new V(i())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(s.response):s.responseText?o(i()):n({message:""})})()},s.onerror=t=>{n(0===s.status?new se(e):t)},s.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const l in a){const e=a[l];"string"==typeof e&&s.setRequestHeader(l,e)}let c;if(void 0!==r.withCredentials&&(s.withCredentials=r.withCredentials),r.file){if(c=new FormData,c.append("file",r.file),r.data)for(const l in r.data)c.append(l,c[l])}else c=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{s.abort()})),s.send(c)};const Be=[];function He(e){Be.push(e)}var ze=Object.defineProperty,Je=Object.defineProperties,Qe=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,Ye=(e,t,r)=>t in e?ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xe=(e,t)=>{for(var r in t||(t={}))Ke.call(t,r)&&Ye(e,r,t[r]);if(We)for(var r of We(t))Ve.call(t,r)&&Ye(e,r,t[r]);return e},Ze=(e,t,r)=>Ye(e,"symbol"!=typeof t?t+"":t,r),et=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));let tt=0,rt=0;class nt{constructor(e){this.options=e,Ze(this,"id",tt++),Ze(this,"emitter",new D),Ze(this,"user"),Ze(this,"cache"),Ze(this,"withCredentials"),Ze(this,"routeCache"),Ze(this,"client",`NextGIS-NGW-Connector/${J}`),Ze(this,"routeStr","/api/component/pyramid/route"),Ze(this,"activeRequests",{}),Ze(this,"requestTransform");const t=function(e){return Be.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return o(t.options.auth,e.auth)}}))}(e);if(this.cache=new N({namespace:e.cacheId}),this.routeCache=new N({namespace:"routecache"}),t)return t;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),He(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,He(this)}connect(){return et(this,arguments,(function*({signal:e}={}){const t=this.options.auth;if(t){const{login:e,password:r}=t;e&&r&&(yield this._login({login:e,password:r}))}const r=`${this.routeStr}?client=${this.client}`;return this.routeCache.add(this.options.baseUrl||String(this.id),(()=>this.makeQuery(r,null,{signal:e,cache:!1})))}))}login(e,t){return this.logout(),He(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Be.indexOf(e);-1!==t&&Be.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return et(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Xe({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Xe({},this.activeRequests)}route(e,...t){return De(e,this,...t)}makeQuery(e,t){return et(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)Ke.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&We)for(var n of We(e))t.indexOf(n)<0&&Ve.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=I(e,r)}e=encodeURI(a(e)),r=Xe({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:c="GET",headers:l,cacheName:u,cacheProps:h,responseType:f,withCredentials:p}=r,d=new AbortController,y=d.signal;if(i){if(i.aborted)throw new Q;i.addEventListener("abort",(()=>{d.abort()}))}r.signal=y;const m=()=>et(this,null,(function*(){const t=rt++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if("GET"===c&&!1!==o){const r=h||(v=Xe({},s({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Je(v,Qe({params:t})));return this.cache.add(u||e,m,{props:r,expirationTime:o?void 0:500})}var v;return m()}))}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Xe(Xe({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let s;Ge(e,r,t,n,(e=>{s=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==s&&s(),n(new Q)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return et(this,null,(function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}}))}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof V){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ce(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new Z(e)}return e}}Ze(nt,"errors",le);const ot=["description"];function st(e,r=""){r=r?r+"__":"";const n={};for(const[o,s]of Object.entries(e))if(-1===ot.indexOf(o))if(Me(s))if("owner_user"===o){const e=st(s,o);Object.assign(n,e)}else"parent"===o&&"id"in s&&(n.parent_id=s.id);else t(s)&&(n[r+o]=s);return n}var it=Object.defineProperty,at=Object.defineProperties,ct=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,ft=(e,t,r)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pt=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&ft(e,r,t[r]);if(lt)for(var r of lt(t))ht.call(t,r)&&ft(e,r,t[r]);return e},dt=(e,t)=>at(e,ct(t)),yt=(e,t,r)=>ft(e,"symbol"!=typeof t?t+"":t,r),mt=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));class vt{constructor({connector:e,cacheId:t}){yt(this,"cache"),yt(this,"connector"),this.connector=e,this.cache=new N({namespace:t})}getOne(e,t){const r=pt({},t);return"string"==typeof e||"number"==typeof e||Me(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Me(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new ce}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Me(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then((e=>{if(void 0===e)throw new Error;return e}))}getMany(e,t){return this._resourceCacheFilter(e).then((r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,st(e)),this.connector.route("resource.search").get(dt(pt({},t),{query:pt({serialization:"full"},r)})).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)}))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t){return mt(this,arguments,(function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(dt(pt({},t),{query:{parent:n}})),s=[];for(const i of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(i),{id:i.resource.id}),r.push(i),(null==t?void 0:t.recursive)&&i.resource.children&&s.push(this._getChildrenOf(i.resource.id,t,r));return s.length?Promise.all(s).then((()=>r)):r}))}_cleanResourceItemCache(e){return mt(this,null,(function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)}))}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then((r=>(r.filter((r=>{if(r)return e.keyname&&r.resource.keyname?e.keyname===r.resource.keyname:t(e.id)&&t(r.resource.id)?e.id===r.resource.id:o(e,r.resource)})),[])))}}var gt=Object.defineProperty,bt=(e,t,r)=>((e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class wt extends nt{constructor(e){super(e),bt(this,"resources"),this.resources=new vt({connector:this,cacheId:e.cacheId})}static create(e){return new this(e)}clearCache(){super.clearCache(),this.resources.cache.clean()}apiRequest(e,t={},r={}){var n;return A({name:e,params:s(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}function Ot(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const xt={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>Ot(e,t),ilike:(e,t)=>Ot(e,t,!0)};function jt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Pt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(jt(t)){const[r,n,o]=t,s=xt[n];if(s){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,s)=>(t=e[s],r.replace(s,o))));return s(t,n)}return s(e[r],o)}return!1}return Pt(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}const _t=7e3;var Et=Object.defineProperty,Ct=Object.defineProperties,It=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,Rt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Tt=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Lt=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&&Tt(e,r,t[r]);if(kt)for(var r of kt(t))St.call(t,r)&&Tt(e,r,t[r]);return e},At=(e,t)=>Ct(e,It(t));const Ut={srs:4326,geom_format:"geojson",dt_format:"iso"};function $t(e){return t=this,r=null,n=function*(){const t=Nt(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}function qt(e){const[t,r,n]=e;let o="",s="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,s=n,r)))}__${r}`,o+n+s]}function Nt(e,t=[],r=[]){var n;const{filters:o}=e,s=null!=(n=e.paramList)?n:[],i="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===i)for(const c of a)jt(c)?t.push(Dt(At(Lt({},e),{paramList:[...r,...s,qt(c)]}))):Nt(At(Lt({},e),{filters:c}),t,[...r]);else if("all"===i){const n=[],o=[];for(const e of a)jt(e)?n.push(qt(e)):o.push(e);if(o.length)for(const s of o)Nt(At(Lt({},e),{filters:s}),t,[...r,...n]);else t.push(Dt(At(Lt({},e),{paramList:[...r,...s,...n]})))}return t}function Ft(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=function(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function Dt(e){const r=Lt({},Ut),{limit:n,query:o,cache:s,signal:i,offset:a,orderBy:c,paramList:l,connector:u,geomFormat:h,intersects:f,resourceId:p}=e;if(r.limit=n&&n!==Number.POSITIVE_INFINITY?n:_t,a&&(r.offset=a),h&&(r.geom_format=h),function(e,r){const{extensions:n,geom:o,fields:s,srs:i,ilike:a,like:c}=r;e.extensions=n||[],s&&(e.fields=s),void 0!==o&&(e.geom=o,o||(delete e.srs,delete e.geom_format)),t(a)?e.ilike=a:t(c)&&(e.like=c),t(i)&&(e.srs=i)}(r,e),c&&(r.order_by=c.join(",")),Array.isArray(f)){const e=(d=f,Array.isArray(d)&&4===d.length&&d.every((e=>"number"==typeof e))?function(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}(f):f);r.intersects=Ft(e)}else"string"==typeof f&&(r.intersects=f);var d;return l&&Object.assign(r,function(e){return e.reduce(((e,[t,r])=>(e[t]=r,e)),{})}(l)),u.route("feature_layer.feature.collection",{id:Number(p)}).get({query:Lt(Lt({},r),o),cache:s,signal:i})}var Mt=Object.defineProperty,Gt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Qt=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wt=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Qt(e,r,t[r]);if(Ht)for(var r of Ht(t))Jt.call(t,r)&&Qt(e,r,t[r]);return e},Kt=(e,t)=>Gt(e,Bt(t));function Vt(e){return r=this,n=null,o=function*(){var r;const n=e.filters;if(n){let o=yield $t(Kt(Wt({},e),{filters:n}));return(null!=(r=e.clientFilterValidate)?r:Yt(n))&&(o=o.filter((e=>Pt(function(e){let r;for(r in e){const n=e[r];if(i(n)){const o=n;if(t(o.year)&&t(o.month)&&t(o.day)){const t=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach((e=>{t.push(e)})),e[r]=new Date(...t).toISOString()}}else"id"===r&&"string"==typeof n&&(e[r]=n.split(",").map(Number))}return e}(Kt(Wt({},e.fields),{id:e.id})),n)))),o}return Dt(e)},new Promise(((e,t)=>{var s=e=>{try{a(o.next(e))}catch(r){t(r)}},i=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((o=o.apply(r,n)).next())}));var r,n,o}function Yt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(Yt(r))return!0}}return!1}var Xt=Object.defineProperty,Zt=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,rr=(e,t,r)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nr=(e,t,r)=>rr(e,"symbol"!=typeof t?t+"":t,r),or=function(e,t){this[0]=e,this[1]=t},sr=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof or,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};const ir=class e extends E{constructor(e){var t;if(super(e),nr(this,"searchResources",[]),nr(this,"connector"),nr(this,"_abortControllers",[]),!e.searchUrl&&!(null==(t=e.connectorOptions)?void 0:t.baseUrl))throw new Error("The `searchUrl` of `connectorOptions.baseUrl` are required");this.connector=e.connector||new wt(((e,t)=>{for(var r in t||(t={}))er.call(t,r)&&rr(e,r,t[r]);if(Zt)for(var r of Zt(t))tr.call(t,r)&&rr(e,r,t[r]);return e})({baseUrl:this.searchUrl},e.connectorOptions)),this.searchResources=e.searchResources}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers.length=0}search(t){return sr(this,null,(function*(){var r,n;const o=this._makeSignal();for(const i of this.searchResources){if(o.aborted)break;const{searchMethod:a}=i,c=null!=(r=i.limit)?r:e.limit,l=null!=(n=i.id)?n:i.resourceId;try{const e=yield new or(this.connector.getResourceOrFail(l,{cache:!0})),r={connector:this.connector,resourceId:l,signal:o,limit:c};"like"===a?r.like=t:r.ilike=t;const n=Vt(r),s=yield new or(n);for(const o of this._items({entries:s,query:t,config:i,resourceItem:e}))o.result=()=>this.result(o),yield o}catch(s){s&&"name"in s&&"AbortError"!==s.name&&console.warn(s)}}}))}result(e){const t=this._makeSignal();return this.connector.route("feature_layer.feature.item_extent",{id:e.resourceId,fid:e.featureId}).get({signal:t}).then((t=>{const r=t.extent;return{text:e.text,extent:[r.minLon,r.minLat,r.maxLon,r.maxLat]}}))}reverse(e){return sr(this,null,(function*(){throw new Error("Not implemented")}))}_makeSignal(){const e=new AbortController;return this._abortControllers.push(e),e.signal}_items({entries:e,query:t,config:r,resourceItem:n}){var o;const s=[];let i;n.feature_layer&&(i=null==(o=n.feature_layer.fields.find((e=>e.label_field)))?void 0:o.keyname);return this.searchResources.find((e=>{var t;return null!=(t=e.id)?t:e.resourceId===n.resource.id}))&&e.forEach((e=>{let o=i?e.fields[i]:e.id;r.renderSearch?o=r.renderSearch({item:e,resourceItem:n}):i&&(o=e.fields[i]),s.push({query:t,text:o,featureId:e.id,resourceId:n.resource.id,item:e,resourceItem:n})})),s}};nr(ir,"limit",300);let ar=ir;var cr=Object.defineProperty,lr=(e,t,r)=>((e,t,r)=>t in e?cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),ur=function(e,t){this[0]=e,this[1]=t},hr=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof ur,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};return e.BaseProvider=E,e.Geocoder=j,e.NgwProvider=ar,e.NominatimProvider=class extends E{constructor(e){super(),this.options=e,lr(this,"searchUrl","https://nominatim.openstreetmap.org"),lr(this,"_abortControllers",[]),e&&e.searchUrl&&(this.searchUrl=e.searchUrl)}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers=[]}search(e){return hr(this,null,(function*(){var t,r,n,o,s,i,c;const l=new URLSearchParams({format:"geojson",polygon_geojson:"1",q:e,limit:(null==(r=null==(t=this.options)?void 0:t.limit)?void 0:r.toString())||"10"});if((null==(n=this.options)?void 0:n.countrycodes)&&l.append("countrycodes",this.options.countrycodes),(null==(o=this.options)?void 0:o.addressdetails)&&l.append("addressdetails","1"),(null==(s=this.options)?void 0:s.language)&&l.append("accept-language",this.options.language),(null==(i=this.options)?void 0:i.bounded)&&l.append("bounded","1"),null==(c=this.options)?void 0:c.viewbox){const[e,t,r,n]=this.options.viewbox;l.append("viewbox",`${e},${t},${r},${n}`)}const u=a(`${this.searchUrl}/search?${l.toString()}`),h=new AbortController;this._abortControllers.push(h);try{const t=yield new ur(fetch(u,{signal:h.signal}));if(!t.ok)throw new Error(`Network response was not ok: ${t.statusText}`);const r=(yield new ur(t.json())).features.map((t=>({geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:e})));for(const e of r)e.result=()=>this.result(e),yield e}catch(f){if("AbortError"!==f.name)throw f}}))}result(e){return Promise.resolve({text:e.text,extent:e.extent||[],geom:e.geom})}reverse(e){return hr(this,null,(function*(){var t,r;const[n,o]=e,s=new URLSearchParams({format:"geojson",lat:o.toString(),lon:n.toString()});(null==(t=this.options)?void 0:t.addressdetails)&&s.append("addressdetails","1"),(null==(r=this.options)?void 0:r.language)&&s.append("accept-language",this.options.language);const i=a(`${this.searchUrl}/reverse?${s.toString()}`),c=new AbortController;this._abortControllers.push(c);try{const e=yield new ur(fetch(i,{signal:c.signal}));if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);const t=(yield new ur(e.json())).features[0],r={geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:`${o}, ${n}`};r.result=()=>this.result(r),yield r}catch(l){if("AbortError"!==l.name)throw l}}))}},e.create=function(e){return new j(e)},e}({});
1
+ var Geocoder=function(e){"use strict";function t(e){return null!=e}function r(e){return"string"==typeof e?!!e:t(e)}function n(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:o(e,t));return e===t}function o(e,t){const r=Object.keys(e).sort(),o=Object.keys(t).sort();if(r.length!==o.length)return!1;if(r.join("")!==o.join(""))return!1;for(let s=0;s<r.length;s++){if(!n(e[r[s]],t[o[s]],e,t))return!1}return!0}function s(e){const t={};return Object.keys(e).forEach((r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=s(e[r])})),t}function i(e){return"[object Object]"===Object.prototype.toString.call(e)}function a(e){return e.replace(/([^:]\/)\/+/g,"$1")}class c{constructor(e){e&&function(e,...t){for(const r of t)for(const t of Object.getOwnPropertyNames(r))e[t]=r[t]}(this,e)}}var l=Object.defineProperty,u=Object.defineProperties,h=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,y=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),m=(e,t,r)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))p.call(t,r)&&m(e,r,t[r]);if(f)for(var r of f(t))d.call(t,r)&&m(e,r,t[r]);return e},g=(e,t)=>u(e,h(t)),b=function(e,t){this[0]=e,this[1]=t},w=(e,t,r)=>{var n=(e,t,o,s)=>{try{var i=r[e](t),a=(t=i.value)instanceof b,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?n("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,o,s):o({value:r,done:c}))).catch((e=>n("throw",e,o,s)))}catch(l){s(l)}},o=e=>s[e]=t=>new Promise(((r,o)=>n(e,t,r,o))),s={};return r=r.apply(e,t),s[y("asyncIterator")]=()=>s,o("next"),o("throw"),o("return"),s},O=(e,t,r)=>(t=e[y("asyncIterator")])?t.call(e):(e=e[y("iterator")](),t={},(r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,s)=>(t=n.call(e,t),s=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:s})),o))))))("next"),r("return"),t);let x=0;class j extends c{constructor(e){super(e),m(this,"providers"+"",[]),e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach((e=>{e.abort&&e.abort()}))}search(e){return w(this,null,(function*(){this.abort();let t=!0;const r=[];for(const c of this.providers)try{const r=c.search(e);try{for(var n,o,s,i=O(r);n=!(o=yield new b(i.next())).done;n=!1){const e=o.value;t=!1,yield g(v({},e),{provider:c,_id:x++})}}catch(o){s=[o]}finally{try{n&&(o=i.return)&&(yield new b(o.call(i)))}finally{if(s)throw s[0]}}}catch(a){"AbortError"!==a.name&&r.push(a)}if(t&&r.length)throw new Error(`All providers failed: ${r.map((e=>e.message)).join("; ")}`)}))}result(e){return e.provider?e.provider.result(e):Promise.resolve(void 0)}reverse(e){return w(this,null,(function*(){for(const i of this.providers)if(i.reverse)try{const s=i.reverse(e);try{for(var t,r,n,o=O(s);t=!(r=yield new b(o.next())).done;t=!1){const e=r.value;yield g(v({},e),{provider:i,_id:x++})}}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield new b(r.call(o)))}finally{if(n)throw n[0]}}}catch(s){}}))}reverseGeocodeFirstResult(e){return t=this,r=null,n=function*(){for(const i of this.providers)if("function"==typeof i.reverse)try{try{for(var t,r,n,o=O(i.reverse(e));t=!(r=yield o.next()).done;t=!1)return r.value}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n[0]}}}catch(s){console.error("Error in reverse geocoding:",s)}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}}var P=Object.defineProperty,_=(e,t,r)=>((e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class E extends c{constructor(){super(...arguments),_(this,"searchUrl"),_(this,"label")}}const C=/\{ *([\w_-]+) *\}/g;function I(e,t){return e.replace(C,((e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n}))}var k=Object.defineProperty,R=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,L=(e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function A(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,s=yield n.connect();let i=s&&s[r];if(i){i=[...i];let e=i.shift();if(i.length){const r={};for(let e=0;e<i.length;e++){const n=i[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=I(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach((([e,t])=>{r.push(`${e}=${t}`)}));for(const e in t)-1===i.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))S.call(t,r)&&L(e,r,t[r]);if(R)for(var r of R(t))T.call(t,r)&&L(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}var U=Object.defineProperty,$=(e,t,r)=>((e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const q=class e{constructor(t={}){var r;$(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,t,n,o,i){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,o=a.onlyFull,i=a.expirationTime,c=a.props):c=n;const l=this._find(e,c);if(l)return l.value;{let n;n=t instanceof Function?t():t;const a=c&&JSON.parse(JSON.stringify(s(c)));i=i?Date.now()+i:void 0;const l={key:e,value:n,props:a,expirationTime:i};return o&&!r(n)?n:(this.cache.push(l),n instanceof Promise?(n.catch((()=>{this.delete(e,c)})),o&&n.then((t=>(r(t)||this.delete(e,c),t))),n):n)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach((e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)})),e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){const r="string"==typeof e?this.cache.filter((r=>this._filter(r,e,t))):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find((r=>this._filter(r,e,t)))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return o(e.props||{},s(r))}};$(q,"instance",{});let N=q;function F(){}function D(){D.init.call(this)}function M(e){return void 0===e._maxListeners?D.defaultMaxListeners:e._maxListeners}function G(e,t,r,n){var o,s,i,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]):(s=e._events=new F,e._eventsCount=0),i){if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),!i.warned&&(o=M(e))&&o>0&&i.length>o){i.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=i.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else i=s[t]=r,++e._eventsCount;return e}function B(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function H(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function z(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}F.prototype=Object.create(null),D.EventEmitter=D,D.usingDomains=!1,D.prototype.domain=void 0,D.prototype._events=void 0,D.prototype._maxListeners=void 0,D.defaultMaxListeners=10,D.init=function(){this.domain=null,D.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new F,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},D.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},D.prototype.getMaxListeners=function(){return M(this)},D.prototype.emit=function(e){var t,r,n,o,s,i,a,c="error"===e;if(i=this._events)c=c&&null==i.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=i[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=z(e,n),s=0;s<n;++s)o[s].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,s=z(e,o),i=0;i<o;++i)s[i].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var s=e.length,i=z(e,s),a=0;a<s;++a)i[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,s){if(t)e.call(r,n,o,s);else for(var i=e.length,a=z(e,i),c=0;c<i;++c)a[c].call(r,n,o,s)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),s=1;s<n;s++)o[s-1]=arguments[s];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,s=z(e,o),i=0;i<o;++i)s[i].apply(r,n)}(r,u,this,o)}return!0},D.prototype.on=D.prototype.addListener=function(e,t){return G(this,e,t,!1)},D.prototype.prependListener=function(e,t){return G(this,e,t,!0)},D.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,B(this,e,t)),this},D.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,B(this,e,t)),this},D.prototype.removeListener=function(e,t){var r,n,o,s,i;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new F:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new F,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,i||t)}return this},D.prototype.off=function(e,t){return this.removeListener(e,t)},D.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new F,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new F:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),s=0;s<o.length;++s)"removeListener"!==(n=o[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new F,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},D.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},D.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):H.call(e,t)},D.prototype.listenerCount=H,D.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var J="3.0.0-alpha.17";class Q extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var W=Object.defineProperty,K=(e,t,r)=>((e,t,r)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class V extends Error{constructor(e){super(),K(this,"name","NgwError"),K(this,"title"),K(this,"message"),K(this,"detail"),K(this,"exception"),K(this,"status_code"),K(this,"data"),K(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,V.prototype)}}var Y=Object.defineProperty,X=(e,t,r)=>((e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Z extends V{constructor(e){super(e),X(this,"name","InsufficientPermissionsError"),X(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,Z.prototype)}}var ee=Object.defineProperty,te=(e,t,r)=>((e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let re=class e extends V{constructor(t){super(t),te(this,"message","There is no response from the server or problem connecting to server."),te(this,"title","Network error"),te(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var ne=Object.defineProperty,oe=(e,t,r)=>((e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class se extends Error{constructor(e){super(),oe(this,"name","NetworkError"),Object.setPrototypeOf(this,se.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var ie=Object.defineProperty,ae=(e,t,r)=>((e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ce extends V{constructor(e){super(e),ae(this,"name","ResourceNotFoundError"),ae(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ce.prototype)}}var le=Object.freeze({__proto__:null,AbortError:Q,InsufficientPermissionsError:Z,NetworkError:se,NetworksResponseError:re,NgwError:V,ResourceNotFoundError:ce,extractError:function(e){if(i(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new re({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!i(e)&&(e.status_code&&e.exception&&e.title)}}),ue=Object.defineProperty,he=(e,t,r)=>((e,t,r)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class fe extends Error{constructor(e){super(e||"Something went wrong."),he(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,fe)}}class pe extends fe{constructor(e){super(e||"There is no response from the server or problem connecting to server."),he(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class de extends fe{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ye extends fe{constructor(e){super(e.message),he(this,"detail"),he(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class me extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),he(this,"title"),he(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,me)}}class ve extends me{constructor(e){super("Long-running request was cancelled.",e)}}class ge extends me{constructor(e){super(void 0,e)}}var be=Object.defineProperty,we=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,je=(e,t,r)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t)=>{for(var r in t||(t={}))Oe.call(t,r)&&je(e,r,t[r]);if(we)for(var r of we(t))xe.call(t,r)&&je(e,r,t[r]);return e},_e=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));function Ee(e){return _e(this,null,(function*(){const t=yield function(e){return _e(this,null,(function*(){try{return e.json()}catch(t){throw new Error}}))}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,s=`/api/lunkwill/${t.id}/response`,i=e=>new Promise((t=>setTimeout(t,e)));let a=!1,c=!1;for(;!c;){let e,t;yield i(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(l){a=!0;continue}switch(t.status){case void 0:throw new me(void 0,t);case"ready":c=!0;break;case"cancelled":throw new ve(t);case"failed":throw new ge(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new me(void 0,t)}}return s}))}const Ce=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function Ie(e,t){let r="";return void 0!==t&&(r="?"+function(e){const t=[];for(const[r,n]of Object.entries(e))if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)t.push(`${r}=${encodeURIComponent(n)}`);else if(Array.isArray(n))t.push(`${r}=${n.map(encodeURIComponent).join(",")}`);else for(const[e,o]of Object.entries(n)){const n=`${r}[${encodeURIComponent(e)}]`;if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)t.push(`${n}=${encodeURIComponent(o)}`);else if(Array.isArray(o)){const e=o.map(encodeURIComponent);t.push(`${n}=${e.join(",")}`)}}return t.join("&")}(t)),e+r}function ke(e,t,r){return _e(this,null,(function*(){var n,o;const i=Pe(Pe({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:l,cacheName:u,lunkwill:h,cache:f,query:p,json:d}=i,y=((e,t)=>{var r={};for(var n in e)Oe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&we)for(var n of we(e))t.indexOf(n)<0&&xe.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),a&&(y.credentials="include");let m=!1;void 0!==h&&(h.toHeaders(y.headers||{}),m=!0);const v=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=Ie(e,p),b=()=>_e(this,null,(function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new pe}if(m&&function(e){const t=e.headers.get("content-type");return null!=t&&t.includes("application/vnd.lunkwill.request-summary+json")}(e)){const t=yield Ee(e);if(v)return t;e=yield function(e){return _e(this,null,(function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new pe}}))}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&Ce.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new de;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof de)throw o;throw new de}if(400<=e.status&&e.status<=599)throw new ye(n);return n}));if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==f){const e=l||Pe({},s({withCredentials:a,responseType:c}));return r.add(u||g,b,{props:e,expirationTime:f?void 0:500})}}else{["api/feature_layer/identify"].every((t=>!e.includes(t)))&&r.clean()}return b()}))}var Re=Object.defineProperty,Se=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,$e=(e,t,r)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qe=(e,t)=>{for(var r in t||(t={}))Ae.call(t,r)&&$e(e,r,t[r]);if(Le)for(var r of Le(t))Ue.call(t,r)&&$e(e,r,t[r]);return e},Ne=(e,t)=>{var r={};for(var n in e)Ae.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Le)for(var n of Le(e))t.indexOf(n)<0&&Ue.call(e,n)&&(r[n]=e[n]);return r};function Fe(e,t,r,...n){const[o,...s]=r[e],i=n[0];let c;if(void 0===i)c=[];else if("object"==typeof i&&null!==i){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");c=[];for(const[e,t]of Object.entries(i))c[s.indexOf(e)]=String(t)}else c=n.map((e=>String(e)));return a(t+o.replace(/\{(\w+)\}/g,(function(e,t){const r=parseInt(t),n=c[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)})))}function De(e,t,...r){const n={url:n=>{return o=this,s=null,i=function*(){var o;const s=yield t.connect();return Ie(Fe(e,null!=(o=t.options.baseUrl)?o:"",s,...r),null==n?void 0:n.query)},new Promise(((e,t)=>{var r=e=>{try{a(i.next(e))}catch(r){t(r)}},n=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((i=i.apply(o,s)).next())}));var o,s,i}},o=["get","post","put","delete","patch"];for(const i of o){const o=n=>{var o;const a=n||{},{headers:c}=a,l=Ne(a,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new Q;return t.connect().then((n=>{var o;const a=Fe(e,null!=(o=t.options.baseUrl)?o:"",n,...r),u=s(qe(qe({},t.getAuthorizationHeaders()),null!=c?c:{}));return ke(a,(h=qe({headers:u},l),Se(h,Te({method:i}))),t.cache);var h}))};n[i]=o}return n}function Me(e){return"[object Object]"===Object.prototype.toString.call(e)}let Ge;Ge=(e,t,r={},n,o)=>{r.method=r.method||"GET";const s=new XMLHttpRequest;s.open(r.method||"GET",e,!0),"blob"===r.responseType&&(s.responseType=r.responseType);const i=()=>{try{return JSON.parse(s.responseText)}catch(e){return s.responseText}};s.onload=()=>{-1!==[401,403,404,422,500].indexOf(s.status)&&n(new V(i())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(s.response):s.responseText?o(i()):n({message:""})})()},s.onerror=t=>{n(0===s.status?new se(e):t)},s.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const l in a){const e=a[l];"string"==typeof e&&s.setRequestHeader(l,e)}let c;if(void 0!==r.withCredentials&&(s.withCredentials=r.withCredentials),r.file){if(c=new FormData,c.append("file",r.file),r.data)for(const l in r.data)c.append(l,c[l])}else c=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{s.abort()})),s.send(c)};const Be=[];function He(e){Be.push(e)}var ze=Object.defineProperty,Je=Object.defineProperties,Qe=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,Ye=(e,t,r)=>t in e?ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xe=(e,t)=>{for(var r in t||(t={}))Ke.call(t,r)&&Ye(e,r,t[r]);if(We)for(var r of We(t))Ve.call(t,r)&&Ye(e,r,t[r]);return e},Ze=(e,t,r)=>Ye(e,"symbol"!=typeof t?t+"":t,r),et=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));let tt=0,rt=0;class nt{constructor(e){this.options=e,Ze(this,"id",tt++),Ze(this,"emitter",new D),Ze(this,"user"),Ze(this,"cache"),Ze(this,"withCredentials"),Ze(this,"routeCache"),Ze(this,"client",`NextGIS-NGW-Connector/${J}`),Ze(this,"routeStr","/api/component/pyramid/route"),Ze(this,"activeRequests",{}),Ze(this,"requestTransform");const t=function(e){return Be.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return o(t.options.auth,e.auth)}}))}(e);if(this.cache=new N({namespace:e.cacheId}),this.routeCache=new N({namespace:"routecache"}),t)return t;{const{route:e,requestTransform:t,withCredentials:r}=this.options;e&&(this.routeStr=e),t&&(this.requestTransform=t),void 0!==r&&(this.withCredentials=r),He(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,He(this)}connect(){return et(this,arguments,(function*({signal:e}={}){const t=this.options.auth;if(t){const{login:e,password:r}=t;e&&r&&(yield this._login({login:e,password:r}))}const r=`${this.routeStr}?client=${this.client}`;return this.routeCache.add(this.options.baseUrl||String(this.id),(()=>this.makeQuery(r,null,{signal:e,cache:!1})))}))}login(e,t){return this.logout(),He(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Be.indexOf(e);-1!==t&&Be.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return et(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Xe({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Xe({},this.activeRequests)}route(e,...t){return De(e,this,...t)}makeQuery(e,t){return et(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)Ke.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&We)for(var n of We(e))t.indexOf(n)<0&&Ve.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=I(e,r)}e=encodeURI(a(e)),r=Xe({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:c="GET",headers:l,cacheName:u,cacheProps:h,responseType:f,withCredentials:p}=r,d=new AbortController,y=d.signal;if(i){if(i.aborted)throw new Q;i.addEventListener("abort",(()=>{d.abort()}))}r.signal=y;const m=()=>et(this,null,(function*(){const t=rt++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if("GET"===c&&!1!==o){const r=h||(v=Xe({},s({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Je(v,Qe({params:t})));return this.cache.add(u||e,m,{props:r,expirationTime:o?void 0:500})}var v;return m()}))}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Xe(Xe({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let s;Ge(e,r,t,n,(e=>{s=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==s&&s(),n(new Q)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return et(this,null,(function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}}))}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof V){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ce(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new Z(e)}return e}}Ze(nt,"errors",le);const ot=["description"];function st(e,r=""){r=r?r+"__":"";const n={};for(const[o,s]of Object.entries(e))if(-1===ot.indexOf(o))if(Me(s))if("owner_user"===o){const e=st(s,o);Object.assign(n,e)}else"parent"===o&&"id"in s&&(n.parent_id=s.id);else t(s)&&(n[r+o]=s);return n}var it=Object.defineProperty,at=Object.defineProperties,ct=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,ft=(e,t,r)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pt=(e,t)=>{for(var r in t||(t={}))ut.call(t,r)&&ft(e,r,t[r]);if(lt)for(var r of lt(t))ht.call(t,r)&&ft(e,r,t[r]);return e},dt=(e,t)=>at(e,ct(t)),yt=(e,t,r)=>ft(e,"symbol"!=typeof t?t+"":t,r),mt=(e,t,r)=>new Promise(((n,o)=>{var s=e=>{try{a(r.next(e))}catch(t){o(t)}},i=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((r=r.apply(e,t)).next())}));class vt{constructor({connector:e,cacheId:t}){yt(this,"cache"),yt(this,"connector"),this.connector=e,this.cache=new N({namespace:t})}getOne(e,t){const r=pt({},t);return"string"==typeof e||"number"==typeof e||Me(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Me(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new ce}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Me(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then((e=>{if(void 0===e)throw new Error;return e}))}getMany(e,t){return this._resourceCacheFilter(e).then((r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,st(e)),this.connector.route("resource.search").get(dt(pt({},t),{query:pt({serialization:"full"},r)})).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>{var r,n;return(null==(n=null==(r=null==e?void 0:e.resource)?void 0:r.parent)?void 0:n.id)?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)}))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t){return mt(this,arguments,(function*(e,t,r=[]){let n;n="string"==typeof e?yield this.getId(e,t):"object"==typeof e?e.id:e;const o=yield this.connector.route("resource.collection").get(dt(pt({},t),{query:{parent:n}})),s=[];for(const i of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(i),{id:i.resource.id}),r.push(i),(null==t?void 0:t.recursive)&&i.resource.children&&s.push(this._getChildrenOf(i.resource.id,t,r));return s.length?Promise.all(s).then((()=>r)):r}))}_cleanResourceItemCache(e){return mt(this,null,(function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)}))}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then((r=>(r.filter((r=>{if(r)return e.keyname&&r.resource.keyname?e.keyname===r.resource.keyname:t(e.id)&&t(r.resource.id)?e.id===r.resource.id:o(e,r.resource)})),[])))}}var gt=Object.defineProperty,bt=(e,t,r)=>((e,t,r)=>t in e?gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class wt extends nt{constructor(e){super(e),bt(this,"resources"),this.resources=new vt({connector:this,cacheId:e.cacheId})}static create(e){return new this(e)}clearCache(){super.clearCache(),this.resources.cache.clean()}apiRequest(e,t={},r={}){var n;return A({name:e,params:s(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}function Ot(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const xt={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>Ot(e,t),ilike:(e,t)=>Ot(e,t,!0)};function jt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Pt(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(jt(t)){const[r,n,o]=t,s=xt[n];if(s){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,s)=>(t=e[s],r.replace(s,o))));return s(t,n)}return s(e[r],o)}return!1}return Pt(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}const _t=7e3;var Et=Object.defineProperty,Ct=Object.defineProperties,It=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,Rt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Tt=(e,t,r)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Lt=(e,t)=>{for(var r in t||(t={}))Rt.call(t,r)&&Tt(e,r,t[r]);if(kt)for(var r of kt(t))St.call(t,r)&&Tt(e,r,t[r]);return e},At=(e,t)=>Ct(e,It(t));const Ut={srs:4326,geom_format:"geojson",dt_format:"iso"};function $t(e){return t=this,r=null,n=function*(){const t=Nt(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o},new Promise(((e,o)=>{var s=e=>{try{a(n.next(e))}catch(t){o(t)}},i=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((n=n.apply(t,r)).next())}));var t,r,n}function qt(e){const[t,r,n]=e;let o="",s="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,s=n,r)))}__${r}`,o+n+s]}function Nt(e,t=[],r=[]){var n;const{filters:o}=e,s=null!=(n=e.paramList)?n:[],i="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===i)for(const c of a)jt(c)?t.push(Dt(At(Lt({},e),{paramList:[...r,...s,qt(c)]}))):Nt(At(Lt({},e),{filters:c}),t,[...r]);else if("all"===i){const n=[],o=[];for(const e of a)jt(e)?n.push(qt(e)):o.push(e);if(o.length)for(const s of o)Nt(At(Lt({},e),{filters:s}),t,[...r,...n]);else t.push(Dt(At(Lt({},e),{paramList:[...r,...s,...n]})))}return t}function Ft(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=function(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function Dt(e){const r=Lt({},Ut),{limit:n,query:o,cache:s,signal:i,offset:a,orderBy:c,paramList:l,connector:u,geomFormat:h,intersects:f,resourceId:p}=e;if(r.limit=n&&n!==Number.POSITIVE_INFINITY?n:_t,a&&(r.offset=a),h&&(r.geom_format=h),function(e,r){const{extensions:n,geom:o,fields:s,srs:i,ilike:a,like:c}=r;e.extensions=n||[],s&&(e.fields=s),void 0!==o&&(e.geom=o,o||(delete e.srs,delete e.geom_format)),t(a)?e.ilike=a:t(c)&&(e.like=c),t(i)&&(e.srs=i)}(r,e),c&&(r.order_by=c.join(",")),Array.isArray(f)){const e=(d=f,Array.isArray(d)&&4===d.length&&d.every((e=>"number"==typeof e))?function(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}(f):f);r.intersects=Ft(e)}else"string"==typeof f&&(r.intersects=f);var d;return l&&Object.assign(r,function(e){return e.reduce(((e,[t,r])=>(e[t]=r,e)),{})}(l)),u.route("feature_layer.feature.collection",{id:Number(p)}).get({query:Lt(Lt({},r),o),cache:s,signal:i})}var Mt=Object.defineProperty,Gt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Qt=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wt=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Qt(e,r,t[r]);if(Ht)for(var r of Ht(t))Jt.call(t,r)&&Qt(e,r,t[r]);return e},Kt=(e,t)=>Gt(e,Bt(t));function Vt(e){return r=this,n=null,o=function*(){var r;const n=e.filters;if(n){let o=yield $t(Kt(Wt({},e),{filters:n}));return(null!=(r=e.clientFilterValidate)?r:Yt(n))&&(o=o.filter((e=>Pt(function(e){let r;for(r in e){const n=e[r];if(i(n)){const o=n;if(t(o.year)&&t(o.month)&&t(o.day)){const t=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach((e=>{t.push(e)})),e[r]=new Date(...t).toISOString()}}else"id"===r&&"string"==typeof n&&(e[r]=n.split(",").map(Number))}return e}(Kt(Wt({},e.fields),{id:e.id})),n)))),o}return Dt(e)},new Promise(((e,t)=>{var s=e=>{try{a(o.next(e))}catch(r){t(r)}},i=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(s,i);a((o=o.apply(r,n)).next())}));var r,n,o}function Yt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(Yt(r))return!0}}return!1}var Xt=Object.defineProperty,Zt=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,rr=(e,t,r)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nr=(e,t,r)=>rr(e,"symbol"!=typeof t?t+"":t,r),or=function(e,t){this[0]=e,this[1]=t},sr=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof or,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};const ir=class e extends E{constructor(e){var t;if(super(e),nr(this,"searchResources",[]),nr(this,"connector"),nr(this,"_abortControllers",[]),!e.searchUrl&&!(null==(t=e.connectorOptions)?void 0:t.baseUrl))throw new Error("The `searchUrl` of `connectorOptions.baseUrl` are required");this.connector=e.connector||new wt(((e,t)=>{for(var r in t||(t={}))er.call(t,r)&&rr(e,r,t[r]);if(Zt)for(var r of Zt(t))tr.call(t,r)&&rr(e,r,t[r]);return e})({baseUrl:this.searchUrl},e.connectorOptions)),this.searchResources=e.searchResources}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers.length=0}search(t){return sr(this,null,(function*(){var r,n;const o=this._makeSignal();for(const i of this.searchResources){if(o.aborted)break;const{searchMethod:a}=i,c=null!=(r=i.limit)?r:e.limit,l=null!=(n=i.id)?n:i.resourceId;try{const e=yield new or(this.connector.getResourceOrFail(l,{cache:!0})),r={connector:this.connector,resourceId:l,signal:o,limit:c};"like"===a?r.like=t:r.ilike=t;const n=Vt(r),s=yield new or(n);for(const o of this._items({entries:s,query:t,config:i,resourceItem:e}))o.result=()=>this.result(o),yield o}catch(s){s&&"name"in s&&"AbortError"!==s.name&&console.warn(s)}}}))}result(e){const t=this._makeSignal();return this.connector.route("feature_layer.feature.item_extent",{id:e.resourceId,fid:e.featureId}).get({signal:t}).then((t=>{const r=t.extent;return{text:e.text,extent:[r.minLon,r.minLat,r.maxLon,r.maxLat]}}))}reverse(e){return sr(this,null,(function*(){throw new Error("Not implemented")}))}_makeSignal(){const e=new AbortController;return this._abortControllers.push(e),e.signal}_items({entries:e,query:t,config:r,resourceItem:n}){var o;const s=[];let i;n.feature_layer&&(i=null==(o=n.feature_layer.fields.find((e=>e.label_field)))?void 0:o.keyname);return this.searchResources.find((e=>{var t;return null!=(t=e.id)?t:e.resourceId===n.resource.id}))&&e.forEach((e=>{let o=i?e.fields[i]:e.id;r.renderSearch?o=r.renderSearch({item:e,resourceItem:n}):i&&(o=e.fields[i]),s.push({query:t,text:o,featureId:e.id,resourceId:n.resource.id,item:e,resourceItem:n})})),s}};nr(ir,"limit",300);let ar=ir;var cr=Object.defineProperty,lr=(e,t,r)=>((e,t,r)=>t in e?cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),ur=function(e,t){this[0]=e,this[1]=t},hr=(e,t,r)=>{var n,o,s=(e,t,n,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof ur,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?s("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c}))).catch((e=>s("throw",e,n,o)))}catch(l){o(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>s(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};return e.BaseProvider=E,e.Geocoder=j,e.NgwProvider=ar,e.NominatimProvider=class extends E{constructor(e){super(),this.options=e,lr(this,"searchUrl","https://nominatim.openstreetmap.org"),lr(this,"_abortControllers",[]),e&&e.searchUrl&&(this.searchUrl=e.searchUrl)}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers=[]}search(e){return hr(this,null,(function*(){var t,r,n,o,s,i,c;const l=new URLSearchParams({format:"geojson",polygon_geojson:"1",q:e,limit:(null==(r=null==(t=this.options)?void 0:t.limit)?void 0:r.toString())||"10"});if((null==(n=this.options)?void 0:n.countrycodes)&&l.append("countrycodes",this.options.countrycodes),(null==(o=this.options)?void 0:o.addressdetails)&&l.append("addressdetails","1"),(null==(s=this.options)?void 0:s.language)&&l.append("accept-language",this.options.language),(null==(i=this.options)?void 0:i.bounded)&&l.append("bounded","1"),null==(c=this.options)?void 0:c.viewbox){const[e,t,r,n]=this.options.viewbox;l.append("viewbox",`${e},${t},${r},${n}`)}const u=a(`${this.searchUrl}/search?${l.toString()}`),h=new AbortController;this._abortControllers.push(h);try{const t=yield new ur(fetch(u,{signal:h.signal}));if(!t.ok)throw new Error(`Network response was not ok: ${t.statusText}`);const r=(yield new ur(t.json())).features.map((t=>({geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:e})));for(const e of r)e.result=()=>this.result(e),yield e}catch(f){if("AbortError"!==f.name)throw f}}))}result(e){return Promise.resolve({text:e.text,extent:e.extent||[],geom:e.geom})}reverse(e){return hr(this,null,(function*(){var t,r;const[n,o]=e,s=new URLSearchParams({format:"geojson",lat:o.toString(),lon:n.toString()});(null==(t=this.options)?void 0:t.addressdetails)&&s.append("addressdetails","1"),(null==(r=this.options)?void 0:r.language)&&s.append("accept-language",this.options.language);const i=a(`${this.searchUrl}/reverse?${s.toString()}`),c=new AbortController;this._abortControllers.push(c);try{const e=yield new ur(fetch(i,{signal:c.signal}));if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);const t=(yield new ur(e.json())).features[0],r={geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:`${o}, ${n}`};r.result=()=>this.result(r),yield r}catch(l){if("AbortError"!==l.name)throw l}}))}},e.create=function(e){return new j(e)},e}({});
2
2
  //# sourceMappingURL=geocoder.global.prod.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextgis/geocoder",
3
- "version": "3.0.0-alpha.17",
3
+ "version": "3.0.0-alpha.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "lib/geocoder.esm-bundler.js",
@@ -9,8 +9,8 @@
9
9
  "types": "lib/index.d.ts",
10
10
  "dependencies": {
11
11
  "@nextgis/cancelable-promise": "^3.0.0-alpha.17",
12
- "@nextgis/ngw-connector": "^3.0.0-alpha.17",
13
- "@nextgis/ngw-kit": "^3.0.0-alpha.17",
12
+ "@nextgis/ngw-connector": "^3.0.0-alpha.18",
13
+ "@nextgis/ngw-kit": "^3.0.0-alpha.18",
14
14
  "@nextgis/utils": "^3.0.0-alpha.17",
15
15
  "@types/events": "^3.0.0",
16
16
  "@types/geojson": "^7946.0.14",
@@ -53,5 +53,5 @@
53
53
  "bugs": {
54
54
  "url": "https://github.com/nextgis/nextgis_frontend/issues"
55
55
  },
56
- "gitHead": "771fb95598436a3456decca8a1d993d30687e1a3"
56
+ "gitHead": "0de9eccaa82b43981b9463d78a3ef1a135b13b55"
57
57
  }