@nextgis/ngw-map
Version:
1 lines • 146 kB
JavaScript
const e={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'};function t(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const o=void 0===r.replace||r.replace;t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{const i=-1!==n.indexOf(r);if(!o&&!i||o){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}})})}function r(e,t,n=!1){let o=e;const i=t,s=Array.isArray(i);let a=s&&[]||{};return s&&Array.isArray(i)?n?(o=o||[],a=a.concat(o),i.forEach((e,t)=>{void 0===a[t]?a[t]=e:"object"==typeof e?a[t]=r(o[t],e,n):-1===o.indexOf(e)&&a.push(e)})):a=i:(o&&"object"==typeof o&&Object.keys(o).forEach(function(e){a[e]=o[e]}),Object.keys(i).forEach(function(e){a[e]="object"==typeof i[e]&&i[e]&&"object"==typeof o[e]&&"object"==typeof i[e]?r(o[e],i[e],n):i[e]})),a}function n(e){return null!=e}function o(e){return"string"==typeof e?!!e:n(e)}function i(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}function s(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}function a(e){return{type:"Polygon",coordinates:[l(e)]}}function l(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const c=Math.PI/180,u=180/Math.PI;function h(e,t,r=10,n=6){const o=r/6371*u,i=o/Math.cos(t*c),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+i*Math.cos(r),c=t+o*Math.sin(r);s.push([l,c])}return s}function p(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:d(e,t));return e===t}function d(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let o=0;o<r.length;o++){if(!p(e[r[o]],t[n[o]],e,t))return!1}return!0}function f(e){const t={};return Object.keys(e).forEach(r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=f(e[r])}),t}function y(e){return"[object Object]"===Object.prototype.toString.call(e)}function m(e){return"[object Array]"===Object.prototype.toString.call(e)}function b(e){return e.replace(/([^:]\/)\/+/g,"$1")}const g=/\{ *([\w_-]+) *\}/g;function v(e,t){return e.replace(g,(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 w=Object.defineProperty,_=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,P=(e,t,r)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function I(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=v(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={}))O.call(t,r)&&P(e,r,t[r]);if(_)for(var r of _(t))L.call(t,r)&&P(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 x=Object.defineProperty,j=(e,t,r)=>((e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const E=class e{constructor(t={}){var r;j(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,t,r,n,i){let s,a;"object"==typeof r&&"valueToSet"in r?(s=r,n=s.onlyFull,i=s.expirationTime,a=s.props):a=r;const l=this._find(e,a);if(l)return l.value;{let r;r=t instanceof Function?t():t;const s=a&&JSON.parse(JSON.stringify(f(a)));i=i?Date.now()+i:void 0;const l={key:e,value:r,props:s,expirationTime:i};return n&&!o(r)?r:(this.cache.push(l),r instanceof Promise?(r.catch(()=>{this.delete(e,a)}),n&&r.then(t=>(o(t)||this.delete(e,a),t)),r):r)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach(e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)}),e?this.cache.filter(r=>this._filter(r,e,t)).map(e=>e.value):this.cache.map(e=>e.value)}delete(e,t){const r="string"==typeof e?this.cache.filter(r=>this._filter(r,e,t)):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find(r=>this._filter(r,e,t))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return d(e.props||{},f(r))}};j(E,"instance",{});let A=E;function C(){}function k(){k.init.call(this)}function M(e){return void 0===e._maxListeners?k.defaultMaxListeners:e._maxListeners}function S(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 C,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=M(e))&&o>0&&s.length>o){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function T(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function N(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function R(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}C.prototype=Object.create(null),k.EventEmitter=k,k.usingDomains=!1,k.prototype.domain=void 0,k.prototype._events=void 0,k.prototype._maxListeners=void 0,k.defaultMaxListeners=10,k.init=function(){this.domain=null,k.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new C,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},k.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},k.prototype.getMaxListeners=function(){return M(this)},k.prototype.emit=function(e){var t,r,n,o,i,s,a,l="error"===e;if(s=this._events)l=l&&null==s.error;else if(!l)return!1;if(a=this.domain,l){if(t=arguments[1],!a){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=R(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=R(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=R(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=R(e,s),l=0;l<s;++l)a[l].call(r,n,o,i)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=R(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,u,this,o)}return!0},k.prototype.on=k.prototype.addListener=function(e,t){return S(this,e,t,!1)},k.prototype.prependListener=function(e,t){return S(this,e,t,!0)},k.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,T(this,e,t)),this},k.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,T(this,e,t)),this},k.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 C:(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 C,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},k.prototype.off=function(e,t){return this.removeListener(e,t)},k.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new C,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new C: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 C,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},k.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):[]},k.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):N.call(e,t)},k.prototype.listenerCount=N,k.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var F="3.0.1";class B extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var $=Object.defineProperty,q=(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 D extends Error{constructor(e){super(),q(this,"name","NgwError"),q(this,"title"),q(this,"message"),q(this,"detail"),q(this,"exception"),q(this,"status_code"),q(this,"data"),q(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,D.prototype)}}var U=Object.defineProperty,V=(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);class G extends D{constructor(e){super(e),V(this,"name","InsufficientPermissionsError"),V(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,G.prototype)}}var z=Object.defineProperty,Z=(e,t,r)=>((e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let W=class e extends D{constructor(t){super(t),Z(this,"message","There is no response from the server or problem connecting to server."),Z(this,"title","Network error"),Z(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var H=Object.defineProperty,J=(e,t,r)=>((e,t,r)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class Q extends Error{constructor(e){super(),J(this,"name","NetworkError"),Object.setPrototypeOf(this,Q.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var K=Object.defineProperty,X=(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 D{constructor(e){super(e),X(this,"name","ResourceNotFoundError"),X(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,Y.prototype)}}var ee=Object.freeze({__proto__:null,AbortError:B,InsufficientPermissionsError:G,NetworkError:Q,NetworksResponseError:W,NgwError:D,ResourceNotFoundError:Y,extractError:function(e){if(y(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new W({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!y(e)&&(e.status_code&&e.exception&&e.title)}}),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);class ne extends Error{constructor(e){super(e||"Something went wrong."),re(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,ne)}}class oe extends ne{constructor(e){super(e||"There is no response from the server or problem connecting to server."),re(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class ie extends ne{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class se extends ne{constructor(e){super(e.message),re(this,"detail"),re(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class ae extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),re(this,"title"),re(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,ae)}}class le extends ae{constructor(e){super("Long-running request was cancelled.",e)}}class ce extends ae{constructor(e){super(void 0,e)}}var ue=Object.defineProperty,he=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,fe=(e,t,r)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t)=>{for(var r in t||(t={}))pe.call(t,r)&&fe(e,r,t[r]);if(he)for(var r of he(t))de.call(t,r)&&fe(e,r,t[r]);return e},me=(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 be(e){return me(this,null,function*(){const t=yield function(e){return me(this,null,function*(){try{return e.json()}catch(t){throw new Error}})}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise(t=>setTimeout(t,e));let a=!1,l=!1;for(;!l;){let e,t;yield s(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(c){a=!0;continue}switch(t.status){case void 0:throw new ae(void 0,t);case"ready":l=!0;break;case"cancelled":throw new le(t);case"failed":throw new ce(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new ae(void 0,t)}}return i})}const ge=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ve(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 we(e,t,r){return me(this,null,function*(){var n,o;const i=ye(ye({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:s,responseType:a,cacheProps:l,cacheName:c,lunkwill:u,cache:h,query:p,json:d}=i,y=((e,t)=>{var r={};for(var n in e)pe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&he)for(var n of he(e))t.indexOf(n)<0&&de.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),s&&(y.credentials="include");let m=!1;void 0!==u&&(u.toHeaders(y.headers||{}),m=!0);const b=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=ve(e,p),v=()=>me(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new oe}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 be(e);if(b)return t;e=yield function(e){return me(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new oe}})}(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&&ge.test(t);if("blob"===a||o)n=yield e.blob();else{if(!r)throw new ie;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof ie)throw o;throw new ie}if(400<=e.status&&e.status<=599)throw new se(n);return n});if(r)if("GET"===(null==(o=y.method)?void 0:o.toUpperCase())){if(!1!==h){const e=l||ye({},f({withCredentials:s,responseType:a}));return r.add(c||g,v,{props:e,expirationTime:h?void 0:500})}}else{["api/feature_layer/identify"].every(t=>!e.includes(t))&&r.clean()}return v()})}var _e=Object.defineProperty,Oe=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,je=(e,t,r)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ee=(e,t)=>{for(var r in t||(t={}))Ie.call(t,r)&&je(e,r,t[r]);if(Pe)for(var r of Pe(t))xe.call(t,r)&&je(e,r,t[r]);return e},Ae=(e,t)=>{var r={};for(var n in e)Ie.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Pe)for(var n of Pe(e))t.indexOf(n)<0&&xe.call(e,n)&&(r[n]=e[n]);return r};function Ce(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 b(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 ke(e,t,...r){const n={url:n=>{return o=null,i=null,s=function*(){var o;const i=yield t.connect();return ve(Ce(e,null!=(o=t.options.baseUrl)?o:"",i,...r),null==n?void 0:n.query)},new Promise((e,t)=>{var r=e=>{try{a(s.next(e))}catch(r){t(r)}},n=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,n);a((s=s.apply(o,i)).next())});var o,i,s}},o=["get","post","put","delete","patch"];for(const i of o){const o=n=>{var o;const s=n||{},{headers:a}=s,l=Ae(s,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new B;return t.connect().then(n=>{var o;const s=Ce(e,null!=(o=t.options.baseUrl)?o:"",n,...r),c=f(Ee(Ee({},t.getAuthorizationHeaders()),null!=a?a:{}));return we(s,(u=Ee({headers:c},l),Oe(u,Le({method:i}))),t.cache);var u})};n[i]=o}return n}function Me(e){return"[object Object]"===Object.prototype.toString.call(e)}let Se;Se=(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 D(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 Q(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&i.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o(()=>{i.abort()}),i.send(l)};const Te=[];function Ne(e){Te.push(e)}var Re=Object.defineProperty,Fe=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,Ue=(e,t,r)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ve=(e,t)=>{for(var r in t||(t={}))qe.call(t,r)&&Ue(e,r,t[r]);if($e)for(var r of $e(t))De.call(t,r)&&Ue(e,r,t[r]);return e},Ge=(e,t,r)=>Ue(e,"symbol"!=typeof t?t+"":t,r),ze=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});let Ze=0,We=0;class He{constructor(e){this.options=e,Ge(this,"id",Ze++),Ge(this,"emitter",new k),Ge(this,"user"),Ge(this,"cache"),Ge(this,"withCredentials"),Ge(this,"routeCache"),Ge(this,"client",`NextGIS-NGW-Connector/${F}`),Ge(this,"routeStr","/api/component/pyramid/route"),Ge(this,"activeRequests",{}),Ge(this,"requestTransform");const t=function(e){return Te.find(t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return d(t.options.auth,e.auth)}})}(e);if(this.cache=new A({namespace:e.cacheId}),this.routeCache=new A({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),Ne(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Ne(this)}connect(){return ze(this,arguments,function*({signal:e}={}){const t=this.options.auth;if(t){const{login:e,password:r}=t;e&&r&&(yield this._login({login:e,password:r}))}const r=`${this.routeStr}?client=${this.client}`;return this.routeCache.add(this.options.baseUrl||String(this.id),()=>this.makeQuery(r,null,{signal:e,cache:!1}))})}login(e,t){return this.logout(),Ne(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Te.indexOf(e);-1!==t&&Te.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.routeCache.clean(),this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return ze(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=Ve({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 Ve({},this.activeRequests)}route(e,...t){return ke(e,this,...t)}makeQuery(e,t){return ze(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)qe.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&&De.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=v(e,r)}e=encodeURI(b(e)),r=Ve({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:h}=r,p=new AbortController,d=p.signal;if(i){if(i.aborted)throw new B;i.addEventListener("abort",()=>{p.abort()})}r.signal=d;const y=()=>ze(this,null,function*(){const t=We++;this.activeRequests[t]=p;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===s&&!1!==o){const r=c||(m=Ve({},f({headers:a,withCredentials:h,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Fe(m,Be({params:t})));return this.cache.add(l||e,y,{props:r,expirationTime:o?void 0:500})}var m;return y()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Ve(Ve({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;Se(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new B)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return ze(this,null,function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}})}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof D){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new Y(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new G(e)}return e}}Ge(He,"errors",ee);const Je=["description"];function Qe(e,t=""){t=t?t+"__":"";const r={};for(const[o,i]of Object.entries(e))if(-1===Je.indexOf(o))if(Me(i))if("owner_user"===o){const e=Qe(i,o);Object.assign(r,e)}else"parent"===o&&"id"in i&&(r.parent_id=i.id);else n(i)&&(r[t+o]=i);return r}var Ke=Object.defineProperty,Xe=Object.defineProperties,Ye=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,tt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,nt=(e,t,r)=>t in e?Ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ot=(e,t)=>{for(var r in t||(t={}))tt.call(t,r)&&nt(e,r,t[r]);if(et)for(var r of et(t))rt.call(t,r)&&nt(e,r,t[r]);return e},it=(e,t)=>Xe(e,Ye(t)),st=(e,t,r)=>nt(e,"symbol"!=typeof t?t+"":t,r),at=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});class lt{constructor({connector:e,cacheId:t}){st(this,"cache"),st(this,"connector"),this.connector=e,this.cache=new A({namespace:t})}getOne(e,t){const r=ot({},t);return"string"==typeof e||"number"==typeof e||Me(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Me(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then(e=>{if(e)return e;throw new Y})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Me(e)?this.getOne(e,t).then(e=>{if(e)return e.resource.id}):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then(e=>{if(void 0===e)throw new Error;return e})}getMany(e,t){return this._resourceCacheFilter(e).then(r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,Qe(e)),this.connector.route("resource.search").get(it(ot({},t),{query:ot({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 at(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(it(ot({},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 at(this,null,function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)})}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then(e=>e[0])}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then(t=>(t.filter(t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:n(e.id)&&n(t.resource.id)?e.id===t.resource.id:d(e,t.resource)}),[]))}}var ct=Object.defineProperty,ut=(e,t,r)=>((e,t,r)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ht extends He{constructor(e){super(e),ut(this,"resources"),this.resources=new lt({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 I({name:e,params:f(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}var pt=Object.defineProperty,dt=Object.defineProperties,ft=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable,gt=(e,t,r)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vt=(e,t)=>{for(var r in t||(t={}))mt.call(t,r)&>(e,r,t[r]);if(yt)for(var r of yt(t))bt.call(t,r)&>(e,r,t[r]);return e},wt=(e,t)=>dt(e,ft(t));function _t(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,o=e.extent_right;if(t&&r&&n&&o){const e=[r,t,o,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function Ot({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.route("layer.extent",{id:Number(e)}).get({cache:r,signal:n}).then(e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}})}function Lt(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then(t=>{if(t)return Pt(t,e.connector,e)})}function Pt(e,t,r){if(e.webmap)return Promise.resolve(_t(e.webmap));{const n=e.resource;return n.cls&&n.parent&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id,r).then(e=>{if(e)return Ot(wt(vt({},r),{resourceId:e.resource.id,connector:t}))}):Ot(wt(vt({},r),{resourceId:n.id,connector:t}))}}var It=Object.defineProperty,xt=(e,t,r)=>((e,t,r)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),jt=(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 Et{constructor(){xt(this,"item"),xt(this,"connector"),xt(this,"_extent")}getExtent(){return jt(this,null,function*(){return this.getBounds()})}getBounds(e){return jt(this,null,function*(){return this._extent?this._extent:this.item?(this._extent=yield Pt(this.item,this.connector,e),this._extent):void 0})}}function At(e,t){return r=this,n=null,o=function*(){const r=e.resource,n=r;let{keyname:o,resourceId:i}=e;if(r&&("string"==typeof r?o=r:i="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield At(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i},new Promise((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())});var r,n,o}var Ct=Object.defineProperty,kt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Tt=(e,t,r)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nt=(e,t,r)=>Tt(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())});function Ft(e){return Rt(this,arguments,function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){Nt(this,"options",{}),Nt(this,"layer",[]),Nt(this,"_removed",!1),Nt(this,"_creatingInProgress",!1)}addLayer(){return this.layer}removeLayer(){this._removed=!0;for(const t of this.layer)e.removeLayer(t)}destroyed(){return this._removed}showLayer(){return Rt(this,null,function*(){if(this.options.visibility=!0,this.layer.length)for(const t of this.layer)yield e.showLayer(t);else yield this.loadLayer()})}hideLayer(){return Rt(this,null,function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)})}loadLayer(){return Rt(this,null,function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const o=yield n(this);if(o){const n=new o(e.mapAdapter.map,((e,t)=>{for(var r in t||(t={}))Mt.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)),i=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=i,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer})}}})}function Bt(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){return Ft({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>Zi({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)})},new Promise((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())});var t,r,n}var $t=Object.defineProperty,qt=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?$t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function Gt(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 zt={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)=>Gt(e,t),ilike:(e,t)=>Gt(e,t,!0)};function Zt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Wt(e,t){const r=((e,t)=>{for(var r in t||(t={}))Dt.call(t,r)&&Vt(e,r,t[r]);if(qt)for(var r of qt(t))Ut.call(t,r)&&Vt(e,r,t[r]);return e})({},e.properties);return!!r&&(r.$id=e.id,Ht(r,t))}function Ht(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Zt(t)){const[r,n,o]=t,i=zt[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 Ht(e,t)},o=t.filter(e=>Array.isArray(e));return"any"===r?o.some(n):o.every(n)}var Jt=Object.defineProperty,Qt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Xt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,er=Object.prototype.propertyIsEnumerable,tr=(e,t,r)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rr=(e,t)=>{for(var r in t||(t={}))Yt.call(t,r)&&tr(e,r,t[r]);if(Xt)for(var r of Xt(t))er.call(t,r)&&tr(e,r,t[r]);return e},nr=(e,t)=>Qt(e,Kt(t)),or=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});const ir={srs:4326,geom_format:"geojson",dt_format:"iso"};function sr(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function ar(e,t){const{extensions:r,geom:o,fields:i,srs:s,ilike:a,like:l}=t;e.extensions=r||[],i&&(e.fields=i),void 0!==o&&(e.geom=o,o||(delete e.srs,delete e.geom_format)),n(a)?e.ilike=a:n(l)&&(e.like=l),n(s)&&(e.srs=s)}function lr(e){return or(this,null,function*(){const t=ur(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o})}function cr(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,(e,t,r,n)=>(o=t,i=n,r))}__${r}`,o+n+i]}function ur(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter(e=>Array.isArray(e));if("any"===s)for(const l of a)Zt(l)?t.push(pr(nr(rr({},e),{paramList:[...r,...i,cr(l)]}))):ur(nr(rr({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)Zt(e)?n.push(cr(e)):o.push(e);if(o.length)for(const i of o)ur(nr(rr({},e),{filters:i}),t,[...r,...n]);else t.push(pr(nr(rr({},e),{paramList:[...r,...i,...n]})))}return t}function hr(e){return`POLYGON((${e.map(([e,t])=>{const[r,n]=s(e,t).map(e=>Math.round(1*(e+Number.EPSILON))/1);return r+" "+n}).join(", ")}))`}function pr(e){const t=rr({},ir),{limit:r,query:n,cache:o,signal:i,offset:s,orderBy:a,paramList:c,connector:u,geomFormat:h,intersects:p,resourceId:d}=e;if("number"==typeof r&&r!==Number.POSITIVE_INFINITY&&(t.limit=r),s&&(t.offset=s),h&&(t.geom_format=h),ar(t,e),a&&(t.order_by=a.join(",")),Array.isArray(p)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every(e=>"number"==typeof e)}(p)?l(p):p;t.intersects=hr(e)}else"string"==typeof p&&(t.intersects=p);return c&&Object.assign(t,function(e){return e.reduce((e,[t,r])=>(e[t]=r,e),{})}(c)),u.route("feature_layer.feature.collection",{id:Number(d)}).get({query:rr(rr({},t),n),cache:o,signal:i})}function dr(e){let t;for(t in e){const r=e[t];if(y(r)){const o=r;if(n(o.year)&&n(o.month)&&n(o.day)){const r=[o.year,o.month-1,o.day];"hour"in o&&[o.hour,o.minute,o.second].forEach(e=>{r.push(e)}),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var fr=Object.defineProperty,yr=Object.defineProperties,mr=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertySymbols,gr=Object.prototype.hasOwnProperty,vr=Object.prototype.propertyIsEnumerable,wr=(e,t,r)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_r=(e,t)=>{for(var r in t||(t={}))gr.call(t,r)&&wr(e,r,t[r]);if(br)for(var r of br(t))vr.call(t,r)&&wr(e,r,t[r]);return e},Or=(e,t)=>yr(e,mr(t)),Lr=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Pr(e){return Lr(this,null,function*(){var t;const r=e.filters;if(r){let n=yield lr(Or(_r({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:Ir(r))&&(n=n.filter(e=>Ht(dr(Or(_r({},e.fields),{id:e.id})),r))),n}return pr(e)})}function Ir(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(m(r)){if(Ir(r))return!0}}return!1}function xr({options:e,webMap:t,baseUrl:r}){var n;let o,i=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===i){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const o=t+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:t=>(r&&(t.nd=r),_o(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});i="TILE"}if("WMS"===i){o=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:o,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===i)return o=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:o,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===i)return o=r+`/api/resource/${a}/terrain_provider`,{url:o,adapter:i};if("MODEL_3D"===i)return o=r+`/api/component/model_3d/${a}/data.glb`,{url:o};if("TILE"===i)return o=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:o,adapter:i}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var jr=Object.defineProperty,Er=Object.defineProperties,Ar=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,Sr=(e,t,r)=>t in e?jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tr=(e,t)=>{for(var r in t||(t={}))kr.call(t,r)&&Sr(e,r,t[r]);if(Cr)for(var r of Cr(t))Mr.call(t,r)&&Sr(e,r,t[r]);return e},Nr=(e,t)=>Er(e,Ar(t)),Rr=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Fr(e){return Rr(this,null,function*(){const t=Tr({},ir);ar(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Nr(Tr({},e),{query:t}));return Nr(Tr({},r),{toGeojson:()=>Rr(null,null,function*(){if(r.geom)return sr(r);{const t=(yield Fr(Nr(Tr({},e),{geom:!0,fields:null,extensions:null}))).geom;return sr(Nr(Tr({},r),{geom:t}))}})})})}var Br=Object.defineProperty,$r=Object.getOwnPropertySymbols,qr=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,Ur=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Vr=(e,t,r)=>Ur(e,"symbol"!=typeof t?t+"":t,r);class Gr{constructor(e){this.options=e,Vr(this,"name"),Vr(this,"resourceId"),Vr(this,"item"),Vr(this,"_extent"),this.resourceId=e.resourceId;const t=e.item;this.item=t,this.name=e.labelField&&t.fields?t.fields[e.labelField]:String(t.id)}extent(e){return this._extent?Promise.resolve(this._extent):this.options.connector.route("feature_layer.feature.item_extent",{id:this.resourceId,fid:this.item.id}).get(e).then(e=>{if(e.extent){const{minLat:t,minLon:r,maxLat:n,maxLon:o}=e.extent,i=[r,t,o,n];return this._extent=i,i}})}geoJson(e){return this.item.geom?Promise.resolve(sr(this.item)):Fr(((e,t)=>{for(var r in t||(t={}))qr.call(t,r)&&Ur(e,r,t[r]);if($r)for(var r of $r(t))Dr.call(t,r)&&Ur(e,r,t[r]);return e})({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null},e)).then(e=>(this.item.geom=e.geom,sr(this.item)))}}var zr=Object.defineProperty,Zr=(e,t,r)=>((e,t,r)=>t in e?zr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Wr{constructor(e,t,r){Zr(this,"options"),Zr(this,"emitter",new k),Zr(this,"name"),Zr(this,"item"),Zr(this,"_blocked",!1),Zr(this,"_container"),Zr(this,"__value"),Zr(this,"_removeEventsListener"),this.item=t,this.options=Object.assign({},r),this.name=e,this._value=this.getProperty()}set _value(e){this.__value=e}get _value(){return this.__value}getProperty(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value}getParents(){return this.item.tree.getParents()||[]}getParent(){return this.item.tree.getParent()}getChildren(){return this.item.tree.getChildren()}isGroup(){return this.item.tree.getDescendants().length}isBlocked(){if(void 0!==this._blocked)return this._blocked;const e=this.item.tree.getParents();return this._blocked=this._calculateBlockedStatus(e),this._blocked}set(e,t){this._value=this._prepareValue(e),this.update(this._value,t),this._fireChangeEvent(this._value,t)}get(){return this.getValue()}update(e,t){this._callOnSet(e,t)}getContainer(){return this._container}destroy(){if(this._container){const e=this._container.parentNode;e&&e.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()}getValue(){return void 0!==this._value?this._value:this.getProperty()}_prepareValue(e){return e}_callOnSet(e,t){this.options.onSet&&this.options.onSet.call(this,e,t,this.item)}_fireChangeEvent(e,t){if(this.emitter){e=void 0!==e?e:this.getValue(),this.emitter.emit("change",{value:e,options:t});this.item.tree.getParents().forEach(r=>{const n=r.properties&&r.properties.property(this.name);n&&n.emitter.emit("change-tree",{value:e,options:t,item:this.item})})}}_calculateBlockedStatus(e){return e.some(e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()})}}var Hr=Object.defineProperty,Jr=Object.getOwnPropertySymbols,Qr=Object.prototype.hasOwnProperty,Kr=Object.prototype.propertyIsEnumerable,Xr=(e,t,r)=>t in e?Hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yr=(e,t)=>{for(var r in t||(t={}))Qr.call(t,r)&&Xr(e,r,t[r]);if(Jr)for(var r of Jr(t))Kr.call(t,r)&&Xr(e,r,t[r]);return e};const en=class e extends Wr{constructor(t,r,n){super(t,r,Yr(Yr({},e.options),n)),this.set(this.get())}update(e,t){if(e){if(t&&t.bubble||this.options.bubble){this.unBlock(t);const r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(e,Object.assign({},t,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(t)}else this._turnOff(t);(t&&t.propagation||this.options.propagation)&&this._propagation(e,t)}getHierarchyValue(){return this.get()&&this.getParents().every(e=>{const t=e.properties&&e.properties.get(this.name);return t&&t.get()})}block(e){this._blocked=!0,this._block(e)}unBlock(e){this._blocked=!1;this.getValue()&&this._unBlock(e)}blockChild(e){this.item.tree.getDescendants().forEach(t=>this._blockChild(t,e))}unblockChild(e){this.item.tree.getChildren().forEach(t=>this._unBlockChild(t,e))}_prepareValue(e){return e}_turnOff(e){this.options.turnOff&&this.options.turnOff.call(this,e),this._callOnSet(!1,e),this.options.hierarchy&&this.isGroup()&&this.blockChild(e)}_turnOn(e){this.options.turnOn&&this.options.turnOn.call(this,e),this._callOnSet(!0,e),this.options.hierarchy&&this.isGroup()&&this.unblockChild(e)}_block(e){this._turnOff(e)}_unBlock(e){this._turnOn(e)}_blockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.block&&r.block(Yr({silent:!0},t||{}))}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(Yr({silent:!0},t||{}))}_propagation(e,t){if(this.isGroup()){const r=this.item.tree.getChildren();for(let n=0;n<r.length;n++){const o=r[n],i=o.properties&&o.properties.property(this.name);i&&i.set(e,Yr(Yr({},t),{propagation:!0,bubble:!1}))}}}};Xr(en,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let tn=en;var rn=Object.defineProperty,nn=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable,an=(e,t,r)=>t in e?rn(e,t,{enumerable:!0,configurable: