@nextgis/ngw-map
Version:
1 lines • 146 kB
JavaScript
var NgwMap=function(e){"use strict";const t={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 r(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 n(e,t,r=!1){let o=e;const i=t,s=Array.isArray(i);let a=s&&[]||{};return s&&Array.isArray(i)?r?(o=o||[],a=a.concat(o),i.forEach((e,t)=>{void 0===a[t]?a[t]=e:"object"==typeof e?a[t]=n(o[t],e,r):-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]?n(o[e],i[e],r):i[e]})),a}function o(e){return null!=e}function i(e){return"string"==typeof e?!!e:o(e)}function s(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}function a(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 l(e){return{type:"Polygon",coordinates:[c(e)]}}function c(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const u=Math.PI/180,p=180/Math.PI;function h(e,t,r=10,n=6){const o=r/6371*p,i=o/Math.cos(t*u),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 d(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:f(e,t));return e===t}function f(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(!d(e[r[o]],t[n[o]],e,t))return!1}return!0}function y(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]=y(e[r])}),t}function m(e){return"[object Object]"===Object.prototype.toString.call(e)}function b(e){return"[object Array]"===Object.prototype.toString.call(e)}function g(e){return e.replace(/([^:]\/)\/+/g,"$1")}const v=/\{ *([\w_-]+) *\}/g;function w(e,t){return e.replace(v,(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 _=Object.defineProperty,O=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,I=(e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function x(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=w(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={}))L.call(t,r)&&I(e,r,t[r]);if(O)for(var r of O(t))P.call(t,r)&&I(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 j=Object.defineProperty,E=(e,t,r)=>((e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const A=class e{constructor(t={}){var r;E(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,t,r,n,o){let s,a;"object"==typeof r&&"valueToSet"in r?(s=r,n=s.onlyFull,o=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(y(a)));o=o?Date.now()+o:void 0;const l={key:e,value:r,props:s,expirationTime:o};return n&&!i(r)?r:(this.cache.push(l),r instanceof Promise?(r.catch(()=>{this.delete(e,a)}),n&&r.then(t=>(i(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 f(e.props||{},y(r))}};E(A,"instance",{});let C=A;function M(){}function k(){k.init.call(this)}function S(e){return void 0===e._maxListeners?k.defaultMaxListeners:e._maxListeners}function T(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=S(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 N(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 R(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 F(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}M.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 M,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 S(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=F(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=F(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=F(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=F(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=F(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 T(this,e,t,!1)},k.prototype.prependListener=function(e,t){return T(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,N(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,N(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 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},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 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},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):R.call(e,t)},k.prototype.listenerCount=R,k.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var B="3.0.1";class $ extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var q=Object.defineProperty,D=(e,t,r)=>((e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class U extends Error{constructor(e){super(),D(this,"name","NgwError"),D(this,"title"),D(this,"message"),D(this,"detail"),D(this,"exception"),D(this,"status_code"),D(this,"data"),D(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,U.prototype)}}var V=Object.defineProperty,G=(e,t,r)=>((e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class z extends U{constructor(e){super(e),G(this,"name","InsufficientPermissionsError"),G(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,z.prototype)}}var Z=Object.defineProperty,W=(e,t,r)=>((e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);let J=class e extends U{constructor(t){super(t),W(this,"message","There is no response from the server or problem connecting to server."),W(this,"title","Network error"),W(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var H=Object.defineProperty,Q=(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 K extends Error{constructor(e){super(),Q(this,"name","NetworkError"),Object.setPrototypeOf(this,K.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var X=Object.defineProperty,Y=(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 U{constructor(e){super(e),Y(this,"name","ResourceNotFoundError"),Y(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,ee.prototype)}}var te=Object.freeze({__proto__:null,AbortError:$,InsufficientPermissionsError:z,NetworkError:K,NetworksResponseError:J,NgwError:U,ResourceNotFoundError:ee,extractError:function(e){if(m(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 J({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!m(e)&&(e.status_code&&e.exception&&e.title)}}),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);class oe extends Error{constructor(e){super(e||"Something went wrong."),ne(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,oe)}}class ie extends oe{constructor(e){super(e||"There is no response from the server or problem connecting to server."),ne(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class se extends oe{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class ae extends oe{constructor(e){super(e.message),ne(this,"detail"),ne(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class le extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),ne(this,"title"),ne(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,le)}}class ce extends le{constructor(e){super("Long-running request was cancelled.",e)}}class ue extends le{constructor(e){super(void 0,e)}}var pe=Object.defineProperty,he=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,ye=(e,t,r)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,me=(e,t)=>{for(var r in t||(t={}))de.call(t,r)&&ye(e,r,t[r]);if(he)for(var r of he(t))fe.call(t,r)&&ye(e,r,t[r]);return e},be=(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 ge(e){return be(this,null,function*(){const t=yield function(e){return be(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 le(void 0,t);case"ready":l=!0;break;case"cancelled":throw new ce(t);case"failed":throw new ue(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new le(void 0,t)}}return i})}const ve=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function we(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 _e(e,t,r){return be(this,null,function*(){var n,o;const i=me(me({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:s,responseType:a,cacheProps:l,cacheName:c,lunkwill:u,cache:p,query:h,json:d}=i,f=((e,t)=>{var r={};for(var n in e)de.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&&fe.call(e,n)&&(r[n]=e[n]);return r})(i,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);f.method=null==(n=f.method)?void 0:n.toUpperCase(),s&&(f.credentials="include");let m=!1;void 0!==u&&(u.toHeaders(f.headers||{}),m=!0);const b=!!f.lunkwillReturnUrl;if(delete f.lunkwillReturnUrl,void 0!==d){f.body=JSON.stringify(d);const e=f.headers||{};e["Content-Type"]="application/json",f.headers=e}const g=we(e,h),v=()=>be(null,null,function*(){let e;try{e=yield fetch(g,f)}catch(o){if(f.signal&&f.signal.aborted)throw o;throw new ie}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 ge(e);if(b)return t;e=yield function(e){return be(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new ie}})}(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&&ve.test(t);if("blob"===a||o)n=yield e.blob();else{if(!r)throw new se;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof se)throw o;throw new se}if(400<=e.status&&e.status<=599)throw new ae(n);return n});if(r)if("GET"===(null==(o=f.method)?void 0:o.toUpperCase())){if(!1!==p){const e=l||me({},y({withCredentials:s,responseType:a}));return r.add(c||g,v,{props:e,expirationTime:p?void 0:500})}}else{["api/feature_layer/identify"].every(t=>!e.includes(t))&&r.clean()}return v()})}var Oe=Object.defineProperty,Le=Object.defineProperties,Pe=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Ee=(e,t,r)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ae=(e,t)=>{for(var r in t||(t={}))xe.call(t,r)&&Ee(e,r,t[r]);if(Ie)for(var r of Ie(t))je.call(t,r)&&Ee(e,r,t[r]);return e},Ce=(e,t)=>{var r={};for(var n in e)xe.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Ie)for(var n of Ie(e))t.indexOf(n)<0&&je.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 g(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 we(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 i of o){const o=n=>{var o;const s=n||{},{headers:a}=s,l=Ce(s,["headers"]);if(null==(o=null==n?void 0:n.signal)?void 0:o.aborted)throw new $;return t.connect().then(n=>{var o;const s=Me(e,null!=(o=t.options.baseUrl)?o:"",n,...r),c=y(Ae(Ae({},t.getAuthorizationHeaders()),null!=a?a:{}));return _e(s,(u=Ae({headers:c},l),Le(u,Pe({method:i}))),t.cache);var u})};n[i]=o}return n}function Se(e){return"[object Object]"===Object.prototype.toString.call(e)}let Te;Te=(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 U(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 K(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 Ne=[];function Re(e){Ne.push(e)}var Fe=Object.defineProperty,Be=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,qe=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable,Ve=(e,t,r)=>t in e?Fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ge=(e,t)=>{for(var r in t||(t={}))De.call(t,r)&&Ve(e,r,t[r]);if(qe)for(var r of qe(t))Ue.call(t,r)&&Ve(e,r,t[r]);return e},ze=(e,t,r)=>Ve(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 We=0,Je=0;class He{constructor(e){this.options=e,ze(this,"id",We++),ze(this,"emitter",new k),ze(this,"user"),ze(this,"cache"),ze(this,"withCredentials"),ze(this,"routeCache"),ze(this,"client",`NextGIS-NGW-Connector/${B}`),ze(this,"routeStr","/api/component/pyramid/route"),ze(this,"activeRequests",{}),ze(this,"requestTransform");const t=function(e){return Ne.find(t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return f(t.options.auth,e.auth)}})}(e);if(this.cache=new C({namespace:e.cacheId}),this.routeCache=new C({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),Re(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Re(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(),Re(this),this._login(e,t)}logout(){this.abort(),function(e){const t=Ne.indexOf(e);-1!==t&&Ne.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=Ge({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 Ge({},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)De.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&qe)for(var n of qe(e))t.indexOf(n)<0&&Ue.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=w(e,r)}e=encodeURI(g(e)),r=Ge({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:p}=r,h=new AbortController,d=h.signal;if(i){if(i.aborted)throw new $;i.addEventListener("abort",()=>{h.abort()})}r.signal=d;const f=()=>Ze(this,null,function*(){const t=Je++;this.activeRequests[t]=h;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===s&&!1!==o){const r=c||(m=Ge({},y({headers:a,withCredentials:p,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Be(m,$e({params:t})));return this.cache.add(l||e,f,{props:r,expirationTime:o?void 0:500})}var m;return f()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var o;if(this.user&&((t=t||{}).headers=Ge(Ge({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;Te(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new $)})}).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 U){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new ee(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new z(e)}return e}}ze(He,"errors",te);const Qe=["description"];function Ke(e,t=""){t=t?t+"__":"";const r={};for(const[n,i]of Object.entries(e))if(-1===Qe.indexOf(n))if(Se(i))if("owner_user"===n){const e=Ke(i,n);Object.assign(r,e)}else"parent"===n&&"id"in i&&(r.parent_id=i.id);else o(i)&&(r[t+n]=i);return r}var Xe=Object.defineProperty,Ye=Object.defineProperties,et=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,ot=(e,t,r)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,it=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&ot(e,r,t[r]);if(tt)for(var r of tt(t))nt.call(t,r)&&ot(e,r,t[r]);return e},st=(e,t)=>Ye(e,et(t)),at=(e,t,r)=>ot(e,"symbol"!=typeof t?t+"":t,r),lt=(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 ct{constructor({connector:e,cacheId:t}){at(this,"cache"),at(this,"connector"),this.connector=e,this.cache=new C({namespace:t})}getOne(e,t){const r=it({},t);return"string"==typeof e||"number"==typeof e||Se(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):Se(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 ee})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||Se(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,Ke(e)),this.connector.route("resource.search").get(st(it({},t),{query:it({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 lt(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(st(it({},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 lt(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:o(e.id)&&o(t.resource.id)?e.id===t.resource.id:f(e,t.resource)}),[]))}}var ut=Object.defineProperty,pt=(e,t,r)=>((e,t,r)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class ht extends He{constructor(e){super(e),pt(this,"resources"),this.resources=new ct({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 x({name:e,params:y(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 dt=Object.defineProperty,ft=Object.defineProperties,yt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable,vt=(e,t,r)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wt=(e,t)=>{for(var r in t||(t={}))bt.call(t,r)&&vt(e,r,t[r]);if(mt)for(var r of mt(t))gt.call(t,r)&&vt(e,r,t[r]);return e},_t=(e,t)=>ft(e,yt(t));function Ot(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 Lt({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 Pt(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then(t=>{if(t)return It(t,e.connector,e)})}function It(e,t,r){if(e.webmap)return Promise.resolve(Ot(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 Lt(_t(wt({},r),{resourceId:e.resource.id,connector:t}))}):Lt(_t(wt({},r),{resourceId:n.id,connector:t}))}}var xt=Object.defineProperty,jt=(e,t,r)=>((e,t,r)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Et=(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 At{constructor(){jt(this,"item"),jt(this,"connector"),jt(this,"_extent")}getExtent(){return Et(this,null,function*(){return this.getBounds()})}getBounds(e){return Et(this,null,function*(){return this._extent?this._extent:this.item?(this._extent=yield It(this.item,this.connector,e),this._extent):void 0})}}function Ct(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 Ct(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 Mt=Object.defineProperty,kt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable,Nt=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Rt=(e,t,r)=>Nt(e,"symbol"!=typeof t?t+"":t,r),Ft=(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 Bt(e){return Ft(this,arguments,function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){Rt(this,"options",{}),Rt(this,"layer",[]),Rt(this,"_removed",!1),Rt(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 Ft(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 Ft(this,null,function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)})}loadLayer(){return Ft(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={}))St.call(t,r)&&Nt(e,r,t[r]);if(kt)for(var r of kt(t))Tt.call(t,r)&&Nt(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 $t(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){return Bt({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>Wi({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 qt=Object.defineProperty,Dt=Object.getOwnPropertySymbols,Ut=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable,Gt=(e,t,r)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function zt(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)=>zt(e,t),ilike:(e,t)=>zt(e,t,!0)};function Wt(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Jt(e,t){const r=((e,t)=>{for(var r in t||(t={}))Ut.call(t,r)&&Gt(e,r,t[r]);if(Dt)for(var r of Dt(t))Vt.call(t,r)&&Gt(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(Wt(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 Qt=Object.defineProperty,Kt=Object.defineProperties,Xt=Object.getOwnPropertyDescriptors,Yt=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,rr=(e,t,r)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nr=(e,t)=>{for(var r in t||(t={}))er.call(t,r)&&rr(e,r,t[r]);if(Yt)for(var r of Yt(t))tr.call(t,r)&&rr(e,r,t[r]);return e},or=(e,t)=>Kt(e,Xt(t)),ir=(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 sr={srs:4326,geom_format:"geojson",dt_format:"iso"};function ar(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function lr(e,t){const{extensions:r,geom:n,fields:i,srs:s,ilike:a,like:l}=t;e.extensions=r||[],i&&(e.fields=i),void 0!==n&&(e.geom=n,n||(delete e.srs,delete e.geom_format)),o(a)?e.ilike=a:o(l)&&(e.like=l),o(s)&&(e.srs=s)}function cr(e){return ir(this,null,function*(){const t=pr(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 ur(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 pr(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)Wt(l)?t.push(dr(or(nr({},e),{paramList:[...r,...i,ur(l)]}))):pr(or(nr({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)Wt(e)?n.push(ur(e)):o.push(e);if(o.length)for(const i of o)pr(or(nr({},e),{filters:i}),t,[...r,...n]);else t.push(dr(or(nr({},e),{paramList:[...r,...i,...n]})))}return t}function hr(e){return`POLYGON((${e.map(([e,t])=>{const[r,n]=a(e,t).map(e=>Math.round(1*(e+Number.EPSILON))/1);return r+" "+n}).join(", ")}))`}function dr(e){const t=nr({},sr),{limit:r,query:n,cache:o,signal:i,offset:s,orderBy:a,paramList:l,connector:u,geomFormat:p,intersects:h,resourceId:d}=e;if("number"==typeof r&&r!==Number.POSITIVE_INFINITY&&(t.limit=r),s&&(t.offset=s),p&&(t.geom_format=p),lr(t,e),a&&(t.order_by=a.join(",")),Array.isArray(h)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every(e=>"number"==typeof e)}(h)?c(h):h;t.intersects=hr(e)}else"string"==typeof h&&(t.intersects=h);return l&&Object.assign(t,function(e){return e.reduce((e,[t,r])=>(e[t]=r,e),{})}(l)),u.route("feature_layer.feature.collection",{id:Number(d)}).get({query:nr(nr({},t),n),cache:o,signal:i})}function fr(e){let t;for(t in e){const r=e[t];if(m(r)){const n=r;if(o(n.year)&&o(n.month)&&o(n.day)){const r=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach(e=>{r.push(e)}),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var yr=Object.defineProperty,mr=Object.defineProperties,br=Object.getOwnPropertyDescriptors,gr=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,wr=Object.prototype.propertyIsEnumerable,_r=(e,t,r)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Or=(e,t)=>{for(var r in t||(t={}))vr.call(t,r)&&_r(e,r,t[r]);if(gr)for(var r of gr(t))wr.call(t,r)&&_r(e,r,t[r]);return e},Lr=(e,t)=>mr(e,br(t)),Pr=(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 Ir(e){return Pr(this,null,function*(){var t;const r=e.filters;if(r){let n=yield cr(Lr(Or({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:xr(r))&&(n=n.filter(e=>Ht(fr(Lr(Or({},e.fields),{id:e.id})),r))),n}return dr(e)})}function xr(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if(b(r)){if(xr(r))return!0}}return!1}function jr({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),Oo(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 Er=Object.defineProperty,Ar=Object.defineProperties,Cr=Object.getOwnPropertyDescriptors,Mr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,Tr=(e,t,r)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nr=(e,t)=>{for(var r in t||(t={}))kr.call(t,r)&&Tr(e,r,t[r]);if(Mr)for(var r of Mr(t))Sr.call(t,r)&&Tr(e,r,t[r]);return e},Rr=(e,t)=>Ar(e,Cr(t)),Fr=(e,t,r)=>new Promise((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())});function Br(e){return Fr(this,null,function*(){const t=Nr({},sr);lr(t,e);const r=yield e.connector.route("feature_layer.feature.item",{id:Number(e.resourceId),fid:e.featureId}).get(Rr(Nr({},e),{query:t}));return Rr(Nr({},r),{toGeojson:()=>Fr(null,null,function*(){if(r.geom)return ar(r);{const t=(yield Br(Rr(Nr({},e),{geom:!0,fields:null,extensions:null}))).geom;return ar(Rr(Nr({},r),{geom:t}))}})})})}var $r=Object.defineProperty,qr=Object.getOwnPropertySymbols,Dr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Vr=(e,t,r)=>t in e?$r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Gr=(e,t,r)=>Vr(e,"symbol"!=typeof t?t+"":t,r);class zr{constructor(e){this.options=e,Gr(this,"name"),Gr(this,"resourceId"),Gr(this,"item"),Gr(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(ar(this.item)):Br(((e,t)=>{for(var r in t||(t={}))Dr.call(t,r)&&Vr(e,r,t[r]);if(qr)for(var r of qr(t))Ur.call(t,r)&&Vr(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,ar(this.item)))}}var Zr=Object.defineProperty,Wr=(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 Jr{constructor(e,t,r){Wr(this,"options"),Wr(this,"emitter",new k),Wr(this,"name"),Wr(this,"item"),Wr(this,"_blocked",!1),Wr(this,"_container"),Wr(this,"__value"),Wr(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,Qr=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Xr=Object.prototype.propertyIsEnumerable,Yr=(e,t,r)=>t in e?Hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,en=(e,t)=>{for(var r in t||(t={}))Kr.call(t,r)&&Yr(e,r,t[r]);if(Qr)for(var r of Qr(t))Xr.call(t,r)&&Yr(e,r,t[r]);return e};const tn=class e extends Jr{constructor(t,r,n){super(t,r,en(en({},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(en({silent:!0},t||{}))}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(en({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,en(en({},t),{propagation:!0,bubble:!1}))}}}};Yr(tn,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let rn=tn;var nn=Object.defineProperty,on=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable,ln=(e,t,r)=>t