@nextgis/ngw-connector 4.0.0-alpha.2 → 4.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- function e(e){return null!=e}function t(t){return"string"==typeof t?!!t:e(t)}function r(e,t,r,o){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===o:n(e,t));return e===t}function n(e,t){const n=Object.keys(e).sort(),o=Object.keys(t).sort();if(n.length!==o.length)return!1;if(n.join("")!==o.join(""))return!1;for(let i=0;i<n.length;i++){if(!r(e[n[i]],t[o[i]],e,t))return!1}return!0}function o(e){const t={};return Object.keys(e).forEach(r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=o(e[r])}),t}function i(e){return"[object Object]"===Object.prototype.toString.call(e)}function s(e){return e.replace(/([^:]\/)\/+/g,"$1")}const a=/\{ *([\w_-]+) *\}/g;function c(e,t){return e.replace(a,(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 u=Object.defineProperty,l=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,p=(e,t,r)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function d(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=c(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach(([e,t])=>{r.push(`${e}=${t}`)});for(const e in t)-1===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={}))h.call(t,r)&&p(e,r,t[r]);if(l)for(var r of l(t))f.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 y=Object.defineProperty,m=(e,t,r)=>((e,t,r)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const v=class e{constructor(t={}){var r;m(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,r,n,i,s){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,i=a.onlyFull,s=a.expirationTime,c=a.props):c=n;const u=this._find(e,c);if(u)return u.value;{let n;n=r instanceof Function?r():r;const a=c&&JSON.parse(JSON.stringify(o(c)));s=s?Date.now()+s:void 0;const u={key:e,value:n,props:a,expirationTime:s};return i&&!t(n)?n:(this.cache.push(u),n instanceof Promise?(n.catch(()=>{this.delete(e,c)}),i&&n.then(r=>(t(r)||this.delete(e,c),r)),n):n)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach(e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)}),e?this.cache.filter(r=>this._filter(r,e,t)).map(e=>e.value):this.cache.map(e=>e.value)}delete(e,t){const r="string"==typeof e?this.cache.filter(r=>this._filter(r,e,t)):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find(r=>this._filter(r,e,t))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return n(e.props||{},o(r))}};m(v,"instance",{});let g=v;var w;function b(){}function O(){O.init.call(this)}function j(e){return void 0===e._maxListeners?O.defaultMaxListeners:e._maxListeners}function x(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 b,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=j(e))&&o>0&&s.length>o){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function _(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 P(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 E(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),O.EventEmitter=O,O.usingDomains=!1,O.prototype.domain=void 0,O.prototype._events=void 0,O.prototype._maxListeners=void 0,O.defaultMaxListeners=10,O.init=function(){this.domain=null,O.usingDomains&&(!w.active||this instanceof w.Domain||(this.domain=w.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},O.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},O.prototype.getMaxListeners=function(){return j(this)},O.prototype.emit=function(e){var t,r,n,o,i,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}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 l="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=E(e,n),i=0;i<n;++i)o[i].call(r)}(r,l,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=E(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,l,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=E(e,i),a=0;a<i;++a)s[a].call(r,n,o)}(r,l,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=E(e,s),c=0;c<s;++c)a[c].call(r,n,o,i)}(r,l,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=E(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,l,this,o)}return!0},O.prototype.on=O.prototype.addListener=function(e,t){return x(this,e,t,!1)},O.prototype.prependListener=function(e,t){return x(this,e,t,!0)},O.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,_(this,e,t)),this},O.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,_(this,e,t)),this},O.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 b:(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 b,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},O.prototype.off=function(e,t){return this.removeListener(e,t)},O.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new b,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new b: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 b,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},O.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):[]},O.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):P.call(e,t)},O.prototype.listenerCount=P,O.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var C="4.0.0-alpha.2";class R extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var T=Object.defineProperty,k=(e,t,r)=>((e,t,r)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class I extends Error{constructor(e){super(),k(this,"name","NgwError"),k(this,"title"),k(this,"message"),k(this,"detail"),k(this,"exception"),k(this,"status_code"),k(this,"data"),k(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,I.prototype)}}var L=Object.defineProperty,q=(e,t,r)=>((e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class A extends I{constructor(e){super(e),q(this,"name","InsufficientPermissionsError"),q(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,A.prototype)}}var U=Object.defineProperty,S=(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);let $=class e extends I{constructor(t){super(t),S(this,"message","There is no response from the server or problem connecting to server."),S(this,"title","Network error"),S(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var N=Object.defineProperty,F=(e,t,r)=>((e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class D extends Error{constructor(e){super(),F(this,"name","NetworkError"),Object.setPrototypeOf(this,D.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var B=Object.defineProperty,G=(e,t,r)=>((e,t,r)=>t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class H extends I{constructor(e){super(e),G(this,"name","ResourceNotFoundError"),G(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,H.prototype)}}var M=Object.freeze({__proto__:null,AbortError:R,InsufficientPermissionsError:A,NetworkError:D,NetworksResponseError:$,NgwError:I,ResourceNotFoundError:H,extractError:function(e){if(i(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new $({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!i(e)&&(e.status_code&&e.exception&&e.title)}}),z=Object.defineProperty,J=(e,t,r)=>((e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Q extends Error{constructor(e){super(e||"Something went wrong."),J(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,Q)}}class W extends Q{constructor(e){super(e||"There is no response from the server or problem connecting to server."),J(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class K extends Q{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class X extends Q{constructor(e){super(e.message),J(this,"detail"),J(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class V extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),J(this,"title"),J(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,V)}}class Y extends V{constructor(e){super("Long-running request was cancelled.",e)}}class Z extends V{constructor(e){super(void 0,e)}}var ee=Object.defineProperty,te=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,oe=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ie=(e,t)=>{for(var r in t||(t={}))re.call(t,r)&&oe(e,r,t[r]);if(te)for(var r of te(t))ne.call(t,r)&&oe(e,r,t[r]);return e},se=(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 ae(e){return se(this,null,function*(){const t=yield function(e){return se(this,null,function*(){try{return e.json()}catch(t){throw new Error}})}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise(t=>setTimeout(t,e));let a=!1,c=!1;for(;!c;){let e,t;yield s(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(u){a=!0;continue}switch(t.status){case void 0:throw new V(void 0,t);case"ready":c=!0;break;case"cancelled":throw new Y(t);case"failed":throw new Z(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new V(void 0,t)}}return i})}const ce=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ue(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 le(e,t,r){return se(this,null,function*(){var n,i;const s=ie(ie({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:u,cacheName:l,lunkwill:h,cache:f,query:p,json:d}=s,y=((e,t)=>{var r={};for(var n in e)re.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&te)for(var n of te(e))t.indexOf(n)<0&&ne.call(e,n)&&(r[n]=e[n]);return r})(s,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),a&&(y.credentials="include");let m=!1;void 0!==h&&(h.toHeaders(y.headers||{}),m=!0);const v=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=ue(e,p),w=()=>se(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new W}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 ae(e);if(v)return t;e=yield function(e){return se(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new W}})}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&ce.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new K;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof K)throw o;throw new K}if(400<=e.status&&e.status<=599)throw new X(n);return n});if(r)if("GET"===(null==(i=y.method)?void 0:i.toUpperCase())){if(!1!==f){const e=u||ie({},o({withCredentials:a,responseType:c}));return r.add(l||g,w,{props:e,expirationTime:f?void 0:500})}}else{["api/feature_layer/identify"].every(t=>!e.includes(t))&&r.clean()}return w()})}var he=Object.defineProperty,fe=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,ve=(e,t,r)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ge=(e,t)=>{for(var r in t||(t={}))ye.call(t,r)&&ve(e,r,t[r]);if(de)for(var r of de(t))me.call(t,r)&&ve(e,r,t[r]);return e},we=(e,t)=>{var r={};for(var n in e)ye.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&de)for(var n of de(e))t.indexOf(n)<0&&me.call(e,n)&&(r[n]=e[n]);return r};function be(e,t,r,...n){const[o,...i]=r[e],a=n[0];let c;if(void 0===a)c=[];else if("object"==typeof a&&null!==a){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");c=[];for(const[e,t]of Object.entries(a))c[i.indexOf(e)]=String(t)}else c=n.map(e=>String(e));return s(t+o.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=c[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)}))}function Oe(e,t,...r){const n={url:n=>{return o=null,i=null,s=function*(){var o;const i=yield t.connect();return ue(be(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}},i=["get","post","put","delete","patch"];for(const s of i){const i=n=>{var i;const a=n||{},{headers:c}=a,u=we(a,["headers"]);if(null==(i=null==n?void 0:n.signal)?void 0:i.aborted)throw new R;return t.connect().then(n=>{var i;const a=be(e,null!=(i=t.options.baseUrl)?i:"",n,...r),l=o(ge(ge({},t.getAuthorizationHeaders()),null!=c?c:{}));return le(a,(h=ge({headers:l},u),fe(h,pe({method:s}))),t.cache);var h})};n[s]=i}return n}function je(e){return"[object Object]"===Object.prototype.toString.call(e)}let xe;xe=(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 I(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 D(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 u in a){const e=a[u];"string"==typeof e&&i.setRequestHeader(u,e)}let c;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(c=new FormData,c.append("file",r.file),r.data)for(const u in r.data)c.append(u,c[u])}else c=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o(()=>{i.abort()}),i.send(c)};const _e=[];function Pe(e){_e.push(e)}var Ee=Object.defineProperty,Ce=Object.defineProperties,Re=Object.getOwnPropertyDescriptors,Te=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Le=(e,t,r)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qe=(e,t)=>{for(var r in t||(t={}))ke.call(t,r)&&Le(e,r,t[r]);if(Te)for(var r of Te(t))Ie.call(t,r)&&Le(e,r,t[r]);return e},Ae=(e,t,r)=>Le(e,"symbol"!=typeof t?t+"":t,r),Ue=(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 Se=0,$e=0;class Ne{constructor(e){this.options=e,Ae(this,"id",Se++),Ae(this,"emitter",new O),Ae(this,"user"),Ae(this,"cache"),Ae(this,"withCredentials"),Ae(this,"routeCache"),Ae(this,"client",`NextGIS-NGW-Connector/${C}`),Ae(this,"routeStr","/api/component/pyramid/route"),Ae(this,"activeRequests",{}),Ae(this,"requestTransform");const t=function(e){return _e.find(t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return n(t.options.auth,e.auth)}})}(e);if(this.cache=new g({namespace:e.cacheId}),this.routeCache=new g({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),Pe(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Pe(this)}connect(){return Ue(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(),Pe(this),this._login(e,t)}logout(){this.abort(),function(e){const t=_e.indexOf(e);-1!==t&&_e.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 Ue(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=qe({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 qe({},this.activeRequests)}route(e,...t){return Oe(e,this,...t)}makeQuery(e,t){return Ue(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=t,n=((e,t)=>{var r={};for(var n in e)ke.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Te)for(var n of Te(e))t.indexOf(n)<0&&Ie.call(e,n)&&(r[n]=e[n]);return r})(r,["paramList"]);e=c(e,n)}e=encodeURI(s(e)),r=qe({withCredentials:this.withCredentials},r);const{cache:i,signal:a,method:u="GET",headers:l,cacheName:h,cacheProps:f,responseType:p,withCredentials:d}=r,y=new AbortController,m=y.signal;if(a){if(a.aborted)throw new R;a.addEventListener("abort",()=>{y.abort()})}r.signal=m;const v=()=>Ue(this,null,function*(){const t=$e++;this.activeRequests[t]=y;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===u&&!1!==i){const r=f||(g=qe({},o({headers:l,withCredentials:d,responseType:p,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Ce(g,Re({params:t})));return this.cache.add(h||e,v,{props:r,expirationTime:i?void 0:500})}var g;return v()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var o;if(this.user&&((t=t||{}).headers=qe(qe({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;xe(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new R)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return Ue(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 I){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new H(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new A(e)}return e}}Ae(Ne,"errors",M);const Fe=["description"];function De(t,r=""){r=r?r+"__":"";const n={};for(const[o,i]of Object.entries(t))if(-1===Fe.indexOf(o))if(je(i))if("owner_user"===o){const e=De(i,o);Object.assign(n,e)}else"parent"===o&&"id"in i&&(n.parent_id=i.id);else e(i)&&(n[r+o]=i);return n}var Be=Object.defineProperty,Ge=Object.defineProperties,He=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Qe=(e,t,r)=>t in e?Be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,We=(e,t)=>{for(var r in t||(t={}))ze.call(t,r)&&Qe(e,r,t[r]);if(Me)for(var r of Me(t))Je.call(t,r)&&Qe(e,r,t[r]);return e},Ke=(e,t)=>Ge(e,He(t)),Xe=(e,t,r)=>Qe(e,"symbol"!=typeof t?t+"":t,r),Ve=(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 Ye{constructor({connector:e,cacheId:t}){Xe(this,"cache"),Xe(this,"connector"),this.connector=e,this.cache=new g({namespace:t})}getOne(e,t){const r=We({},t);return"string"==typeof e||"number"==typeof e||je(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):je(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 H})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||je(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,De(e)),this.connector.route("resource.search").get(Ke(We({},t),{query:We({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 Ve(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(Ke(We({},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 Ve(this,null,function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)})}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then(e=>e[0])}_resourceCacheFilter(t){return Promise.all(this.cache.matchAll("resource.item")).then(r=>(r.filter(r=>{if(r)return t.keyname&&r.resource.keyname?t.keyname===r.resource.keyname:e(t.id)&&e(r.resource.id)?t.id===r.resource.id:n(t,r.resource)}),[]))}}var Ze=Object.defineProperty,et=(e,t,r)=>((e,t,r)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class tt extends Ne{constructor(e){super(e),et(this,"resources"),this.resources=new Ye({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 d({name:e,params:o(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}export{tt as default};
1
+ function e(e){return null!=e}function t(t){return"string"==typeof t?!!t:e(t)}function r(e,t,r,o){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===o:n(e,t));return e===t}function n(e,t){const n=Object.keys(e).sort(),o=Object.keys(t).sort();if(n.length!==o.length)return!1;if(n.join("")!==o.join(""))return!1;for(let i=0;i<n.length;i++){if(!r(e[n[i]],t[o[i]],e,t))return!1}return!0}function o(e){const t={};return Object.keys(e).forEach(r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=o(e[r])}),t}function i(e){return"[object Object]"===Object.prototype.toString.call(e)}function s(e){return e.replace(/([^:]\/)\/+/g,"$1")}const a=/\{ *([\w_-]+) *\}/g;function c(e,t){return e.replace(a,(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 u=Object.defineProperty,l=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,p=(e,t,r)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function d(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=c(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach(([e,t])=>{r.push(`${e}=${t}`)});for(const e in t)-1===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={}))h.call(t,r)&&p(e,r,t[r]);if(l)for(var r of l(t))f.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 y=Object.defineProperty,m=(e,t,r)=>((e,t,r)=>t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const v=class e{constructor(t={}){var r;m(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r,n){return"object"==typeof r&&"valueToSet"in r&&(r.onlyFull=!0),this.add(e,t,r,!0,n)}add(e,r,n,i,s){let a,c;"object"==typeof n&&"valueToSet"in n?(a=n,i=a.onlyFull,s=a.expirationTime,c=a.props):c=n;const u=this._find(e,c);if(u)return u.value;{let n;n=r instanceof Function?r():r;const a=c&&JSON.parse(JSON.stringify(o(c)));s=s?Date.now()+s:void 0;const u={key:e,value:n,props:a,expirationTime:s};return i&&!t(n)?n:(this.cache.push(u),n instanceof Promise?(n.catch(()=>{this.delete(e,c)}),i&&n.then(r=>(t(r)||this.delete(e,c),r)),n):n)}}match(e,t){const r=this._find(e,t);if(!(r&&r.expirationTime&&Date.now()>r.expirationTime))return null==r?void 0:r.value;this.delete(r)}matchAll(e,t){const r=Date.now();return this.cache.forEach(e=>{e.expirationTime&&r>e.expirationTime&&this.delete(e)}),e?this.cache.filter(r=>this._filter(r,e,t)).map(e=>e.value):this.cache.map(e=>e.value)}delete(e,t){const r="string"==typeof e?this.cache.filter(r=>this._filter(r,e,t)):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find(r=>this._filter(r,e,t))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return n(e.props||{},o(r))}};m(v,"instance",{});let g=v;var w;function b(){}function O(){O.init.call(this)}function j(e){return void 0===e._maxListeners?O.defaultMaxListeners:e._maxListeners}function x(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 b,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=j(e))&&o>0&&s.length>o){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=i[t]=r,++e._eventsCount;return e}function _(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 P(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 E(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}b.prototype=Object.create(null),O.EventEmitter=O,O.usingDomains=!1,O.prototype.domain=void 0,O.prototype._events=void 0,O.prototype._maxListeners=void 0,O.defaultMaxListeners=10,O.init=function(){this.domain=null,O.usingDomains&&(!w.active||this instanceof w.Domain||(this.domain=w.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new b,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},O.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},O.prototype.getMaxListeners=function(){return j(this)},O.prototype.emit=function(e){var t,r,n,o,i,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}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 l="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=E(e,n),i=0;i<n;++i)o[i].call(r)}(r,l,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=E(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,l,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=E(e,i),a=0;a<i;++a)s[a].call(r,n,o)}(r,l,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=E(e,s),c=0;c<s;++c)a[c].call(r,n,o,i)}(r,l,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=E(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,l,this,o)}return!0},O.prototype.on=O.prototype.addListener=function(e,t){return x(this,e,t,!1)},O.prototype.prependListener=function(e,t){return x(this,e,t,!0)},O.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,_(this,e,t)),this},O.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,_(this,e,t)),this},O.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 b:(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 b,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},O.prototype.off=function(e,t){return this.removeListener(e,t)},O.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new b,this._eventsCount=0):r[e]&&(0===--this._eventsCount?this._events=new b: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 b,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},O.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):[]},O.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):P.call(e,t)},O.prototype.listenerCount=P,O.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var C="4.0.0-alpha.6";class R extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var T=Object.defineProperty,k=(e,t,r)=>((e,t,r)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class I extends Error{constructor(e){super(),k(this,"name","NgwError"),k(this,"title"),k(this,"message"),k(this,"detail"),k(this,"exception"),k(this,"status_code"),k(this,"data"),k(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,I.prototype)}}var L=Object.defineProperty,q=(e,t,r)=>((e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class A extends I{constructor(e){super(e),q(this,"name","InsufficientPermissionsError"),q(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,A.prototype)}}var U=Object.defineProperty,S=(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);let $=class e extends I{constructor(t){super(t),S(this,"message","There is no response from the server or problem connecting to server."),S(this,"title","Network error"),S(this,"detail","Check network connectivity and try again later."),Object.setPrototypeOf(this,e.prototype)}};var N=Object.defineProperty,F=(e,t,r)=>((e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class D extends Error{constructor(e){super(),F(this,"name","NetworkError"),Object.setPrototypeOf(this,D.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}var B=Object.defineProperty,G=(e,t,r)=>((e,t,r)=>t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class H extends I{constructor(e){super(e),G(this,"name","ResourceNotFoundError"),G(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,H.prototype)}}var M=Object.freeze({__proto__:null,AbortError:R,InsufficientPermissionsError:A,NetworkError:D,NetworksResponseError:$,NgwError:I,ResourceNotFoundError:H,extractError:function(e){if(i(e))return e.name&&e.message&&e.title?{title:e.title,message:e.message,detail:e.detail||null,data:e.data&&e.data.data?e.data.data:null}:!e.exception||void 0!==e.status&&0!==e.status&&void 0!==e.data?{title:"string"==typeof e.title?e.title:"Unexpected error",message:"string"==typeof e.message?e.message:"Something went wrong."}:new $({title:e.title,status_code:e.status_code,exception:e.exception})},isError:function(e){return!!i(e)&&(e.status_code&&e.exception&&e.title)}}),z=Object.defineProperty,J=(e,t,r)=>((e,t,r)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Q extends Error{constructor(e){super(e||"Something went wrong."),J(this,"title"),this.name="BaseAPIError",this.title="Unknown API error",Error.captureStackTrace&&Error.captureStackTrace(this,Q)}}class W extends Q{constructor(e){super(e||"There is no response from the server or problem connecting to server."),J(this,"detail"),this.title="Network error",this.detail="Check network connectivity and try again later."}}class K extends Q{constructor(e){super(e||"Something went wrong."),this.title="Unexpected server response"}}class X extends Q{constructor(e){super(e.message),J(this,"detail"),J(this,"data"),this.title=e.title||this.title,this.detail=e.detail||null,this.data=e}}class V extends Error{constructor(e,t={}){super(e||"Unexpected error while processing long-running request."),J(this,"title"),J(this,"data"),this.name="LunkwillError",this.title="Long-running request error",this.data=t,Error.captureStackTrace&&Error.captureStackTrace(this,V)}}class Y extends V{constructor(e){super("Long-running request was cancelled.",e)}}class Z extends V{constructor(e){super(void 0,e)}}var ee=Object.defineProperty,te=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,oe=(e,t,r)=>t in e?ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ie=(e,t)=>{for(var r in t||(t={}))re.call(t,r)&&oe(e,r,t[r]);if(te)for(var r of te(t))ne.call(t,r)&&oe(e,r,t[r]);return e},se=(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 ae(e){return se(this,null,function*(){const t=yield function(e){return se(this,null,function*(){try{return e.json()}catch(t){throw new Error}})}(e);let r=t.delay_ms;const n=void 0!==t.retry_ms?t.retry_ms:2e3,o=`/api/lunkwill/${t.id}/summary`,i=`/api/lunkwill/${t.id}/response`,s=e=>new Promise(t=>setTimeout(t,e));let a=!1,c=!1;for(;!c;){let e,t;yield s(a?n:r),a=!1;try{e=yield fetch(o,{credentials:"same-origin"}),t=yield e.json()}catch(u){a=!0;continue}switch(t.status){case void 0:throw new V(void 0,t);case"ready":c=!0;break;case"cancelled":throw new Y(t);case"failed":throw new Z(t);case"spooled":case"processing":case"buffering":r=t.delay_ms;break;default:throw new V(void 0,t)}}return i})}const ce=new RegExp(["application/pdf","image/png","image/jpeg","image/tiff","text/csv"].join("|"));function ue(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 le(e,t,r){return se(this,null,function*(){var n,i;const s=ie(ie({},{method:"GET",credentials:"same-origin",headers:{}}),t),{withCredentials:a,responseType:c,cacheProps:u,cacheName:l,lunkwill:h,cache:f,query:p,json:d}=s,y=((e,t)=>{var r={};for(var n in e)re.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&te)for(var n of te(e))t.indexOf(n)<0&&ne.call(e,n)&&(r[n]=e[n]);return r})(s,["withCredentials","responseType","cacheProps","cacheName","lunkwill","cache","query","json"]);y.method=null==(n=y.method)?void 0:n.toUpperCase(),a&&(y.credentials="include");let m=!1;void 0!==h&&(h.toHeaders(y.headers||{}),m=!0);const v=!!y.lunkwillReturnUrl;if(delete y.lunkwillReturnUrl,void 0!==d){y.body=JSON.stringify(d);const e=y.headers||{};e["Content-Type"]="application/json",y.headers=e}const g=ue(e,p),w=()=>se(null,null,function*(){let e;try{e=yield fetch(g,y)}catch(o){if(y.signal&&y.signal.aborted)throw o;throw new W}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 ae(e);if(v)return t;e=yield function(e){return se(this,null,function*(){try{return yield window.fetch(e,{credentials:"same-origin"})}catch(o){throw new W}})}(t)}const t=e.headers.get("content-type"),r=t&&(t.includes("application/json")||t.includes("application/vnd.lunkwill.request-summary+json"));let n;try{const o=t&&ce.test(t);if("blob"===c||o)n=yield e.blob();else{if(!r)throw new K;n=yield e.json()}}catch(o){if("AbortError"===o.name||o instanceof K)throw o;throw new K}if(400<=e.status&&e.status<=599)throw new X(n);return n});if(r)if("GET"===(null==(i=y.method)?void 0:i.toUpperCase())){if(!1!==f){const e=u||ie({},o({withCredentials:a,responseType:c}));return r.add(l||g,w,{props:e,expirationTime:f?void 0:500})}}else{["api/feature_layer/identify"].every(t=>!e.includes(t))&&r.clean()}return w()})}var he=Object.defineProperty,fe=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,ve=(e,t,r)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ge=(e,t)=>{for(var r in t||(t={}))ye.call(t,r)&&ve(e,r,t[r]);if(de)for(var r of de(t))me.call(t,r)&&ve(e,r,t[r]);return e},we=(e,t)=>{var r={};for(var n in e)ye.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&de)for(var n of de(e))t.indexOf(n)<0&&me.call(e,n)&&(r[n]=e[n]);return r};function be(e,t,r,...n){const[o,...i]=r[e],a=n[0];let c;if(void 0===a)c=[];else if("object"==typeof a&&null!==a){if(n.length>1)throw new Error("Too many arguments for route(name, object)!");c=[];for(const[e,t]of Object.entries(a))c[i.indexOf(e)]=String(t)}else c=n.map(e=>String(e));return s(t+o.replace(/\{(\w+)\}/g,function(e,t){const r=parseInt(t),n=c[r];if(void 0===n){throw new Error(`Undefined parameter ${r} in "${o}".`)}return String(n)}))}function Oe(e,t,...r){const n={url:n=>{return o=null,i=null,s=function*(){var o;const i=yield t.connect();return ue(be(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}},i=["get","post","put","delete","patch"];for(const s of i){const i=n=>{var i;const a=n||{},{headers:c}=a,u=we(a,["headers"]);if(null==(i=null==n?void 0:n.signal)?void 0:i.aborted)throw new R;return t.connect().then(n=>{var i;const a=be(e,null!=(i=t.options.baseUrl)?i:"",n,...r),l=o(ge(ge({},t.getAuthorizationHeaders()),null!=c?c:{}));return le(a,(h=ge({headers:l},u),fe(h,pe({method:s}))),t.cache);var h})};n[s]=i}return n}function je(e){return"[object Object]"===Object.prototype.toString.call(e)}let xe;xe=(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 I(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 D(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 u in a){const e=a[u];"string"==typeof e&&i.setRequestHeader(u,e)}let c;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(c=new FormData,c.append("file",r.file),r.data)for(const u in r.data)c.append(u,c[u])}else c=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o(()=>{i.abort()}),i.send(c)};const _e=[];function Pe(e){_e.push(e)}var Ee=Object.defineProperty,Ce=Object.defineProperties,Re=Object.getOwnPropertyDescriptors,Te=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Le=(e,t,r)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qe=(e,t)=>{for(var r in t||(t={}))ke.call(t,r)&&Le(e,r,t[r]);if(Te)for(var r of Te(t))Ie.call(t,r)&&Le(e,r,t[r]);return e},Ae=(e,t,r)=>Le(e,"symbol"!=typeof t?t+"":t,r),Ue=(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 Se=0,$e=0;class Ne{constructor(e){Ae(this,"options",e),Ae(this,"id",Se++),Ae(this,"emitter",new O),Ae(this,"user"),Ae(this,"cache"),Ae(this,"withCredentials"),Ae(this,"routeCache"),Ae(this,"client",`NextGIS-NGW-Connector/${C}`),Ae(this,"routeStr","/api/component/pyramid/route"),Ae(this,"activeRequests",{}),Ae(this,"requestTransform");const t=function(e){return _e.find(t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return n(t.options.auth,e.auth)}})}(e);if(this.cache=new g({namespace:e.cacheId}),this.routeCache=new g({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),Pe(this)}}clearCache(){this.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Pe(this)}connect(){return Ue(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(),Pe(this),this._login(e,t)}logout(){this.abort(),function(e){const t=_e.indexOf(e);-1!==t&&_e.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 Ue(this,null,function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=qe({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 qe({},this.activeRequests)}route(e,...t){return Oe(e,this,...t)}makeQuery(e,t){return Ue(this,arguments,function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=t,n=((e,t)=>{var r={};for(var n in e)ke.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Te)for(var n of Te(e))t.indexOf(n)<0&&Ie.call(e,n)&&(r[n]=e[n]);return r})(r,["paramList"]);e=c(e,n)}e=encodeURI(s(e)),r=qe({withCredentials:this.withCredentials},r);const{cache:i,signal:a,method:u="GET",headers:l,cacheName:h,cacheProps:f,responseType:p,withCredentials:d}=r,y=new AbortController,m=y.signal;if(a){if(a.aborted)throw new R;a.addEventListener("abort",()=>{y.abort()})}r.signal=m;const v=()=>Ue(this,null,function*(){const t=$e++;this.activeRequests[t]=y;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}});if("GET"===u&&!1!==i){const r=f||(g=qe({},o({headers:l,withCredentials:d,responseType:p,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),Ce(g,Re({params:t})));return this.cache.add(h||e,v,{props:r,expirationTime:i?void 0:500})}var g;return v()})}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise((r,n)=>{var o;if(this.user&&((t=t||{}).headers=qe(qe({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;xe(e,r,t,n,e=>{i=e}),null==(o=t.signal)||o.addEventListener("abort",()=>{void 0!==i&&i(),n(new R)})}).catch(e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e})}_login(e,t){return Ue(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 I){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new H(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new A(e)}return e}}Ae(Ne,"errors",M);const Fe=["description"];function De(t,r=""){r=r?r+"__":"";const n={};for(const[o,i]of Object.entries(t))if(-1===Fe.indexOf(o))if(je(i))if("owner_user"===o){const e=De(i,o);Object.assign(n,e)}else"parent"===o&&"id"in i&&(n.parent_id=i.id);else e(i)&&(n[r+o]=i);return n}var Be=Object.defineProperty,Ge=Object.defineProperties,He=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Qe=(e,t,r)=>t in e?Be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,We=(e,t)=>{for(var r in t||(t={}))ze.call(t,r)&&Qe(e,r,t[r]);if(Me)for(var r of Me(t))Je.call(t,r)&&Qe(e,r,t[r]);return e},Ke=(e,t)=>Ge(e,He(t)),Xe=(e,t,r)=>Qe(e,"symbol"!=typeof t?t+"":t,r),Ve=(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 Ye{constructor({connector:e,cacheId:t}){Xe(this,"cache"),Xe(this,"connector"),this.connector=e,this.cache=new g({namespace:t})}getOne(e,t){const r=We({},t);return"string"==typeof e||"number"==typeof e||je(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):je(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 H})}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||je(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,De(e)),this.connector.route("resource.search").get(Ke(We({},t),{query:We({serialization:"full"},r)})).then(e=>{const r=Array.isArray(e)?e:e.items;if(null==t?void 0:t.cache)for(const t of r)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return r})}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 Ve(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(Ke(We({},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 Ve(this,null,function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;if(["resource.item","resource"].includes(o.key)&&void 0!==r)if("number"==typeof r)r===e&&n.push(o);else{(yield this.getId(r))===e&&n.push(o)}}for(const e of n)this.cache.delete(e)})}_fetchResourceById(e,t){return this.connector.route("resource.item",{id:e}).get(t)}_fetchResourceBy(e,t){return this.getMany(e,t).then(e=>e[0])}_resourceCacheFilter(t){return Promise.all(this.cache.matchAll("resource.item")).then(r=>(r.filter(r=>{if(r)return t.keyname&&r.resource.keyname?t.keyname===r.resource.keyname:e(t.id)&&e(r.resource.id)?t.id===r.resource.id:n(t,r.resource)}),[]))}}var Ze=Object.defineProperty,et=(e,t,r)=>((e,t,r)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class tt extends Ne{constructor(e){super(e),et(this,"resources"),this.resources=new Ye({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 d({name:e,params:o(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}}export{tt as default};
2
2
  //# sourceMappingURL=ngw-connector.esm-browser.prod.js.map