@nextgis/geocoder 4.0.0-alpha.2 → 4.0.0-alpha.5
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.
- package/lib/geocoder.cjs.js +1 -1
- package/lib/geocoder.css +1 -0
- package/lib/geocoder.esm-browser.js +2 -2
- package/lib/geocoder.esm-browser.prod.js +1 -1
- package/lib/geocoder.esm-bundler.js +1 -1
- package/lib/geocoder.global.js +2 -2
- package/lib/geocoder.global.prod.js +1 -1
- package/package.json +7 -7
package/lib/geocoder.cjs.js
CHANGED
package/lib/geocoder.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.nextgis-qms-control{--nextgis-qms-control-width:300px;--nextgis-qms-control-max-height:380px;--nextgis-qms-control-background:#fff;--nextgis-qms-control-color:#252a31;--nextgis-qms-control-muted-color:#69717d;--nextgis-qms-control-accent:#0c65af;--nextgis-qms-control-border-color:#d8dde3;--nextgis-qms-control-hover-background:#f3f5f7;--nextgis-qms-control-border-radius:6px;--nextgis-qms-control-shadow:0 2px 10px rgba(0,0,0,.18);--nextgis-qms-control-gap:8px;color:var(--nextgis-qms-control-color);font:13px/1.4 -apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;width:-moz-max-content;width:max-content}.nextgis-qms-control.ol-control{background:transparent;left:var(--nextgis-qms-control-left,3em);padding:0;top:var(--nextgis-qms-control-top,.5em)}.nextgis-qms-control [hidden],.nextgis-qms-control[hidden]{display:none}.nextgis-qms-control button,.nextgis-qms-control input{box-sizing:border-box;font:inherit}.nextgis-qms-control button{margin:0}.nextgis-qms-control .nextgis-qms-control__toggle{background-color:var(--nextgis-qms-control-background);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' fill='none' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='%23176fc1' rx='7.291' style='stroke-width:.202532'/%3E%3Cpath fill='%23fff' d='M52 15.95H33.792a4 4 0 0 1-2.764-1.109l-1.868-1.784a4 4 0 0 0-2.764-1.108H10a2 2 0 0 0-2 2v6h48c0-2.208-1.792-4-4-4M21.244 34.261a3.1 3.1 0 0 0-1.116-.876q-.665-.31-1.492-.308-.846-.001-1.5.316a3.2 3.2 0 0 0-1.104.884q-.457.571-.692 1.364a6 6 0 0 0-.244 1.768q0 .983.24 1.768.241.786.692 1.356c.3.376.668.672 1.104.876q.654.307 1.5.308.827.002 1.492-.308a3.04 3.04 0 0 0 1.12-.876q.451-.57.692-1.356.24-.788.24-1.768a6.2 6.2 0 0 0-.24-1.78 4.1 4.1 0 0 0-.692-1.368' style='stroke-width:.202532'/%3E%3Cpath fill='%23fff' d='M8 23.95v26a2 2 0 0 0 2 2h44a2 2 0 0 0 2-2v-26zm16.928 15.99c-.232.748-.552 1.408-.972 1.972a5.6 5.6 0 0 1-1.492 1.404 6.1 6.1 0 0 1-1.904.808q.095.384.424.624c.216.16.496.292.824.396.336.1.72.176 1.164.232q.664.077 1.436.136l-.616 2.196q-1.5-.055-2.568-.296-1.069-.239-1.808-.664c-.496-.284-.884-.624-1.176-1.036a4.8 4.8 0 0 1-.664-1.424 6.9 6.9 0 0 1-2.216-.664 5.6 5.6 0 0 1-1.768-1.376q-.75-.869-1.176-2.08-.415-1.224-.416-2.76c0-1.14.18-2.148.54-3.012s.844-1.596 1.452-2.184a5.9 5.9 0 0 1 2.116-1.324 7.3 7.3 0 0 1 2.532-.444c.912 0 1.768.144 2.576.444a5.9 5.9 0 0 1 2.116 1.324q.906.888 1.428 2.184.516 1.296.516 3.012 0 1.404-.348 2.532m13.54 4.14a302 302 0 0 0-.152-4.232c-.06-1.524-.16-3.064-.284-4.616-.236.54-.492 1.132-.776 1.788q-.426.982-.84 1.964-.414.983-.804 1.876-.38.896-.652 1.528h-2.1c-.176-.424-.4-.932-.656-1.532q-.383-.896-.796-1.876c-.276-.656-.56-1.308-.84-1.964-.284-.652-.544-1.248-.772-1.784a107 107 0 0 0-.292 4.616q-.091 2.286-.152 4.236h-2.924q.072-1.579.18-3.368.107-1.793.232-3.568c.084-1.188.176-2.328.288-3.424q.166-1.648.356-2.972h2.876q.347.634.796 1.568a98 98 0 0 1 1.92 4.244l.904 2.136c.284-.664.584-1.38.904-2.136q.48-1.133.972-2.224.493-1.091.944-2.02c.304-.62.576-1.144.804-1.568h2.728a61 61 0 0 1 .356 2.972q.161 1.643.292 3.424.122 1.778.232 3.568.107 1.79.184 3.364zm12.224-.756q-1.306 1.032-3.944 1.032-.888-.001-1.596-.104a10 10 0 0 1-1.26-.26 8 8 0 0 1-.944-.328 7 7 0 0 1-.664-.324l.848-2.388c.396.216.888.416 1.472.588s1.296.26 2.144.26q.635-.001 1.048-.104c.276-.072.496-.164.664-.288a.94.94 0 0 0 .344-.436q.096-.247.096-.56.001-.653-.616-1.084t-2.116-.936a16 16 0 0 1-1.308-.528 4.8 4.8 0 0 1-1.176-.752 3.6 3.6 0 0 1-.844-1.096q-.326-.643-.328-1.568 0-.925.348-1.664c.232-.496.556-.916.984-1.26a4.5 4.5 0 0 1 1.536-.796q.906-.276 2.04-.276 1.35 0 2.328.288c.652.192 1.196.404 1.616.636L50.5 33.74a8 8 0 0 0-1.24-.508c-.456-.144-1.004-.22-1.644-.22q-1.08.001-1.548.296-.468.284-.468.904.001.365.176.616.174.25.492.452.318.203.732.364.413.162.916.336a21 21 0 0 1 1.808.76c.516.248.94.54 1.28.876s.596.724.76 1.176c.152.448.236.996.236 1.636 0 1.244-.436 2.212-1.308 2.896' style='stroke-width:.202532'/%3E%3C/svg%3E");background-position:50%;background-repeat:no-repeat;background-size:24px 24px;border:1px solid var(--nextgis-qms-control-border-color);border-radius:var(--nextgis-qms-control-border-radius);box-shadow:var(--nextgis-qms-control-shadow);color:var(--nextgis-qms-control-color);cursor:pointer;display:grid;height:32px;line-height:1;padding:0;place-items:center;width:32px}.nextgis-qms-control .nextgis-qms-control__toggle[hidden]{display:none}.nextgis-qms-control .nextgis-qms-control__about-close:hover,.nextgis-qms-control .nextgis-qms-control__about:hover,.nextgis-qms-control .nextgis-qms-control__close:hover,.nextgis-qms-control .nextgis-qms-control__service:hover,.nextgis-qms-control .nextgis-qms-control__toggle:hover,.nextgis-qms-control__group>summary:hover{background-color:var(--nextgis-qms-control-hover-background)}.nextgis-qms-control button:focus-visible,.nextgis-qms-control input:focus-visible,.nextgis-qms-control__group>summary:focus-visible{outline:2px solid var(--nextgis-qms-control-accent);outline-offset:-2px}.nextgis-qms-control__panel{background:var(--nextgis-qms-control-background);border:1px solid var(--nextgis-qms-control-border-color);border-radius:var(--nextgis-qms-control-border-radius);box-shadow:var(--nextgis-qms-control-shadow);box-sizing:border-box;overflow:hidden;padding:var(--nextgis-qms-control-gap);width:min(var(--nextgis-qms-control-width),calc(100vw - 20px))}.nextgis-qms-control__header{align-items:center;display:flex;justify-content:space-between;margin-bottom:var(--nextgis-qms-control-gap);min-height:28px}.nextgis-qms-control__title{font-size:14px;font-weight:600;padding-left:2px}.nextgis-qms-control .nextgis-qms-control__close{background:transparent;border:0;border-radius:4px;box-shadow:none;color:var(--nextgis-qms-control-muted-color);cursor:pointer;display:grid;font-size:0;height:28px;line-height:0;padding:0;place-items:center;position:relative;width:28px}.nextgis-qms-control__input{background:var(--nextgis-qms-control-background);border:1px solid var(--nextgis-qms-control-border-color);border-radius:4px;color:inherit;height:34px;padding:0 10px;width:100%}.nextgis-qms-control__input:focus{border-color:var(--nextgis-qms-control-accent)}.nextgis-qms-control__catalog,.nextgis-qms-control__results{border-top:1px solid var(--nextgis-qms-control-border-color);margin-top:var(--nextgis-qms-control-gap);max-height:var(--nextgis-qms-control-max-height);overflow-x:hidden;overflow-y:auto}.nextgis-qms-control__results{color:var(--nextgis-qms-control-muted-color);padding:6px 0}.nextgis-qms-control__results>.nextgis-qms-control__service{color:var(--nextgis-qms-control-color)}.nextgis-qms-control__group{border-bottom:1px solid var(--nextgis-qms-control-border-color)}.nextgis-qms-control__group>summary{align-items:center;cursor:pointer;display:flex;font-weight:600;list-style:none;min-height:36px;padding:0 8px}.nextgis-qms-control__group>summary::-webkit-details-marker{display:none}.nextgis-qms-control__group>summary:after{color:var(--nextgis-qms-control-muted-color);content:"›";flex:none;font-size:18px;margin-left:auto;transition:transform .12s ease}.nextgis-qms-control__group[open]>summary:after{transform:rotate(90deg)}.nextgis-qms-control__group-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nextgis-qms-control .nextgis-qms-control__service{background:transparent;border:0;border-radius:0;box-shadow:none;color:inherit;cursor:pointer;display:block;min-height:34px;overflow:hidden;padding:7px 10px;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%}.nextgis-qms-control__group>.nextgis-qms-control__service{color:var(--nextgis-qms-control-muted-color);padding-left:22px}.nextgis-qms-control__group>.nextgis-qms-control__service:hover{color:var(--nextgis-qms-control-color)}.nextgis-qms-control__footer{display:flex;justify-content:center;padding-top:var(--nextgis-qms-control-gap)}.nextgis-qms-control .nextgis-qms-control__about{background:transparent;border:0;box-shadow:none;color:var(--nextgis-qms-control-accent);cursor:pointer;display:inline-block;height:auto;line-height:inherit;padding:2px 6px;width:auto}.nextgis-qms-control__about-dialog{background:var(--nextgis-qms-control-background);border:1px solid var(--nextgis-qms-control-border-color);border-radius:var(--nextgis-qms-control-border-radius);box-shadow:var(--nextgis-qms-control-shadow);box-sizing:border-box;color:var(--nextgis-qms-control-color);font:inherit;padding:24px;text-align:left;width:min(420px,calc(100vw - 32px))}.nextgis-qms-control__about-dialog::backdrop{background:rgba(0,0,0,.4)}.nextgis-qms-control__about-title{display:block;font-size:16px;padding-right:24px}.nextgis-qms-control__about-dialog p{margin:12px 0}.nextgis-qms-control__about-links{display:grid;gap:6px}.nextgis-qms-control__about-links a{color:var(--nextgis-qms-control-accent)}.nextgis-qms-control .nextgis-qms-control__about-close{background:transparent;border:0;border-radius:4px;box-shadow:none;color:var(--nextgis-qms-control-muted-color);cursor:pointer;float:right;font-size:0;height:28px;line-height:0;padding:0;position:relative;width:28px}.nextgis-qms-control__about-close:after,.nextgis-qms-control__about-close:before,.nextgis-qms-control__close:after,.nextgis-qms-control__close:before{background:currentcolor;content:"";height:1px;left:50%;position:absolute;top:50%;width:12px}.nextgis-qms-control__about-close:before,.nextgis-qms-control__close:before{transform:translate(-50%,-50%) rotate(45deg)}.nextgis-qms-control__about-close:after,.nextgis-qms-control__close:after{transform:translate(-50%,-50%) rotate(-45deg)}.nextgis-qms-control.maplibregl-ctrl .nextgis-qms-control__toggle:not(:disabled):hover{background-color:var(--nextgis-qms-control-hover-background)}.nextgis-qms-control button.nextgis-qms-control__about:not(:focus-visible){outline:0}.nextgis-qms-control__about-developed-by{color:var(--nextgis-qms-control-muted-color)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.5; author: NextGIS */
|
|
2
2
|
function defined(val) {
|
|
3
3
|
return val !== void 0 && val !== null;
|
|
4
4
|
}
|
|
@@ -1018,7 +1018,7 @@ function unwrapListeners(arr) {
|
|
|
1018
1018
|
}
|
|
1019
1019
|
|
|
1020
1020
|
var pkg = {
|
|
1021
|
-
version: "4.0.0-alpha.
|
|
1021
|
+
version: "4.0.0-alpha.5"};
|
|
1022
1022
|
|
|
1023
1023
|
class AbortError extends Error {
|
|
1024
1024
|
constructor(message = "AbortError") {
|
|
@@ -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"[object Array]"===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 $(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 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 q=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(q,"instance",{});let N=q;var F;function D(){}function M(){M.init.call(this)}function B(e){return void 0===e._maxListeners?M.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 D,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=B(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 H(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 z(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 J(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}D.prototype=Object.create(null),M.EventEmitter=M,M.usingDomains=!1,M.prototype.domain=void 0,M.prototype._events=void 0,M.prototype._maxListeners=void 0,M.defaultMaxListeners=10,M.init=function(){this.domain=null,M.usingDomains&&(!F.active||this instanceof F.Domain||(this.domain=F.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new D,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},M.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},M.prototype.getMaxListeners=function(){return B(this)},M.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=J(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=J(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=J(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=J(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=J(e,o),i=0;i<o;++i)s[i].apply(r,n)}(r,u,this,o)}return!0},M.prototype.on=M.prototype.addListener=function(e,t){return G(this,e,t,!1)},M.prototype.prependListener=function(e,t){return G(this,e,t,!0)},M.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,H(this,e,t)),this},M.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,H(this,e,t)),this},M.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 D:(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 D,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},M.prototype.off=function(e,t){return this.removeListener(e,t)},M.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new D,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new D: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 D,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},M.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},M.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):z.call(e,t)},M.prototype.listenerCount=z,M.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Q="4.0.0-alpha.2";class W extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var K=Object.defineProperty,V=(e,t,r)=>((e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Y extends Error{constructor(e){super(),V(this,"name","NgwError"),V(this,"title"),V(this,"message"),V(this,"detail"),V(this,"exception"),V(this,"status_code"),V(this,"data"),V(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,Y.prototype)}}var X=Object.defineProperty,Z=(e,t,r)=>((e,t,r)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ee extends Y{constructor(e){super(e),Z(this,"name","InsufficientPermissionsError"),Z(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,ee.prototype)}}var te=Object.defineProperty,re=(e,t,r)=>((e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let ne=class e extends Y{constructor(t){super(t),re(this,"message","There is no response from the server or problem connecting to server."),re(this,"title","Network error"),re(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var oe=Object.defineProperty,se=(e,t,r)=>((e,t,r)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ie extends Error{constructor(e){super(),se(this,"name","NetworkError"),Object.setPrototypeOf(this,ie.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var ae=Object.defineProperty,ce=(e,t,r)=>((e,t,r)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class le extends Y{constructor(e){super(e),ce(this,"name","ResourceNotFoundError"),ce(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,le.prototype)}}var ue=Object.freeze({__proto__:null,AbortError:W,InsufficientPermissionsError:ee,NetworkError:ie,NetworksResponseError:ne,NgwError:Y,ResourceNotFoundError:le,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 ne({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!s(e)&&(e.status_code&&e.exception&&e.title)}}),he=Object.defineProperty,fe=(e,t,r)=>((e,t,r)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class pe extends Error{constructor(e){super(e||"Something went wrong."),fe(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,pe)}}class de extends pe{constructor(e){super(e||"There is no response from the server or problem connecting to server."),fe(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class ye extends pe{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class me extends pe{constructor(e){super(e.message),fe(this,"detail"),fe(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ve extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),fe(this,"title"),fe(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ve)}}class ge extends ve{constructor(e){super("Long-running request was cancelled.",e)}}class be extends ve{constructor(e){super(void 0,e)}}var we=Object.defineProperty,Oe=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Pe=(e,t,r)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_e=(e,t)=>{for(var r in t||(t={}))xe.call(t,r)&&Pe(e,r,t[r]);if(Oe)for(var r of Oe(t))je.call(t,r)&&Pe(e,r,t[r]);return e},Ee=(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 Ce(e){return Ee(this,null,function*(){const t=yield function(e){return Ee(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 ve(void 0,t);case"ready":c=!0;break;case"cancelled":throw new ge(t);case"failed":throw new be(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ve(void 0,t)}}return s})}const Ie=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ke(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 Re(e,t,r){return Ee(this,null,function*(){var n,s;const i=_e(_e({},{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)xe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Oe)for(var n of Oe(e))t.indexOf(n)<0&&je.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=ke(e,p),b=()=>Ee(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new de}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 Ce(e);if(v)return t;e=yield function(e){return Ee(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new de}})}(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&&Ie.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new ye;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof ye)throw o;throw new ye}if(400<=e.status&&e.status<=599)throw new me(n);return n});if(r)if("GET"===(null==(s=y.method)?void 0:s.toUpperCase())){if(!1!==f){const e=l||_e({},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 Se=Object.defineProperty,Te=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,qe=(e,t,r)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ne=(e,t)=>{for(var r in t||(t={}))Ae.call(t,r)&&qe(e,r,t[r]);if($e)for(var r of $e(t))Ue.call(t,r)&&qe(e,r,t[r]);return e},Fe=(e,t)=>{var r={};for(var n in e)Ae.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&$e)for(var n of $e(e))t.indexOf(n)<0&&Ue.call(e,n)&&(r[n]=e[n]);return r};function De(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 Me(e,t,...r){const n={url:n=>{return o=null,s=null,i=function*(){var o;const s=yield t.connect();return ke(De(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=Fe(a,["headers"]);if(null==(s=null==n?void 0:n.signal)?void 0:s.aborted)throw new W;return t.connect().then(n=>{var s;const a=De(e,null!=(s=t.options.baseUrl)?s:"",n,...r),u=o(Ne(Ne({},t.getAuthorizationHeaders()),null!=c?c:{}));return Re(a,(h=Ne({headers:u},l),Te(h,Le({method:i}))),t.cache);var h})};n[i]=s}return n}function Be(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 Y(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 ie(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 He=[];function ze(e){He.push(e)}var Je=Object.defineProperty,Qe=Object.defineProperties,We=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertySymbols,Ve=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable,Xe=(e,t,r)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ze=(e,t)=>{for(var r in t||(t={}))Ve.call(t,r)&&Xe(e,r,t[r]);if(Ke)for(var r of Ke(t))Ye.call(t,r)&&Xe(e,r,t[r]);return e},et=(e,t,r)=>Xe(e,"symbol"!=typeof t?t+"":t,r),tt=(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 rt=0,nt=0;class ot{constructor(e){this.options=e,et(this,"id",rt++),et(this,"emitter",new M),et(this,"user"),et(this,"cache"),et(this,"withCredentials"),et(this,"routeCache"),et(this,"client",`NextGIS-NGW-Connector/${Q}`),et(this,"routeStr","/api/component/pyramid/route"),et(this,"activeRequests",{}),et(this,"requestTransform");const t=function(e){return He.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 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),ze(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,ze(this)}connect(){return tt(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(),ze(this),this._login(e,t)}logout(){this.abort(),function(e){const t=He.indexOf(e);-1!==t&&He.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return tt(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ze({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)})}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e;return window.btoa(`${t}:${r}`)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Ze({},this.activeRequests)}route(e,...t){return Me(e,this,...t)}makeQuery(e,t){return tt(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=t,n=((e,t)=>{var r={};for(var n in e)Ve.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ke)for(var n of Ke(e))t.indexOf(n)<0&&Ye.call(e,n)&&(r[n]=e[n]);return r})(r,["paramList"]);e=I(e,n)}e=encodeURI(a(e)),r=Ze({withCredentials:this.withCredentials},r);const{cache:s,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 W;i.addEventListener("abort",()=>{d.abort()})}r.signal=y;const m=()=>tt(this,null,function*(){const t=nt++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===c&&!1!==s){const r=h||(v=Ze({},o({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Qe(v,We({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=Ze(Ze({},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 W)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return tt(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 Y){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new le(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new ee(e)}return e}}et(ot,"errors",ue);const st=["description"];function it(t,r=""){r=r?r+"__":"";const n={};for(const[o,s]of Object.entries(t))if(-1===st.indexOf(o))if(Be(s))if("owner_user"===o){const e=it(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 at=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,pt=(e,t,r)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dt=(e,t)=>{for(var r in t||(t={}))ht.call(t,r)&&pt(e,r,t[r]);if(ut)for(var r of ut(t))ft.call(t,r)&&pt(e,r,t[r]);return e},yt=(e,t)=>ct(e,lt(t)),mt=(e,t,r)=>pt(e,"symbol"!=typeof t?t+"":t,r),vt=(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 gt{constructor({connector:e,cacheId:t}){mt(this,"cache"),mt(this,"connector"),this.connector=e,this.cache=new N({namespace:t})}getOne(e,t){const r=dt({},t);return"string"==typeof e||"number"==typeof e||Be(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Be(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 le})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Be(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,it(e)),this.connector.route("resource.search").get(yt(dt({},t),{query:dt({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 vt(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(yt(dt({},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 vt(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 bt=Object.defineProperty,wt=(e,t,r)=>((e,t,r)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class Ot extends ot{constructor(e){super(e),wt(this,"resources"),this.resources=new gt({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 $({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 xt(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 jt={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)=>xt(e,t),ilike:(e,t)=>xt(e,t,!0)};function Pt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function _t(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Pt(t)){const[r,n,o]=t,s=jt[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 _t(e,t)},o=t.filter(e=>Array.isArray(e));return"any"===r?o.some(n):o.every(n)}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},$t=(e,t)=>Ct(e,It(t));const At={srs:4326,geom_format:"geojson",dt_format:"iso"};function Ut(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)Pt(c)?t.push(Dt($t(Lt({},e),{paramList:[...r,...s,qt(c)]}))):Nt($t(Lt({},e),{filters:c}),t,[...r]);else if("all"===i){const n=[],o=[];for(const e of a)Pt(e)?n.push(qt(e)):o.push(e);if(o.length)for(const s of o)Nt($t(Lt({},e),{filters:s}),t,[...r,...n]);else t.push(Dt($t(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(t){const r=Lt({},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("number"==typeof n&&n!==Number.POSITIVE_INFINITY&&(r.limit=n),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=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,Bt=Object.defineProperties,Gt=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)=>Bt(e,Gt(t));function Vt(t){return r=this,n=null,o=function*(){var r;const n=t.filters;if(n){let o=yield Ut(Kt(Wt({},t),{filters:n}));return(null!=(r=t.clientFilterValidate)?r:Yt(n))&&(o=o.filter(t=>_t(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}(Kt(Wt({},t.fields),{id:t.id})),n))),o}return Dt(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 Yt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(i(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 Ot(((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||{minLon:0,minLat:0,maxLon:0,maxLat:0};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};class fr 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}})}}function pr(e){return new j(e)}export{E as BaseProvider,j as Geocoder,ar as NgwProvider,fr as NominatimProvider,pr 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"[object Array]"===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 $(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 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 q=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(q,"instance",{});let N=q;var F;function D(){}function M(){M.init.call(this)}function B(e){return void 0===e._maxListeners?M.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 D,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=B(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 H(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 z(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 J(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}D.prototype=Object.create(null),M.EventEmitter=M,M.usingDomains=!1,M.prototype.domain=void 0,M.prototype._events=void 0,M.prototype._maxListeners=void 0,M.defaultMaxListeners=10,M.init=function(){this.domain=null,M.usingDomains&&(!F.active||this instanceof F.Domain||(this.domain=F.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new D,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},M.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},M.prototype.getMaxListeners=function(){return B(this)},M.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=J(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=J(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=J(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=J(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=J(e,o),i=0;i<o;++i)s[i].apply(r,n)}(r,u,this,o)}return!0},M.prototype.on=M.prototype.addListener=function(e,t){return G(this,e,t,!1)},M.prototype.prependListener=function(e,t){return G(this,e,t,!0)},M.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,H(this,e,t)),this},M.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,H(this,e,t)),this},M.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 D:(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 D,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},M.prototype.off=function(e,t){return this.removeListener(e,t)},M.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new D,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new D: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 D,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},M.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},M.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):z.call(e,t)},M.prototype.listenerCount=z,M.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Q="4.0.0-alpha.5";class W extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var K=Object.defineProperty,V=(e,t,r)=>((e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Y extends Error{constructor(e){super(),V(this,"name","NgwError"),V(this,"title"),V(this,"message"),V(this,"detail"),V(this,"exception"),V(this,"status_code"),V(this,"data"),V(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,Y.prototype)}}var X=Object.defineProperty,Z=(e,t,r)=>((e,t,r)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ee extends Y{constructor(e){super(e),Z(this,"name","InsufficientPermissionsError"),Z(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,ee.prototype)}}var te=Object.defineProperty,re=(e,t,r)=>((e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let ne=class e extends Y{constructor(t){super(t),re(this,"message","There is no response from the server or problem connecting to server."),re(this,"title","Network error"),re(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var oe=Object.defineProperty,se=(e,t,r)=>((e,t,r)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ie extends Error{constructor(e){super(),se(this,"name","NetworkError"),Object.setPrototypeOf(this,ie.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var ae=Object.defineProperty,ce=(e,t,r)=>((e,t,r)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class le extends Y{constructor(e){super(e),ce(this,"name","ResourceNotFoundError"),ce(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,le.prototype)}}var ue=Object.freeze({__proto__:null,AbortError:W,InsufficientPermissionsError:ee,NetworkError:ie,NetworksResponseError:ne,NgwError:Y,ResourceNotFoundError:le,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 ne({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!s(e)&&(e.status_code&&e.exception&&e.title)}}),he=Object.defineProperty,fe=(e,t,r)=>((e,t,r)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class pe extends Error{constructor(e){super(e||"Something went wrong."),fe(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,pe)}}class de extends pe{constructor(e){super(e||"There is no response from the server or problem connecting to server."),fe(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class ye extends pe{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class me extends pe{constructor(e){super(e.message),fe(this,"detail"),fe(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ve extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),fe(this,"title"),fe(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ve)}}class ge extends ve{constructor(e){super("Long-running request was cancelled.",e)}}class be extends ve{constructor(e){super(void 0,e)}}var we=Object.defineProperty,Oe=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Pe=(e,t,r)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_e=(e,t)=>{for(var r in t||(t={}))xe.call(t,r)&&Pe(e,r,t[r]);if(Oe)for(var r of Oe(t))je.call(t,r)&&Pe(e,r,t[r]);return e},Ee=(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 Ce(e){return Ee(this,null,function*(){const t=yield function(e){return Ee(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 ve(void 0,t);case"ready":c=!0;break;case"cancelled":throw new ge(t);case"failed":throw new be(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ve(void 0,t)}}return s})}const Ie=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ke(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 Re(e,t,r){return Ee(this,null,function*(){var n,s;const i=_e(_e({},{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)xe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Oe)for(var n of Oe(e))t.indexOf(n)<0&&je.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=ke(e,p),b=()=>Ee(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new de}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 Ce(e);if(v)return t;e=yield function(e){return Ee(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new de}})}(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&&Ie.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new ye;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof ye)throw o;throw new ye}if(400<=e.status&&e.status<=599)throw new me(n);return n});if(r)if("GET"===(null==(s=y.method)?void 0:s.toUpperCase())){if(!1!==f){const e=l||_e({},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 Se=Object.defineProperty,Te=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,qe=(e,t,r)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ne=(e,t)=>{for(var r in t||(t={}))Ae.call(t,r)&&qe(e,r,t[r]);if($e)for(var r of $e(t))Ue.call(t,r)&&qe(e,r,t[r]);return e},Fe=(e,t)=>{var r={};for(var n in e)Ae.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&$e)for(var n of $e(e))t.indexOf(n)<0&&Ue.call(e,n)&&(r[n]=e[n]);return r};function De(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 Me(e,t,...r){const n={url:n=>{return o=null,s=null,i=function*(){var o;const s=yield t.connect();return ke(De(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=Fe(a,["headers"]);if(null==(s=null==n?void 0:n.signal)?void 0:s.aborted)throw new W;return t.connect().then(n=>{var s;const a=De(e,null!=(s=t.options.baseUrl)?s:"",n,...r),u=o(Ne(Ne({},t.getAuthorizationHeaders()),null!=c?c:{}));return Re(a,(h=Ne({headers:u},l),Te(h,Le({method:i}))),t.cache);var h})};n[i]=s}return n}function Be(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 Y(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 ie(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 He=[];function ze(e){He.push(e)}var Je=Object.defineProperty,Qe=Object.defineProperties,We=Object.getOwnPropertyDescriptors,Ke=Object.getOwnPropertySymbols,Ve=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable,Xe=(e,t,r)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ze=(e,t)=>{for(var r in t||(t={}))Ve.call(t,r)&&Xe(e,r,t[r]);if(Ke)for(var r of Ke(t))Ye.call(t,r)&&Xe(e,r,t[r]);return e},et=(e,t,r)=>Xe(e,"symbol"!=typeof t?t+"":t,r),tt=(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 rt=0,nt=0;class ot{constructor(e){this.options=e,et(this,"id",rt++),et(this,"emitter",new M),et(this,"user"),et(this,"cache"),et(this,"withCredentials"),et(this,"routeCache"),et(this,"client",`NextGIS-NGW-Connector/${Q}`),et(this,"routeStr","/api/component/pyramid/route"),et(this,"activeRequests",{}),et(this,"requestTransform");const t=function(e){return He.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 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),ze(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,ze(this)}connect(){return tt(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(),ze(this),this._login(e,t)}logout(){this.abort(),function(e){const t=He.indexOf(e);-1!==t&&He.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return tt(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ze({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)})}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e;return window.btoa(`${t}:${r}`)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return Ze({},this.activeRequests)}route(e,...t){return Me(e,this,...t)}makeQuery(e,t){return tt(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=t,n=((e,t)=>{var r={};for(var n in e)Ve.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ke)for(var n of Ke(e))t.indexOf(n)<0&&Ye.call(e,n)&&(r[n]=e[n]);return r})(r,["paramList"]);e=I(e,n)}e=encodeURI(a(e)),r=Ze({withCredentials:this.withCredentials},r);const{cache:s,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 W;i.addEventListener("abort",()=>{d.abort()})}r.signal=y;const m=()=>tt(this,null,function*(){const t=nt++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===c&&!1!==s){const r=h||(v=Ze({},o({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Qe(v,We({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=Ze(Ze({},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 W)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return tt(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 Y){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new le(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new ee(e)}return e}}et(ot,"errors",ue);const st=["description"];function it(t,r=""){r=r?r+"__":"";const n={};for(const[o,s]of Object.entries(t))if(-1===st.indexOf(o))if(Be(s))if("owner_user"===o){const e=it(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 at=Object.defineProperty,ct=Object.defineProperties,lt=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,pt=(e,t,r)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dt=(e,t)=>{for(var r in t||(t={}))ht.call(t,r)&&pt(e,r,t[r]);if(ut)for(var r of ut(t))ft.call(t,r)&&pt(e,r,t[r]);return e},yt=(e,t)=>ct(e,lt(t)),mt=(e,t,r)=>pt(e,"symbol"!=typeof t?t+"":t,r),vt=(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 gt{constructor({connector:e,cacheId:t}){mt(this,"cache"),mt(this,"connector"),this.connector=e,this.cache=new N({namespace:t})}getOne(e,t){const r=dt({},t);return"string"==typeof e||"number"==typeof e||Be(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Be(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 le})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Be(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,it(e)),this.connector.route("resource.search").get(yt(dt({},t),{query:dt({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 vt(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(yt(dt({},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 vt(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 bt=Object.defineProperty,wt=(e,t,r)=>((e,t,r)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class Ot extends ot{constructor(e){super(e),wt(this,"resources"),this.resources=new gt({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 $({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 xt(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 jt={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)=>xt(e,t),ilike:(e,t)=>xt(e,t,!0)};function Pt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function _t(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Pt(t)){const[r,n,o]=t,s=jt[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 _t(e,t)},o=t.filter(e=>Array.isArray(e));return"any"===r?o.some(n):o.every(n)}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},$t=(e,t)=>Ct(e,It(t));const At={srs:4326,geom_format:"geojson",dt_format:"iso"};function Ut(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)Pt(c)?t.push(Dt($t(Lt({},e),{paramList:[...r,...s,qt(c)]}))):Nt($t(Lt({},e),{filters:c}),t,[...r]);else if("all"===i){const n=[],o=[];for(const e of a)Pt(e)?n.push(qt(e)):o.push(e);if(o.length)for(const s of o)Nt($t(Lt({},e),{filters:s}),t,[...r,...n]);else t.push(Dt($t(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(t){const r=Lt({},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("number"==typeof n&&n!==Number.POSITIVE_INFINITY&&(r.limit=n),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=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,Bt=Object.defineProperties,Gt=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)=>Bt(e,Gt(t));function Vt(t){return r=this,n=null,o=function*(){var r;const n=t.filters;if(n){let o=yield Ut(Kt(Wt({},t),{filters:n}));return(null!=(r=t.clientFilterValidate)?r:Yt(n))&&(o=o.filter(t=>_t(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}(Kt(Wt({},t.fields),{id:t.id})),n))),o}return Dt(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 Yt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(i(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 Ot(((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||{minLon:0,minLat:0,maxLon:0,maxLat:0};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};class fr 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}})}}function pr(e){return new j(e)}export{E as BaseProvider,j as Geocoder,ar as NgwProvider,fr as NominatimProvider,pr as create};
|
|
2
2
|
//# sourceMappingURL=geocoder.esm-browser.prod.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.5; 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';
|
package/lib/geocoder.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.5; author: NextGIS */
|
|
2
2
|
var Geocoder = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1021,7 +1021,7 @@ var Geocoder = (function (exports) {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
1023
|
var pkg = {
|
|
1024
|
-
version: "4.0.0-alpha.
|
|
1024
|
+
version: "4.0.0-alpha.5"};
|
|
1025
1025
|
|
|
1026
1026
|
class AbortError extends Error {
|
|
1027
1027
|
constructor(message = "AbortError") {
|
|
@@ -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 i=0;i<r.length;i++){if(!n(e[r[i]],t[o[i]],e,t))return!1}return!0}function i(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]=i(e[r])}),t}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function a(e){return"[object Array]"===Object.prototype.toString.call(e)}function c(e){return e.replace(/([^:]\/)\/+/g,"$1")}class l{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 u=Object.defineProperty,h=Object.defineProperties,f=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,m=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),v=(e,t,r)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))d.call(t,r)&&v(e,r,t[r]);if(p)for(var r of p(t))y.call(t,r)&&v(e,r,t[r]);return e},b=(e,t)=>h(e,f(t)),w=function(e,t){this[0]=e,this[1]=t},O=(e,t,r)=>{var n=(e,t,o,i)=>{try{var s=r[e](t),a=(t=s.value)instanceof w,c=s.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,i):o({value:r,done:c})).catch(e=>n("throw",e,o,i))}catch(l){i(l)}},o=e=>i[e]=t=>new Promise((r,o)=>n(e,t,r,o)),i={};return r=r.apply(e,t),i[m("asyncIterator")]=()=>i,o("next"),o("throw"),o("return"),i},x=(e,t,r)=>(t=e[m("asyncIterator")])?t.call(e):(e=e[m("iterator")](),t={},(r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:i}),o)))))("next"),r("return"),t);let j=0;class P extends l{constructor(e){super(e),v(this,"providers"+"",[]),e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach(e=>{e.abort&&e.abort()})}search(e){return O(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,i,s=x(r);n=!(o=yield new w(s.next())).done;n=!1){const e=o.value;t=!1,yield b(g({},e),{provider:c,_id:j++})}}catch(o){i=[o]}finally{try{n&&(o=s.return)&&(yield new w(o.call(s)))}finally{if(i)throw i[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 O(this,null,function*(){for(const s of this.providers)if(s.reverse)try{const i=s.reverse(e);try{for(var t,r,n,o=x(i);t=!(r=yield new w(o.next())).done;t=!1){const e=r.value;yield b(g({},e),{provider:s,_id:j++})}}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield new w(r.call(o)))}finally{if(n)throw n[0]}}}catch(i){}})}reverseGeocodeFirstResult(e){return t=this,r=null,n=function*(){for(const s of this.providers)if("function"==typeof s.reverse)try{try{for(var t,r,n,o=x(s.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(i){console.error("Error in reverse geocoding:",i)}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}}var _=Object.defineProperty,E=(e,t,r)=>((e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class C extends l{constructor(){super(...arguments),E(this,"searchUrl"),E(this,"label")}}const I=/\{ *([\w_-]+) *\}/g;function k(e,t){return e.replace(I,(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 R=Object.defineProperty,S=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,$=(e,t,r)=>t in e?R(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,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=k(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach(([e,t])=>{r.push(`${e}=${t}`)});for(const e in t)-1===s.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))T.call(t,r)&&$(e,r,t[r]);if(S)for(var r of S(t))L.call(t,r)&&$(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var U=Object.defineProperty,q=(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 N=class e{constructor(t={}){var r;q(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,s){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,o=a.onlyFull,s=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(i(c)));s=s?Date.now()+s:void 0;const l={key:e,value:n,props:a,expirationTime:s};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||{},i(r))}};q(N,"instance",{});let F=N;var D;function M(){}function G(){G.init.call(this)}function B(e){return void 0===e._maxListeners?G.defaultMaxListeners:e._maxListeners}function H(e,t,r,n){var o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]):(i=e._events=new M,e._eventsCount=0),s){if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(o=B(e))&&o>0&&s.length>o){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function z(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 J(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 Q(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}M.prototype=Object.create(null),G.EventEmitter=G,G.usingDomains=!1,G.prototype.domain=void 0,G.prototype._events=void 0,G.prototype._maxListeners=void 0,G.defaultMaxListeners=10,G.init=function(){this.domain=null,G.usingDomains&&(!D.active||this instanceof D.Domain||(this.domain=D.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new M,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},G.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},G.prototype.getMaxListeners=function(){return B(this)},G.prototype.emit=function(e){var t,r,n,o,i,s,a,c="error"===e;if(s=this._events)c=c&&null==s.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=s[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=Q(e,n),i=0;i<n;++i)o[i].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=Q(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=Q(e,i),a=0;a<i;++a)s[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,a=Q(e,s),c=0;c<s;++c)a[c].call(r,n,o,i)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=Q(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,u,this,o)}return!0},G.prototype.on=G.prototype.addListener=function(e,t){return H(this,e,t,!1)},G.prototype.prependListener=function(e,t){return H(this,e,t,!0)},G.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,z(this,e,t)),this},G.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,z(this,e,t)),this},G.prototype.removeListener=function(e,t){var r,n,o,i,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0===--this._eventsCount?this._events=new M:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0===--this._eventsCount)return this._events=new M,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,s||t)}return this},G.prototype.off=function(e,t){return this.removeListener(e,t)},G.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new M,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new M:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new M,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},G.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):[]},G.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):J.call(e,t)},G.prototype.listenerCount=J,G.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var W="4.0.0-alpha.2";class K extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}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 Error{constructor(e){super(),Y(this,"name","NgwError"),Y(this,"title"),Y(this,"message"),Y(this,"detail"),Y(this,"exception"),Y(this,"status_code"),Y(this,"data"),Y(this,"guru_meditation"),Object.assign(this,e),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);class te extends X{constructor(e){super(e),ee(this,"name","InsufficientPermissionsError"),ee(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,te.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,"symbol"!=typeof t?t+"":t,r);let oe=class e extends X{constructor(t){super(t),ne(this,"message","There is no response from the server or problem connecting to server."),ne(this,"title","Network error"),ne(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var ie=Object.defineProperty,se=(e,t,r)=>((e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ae extends Error{constructor(e){super(),se(this,"name","NetworkError"),Object.setPrototypeOf(this,ae.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var ce=Object.defineProperty,le=(e,t,r)=>((e,t,r)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ue extends X{constructor(e){super(e),le(this,"name","ResourceNotFoundError"),le(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ue.prototype)}}var he=Object.freeze({__proto__:null,AbortError:K,InsufficientPermissionsError:te,NetworkError:ae,NetworksResponseError:oe,NgwError:X,ResourceNotFoundError:ue,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 oe({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!s(e)&&(e.status_code&&e.exception&&e.title)}}),fe=Object.defineProperty,pe=(e,t,r)=>((e,t,r)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class de extends Error{constructor(e){super(e||"Something went wrong."),pe(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,de)}}class ye extends de{constructor(e){super(e||"There is no response from the server or problem connecting to server."),pe(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class me extends de{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ve extends de{constructor(e){super(e.message),pe(this,"detail"),pe(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ge extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),pe(this,"title"),pe(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ge)}}class be extends ge{constructor(e){super("Long-running request was cancelled.",e)}}class we extends ge{constructor(e){super(void 0,e)}}var Oe=Object.defineProperty,xe=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ee=(e,t)=>{for(var r in t||(t={}))je.call(t,r)&&_e(e,r,t[r]);if(xe)for(var r of xe(t))Pe.call(t,r)&&_e(e,r,t[r]);return e},Ce=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Ie(e){return Ce(this,null,function*(){const t=yield function(e){return Ce(this,null,function*(){try{return e.json()}catch(t){throw new Error}})}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise(t=>setTimeout(t,e));let a=!1,c=!1;for(;!c;){let e,t;yield s(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 ge(void 0,t);case"ready":c=!0;break;case"cancelled":throw new be(t);case"failed":throw new we(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ge(void 0,t)}}return i})}const ke=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function Re(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 Se(e,t,r){return Ce(this,null,function*(){var n,o;const s=Ee(Ee({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:l,cacheName:u,lunkwill:h,cache:f,query:p,json:d}=s,y=((e,t)=>{var r={};for(var n in e)je.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&xe)for(var n of xe(e))t.indexOf(n)<0&&Pe.call(e,n)&&(r[n]=e[n]);return r})(s,["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=Re(e,p),b=()=>Ce(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new ye}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 Ie(e);if(v)return t;e=yield function(e){return Ce(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new ye}})}(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&&ke.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new me;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof me)throw o;throw new me}if(400<=e.status&&e.status<=599)throw new ve(n);return n});if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==f){const e=l||Ee({},i({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 Te=Object.defineProperty,Le=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,Ae=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,Ne=(e,t,r)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fe=(e,t)=>{for(var r in t||(t={}))Ue.call(t,r)&&Ne(e,r,t[r]);if(Ae)for(var r of Ae(t))qe.call(t,r)&&Ne(e,r,t[r]);return e},De=(e,t)=>{var r={};for(var n in e)Ue.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ae)for(var n of Ae(e))t.indexOf(n)<0&&qe.call(e,n)&&(r[n]=e[n]);return r};function Me(e,t,r,...n){const[o,...i]=r[e],s=n[0];let a;if(void 0===s)a=[];else if("object"==typeof s&&null!==s){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");a=[];for(const[e,t]of Object.entries(s))a[i.indexOf(e)]=String(t)}else a=n.map(e=>String(e));return c(t+o.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)}))}function Ge(e,t,...r){const n={url:n=>{return o=null,i=null,s=function*(){var o;const i=yield t.connect();return Re(Me(e,null!=(o=t.options.baseUrl)?o:"",i,...r),null==n?void 0:n.query)},new Promise((e,t)=>{var r=e=>{try{a(s.next(e))}catch(r){t(r)}},n=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((s=s.apply(o,i)).next())});var o,i,s}},o=["get","post","put","delete","patch"];for(const s of o){const o=n=>{var o;const a=n||{},{headers:c}=a,l=De(a,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new K;return t.connect().then(n=>{var o;const a=Me(e,null!=(o=t.options.baseUrl)?o:"",n,...r),u=i(Fe(Fe({},t.getAuthorizationHeaders()),null!=c?c:{}));return Se(a,(h=Fe({headers:u},l),Le(h,$e({method:s}))),t.cache);var h})};n[s]=o}return n}function Be(e){return"[object Object]"===Object.prototype.toString.call(e)}let He;He=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new X(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new ae(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const l in a){const e=a[l];"string"==typeof e&&i.setRequestHeader(l,e)}let c;if(void 0!==r.withCredentials&&(i.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(()=>{i.abort()}),i.send(c)};const ze=[];function Je(e){ze.push(e)}var Qe=Object.defineProperty,We=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Ze=(e,t,r)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t)=>{for(var r in t||(t={}))Ye.call(t,r)&&Ze(e,r,t[r]);if(Ve)for(var r of Ve(t))Xe.call(t,r)&&Ze(e,r,t[r]);return e},tt=(e,t,r)=>Ze(e,"symbol"!=typeof t?t+"":t,r),rt=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});let nt=0,ot=0;class it{constructor(e){this.options=e,tt(this,"id",nt++),tt(this,"emitter",new G),tt(this,"user"),tt(this,"cache"),tt(this,"withCredentials"),tt(this,"routeCache"),tt(this,"client",`NextGIS-NGW-Connector/${W}`),tt(this,"routeStr","/api/component/pyramid/route"),tt(this,"activeRequests",{}),tt(this,"requestTransform");const t=function(e){return ze.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 F({namespace:e.cacheId}),this.routeCache=new F({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),Je(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Je(this)}connect(){return rt(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(),Je(this),this._login(e,t)}logout(){this.abort(),function(e){const t=ze.indexOf(e);-1!==t&&ze.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 rt(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=et({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)})}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e;return window.btoa(`${t}:${r}`)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return et({},this.activeRequests)}route(e,...t){return Ge(e,this,...t)}makeQuery(e,t){return rt(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=t,n=((e,t)=>{var r={};for(var n in e)Ye.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ve)for(var n of Ve(e))t.indexOf(n)<0&&Xe.call(e,n)&&(r[n]=e[n]);return r})(r,["paramList"]);e=k(e,n)}e=encodeURI(c(e)),r=et({withCredentials:this.withCredentials},r);const{cache:o,signal:s,method:a="GET",headers:l,cacheName:u,cacheProps:h,responseType:f,withCredentials:p}=r,d=new AbortController,y=d.signal;if(s){if(s.aborted)throw new K;s.addEventListener("abort",()=>{d.abort()})}r.signal=y;const m=()=>rt(this,null,function*(){const t=ot++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===a&&!1!==o){const r=h||(v=et({},i({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),We(v,Ke({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=et(et({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;He(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new K)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return rt(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 X){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ue(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new te(e)}return e}}tt(it,"errors",he);const st=["description"];function at(e,r=""){r=r?r+"__":"";const n={};for(const[o,i]of Object.entries(e))if(-1===st.indexOf(o))if(Be(i))if("owner_user"===o){const e=at(i,o);Object.assign(n,e)}else"parent"===o&&"id"in i&&(n.parent_id=i.id);else t(i)&&(n[r+o]=i);return n}var ct=Object.defineProperty,lt=Object.defineProperties,ut=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,ft=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,dt=(e,t,r)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))ft.call(t,r)&&dt(e,r,t[r]);if(ht)for(var r of ht(t))pt.call(t,r)&&dt(e,r,t[r]);return e},mt=(e,t)=>lt(e,ut(t)),vt=(e,t,r)=>dt(e,"symbol"!=typeof t?t+"":t,r),gt=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class bt{constructor({connector:e,cacheId:t}){vt(this,"cache"),vt(this,"connector"),this.connector=e,this.cache=new F({namespace:t})}getOne(e,t){const r=yt({},t);return"string"==typeof e||"number"==typeof e||Be(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Be(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 ue})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Be(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,at(e)),this.connector.route("resource.search").get(mt(yt({},t),{query:yt({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 gt(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(mt(yt({},t),{query:{parent:n}})),i=[];for(const s of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(s),{id:s.resource.id}),r.push(s),(null==t?void 0:t.recursive)&&s.resource.children&&i.push(this._getChildrenOf(s.resource.id,t,r));return i.length?Promise.all(i).then(()=>r):r})}_cleanResourceItemCache(e){return gt(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 wt=Object.defineProperty,Ot=(e,t,r)=>((e,t,r)=>t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class xt extends it{constructor(e){super(e),Ot(this,"resources"),this.resources=new bt({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:i(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 jt(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 Pt={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)=>jt(e,t),ilike:(e,t)=>jt(e,t,!0)};function _t(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Et(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(_t(t)){const[r,n,o]=t,i=Pt[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,(n,i)=>(t=e[i],r.replace(i,o)));return i(t,n)}return i(e[r],o)}return!1}return Et(e,t)},o=t.filter(e=>Array.isArray(e));return"any"===r?o.some(n):o.every(n)}var Ct=Object.defineProperty,It=Object.defineProperties,kt=Object.getOwnPropertyDescriptors,Rt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Lt=(e,t,r)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$t=(e,t)=>{for(var r in t||(t={}))St.call(t,r)&&Lt(e,r,t[r]);if(Rt)for(var r of Rt(t))Tt.call(t,r)&&Lt(e,r,t[r]);return e},At=(e,t)=>It(e,kt(t));const Ut={srs:4326,geom_format:"geojson",dt_format:"iso"};function qt(e){return t=this,r=null,n=function*(){const t=Ft(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 i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}function Nt(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,(e,t,r,n)=>(o=t,i=n,r))}__${r}`,o+n+i]}function Ft(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter(e=>Array.isArray(e));if("any"===s)for(const c of a)_t(c)?t.push(Mt(At($t({},e),{paramList:[...r,...i,Nt(c)]}))):Ft(At($t({},e),{filters:c}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)_t(e)?n.push(Nt(e)):o.push(e);if(o.length)for(const i of o)Ft(At($t({},e),{filters:i}),t,[...r,...n]);else t.push(Mt(At($t({},e),{paramList:[...r,...i,...n]})))}return t}function Dt(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 Mt(e){const r=$t({},Ut),{limit:n,query:o,cache:i,signal:s,offset:a,orderBy:c,paramList:l,connector:u,geomFormat:h,intersects:f,resourceId:p}=e;if("number"==typeof n&&n!==Number.POSITIVE_INFINITY&&(r.limit=n),a&&(r.offset=a),h&&(r.geom_format=h),function(e,r){const{extensions:n,geom:o,fields:i,srs:s,ilike:a,like:c}=r;e.extensions=n||[],i&&(e.fields=i),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(s)&&(e.srs=s)}(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=Dt(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:$t($t({},r),o),cache:i,signal:s})}var Gt=Object.defineProperty,Bt=Object.defineProperties,Ht=Object.getOwnPropertyDescriptors,zt=Object.getOwnPropertySymbols,Jt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Wt=(e,t,r)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kt=(e,t)=>{for(var r in t||(t={}))Jt.call(t,r)&&Wt(e,r,t[r]);if(zt)for(var r of zt(t))Qt.call(t,r)&&Wt(e,r,t[r]);return e},Vt=(e,t)=>Bt(e,Ht(t));function Yt(e){return r=this,n=null,o=function*(){var r;const n=e.filters;if(n){let o=yield qt(Vt(Kt({},e),{filters:n}));return(null!=(r=e.clientFilterValidate)?r:Xt(n))&&(o=o.filter(e=>Et(function(e){let r;for(r in e){const n=e[r];if(s(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}(Vt(Kt({},e.fields),{id:e.id})),n))),o}return Mt(e)},new Promise((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())});var r,n,o}function Xt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(a(r)){if(Xt(r))return!0}}return!1}var Zt=Object.defineProperty,er=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,nr=(e,t,r)=>t in e?Zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,or=(e,t,r)=>nr(e,"symbol"!=typeof t?t+"":t,r),ir=function(e,t){this[0]=e,this[1]=t},sr=(e,t,r)=>{var n,o,i=(e,t,n,o)=>{try{var s=r[e](t),a=(t=s.value)instanceof ir,c=s.done;Promise.resolve(a?t[0]:t).then(r=>a?i("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c})).catch(e=>i("throw",e,n,o))}catch(l){o(l)}},s=e=>a[e]=t=>new Promise((r,n)=>i(e,t,r,n)),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,s("next"),s("throw"),s("return"),a};const ar=class e extends C{constructor(e){var t;if(super(e),or(this,"searchResources",[]),or(this,"connector"),or(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 xt(((e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&nr(e,r,t[r]);if(er)for(var r of er(t))rr.call(t,r)&&nr(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 s of this.searchResources){if(o.aborted)break;const{searchMethod:a}=s,c=null!=(r=s.limit)?r:e.limit,l=null!=(n=s.id)?n:s.resourceId;try{const e=yield new ir(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=Yt(r),i=yield new ir(n);for(const o of this._items({entries:i,query:t,config:s,resourceItem:e}))o.result=()=>this.result(o),yield o}catch(i){i&&"name"in i&&"AbortError"!==i.name&&console.warn(i)}}})}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||{minLon:0,minLat:0,maxLon:0,maxLat:0};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 i=[];let s;n.feature_layer&&(s=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=s?e.fields[s]:e.id;r.renderSearch?o=r.renderSearch({item:e,resourceItem:n}):s&&(o=e.fields[s]),i.push({query:t,text:o,featureId:e.id,resourceId:n.resource.id,item:e,resourceItem:n})}),i}};or(ar,"limit",300);let cr=ar;var lr=Object.defineProperty,ur=(e,t,r)=>((e,t,r)=>t in e?lr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),hr=function(e,t){this[0]=e,this[1]=t},fr=(e,t,r)=>{var n,o,i=(e,t,n,o)=>{try{var s=r[e](t),a=(t=s.value)instanceof hr,c=s.done;Promise.resolve(a?t[0]:t).then(r=>a?i("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c})).catch(e=>i("throw",e,n,o))}catch(l){o(l)}},s=e=>a[e]=t=>new Promise((r,n)=>i(e,t,r,n)),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,s("next"),s("throw"),s("return"),a};return e.BaseProvider=C,e.Geocoder=P,e.NgwProvider=cr,e.NominatimProvider=class extends C{constructor(e){super(),this.options=e,ur(this,"searchUrl","https://nominatim.openstreetmap.org"),ur(this,"_abortControllers",[]),e&&e.searchUrl&&(this.searchUrl=e.searchUrl)}abort(){this._abortControllers.forEach(e=>{e.abort()}),this._abortControllers=[]}search(e){return fr(this,null,function*(){var t,r,n,o,i,s,a;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==(i=this.options)?void 0:i.language)&&l.append("accept-language",this.options.language),(null==(s=this.options)?void 0:s.bounded)&&l.append("bounded","1"),null==(a=this.options)?void 0:a.viewbox){const[e,t,r,n]=this.options.viewbox;l.append("viewbox",`${e},${t},${r},${n}`)}const u=c(`${this.searchUrl}/search?${l.toString()}`),h=new AbortController;this._abortControllers.push(h);try{const t=yield new hr(fetch(u,{signal:h.signal}));if(!t.ok)throw new Error(`Network response was not ok: ${t.statusText}`);const r=(yield new hr(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 fr(this,null,function*(){var t,r;const[n,o]=e,i=new URLSearchParams({format:"geojson",lat:o.toString(),lon:n.toString()});(null==(t=this.options)?void 0:t.addressdetails)&&i.append("addressdetails","1"),(null==(r=this.options)?void 0:r.language)&&i.append("accept-language",this.options.language);const s=c(`${this.searchUrl}/reverse?${i.toString()}`),a=new AbortController;this._abortControllers.push(a);try{const e=yield new hr(fetch(s,{signal:a.signal}));if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);const t=(yield new hr(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 P(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 i=0;i<r.length;i++){if(!n(e[r[i]],t[o[i]],e,t))return!1}return!0}function i(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]=i(e[r])}),t}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function a(e){return"[object Array]"===Object.prototype.toString.call(e)}function c(e){return e.replace(/([^:]\/)\/+/g,"$1")}class l{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 u=Object.defineProperty,h=Object.defineProperties,f=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,m=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),v=(e,t,r)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))d.call(t,r)&&v(e,r,t[r]);if(p)for(var r of p(t))y.call(t,r)&&v(e,r,t[r]);return e},b=(e,t)=>h(e,f(t)),w=function(e,t){this[0]=e,this[1]=t},O=(e,t,r)=>{var n=(e,t,o,i)=>{try{var s=r[e](t),a=(t=s.value)instanceof w,c=s.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,i):o({value:r,done:c})).catch(e=>n("throw",e,o,i))}catch(l){i(l)}},o=e=>i[e]=t=>new Promise((r,o)=>n(e,t,r,o)),i={};return r=r.apply(e,t),i[m("asyncIterator")]=()=>i,o("next"),o("throw"),o("return"),i},x=(e,t,r)=>(t=e[m("asyncIterator")])?t.call(e):(e=e[m("iterator")](),t={},(r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:i}),o)))))("next"),r("return"),t);let j=0;class P extends l{constructor(e){super(e),v(this,"providers"+"",[]),e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach(e=>{e.abort&&e.abort()})}search(e){return O(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,i,s=x(r);n=!(o=yield new w(s.next())).done;n=!1){const e=o.value;t=!1,yield b(g({},e),{provider:c,_id:j++})}}catch(o){i=[o]}finally{try{n&&(o=s.return)&&(yield new w(o.call(s)))}finally{if(i)throw i[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 O(this,null,function*(){for(const s of this.providers)if(s.reverse)try{const i=s.reverse(e);try{for(var t,r,n,o=x(i);t=!(r=yield new w(o.next())).done;t=!1){const e=r.value;yield b(g({},e),{provider:s,_id:j++})}}catch(r){n=[r]}finally{try{t&&(r=o.return)&&(yield new w(r.call(o)))}finally{if(n)throw n[0]}}}catch(i){}})}reverseGeocodeFirstResult(e){return t=this,r=null,n=function*(){for(const s of this.providers)if("function"==typeof s.reverse)try{try{for(var t,r,n,o=x(s.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(i){console.error("Error in reverse geocoding:",i)}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}}var _=Object.defineProperty,E=(e,t,r)=>((e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class C extends l{constructor(){super(...arguments),E(this,"searchUrl"),E(this,"label")}}const I=/\{ *([\w_-]+) *\}/g;function k(e,t){return e.replace(I,(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 R=Object.defineProperty,S=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,$=(e,t,r)=>t in e?R(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,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=k(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach(([e,t])=>{r.push(`${e}=${t}`)});for(const e in t)-1===s.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))T.call(t,r)&&$(e,r,t[r]);if(S)for(var r of S(t))L.call(t,r)&&$(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var U=Object.defineProperty,q=(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 N=class e{constructor(t={}){var r;q(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,s){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,o=a.onlyFull,s=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(i(c)));s=s?Date.now()+s:void 0;const l={key:e,value:n,props:a,expirationTime:s};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||{},i(r))}};q(N,"instance",{});let F=N;var D;function M(){}function G(){G.init.call(this)}function B(e){return void 0===e._maxListeners?G.defaultMaxListeners:e._maxListeners}function H(e,t,r,n){var o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]):(i=e._events=new M,e._eventsCount=0),s){if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(o=B(e))&&o>0&&s.length>o){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function z(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 J(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 Q(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}M.prototype=Object.create(null),G.EventEmitter=G,G.usingDomains=!1,G.prototype.domain=void 0,G.prototype._events=void 0,G.prototype._maxListeners=void 0,G.defaultMaxListeners=10,G.init=function(){this.domain=null,G.usingDomains&&(!D.active||this instanceof D.Domain||(this.domain=D.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new M,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},G.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},G.prototype.getMaxListeners=function(){return B(this)},G.prototype.emit=function(e){var t,r,n,o,i,s,a,c="error"===e;if(s=this._events)c=c&&null==s.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=s[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=Q(e,n),i=0;i<n;++i)o[i].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=Q(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=Q(e,i),a=0;a<i;++a)s[a].call(r,n,o)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,a=Q(e,s),c=0;c<s;++c)a[c].call(r,n,o,i)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=Q(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,u,this,o)}return!0},G.prototype.on=G.prototype.addListener=function(e,t){return H(this,e,t,!1)},G.prototype.prependListener=function(e,t){return H(this,e,t,!0)},G.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,z(this,e,t)),this},G.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,z(this,e,t)),this},G.prototype.removeListener=function(e,t){var r,n,o,i,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0===--this._eventsCount?this._events=new M:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;if(1===r.length){if(r[0]=void 0,0===--this._eventsCount)return this._events=new M,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(r,o);n.removeListener&&this.emit("removeListener",e,s||t)}return this},G.prototype.off=function(e,t){return this.removeListener(e,t)},G.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new M,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new M:delete r[e]),this;if(0===arguments.length){for(var n,o=Object.keys(r),i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new M,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},G.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):[]},G.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):J.call(e,t)},G.prototype.listenerCount=J,G.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var W="4.0.0-alpha.5";class K extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}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 Error{constructor(e){super(),Y(this,"name","NgwError"),Y(this,"title"),Y(this,"message"),Y(this,"detail"),Y(this,"exception"),Y(this,"status_code"),Y(this,"data"),Y(this,"guru_meditation"),Object.assign(this,e),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);class te extends X{constructor(e){super(e),ee(this,"name","InsufficientPermissionsError"),ee(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,te.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,"symbol"!=typeof t?t+"":t,r);let oe=class e extends X{constructor(t){super(t),ne(this,"message","There is no response from the server or problem connecting to server."),ne(this,"title","Network error"),ne(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var ie=Object.defineProperty,se=(e,t,r)=>((e,t,r)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ae extends Error{constructor(e){super(),se(this,"name","NetworkError"),Object.setPrototypeOf(this,ae.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var ce=Object.defineProperty,le=(e,t,r)=>((e,t,r)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ue extends X{constructor(e){super(e),le(this,"name","ResourceNotFoundError"),le(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ue.prototype)}}var he=Object.freeze({__proto__:null,AbortError:K,InsufficientPermissionsError:te,NetworkError:ae,NetworksResponseError:oe,NgwError:X,ResourceNotFoundError:ue,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 oe({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!s(e)&&(e.status_code&&e.exception&&e.title)}}),fe=Object.defineProperty,pe=(e,t,r)=>((e,t,r)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class de extends Error{constructor(e){super(e||"Something went wrong."),pe(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,de)}}class ye extends de{constructor(e){super(e||"There is no response from the server or problem connecting to server."),pe(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class me extends de{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ve extends de{constructor(e){super(e.message),pe(this,"detail"),pe(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ge extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),pe(this,"title"),pe(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ge)}}class be extends ge{constructor(e){super("Long-running request was cancelled.",e)}}class we extends ge{constructor(e){super(void 0,e)}}var Oe=Object.defineProperty,xe=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,_e=(e,t,r)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ee=(e,t)=>{for(var r in t||(t={}))je.call(t,r)&&_e(e,r,t[r]);if(xe)for(var r of xe(t))Pe.call(t,r)&&_e(e,r,t[r]);return e},Ce=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Ie(e){return Ce(this,null,function*(){const t=yield function(e){return Ce(this,null,function*(){try{return e.json()}catch(t){throw new Error}})}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise(t=>setTimeout(t,e));let a=!1,c=!1;for(;!c;){let e,t;yield s(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 ge(void 0,t);case"ready":c=!0;break;case"cancelled":throw new be(t);case"failed":throw new we(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ge(void 0,t)}}return i})}const ke=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function Re(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 Se(e,t,r){return Ce(this,null,function*(){var n,o;const s=Ee(Ee({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:l,cacheName:u,lunkwill:h,cache:f,query:p,json:d}=s,y=((e,t)=>{var r={};for(var n in e)je.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&xe)for(var n of xe(e))t.indexOf(n)<0&&Pe.call(e,n)&&(r[n]=e[n]);return r})(s,["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=Re(e,p),b=()=>Ce(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new ye}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 Ie(e);if(v)return t;e=yield function(e){return Ce(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new ye}})}(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&&ke.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new me;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof me)throw o;throw new me}if(400<=e.status&&e.status<=599)throw new ve(n);return n});if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==f){const e=l||Ee({},i({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 Te=Object.defineProperty,Le=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,Ae=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,Ne=(e,t,r)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fe=(e,t)=>{for(var r in t||(t={}))Ue.call(t,r)&&Ne(e,r,t[r]);if(Ae)for(var r of Ae(t))qe.call(t,r)&&Ne(e,r,t[r]);return e},De=(e,t)=>{var r={};for(var n in e)Ue.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ae)for(var n of Ae(e))t.indexOf(n)<0&&qe.call(e,n)&&(r[n]=e[n]);return r};function Me(e,t,r,...n){const[o,...i]=r[e],s=n[0];let a;if(void 0===s)a=[];else if("object"==typeof s&&null!==s){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");a=[];for(const[e,t]of Object.entries(s))a[i.indexOf(e)]=String(t)}else a=n.map(e=>String(e));return c(t+o.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=a[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)}))}function Ge(e,t,...r){const n={url:n=>{return o=null,i=null,s=function*(){var o;const i=yield t.connect();return Re(Me(e,null!=(o=t.options.baseUrl)?o:"",i,...r),null==n?void 0:n.query)},new Promise((e,t)=>{var r=e=>{try{a(s.next(e))}catch(r){t(r)}},n=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((s=s.apply(o,i)).next())});var o,i,s}},o=["get","post","put","delete","patch"];for(const s of o){const o=n=>{var o;const a=n||{},{headers:c}=a,l=De(a,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new K;return t.connect().then(n=>{var o;const a=Me(e,null!=(o=t.options.baseUrl)?o:"",n,...r),u=i(Fe(Fe({},t.getAuthorizationHeaders()),null!=c?c:{}));return Se(a,(h=Fe({headers:u},l),Le(h,$e({method:s}))),t.cache);var h})};n[s]=o}return n}function Be(e){return"[object Object]"===Object.prototype.toString.call(e)}let He;He=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new X(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new ae(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const l in a){const e=a[l];"string"==typeof e&&i.setRequestHeader(l,e)}let c;if(void 0!==r.withCredentials&&(i.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(()=>{i.abort()}),i.send(c)};const ze=[];function Je(e){ze.push(e)}var Qe=Object.defineProperty,We=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Ze=(e,t,r)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t)=>{for(var r in t||(t={}))Ye.call(t,r)&&Ze(e,r,t[r]);if(Ve)for(var r of Ve(t))Xe.call(t,r)&&Ze(e,r,t[r]);return e},tt=(e,t,r)=>Ze(e,"symbol"!=typeof t?t+"":t,r),rt=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});let nt=0,ot=0;class it{constructor(e){this.options=e,tt(this,"id",nt++),tt(this,"emitter",new G),tt(this,"user"),tt(this,"cache"),tt(this,"withCredentials"),tt(this,"routeCache"),tt(this,"client",`NextGIS-NGW-Connector/${W}`),tt(this,"routeStr","/api/component/pyramid/route"),tt(this,"activeRequests",{}),tt(this,"requestTransform");const t=function(e){return ze.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 F({namespace:e.cacheId}),this.routeCache=new F({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),Je(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Je(this)}connect(){return rt(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(),Je(this),this._login(e,t)}logout(){this.abort(),function(e){const t=ze.indexOf(e);-1!==t&&ze.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 rt(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=et({headers:this.getAuthorizationHeaders(e),cache:!0},t);return this.makeQuery("/api/component/auth/current_user",{},r)})}getAuthorizationHeaders(e){const t=this.makeClientId(e);return t?{Authorization:`Basic ${t}`}:{}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e;return window.btoa(`${t}:${r}`)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return et({},this.activeRequests)}route(e,...t){return Ge(e,this,...t)}makeQuery(e,t){return rt(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=t,n=((e,t)=>{var r={};for(var n in e)Ye.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ve)for(var n of Ve(e))t.indexOf(n)<0&&Xe.call(e,n)&&(r[n]=e[n]);return r})(r,["paramList"]);e=k(e,n)}e=encodeURI(c(e)),r=et({withCredentials:this.withCredentials},r);const{cache:o,signal:s,method:a="GET",headers:l,cacheName:u,cacheProps:h,responseType:f,withCredentials:p}=r,d=new AbortController,y=d.signal;if(s){if(s.aborted)throw new K;s.addEventListener("abort",()=>{d.abort()})}r.signal=y;const m=()=>rt(this,null,function*(){const t=ot++;this.activeRequests[t]=d;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===a&&!1!==o){const r=h||(v=et({},i({headers:l,withCredentials:p,responseType:f,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),We(v,Ke({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=et(et({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;He(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new K)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return rt(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 X){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ue(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new te(e)}return e}}tt(it,"errors",he);const st=["description"];function at(e,r=""){r=r?r+"__":"";const n={};for(const[o,i]of Object.entries(e))if(-1===st.indexOf(o))if(Be(i))if("owner_user"===o){const e=at(i,o);Object.assign(n,e)}else"parent"===o&&"id"in i&&(n.parent_id=i.id);else t(i)&&(n[r+o]=i);return n}var ct=Object.defineProperty,lt=Object.defineProperties,ut=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,ft=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,dt=(e,t,r)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yt=(e,t)=>{for(var r in t||(t={}))ft.call(t,r)&&dt(e,r,t[r]);if(ht)for(var r of ht(t))pt.call(t,r)&&dt(e,r,t[r]);return e},mt=(e,t)=>lt(e,ut(t)),vt=(e,t,r)=>dt(e,"symbol"!=typeof t?t+"":t,r),gt=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class bt{constructor({connector:e,cacheId:t}){vt(this,"cache"),vt(this,"connector"),this.connector=e,this.cache=new F({namespace:t})}getOne(e,t){const r=yt({},t);return"string"==typeof e||"number"==typeof e||Be(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Be(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 ue})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Be(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,at(e)),this.connector.route("resource.search").get(mt(yt({},t),{query:yt({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 gt(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(mt(yt({},t),{query:{parent:n}})),i=[];for(const s of o)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(s),{id:s.resource.id}),r.push(s),(null==t?void 0:t.recursive)&&s.resource.children&&i.push(this._getChildrenOf(s.resource.id,t,r));return i.length?Promise.all(i).then(()=>r):r})}_cleanResourceItemCache(e){return gt(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 wt=Object.defineProperty,Ot=(e,t,r)=>((e,t,r)=>t in e?wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class xt extends it{constructor(e){super(e),Ot(this,"resources"),this.resources=new bt({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:i(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 jt(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 Pt={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)=>jt(e,t),ilike:(e,t)=>jt(e,t,!0)};function _t(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Et(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(_t(t)){const[r,n,o]=t,i=Pt[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,(n,i)=>(t=e[i],r.replace(i,o)));return i(t,n)}return i(e[r],o)}return!1}return Et(e,t)},o=t.filter(e=>Array.isArray(e));return"any"===r?o.some(n):o.every(n)}var Ct=Object.defineProperty,It=Object.defineProperties,kt=Object.getOwnPropertyDescriptors,Rt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Lt=(e,t,r)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$t=(e,t)=>{for(var r in t||(t={}))St.call(t,r)&&Lt(e,r,t[r]);if(Rt)for(var r of Rt(t))Tt.call(t,r)&&Lt(e,r,t[r]);return e},At=(e,t)=>It(e,kt(t));const Ut={srs:4326,geom_format:"geojson",dt_format:"iso"};function qt(e){return t=this,r=null,n=function*(){const t=Ft(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 i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}function Nt(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,(e,t,r,n)=>(o=t,i=n,r))}__${r}`,o+n+i]}function Ft(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter(e=>Array.isArray(e));if("any"===s)for(const c of a)_t(c)?t.push(Mt(At($t({},e),{paramList:[...r,...i,Nt(c)]}))):Ft(At($t({},e),{filters:c}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)_t(e)?n.push(Nt(e)):o.push(e);if(o.length)for(const i of o)Ft(At($t({},e),{filters:i}),t,[...r,...n]);else t.push(Mt(At($t({},e),{paramList:[...r,...i,...n]})))}return t}function Dt(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 Mt(e){const r=$t({},Ut),{limit:n,query:o,cache:i,signal:s,offset:a,orderBy:c,paramList:l,connector:u,geomFormat:h,intersects:f,resourceId:p}=e;if("number"==typeof n&&n!==Number.POSITIVE_INFINITY&&(r.limit=n),a&&(r.offset=a),h&&(r.geom_format=h),function(e,r){const{extensions:n,geom:o,fields:i,srs:s,ilike:a,like:c}=r;e.extensions=n||[],i&&(e.fields=i),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(s)&&(e.srs=s)}(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=Dt(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:$t($t({},r),o),cache:i,signal:s})}var Gt=Object.defineProperty,Bt=Object.defineProperties,Ht=Object.getOwnPropertyDescriptors,zt=Object.getOwnPropertySymbols,Jt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Wt=(e,t,r)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kt=(e,t)=>{for(var r in t||(t={}))Jt.call(t,r)&&Wt(e,r,t[r]);if(zt)for(var r of zt(t))Qt.call(t,r)&&Wt(e,r,t[r]);return e},Vt=(e,t)=>Bt(e,Ht(t));function Yt(e){return r=this,n=null,o=function*(){var r;const n=e.filters;if(n){let o=yield qt(Vt(Kt({},e),{filters:n}));return(null!=(r=e.clientFilterValidate)?r:Xt(n))&&(o=o.filter(e=>Et(function(e){let r;for(r in e){const n=e[r];if(s(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}(Vt(Kt({},e.fields),{id:e.id})),n))),o}return Mt(e)},new Promise((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())});var r,n,o}function Xt(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(a(r)){if(Xt(r))return!0}}return!1}var Zt=Object.defineProperty,er=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,nr=(e,t,r)=>t in e?Zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,or=(e,t,r)=>nr(e,"symbol"!=typeof t?t+"":t,r),ir=function(e,t){this[0]=e,this[1]=t},sr=(e,t,r)=>{var n,o,i=(e,t,n,o)=>{try{var s=r[e](t),a=(t=s.value)instanceof ir,c=s.done;Promise.resolve(a?t[0]:t).then(r=>a?i("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c})).catch(e=>i("throw",e,n,o))}catch(l){o(l)}},s=e=>a[e]=t=>new Promise((r,n)=>i(e,t,r,n)),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,s("next"),s("throw"),s("return"),a};const ar=class e extends C{constructor(e){var t;if(super(e),or(this,"searchResources",[]),or(this,"connector"),or(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 xt(((e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&nr(e,r,t[r]);if(er)for(var r of er(t))rr.call(t,r)&&nr(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 s of this.searchResources){if(o.aborted)break;const{searchMethod:a}=s,c=null!=(r=s.limit)?r:e.limit,l=null!=(n=s.id)?n:s.resourceId;try{const e=yield new ir(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=Yt(r),i=yield new ir(n);for(const o of this._items({entries:i,query:t,config:s,resourceItem:e}))o.result=()=>this.result(o),yield o}catch(i){i&&"name"in i&&"AbortError"!==i.name&&console.warn(i)}}})}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||{minLon:0,minLat:0,maxLon:0,maxLat:0};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 i=[];let s;n.feature_layer&&(s=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=s?e.fields[s]:e.id;r.renderSearch?o=r.renderSearch({item:e,resourceItem:n}):s&&(o=e.fields[s]),i.push({query:t,text:o,featureId:e.id,resourceId:n.resource.id,item:e,resourceItem:n})}),i}};or(ar,"limit",300);let cr=ar;var lr=Object.defineProperty,ur=(e,t,r)=>((e,t,r)=>t in e?lr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),hr=function(e,t){this[0]=e,this[1]=t},fr=(e,t,r)=>{var n,o,i=(e,t,n,o)=>{try{var s=r[e](t),a=(t=s.value)instanceof hr,c=s.done;Promise.resolve(a?t[0]:t).then(r=>a?i("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,o):n({value:r,done:c})).catch(e=>i("throw",e,n,o))}catch(l){o(l)}},s=e=>a[e]=t=>new Promise((r,n)=>i(e,t,r,n)),a={};return r=r.apply(e,t),a[(n="asyncIterator",(o=Symbol[n])?o:Symbol.for("Symbol."+n))]=()=>a,s("next"),s("throw"),s("return"),a};return e.BaseProvider=C,e.Geocoder=P,e.NgwProvider=cr,e.NominatimProvider=class extends C{constructor(e){super(),this.options=e,ur(this,"searchUrl","https://nominatim.openstreetmap.org"),ur(this,"_abortControllers",[]),e&&e.searchUrl&&(this.searchUrl=e.searchUrl)}abort(){this._abortControllers.forEach(e=>{e.abort()}),this._abortControllers=[]}search(e){return fr(this,null,function*(){var t,r,n,o,i,s,a;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==(i=this.options)?void 0:i.language)&&l.append("accept-language",this.options.language),(null==(s=this.options)?void 0:s.bounded)&&l.append("bounded","1"),null==(a=this.options)?void 0:a.viewbox){const[e,t,r,n]=this.options.viewbox;l.append("viewbox",`${e},${t},${r},${n}`)}const u=c(`${this.searchUrl}/search?${l.toString()}`),h=new AbortController;this._abortControllers.push(h);try{const t=yield new hr(fetch(u,{signal:h.signal}));if(!t.ok)throw new Error(`Network response was not ok: ${t.statusText}`);const r=(yield new hr(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 fr(this,null,function*(){var t,r;const[n,o]=e,i=new URLSearchParams({format:"geojson",lat:o.toString(),lon:n.toString()});(null==(t=this.options)?void 0:t.addressdetails)&&i.append("addressdetails","1"),(null==(r=this.options)?void 0:r.language)&&i.append("accept-language",this.options.language);const s=c(`${this.searchUrl}/reverse?${i.toString()}`),a=new AbortController;this._abortControllers.push(a);try{const e=yield new hr(fetch(s,{signal:a.signal}));if(!e.ok)throw new Error(`Network response was not ok: ${e.statusText}`);const t=(yield new hr(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 P(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": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "lib/geocoder.esm-bundler.js",
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
"jsdelivr": "lib/geocoder.global.prod.js",
|
|
9
9
|
"types": "lib/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@nextgis/cancelable-promise": "
|
|
12
|
-
"@nextgis/ngw-connector": "4.0.0-alpha.
|
|
13
|
-
"@nextgis/ngw-kit": "4.0.0-alpha.
|
|
14
|
-
"@nextgis/utils": "4.0.0-alpha.
|
|
11
|
+
"@nextgis/cancelable-promise": "4.0.0-alpha.5",
|
|
12
|
+
"@nextgis/ngw-connector": "4.0.0-alpha.5",
|
|
13
|
+
"@nextgis/ngw-kit": "4.0.0-alpha.5",
|
|
14
|
+
"@nextgis/utils": "4.0.0-alpha.5",
|
|
15
15
|
"@types/events": "^3.0.0",
|
|
16
16
|
"@types/geojson": "^7946.0.14",
|
|
17
17
|
"events": "*"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@nextgis/build-tools": "
|
|
20
|
+
"@nextgis/build-tools": "4.0.0-alpha.5"
|
|
21
21
|
},
|
|
22
22
|
"buildOptions": {
|
|
23
23
|
"name": "Geocoder",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"bugs": {
|
|
54
54
|
"url": "https://github.com/nextgis/nextgis_frontend/issues"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "6a9155123c6bab511ee4ee719eabb7faff0cc387"
|
|
57
57
|
}
|