@nextgis/ngw-map 3.0.0-alpha.0 → 3.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.8; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -32,7 +32,7 @@ var NgwMap = (function (exports) {
32
32
  this.domain = null;
33
33
  if (EventEmitter.usingDomains) {
34
34
  // if there is an active domain, then attach to it.
35
- if (domain.active ) ;
35
+ if (domain.active) ;
36
36
  }
37
37
 
38
38
  if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
@@ -827,12 +827,12 @@ var NgwMap = (function (exports) {
827
827
  return url.replace(/([^:]\/)\/+/g, "$1");
828
828
  }
829
829
 
830
- var __defProp$K = Object.defineProperty;
831
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
832
- var __publicField$v = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
830
+ var __defProp$Q = Object.defineProperty;
831
+ var __defNormalProp$Q = (obj, key, value) => key in obj ? __defProp$Q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
832
+ var __publicField$z = (obj, key, value) => __defNormalProp$Q(obj, typeof key !== "symbol" ? key + "" : key, value);
833
833
  const _Cache = class _Cache {
834
834
  constructor(options = {}) {
835
- __publicField$v(this, "cache", []);
835
+ __publicField$z(this, "cache", []);
836
836
  var _a;
837
837
  const namespace = (_a = options.namespace) != null ? _a : "default";
838
838
  if (_Cache.instance[namespace]) {
@@ -868,10 +868,23 @@ var NgwMap = (function (exports) {
868
868
  * });
869
869
  * ```
870
870
  */
871
- addFull(key, valueToSet, props) {
872
- return this.add(key, valueToSet, props, true);
873
- }
874
- add(key, valueToSet, props, onlyFull) {
871
+ addFull(key, valueToSet, propsOrOptions, expirationTime) {
872
+ if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
873
+ propsOrOptions.onlyFull = true;
874
+ }
875
+ return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
876
+ }
877
+ add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
878
+ let opt;
879
+ let props;
880
+ if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
881
+ opt = propsOrOptions;
882
+ onlyFull = opt.onlyFull;
883
+ expirationTime = opt.expirationTime;
884
+ props = opt.props;
885
+ } else {
886
+ props = propsOrOptions;
887
+ }
875
888
  const exist = this._find(key, props);
876
889
  if (!exist) {
877
890
  let value;
@@ -881,10 +894,12 @@ var NgwMap = (function (exports) {
881
894
  value = valueToSet;
882
895
  }
883
896
  const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
897
+ expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
884
898
  const cacheItem = {
885
899
  key,
886
900
  value,
887
- props: nonEmptyProps
901
+ props: nonEmptyProps,
902
+ expirationTime
888
903
  };
889
904
  if (onlyFull && !full(value)) {
890
905
  return value;
@@ -911,9 +926,19 @@ var NgwMap = (function (exports) {
911
926
  }
912
927
  match(key, props) {
913
928
  const cacheRecord = this._find(key, props);
929
+ if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
930
+ this.delete(cacheRecord);
931
+ return void 0;
932
+ }
914
933
  return cacheRecord == null ? void 0 : cacheRecord.value;
915
934
  }
916
935
  matchAll(key, props) {
936
+ const now = Date.now();
937
+ this.cache.forEach((item) => {
938
+ if (item.expirationTime && now > item.expirationTime) {
939
+ this.delete(item);
940
+ }
941
+ });
917
942
  if (key) {
918
943
  return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
919
944
  }
@@ -938,87 +963,305 @@ var NgwMap = (function (exports) {
938
963
  return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
939
964
  }
940
965
  };
941
- __publicField$v(_Cache, "instance", {});
966
+ __publicField$z(_Cache, "instance", {});
942
967
  let Cache = _Cache;
943
968
 
944
- var __defProp$J = Object.defineProperty;
945
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
946
- var __publicField$u = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
969
+ var pkg = {
970
+ name: "@nextgis/ngw-connector",
971
+ version: "3.0.0-alpha.8",
972
+ _priority: 12,
973
+ description: "A lightweight HTTP client optimized for use with NextGIS Web API",
974
+ main: "index.js",
975
+ module: "lib/ngw-connector.esm-bundler.js",
976
+ unpkg: "lib/ngw-connector.global.prod.js",
977
+ jsdelivr: "lib/ngw-connector.global.prod.js",
978
+ types: "lib/index.d.ts",
979
+ dependencies: {
980
+ "@nextgis/cache": "^3.0.0-alpha.7",
981
+ "@nextgis/cancelable-promise": "^3.0.0-alpha.5",
982
+ "@nextgis/utils": "^3.0.0-alpha.5",
983
+ "@types/events": "^3.0.0",
984
+ events: "*",
985
+ "form-data": "^4.0.0"
986
+ },
987
+ devDependencies: {
988
+ "@nextgis/build-tools": "^3.0.0-alpha.5"
989
+ },
990
+ scripts: {
991
+ clean: "rimraf ./lib",
992
+ dev: "node ../build-tools/lib/build.js",
993
+ prod: "npm run dev -- --release",
994
+ lint: "eslint ./src/**/*.ts --fix --c ../../.eslintrc",
995
+ watch: "npm run dev -- --watch",
996
+ "gen:types": "node ./scripts/generator"
997
+ },
998
+ buildOptions: {
999
+ name: "NgwConnector",
1000
+ formats: [
1001
+ "esm-bundler",
1002
+ "esm-browser",
1003
+ "cjs",
1004
+ "global"
1005
+ ]
1006
+ },
1007
+ keywords: [
1008
+ "NextGIS",
1009
+ "MAP"
1010
+ ],
1011
+ author: "NextGIS",
1012
+ files: [
1013
+ "index.js",
1014
+ "lib"
1015
+ ],
1016
+ license: "MIT",
1017
+ homepage: "https://github.com/nextgis/nextgis_frontend/tree/master/packages/ngw-connector#readme",
1018
+ repository: {
1019
+ type: "git",
1020
+ url: "git://github.com/nextgis/nextgis_frontend.git"
1021
+ },
1022
+ engines: {
1023
+ node: ">=18.20.4"
1024
+ },
1025
+ gitHead: "edc68033f914f6c95c4125b9738bba6d36e990b4"
1026
+ };
1027
+
1028
+ const CONNECTORS = [];
1029
+ function addConnector(connector) {
1030
+ CONNECTORS.push(connector);
1031
+ }
1032
+ function findConnector(options) {
1033
+ return CONNECTORS.find((x) => {
1034
+ if (x.options.baseUrl === options.baseUrl) {
1035
+ if (options.auth) {
1036
+ if (x.options.auth) {
1037
+ return objectDeepEqual(x.options.auth, options.auth);
1038
+ }
1039
+ } else {
1040
+ return true;
1041
+ }
1042
+ }
1043
+ });
1044
+ }
1045
+ function removeConnector(connector) {
1046
+ const index = CONNECTORS.indexOf(connector);
1047
+ if (index !== -1) {
1048
+ CONNECTORS.splice(index, 1);
1049
+ }
1050
+ }
1051
+
1052
+ class AbortError extends Error {
1053
+ constructor(message = "AbortError") {
1054
+ super(message);
1055
+ this.name = "AbortError";
1056
+ }
1057
+ }
1058
+
1059
+ var __defProp$P = Object.defineProperty;
1060
+ var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1061
+ var __publicField$y = (obj, key, value) => __defNormalProp$P(obj, typeof key !== "symbol" ? key + "" : key, value);
947
1062
  class NgwError extends Error {
948
1063
  constructor(er) {
949
1064
  super();
950
- __publicField$u(this, "name", "NgwError");
951
- __publicField$u(this, "title");
952
- __publicField$u(this, "message");
953
- __publicField$u(this, "detail");
954
- __publicField$u(this, "exception");
955
- __publicField$u(this, "status_code");
956
- __publicField$u(this, "data");
957
- __publicField$u(this, "guru_meditation");
1065
+ __publicField$y(this, "name", "NgwError");
1066
+ __publicField$y(this, "title");
1067
+ __publicField$y(this, "message");
1068
+ __publicField$y(this, "detail");
1069
+ __publicField$y(this, "exception");
1070
+ __publicField$y(this, "status_code");
1071
+ __publicField$y(this, "data");
1072
+ __publicField$y(this, "guru_meditation");
958
1073
  Object.assign(this, er);
959
1074
  Object.setPrototypeOf(this, NgwError.prototype);
960
1075
  }
961
1076
  }
962
1077
 
963
- var __defProp$I = Object.defineProperty;
964
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
965
- var __publicField$t = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
1078
+ var __defProp$O = Object.defineProperty;
1079
+ var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1080
+ var __publicField$x = (obj, key, value) => __defNormalProp$O(obj, typeof key !== "symbol" ? key + "" : key, value);
1081
+ class InsufficientPermissionsError extends NgwError {
1082
+ constructor(obj) {
1083
+ super(obj);
1084
+ __publicField$x(this, "name", "InsufficientPermissionsError");
1085
+ __publicField$x(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
1086
+ Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
1087
+ }
1088
+ }
1089
+
1090
+ var __defProp$N = Object.defineProperty;
1091
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1092
+ var __publicField$w = (obj, key, value) => __defNormalProp$N(obj, key + "" , value);
1093
+ class NetworkError extends Error {
1094
+ constructor(url) {
1095
+ super();
1096
+ __publicField$w(this, "name", "NetworkError");
1097
+ Object.setPrototypeOf(this, NetworkError.prototype);
1098
+ this.message = `Unable to request ${url}.
1099
+ Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
1100
+ }
1101
+ }
1102
+
1103
+ var __defProp$M = Object.defineProperty;
1104
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1105
+ var __publicField$v = (obj, key, value) => __defNormalProp$M(obj, typeof key !== "symbol" ? key + "" : key, value);
1106
+ let NetworksResponseError$1 = class NetworksResponseError extends NgwError {
1107
+ constructor(obj) {
1108
+ super(obj);
1109
+ __publicField$v(this, "message", "There is no response from the server or problem connecting to server.");
1110
+ __publicField$v(this, "title", "Network error");
1111
+ __publicField$v(this, "detail", "Check network connectivity and try again later.");
1112
+ Object.setPrototypeOf(this, NetworksResponseError.prototype);
1113
+ }
1114
+ };
1115
+
1116
+ var __defProp$L = Object.defineProperty;
1117
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1118
+ var __publicField$u = (obj, key, value) => __defNormalProp$L(obj, typeof key !== "symbol" ? key + "" : key, value);
966
1119
  class ResourceNotFoundError extends NgwError {
967
1120
  constructor(obj) {
968
1121
  super(obj);
969
- __publicField$t(this, "name", "ResourceNotFoundError");
970
- __publicField$t(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
1122
+ __publicField$u(this, "name", "ResourceNotFoundError");
1123
+ __publicField$u(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
971
1124
  Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
972
1125
  }
973
1126
  }
974
1127
 
975
- function isObject(val) {
976
- return Object.prototype.toString.call(val) === "[object Object]";
1128
+ function isError(error) {
1129
+ if (isObject$1(error)) {
1130
+ return error.status_code && error.exception && error.title;
1131
+ }
1132
+ return false;
977
1133
  }
978
1134
 
979
- function resourceCompare(res1, res2) {
980
- return objectDeepEqual(res1, res2);
1135
+ function extractError(error) {
1136
+ if (isObject$1(error)) {
1137
+ if (error.name && error.message && error.title) {
1138
+ return {
1139
+ title: error.title,
1140
+ message: error.message,
1141
+ detail: error.detail || null,
1142
+ data: error.data && error.data.data ? error.data.data : null
1143
+ };
1144
+ } else if (error.exception) {
1145
+ if (error.status === void 0 || error.status === 0 || error.data === void 0) {
1146
+ return new NetworksResponseError$1({
1147
+ title: error.title,
1148
+ status_code: error.status_code,
1149
+ exception: error.exception
1150
+ });
1151
+ }
1152
+ }
1153
+ return {
1154
+ title: typeof error.title === "string" ? error.title : "Unexpected error",
1155
+ message: typeof error.message === "string" ? error.message : "Something went wrong."
1156
+ };
1157
+ }
981
1158
  }
982
1159
 
983
- const exclude = ["description"];
984
- function resourceToQuery(resource, prefix = "") {
985
- prefix = prefix ? prefix + "__" : "";
986
- const query = {};
987
- for (const [key, value] of Object.entries(resource)) {
988
- if (exclude.indexOf(key) === -1) {
989
- if (isObject(value)) {
990
- if (key === "owner_user") {
991
- const children = resourceToQuery(value, key);
992
- Object.assign(query, children);
993
- } else if (key === "parent" && "id" in value) {
994
- query.parent_id = value.id;
995
- }
996
- } else if (defined(value)) {
997
- query[prefix + key] = value;
998
- }
1160
+ var errors = /*#__PURE__*/Object.freeze({
1161
+ __proto__: null,
1162
+ AbortError: AbortError,
1163
+ InsufficientPermissionsError: InsufficientPermissionsError,
1164
+ NetworkError: NetworkError,
1165
+ NetworksResponseError: NetworksResponseError$1,
1166
+ NgwError: NgwError,
1167
+ ResourceNotFoundError: ResourceNotFoundError,
1168
+ extractError: extractError,
1169
+ isError: isError
1170
+ });
1171
+
1172
+ var __defProp$K = Object.defineProperty;
1173
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1174
+ var __publicField$t = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
1175
+ class BaseAPIError extends Error {
1176
+ constructor(message) {
1177
+ super(message || "Something went wrong.");
1178
+ __publicField$t(this, "title");
1179
+ this.name = "BaseAPIError";
1180
+ this.title = "Unknown API error";
1181
+ if (Error.captureStackTrace) {
1182
+ Error.captureStackTrace(this, BaseAPIError);
999
1183
  }
1000
1184
  }
1001
- return query;
1185
+ }
1186
+ class NetworksResponseError extends BaseAPIError {
1187
+ // prettier-ignore
1188
+ constructor(message) {
1189
+ super(message || "There is no response from the server or problem connecting to server.");
1190
+ __publicField$t(this, "detail");
1191
+ this.title = "Network error";
1192
+ this.detail = "Check network connectivity and try again later.";
1193
+ }
1194
+ }
1195
+ class InvalidResponseError extends BaseAPIError {
1196
+ constructor(message) {
1197
+ super(message || "Something went wrong.");
1198
+ this.title = "Unexpected server response";
1199
+ }
1200
+ }
1201
+ class ServerResponseError extends BaseAPIError {
1202
+ constructor(data) {
1203
+ super(data.message);
1204
+ __publicField$t(this, "detail");
1205
+ __publicField$t(this, "data");
1206
+ this.title = data.title || this.title;
1207
+ this.detail = data.detail || null;
1208
+ this.data = data;
1209
+ }
1210
+ }
1211
+ class LunkwillError extends Error {
1212
+ // prettier-ignore
1213
+ constructor(message, data = {}) {
1214
+ super(message || "Unexpected error while processing long-running request.");
1215
+ __publicField$t(this, "title");
1216
+ __publicField$t(this, "data");
1217
+ this.name = "LunkwillError";
1218
+ this.title = "Long-running request error";
1219
+ this.data = data;
1220
+ if (Error.captureStackTrace) {
1221
+ Error.captureStackTrace(this, LunkwillError);
1222
+ }
1223
+ }
1224
+ }
1225
+ class LunkwillRequestCancelled extends LunkwillError {
1226
+ constructor(data) {
1227
+ super("Long-running request was cancelled.", data);
1228
+ }
1229
+ }
1230
+ class LunkwillRequestFailed extends LunkwillError {
1231
+ constructor(data) {
1232
+ super(void 0, data);
1233
+ }
1002
1234
  }
1003
1235
 
1004
- var __defProp$H = Object.defineProperty;
1005
- var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1006
- var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1007
- var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1008
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1009
- var __spreadValues$v = (a, b) => {
1236
+ var __defProp$J = Object.defineProperty;
1237
+ var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
1238
+ var __hasOwnProp$y = Object.prototype.hasOwnProperty;
1239
+ var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
1240
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1241
+ var __spreadValues$x = (a, b) => {
1010
1242
  for (var prop in b || (b = {}))
1011
- if (__hasOwnProp$w.call(b, prop))
1012
- __defNormalProp$H(a, prop, b[prop]);
1013
- if (__getOwnPropSymbols$w)
1014
- for (var prop of __getOwnPropSymbols$w(b)) {
1015
- if (__propIsEnum$w.call(b, prop))
1016
- __defNormalProp$H(a, prop, b[prop]);
1243
+ if (__hasOwnProp$y.call(b, prop))
1244
+ __defNormalProp$J(a, prop, b[prop]);
1245
+ if (__getOwnPropSymbols$y)
1246
+ for (var prop of __getOwnPropSymbols$y(b)) {
1247
+ if (__propIsEnum$y.call(b, prop))
1248
+ __defNormalProp$J(a, prop, b[prop]);
1017
1249
  }
1018
1250
  return a;
1019
1251
  };
1020
- var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
1021
- var __async$s = (__this, __arguments, generator) => {
1252
+ var __objRest$5 = (source, exclude) => {
1253
+ var target = {};
1254
+ for (var prop in source)
1255
+ if (__hasOwnProp$y.call(source, prop) && exclude.indexOf(prop) < 0)
1256
+ target[prop] = source[prop];
1257
+ if (source != null && __getOwnPropSymbols$y)
1258
+ for (var prop of __getOwnPropSymbols$y(source)) {
1259
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$y.call(source, prop))
1260
+ target[prop] = source[prop];
1261
+ }
1262
+ return target;
1263
+ };
1264
+ var __async$v = (__this, __arguments, generator) => {
1022
1265
  return new Promise((resolve, reject) => {
1023
1266
  var fulfilled = (value) => {
1024
1267
  try {
@@ -1038,123 +1281,967 @@ var NgwMap = (function (exports) {
1038
1281
  step((generator = generator.apply(__this, __arguments)).next());
1039
1282
  });
1040
1283
  };
1041
- class ResourcesControl {
1042
- constructor({
1043
- connector,
1044
- cacheId
1045
- }) {
1046
- __publicField$s(this, "cache");
1047
- __publicField$s(this, "connector");
1048
- this.connector = connector;
1049
- this.cache = new Cache({ namespace: cacheId });
1050
- }
1051
- // -------------------------------------------------------------------------
1052
- // Resource Methods
1053
- // -------------------------------------------------------------------------
1054
- /**
1055
- * Receive resource from NGW by id, keyname or search-object parameter.
1056
- * @param resource - Resource id, keyname or search-object
1057
- *
1058
- * @remarks
1059
- * Fetching resource would be cached to speed up next call
1060
- */
1061
- getOne(resource, requestOptions) {
1062
- const opt = __spreadValues$v({}, requestOptions);
1063
- if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
1064
- if (resource.id !== void 0) {
1065
- resource.id;
1066
- } else {
1067
- if (resource.keyname) {
1068
- resource.keyname;
1069
- }
1070
- if (resource.display_name) {
1071
- resource.display_name;
1072
- }
1284
+ function lunkwillCheckResponse(lwResp) {
1285
+ const ct = lwResp.headers.get("content-type");
1286
+ return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
1287
+ }
1288
+ function responseJson(response) {
1289
+ return __async$v(this, null, function* () {
1290
+ try {
1291
+ return response.json();
1292
+ } catch (e) {
1293
+ throw new Error();
1294
+ }
1295
+ });
1296
+ }
1297
+ function lunkwillResponseUrl(lwResp) {
1298
+ return __async$v(this, null, function* () {
1299
+ const lwData = yield responseJson(lwResp);
1300
+ let delay = lwData.delay_ms;
1301
+ const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
1302
+ const sum = `/api/lunkwill/${lwData.id}/summary`;
1303
+ const res = `/api/lunkwill/${lwData.id}/response`;
1304
+ const sleep = (msec) => new Promise((resolve) => setTimeout(resolve, msec));
1305
+ let failed = false;
1306
+ let ready = false;
1307
+ while (!ready) {
1308
+ yield sleep(failed ? retry : delay);
1309
+ failed = false;
1310
+ let lwResp2;
1311
+ let lwData2;
1312
+ try {
1313
+ lwResp2 = yield fetch(sum, { credentials: "same-origin" });
1314
+ lwData2 = yield lwResp2.json();
1315
+ } catch (e) {
1316
+ failed = true;
1317
+ continue;
1318
+ }
1319
+ switch (lwData2.status) {
1320
+ case void 0:
1321
+ throw new LunkwillError(void 0, lwData2);
1322
+ case "ready":
1323
+ ready = true;
1324
+ break;
1325
+ case "cancelled":
1326
+ throw new LunkwillRequestCancelled(lwData2);
1327
+ case "failed":
1328
+ throw new LunkwillRequestFailed(lwData2);
1329
+ case "spooled":
1330
+ case "processing":
1331
+ case "buffering":
1332
+ delay = lwData2.delay_ms;
1333
+ break;
1334
+ default:
1335
+ throw new LunkwillError(void 0, lwData2);
1073
1336
  }
1074
1337
  }
1075
- if (typeof resource === "string") {
1076
- return this._fetchResourceBy({ keyname: resource }, opt);
1077
- } else if (typeof resource === "number") {
1078
- return this._fetchResourceById(resource, opt);
1079
- } else if (isObject(resource)) {
1080
- return this._fetchResourceBy(resource, opt);
1338
+ return res;
1339
+ });
1340
+ }
1341
+ function lunkwillFetch(lwRespUrl) {
1342
+ return __async$v(this, null, function* () {
1343
+ try {
1344
+ return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
1345
+ } catch (e) {
1346
+ throw new NetworksResponseError();
1081
1347
  }
1082
- return Promise.resolve(void 0);
1083
- }
1084
- getOneOrFail(resource, requestOptions) {
1085
- return this.getOne(resource, requestOptions).then((res) => {
1086
- if (res) {
1087
- return res;
1088
- }
1089
- throw new ResourceNotFoundError();
1090
- });
1091
- }
1092
- /**
1093
- * A fast way to retrieve resource ID for any resource definition.
1094
- * @param resource - Any available resource definition
1095
- *
1096
- * @remarks
1097
- * There are situations when exactly the resource id is needed
1098
- * (for example, to compose the correct request to the api)
1099
- * then this method will come in handy to facilitate the extraction of the identifier
1100
- * if the resource is specified through a keyname or other parameters.
1101
- */
1102
- getId(resource, requestOptions) {
1103
- if (typeof resource === "number") {
1104
- return Promise.resolve(resource);
1105
- } else if (typeof resource === "string" || isObject(resource)) {
1106
- return this.getOne(resource, requestOptions).then((res) => {
1107
- if (res) {
1108
- return res.resource.id;
1348
+ });
1349
+ }
1350
+ const mediaContentTypes = [
1351
+ "application/pdf",
1352
+ "image/png",
1353
+ "image/jpeg",
1354
+ "image/tiff",
1355
+ "text/csv"
1356
+ ];
1357
+ const mediaContentTypesRegex = new RegExp(mediaContentTypes.join("|"));
1358
+ function isMediaContentType(contentType) {
1359
+ return mediaContentTypesRegex.test(contentType);
1360
+ }
1361
+ function encodeQueryParams(value) {
1362
+ const result = [];
1363
+ for (const [k, v] of Object.entries(value)) {
1364
+ if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
1365
+ result.push(`${k}=${encodeURIComponent(v)}`);
1366
+ } else if (Array.isArray(v)) {
1367
+ result.push(`${k}=${v.map(encodeURIComponent).join(",")}`);
1368
+ } else {
1369
+ for (const [sk, sv] of Object.entries(v)) {
1370
+ const ske = `${k}[${encodeURIComponent(sk)}]`;
1371
+ if (typeof sv === "string" || typeof sv === "number" || typeof sv === "boolean") {
1372
+ result.push(`${ske}=${encodeURIComponent(sv)}`);
1373
+ } else if (Array.isArray(sv)) {
1374
+ const sve = sv.map(encodeURIComponent);
1375
+ result.push(`${ske}=${sve.join(",")}`);
1109
1376
  }
1110
- });
1377
+ }
1111
1378
  }
1112
- return Promise.resolve(void 0);
1113
1379
  }
1114
- /**
1115
- * A fast way to retrieve resource ID for any resource definition.
1116
- * @param resource - Any available resource definition
1117
- *
1118
- * @remarks
1119
- * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
1120
- * To not make one more checks if the resource is definitely exists
1121
- */
1122
- getIdOrFail(resource, requestOptions) {
1123
- return this.getId(resource, requestOptions).then((resp) => {
1124
- if (resp === void 0) {
1125
- throw new Error();
1126
- }
1127
- return resp;
1128
- });
1380
+ return result.join("&");
1381
+ }
1382
+ function generateUrl(path, query) {
1383
+ let urlParams = "";
1384
+ if (query !== void 0) {
1385
+ urlParams = "?" + encodeQueryParams(query);
1129
1386
  }
1130
- getMany(resource, requestOptions) {
1131
- return this._resourceCacheFilter(resource).then((items) => {
1132
- if (!items.length) {
1133
- const query = {};
1134
- if (resource.keyname) {
1135
- query.keyname = resource.keyname;
1136
- } else {
1137
- Object.assign(query, resourceToQuery(resource));
1387
+ return path + urlParams;
1388
+ }
1389
+ function request(path, options, cacheEngine) {
1390
+ return __async$v(this, null, function* () {
1391
+ var _b;
1392
+ const defaults = {
1393
+ method: "GET",
1394
+ credentials: "same-origin",
1395
+ headers: {}
1396
+ };
1397
+ const _a = __spreadValues$x(__spreadValues$x({}, defaults), options), {
1398
+ withCredentials,
1399
+ responseType,
1400
+ cacheProps,
1401
+ cacheName,
1402
+ lunkwill,
1403
+ cache,
1404
+ query,
1405
+ json
1406
+ } = _a, opt = __objRest$5(_a, [
1407
+ "withCredentials",
1408
+ "responseType",
1409
+ "cacheProps",
1410
+ "cacheName",
1411
+ "lunkwill",
1412
+ "cache",
1413
+ "query",
1414
+ "json"
1415
+ ]);
1416
+ if (withCredentials) {
1417
+ opt.credentials = "include";
1418
+ }
1419
+ let useLunkwill = false;
1420
+ if (lunkwill !== void 0) {
1421
+ lunkwill.toHeaders(opt.headers || {});
1422
+ useLunkwill = true;
1423
+ }
1424
+ const lunkwillReturnUrl = !!opt.lunkwillReturnUrl;
1425
+ delete opt.lunkwillReturnUrl;
1426
+ if (json !== void 0) {
1427
+ opt.body = JSON.stringify(json);
1428
+ const headers = opt.headers || {};
1429
+ headers["Content-Type"] = "application/json";
1430
+ opt.headers = headers;
1431
+ }
1432
+ const url = generateUrl(path, query);
1433
+ const makeRequest = () => __async$v(this, null, function* () {
1434
+ let response;
1435
+ try {
1436
+ response = yield fetch(url, opt);
1437
+ } catch (e) {
1438
+ if (opt.signal && opt.signal.aborted) {
1439
+ throw e;
1138
1440
  }
1139
- return this.connector.get("resource.search", requestOptions, __spreadValues$v({
1140
- serialization: "full"
1141
- }, query)).then((resources) => {
1142
- if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
1143
- for (const x of resources) {
1144
- this.cache.add("resource.item", Promise.resolve(x), {
1145
- id: x.resource.id
1146
- });
1147
- }
1148
- }
1149
- return resources;
1150
- });
1441
+ throw new NetworksResponseError();
1442
+ }
1443
+ if (useLunkwill && lunkwillCheckResponse(response)) {
1444
+ const lwRespUrl = yield lunkwillResponseUrl(response);
1445
+ if (lunkwillReturnUrl) {
1446
+ return lwRespUrl;
1447
+ }
1448
+ response = yield lunkwillFetch(lwRespUrl);
1449
+ }
1450
+ const respCType = response.headers.get("content-type");
1451
+ const respJSON = respCType && (respCType.includes("application/json") || respCType.includes("application/vnd.lunkwill.request-summary+json"));
1452
+ let body;
1453
+ try {
1454
+ const respMedia = respCType && isMediaContentType(respCType);
1455
+ if (responseType === "blob" || respMedia) {
1456
+ body = yield response.blob();
1457
+ } else if (respJSON) {
1458
+ body = yield response.json();
1459
+ } else {
1460
+ throw new InvalidResponseError();
1461
+ }
1462
+ } catch (e) {
1463
+ if (e.name === "AbortError" || e instanceof InvalidResponseError) {
1464
+ throw e;
1465
+ }
1466
+ throw new InvalidResponseError();
1467
+ }
1468
+ if (400 <= response.status && response.status <= 599) {
1469
+ throw new ServerResponseError(body);
1470
+ }
1471
+ return body;
1472
+ });
1473
+ if (cacheEngine && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
1474
+ const props = cacheProps ? cacheProps : __spreadValues$x({}, objectRemoveEmpty({
1475
+ withCredentials,
1476
+ responseType
1477
+ }));
1478
+ return cacheEngine.add(cacheName || url, makeRequest, {
1479
+ props,
1480
+ expirationTime: cache ? void 0 : 500
1481
+ });
1482
+ }
1483
+ return makeRequest();
1484
+ });
1485
+ }
1486
+
1487
+ var __defProp$I = Object.defineProperty;
1488
+ var __defProps$i = Object.defineProperties;
1489
+ var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
1490
+ var __getOwnPropSymbols$x = Object.getOwnPropertySymbols;
1491
+ var __hasOwnProp$x = Object.prototype.hasOwnProperty;
1492
+ var __propIsEnum$x = Object.prototype.propertyIsEnumerable;
1493
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1494
+ var __spreadValues$w = (a, b) => {
1495
+ for (var prop in b || (b = {}))
1496
+ if (__hasOwnProp$x.call(b, prop))
1497
+ __defNormalProp$I(a, prop, b[prop]);
1498
+ if (__getOwnPropSymbols$x)
1499
+ for (var prop of __getOwnPropSymbols$x(b)) {
1500
+ if (__propIsEnum$x.call(b, prop))
1501
+ __defNormalProp$I(a, prop, b[prop]);
1502
+ }
1503
+ return a;
1504
+ };
1505
+ var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
1506
+ var __objRest$4 = (source, exclude) => {
1507
+ var target = {};
1508
+ for (var prop in source)
1509
+ if (__hasOwnProp$x.call(source, prop) && exclude.indexOf(prop) < 0)
1510
+ target[prop] = source[prop];
1511
+ if (source != null && __getOwnPropSymbols$x)
1512
+ for (var prop of __getOwnPropSymbols$x(source)) {
1513
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$x.call(source, prop))
1514
+ target[prop] = source[prop];
1515
+ }
1516
+ return target;
1517
+ };
1518
+ var __async$u = (__this, __arguments, generator) => {
1519
+ return new Promise((resolve, reject) => {
1520
+ var fulfilled = (value) => {
1521
+ try {
1522
+ step(generator.next(value));
1523
+ } catch (e) {
1524
+ reject(e);
1525
+ }
1526
+ };
1527
+ var rejected = (value) => {
1528
+ try {
1529
+ step(generator.throw(value));
1530
+ } catch (e) {
1531
+ reject(e);
1532
+ }
1533
+ };
1534
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1535
+ step((generator = generator.apply(__this, __arguments)).next());
1536
+ });
1537
+ };
1538
+ function routeURL(name, baseUrl, routeData, ...rest) {
1539
+ const [template, ...params] = routeData[name];
1540
+ const first = rest[0];
1541
+ let sub;
1542
+ if (first === void 0) {
1543
+ sub = [];
1544
+ } else if (typeof first === "object" && first !== null) {
1545
+ if (rest.length > 1) {
1546
+ throw new Error("Too many arguments for route(name, object)!");
1547
+ }
1548
+ sub = [];
1549
+ for (const [p, v] of Object.entries(first)) {
1550
+ sub[params.indexOf(p)] = String(v);
1551
+ }
1552
+ } else {
1553
+ sub = rest.map((v) => String(v));
1554
+ }
1555
+ return fixUrlStr(
1556
+ baseUrl + template.replace(/\{(\w+)\}/g, function(m, a) {
1557
+ const idx = parseInt(a);
1558
+ const value = sub[idx];
1559
+ if (value === void 0) {
1560
+ const msg = `Undefined parameter ${idx} in "${template}".`;
1561
+ throw new Error(msg);
1562
+ }
1563
+ return String(value);
1564
+ })
1565
+ );
1566
+ }
1567
+ function route(name, connector, ...rest) {
1568
+ const result = {
1569
+ url: (opt) => __async$u(this, null, function* () {
1570
+ var _a;
1571
+ const routeData = yield connector.connect();
1572
+ const template = routeURL(
1573
+ name,
1574
+ (_a = connector.options.baseUrl) != null ? _a : "",
1575
+ routeData,
1576
+ ...rest
1577
+ );
1578
+ return generateUrl(template, opt == null ? void 0 : opt.query);
1579
+ })
1580
+ };
1581
+ const methods = ["get", "post", "put", "delete", "patch"];
1582
+ for (const method of methods) {
1583
+ const methodResp = (requestOptions) => __async$u(this, null, function* () {
1584
+ var _b;
1585
+ const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$4(_a, ["headers"]);
1586
+ const routeData = yield connector.connect();
1587
+ const template = routeURL(
1588
+ name,
1589
+ (_b = connector.options.baseUrl) != null ? _b : "",
1590
+ routeData,
1591
+ ...rest
1592
+ );
1593
+ const headers = objectRemoveEmpty(__spreadValues$w(__spreadValues$w({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1594
+ return request(
1595
+ template,
1596
+ __spreadProps$i(__spreadValues$w({
1597
+ headers
1598
+ }, restOpt), {
1599
+ method
1600
+ }),
1601
+ connector.cache
1602
+ );
1603
+ });
1604
+ result[method] = methodResp;
1605
+ }
1606
+ return result;
1607
+ }
1608
+
1609
+ function isObject(val) {
1610
+ return Object.prototype.toString.call(val) === "[object Object]";
1611
+ }
1612
+
1613
+ let loadData;
1614
+ {
1615
+ loadData = (url, callback, options = {}, error, onCancel) => {
1616
+ options.method = options.method || "GET";
1617
+ const xhr = new XMLHttpRequest();
1618
+ xhr.open(options.method || "GET", url, true);
1619
+ if (options.responseType === "blob") {
1620
+ xhr.responseType = options.responseType;
1621
+ }
1622
+ const getResponseText = () => {
1623
+ try {
1624
+ return JSON.parse(xhr.responseText);
1625
+ } catch (er) {
1626
+ return xhr.responseText;
1627
+ }
1628
+ };
1629
+ const processingResponse = (forError = false) => {
1630
+ const cb = forError ? error : callback;
1631
+ if (options.responseType === "blob") {
1632
+ cb(xhr.response);
1633
+ } else {
1634
+ if (xhr.responseText) {
1635
+ cb(getResponseText());
1636
+ } else {
1637
+ error({ message: "" });
1638
+ }
1639
+ }
1640
+ };
1641
+ xhr.onload = () => {
1642
+ if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
1643
+ error(new NgwError(getResponseText()));
1644
+ }
1645
+ processingResponse();
1646
+ };
1647
+ xhr.onerror = (er) => {
1648
+ if (xhr.status === 0) {
1649
+ error(new NetworkError(url));
1650
+ } else {
1651
+ error(er);
1652
+ }
1653
+ };
1654
+ xhr.upload.onprogress = function(e) {
1655
+ if (e.lengthComputable) {
1656
+ const percentComplete = e.loaded / e.total * 100;
1657
+ if (options.onProgress) {
1658
+ options.onProgress(percentComplete, e);
1659
+ }
1660
+ }
1661
+ };
1662
+ const headers = options.headers;
1663
+ if (headers) {
1664
+ for (const h in headers) {
1665
+ const header = headers[h];
1666
+ if (typeof header === "string") {
1667
+ xhr.setRequestHeader(h, header);
1668
+ }
1669
+ }
1670
+ }
1671
+ if (options.withCredentials !== void 0) {
1672
+ xhr.withCredentials = options.withCredentials;
1673
+ }
1674
+ let data;
1675
+ if (options.file) {
1676
+ data = new FormData();
1677
+ data.append("file", options.file);
1678
+ if (options.data) {
1679
+ for (const d in options.data) {
1680
+ data.append(d, data[d]);
1681
+ }
1682
+ }
1683
+ } else {
1684
+ data = options.data ? typeof options.data === "string" ? options.data : JSON.stringify(options.data) : null;
1685
+ }
1686
+ if (onCancel) {
1687
+ onCancel(() => {
1688
+ xhr.abort();
1689
+ });
1690
+ }
1691
+ xhr.send(data);
1692
+ };
1693
+ }
1694
+
1695
+ const templateRe = /\{ *([\w_-]+) *\}/g;
1696
+ function template(str, data) {
1697
+ return str.replace(templateRe, (s, key) => {
1698
+ let value = data[key];
1699
+ if (value === void 0) {
1700
+ throw new Error("No value provided for letiable " + s);
1701
+ } else if (typeof value === "function") {
1702
+ value = value(data);
1703
+ }
1704
+ return value;
1705
+ });
1706
+ }
1707
+
1708
+ var __defProp$H = Object.defineProperty;
1709
+ var __defProps$h = Object.defineProperties;
1710
+ var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
1711
+ var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1712
+ var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1713
+ var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1714
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1715
+ var __spreadValues$v = (a, b) => {
1716
+ for (var prop in b || (b = {}))
1717
+ if (__hasOwnProp$w.call(b, prop))
1718
+ __defNormalProp$H(a, prop, b[prop]);
1719
+ if (__getOwnPropSymbols$w)
1720
+ for (var prop of __getOwnPropSymbols$w(b)) {
1721
+ if (__propIsEnum$w.call(b, prop))
1722
+ __defNormalProp$H(a, prop, b[prop]);
1723
+ }
1724
+ return a;
1725
+ };
1726
+ var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
1727
+ var __objRest$3 = (source, exclude) => {
1728
+ var target = {};
1729
+ for (var prop in source)
1730
+ if (__hasOwnProp$w.call(source, prop) && exclude.indexOf(prop) < 0)
1731
+ target[prop] = source[prop];
1732
+ if (source != null && __getOwnPropSymbols$w)
1733
+ for (var prop of __getOwnPropSymbols$w(source)) {
1734
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$w.call(source, prop))
1735
+ target[prop] = source[prop];
1736
+ }
1737
+ return target;
1738
+ };
1739
+ var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
1740
+ var __async$t = (__this, __arguments, generator) => {
1741
+ return new Promise((resolve, reject) => {
1742
+ var fulfilled = (value) => {
1743
+ try {
1744
+ step(generator.next(value));
1745
+ } catch (e) {
1746
+ reject(e);
1747
+ }
1748
+ };
1749
+ var rejected = (value) => {
1750
+ try {
1751
+ step(generator.throw(value));
1752
+ } catch (e) {
1753
+ reject(e);
1754
+ }
1755
+ };
1756
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1757
+ step((generator = generator.apply(__this, __arguments)).next());
1758
+ });
1759
+ };
1760
+ let ID$2 = 0;
1761
+ let REQUEST_ID = 0;
1762
+ class NgwConnector {
1763
+ constructor(options) {
1764
+ this.options = options;
1765
+ __publicField$s(this, "id", ID$2++);
1766
+ __publicField$s(this, "emitter", new EventEmitter());
1767
+ __publicField$s(this, "user");
1768
+ __publicField$s(this, "cache");
1769
+ __publicField$s(this, "withCredentials");
1770
+ __publicField$s(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
1771
+ __publicField$s(this, "routeStr", "/api/component/pyramid/route");
1772
+ __publicField$s(this, "activeRequests", {});
1773
+ __publicField$s(this, "requestTransform");
1774
+ const exist = findConnector(options);
1775
+ this.cache = new Cache({ namespace: options.cacheId });
1776
+ if (exist) {
1777
+ return exist;
1778
+ } else {
1779
+ const { route: route2, requestTransform, withCredentials } = this.options;
1780
+ if (route2) {
1781
+ this.routeStr = route2;
1782
+ }
1783
+ if (requestTransform) {
1784
+ this.requestTransform = requestTransform;
1785
+ }
1786
+ if (withCredentials !== void 0) {
1787
+ this.withCredentials = withCredentials;
1788
+ }
1789
+ addConnector(this);
1790
+ }
1791
+ }
1792
+ /**
1793
+ * Clear the cache.
1794
+ */
1795
+ clearCache() {
1796
+ this.cache.clean();
1797
+ }
1798
+ setRequestTransform(requestTransform) {
1799
+ this.requestTransform = requestTransform;
1800
+ }
1801
+ /**
1802
+ * Fast way to specify the connection address to NextGIS Web.
1803
+ * The current connection will be severed.
1804
+ * @param baseUrl - NGW url
1805
+ */
1806
+ setNgw(baseUrl) {
1807
+ this.logout();
1808
+ this.options.baseUrl = baseUrl;
1809
+ addConnector(this);
1810
+ }
1811
+ /**
1812
+ * Establishing a connection with NextGIS Web to fulfill all other requests.
1813
+ * @remarks
1814
+ * This method need not be called manually as it is used when forming a request in {@link apiRequest | apiRequest}.
1815
+ * Can be used to check connection.
1816
+ * @example
1817
+ * ```javascript
1818
+ * const connector = new NgwConnector({ baseUrl: 'https://demo.nextgis.com' });
1819
+ * connector.connect()
1820
+ * .then(() => console.log('Ok'))
1821
+ * .catch((er) => console.log('Connection problem', er));
1822
+ * ```
1823
+ */
1824
+ connect() {
1825
+ return __async$t(this, null, function* () {
1826
+ const auth = this.options.auth;
1827
+ if (auth) {
1828
+ const { login, password } = auth;
1829
+ if (login && password) {
1830
+ yield this._login({ login, password });
1831
+ }
1832
+ }
1833
+ const routeUrl = `${this.routeStr}?client=${this.client}`;
1834
+ return yield this.makeQuery(
1835
+ routeUrl,
1836
+ {},
1837
+ {
1838
+ cacheName: "route",
1839
+ cache: true,
1840
+ cacheProps: {
1841
+ id: this.id,
1842
+ auth,
1843
+ baseUrl: this.options.baseUrl
1844
+ }
1845
+ }
1846
+ );
1847
+ });
1848
+ }
1849
+ /**
1850
+ * Quick way to change NextGIS Web user.
1851
+ * @param credentials - New user credentials
1852
+ */
1853
+ login(credentials, options) {
1854
+ this.logout();
1855
+ addConnector(this);
1856
+ return this._login(credentials, options);
1857
+ }
1858
+ /**
1859
+ * Disconnecting a user. Aborting all current requests
1860
+ */
1861
+ logout() {
1862
+ this.abort();
1863
+ removeConnector(this);
1864
+ this.options.auth = void 0;
1865
+ this.user = void 0;
1866
+ this.clearCache();
1867
+ this.emitter.emit("logout");
1868
+ }
1869
+ getUserInfo(credentials, options) {
1870
+ return __async$t(this, null, function* () {
1871
+ if (this.user && this.user.id) {
1872
+ return this.user;
1873
+ }
1874
+ if (credentials) {
1875
+ this.options.auth = credentials;
1876
+ }
1877
+ const options_ = __spreadValues$v({
1878
+ headers: this.getAuthorizationHeaders(credentials),
1879
+ cache: true
1880
+ }, options);
1881
+ return this.makeQuery(
1882
+ "/api/component/auth/current_user",
1883
+ {},
1884
+ options_
1885
+ );
1886
+ });
1887
+ }
1888
+ /**
1889
+ * Obtaining the required Headers for authentication of requests in the NGW.
1890
+ */
1891
+ getAuthorizationHeaders(credentials) {
1892
+ const client = this.makeClientId(credentials);
1893
+ if (client) {
1894
+ return {
1895
+ Authorization: `Basic ${client}`
1896
+ };
1897
+ }
1898
+ return {};
1899
+ }
1900
+ makeClientId(credentials) {
1901
+ credentials = credentials || this.options.auth;
1902
+ if (credentials) {
1903
+ const { login, password } = credentials;
1904
+ const encodedStr = [login, password].map(encodeURIComponent).join(":");
1905
+ {
1906
+ return window.btoa(encodedStr);
1907
+ }
1908
+ }
1909
+ }
1910
+ /** Stop all api requests */
1911
+ abort() {
1912
+ for (const abortController of Object.values(this.activeRequests)) {
1913
+ abortController.abort();
1914
+ }
1915
+ this.activeRequests = {};
1916
+ }
1917
+ getActiveApiRequests() {
1918
+ return __spreadValues$v({}, this.activeRequests);
1919
+ }
1920
+ route(name, ...rest) {
1921
+ return route(name, this, ...rest);
1922
+ }
1923
+ /**
1924
+ * Send request to NGW.
1925
+ * @param url - URL address to NGW
1926
+ * @param params - Query params
1927
+ * @param options - Request options
1928
+ */
1929
+ makeQuery(_0, _1) {
1930
+ return __async$t(this, arguments, function* (url, params, options = {}) {
1931
+ var _b;
1932
+ url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1933
+ if (!url) {
1934
+ throw new Error("Empty `url` not allowed");
1935
+ }
1936
+ if (params) {
1937
+ const _a = params, restParams = __objRest$3(_a, ["paramList"]);
1938
+ url = template(url, restParams);
1939
+ }
1940
+ url = encodeURI(fixUrlStr(url));
1941
+ options = __spreadValues$v({ withCredentials: this.withCredentials }, options);
1942
+ const {
1943
+ cache,
1944
+ signal: externalSignal,
1945
+ method = "GET",
1946
+ headers,
1947
+ cacheName,
1948
+ cacheProps,
1949
+ responseType,
1950
+ withCredentials
1951
+ } = options;
1952
+ const internalAbortController = new AbortController();
1953
+ const internalSignal = internalAbortController.signal;
1954
+ if (externalSignal) {
1955
+ if (externalSignal.aborted) {
1956
+ throw new AbortError();
1957
+ }
1958
+ externalSignal.addEventListener("abort", () => {
1959
+ internalAbortController.abort();
1960
+ });
1961
+ }
1962
+ options.signal = internalSignal;
1963
+ const createPromise = () => __async$t(this, null, function* () {
1964
+ const id = REQUEST_ID++;
1965
+ this.activeRequests[id] = internalAbortController;
1966
+ try {
1967
+ return this._loadData(url, options);
1968
+ } finally {
1969
+ this._cleanActiveRequest(id);
1970
+ }
1971
+ });
1972
+ if (method === "GET") {
1973
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$h(__spreadValues$v({}, objectRemoveEmpty({
1974
+ headers,
1975
+ withCredentials,
1976
+ responseType,
1977
+ baseUrl: this.options.baseUrl,
1978
+ userId: (_b = this.user) == null ? void 0 : _b.id
1979
+ })), {
1980
+ params
1981
+ });
1982
+ return this.cache.add(cacheName || url, createPromise, {
1983
+ props: cacheOptions,
1984
+ expirationTime: cache ? void 0 : 500
1985
+ });
1986
+ }
1987
+ return createPromise();
1988
+ });
1989
+ }
1990
+ _loadData(url, options) {
1991
+ options.responseType = options.responseType || "json";
1992
+ return new Promise((resolve, reject) => {
1993
+ var _a;
1994
+ if (this.user) {
1995
+ options = options || {};
1996
+ options.headers = __spreadValues$v(__spreadValues$v({}, this.getAuthorizationHeaders()), options.headers);
1997
+ }
1998
+ if (this.requestTransform) {
1999
+ const [transUrl, transOptions] = this.requestTransform(url, options);
2000
+ url = transUrl;
2001
+ options = transOptions;
2002
+ }
2003
+ let runOnAbort = void 0;
2004
+ loadData(url, resolve, options, reject, (handler) => {
2005
+ runOnAbort = handler;
2006
+ });
2007
+ (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
2008
+ if (runOnAbort !== void 0) {
2009
+ runOnAbort();
2010
+ }
2011
+ reject(new AbortError());
2012
+ });
2013
+ }).catch((httpError) => {
2014
+ if (httpError.name !== "AbortError") {
2015
+ {
2016
+ console.warn("DEV WARN", httpError);
2017
+ }
2018
+ const er = this._handleHttpError(httpError);
2019
+ if (er) {
2020
+ throw er;
2021
+ }
2022
+ }
2023
+ throw httpError;
2024
+ });
2025
+ }
2026
+ _login(credentials, options) {
2027
+ return __async$t(this, null, function* () {
2028
+ try {
2029
+ const data = yield this.getUserInfo(credentials, options);
2030
+ this.user = data;
2031
+ this.emitter.emit("login", data);
2032
+ return data;
2033
+ } catch (er) {
2034
+ this.emitter.emit("login:error", er);
2035
+ throw er;
2036
+ }
2037
+ });
2038
+ }
2039
+ _cleanActiveRequest(requestId) {
2040
+ delete this.activeRequests[requestId];
2041
+ }
2042
+ _handleHttpError(er) {
2043
+ if (er) {
2044
+ if (er instanceof NgwError) {
2045
+ if (er.exception === "nextgisweb.resource.exception.ResourceNotFound") {
2046
+ throw new ResourceNotFoundError(er);
2047
+ } else if (er.exception === "nextgisweb.core.exception.InsufficientPermissions") {
2048
+ throw new InsufficientPermissionsError(er);
2049
+ }
2050
+ }
2051
+ }
2052
+ return er;
2053
+ }
2054
+ }
2055
+ __publicField$s(NgwConnector, "errors", errors);
2056
+
2057
+ function resourceCompare(res1, res2) {
2058
+ return objectDeepEqual(res1, res2);
2059
+ }
2060
+
2061
+ const exclude = ["description"];
2062
+ function resourceToQuery(resource, prefix = "") {
2063
+ prefix = prefix ? prefix + "__" : "";
2064
+ const query = {};
2065
+ for (const [key, value] of Object.entries(resource)) {
2066
+ if (exclude.indexOf(key) === -1) {
2067
+ if (isObject(value)) {
2068
+ if (key === "owner_user") {
2069
+ const children = resourceToQuery(
2070
+ value,
2071
+ key
2072
+ );
2073
+ Object.assign(query, children);
2074
+ } else if (key === "parent" && "id" in value) {
2075
+ query.parent_id = value.id;
2076
+ }
2077
+ } else if (defined(value)) {
2078
+ query[prefix + key] = value;
2079
+ }
2080
+ }
2081
+ }
2082
+ return query;
2083
+ }
2084
+
2085
+ var __defProp$G = Object.defineProperty;
2086
+ var __defProps$g = Object.defineProperties;
2087
+ var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
2088
+ var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
2089
+ var __hasOwnProp$v = Object.prototype.hasOwnProperty;
2090
+ var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
2091
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2092
+ var __spreadValues$u = (a, b) => {
2093
+ for (var prop in b || (b = {}))
2094
+ if (__hasOwnProp$v.call(b, prop))
2095
+ __defNormalProp$G(a, prop, b[prop]);
2096
+ if (__getOwnPropSymbols$v)
2097
+ for (var prop of __getOwnPropSymbols$v(b)) {
2098
+ if (__propIsEnum$v.call(b, prop))
2099
+ __defNormalProp$G(a, prop, b[prop]);
2100
+ }
2101
+ return a;
2102
+ };
2103
+ var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
2104
+ var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
2105
+ var __async$s = (__this, __arguments, generator) => {
2106
+ return new Promise((resolve, reject) => {
2107
+ var fulfilled = (value) => {
2108
+ try {
2109
+ step(generator.next(value));
2110
+ } catch (e) {
2111
+ reject(e);
2112
+ }
2113
+ };
2114
+ var rejected = (value) => {
2115
+ try {
2116
+ step(generator.throw(value));
2117
+ } catch (e) {
2118
+ reject(e);
2119
+ }
2120
+ };
2121
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2122
+ step((generator = generator.apply(__this, __arguments)).next());
2123
+ });
2124
+ };
2125
+ class ResourcesControl {
2126
+ constructor({
2127
+ connector,
2128
+ cacheId
2129
+ }) {
2130
+ __publicField$r(this, "cache");
2131
+ __publicField$r(this, "connector");
2132
+ this.connector = connector;
2133
+ this.cache = new Cache({ namespace: cacheId });
2134
+ }
2135
+ // -------------------------------------------------------------------------
2136
+ // Resource Methods
2137
+ // -------------------------------------------------------------------------
2138
+ /**
2139
+ * Receive resource from NGW by id, keyname or search-object parameter.
2140
+ * @param resource - Resource id, keyname or search-object
2141
+ *
2142
+ * @remarks
2143
+ * Fetching resource would be cached to speed up next call
2144
+ */
2145
+ getOne(resource, requestOptions) {
2146
+ const opt = __spreadValues$u({}, requestOptions);
2147
+ if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
2148
+ if (resource.id !== void 0) {
2149
+ resource.id;
2150
+ } else {
2151
+ if (resource.keyname) {
2152
+ resource.keyname;
2153
+ }
2154
+ if (resource.display_name) {
2155
+ resource.display_name;
2156
+ }
2157
+ }
2158
+ }
2159
+ if (typeof resource === "string") {
2160
+ return this._fetchResourceBy({ keyname: resource }, opt);
2161
+ } else if (typeof resource === "number") {
2162
+ return this._fetchResourceById(resource, opt);
2163
+ } else if (isObject(resource)) {
2164
+ return this._fetchResourceBy(resource, opt);
2165
+ }
2166
+ return Promise.resolve(void 0);
2167
+ }
2168
+ getOneOrFail(resource, requestOptions) {
2169
+ return this.getOne(resource, requestOptions).then((res) => {
2170
+ if (res) {
2171
+ return res;
2172
+ }
2173
+ throw new ResourceNotFoundError();
2174
+ });
2175
+ }
2176
+ /**
2177
+ * A fast way to retrieve resource ID for any resource definition.
2178
+ * @param resource - Any available resource definition
2179
+ *
2180
+ * @remarks
2181
+ * There are situations when exactly the resource id is needed
2182
+ * (for example, to compose the correct request to the api)
2183
+ * then this method will come in handy to facilitate the extraction of the identifier
2184
+ * if the resource is specified through a keyname or other parameters.
2185
+ */
2186
+ getId(resource, requestOptions) {
2187
+ if (typeof resource === "number") {
2188
+ return Promise.resolve(resource);
2189
+ } else if (typeof resource === "string" || isObject(resource)) {
2190
+ return this.getOne(resource, requestOptions).then((res) => {
2191
+ if (res) {
2192
+ return res.resource.id;
2193
+ }
2194
+ });
2195
+ }
2196
+ return Promise.resolve(void 0);
2197
+ }
2198
+ /**
2199
+ * A fast way to retrieve resource ID for any resource definition.
2200
+ * @param resource - Any available resource definition
2201
+ *
2202
+ * @remarks
2203
+ * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
2204
+ * To not make one more checks if the resource is definitely exists
2205
+ */
2206
+ getIdOrFail(resource, requestOptions) {
2207
+ return this.getId(resource, requestOptions).then((resp) => {
2208
+ if (resp === void 0) {
2209
+ throw new Error();
2210
+ }
2211
+ return resp;
2212
+ });
2213
+ }
2214
+ getMany(resource, requestOptions) {
2215
+ return this._resourceCacheFilter(resource).then((items) => {
2216
+ if (!items.length) {
2217
+ const query = {};
2218
+ if (resource.keyname) {
2219
+ query.keyname = resource.keyname;
2220
+ } else {
2221
+ Object.assign(query, resourceToQuery(resource));
2222
+ }
2223
+ return this.connector.route("resource.search").get(__spreadProps$g(__spreadValues$u({}, requestOptions), {
2224
+ query: __spreadValues$u({
2225
+ serialization: "full"
2226
+ }, query)
2227
+ })).then((resources) => {
2228
+ if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
2229
+ for (const x of resources) {
2230
+ this.cache.add("resource.item", Promise.resolve(x), {
2231
+ id: x.resource.id
2232
+ });
2233
+ }
2234
+ }
2235
+ return resources;
2236
+ });
1151
2237
  }
1152
2238
  return items;
1153
2239
  });
1154
2240
  }
1155
2241
  getParent(resource, requestOptions) {
1156
2242
  return this.getOne(resource, requestOptions).then((child) => {
1157
- if (child) {
2243
+ var _a, _b;
2244
+ if ((_b = (_a = child == null ? void 0 : child.resource) == null ? void 0 : _a.parent) == null ? void 0 : _b.id) {
1158
2245
  return this.getOne(child.resource.parent.id, requestOptions);
1159
2246
  }
1160
2247
  return Promise.resolve(void 0);
@@ -1186,10 +2273,21 @@ var NgwMap = (function (exports) {
1186
2273
  }
1187
2274
  });
1188
2275
  }
1189
- _getChildrenOf(parent, requestOptions, _items = []) {
1190
- return this.connector.get("resource.collection", requestOptions, {
1191
- parent
1192
- }).then((items) => {
2276
+ _getChildrenOf(_0, _1) {
2277
+ return __async$s(this, arguments, function* (parentDef, requestOptions, _items = []) {
2278
+ let parent = void 0;
2279
+ if (typeof parentDef === "string") {
2280
+ parent = yield this.getId(parentDef, requestOptions);
2281
+ } else if (typeof parentDef === "object") {
2282
+ parent = parentDef.id;
2283
+ } else {
2284
+ parent = parentDef;
2285
+ }
2286
+ const items = yield this.connector.route("resource.collection").get(__spreadProps$g(__spreadValues$u({}, requestOptions), {
2287
+ query: {
2288
+ parent
2289
+ }
2290
+ }));
1193
2291
  const recursivePromises = [];
1194
2292
  for (const item of items) {
1195
2293
  if (requestOptions == null ? void 0 : requestOptions.cache) {
@@ -1238,7 +2336,7 @@ var NgwMap = (function (exports) {
1238
2336
  });
1239
2337
  }
1240
2338
  _fetchResourceById(id, requestOptions) {
1241
- return this.connector.get("resource.item", requestOptions, { id });
2339
+ return this.connector.route("resource.item", { id }).get(requestOptions);
1242
2340
  }
1243
2341
  _fetchResourceBy(resource, requestOptions) {
1244
2342
  return this.getMany(resource, requestOptions).then((resources) => {
@@ -1262,78 +2360,22 @@ var NgwMap = (function (exports) {
1262
2360
  });
1263
2361
  return items;
1264
2362
  }
1265
- );
1266
- }
1267
- }
1268
-
1269
- const CONNECTORS = [];
1270
- function addConnector(connector) {
1271
- CONNECTORS.push(connector);
1272
- }
1273
- function findConnector(options) {
1274
- return CONNECTORS.find((x) => {
1275
- if (x.options.baseUrl === options.baseUrl) {
1276
- if (options.auth) {
1277
- if (x.options.auth) {
1278
- return objectDeepEqual(x.options.auth, options.auth);
1279
- }
1280
- } else {
1281
- return true;
1282
- }
1283
- }
1284
- });
1285
- }
1286
- function removeConnector(connector) {
1287
- const index = CONNECTORS.indexOf(connector);
1288
- if (index !== -1) {
1289
- CONNECTORS.splice(index, 1);
1290
- }
1291
- }
1292
-
1293
- class AbortError extends Error {
1294
- constructor(message = "AbortError") {
1295
- super(message);
1296
- this.name = "AbortError";
1297
- }
1298
- }
1299
-
1300
- var __defProp$G = Object.defineProperty;
1301
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1302
- var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1303
- class InsufficientPermissionsError extends NgwError {
1304
- constructor(obj) {
1305
- super(obj);
1306
- __publicField$r(this, "name", "InsufficientPermissionsError");
1307
- __publicField$r(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
1308
- Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
1309
- }
1310
- }
1311
-
1312
- const templateRe = /\{ *([\w_-]+) *\}/g;
1313
- function template(str, data) {
1314
- return str.replace(templateRe, (s, key) => {
1315
- let value = data[key];
1316
- if (value === void 0) {
1317
- throw new Error("No value provided for letiable " + s);
1318
- } else if (typeof value === "function") {
1319
- value = value(data);
1320
- }
1321
- return value;
1322
- });
2363
+ );
2364
+ }
1323
2365
  }
1324
2366
 
1325
2367
  var __defProp$F = Object.defineProperty;
1326
- var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
1327
- var __hasOwnProp$v = Object.prototype.hasOwnProperty;
1328
- var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
2368
+ var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
2369
+ var __hasOwnProp$u = Object.prototype.hasOwnProperty;
2370
+ var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1329
2371
  var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1330
- var __spreadValues$u = (a, b) => {
2372
+ var __spreadValues$t = (a, b) => {
1331
2373
  for (var prop in b || (b = {}))
1332
- if (__hasOwnProp$v.call(b, prop))
2374
+ if (__hasOwnProp$u.call(b, prop))
1333
2375
  __defNormalProp$F(a, prop, b[prop]);
1334
- if (__getOwnPropSymbols$v)
1335
- for (var prop of __getOwnPropSymbols$v(b)) {
1336
- if (__propIsEnum$v.call(b, prop))
2376
+ if (__getOwnPropSymbols$u)
2377
+ for (var prop of __getOwnPropSymbols$u(b)) {
2378
+ if (__propIsEnum$u.call(b, prop))
1337
2379
  __defNormalProp$F(a, prop, b[prop]);
1338
2380
  }
1339
2381
  return a;
@@ -1379,343 +2421,57 @@ var NgwMap = (function (exports) {
1379
2421
  url = template(url, replaceParams);
1380
2422
  }
1381
2423
  }
1382
- if (params) {
1383
- const paramArray = [];
1384
- const paramList = params.paramList;
1385
- if (Array.isArray(paramList)) {
1386
- paramList.forEach(([key, value]) => {
1387
- paramArray.push(`${key}=${value}`);
1388
- });
1389
- }
1390
- for (const p in params) {
1391
- if (apiItem.indexOf(p) === -1) {
1392
- paramArray.push(`${p}=${params[p]}`);
1393
- }
1394
- }
1395
- if (paramArray.length) {
1396
- url = `${url}?${paramArray.join("&")}`;
1397
- }
1398
- }
1399
- if (url) {
1400
- return connector.makeQuery(url, params, __spreadValues$u({
1401
- cacheName: name
1402
- }, requestOptions));
1403
- } else {
1404
- throw new Error("Request URL is not set");
1405
- }
1406
- } else {
1407
- return void 0;
1408
- }
1409
- });
1410
- }
1411
-
1412
- var __defProp$E = Object.defineProperty;
1413
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1414
- var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
1415
- class NetworkError extends Error {
1416
- constructor(url) {
1417
- super();
1418
- __publicField$q(this, "name", "NetworkError");
1419
- Object.setPrototypeOf(this, NetworkError.prototype);
1420
- this.message = `Unable to request ${url}.
1421
- Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
1422
- }
1423
- }
1424
-
1425
- let loadData;
1426
- {
1427
- loadData = (url, callback, options = {}, error, onCancel) => {
1428
- options.method = options.method || "GET";
1429
- const xhr = new XMLHttpRequest();
1430
- xhr.open(options.method || "GET", url, true);
1431
- if (options.responseType === "blob") {
1432
- xhr.responseType = options.responseType;
1433
- }
1434
- const getResponseText = () => {
1435
- try {
1436
- return JSON.parse(xhr.responseText);
1437
- } catch (er) {
1438
- return xhr.responseText;
1439
- }
1440
- };
1441
- const processingResponse = (forError = false) => {
1442
- const cb = forError ? error : callback;
1443
- if (options.responseType === "blob") {
1444
- cb(xhr.response);
1445
- } else {
1446
- if (xhr.responseText) {
1447
- cb(getResponseText());
1448
- } else {
1449
- error({ message: "" });
1450
- }
1451
- }
1452
- };
1453
- xhr.onload = () => {
1454
- if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
1455
- error(new NgwError(getResponseText()));
1456
- }
1457
- processingResponse();
1458
- };
1459
- xhr.onerror = (er) => {
1460
- if (xhr.status === 0) {
1461
- error(new NetworkError(url));
1462
- } else {
1463
- error(er);
1464
- }
1465
- };
1466
- xhr.upload.onprogress = function(e) {
1467
- if (e.lengthComputable) {
1468
- const percentComplete = e.loaded / e.total * 100;
1469
- if (options.onProgress) {
1470
- options.onProgress(percentComplete, e);
1471
- }
1472
- }
1473
- };
1474
- const headers = options.headers;
1475
- if (headers) {
1476
- for (const h in headers) {
1477
- const header = headers[h];
1478
- if (typeof header === "string") {
1479
- xhr.setRequestHeader(h, header);
1480
- }
1481
- }
1482
- }
1483
- if (options.withCredentials !== void 0) {
1484
- xhr.withCredentials = options.withCredentials;
1485
- }
1486
- let data;
1487
- if (options.file) {
1488
- data = new FormData();
1489
- data.append("file", options.file);
1490
- if (options.data) {
1491
- for (const d in options.data) {
1492
- data.append(d, data[d]);
1493
- }
1494
- }
1495
- } else {
1496
- data = options.data ? typeof options.data === "string" ? options.data : JSON.stringify(options.data) : null;
1497
- }
1498
- if (onCancel) {
1499
- onCancel(() => {
1500
- xhr.abort();
1501
- });
1502
- }
1503
- xhr.send(data);
1504
- };
1505
- }
1506
-
1507
- var __defProp$D = Object.defineProperty;
1508
- var __defProps$d = Object.defineProperties;
1509
- var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
1510
- var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1511
- var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1512
- var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1513
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1514
- var __spreadValues$t = (a, b) => {
1515
- for (var prop in b || (b = {}))
1516
- if (__hasOwnProp$u.call(b, prop))
1517
- __defNormalProp$D(a, prop, b[prop]);
1518
- if (__getOwnPropSymbols$u)
1519
- for (var prop of __getOwnPropSymbols$u(b)) {
1520
- if (__propIsEnum$u.call(b, prop))
1521
- __defNormalProp$D(a, prop, b[prop]);
1522
- }
1523
- return a;
1524
- };
1525
- var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
1526
- var __objRest$2 = (source, exclude) => {
1527
- var target = {};
1528
- for (var prop in source)
1529
- if (__hasOwnProp$u.call(source, prop) && exclude.indexOf(prop) < 0)
1530
- target[prop] = source[prop];
1531
- if (source != null && __getOwnPropSymbols$u)
1532
- for (var prop of __getOwnPropSymbols$u(source)) {
1533
- if (exclude.indexOf(prop) < 0 && __propIsEnum$u.call(source, prop))
1534
- target[prop] = source[prop];
1535
- }
1536
- return target;
1537
- };
1538
- var __publicField$p = (obj, key, value) => __defNormalProp$D(obj, typeof key !== "symbol" ? key + "" : key, value);
1539
- var __async$q = (__this, __arguments, generator) => {
1540
- return new Promise((resolve, reject) => {
1541
- var fulfilled = (value) => {
1542
- try {
1543
- step(generator.next(value));
1544
- } catch (e) {
1545
- reject(e);
1546
- }
1547
- };
1548
- var rejected = (value) => {
1549
- try {
1550
- step(generator.throw(value));
1551
- } catch (e) {
1552
- reject(e);
1553
- }
1554
- };
1555
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1556
- step((generator = generator.apply(__this, __arguments)).next());
1557
- });
1558
- };
1559
- let ID$2 = 0;
1560
- let REQUEST_ID = 0;
1561
- class NgwConnector {
1562
- constructor(options) {
1563
- this.options = options;
1564
- __publicField$p(this, "id", ID$2++);
1565
- __publicField$p(this, "emitter", new EventEmitter());
1566
- __publicField$p(this, "user");
1567
- __publicField$p(this, "resources");
1568
- __publicField$p(this, "cache");
1569
- __publicField$p(this, "routeStr", "/api/component/pyramid/route");
1570
- __publicField$p(this, "activeRequests", {});
1571
- __publicField$p(this, "requestTransform");
1572
- const exist = findConnector(options);
1573
- this.cache = new Cache({ namespace: options.cacheId });
1574
- if (exist) {
1575
- return exist;
1576
- } else {
1577
- if (this.options.route) {
1578
- this.routeStr = this.options.route;
1579
- }
1580
- if (this.options.requestTransform) {
1581
- this.requestTransform = this.options.requestTransform;
1582
- }
1583
- this.resources = new ResourcesControl({
1584
- connector: this,
1585
- cacheId: options.cacheId
1586
- });
1587
- addConnector(this);
1588
- }
1589
- }
1590
- static create(options) {
1591
- return new this(options);
1592
- }
1593
- /**
1594
- * Clear the cache.
1595
- */
1596
- clearCache() {
1597
- this.cache.clean();
1598
- this.resources.cache.clean();
1599
- }
1600
- setRequestTransform(requestTransform) {
1601
- this.requestTransform = requestTransform;
1602
- }
1603
- /**
1604
- * Fast way to specify the connection address to NextGIS Web.
1605
- * The current connection will be severed.
1606
- * @param baseUrl - NGW url
1607
- */
1608
- setNgw(baseUrl) {
1609
- this.logout();
1610
- this.options.baseUrl = baseUrl;
1611
- addConnector(this);
1612
- }
1613
- /**
1614
- * Establishing a connection with NextGIS Web to fulfill all other requests.
1615
- * @remarks
1616
- * This method need not be called manually as it is used when forming a request in {@link apiRequest | apiRequest}.
1617
- * Can be used to check connection.
1618
- * @example
1619
- * ```javascript
1620
- * const connector = new NgwConnector({baseUrl: 'https://demo.nextgis.com'});
1621
- * connector.connect()
1622
- * .then(() => console.log('Ok'))
1623
- * .catch((er) => console.log('Connection problem', er));
1624
- * ```
1625
- */
1626
- connect() {
1627
- return __async$q(this, null, function* () {
1628
- const auth = this.options.auth;
1629
- if (auth) {
1630
- const { login, password } = auth;
1631
- if (login && password) {
1632
- yield this._login({ login, password });
1633
- }
1634
- }
1635
- return yield this.makeQuery(
1636
- this.routeStr,
1637
- {},
1638
- {
1639
- cacheName: "route",
1640
- cache: true,
1641
- cacheProps: {
1642
- id: this.id,
1643
- auth,
1644
- baseUrl: this.options.baseUrl
2424
+ if (params) {
2425
+ const paramArray = [];
2426
+ const paramList = params.paramList;
2427
+ if (Array.isArray(paramList)) {
2428
+ paramList.forEach(([key, value]) => {
2429
+ paramArray.push(`${key}=${value}`);
2430
+ });
2431
+ }
2432
+ for (const p in params) {
2433
+ if (apiItem.indexOf(p) === -1) {
2434
+ paramArray.push(`${p}=${params[p]}`);
1645
2435
  }
1646
2436
  }
1647
- );
1648
- });
1649
- }
1650
- /**
1651
- * Quick way to change NextGIS Web user.
1652
- * @param credentials - New user credentials
1653
- */
1654
- login(credentials, options) {
1655
- this.logout();
1656
- addConnector(this);
1657
- return this._login(credentials, options);
1658
- }
1659
- /**
1660
- * Disconnecting a user. Aborting all current requests
1661
- */
1662
- logout() {
1663
- this.abort();
1664
- removeConnector(this);
1665
- this.options.auth = void 0;
1666
- this.user = void 0;
1667
- this.clearCache();
1668
- this.emitter.emit("logout");
1669
- }
1670
- getUserInfo(credentials, options) {
1671
- return __async$q(this, null, function* () {
1672
- if (this.user && this.user.id) {
1673
- return this.user;
2437
+ if (paramArray.length) {
2438
+ url = `${url}?${paramArray.join("&")}`;
2439
+ }
1674
2440
  }
1675
- if (credentials) {
1676
- this.options.auth = credentials;
2441
+ if (url) {
2442
+ return connector.makeQuery(url, params, __spreadValues$t({
2443
+ cacheName: name
2444
+ }, requestOptions));
2445
+ } else {
2446
+ throw new Error("Request URL is not set");
1677
2447
  }
1678
- const options_ = __spreadValues$t({
1679
- headers: this.getAuthorizationHeaders(credentials)
1680
- }, options);
1681
- return this.makeQuery(
1682
- "/api/component/auth/current_user",
1683
- {},
1684
- options_
1685
- );
2448
+ } else {
2449
+ return void 0;
2450
+ }
2451
+ });
2452
+ }
2453
+
2454
+ var __defProp$E = Object.defineProperty;
2455
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2456
+ var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
2457
+ class NgwConnectorExtended extends NgwConnector {
2458
+ constructor(options) {
2459
+ super(options);
2460
+ __publicField$q(this, "resources");
2461
+ this.resources = new ResourcesControl({
2462
+ connector: this,
2463
+ cacheId: options.cacheId
1686
2464
  });
1687
2465
  }
2466
+ static create(options) {
2467
+ return new this(options);
2468
+ }
1688
2469
  /**
1689
- * Obtaining the required Headers for authentication of requests in the NGW.
2470
+ * Clear the cache.
1690
2471
  */
1691
- getAuthorizationHeaders(credentials) {
1692
- const client = this.makeClientId(credentials);
1693
- if (client) {
1694
- return {
1695
- Authorization: `Basic ${client}`
1696
- };
1697
- }
1698
- }
1699
- makeClientId(credentials) {
1700
- credentials = credentials || this.options.auth;
1701
- if (credentials) {
1702
- const { login, password } = credentials;
1703
- const str = `${login}:${password}`;
1704
- const encodedStr = encodeURIComponent(str);
1705
- {
1706
- return window.btoa(encodedStr);
1707
- }
1708
- }
1709
- }
1710
- /** Stop all api requests */
1711
- abort() {
1712
- for (const abortController of Object.values(this.activeRequests)) {
1713
- abortController.abort();
1714
- }
1715
- this.activeRequests = {};
1716
- }
1717
- getActiveApiRequests() {
1718
- return __spreadValues$t({}, this.activeRequests);
2472
+ clearCache() {
2473
+ super.clearCache();
2474
+ this.resources.cache.clean();
1719
2475
  }
1720
2476
  /**
1721
2477
  * Send request to NGW api router.
@@ -1834,74 +2590,6 @@ var NgwMap = (function (exports) {
1834
2590
  options
1835
2591
  );
1836
2592
  }
1837
- /**
1838
- * Send request to NGW.
1839
- * @param url - URL address to NGW
1840
- * @param params - Query params
1841
- * @param options - Request options
1842
- */
1843
- makeQuery(_0, _1) {
1844
- return __async$q(this, arguments, function* (url, params, options = {}) {
1845
- var _b;
1846
- url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1847
- if (!url) {
1848
- throw new Error("Empty `url` not allowed");
1849
- }
1850
- if (params) {
1851
- const _a = params, restParams = __objRest$2(_a, ["paramList"]);
1852
- url = template(url, restParams);
1853
- }
1854
- url = encodeURI(fixUrlStr(url));
1855
- const {
1856
- cache,
1857
- signal: externalSignal,
1858
- method = "GET",
1859
- headers,
1860
- cacheName,
1861
- cacheProps,
1862
- responseType,
1863
- withCredentials
1864
- } = options;
1865
- const internalAbortController = new AbortController();
1866
- const internalSignal = internalAbortController.signal;
1867
- if (externalSignal) {
1868
- if (externalSignal.aborted) {
1869
- throw new AbortError();
1870
- }
1871
- externalSignal.addEventListener("abort", () => {
1872
- internalAbortController.abort();
1873
- });
1874
- }
1875
- options.signal = internalSignal;
1876
- const createPromise = () => __async$q(this, null, function* () {
1877
- const id = REQUEST_ID++;
1878
- this.activeRequests[id] = internalAbortController;
1879
- try {
1880
- return this._loadData(url, options);
1881
- } finally {
1882
- this._cleanActiveRequest(id);
1883
- }
1884
- });
1885
- if (cache && method === "GET") {
1886
- const cacheOptions = cacheProps ? cacheProps : __spreadProps$d(__spreadValues$t({}, objectRemoveEmpty({
1887
- headers,
1888
- withCredentials,
1889
- responseType,
1890
- baseUrl: this.options.baseUrl,
1891
- userId: (_b = this.user) == null ? void 0 : _b.id
1892
- })), {
1893
- params
1894
- });
1895
- return this.cache.add(
1896
- cacheName || url,
1897
- createPromise,
1898
- cacheOptions,
1899
- false
1900
- );
1901
- }
1902
- return createPromise();
1903
- });
1904
- }
1905
2593
  // -------------------------------------------------------------------------
1906
2594
  // Resource Methods
1907
2595
  // -------------------------------------------------------------------------
@@ -1977,92 +2665,21 @@ var NgwMap = (function (exports) {
1977
2665
  deleteResource(resource) {
1978
2666
  return this.resources.delete(resource);
1979
2667
  }
1980
- /**
1981
- * @internal
1982
- */
1983
- _loadData(url, options) {
1984
- options.responseType = options.responseType || "json";
1985
- return new Promise((resolve, reject) => {
1986
- var _a;
1987
- if (this.user) {
1988
- options = options || {};
1989
- options.headers = __spreadValues$t(__spreadValues$t({}, this.getAuthorizationHeaders()), options.headers);
1990
- }
1991
- if (this.requestTransform) {
1992
- const [transUrl, transOptions] = this.requestTransform(url, options);
1993
- url = transUrl;
1994
- options = transOptions;
1995
- }
1996
- let runOnAbort = void 0;
1997
- loadData(url, resolve, options, reject, (handler) => {
1998
- runOnAbort = handler;
1999
- });
2000
- (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
2001
- if (runOnAbort !== void 0) {
2002
- runOnAbort();
2003
- }
2004
- reject(new AbortError());
2005
- });
2006
- }).catch((httpError) => {
2007
- if (httpError.name !== "AbortError") {
2008
- {
2009
- console.warn("DEV WARN", httpError);
2010
- }
2011
- const er = this._handleHttpError(httpError);
2012
- if (er) {
2013
- throw er;
2014
- }
2015
- }
2016
- throw httpError;
2017
- });
2018
- }
2019
- _login(credentials, options) {
2020
- return __async$q(this, null, function* () {
2021
- try {
2022
- const data = yield this.getUserInfo(credentials, options);
2023
- this.user = data;
2024
- this.emitter.emit("login", data);
2025
- return data;
2026
- } catch (er) {
2027
- this.emitter.emit("login:error", er);
2028
- throw er;
2029
- }
2030
- });
2031
- }
2032
- _cleanActiveRequest(requestId) {
2033
- delete this.activeRequests[requestId];
2034
- }
2035
- _handleHttpError(er) {
2036
- if (er) {
2037
- if (er instanceof NgwError) {
2038
- if (er.exception === "nextgisweb.resource.exception.ResourceNotFound") {
2039
- throw new ResourceNotFoundError(er);
2040
- } else if (er.exception === "nextgisweb.core.exception.InsufficientPermissions") {
2041
- throw new InsufficientPermissionsError(er);
2042
- }
2043
- }
2044
- }
2045
- return er;
2046
- }
2047
2668
  }
2048
- __publicField$p(NgwConnector, "errors", {
2049
- NgwError,
2050
- ResourceNotFoundError
2051
- });
2052
2669
 
2053
- var __defProp$C = Object.defineProperty;
2670
+ var __defProp$D = Object.defineProperty;
2054
2671
  var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
2055
2672
  var __hasOwnProp$t = Object.prototype.hasOwnProperty;
2056
2673
  var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
2057
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2674
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2058
2675
  var __spreadValues$s = (a, b) => {
2059
2676
  for (var prop in b || (b = {}))
2060
2677
  if (__hasOwnProp$t.call(b, prop))
2061
- __defNormalProp$C(a, prop, b[prop]);
2678
+ __defNormalProp$D(a, prop, b[prop]);
2062
2679
  if (__getOwnPropSymbols$t)
2063
2680
  for (var prop of __getOwnPropSymbols$t(b)) {
2064
2681
  if (__propIsEnum$t.call(b, prop))
2065
- __defNormalProp$C(a, prop, b[prop]);
2682
+ __defNormalProp$D(a, prop, b[prop]);
2066
2683
  }
2067
2684
  return a;
2068
2685
  };
@@ -2144,26 +2761,30 @@ var NgwMap = (function (exports) {
2144
2761
  return logic === "any" ? filters_.some(filterFunction) : filters_.every(filterFunction);
2145
2762
  }
2146
2763
 
2147
- var __defProp$B = Object.defineProperty;
2148
- var __defProps$c = Object.defineProperties;
2149
- var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
2764
+ const config = {
2765
+ defaultRequestLimit: 7e3
2766
+ };
2767
+
2768
+ var __defProp$C = Object.defineProperty;
2769
+ var __defProps$f = Object.defineProperties;
2770
+ var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
2150
2771
  var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2151
2772
  var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2152
2773
  var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2153
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2774
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2154
2775
  var __spreadValues$r = (a, b) => {
2155
2776
  for (var prop in b || (b = {}))
2156
2777
  if (__hasOwnProp$s.call(b, prop))
2157
- __defNormalProp$B(a, prop, b[prop]);
2778
+ __defNormalProp$C(a, prop, b[prop]);
2158
2779
  if (__getOwnPropSymbols$s)
2159
2780
  for (var prop of __getOwnPropSymbols$s(b)) {
2160
2781
  if (__propIsEnum$s.call(b, prop))
2161
- __defNormalProp$B(a, prop, b[prop]);
2782
+ __defNormalProp$C(a, prop, b[prop]);
2162
2783
  }
2163
2784
  return a;
2164
2785
  };
2165
- var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
2166
- var __async$p = (__this, __arguments, generator) => {
2786
+ var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
2787
+ var __async$q = (__this, __arguments, generator) => {
2167
2788
  return new Promise((resolve, reject) => {
2168
2789
  var fulfilled = (value) => {
2169
2790
  try {
@@ -2199,15 +2820,12 @@ var NgwMap = (function (exports) {
2199
2820
  }
2200
2821
  function updateItemRequestParam(params, options) {
2201
2822
  const { extensions, geom, fields, srs, ilike, like } = options;
2202
- const extensionsStr = extensions ? extensions.join(",") : "";
2203
- if (extensionsStr !== "*") {
2204
- params.extensions = extensionsStr;
2205
- }
2206
- if (fields !== void 0) {
2207
- params.fields = Array.isArray(fields) ? fields.join(",") : "";
2823
+ params.extensions = extensions ? extensions : [];
2824
+ if (fields) {
2825
+ params.fields = fields;
2208
2826
  }
2209
2827
  if (geom !== void 0) {
2210
- params.geom = geom ? "yes" : "no";
2828
+ params.geom = geom;
2211
2829
  if (!geom) {
2212
2830
  delete params.srs;
2213
2831
  delete params.geom_format;
@@ -2222,8 +2840,17 @@ var NgwMap = (function (exports) {
2222
2840
  params.srs = srs;
2223
2841
  }
2224
2842
  }
2843
+ function paramListToQuery(paramList) {
2844
+ return paramList.reduce(
2845
+ (acc, [key, value]) => {
2846
+ acc[key] = value;
2847
+ return acc;
2848
+ },
2849
+ {}
2850
+ );
2851
+ }
2225
2852
  function createFeatureFieldFilterQueries(opt) {
2226
- return __async$p(this, null, function* () {
2853
+ return __async$q(this, null, function* () {
2227
2854
  const queries = getQueries(opt);
2228
2855
  const itemsParts = yield Promise.all(queries);
2229
2856
  const ids = [];
@@ -2267,13 +2894,13 @@ var NgwMap = (function (exports) {
2267
2894
  for (const f of filters_) {
2268
2895
  if (isPropertyFilter(f)) {
2269
2896
  _queries.push(
2270
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2897
+ fetchNgwLayerItemsRequest(__spreadProps$f(__spreadValues$r({}, opt), {
2271
2898
  paramList: [..._parentAllParams, ...paramList, createParam(f)]
2272
2899
  }))
2273
2900
  );
2274
2901
  } else {
2275
2902
  getQueries(
2276
- __spreadProps$c(__spreadValues$r({}, opt), {
2903
+ __spreadProps$f(__spreadValues$r({}, opt), {
2277
2904
  filters: f
2278
2905
  }),
2279
2906
  _queries,
@@ -2294,7 +2921,7 @@ var NgwMap = (function (exports) {
2294
2921
  if (propertiesFilterList.length) {
2295
2922
  for (const x of propertiesFilterList) {
2296
2923
  getQueries(
2297
- __spreadProps$c(__spreadValues$r({}, opt), {
2924
+ __spreadProps$f(__spreadValues$r({}, opt), {
2298
2925
  filters: x
2299
2926
  }),
2300
2927
  _queries,
@@ -2303,7 +2930,7 @@ var NgwMap = (function (exports) {
2303
2930
  }
2304
2931
  } else {
2305
2932
  _queries.push(
2306
- fetchNgwLayerItemsRequest(__spreadProps$c(__spreadValues$r({}, opt), {
2933
+ fetchNgwLayerItemsRequest(__spreadProps$f(__spreadValues$r({}, opt), {
2307
2934
  paramList: [..._parentAllParams, ...paramList, ...filters2]
2308
2935
  }))
2309
2936
  );
@@ -2322,6 +2949,7 @@ var NgwMap = (function (exports) {
2322
2949
  const params = __spreadValues$r({}, FEATURE_REQUEST_PARAMS);
2323
2950
  const {
2324
2951
  limit,
2952
+ query,
2325
2953
  cache,
2326
2954
  signal,
2327
2955
  offset,
@@ -2332,12 +2960,10 @@ var NgwMap = (function (exports) {
2332
2960
  intersects,
2333
2961
  resourceId
2334
2962
  } = options;
2335
- if (limit) {
2336
- if (limit !== Number.POSITIVE_INFINITY) {
2337
- params.limit = limit;
2338
- }
2963
+ if (limit && limit !== Number.POSITIVE_INFINITY) {
2964
+ params.limit = limit;
2339
2965
  } else {
2340
- params.limit = 7e3;
2966
+ params.limit = config.defaultRequestLimit;
2341
2967
  }
2342
2968
  if (offset) {
2343
2969
  params.offset = offset;
@@ -2356,38 +2982,31 @@ var NgwMap = (function (exports) {
2356
2982
  params.intersects = intersects;
2357
2983
  }
2358
2984
  if (paramList) {
2359
- params.paramList = paramList;
2985
+ Object.assign(params, paramListToQuery(paramList));
2360
2986
  }
2361
- const reqParams = __spreadValues$r({
2362
- id: resourceId
2363
- }, params);
2364
- return connector.get(
2365
- "feature_layer.feature.collection",
2366
- { cache, signal },
2367
- reqParams
2368
- );
2987
+ return connector.route("feature_layer.feature.collection", { id: Number(resourceId) }).get({ query: __spreadValues$r(__spreadValues$r({}, params), query), cache, signal });
2369
2988
  }
2370
2989
 
2371
- var __defProp$A = Object.defineProperty;
2372
- var __defProps$b = Object.defineProperties;
2373
- var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
2990
+ var __defProp$B = Object.defineProperty;
2991
+ var __defProps$e = Object.defineProperties;
2992
+ var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
2374
2993
  var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2375
2994
  var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2376
2995
  var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2377
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2996
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2378
2997
  var __spreadValues$q = (a, b) => {
2379
2998
  for (var prop in b || (b = {}))
2380
2999
  if (__hasOwnProp$r.call(b, prop))
2381
- __defNormalProp$A(a, prop, b[prop]);
3000
+ __defNormalProp$B(a, prop, b[prop]);
2382
3001
  if (__getOwnPropSymbols$r)
2383
3002
  for (var prop of __getOwnPropSymbols$r(b)) {
2384
3003
  if (__propIsEnum$r.call(b, prop))
2385
- __defNormalProp$A(a, prop, b[prop]);
3004
+ __defNormalProp$B(a, prop, b[prop]);
2386
3005
  }
2387
3006
  return a;
2388
3007
  };
2389
- var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
2390
- var __async$o = (__this, __arguments, generator) => {
3008
+ var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
3009
+ var __async$p = (__this, __arguments, generator) => {
2391
3010
  return new Promise((resolve, reject) => {
2392
3011
  var fulfilled = (value) => {
2393
3012
  try {
@@ -2408,61 +3027,56 @@ var NgwMap = (function (exports) {
2408
3027
  });
2409
3028
  };
2410
3029
  function fetchNgwLayerItem(options) {
2411
- return __async$o(this, null, function* () {
3030
+ return __async$p(this, null, function* () {
2412
3031
  const params = __spreadValues$q({}, FEATURE_REQUEST_PARAMS);
2413
3032
  updateItemRequestParam(params, options);
2414
- const queryParams = __spreadValues$q({
2415
- id: options.resourceId,
3033
+ const resp = yield options.connector.route("feature_layer.feature.item", {
3034
+ id: Number(options.resourceId),
2416
3035
  fid: options.featureId
2417
- }, params);
2418
- const resp = yield options.connector.get(
2419
- "feature_layer.feature.item",
2420
- options,
2421
- queryParams
2422
- );
2423
- const toGeojson = () => __async$o(this, null, function* () {
3036
+ }).get(__spreadProps$e(__spreadValues$q({}, options), { query: params }));
3037
+ const toGeojson = () => __async$p(this, null, function* () {
2424
3038
  if (resp.geom) {
2425
3039
  return createGeoJsonFeature(resp);
2426
3040
  } else {
2427
- const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$b(__spreadValues$q({}, options), {
3041
+ const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$e(__spreadValues$q({}, options), {
2428
3042
  geom: true,
2429
3043
  fields: null,
2430
3044
  extensions: null
2431
3045
  }));
2432
3046
  const geom = onlyGeomItem.geom;
2433
- return createGeoJsonFeature(__spreadProps$b(__spreadValues$q({}, resp), { geom }));
3047
+ return createGeoJsonFeature(__spreadProps$e(__spreadValues$q({}, resp), { geom }));
2434
3048
  }
2435
3049
  });
2436
- return __spreadProps$b(__spreadValues$q({}, resp), {
3050
+ return __spreadProps$e(__spreadValues$q({}, resp), {
2437
3051
  toGeojson
2438
3052
  });
2439
3053
  });
2440
3054
  }
2441
3055
 
2442
- var __defProp$z = Object.defineProperty;
3056
+ var __defProp$A = Object.defineProperty;
2443
3057
  var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2444
3058
  var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2445
3059
  var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2446
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3060
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2447
3061
  var __spreadValues$p = (a, b) => {
2448
3062
  for (var prop in b || (b = {}))
2449
3063
  if (__hasOwnProp$q.call(b, prop))
2450
- __defNormalProp$z(a, prop, b[prop]);
3064
+ __defNormalProp$A(a, prop, b[prop]);
2451
3065
  if (__getOwnPropSymbols$q)
2452
3066
  for (var prop of __getOwnPropSymbols$q(b)) {
2453
3067
  if (__propIsEnum$q.call(b, prop))
2454
- __defNormalProp$z(a, prop, b[prop]);
3068
+ __defNormalProp$A(a, prop, b[prop]);
2455
3069
  }
2456
3070
  return a;
2457
3071
  };
2458
- var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
3072
+ var __publicField$p = (obj, key, value) => __defNormalProp$A(obj, typeof key !== "symbol" ? key + "" : key, value);
2459
3073
  class BookmarkItem {
2460
3074
  constructor(options) {
2461
3075
  this.options = options;
2462
- __publicField$o(this, "name");
2463
- __publicField$o(this, "resourceId");
2464
- __publicField$o(this, "item");
2465
- __publicField$o(this, "_extent");
3076
+ __publicField$p(this, "name");
3077
+ __publicField$p(this, "resourceId");
3078
+ __publicField$p(this, "item");
3079
+ __publicField$p(this, "_extent");
2466
3080
  this.resourceId = options.resourceId;
2467
3081
  const item = options.item;
2468
3082
  this.item = item;
@@ -2476,10 +3090,10 @@ var NgwMap = (function (exports) {
2476
3090
  if (this._extent) {
2477
3091
  return Promise.resolve(this._extent);
2478
3092
  }
2479
- return this.options.connector.get("feature_layer.feature.item_extent", opt, {
3093
+ return this.options.connector.route("feature_layer.feature.item_extent", {
2480
3094
  id: this.resourceId,
2481
3095
  fid: this.item.id
2482
- }).then((resp) => {
3096
+ }).get(opt).then((resp) => {
2483
3097
  const { minLat, minLon, maxLat, maxLon } = resp.extent;
2484
3098
  const lonLat = [minLon, minLat, maxLon, maxLat];
2485
3099
  this._extent = lonLat;
@@ -2608,14 +3222,14 @@ var NgwMap = (function (exports) {
2608
3222
  return true;
2609
3223
  }
2610
3224
 
2611
- var __defProp$y = Object.defineProperty;
2612
- var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2613
- var __publicField$n = (obj, key, value) => __defNormalProp$y(obj, typeof key !== "symbol" ? key + "" : key, value);
3225
+ var __defProp$z = Object.defineProperty;
3226
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3227
+ var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2614
3228
  class TreeHelper {
2615
3229
  constructor(item) {
2616
- __publicField$n(this, "item");
2617
- __publicField$n(this, "_children", []);
2618
- __publicField$n(this, "_parent");
3230
+ __publicField$o(this, "item");
3231
+ __publicField$o(this, "_children", []);
3232
+ __publicField$o(this, "_parent");
2619
3233
  this.item = item;
2620
3234
  }
2621
3235
  setParent(parent) {
@@ -2678,19 +3292,19 @@ var NgwMap = (function (exports) {
2678
3292
  }
2679
3293
  }
2680
3294
 
2681
- var __defProp$x = Object.defineProperty;
2682
- var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2683
- var __publicField$m = (obj, key, value) => __defNormalProp$x(obj, typeof key !== "symbol" ? key + "" : key, value);
3295
+ var __defProp$y = Object.defineProperty;
3296
+ var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3297
+ var __publicField$n = (obj, key, value) => __defNormalProp$y(obj, typeof key !== "symbol" ? key + "" : key, value);
2684
3298
  class BaseProperty {
2685
3299
  constructor(name, item, options) {
2686
- __publicField$m(this, "options");
2687
- __publicField$m(this, "emitter", new EventEmitter());
2688
- __publicField$m(this, "name");
2689
- __publicField$m(this, "item");
2690
- __publicField$m(this, "_blocked", false);
2691
- __publicField$m(this, "_container");
2692
- __publicField$m(this, "_value");
2693
- __publicField$m(this, "_removeEventsListener");
3300
+ __publicField$n(this, "options");
3301
+ __publicField$n(this, "emitter", new EventEmitter());
3302
+ __publicField$n(this, "name");
3303
+ __publicField$n(this, "item");
3304
+ __publicField$n(this, "_blocked", false);
3305
+ __publicField$n(this, "_container");
3306
+ __publicField$n(this, "_value");
3307
+ __publicField$n(this, "_removeEventsListener");
2694
3308
  this.item = item;
2695
3309
  this.options = Object.assign({}, options);
2696
3310
  this.name = name;
@@ -2787,23 +3401,23 @@ var NgwMap = (function (exports) {
2787
3401
  }
2788
3402
  }
2789
3403
 
2790
- var __defProp$w = Object.defineProperty;
3404
+ var __defProp$x = Object.defineProperty;
2791
3405
  var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
2792
3406
  var __hasOwnProp$p = Object.prototype.hasOwnProperty;
2793
3407
  var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
2794
- var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3408
+ var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2795
3409
  var __spreadValues$o = (a, b) => {
2796
3410
  for (var prop in b || (b = {}))
2797
3411
  if (__hasOwnProp$p.call(b, prop))
2798
- __defNormalProp$w(a, prop, b[prop]);
3412
+ __defNormalProp$x(a, prop, b[prop]);
2799
3413
  if (__getOwnPropSymbols$p)
2800
3414
  for (var prop of __getOwnPropSymbols$p(b)) {
2801
3415
  if (__propIsEnum$p.call(b, prop))
2802
- __defNormalProp$w(a, prop, b[prop]);
3416
+ __defNormalProp$x(a, prop, b[prop]);
2803
3417
  }
2804
3418
  return a;
2805
3419
  };
2806
- var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, key + "" , value);
3420
+ var __publicField$m = (obj, key, value) => __defNormalProp$x(obj, key + "" , value);
2807
3421
  const _CheckProperty = class _CheckProperty extends BaseProperty {
2808
3422
  constructor(name, item, options) {
2809
3423
  super(name, item, __spreadValues$o(__spreadValues$o({}, _CheckProperty.options), options));
@@ -2911,7 +3525,7 @@ var NgwMap = (function (exports) {
2911
3525
  }
2912
3526
  }
2913
3527
  };
2914
- __publicField$l(_CheckProperty, "options", {
3528
+ __publicField$m(_CheckProperty, "options", {
2915
3529
  hierarchy: true,
2916
3530
  bubble: false,
2917
3531
  propagation: false,
@@ -2920,31 +3534,31 @@ var NgwMap = (function (exports) {
2920
3534
  });
2921
3535
  let CheckProperty = _CheckProperty;
2922
3536
 
2923
- var __defProp$v = Object.defineProperty;
3537
+ var __defProp$w = Object.defineProperty;
2924
3538
  var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
2925
3539
  var __hasOwnProp$o = Object.prototype.hasOwnProperty;
2926
3540
  var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
2927
- var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3541
+ var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2928
3542
  var __spreadValues$n = (a, b) => {
2929
3543
  for (var prop in b || (b = {}))
2930
3544
  if (__hasOwnProp$o.call(b, prop))
2931
- __defNormalProp$v(a, prop, b[prop]);
3545
+ __defNormalProp$w(a, prop, b[prop]);
2932
3546
  if (__getOwnPropSymbols$o)
2933
3547
  for (var prop of __getOwnPropSymbols$o(b)) {
2934
3548
  if (__propIsEnum$o.call(b, prop))
2935
- __defNormalProp$v(a, prop, b[prop]);
3549
+ __defNormalProp$w(a, prop, b[prop]);
2936
3550
  }
2937
3551
  return a;
2938
3552
  };
2939
- var __publicField$k = (obj, key, value) => __defNormalProp$v(obj, typeof key !== "symbol" ? key + "" : key, value);
3553
+ var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, typeof key !== "symbol" ? key + "" : key, value);
2940
3554
  const BOOLEAN_TYPE = "boolean";
2941
3555
  const STRING_TYPE = "string";
2942
3556
  const _ItemProperties = class _ItemProperties {
2943
3557
  constructor(item, propertiesList) {
2944
3558
  this.item = item;
2945
- __publicField$k(this, "options", {});
2946
- __publicField$k(this, "_properties", {});
2947
- __publicField$k(this, "_propertiesList", []);
3559
+ __publicField$l(this, "options", {});
3560
+ __publicField$l(this, "_properties", {});
3561
+ __publicField$l(this, "_propertiesList", []);
2948
3562
  if (propertiesList) {
2949
3563
  propertiesList.forEach(this._setPropertyHandler.bind(this));
2950
3564
  }
@@ -3007,35 +3621,35 @@ var NgwMap = (function (exports) {
3007
3621
  return Handler;
3008
3622
  }
3009
3623
  };
3010
- __publicField$k(_ItemProperties, "handlers", {
3624
+ __publicField$l(_ItemProperties, "handlers", {
3011
3625
  CheckProperty
3012
3626
  });
3013
3627
  let ItemProperties = _ItemProperties;
3014
3628
 
3015
- var __defProp$u = Object.defineProperty;
3629
+ var __defProp$v = Object.defineProperty;
3016
3630
  var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
3017
3631
  var __hasOwnProp$n = Object.prototype.hasOwnProperty;
3018
3632
  var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
3019
- var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3633
+ var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3020
3634
  var __spreadValues$m = (a, b) => {
3021
3635
  for (var prop in b || (b = {}))
3022
3636
  if (__hasOwnProp$n.call(b, prop))
3023
- __defNormalProp$u(a, prop, b[prop]);
3637
+ __defNormalProp$v(a, prop, b[prop]);
3024
3638
  if (__getOwnPropSymbols$n)
3025
3639
  for (var prop of __getOwnPropSymbols$n(b)) {
3026
3640
  if (__propIsEnum$n.call(b, prop))
3027
- __defNormalProp$u(a, prop, b[prop]);
3641
+ __defNormalProp$v(a, prop, b[prop]);
3028
3642
  }
3029
3643
  return a;
3030
3644
  };
3031
- var __publicField$j = (obj, key, value) => __defNormalProp$u(obj, typeof key !== "symbol" ? key + "" : key, value);
3645
+ var __publicField$k = (obj, key, value) => __defNormalProp$v(obj, typeof key !== "symbol" ? key + "" : key, value);
3032
3646
  let ID$1 = 0;
3033
3647
  class Item {
3034
3648
  constructor(options) {
3035
- __publicField$j(this, "options", {});
3036
- __publicField$j(this, "properties");
3037
- __publicField$j(this, "tree");
3038
- __publicField$j(this, "id", ID$1);
3649
+ __publicField$k(this, "options", {});
3650
+ __publicField$k(this, "properties");
3651
+ __publicField$k(this, "tree");
3652
+ __publicField$k(this, "id", ID$1);
3039
3653
  ID$1 += 1;
3040
3654
  this.options = __spreadValues$m({}, options);
3041
3655
  this.tree = new TreeHelper(this);
@@ -3049,7 +3663,7 @@ var NgwMap = (function (exports) {
3049
3663
  getProperty() {
3050
3664
  const layer = this.item.layer;
3051
3665
  if (layer) {
3052
- return layer && layer.options && layer.options.opacity !== void 0 ? layer.options.opacity : 1;
3666
+ return layer && layer.options && layer.options.opacity !== void 0 && layer.options.opacity !== null ? layer.options.opacity : 1;
3053
3667
  }
3054
3668
  return 1;
3055
3669
  }
@@ -3089,25 +3703,25 @@ var NgwMap = (function (exports) {
3089
3703
  }
3090
3704
  }
3091
3705
 
3092
- var __defProp$t = Object.defineProperty;
3093
- var __defProps$a = Object.defineProperties;
3094
- var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
3706
+ var __defProp$u = Object.defineProperty;
3707
+ var __defProps$d = Object.defineProperties;
3708
+ var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
3095
3709
  var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
3096
3710
  var __hasOwnProp$m = Object.prototype.hasOwnProperty;
3097
3711
  var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
3098
- var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3712
+ var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3099
3713
  var __spreadValues$l = (a, b) => {
3100
3714
  for (var prop in b || (b = {}))
3101
3715
  if (__hasOwnProp$m.call(b, prop))
3102
- __defNormalProp$t(a, prop, b[prop]);
3716
+ __defNormalProp$u(a, prop, b[prop]);
3103
3717
  if (__getOwnPropSymbols$m)
3104
3718
  for (var prop of __getOwnPropSymbols$m(b)) {
3105
3719
  if (__propIsEnum$m.call(b, prop))
3106
- __defNormalProp$t(a, prop, b[prop]);
3720
+ __defNormalProp$u(a, prop, b[prop]);
3107
3721
  }
3108
3722
  return a;
3109
3723
  };
3110
- var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
3724
+ var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
3111
3725
  function getNgwWebmapExtent(webmap) {
3112
3726
  const bottom = webmap["extent_bottom"];
3113
3727
  const left = webmap["extent_left"];
@@ -3130,7 +3744,7 @@ var NgwMap = (function (exports) {
3130
3744
  cache = true,
3131
3745
  signal
3132
3746
  }) {
3133
- return connector.get("layer.extent", { cache, signal }, { id: resourceId }).then((resp) => {
3747
+ return connector.route("layer.extent", { id: Number(resourceId) }).get({ cache, signal }).then((resp) => {
3134
3748
  if (resp) {
3135
3749
  const { maxLat, maxLon, minLat, minLon } = resp.extent;
3136
3750
  const extentArray = [minLon, minLat, maxLon, maxLat];
@@ -3145,11 +3759,10 @@ var NgwMap = (function (exports) {
3145
3759
  cache = true,
3146
3760
  signal
3147
3761
  }) {
3148
- return connector.get(
3149
- "feature_layer.feature.item_extent",
3150
- { cache, signal },
3151
- { id: resourceId, fid: featureId }
3152
- ).then((resp) => {
3762
+ return connector.route("feature_layer.feature.item_extent", {
3763
+ id: Number(resourceId),
3764
+ fid: featureId
3765
+ }).get({ cache, signal }).then((resp) => {
3153
3766
  if (resp) {
3154
3767
  const { maxLat, maxLon, minLat, minLon } = resp.extent;
3155
3768
  const extentArray = [minLon, minLat, maxLon, maxLat];
@@ -3172,17 +3785,17 @@ var NgwMap = (function (exports) {
3172
3785
  return Promise.resolve(getNgwWebmapExtent(item.webmap));
3173
3786
  } else {
3174
3787
  const resource = item.resource;
3175
- if (resource.cls && resource.cls.indexOf("style") !== -1) {
3788
+ if (resource.cls && resource.parent && resource.cls.indexOf("style") !== -1) {
3176
3789
  return connector.getResource(resource.parent.id, options).then((res) => {
3177
3790
  if (res) {
3178
- return fetchNgwLayerExtent(__spreadProps$a(__spreadValues$l({}, options), {
3791
+ return fetchNgwLayerExtent(__spreadProps$d(__spreadValues$l({}, options), {
3179
3792
  resourceId: res.resource.id,
3180
3793
  connector
3181
3794
  }));
3182
3795
  }
3183
3796
  });
3184
3797
  } else {
3185
- return fetchNgwLayerExtent(__spreadProps$a(__spreadValues$l({}, options), {
3798
+ return fetchNgwLayerExtent(__spreadProps$d(__spreadValues$l({}, options), {
3186
3799
  resourceId: resource.id,
3187
3800
  connector
3188
3801
  }));
@@ -3190,10 +3803,10 @@ var NgwMap = (function (exports) {
3190
3803
  }
3191
3804
  }
3192
3805
 
3193
- var __defProp$s = Object.defineProperty;
3194
- var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3195
- var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3196
- var __async$n = (__this, __arguments, generator) => {
3806
+ var __defProp$t = Object.defineProperty;
3807
+ var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3808
+ var __publicField$j = (obj, key, value) => __defNormalProp$t(obj, typeof key !== "symbol" ? key + "" : key, value);
3809
+ var __async$o = (__this, __arguments, generator) => {
3197
3810
  return new Promise((resolve, reject) => {
3198
3811
  var fulfilled = (value) => {
3199
3812
  try {
@@ -3215,18 +3828,18 @@ var NgwMap = (function (exports) {
3215
3828
  };
3216
3829
  class NgwResource {
3217
3830
  constructor() {
3218
- __publicField$i(this, "item");
3219
- __publicField$i(this, "connector");
3220
- __publicField$i(this, "_extent");
3831
+ __publicField$j(this, "item");
3832
+ __publicField$j(this, "connector");
3833
+ __publicField$j(this, "_extent");
3221
3834
  }
3222
3835
  /** @deprecated use {@link NgwResource.getBounds} instead */
3223
3836
  getExtent() {
3224
- return __async$n(this, null, function* () {
3837
+ return __async$o(this, null, function* () {
3225
3838
  return this.getBounds();
3226
3839
  });
3227
3840
  }
3228
3841
  getBounds(options) {
3229
- return __async$n(this, null, function* () {
3842
+ return __async$o(this, null, function* () {
3230
3843
  if (this._extent) {
3231
3844
  return this._extent;
3232
3845
  }
@@ -3242,7 +3855,7 @@ var NgwMap = (function (exports) {
3242
3855
  }
3243
3856
  }
3244
3857
 
3245
- var __async$m = (__this, __arguments, generator) => {
3858
+ var __async$n = (__this, __arguments, generator) => {
3246
3859
  return new Promise((resolve, reject) => {
3247
3860
  var fulfilled = (value) => {
3248
3861
  try {
@@ -3263,7 +3876,7 @@ var NgwMap = (function (exports) {
3263
3876
  });
3264
3877
  };
3265
3878
  function resourceIdFromLayerOptions(options, connector) {
3266
- return __async$m(this, null, function* () {
3879
+ return __async$n(this, null, function* () {
3267
3880
  const resource = options.resource;
3268
3881
  const item = resource;
3269
3882
  let { keyname, resourceId } = options;
@@ -3336,23 +3949,23 @@ var NgwMap = (function (exports) {
3336
3949
  };
3337
3950
  }
3338
3951
 
3339
- var __defProp$r = Object.defineProperty;
3952
+ var __defProp$s = Object.defineProperty;
3340
3953
  var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
3341
3954
  var __hasOwnProp$l = Object.prototype.hasOwnProperty;
3342
3955
  var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
3343
- var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3956
+ var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3344
3957
  var __spreadValues$k = (a, b) => {
3345
3958
  for (var prop in b || (b = {}))
3346
3959
  if (__hasOwnProp$l.call(b, prop))
3347
- __defNormalProp$r(a, prop, b[prop]);
3960
+ __defNormalProp$s(a, prop, b[prop]);
3348
3961
  if (__getOwnPropSymbols$l)
3349
3962
  for (var prop of __getOwnPropSymbols$l(b)) {
3350
3963
  if (__propIsEnum$l.call(b, prop))
3351
- __defNormalProp$r(a, prop, b[prop]);
3964
+ __defNormalProp$s(a, prop, b[prop]);
3352
3965
  }
3353
3966
  return a;
3354
3967
  };
3355
- var __objRest$1 = (source, exclude) => {
3968
+ var __objRest$2 = (source, exclude) => {
3356
3969
  var target = {};
3357
3970
  for (var prop in source)
3358
3971
  if (__hasOwnProp$l.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -3364,8 +3977,8 @@ var NgwMap = (function (exports) {
3364
3977
  }
3365
3978
  return target;
3366
3979
  };
3367
- var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3368
- var __async$l = (__this, __arguments, generator) => {
3980
+ var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3981
+ var __async$m = (__this, __arguments, generator) => {
3369
3982
  return new Promise((resolve, reject) => {
3370
3983
  var fulfilled = (value) => {
3371
3984
  try {
@@ -3389,7 +4002,7 @@ var NgwMap = (function (exports) {
3389
4002
  function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
3390
4003
  let webMap;
3391
4004
  if ("webMap" in webMapOrOptions) {
3392
- const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$1(_a, ["webMap", "url"]);
4005
+ const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$2(_a, ["webMap", "url"]);
3393
4006
  webMap = webMap_;
3394
4007
  if (url_) {
3395
4008
  url = url_;
@@ -3405,9 +4018,9 @@ var NgwMap = (function (exports) {
3405
4018
  }
3406
4019
  class QmsAdapter {
3407
4020
  constructor(map, options) {
3408
- __publicField$h(this, "qms");
3409
- __publicField$h(this, "options");
3410
- __publicField$h(this, "map");
4021
+ __publicField$i(this, "qms");
4022
+ __publicField$i(this, "options");
4023
+ __publicField$i(this, "map");
3411
4024
  this.map = map;
3412
4025
  const opt = __spreadValues$k(__spreadValues$k({}, createOpt), options);
3413
4026
  this.options = opt;
@@ -3417,7 +4030,7 @@ var NgwMap = (function (exports) {
3417
4030
  }
3418
4031
  }
3419
4032
  addLayer(options) {
3420
- return __async$l(this, null, function* () {
4033
+ return __async$m(this, null, function* () {
3421
4034
  if (!this.qms && options.qmsId) {
3422
4035
  try {
3423
4036
  this.qms = yield loadJson(
@@ -3461,29 +4074,29 @@ var NgwMap = (function (exports) {
3461
4074
  return QmsAdapter;
3462
4075
  }
3463
4076
 
3464
- var __defProp$q = Object.defineProperty;
4077
+ var __defProp$r = Object.defineProperty;
3465
4078
  var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
3466
4079
  var __hasOwnProp$k = Object.prototype.hasOwnProperty;
3467
4080
  var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
3468
- var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4081
+ var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3469
4082
  var __spreadValues$j = (a, b) => {
3470
4083
  for (var prop in b || (b = {}))
3471
4084
  if (__hasOwnProp$k.call(b, prop))
3472
- __defNormalProp$q(a, prop, b[prop]);
4085
+ __defNormalProp$r(a, prop, b[prop]);
3473
4086
  if (__getOwnPropSymbols$k)
3474
4087
  for (var prop of __getOwnPropSymbols$k(b)) {
3475
4088
  if (__propIsEnum$k.call(b, prop))
3476
- __defNormalProp$q(a, prop, b[prop]);
4089
+ __defNormalProp$r(a, prop, b[prop]);
3477
4090
  }
3478
4091
  return a;
3479
4092
  };
3480
- var __publicField$g = (obj, key, value) => __defNormalProp$q(obj, typeof key !== "symbol" ? key + "" : key, value);
4093
+ var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3481
4094
  class QmsKit {
3482
4095
  constructor(options) {
3483
- __publicField$g(this, "options", {
4096
+ __publicField$h(this, "options", {
3484
4097
  url: "https://qms.nextgis.com"
3485
4098
  });
3486
- __publicField$g(this, "url");
4099
+ __publicField$h(this, "url");
3487
4100
  this.options = __spreadValues$j(__spreadValues$j({}, this.options), options);
3488
4101
  this.url = this.options.url;
3489
4102
  }
@@ -3499,33 +4112,33 @@ var NgwMap = (function (exports) {
3499
4112
  return createQmsAdapter({ webMap, url: this.url });
3500
4113
  }
3501
4114
  }
3502
- __publicField$g(QmsKit, "utils", {
4115
+ __publicField$h(QmsKit, "utils", {
3503
4116
  createQmsAdapter
3504
4117
  });
3505
4118
 
3506
- var __defProp$p = Object.defineProperty;
3507
- var __defProps$9 = Object.defineProperties;
3508
- var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
4119
+ var __defProp$q = Object.defineProperty;
4120
+ var __defProps$c = Object.defineProperties;
4121
+ var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
3509
4122
  var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
3510
4123
  var __getProtoOf$2 = Object.getPrototypeOf;
3511
4124
  var __hasOwnProp$j = Object.prototype.hasOwnProperty;
3512
4125
  var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
3513
4126
  var __reflectGet$2 = Reflect.get;
3514
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4127
+ var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3515
4128
  var __spreadValues$i = (a, b) => {
3516
4129
  for (var prop in b || (b = {}))
3517
4130
  if (__hasOwnProp$j.call(b, prop))
3518
- __defNormalProp$p(a, prop, b[prop]);
4131
+ __defNormalProp$q(a, prop, b[prop]);
3519
4132
  if (__getOwnPropSymbols$j)
3520
4133
  for (var prop of __getOwnPropSymbols$j(b)) {
3521
4134
  if (__propIsEnum$j.call(b, prop))
3522
- __defNormalProp$p(a, prop, b[prop]);
4135
+ __defNormalProp$q(a, prop, b[prop]);
3523
4136
  }
3524
4137
  return a;
3525
4138
  };
3526
- var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
4139
+ var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
3527
4140
  var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
3528
- var __async$k = (__this, __arguments, generator) => {
4141
+ var __async$l = (__this, __arguments, generator) => {
3529
4142
  return new Promise((resolve, reject) => {
3530
4143
  var fulfilled = (value) => {
3531
4144
  try {
@@ -3546,7 +4159,7 @@ var NgwMap = (function (exports) {
3546
4159
  });
3547
4160
  };
3548
4161
  function createBasemapLayerAdapter(_0) {
3549
- return __async$k(this, arguments, function* ({
4162
+ return __async$l(this, arguments, function* ({
3550
4163
  webMap,
3551
4164
  item
3552
4165
  }) {
@@ -3567,8 +4180,10 @@ var NgwMap = (function (exports) {
3567
4180
  if (TileAdapter) {
3568
4181
  class BasemapTileAdapter extends TileAdapter {
3569
4182
  addLayer(opt) {
3570
- return __async$k(this, null, function* () {
3571
- return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$9(__spreadValues$i({}, opt), { url }));
4183
+ return __async$l(this, null, function* () {
4184
+ if (url) {
4185
+ return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$c(__spreadValues$i({}, opt), { url }));
4186
+ }
3572
4187
  });
3573
4188
  }
3574
4189
  }
@@ -3610,13 +4225,9 @@ var NgwMap = (function (exports) {
3610
4225
  cache = true,
3611
4226
  signal
3612
4227
  }) {
3613
- return connector.get(
3614
- "feature_layer.feature.count",
3615
- { cache, signal },
3616
- {
3617
- id: resourceId
3618
- }
3619
- ).then((resp) => {
4228
+ return connector.route("feature_layer.feature.count", {
4229
+ id: resourceId
4230
+ }).get({ cache, signal }).then((resp) => {
3620
4231
  return resp.total_count;
3621
4232
  });
3622
4233
  }
@@ -3647,26 +4258,26 @@ var NgwMap = (function (exports) {
3647
4258
  return fields;
3648
4259
  }
3649
4260
 
3650
- var __defProp$o = Object.defineProperty;
3651
- var __defProps$8 = Object.defineProperties;
3652
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
4261
+ var __defProp$p = Object.defineProperty;
4262
+ var __defProps$b = Object.defineProperties;
4263
+ var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
3653
4264
  var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
3654
4265
  var __hasOwnProp$i = Object.prototype.hasOwnProperty;
3655
4266
  var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
3656
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4267
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3657
4268
  var __spreadValues$h = (a, b) => {
3658
4269
  for (var prop in b || (b = {}))
3659
4270
  if (__hasOwnProp$i.call(b, prop))
3660
- __defNormalProp$o(a, prop, b[prop]);
4271
+ __defNormalProp$p(a, prop, b[prop]);
3661
4272
  if (__getOwnPropSymbols$i)
3662
4273
  for (var prop of __getOwnPropSymbols$i(b)) {
3663
4274
  if (__propIsEnum$i.call(b, prop))
3664
- __defNormalProp$o(a, prop, b[prop]);
4275
+ __defNormalProp$p(a, prop, b[prop]);
3665
4276
  }
3666
4277
  return a;
3667
4278
  };
3668
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
3669
- var __async$j = (__this, __arguments, generator) => {
4279
+ var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
4280
+ var __async$k = (__this, __arguments, generator) => {
3670
4281
  return new Promise((resolve, reject) => {
3671
4282
  var fulfilled = (value) => {
3672
4283
  try {
@@ -3687,17 +4298,17 @@ var NgwMap = (function (exports) {
3687
4298
  });
3688
4299
  };
3689
4300
  function fetchNgwLayerItems(options) {
3690
- return __async$j(this, null, function* () {
4301
+ return __async$k(this, null, function* () {
3691
4302
  var _a;
3692
4303
  const filters = options.filters;
3693
4304
  if (filters) {
3694
- let data = yield createFeatureFieldFilterQueries(__spreadProps$8(__spreadValues$h({}, options), {
4305
+ let data = yield createFeatureFieldFilterQueries(__spreadProps$b(__spreadValues$h({}, options), {
3695
4306
  filters
3696
4307
  }));
3697
4308
  const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
3698
4309
  if (clientFilterValidate) {
3699
4310
  data = data.filter((y) => {
3700
- const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps$8(__spreadValues$h({}, y.fields), {
4311
+ const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps$b(__spreadValues$h({}, y.fields), {
3701
4312
  id: y.id
3702
4313
  }));
3703
4314
  const result = propertiesFilter(fields, filters);
@@ -3726,7 +4337,7 @@ var NgwMap = (function (exports) {
3726
4337
  return false;
3727
4338
  }
3728
4339
 
3729
- var __async$i = (__this, __arguments, generator) => {
4340
+ var __async$j = (__this, __arguments, generator) => {
3730
4341
  return new Promise((resolve, reject) => {
3731
4342
  var fulfilled = (value) => {
3732
4343
  try {
@@ -3747,7 +4358,7 @@ var NgwMap = (function (exports) {
3747
4358
  });
3748
4359
  };
3749
4360
  function fetchNgwLayerFeatures(options) {
3750
- return __async$i(this, null, function* () {
4361
+ return __async$j(this, null, function* () {
3751
4362
  const x = yield fetchNgwLayerItems(options);
3752
4363
  const features = [];
3753
4364
  x.forEach((y) => {
@@ -3785,30 +4396,30 @@ var NgwMap = (function (exports) {
3785
4396
  return filterOptions;
3786
4397
  }
3787
4398
 
3788
- var __defProp$n = Object.defineProperty;
3789
- var __defProps$7 = Object.defineProperties;
3790
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
4399
+ var __defProp$o = Object.defineProperty;
4400
+ var __defProps$a = Object.defineProperties;
4401
+ var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
3791
4402
  var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
3792
4403
  var __getProtoOf$1 = Object.getPrototypeOf;
3793
4404
  var __hasOwnProp$h = Object.prototype.hasOwnProperty;
3794
4405
  var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
3795
4406
  var __reflectGet$1 = Reflect.get;
3796
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4407
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3797
4408
  var __spreadValues$g = (a, b) => {
3798
4409
  for (var prop in b || (b = {}))
3799
4410
  if (__hasOwnProp$h.call(b, prop))
3800
- __defNormalProp$n(a, prop, b[prop]);
4411
+ __defNormalProp$o(a, prop, b[prop]);
3801
4412
  if (__getOwnPropSymbols$h)
3802
4413
  for (var prop of __getOwnPropSymbols$h(b)) {
3803
4414
  if (__propIsEnum$h.call(b, prop))
3804
- __defNormalProp$n(a, prop, b[prop]);
4415
+ __defNormalProp$o(a, prop, b[prop]);
3805
4416
  }
3806
4417
  return a;
3807
4418
  };
3808
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
3809
- var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
4419
+ var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
4420
+ var __publicField$g = (obj, key, value) => __defNormalProp$o(obj, typeof key !== "symbol" ? key + "" : key, value);
3810
4421
  var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
3811
- var __async$h = (__this, __arguments, generator) => {
4422
+ var __async$i = (__this, __arguments, generator) => {
3812
4423
  return new Promise((resolve, reject) => {
3813
4424
  var fulfilled = (value) => {
3814
4425
  try {
@@ -3829,7 +4440,7 @@ var NgwMap = (function (exports) {
3829
4440
  });
3830
4441
  };
3831
4442
  function createGeoJsonAdapter(props) {
3832
- return __async$h(this, null, function* () {
4443
+ return __async$i(this, null, function* () {
3833
4444
  var _a, _b;
3834
4445
  const {
3835
4446
  item,
@@ -3852,7 +4463,7 @@ var NgwMap = (function (exports) {
3852
4463
  return feature && createPopupContent(feature, item);
3853
4464
  };
3854
4465
  }
3855
- const getData = (filters, filterOpt) => __async$h(this, null, function* () {
4466
+ const getData = (filters, filterOpt) => __async$i(this, null, function* () {
3856
4467
  abort();
3857
4468
  internalAbortController = new AbortController();
3858
4469
  const internalSignal = internalAbortController.signal;
@@ -3879,14 +4490,14 @@ var NgwMap = (function (exports) {
3879
4490
  class NgwGeoJsonAdapter extends GeoJsonAdapter {
3880
4491
  constructor() {
3881
4492
  super(...arguments);
3882
- __publicField$f(this, "emitter", new EventEmitter());
3883
- __publicField$f(this, "__onMapMove");
3884
- __publicField$f(this, "__onMapMoveStart");
3885
- __publicField$f(this, "__enableMapMoveListener");
3886
- __publicField$f(this, "__disableMapMoveListener");
4493
+ __publicField$g(this, "emitter", new EventEmitter());
4494
+ __publicField$g(this, "__onMapMove");
4495
+ __publicField$g(this, "__onMapMoveStart");
4496
+ __publicField$g(this, "__enableMapMoveListener");
4497
+ __publicField$g(this, "__disableMapMoveListener");
3887
4498
  }
3888
4499
  addLayer(opt) {
3889
- return __async$h(this, null, function* () {
4500
+ return __async$i(this, null, function* () {
3890
4501
  let needUpdate = !opt.data;
3891
4502
  const waitFullLoad = opt.waitFullLoad !== void 0 ? opt.waitFullLoad : true;
3892
4503
  if (options.id !== void 0) {
@@ -3931,7 +4542,7 @@ var NgwMap = (function (exports) {
3931
4542
  return this.getBounds();
3932
4543
  }
3933
4544
  getBounds() {
3934
- return __async$h(this, null, function* () {
4545
+ return __async$i(this, null, function* () {
3935
4546
  const hasData = this.getLayers && this.getLayers().length;
3936
4547
  const strategy = this.options.strategy;
3937
4548
  if ((strategy == null ? void 0 : strategy.startsWith("BBOX")) || hasData) {
@@ -3956,10 +4567,10 @@ var NgwMap = (function (exports) {
3956
4567
  getCount() {
3957
4568
  return fetchNgwLayerCount({ connector, resourceId, cache: true });
3958
4569
  }
3959
- updateLayer(filterArgs) {
3960
- return __async$h(this, null, function* () {
4570
+ updateLayer(opt) {
4571
+ return __async$i(this, null, function* () {
3961
4572
  var _a2;
3962
- filterArgs = filterArgs || _lastFilterArgs || {};
4573
+ const filterArgs = opt || _lastFilterArgs || {};
3963
4574
  if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
3964
4575
  yield webMap.onLoad("create");
3965
4576
  filterArgs.options = filterArgs.options || {};
@@ -3984,7 +4595,7 @@ var NgwMap = (function (exports) {
3984
4595
  try {
3985
4596
  this.emitter.emit("preupdate", filterArgs);
3986
4597
  webMap._emitLayerEvent("layer:preupdate", options.id || "", filterArgs);
3987
- const data = yield getData(filterArgs.filters, __spreadProps$7(__spreadValues$g({}, filterArgs.options), {
4598
+ const data = yield getData(filterArgs.filters, __spreadProps$a(__spreadValues$g({}, filterArgs.options), {
3988
4599
  srs: this.options.srs
3989
4600
  }));
3990
4601
  let newData = data;
@@ -4013,7 +4624,7 @@ var NgwMap = (function (exports) {
4013
4624
  isFull: _fullDataLoad
4014
4625
  });
4015
4626
  } catch (er) {
4016
- if (er instanceof Error && er.name !== "CancelError") {
4627
+ if (er instanceof Error && er.name !== "AbortError") {
4017
4628
  throw er;
4018
4629
  }
4019
4630
  }
@@ -4023,7 +4634,7 @@ var NgwMap = (function (exports) {
4023
4634
  });
4024
4635
  }
4025
4636
  propertiesFilter(filters, opt) {
4026
- return __async$h(this, null, function* () {
4637
+ return __async$i(this, null, function* () {
4027
4638
  abort();
4028
4639
  if (this.filter && _fullDataLoad) {
4029
4640
  this.filter((e) => {
@@ -4037,7 +4648,7 @@ var NgwMap = (function (exports) {
4037
4648
  if (this.clearLayer) {
4038
4649
  this.clearLayer();
4039
4650
  }
4040
- const data = yield getData(filters, __spreadProps$7(__spreadValues$g({}, opt), {
4651
+ const data = yield getData(filters, __spreadProps$a(__spreadValues$g({}, opt), {
4041
4652
  srs: this.options.srs
4042
4653
  }));
4043
4654
  this.setData(data);
@@ -4097,7 +4708,7 @@ var NgwMap = (function (exports) {
4097
4708
  });
4098
4709
  }
4099
4710
 
4100
- var __async$g = (__this, __arguments, generator) => {
4711
+ var __async$h = (__this, __arguments, generator) => {
4101
4712
  return new Promise((resolve, reject) => {
4102
4713
  var fulfilled = (value) => {
4103
4714
  try {
@@ -4118,7 +4729,7 @@ var NgwMap = (function (exports) {
4118
4729
  });
4119
4730
  };
4120
4731
  function createWebMapAdapter(_0) {
4121
- return __async$g(this, arguments, function* ({
4732
+ return __async$h(this, arguments, function* ({
4122
4733
  layerOptions: options,
4123
4734
  webMap,
4124
4735
  connector
@@ -4226,27 +4837,27 @@ var NgwMap = (function (exports) {
4226
4837
  }
4227
4838
  }
4228
4839
 
4229
- var __defProp$m = Object.defineProperty;
4230
- var __defProps$6 = Object.defineProperties;
4231
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
4840
+ var __defProp$n = Object.defineProperty;
4841
+ var __defProps$9 = Object.defineProperties;
4842
+ var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
4232
4843
  var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
4233
4844
  var __hasOwnProp$g = Object.prototype.hasOwnProperty;
4234
4845
  var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
4235
- var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4846
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4236
4847
  var __spreadValues$f = (a, b) => {
4237
4848
  for (var prop in b || (b = {}))
4238
4849
  if (__hasOwnProp$g.call(b, prop))
4239
- __defNormalProp$m(a, prop, b[prop]);
4850
+ __defNormalProp$n(a, prop, b[prop]);
4240
4851
  if (__getOwnPropSymbols$g)
4241
4852
  for (var prop of __getOwnPropSymbols$g(b)) {
4242
4853
  if (__propIsEnum$g.call(b, prop))
4243
- __defNormalProp$m(a, prop, b[prop]);
4854
+ __defNormalProp$n(a, prop, b[prop]);
4244
4855
  }
4245
4856
  return a;
4246
4857
  };
4247
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
4248
- var __publicField$e = (obj, key, value) => __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
4249
- var __async$f = (__this, __arguments, generator) => {
4858
+ var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
4859
+ var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
4860
+ var __async$g = (__this, __arguments, generator) => {
4250
4861
  return new Promise((resolve, reject) => {
4251
4862
  var fulfilled = (value) => {
4252
4863
  try {
@@ -4266,11 +4877,47 @@ var NgwMap = (function (exports) {
4266
4877
  step((generator = generator.apply(__this, __arguments)).next());
4267
4878
  });
4268
4879
  };
4880
+ class Legend {
4881
+ constructor({
4882
+ layerId,
4883
+ legend,
4884
+ onSymbolRenderChange
4885
+ }) {
4886
+ __publicField$f(this, "layerId");
4887
+ __publicField$f(this, "legend");
4888
+ __publicField$f(this, "onSymbolRenderChange");
4889
+ this.layerId = layerId;
4890
+ this.legend = this.createLegend(legend);
4891
+ this.onSymbolRenderChange = onSymbolRenderChange;
4892
+ }
4893
+ createLegend(items) {
4894
+ return items.map((params) => __spreadProps$9(__spreadValues$f({}, params), {
4895
+ /** @deprecated use display_name instead */
4896
+ name: params.display_name,
4897
+ /** @deprecated use icon instead */
4898
+ symbol: params.icon
4899
+ }));
4900
+ }
4901
+ setSymbolRender(symbolIndex, status) {
4902
+ const legendItem = this.legend.find((l) => l.index === symbolIndex);
4903
+ if (legendItem) {
4904
+ const render = legendItem.render;
4905
+ if (render !== status) {
4906
+ legendItem.render = status;
4907
+ if (this.onSymbolRenderChange) {
4908
+ this.onSymbolRenderChange(
4909
+ this.legend.filter((l) => l.render).map((l) => l.index)
4910
+ );
4911
+ }
4912
+ }
4913
+ }
4914
+ }
4915
+ }
4269
4916
  function createRasterAdapter(_0) {
4270
- return __async$f(this, arguments, function* ({
4917
+ return __async$g(this, arguments, function* ({
4271
4918
  layerOptions,
4272
- webMap,
4273
4919
  connector,
4920
+ webMap,
4274
4921
  item
4275
4922
  }) {
4276
4923
  const resourceCls = item.resource.cls;
@@ -4299,16 +4946,17 @@ var NgwMap = (function (exports) {
4299
4946
  constructor(map, _options) {
4300
4947
  super(map, _options);
4301
4948
  this.map = map;
4302
- // options = {};
4303
- __publicField$e(this, "item", item);
4304
- __publicField$e(this, "resourceId", resourceId);
4949
+ __publicField$f(this, "item", item);
4950
+ __publicField$f(this, "resourceId", resourceId);
4951
+ __publicField$f(this, "_blocked", false);
4952
+ __publicField$f(this, "_layerVisibility");
4305
4953
  const opt = ngwApiToAdapterOptions({
4306
4954
  options: layerOptions,
4307
4955
  webMap,
4308
4956
  baseUrl: connector.options.baseUrl || ""
4309
4957
  });
4310
4958
  if (opt) {
4311
- const layerAdapterOptions = __spreadProps$6(__spreadValues$f(__spreadValues$f({}, opt), layerOptions.adapterOptions), {
4959
+ const layerAdapterOptions = __spreadProps$9(__spreadValues$f(__spreadValues$f({}, opt), layerOptions.adapterOptions), {
4312
4960
  params: { resource: resourceId },
4313
4961
  layers: opt.layers || String(resourceId),
4314
4962
  resourceId
@@ -4322,42 +4970,98 @@ var NgwMap = (function (exports) {
4322
4970
  addLayer(addOptions) {
4323
4971
  return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
4324
4972
  }
4325
- getLegend(options) {
4326
- return __async$f(this, null, function* () {
4327
- const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4328
- params: { id: resourceId },
4329
- cache: true
4330
- }, options));
4331
- const id = this.options.id;
4332
- if (id !== void 0) {
4333
- const legend = {
4334
- layerId: id,
4335
- legend: ngwLegend.map(({ display_name, icon }) => ({
4336
- name: display_name,
4337
- symbol: icon
4338
- }))
4339
- };
4340
- return [legend];
4973
+ showLayer() {
4974
+ this._layerVisibility = true;
4975
+ if (this.layer) {
4976
+ if (!this._blocked) {
4977
+ webMap.mapAdapter.showLayer(this.layer);
4341
4978
  }
4342
- return [];
4343
- });
4979
+ }
4980
+ }
4981
+ hideLayer() {
4982
+ this._layerVisibility = false;
4983
+ if (this.layer) {
4984
+ webMap.mapAdapter.hideLayer(this.layer);
4985
+ }
4344
4986
  }
4345
4987
  getIdentificationIds() {
4346
- return __async$f(this, null, function* () {
4988
+ return __async$g(this, null, function* () {
4347
4989
  if (this.item) {
4348
4990
  if (adapter === "MVT") {
4349
4991
  return [this.item.resource.id];
4350
4992
  }
4351
- const id = this.item.resource.parent.id;
4352
- if (defined(id)) {
4353
- return [id];
4993
+ if (this.item.resource.parent) {
4994
+ const id = this.item.resource.parent.id;
4995
+ if (defined(id)) {
4996
+ return [id];
4997
+ }
4354
4998
  }
4355
4999
  }
4356
5000
  return [];
4357
5001
  });
4358
5002
  }
4359
- // beforeRemove() {
4360
- // }
5003
+ getLegend(options) {
5004
+ return __async$g(this, null, function* () {
5005
+ const id = this.options.id;
5006
+ if (id !== void 0) {
5007
+ const ngwLegend = yield connector.route("render.legend_symbols", { id: resourceId }).get(__spreadValues$f({
5008
+ cache: true
5009
+ }, options));
5010
+ const legend = new Legend({
5011
+ layerId: id,
5012
+ legend: ngwLegend,
5013
+ onSymbolRenderChange: this._setLegendSymbol.bind(this)
5014
+ });
5015
+ return [legend];
5016
+ }
5017
+ return [];
5018
+ });
5019
+ }
5020
+ _hideLayer() {
5021
+ if (this.options.id) {
5022
+ webMap.mapAdapter.hideLayer(this.layer);
5023
+ }
5024
+ }
5025
+ _showLayer() {
5026
+ if (this.options.id) {
5027
+ if (this._layerVisibility) {
5028
+ webMap.showLayer(this.options.id, { silent: true });
5029
+ }
5030
+ }
5031
+ }
5032
+ _setLegendSymbol(renderIndexes) {
5033
+ const intervals = this._consolidateIntervals(renderIndexes);
5034
+ if (!intervals.length) {
5035
+ this._hideLayer();
5036
+ this._blocked = true;
5037
+ } else {
5038
+ this._blocked = false;
5039
+ this._showLayer();
5040
+ }
5041
+ if (this.updateLayer) {
5042
+ this.updateLayer({
5043
+ params: {
5044
+ [`symbols[${resourceId}]`]: intervals.join(",") || void 0
5045
+ }
5046
+ });
5047
+ }
5048
+ }
5049
+ _consolidateIntervals(symbols) {
5050
+ const sortedSymbols = symbols.slice().sort((a, b) => a - b);
5051
+ const intervals = [];
5052
+ let start = sortedSymbols[0];
5053
+ let end = start;
5054
+ for (let i = 1; i <= sortedSymbols.length; i++) {
5055
+ if (sortedSymbols[i] === end + 1) {
5056
+ end = sortedSymbols[i];
5057
+ } else {
5058
+ intervals.push(start === end ? `${start}` : `${start}-${end}`);
5059
+ start = sortedSymbols[i];
5060
+ end = start;
5061
+ }
5062
+ }
5063
+ return intervals;
5064
+ }
4361
5065
  };
4362
5066
  } else {
4363
5067
  throw new Error(adapter + " not supported yet. Only TILE");
@@ -4365,26 +5069,26 @@ var NgwMap = (function (exports) {
4365
5069
  });
4366
5070
  }
4367
5071
 
4368
- var __defProp$l = Object.defineProperty;
4369
- var __defProps$5 = Object.defineProperties;
4370
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
5072
+ var __defProp$m = Object.defineProperty;
5073
+ var __defProps$8 = Object.defineProperties;
5074
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
4371
5075
  var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
4372
5076
  var __hasOwnProp$f = Object.prototype.hasOwnProperty;
4373
5077
  var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
4374
- var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5078
+ var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4375
5079
  var __spreadValues$e = (a, b) => {
4376
5080
  for (var prop in b || (b = {}))
4377
5081
  if (__hasOwnProp$f.call(b, prop))
4378
- __defNormalProp$l(a, prop, b[prop]);
5082
+ __defNormalProp$m(a, prop, b[prop]);
4379
5083
  if (__getOwnPropSymbols$f)
4380
5084
  for (var prop of __getOwnPropSymbols$f(b)) {
4381
5085
  if (__propIsEnum$f.call(b, prop))
4382
- __defNormalProp$l(a, prop, b[prop]);
5086
+ __defNormalProp$m(a, prop, b[prop]);
4383
5087
  }
4384
5088
  return a;
4385
5089
  };
4386
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
4387
- var __async$e = (__this, __arguments, generator) => {
5090
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
5091
+ var __async$f = (__this, __arguments, generator) => {
4388
5092
  return new Promise((resolve, reject) => {
4389
5093
  var fulfilled = (value) => {
4390
5094
  try {
@@ -4420,7 +5124,7 @@ var NgwMap = (function (exports) {
4420
5124
  "tmsclient_layer"
4421
5125
  ];
4422
5126
  function createAdapterFromFirstStyle(_0) {
4423
- return __async$e(this, arguments, function* ({
5127
+ return __async$f(this, arguments, function* ({
4424
5128
  layerOptions,
4425
5129
  webMap,
4426
5130
  connector,
@@ -4431,7 +5135,7 @@ var NgwMap = (function (exports) {
4431
5135
  const firstStyle = childrenStyles && childrenStyles[0];
4432
5136
  if (firstStyle) {
4433
5137
  return createAsyncAdapter(
4434
- __spreadProps$5(__spreadValues$e({}, layerOptions), { resource: firstStyle.resource.id }),
5138
+ __spreadProps$8(__spreadValues$e({}, layerOptions), { resource: firstStyle.resource.id }),
4435
5139
  webMap,
4436
5140
  connector
4437
5141
  );
@@ -4439,7 +5143,7 @@ var NgwMap = (function (exports) {
4439
5143
  });
4440
5144
  }
4441
5145
  function createAsyncAdapter(options, webMap, connector) {
4442
- return __async$e(this, null, function* () {
5146
+ return __async$f(this, null, function* () {
4443
5147
  let adapter;
4444
5148
  let item;
4445
5149
  const adapterType = options.adapter;
@@ -4454,13 +5158,13 @@ var NgwMap = (function (exports) {
4454
5158
  }
4455
5159
  if (item) {
4456
5160
  const cls = item.resource.cls;
4457
- const layerOptions = __spreadProps$5(__spreadValues$e({}, options), {
5161
+ const layerOptions = __spreadProps$8(__spreadValues$e({}, options), {
4458
5162
  resource: resourceId
4459
5163
  });
4460
5164
  const adapterOptions = {
4461
5165
  layerOptions,
4462
- webMap,
4463
5166
  connector,
5167
+ webMap,
4464
5168
  item
4465
5169
  };
4466
5170
  if (supportCls.indexOf(cls) !== -1) {
@@ -4486,15 +5190,15 @@ var NgwMap = (function (exports) {
4486
5190
  } else if (cls === "basemap_layer") {
4487
5191
  adapter = createBasemapLayerAdapter(adapterOptions);
4488
5192
  } else {
4489
- if (adapterType === "GEOJSON") {
5193
+ if (adapterType === "GEOJSON" && item.resource.parent) {
4490
5194
  const parentItem = yield connector.getResource(
4491
5195
  item.resource.parent.id
4492
5196
  );
4493
5197
  if (parentItem) {
4494
- const parentOptions = __spreadProps$5(__spreadValues$e({}, options), {
5198
+ const parentOptions = __spreadProps$8(__spreadValues$e({}, options), {
4495
5199
  resource: item.resource.parent.id
4496
5200
  });
4497
- adapter = createGeoJsonAdapter(__spreadProps$5(__spreadValues$e({}, adapterOptions), {
5201
+ adapter = createGeoJsonAdapter(__spreadProps$8(__spreadValues$e({}, adapterOptions), {
4498
5202
  item: parentItem,
4499
5203
  layerOptions: parentOptions
4500
5204
  }));
@@ -4538,31 +5242,46 @@ var NgwMap = (function (exports) {
4538
5242
  });
4539
5243
  }
4540
5244
 
4541
- var __defProp$k = Object.defineProperty;
5245
+ var __defProp$l = Object.defineProperty;
5246
+ var __defProps$7 = Object.defineProperties;
5247
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
4542
5248
  var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
4543
5249
  var __hasOwnProp$e = Object.prototype.hasOwnProperty;
4544
5250
  var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
4545
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5251
+ var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4546
5252
  var __spreadValues$d = (a, b) => {
4547
5253
  for (var prop in b || (b = {}))
4548
5254
  if (__hasOwnProp$e.call(b, prop))
4549
- __defNormalProp$k(a, prop, b[prop]);
5255
+ __defNormalProp$l(a, prop, b[prop]);
4550
5256
  if (__getOwnPropSymbols$e)
4551
5257
  for (var prop of __getOwnPropSymbols$e(b)) {
4552
5258
  if (__propIsEnum$e.call(b, prop))
4553
- __defNormalProp$k(a, prop, b[prop]);
5259
+ __defNormalProp$l(a, prop, b[prop]);
4554
5260
  }
4555
5261
  return a;
4556
5262
  };
5263
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
5264
+ var __objRest$1 = (source, exclude) => {
5265
+ var target = {};
5266
+ for (var prop in source)
5267
+ if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
5268
+ target[prop] = source[prop];
5269
+ if (source != null && __getOwnPropSymbols$e)
5270
+ for (var prop of __getOwnPropSymbols$e(source)) {
5271
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$e.call(source, prop))
5272
+ target[prop] = source[prop];
5273
+ }
5274
+ return target;
5275
+ };
4557
5276
  function updateImageParams(params, resourceId) {
4558
- const { bbox, width, height, nd } = params;
4559
- return {
5277
+ const _a = params, { bbox, width, height, nd } = _a, rest = __objRest$1(_a, ["bbox", "width", "height", "nd"]);
5278
+ return __spreadProps$7(__spreadValues$d({}, rest), {
4560
5279
  resource: Array.isArray(resourceId) ? resourceId.join(",") : resourceId,
4561
5280
  extent: bbox,
4562
5281
  size: width + "," + height,
4563
5282
  timestamp: Date.now(),
4564
5283
  nd: nd != null ? nd : 200
4565
- };
5284
+ });
4566
5285
  }
4567
5286
  const vectorLayerGeomToPaintTypeAlias = {
4568
5287
  POINT: "point",
@@ -4583,6 +5302,9 @@ var NgwMap = (function (exports) {
4583
5302
  if (headers) {
4584
5303
  options.headers = headers;
4585
5304
  }
5305
+ if (connector.withCredentials !== void 0) {
5306
+ options.withCredentials = connector.withCredentials;
5307
+ }
4586
5308
  return createAsyncAdapter(options, webMap, connector);
4587
5309
  }
4588
5310
  function extendNgwWebmapLayerAdapter(opt) {
@@ -4619,24 +5341,27 @@ var NgwMap = (function (exports) {
4619
5341
  return zoom;
4620
5342
  }
4621
5343
 
4622
- var __defProp$j = Object.defineProperty;
5344
+ var __defProp$k = Object.defineProperty;
5345
+ var __defProps$6 = Object.defineProperties;
5346
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
4623
5347
  var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
4624
5348
  var __hasOwnProp$d = Object.prototype.hasOwnProperty;
4625
5349
  var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
4626
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5350
+ var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4627
5351
  var __spreadValues$c = (a, b) => {
4628
5352
  for (var prop in b || (b = {}))
4629
5353
  if (__hasOwnProp$d.call(b, prop))
4630
- __defNormalProp$j(a, prop, b[prop]);
5354
+ __defNormalProp$k(a, prop, b[prop]);
4631
5355
  if (__getOwnPropSymbols$d)
4632
5356
  for (var prop of __getOwnPropSymbols$d(b)) {
4633
5357
  if (__propIsEnum$d.call(b, prop))
4634
- __defNormalProp$j(a, prop, b[prop]);
5358
+ __defNormalProp$k(a, prop, b[prop]);
4635
5359
  }
4636
5360
  return a;
4637
5361
  };
4638
- var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
4639
- var __async$d = (__this, __arguments, generator) => {
5362
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
5363
+ var __publicField$e = (obj, key, value) => __defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
5364
+ var __async$e = (__this, __arguments, generator) => {
4640
5365
  return new Promise((resolve, reject) => {
4641
5366
  var fulfilled = (value) => {
4642
5367
  try {
@@ -4660,11 +5385,11 @@ var NgwMap = (function (exports) {
4660
5385
  constructor(webMap, item, options, connector, parent, noInit) {
4661
5386
  super(__spreadValues$c(__spreadValues$c({}, _NgwWebmapItem.options), options));
4662
5387
  this.webMap = webMap;
4663
- __publicField$d(this, "item");
4664
- __publicField$d(this, "connector");
4665
- __publicField$d(this, "layer");
4666
- __publicField$d(this, "emitter", new EventEmitter());
4667
- __publicField$d(this, "_rootDescendantsCount", 0);
5388
+ __publicField$e(this, "item");
5389
+ __publicField$e(this, "connector");
5390
+ __publicField$e(this, "layer");
5391
+ __publicField$e(this, "emitter", new EventEmitter());
5392
+ __publicField$e(this, "_rootDescendantsCount", 0);
4668
5393
  if (connector) {
4669
5394
  this.connector = connector;
4670
5395
  }
@@ -4686,7 +5411,7 @@ var NgwMap = (function (exports) {
4686
5411
  }
4687
5412
  }
4688
5413
  static create(webMap, item, options, connector, parent) {
4689
- return __async$d(this, null, function* () {
5414
+ return __async$e(this, null, function* () {
4690
5415
  const ngwWebmapItem = new _NgwWebmapItem(
4691
5416
  webMap,
4692
5417
  item,
@@ -4715,21 +5440,21 @@ var NgwMap = (function (exports) {
4715
5440
  return this.layer;
4716
5441
  }
4717
5442
  getLegend(options) {
4718
- return __async$d(this, null, function* () {
5443
+ return __async$e(this, null, function* () {
4719
5444
  var _a;
4720
5445
  const id = (_a = this.layer) == null ? void 0 : _a.id;
4721
5446
  if (id !== void 0) {
4722
5447
  const connector = this.connector;
4723
- if (connector) {
4724
- const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$c({
4725
- params: { id: this.item.resourceId }
4726
- }, options));
5448
+ if (connector && "resourceId" in this.item) {
5449
+ const ngwLegend = yield connector.route("render.legend_symbols", { id: Number(this.item.resourceId) }).get(__spreadValues$c({}, options));
4727
5450
  const legend = {
4728
5451
  layerId: id,
4729
- legend: ngwLegend.map(({ display_name, icon }) => ({
4730
- name: display_name,
4731
- symbol: icon
4732
- }))
5452
+ legend: ngwLegend.map((legend2) => __spreadValues$c({
5453
+ /** @deprecated use display_name instead */
5454
+ name: legend2.display_name,
5455
+ /** @deprecated use icon instead */
5456
+ symbol: legend2.icon
5457
+ }, legend2))
4733
5458
  };
4734
5459
  return [legend];
4735
5460
  }
@@ -4740,16 +5465,18 @@ var NgwMap = (function (exports) {
4740
5465
  getItemOptions(item) {
4741
5466
  const transparency = item.item_type === "layer" && item.layer_transparency;
4742
5467
  const opacity = typeof transparency === "number" ? (100 - transparency) / 100 : void 0;
4743
- const options = {
5468
+ const options = __spreadProps$6(__spreadValues$c({
4744
5469
  visibility: false,
4745
- name: item.display_name,
4746
- headers: this.options.headers,
4747
- crossOrigin: this.options.crossOrigin,
4748
- setViewDelay: this.options.setViewDelay,
4749
- params: { resource: this.item.resourceId, item: this.item }
4750
- };
5470
+ name: item.display_name
5471
+ }, this.options), {
5472
+ params: {
5473
+ resource: "resourceId" in this.item ? this.item.resourceId : void 0,
5474
+ item: this.item
5475
+ }
5476
+ });
5477
+ delete options.id;
4751
5478
  if (this.options.order) {
4752
- const subOrder = this.options.drawOrderEnabled && "draw_order_position" in item ? this._rootDescendantsCount - item.draw_order_position : this.id;
5479
+ const subOrder = this.options.drawOrderEnabled && "draw_order_position" in item && item.draw_order_position !== void 0 && item.draw_order_position !== null ? this._rootDescendantsCount - item.draw_order_position : this.id;
4753
5480
  const subLevel = String(subOrder).padStart(4, "0");
4754
5481
  options.order = Number((this.options.order | 0) + "." + subLevel);
4755
5482
  }
@@ -4758,17 +5485,16 @@ var NgwMap = (function (exports) {
4758
5485
  }
4759
5486
  if (item.item_type === "layer") {
4760
5487
  const { maxZoom, minZoom } = this._getZoomRange(item);
4761
- Object.assign(options, {
4762
- updateWmsParams: item.updateWmsParams,
5488
+ Object.assign(options, __spreadProps$6(__spreadValues$c({
5489
+ updateWmsParams: item.updateWmsParams
5490
+ }, options), {
4763
5491
  url: item.url,
4764
- headers: this.options.headers,
4765
- ratio: this.options.ratio,
4766
5492
  maxZoom,
4767
5493
  minZoom,
4768
5494
  minScale: item.layer_min_scale_denom,
4769
5495
  maxScale: item.layer_max_scale_denom,
4770
5496
  interactive: item.layer_identifiable
4771
- });
5497
+ }));
4772
5498
  }
4773
5499
  if (opacity !== void 0) {
4774
5500
  options.opacity = opacity;
@@ -4806,7 +5532,7 @@ var NgwMap = (function (exports) {
4806
5532
  if (enabled) {
4807
5533
  this.properties.set("visibility", true);
4808
5534
  }
4809
- if (options.opacity !== void 0) {
5535
+ if (options.opacity !== void 0 && options.opacity !== null) {
4810
5536
  this.webMap.setLayerOpacity(l, options.opacity);
4811
5537
  }
4812
5538
  };
@@ -4855,8 +5581,8 @@ var NgwMap = (function (exports) {
4855
5581
  return totalValue;
4856
5582
  }
4857
5583
  };
4858
- __publicField$d(_NgwWebmapItem, "GetAdapterFromLayerType", {});
4859
- __publicField$d(_NgwWebmapItem, "options", {
5584
+ __publicField$e(_NgwWebmapItem, "GetAdapterFromLayerType", {});
5585
+ __publicField$e(_NgwWebmapItem, "options", {
4860
5586
  properties: [
4861
5587
  {
4862
5588
  type: "boolean",
@@ -4896,24 +5622,24 @@ var NgwMap = (function (exports) {
4896
5622
  });
4897
5623
  let NgwWebmapItem = _NgwWebmapItem;
4898
5624
 
4899
- var __defProp$i = Object.defineProperty;
5625
+ var __defProp$j = Object.defineProperty;
4900
5626
  var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
4901
5627
  var __hasOwnProp$c = Object.prototype.hasOwnProperty;
4902
5628
  var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
4903
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5629
+ var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4904
5630
  var __spreadValues$b = (a, b) => {
4905
5631
  for (var prop in b || (b = {}))
4906
5632
  if (__hasOwnProp$c.call(b, prop))
4907
- __defNormalProp$i(a, prop, b[prop]);
5633
+ __defNormalProp$j(a, prop, b[prop]);
4908
5634
  if (__getOwnPropSymbols$c)
4909
5635
  for (var prop of __getOwnPropSymbols$c(b)) {
4910
5636
  if (__propIsEnum$c.call(b, prop))
4911
- __defNormalProp$i(a, prop, b[prop]);
5637
+ __defNormalProp$j(a, prop, b[prop]);
4912
5638
  }
4913
5639
  return a;
4914
5640
  };
4915
- var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
4916
- var __async$c = (__this, __arguments, generator) => {
5641
+ var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
5642
+ var __async$d = (__this, __arguments, generator) => {
4917
5643
  return new Promise((resolve, reject) => {
4918
5644
  var fulfilled = (value) => {
4919
5645
  try {
@@ -4934,7 +5660,7 @@ var NgwMap = (function (exports) {
4934
5660
  });
4935
5661
  };
4936
5662
  function createOnFirstShowAdapter(_0) {
4937
- return __async$c(this, arguments, function* ({
5663
+ return __async$d(this, arguments, function* ({
4938
5664
  webMap,
4939
5665
  adapterOptions = {},
4940
5666
  onLayerAdded,
@@ -4942,10 +5668,10 @@ var NgwMap = (function (exports) {
4942
5668
  }) {
4943
5669
  class OnFirstShowAdapter {
4944
5670
  constructor() {
4945
- __publicField$c(this, "options", {});
4946
- __publicField$c(this, "layer", []);
4947
- __publicField$c(this, "_removed", false);
4948
- __publicField$c(this, "_creatingInProgress", false);
5671
+ __publicField$d(this, "options", {});
5672
+ __publicField$d(this, "layer", []);
5673
+ __publicField$d(this, "_removed", false);
5674
+ __publicField$d(this, "_creatingInProgress", false);
4949
5675
  }
4950
5676
  addLayer() {
4951
5677
  return this.layer;
@@ -4960,7 +5686,7 @@ var NgwMap = (function (exports) {
4960
5686
  return this._removed;
4961
5687
  }
4962
5688
  showLayer() {
4963
- return __async$c(this, null, function* () {
5689
+ return __async$d(this, null, function* () {
4964
5690
  this.options.visibility = true;
4965
5691
  if (this.layer.length) {
4966
5692
  for (const x of this.layer) {
@@ -4972,7 +5698,7 @@ var NgwMap = (function (exports) {
4972
5698
  });
4973
5699
  }
4974
5700
  hideLayer() {
4975
- return __async$c(this, null, function* () {
5701
+ return __async$d(this, null, function* () {
4976
5702
  this.options.visibility = false;
4977
5703
  if (this.layer) {
4978
5704
  for (const x of this.layer) {
@@ -4982,7 +5708,7 @@ var NgwMap = (function (exports) {
4982
5708
  });
4983
5709
  }
4984
5710
  loadLayer() {
4985
- return __async$c(this, null, function* () {
5711
+ return __async$d(this, null, function* () {
4986
5712
  if (!this.layer.length && !this._creatingInProgress) {
4987
5713
  this._creatingInProgress = true;
4988
5714
  const Adapter = yield createAdapter(this);
@@ -5016,7 +5742,7 @@ var NgwMap = (function (exports) {
5016
5742
  });
5017
5743
  }
5018
5744
 
5019
- var __async$b = (__this, __arguments, generator) => {
5745
+ var __async$c = (__this, __arguments, generator) => {
5020
5746
  return new Promise((resolve, reject) => {
5021
5747
  var fulfilled = (value) => {
5022
5748
  try {
@@ -5037,7 +5763,7 @@ var NgwMap = (function (exports) {
5037
5763
  });
5038
5764
  };
5039
5765
  function createOnFirstShowNgwAdapter(_0) {
5040
- return __async$b(this, arguments, function* ({
5766
+ return __async$c(this, arguments, function* ({
5041
5767
  webMap,
5042
5768
  connector,
5043
5769
  item,
@@ -5073,24 +5799,27 @@ var NgwMap = (function (exports) {
5073
5799
 
5074
5800
  const WEBMAP_BASELAYER_ID_PREFIX = "webmap-baselayer";
5075
5801
 
5076
- var __defProp$h = Object.defineProperty;
5802
+ var __defProp$i = Object.defineProperty;
5803
+ var __defProps$5 = Object.defineProperties;
5804
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
5077
5805
  var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
5078
5806
  var __hasOwnProp$b = Object.prototype.hasOwnProperty;
5079
5807
  var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
5080
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5808
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5081
5809
  var __spreadValues$a = (a, b) => {
5082
5810
  for (var prop in b || (b = {}))
5083
5811
  if (__hasOwnProp$b.call(b, prop))
5084
- __defNormalProp$h(a, prop, b[prop]);
5812
+ __defNormalProp$i(a, prop, b[prop]);
5085
5813
  if (__getOwnPropSymbols$b)
5086
5814
  for (var prop of __getOwnPropSymbols$b(b)) {
5087
5815
  if (__propIsEnum$b.call(b, prop))
5088
- __defNormalProp$h(a, prop, b[prop]);
5816
+ __defNormalProp$i(a, prop, b[prop]);
5089
5817
  }
5090
5818
  return a;
5091
5819
  };
5092
- var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5093
- var __async$a = (__this, __arguments, generator) => {
5820
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
5821
+ var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5822
+ var __async$b = (__this, __arguments, generator) => {
5094
5823
  return new Promise((resolve, reject) => {
5095
5824
  var fulfilled = (value) => {
5096
5825
  try {
@@ -5114,21 +5843,20 @@ var NgwMap = (function (exports) {
5114
5843
  constructor(map, options) {
5115
5844
  this.map = map;
5116
5845
  this.options = options;
5117
- __publicField$b(this, "layer");
5118
- __publicField$b(this, "NgwWebmapItem", NgwWebmapItem);
5846
+ __publicField$c(this, "layer");
5847
+ __publicField$c(this, "NgwWebmapItem", NgwWebmapItem);
5119
5848
  /**
5120
5849
  * Radius for searching objects in pixels
5121
5850
  */
5122
- __publicField$b(this, "pixelRadius", 10);
5851
+ __publicField$c(this, "pixelRadius", 10);
5123
5852
  // webmapSettings.identify_radius,
5124
- __publicField$b(this, "resourceId");
5125
- __publicField$b(this, "webmapClassName", "webmap");
5126
- __publicField$b(this, "emitter", new EventEmitter());
5127
- __publicField$b(this, "_extent");
5128
- __publicField$b(this, "response");
5129
- __publicField$b(this, "_webmapLayersIds");
5130
- __publicField$b(this, "_webmapBaselayersIds", []);
5131
- __publicField$b(this, "_lastActiveBaselayer");
5853
+ __publicField$c(this, "resourceId");
5854
+ __publicField$c(this, "webmapClassName", "webmap");
5855
+ __publicField$c(this, "emitter", new EventEmitter());
5856
+ __publicField$c(this, "_extent");
5857
+ __publicField$c(this, "webmapResource");
5858
+ __publicField$c(this, "_webmapBaselayersIds", []);
5859
+ __publicField$c(this, "_lastActiveBaselayer");
5132
5860
  const r = options.resourceId;
5133
5861
  if (Array.isArray(r)) {
5134
5862
  this.resourceId = r[0];
@@ -5141,11 +5869,11 @@ var NgwMap = (function (exports) {
5141
5869
  }
5142
5870
  }
5143
5871
  addLayer(options) {
5144
- return __async$a(this, null, function* () {
5145
- var _a, _b;
5872
+ return __async$b(this, null, function* () {
5873
+ var _a;
5146
5874
  this.options = __spreadValues$a(__spreadValues$a({}, this.options), options);
5147
5875
  this.layer = yield this._getWebMapLayerItem();
5148
- const extentConstrained = (_b = (_a = this.response) == null ? void 0 : _a.webmap) == null ? void 0 : _b.extent_constrained;
5876
+ const extentConstrained = (_a = this.webmapResource) == null ? void 0 : _a.constraining_extent;
5149
5877
  if (this.options.useExtentConstrained && this._extent && extentConstrained) {
5150
5878
  this.options.webMap.setView({ maxBounds: this._extent });
5151
5879
  }
@@ -5170,25 +5898,24 @@ var NgwMap = (function (exports) {
5170
5898
  this.options.webMap.setView({ maxBounds: null });
5171
5899
  }
5172
5900
  delete this.layer;
5173
- delete this.response;
5174
- delete this._webmapLayersIds;
5901
+ delete this.webmapResource;
5175
5902
  }
5176
5903
  showLayer() {
5177
- return __async$a(this, null, function* () {
5904
+ return __async$b(this, null, function* () {
5178
5905
  if (this.layer && this.layer.properties) {
5179
5906
  return this.layer.properties.property("visibility").set(true);
5180
5907
  }
5181
5908
  });
5182
5909
  }
5183
5910
  hideLayer() {
5184
- return __async$a(this, null, function* () {
5911
+ return __async$b(this, null, function* () {
5185
5912
  if (this.layer && this.layer.properties) {
5186
5913
  return this.layer.properties.property("visibility").set(false);
5187
5914
  }
5188
5915
  });
5189
5916
  }
5190
5917
  setOpacity(val) {
5191
- return __async$a(this, null, function* () {
5918
+ return __async$b(this, null, function* () {
5192
5919
  if (this.layer && this.layer.properties) {
5193
5920
  return this.layer.properties.property("opacity").set(val);
5194
5921
  }
@@ -5199,7 +5926,7 @@ var NgwMap = (function (exports) {
5199
5926
  return this.getBounds();
5200
5927
  }
5201
5928
  getBounds() {
5202
- const webmap = this.response && this.response.webmap;
5929
+ const webmap = this.webmapResource;
5203
5930
  if (webmap) {
5204
5931
  return getNgwWebmapExtent(webmap);
5205
5932
  }
@@ -5208,8 +5935,8 @@ var NgwMap = (function (exports) {
5208
5935
  return this.layer && this.layer.tree.getDescendants() || [];
5209
5936
  }
5210
5937
  getBookmarksResourceId() {
5211
- const webmap = this.response && this.response.webmap;
5212
- if (webmap) {
5938
+ const webmap = this.webmapResource;
5939
+ if (webmap && webmap.bookmark_resource) {
5213
5940
  return webmap.bookmark_resource.id;
5214
5941
  }
5215
5942
  }
@@ -5248,7 +5975,7 @@ var NgwMap = (function (exports) {
5248
5975
  );
5249
5976
  }
5250
5977
  getLegend(options) {
5251
- return __async$a(this, null, function* () {
5978
+ return __async$b(this, null, function* () {
5252
5979
  const legends = [];
5253
5980
  let deps = this.getDependLayers();
5254
5981
  deps = deps.sort((a, b) => b.id - a.id);
@@ -5260,78 +5987,65 @@ var NgwMap = (function (exports) {
5260
5987
  });
5261
5988
  }
5262
5989
  getIdentificationIds(options) {
5263
- return __async$a(this, null, function* () {
5990
+ return __async$b(this, null, function* () {
5264
5991
  const visibleLayers = [];
5265
- let ids = this._webmapLayersIds;
5266
- if (!ids) {
5267
- ids = yield this._getWebMapIds(options);
5268
- this._webmapLayersIds = ids;
5269
- }
5270
- if (ids && ids.length) {
5271
- let deps = this.getDependLayers();
5272
- deps = deps.sort((a, b) => b.id - a.id);
5273
- deps.forEach((x) => {
5274
- const item = x.item;
5275
- const parentId = item.parentId;
5276
- if (parentId !== void 0 && item.item_type === "layer" && item.layer_identifiable) {
5277
- const visible = x.properties.property("visibility");
5278
- const isVisible = visible.get() && !visible.isBlocked();
5279
- if (isVisible) {
5280
- visibleLayers.push(parentId);
5281
- }
5992
+ let deps = this.getDependLayers();
5993
+ deps = deps.sort((a, b) => b.id - a.id);
5994
+ deps.forEach((x) => {
5995
+ const item = x.item;
5996
+ const parentId = "style_parent_id" in item ? item.style_parent_id : void 0;
5997
+ if (parentId !== void 0 && parentId !== null && item.item_type === "layer" && item.layer_identifiable) {
5998
+ const visible = x.properties.property("visibility");
5999
+ const isVisible = visible.get() && !visible.isBlocked();
6000
+ if (isVisible) {
6001
+ visibleLayers.push(parentId);
5282
6002
  }
5283
- });
5284
- }
6003
+ }
6004
+ });
5285
6005
  return visibleLayers;
5286
6006
  });
5287
6007
  }
5288
6008
  _getWebMapLayerItem() {
5289
- return __async$a(this, null, function* () {
5290
- if (this.resourceId) {
5291
- const webmap = yield this.getWebMapConfig(this.resourceId);
5292
- if (webmap && webmap.root_item) {
5293
- return new Promise((resolve) => {
5294
- const options = {};
5295
- if (this.options.connector && this.options.connector.options.auth) {
5296
- const headers = this.options.connector.getAuthorizationHeaders();
5297
- if (headers) {
5298
- options.headers = headers;
5299
- }
5300
- }
5301
- options.setViewDelay = this.options.setViewDelay;
5302
- options.order = this.options.order;
5303
- options.ratio = this.options.ratio;
5304
- options.crossOrigin = this.options.crossOrigin;
5305
- options.minZoom = this.options.minZoom;
5306
- options.maxZoom = this.options.maxZoom;
5307
- options.drawOrderEnabled = webmap.draw_order_enabled;
5308
- options.popupOptions = this.options.popupOptions;
5309
- const layer = new this.NgwWebmapItem(
5310
- this.options.webMap,
5311
- webmap.root_item,
5312
- options,
5313
- this.options.connector
5314
- );
5315
- layer.emitter.on("init", () => resolve(layer));
5316
- });
5317
- }
6009
+ return __async$b(this, null, function* () {
6010
+ if (!this.resourceId) {
6011
+ return void 0;
6012
+ }
6013
+ const webmap = yield this.getWebMapConfig(this.resourceId);
6014
+ if (!webmap || !webmap.root_item) {
6015
+ return void 0;
5318
6016
  }
6017
+ return new Promise((resolve) => {
6018
+ var _a;
6019
+ const connector = this.options.connector;
6020
+ const headers = (connector == null ? void 0 : connector.options.auth) ? connector.getAuthorizationHeaders() : void 0;
6021
+ const withCredentials = connector.withCredentials;
6022
+ const options = __spreadProps$5(__spreadValues$a({}, this.options), {
6023
+ withCredentials,
6024
+ headers,
6025
+ drawOrderEnabled: (_a = webmap.draw_order_enabled) != null ? _a : false
6026
+ });
6027
+ const layer = new this.NgwWebmapItem(
6028
+ this.options.webMap,
6029
+ webmap.root_item,
6030
+ options,
6031
+ connector
6032
+ );
6033
+ layer.emitter.on("init", () => {
6034
+ resolve(layer);
6035
+ });
6036
+ });
5319
6037
  });
5320
6038
  }
5321
6039
  getWebMapConfig(id) {
5322
- return __async$a(this, null, function* () {
6040
+ return __async$b(this, null, function* () {
6041
+ var _a;
5323
6042
  const data = yield this.options.connector.getResource(id);
5324
6043
  if (data) {
5325
- this.response = data;
5326
6044
  const webmap = data[this.webmapClassName];
6045
+ this.webmapResource = webmap;
5327
6046
  this._setupBaselayers(data);
5328
6047
  if (webmap) {
5329
- this._extent = [
5330
- webmap.extent_left,
5331
- webmap.extent_bottom,
5332
- webmap.extent_right,
5333
- webmap.extent_top
5334
- ];
6048
+ this._extent = (_a = webmap.initial_extent) != null ? _a : void 0;
5335
6049
  this._updateItemsParams(webmap.root_item, this.options.webMap, data);
5336
6050
  return webmap;
5337
6051
  }
@@ -5383,23 +6097,25 @@ var NgwMap = (function (exports) {
5383
6097
  _updateItemsParams(item, webMap, data) {
5384
6098
  if (item) {
5385
6099
  if (item.item_type === "group" || item.item_type === "root") {
5386
- if (item.children) {
5387
- item.children = item.children.map(
6100
+ if ("children" in item && item.children) {
6101
+ const children = item.children.map(
5388
6102
  (x) => this._updateItemsParams(x, webMap, data)
5389
6103
  );
6104
+ item.children = children;
5390
6105
  }
5391
6106
  if (item.item_type === "root") {
5392
6107
  item.display_name = data.resource.display_name;
5393
6108
  }
5394
6109
  } else if (item.item_type === "layer") {
6110
+ const layerItem = item;
5395
6111
  const url = fixUrlStr(
5396
6112
  this.options.connector.options.baseUrl + "/api/component/render/image"
5397
6113
  );
5398
- const resourceId = item.layer_style_id;
5399
- item.url = url;
5400
- item.resourceId = resourceId;
5401
- item.updateWmsParams = (params) => updateImageParams(params, resourceId);
5402
- const adapter = item.layer_adapter.toUpperCase();
6114
+ const resourceId = layerItem.layer_style_id;
6115
+ layerItem.url = url;
6116
+ layerItem.resourceId = resourceId;
6117
+ layerItem.updateWmsParams = (params) => updateImageParams(params, resourceId);
6118
+ const adapter = layerItem.layer_adapter.toUpperCase();
5403
6119
  const layerAdapterOptions = ngwApiToAdapterOptions({
5404
6120
  options: {
5405
6121
  adapter,
@@ -5408,56 +6124,31 @@ var NgwMap = (function (exports) {
5408
6124
  webMap,
5409
6125
  baseUrl: this.options.connector.options.baseUrl || ""
5410
6126
  });
5411
- item = __spreadValues$a(__spreadValues$a({}, item), layerAdapterOptions);
6127
+ item = __spreadValues$a(__spreadValues$a({}, layerItem), layerAdapterOptions);
5412
6128
  }
5413
6129
  }
5414
6130
  return item;
5415
6131
  }
5416
- _getWebMapIds(options) {
5417
- return __async$a(this, null, function* () {
5418
- const webMapItem = this.layer;
5419
- if (webMapItem && webMapItem.item.item_type === "root") {
5420
- const layers = webMapItem.tree.getDescendants();
5421
- const promises = [];
5422
- for (const x of layers) {
5423
- const item = x.item;
5424
- if (item.item_type === "layer") {
5425
- const id = item.layer_style_id;
5426
- const promise = this.options.connector.getResource(id, options).then((y) => {
5427
- if (y) {
5428
- const parentId = Number(y.resource.parent.id);
5429
- item.parentId = parentId;
5430
- return parentId;
5431
- }
5432
- });
5433
- promises.push(promise);
5434
- }
5435
- }
5436
- const ids = yield Promise.all(promises);
5437
- return ids.filter((x) => x !== void 0);
5438
- }
5439
- });
5440
- }
5441
6132
  }
5442
6133
 
5443
- var __defProp$g = Object.defineProperty;
6134
+ var __defProp$h = Object.defineProperty;
5444
6135
  var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
5445
6136
  var __hasOwnProp$a = Object.prototype.hasOwnProperty;
5446
6137
  var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
5447
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6138
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5448
6139
  var __spreadValues$9 = (a, b) => {
5449
6140
  for (var prop in b || (b = {}))
5450
6141
  if (__hasOwnProp$a.call(b, prop))
5451
- __defNormalProp$g(a, prop, b[prop]);
6142
+ __defNormalProp$h(a, prop, b[prop]);
5452
6143
  if (__getOwnPropSymbols$a)
5453
6144
  for (var prop of __getOwnPropSymbols$a(b)) {
5454
6145
  if (__propIsEnum$a.call(b, prop))
5455
- __defNormalProp$g(a, prop, b[prop]);
6146
+ __defNormalProp$h(a, prop, b[prop]);
5456
6147
  }
5457
6148
  return a;
5458
6149
  };
5459
- var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
5460
- var __async$9 = (__this, __arguments, generator) => {
6150
+ var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
6151
+ var __async$a = (__this, __arguments, generator) => {
5461
6152
  return new Promise((resolve, reject) => {
5462
6153
  var fulfilled = (value) => {
5463
6154
  try {
@@ -5480,9 +6171,9 @@ var NgwMap = (function (exports) {
5480
6171
  class NgwKit {
5481
6172
  constructor(options) {
5482
6173
  this.options = options;
5483
- __publicField$a(this, "url");
5484
- __publicField$a(this, "connector");
5485
- __publicField$a(this, "webMap");
6174
+ __publicField$b(this, "url");
6175
+ __publicField$b(this, "connector");
6176
+ __publicField$b(this, "webMap");
5486
6177
  if (this.options.connector) {
5487
6178
  this.url = this.options.connector.options.baseUrl || "";
5488
6179
  this.connector = this.options.connector;
@@ -5492,7 +6183,7 @@ var NgwMap = (function (exports) {
5492
6183
  } else {
5493
6184
  throw new Error("url is not defined");
5494
6185
  }
5495
- this.connector = new NgwConnector({
6186
+ this.connector = new NgwConnectorExtended({
5496
6187
  baseUrl: this.url,
5497
6188
  auth: this.options.auth
5498
6189
  });
@@ -5502,7 +6193,7 @@ var NgwMap = (function (exports) {
5502
6193
  classAdapters[cls] = adapter;
5503
6194
  }
5504
6195
  onLoadSync(webMap) {
5505
- return __async$9(this, null, function* () {
6196
+ return __async$a(this, null, function* () {
5506
6197
  if (this.options.resourceId && this.url) {
5507
6198
  const resourceIds = [this.options.resourceId];
5508
6199
  if (resourceIds.length) {
@@ -5543,37 +6234,57 @@ var NgwMap = (function (exports) {
5543
6234
  }
5544
6235
  }
5545
6236
 
5546
- var __defProp$f = Object.defineProperty;
6237
+ var __defProp$g = Object.defineProperty;
5547
6238
  var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
5548
6239
  var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
5549
6240
  var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
5550
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6241
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5551
6242
  var __spreadValues$8 = (a, b) => {
5552
6243
  for (var prop in b || (b = {}))
5553
6244
  if (__hasOwnProp$9.call(b, prop))
5554
- __defNormalProp$f(a, prop, b[prop]);
6245
+ __defNormalProp$g(a, prop, b[prop]);
5555
6246
  if (__getOwnPropSymbols$9)
5556
6247
  for (var prop of __getOwnPropSymbols$9(b)) {
5557
6248
  if (__propIsEnum$9.call(b, prop))
5558
- __defNormalProp$f(a, prop, b[prop]);
6249
+ __defNormalProp$g(a, prop, b[prop]);
5559
6250
  }
5560
6251
  return a;
5561
6252
  };
5562
- var __publicField$9 = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
6253
+ var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
6254
+ var __async$9 = (__this, __arguments, generator) => {
6255
+ return new Promise((resolve, reject) => {
6256
+ var fulfilled = (value) => {
6257
+ try {
6258
+ step(generator.next(value));
6259
+ } catch (e) {
6260
+ reject(e);
6261
+ }
6262
+ };
6263
+ var rejected = (value) => {
6264
+ try {
6265
+ step(generator.throw(value));
6266
+ } catch (e) {
6267
+ reject(e);
6268
+ }
6269
+ };
6270
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
6271
+ step((generator = generator.apply(__this, __arguments)).next());
6272
+ });
6273
+ };
5563
6274
  class IdentifyItem {
5564
6275
  constructor(options) {
5565
- __publicField$9(this, "id");
5566
- __publicField$9(this, "label");
5567
- __publicField$9(this, "layerId");
5568
- __publicField$9(this, "parent");
5569
- __publicField$9(this, "fields");
5570
- __publicField$9(this, "geom");
5571
- __publicField$9(this, "extensions");
5572
- __publicField$9(this, "connector");
5573
- __publicField$9(this, "_item");
5574
- __publicField$9(this, "_geojson");
5575
- __publicField$9(this, "_resource");
5576
- __publicField$9(this, "_extent");
6276
+ __publicField$a(this, "id");
6277
+ __publicField$a(this, "label");
6278
+ __publicField$a(this, "layerId");
6279
+ __publicField$a(this, "parent");
6280
+ __publicField$a(this, "fields");
6281
+ __publicField$a(this, "geom");
6282
+ __publicField$a(this, "extensions");
6283
+ __publicField$a(this, "connector");
6284
+ __publicField$a(this, "_item");
6285
+ __publicField$a(this, "_geojson");
6286
+ __publicField$a(this, "_resource");
6287
+ __publicField$a(this, "_extent");
5577
6288
  const f = options.feature;
5578
6289
  this.id = f.id;
5579
6290
  this.geom = f.geom;
@@ -5601,12 +6312,16 @@ var NgwMap = (function (exports) {
5601
6312
  });
5602
6313
  }
5603
6314
  resource(opt) {
5604
- if (this._resource) {
5605
- return Promise.resolve(this._resource.feature_layer);
5606
- }
5607
- return this.connector.getResource(this.layerId, opt).then((resp) => {
6315
+ return __async$9(this, null, function* () {
6316
+ if (this._resource && this._resource.feature_layer) {
6317
+ return this._resource.feature_layer;
6318
+ }
6319
+ const resp = yield this.connector.getResource(this.layerId, opt);
6320
+ if (!(resp == null ? void 0 : resp.feature_layer)) {
6321
+ throw new Error("Resource is not avector layer");
6322
+ }
5608
6323
  this._resource = resp;
5609
- return this._resource.feature_layer;
6324
+ return resp.feature_layer;
5610
6325
  });
5611
6326
  }
5612
6327
  getBounds(opt) {
@@ -5659,21 +6374,21 @@ var NgwMap = (function (exports) {
5659
6374
  });
5660
6375
  }
5661
6376
 
5662
- var __defProp$e = Object.defineProperty;
6377
+ var __defProp$f = Object.defineProperty;
5663
6378
  var __defProps$4 = Object.defineProperties;
5664
6379
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
5665
6380
  var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
5666
6381
  var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
5667
6382
  var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
5668
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6383
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5669
6384
  var __spreadValues$7 = (a, b) => {
5670
6385
  for (var prop in b || (b = {}))
5671
6386
  if (__hasOwnProp$8.call(b, prop))
5672
- __defNormalProp$e(a, prop, b[prop]);
6387
+ __defNormalProp$f(a, prop, b[prop]);
5673
6388
  if (__getOwnPropSymbols$8)
5674
6389
  for (var prop of __getOwnPropSymbols$8(b)) {
5675
6390
  if (__propIsEnum$8.call(b, prop))
5676
- __defNormalProp$e(a, prop, b[prop]);
6391
+ __defNormalProp$f(a, prop, b[prop]);
5677
6392
  }
5678
6393
  return a;
5679
6394
  };
@@ -5770,13 +6485,13 @@ var NgwMap = (function (exports) {
5770
6485
  if (!wkt) {
5771
6486
  throw new Error("Not valid geometry format to make intersection");
5772
6487
  }
5773
- const data = {
6488
+ const json = {
5774
6489
  geom: wkt,
5775
6490
  srs: 3857,
5776
6491
  layers
5777
6492
  };
5778
- return options.connector.post("feature_layer.identify", {
5779
- data,
6493
+ return options.connector.route("feature_layer.identify").post({
6494
+ json,
5780
6495
  signal,
5781
6496
  cache
5782
6497
  });
@@ -5836,9 +6551,11 @@ var NgwMap = (function (exports) {
5836
6551
  };
5837
6552
  function getCompanyLogo(connector, options) {
5838
6553
  return __async$7(this, null, function* () {
5839
- var _a;
5840
- const settings = yield connector.get("pyramid.settings", null, {
5841
- component: "pyramid"
6554
+ var _a, _b;
6555
+ const settings = yield connector.route("pyramid.settings").get({
6556
+ query: {
6557
+ component: "pyramid"
6558
+ }
5842
6559
  });
5843
6560
  if (settings && settings.company_logo && settings.company_logo.enabled) {
5844
6561
  const anchor = document.createElement("a");
@@ -5855,12 +6572,21 @@ var NgwMap = (function (exports) {
5855
6572
  img.style.maxWidth = "100px";
5856
6573
  img.src = "";
5857
6574
  try {
5858
- const src = yield connector.get("pyramid.company_logo", {
5859
- responseType: "blob"
5860
- });
5861
- const urlCreator = window.URL || window.webkitURL;
5862
- const imageUrl = urlCreator.createObjectURL(src);
5863
- img.src = imageUrl;
6575
+ const resp = yield connector.route("pyramid.csettings").get();
6576
+ const logo = (_b = resp.pyramid) == null ? void 0 : _b.header_logo;
6577
+ if (logo) {
6578
+ const [mimeType, base64Data] = logo;
6579
+ const byteCharacters = atob(base64Data);
6580
+ const byteNumbers = new Array(byteCharacters.length);
6581
+ for (let i = 0; i < byteCharacters.length; i++) {
6582
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
6583
+ }
6584
+ const byteArray = new Uint8Array(byteNumbers);
6585
+ const blob = new Blob([byteArray], { type: mimeType });
6586
+ const urlCreator = window.URL || window.webkitURL;
6587
+ const imageUrl = urlCreator.createObjectURL(blob);
6588
+ img.src = imageUrl;
6589
+ }
5864
6590
  } catch (er) {
5865
6591
  console.warn(er);
5866
6592
  }
@@ -6517,19 +7243,19 @@ var NgwMap = (function (exports) {
6517
7243
  typeof: evaluateArgs(([arg]) => typeOfValue(arg))
6518
7244
  };
6519
7245
 
6520
- var __defProp$d = Object.defineProperty;
7246
+ var __defProp$e = Object.defineProperty;
6521
7247
  var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
6522
7248
  var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
6523
7249
  var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
6524
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7250
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6525
7251
  var __spreadValues$6 = (a, b) => {
6526
7252
  for (var prop in b || (b = {}))
6527
7253
  if (__hasOwnProp$7.call(b, prop))
6528
- __defNormalProp$d(a, prop, b[prop]);
7254
+ __defNormalProp$e(a, prop, b[prop]);
6529
7255
  if (__getOwnPropSymbols$7)
6530
7256
  for (var prop of __getOwnPropSymbols$7(b)) {
6531
7257
  if (__propIsEnum$7.call(b, prop))
6532
- __defNormalProp$d(a, prop, b[prop]);
7258
+ __defNormalProp$e(a, prop, b[prop]);
6533
7259
  }
6534
7260
  return a;
6535
7261
  };
@@ -6554,19 +7280,19 @@ var NgwMap = (function (exports) {
6554
7280
  throw new Error(`Expression "${name}" is not supported.`);
6555
7281
  }
6556
7282
 
6557
- var __defProp$c = Object.defineProperty;
7283
+ var __defProp$d = Object.defineProperty;
6558
7284
  var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
6559
7285
  var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
6560
7286
  var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
6561
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7287
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6562
7288
  var __spreadValues$5 = (a, b) => {
6563
7289
  for (var prop in b || (b = {}))
6564
7290
  if (__hasOwnProp$6.call(b, prop))
6565
- __defNormalProp$c(a, prop, b[prop]);
7291
+ __defNormalProp$d(a, prop, b[prop]);
6566
7292
  if (__getOwnPropSymbols$6)
6567
7293
  for (var prop of __getOwnPropSymbols$6(b)) {
6568
7294
  if (__propIsEnum$6.call(b, prop))
6569
- __defNormalProp$c(a, prop, b[prop]);
7295
+ __defNormalProp$d(a, prop, b[prop]);
6570
7296
  }
6571
7297
  return a;
6572
7298
  };
@@ -6605,19 +7331,19 @@ var NgwMap = (function (exports) {
6605
7331
  return;
6606
7332
  }
6607
7333
 
6608
- var __defProp$b = Object.defineProperty;
7334
+ var __defProp$c = Object.defineProperty;
6609
7335
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
6610
7336
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
6611
7337
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
6612
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7338
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6613
7339
  var __spreadValues$4 = (a, b) => {
6614
7340
  for (var prop in b || (b = {}))
6615
7341
  if (__hasOwnProp$5.call(b, prop))
6616
- __defNormalProp$b(a, prop, b[prop]);
7342
+ __defNormalProp$c(a, prop, b[prop]);
6617
7343
  if (__getOwnPropSymbols$5)
6618
7344
  for (var prop of __getOwnPropSymbols$5(b)) {
6619
7345
  if (__propIsEnum$5.call(b, prop))
6620
- __defNormalProp$b(a, prop, b[prop]);
7346
+ __defNormalProp$c(a, prop, b[prop]);
6621
7347
  }
6622
7348
  return a;
6623
7349
  };
@@ -6741,95 +7467,95 @@ var NgwMap = (function (exports) {
6741
7467
  return newPaint;
6742
7468
  }
6743
7469
 
6744
- var __defProp$a = Object.defineProperty;
6745
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6746
- var __publicField$8 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
7470
+ var __defProp$b = Object.defineProperty;
7471
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7472
+ var __publicField$9 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
6747
7473
  class KeyCodes {
6748
7474
  constructor() {
6749
- __publicField$8(this, "backspace", 8);
6750
- __publicField$8(this, "tab", 9);
6751
- __publicField$8(this, "enter", 13);
6752
- __publicField$8(this, "shift", 16);
6753
- __publicField$8(this, "ctrl", 17);
6754
- __publicField$8(this, "alt", 18);
6755
- __publicField$8(this, "pause/break", 19);
6756
- __publicField$8(this, "caps_lock", 20);
6757
- __publicField$8(this, "escape", 27);
6758
- __publicField$8(this, "page_up", 33);
6759
- __publicField$8(this, "page_down", 34);
6760
- __publicField$8(this, "end", 35);
6761
- __publicField$8(this, "home", 36);
6762
- __publicField$8(this, "left_arrow", 37);
6763
- __publicField$8(this, "up_arrow", 38);
6764
- __publicField$8(this, "right_arrow", 39);
6765
- __publicField$8(this, "down_arrow", 40);
6766
- __publicField$8(this, "insert", 45);
6767
- __publicField$8(this, "delete", 46);
6768
- __publicField$8(this, "left_window_key", 91);
6769
- __publicField$8(this, "right_window_key", 92);
6770
- __publicField$8(this, "select_key", 93);
6771
- __publicField$8(this, "numpad_0", 96);
6772
- __publicField$8(this, "numpad_1", 97);
6773
- __publicField$8(this, "numpad_2", 98);
6774
- __publicField$8(this, "numpad_3", 99);
6775
- __publicField$8(this, "numpad_4", 100);
6776
- __publicField$8(this, "numpad_5", 101);
6777
- __publicField$8(this, "numpad_6", 102);
6778
- __publicField$8(this, "numpad_7", 103);
6779
- __publicField$8(this, "numpad_8", 104);
6780
- __publicField$8(this, "numpad_9", 105);
6781
- __publicField$8(this, "multiply", 106);
6782
- __publicField$8(this, "add", 107);
6783
- __publicField$8(this, "subtract", 109);
6784
- __publicField$8(this, "decimal_point", 110);
6785
- __publicField$8(this, "divide", 111);
6786
- __publicField$8(this, "f1", 112);
6787
- __publicField$8(this, "f2", 113);
6788
- __publicField$8(this, "f3", 114);
6789
- __publicField$8(this, "f4", 115);
6790
- __publicField$8(this, "f5", 116);
6791
- __publicField$8(this, "f6", 117);
6792
- __publicField$8(this, "f7", 118);
6793
- __publicField$8(this, "f8", 119);
6794
- __publicField$8(this, "f9", 120);
6795
- __publicField$8(this, "f10", 121);
6796
- __publicField$8(this, "f11", 122);
6797
- __publicField$8(this, "f12", 123);
6798
- __publicField$8(this, "num_lock", 144);
6799
- __publicField$8(this, "scroll_lock", 145);
6800
- __publicField$8(this, "semi-colon", 186);
6801
- __publicField$8(this, "equal_sign", 187);
6802
- __publicField$8(this, ",", 188);
7475
+ __publicField$9(this, "backspace", 8);
7476
+ __publicField$9(this, "tab", 9);
7477
+ __publicField$9(this, "enter", 13);
7478
+ __publicField$9(this, "shift", 16);
7479
+ __publicField$9(this, "ctrl", 17);
7480
+ __publicField$9(this, "alt", 18);
7481
+ __publicField$9(this, "pause/break", 19);
7482
+ __publicField$9(this, "caps_lock", 20);
7483
+ __publicField$9(this, "escape", 27);
7484
+ __publicField$9(this, "page_up", 33);
7485
+ __publicField$9(this, "page_down", 34);
7486
+ __publicField$9(this, "end", 35);
7487
+ __publicField$9(this, "home", 36);
7488
+ __publicField$9(this, "left_arrow", 37);
7489
+ __publicField$9(this, "up_arrow", 38);
7490
+ __publicField$9(this, "right_arrow", 39);
7491
+ __publicField$9(this, "down_arrow", 40);
7492
+ __publicField$9(this, "insert", 45);
7493
+ __publicField$9(this, "delete", 46);
7494
+ __publicField$9(this, "left_window_key", 91);
7495
+ __publicField$9(this, "right_window_key", 92);
7496
+ __publicField$9(this, "select_key", 93);
7497
+ __publicField$9(this, "numpad_0", 96);
7498
+ __publicField$9(this, "numpad_1", 97);
7499
+ __publicField$9(this, "numpad_2", 98);
7500
+ __publicField$9(this, "numpad_3", 99);
7501
+ __publicField$9(this, "numpad_4", 100);
7502
+ __publicField$9(this, "numpad_5", 101);
7503
+ __publicField$9(this, "numpad_6", 102);
7504
+ __publicField$9(this, "numpad_7", 103);
7505
+ __publicField$9(this, "numpad_8", 104);
7506
+ __publicField$9(this, "numpad_9", 105);
7507
+ __publicField$9(this, "multiply", 106);
7508
+ __publicField$9(this, "add", 107);
7509
+ __publicField$9(this, "subtract", 109);
7510
+ __publicField$9(this, "decimal_point", 110);
7511
+ __publicField$9(this, "divide", 111);
7512
+ __publicField$9(this, "f1", 112);
7513
+ __publicField$9(this, "f2", 113);
7514
+ __publicField$9(this, "f3", 114);
7515
+ __publicField$9(this, "f4", 115);
7516
+ __publicField$9(this, "f5", 116);
7517
+ __publicField$9(this, "f6", 117);
7518
+ __publicField$9(this, "f7", 118);
7519
+ __publicField$9(this, "f8", 119);
7520
+ __publicField$9(this, "f9", 120);
7521
+ __publicField$9(this, "f10", 121);
7522
+ __publicField$9(this, "f11", 122);
7523
+ __publicField$9(this, "f12", 123);
7524
+ __publicField$9(this, "num_lock", 144);
7525
+ __publicField$9(this, "scroll_lock", 145);
7526
+ __publicField$9(this, "semi-colon", 186);
7527
+ __publicField$9(this, "equal_sign", 187);
7528
+ __publicField$9(this, ",", 188);
6803
7529
  // "comma";
6804
- __publicField$8(this, "-", 189);
7530
+ __publicField$9(this, "-", 189);
6805
7531
  // "dash";
6806
- __publicField$8(this, ".", 190);
7532
+ __publicField$9(this, ".", 190);
6807
7533
  // "period";
6808
- __publicField$8(this, "/", 191);
7534
+ __publicField$9(this, "/", 191);
6809
7535
  // "forward slash";
6810
- __publicField$8(this, "`", 192);
7536
+ __publicField$9(this, "`", 192);
6811
7537
  // "grave accent";
6812
- __publicField$8(this, "[", 219);
7538
+ __publicField$9(this, "[", 219);
6813
7539
  // "open bracket";
6814
- __publicField$8(this, "\\", 220);
7540
+ __publicField$9(this, "\\", 220);
6815
7541
  // "back slash";
6816
- __publicField$8(this, "]", 221);
7542
+ __publicField$9(this, "]", 221);
6817
7543
  // "close braket";
6818
- __publicField$8(this, "'", 222);
7544
+ __publicField$9(this, "'", 222);
6819
7545
  }
6820
7546
  // "single quote"
6821
7547
  }
6822
7548
 
6823
- var __defProp$9 = Object.defineProperty;
6824
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6825
- var __publicField$7 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
7549
+ var __defProp$a = Object.defineProperty;
7550
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7551
+ var __publicField$8 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
6826
7552
  class Keys {
6827
7553
  constructor() {
6828
- __publicField$7(this, "keyCodeAlias", new KeyCodes());
6829
- __publicField$7(this, "keys", {});
6830
- __publicField$7(this, "_windowOnFocus");
6831
- __publicField$7(this, "_keysPressed");
6832
- __publicField$7(this, "_keysReleased");
7554
+ __publicField$8(this, "keyCodeAlias", new KeyCodes());
7555
+ __publicField$8(this, "keys", {});
7556
+ __publicField$8(this, "_windowOnFocus");
7557
+ __publicField$8(this, "_keysPressed");
7558
+ __publicField$8(this, "_keysReleased");
6833
7559
  this._windowOnFocus = this.windowOnFocus.bind(this);
6834
7560
  this._keysPressed = this.keysPressed.bind(this);
6835
7561
  this._keysReleased = this.keysReleased.bind(this);
@@ -6868,15 +7594,15 @@ var NgwMap = (function (exports) {
6868
7594
  }
6869
7595
  }
6870
7596
 
6871
- var __defProp$8 = Object.defineProperty;
6872
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6873
- var __publicField$6 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
7597
+ var __defProp$9 = Object.defineProperty;
7598
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7599
+ var __publicField$7 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
6874
7600
  class StateItem {
6875
7601
  constructor(webMap, opt) {
6876
7602
  this.webMap = webMap;
6877
- __publicField$6(this, "name");
6878
- __publicField$6(this, "event");
6879
- __publicField$6(this, "value");
7603
+ __publicField$7(this, "name");
7604
+ __publicField$7(this, "event");
7605
+ __publicField$7(this, "value");
6880
7606
  if (opt) {
6881
7607
  if (opt.value) {
6882
7608
  this.setValue(opt.value);
@@ -6885,7 +7611,11 @@ var NgwMap = (function (exports) {
6885
7611
  this.name = opt.name;
6886
7612
  }
6887
7613
  if (opt.event) {
6888
- this.event = opt.event;
7614
+ if (typeof opt.event === "string") {
7615
+ this.event = [opt.event];
7616
+ } else {
7617
+ this.event = opt.event;
7618
+ }
6889
7619
  }
6890
7620
  }
6891
7621
  }
@@ -6897,6 +7627,34 @@ var NgwMap = (function (exports) {
6897
7627
  }
6898
7628
  }
6899
7629
 
7630
+ var __defProp$8 = Object.defineProperty;
7631
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7632
+ var __publicField$6 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
7633
+ class BoundState extends StateItem {
7634
+ constructor() {
7635
+ super(...arguments);
7636
+ __publicField$6(this, "name", "bounds");
7637
+ __publicField$6(this, "event", ["moveend"]);
7638
+ }
7639
+ getValue() {
7640
+ return this.webMap.getBounds();
7641
+ }
7642
+ setValue(bounds) {
7643
+ this.webMap.setView({ bounds });
7644
+ }
7645
+ toString() {
7646
+ const data = this.getValue();
7647
+ if (data) {
7648
+ return data.slice(0, 4).map((x) => x.toFixed(5)).join("_");
7649
+ }
7650
+ return void 0;
7651
+ }
7652
+ parse(str) {
7653
+ const lngLat = str.split("_").map(Number);
7654
+ return lngLat;
7655
+ }
7656
+ }
7657
+
6900
7658
  var __defProp$7 = Object.defineProperty;
6901
7659
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6902
7660
  var __publicField$5 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -6904,7 +7662,7 @@ var NgwMap = (function (exports) {
6904
7662
  constructor() {
6905
7663
  super(...arguments);
6906
7664
  __publicField$5(this, "name", "center");
6907
- __publicField$5(this, "event", "moveend");
7665
+ __publicField$5(this, "event", ["moveend"]);
6908
7666
  }
6909
7667
  getValue() {
6910
7668
  return this.webMap.getCenter();
@@ -6912,9 +7670,13 @@ var NgwMap = (function (exports) {
6912
7670
  setValue(val) {
6913
7671
  this.webMap.setCenter(val);
6914
7672
  }
6915
- toString(data) {
6916
- const d = data.map((x) => x.toFixed(5));
6917
- return d[0] + "_" + d[1];
7673
+ toString() {
7674
+ const data = this.getValue();
7675
+ if (data) {
7676
+ const d = data.map((x) => x.toFixed(5));
7677
+ return d[0] + "_" + d[1];
7678
+ }
7679
+ return "";
6918
7680
  }
6919
7681
  parse(str) {
6920
7682
  const lngLat = str.split("_").map(Number);
@@ -6929,7 +7691,7 @@ var NgwMap = (function (exports) {
6929
7691
  constructor() {
6930
7692
  super(...arguments);
6931
7693
  __publicField$4(this, "name", "zoom");
6932
- __publicField$4(this, "event", "zoomend");
7694
+ __publicField$4(this, "event", ["zoomend"]);
6933
7695
  }
6934
7696
  getValue() {
6935
7697
  const zoom = this.webMap.getZoom();
@@ -6938,8 +7700,8 @@ var NgwMap = (function (exports) {
6938
7700
  setValue(val) {
6939
7701
  this.webMap.setZoom(val);
6940
7702
  }
6941
- toString(val) {
6942
- return String(val);
7703
+ toString() {
7704
+ return String(this.getValue());
6943
7705
  }
6944
7706
  parse(str) {
6945
7707
  return Number(str);
@@ -7008,14 +7770,14 @@ var NgwMap = (function (exports) {
7008
7770
  __publicField$3(this, "mapAdapter");
7009
7771
  __publicField$3(this, "runtimeParams", []);
7010
7772
  __publicField$3(this, "getPaintFunctions", _WebMapMain.getPaintFunctions);
7011
- __publicField$3(this, "mapState", [CenterState, ZoomState]);
7773
+ __publicField$3(this, "mapStateItems", [CenterState, ZoomState, BoundState]);
7012
7774
  __publicField$3(this, "id", ID++);
7013
7775
  /**
7014
7776
  * From runtime params
7015
7777
  */
7778
+ __publicField$3(this, "mapState", []);
7016
7779
  __publicField$3(this, "_initMapState", {});
7017
7780
  __publicField$3(this, "_starterKits");
7018
- __publicField$3(this, "_mapState", []);
7019
7781
  __publicField$3(this, "_extent");
7020
7782
  __publicField$3(this, "_eventsStatus", {});
7021
7783
  __publicField$3(this, "_coordFromMapClickAbort");
@@ -7050,7 +7812,7 @@ var NgwMap = (function (exports) {
7050
7812
  create() {
7051
7813
  return __async$6(this, null, function* () {
7052
7814
  if (!this.getEventStatus("create")) {
7053
- yield this._setInitMapState(this.mapState);
7815
+ yield this._setInitMapState(this.mapStateItems);
7054
7816
  yield this._setupMap();
7055
7817
  this._emitStatusEvent("create", this);
7056
7818
  }
@@ -7070,16 +7832,22 @@ var NgwMap = (function (exports) {
7070
7832
  this.mapAdapter.destroy();
7071
7833
  }
7072
7834
  }
7073
- getState() {
7835
+ mapStateWithFunc(func) {
7074
7836
  const state = {};
7075
- this._mapState.forEach((x) => {
7076
- state[x.name] = x.getValue();
7837
+ this.mapState.forEach((x) => {
7838
+ state[x.name] = func(x);
7077
7839
  });
7078
7840
  return state;
7079
7841
  }
7842
+ getStateAsString() {
7843
+ return this.mapStateWithFunc((x) => x.toString());
7844
+ }
7845
+ getState() {
7846
+ return this.mapStateWithFunc((x) => x.getValue());
7847
+ }
7080
7848
  getRuntimeParams() {
7081
7849
  const state = {};
7082
- this._mapState.forEach((x) => {
7850
+ this.mapState.forEach((x) => {
7083
7851
  for (const r of this.runtimeParams) {
7084
7852
  const val = r.get(x.name);
7085
7853
  if (val !== void 0) {
@@ -7113,9 +7881,11 @@ var NgwMap = (function (exports) {
7113
7881
  * @param cursor - Available cursor name from https://developer.mozilla.org/ru/docs/Web/CSS/cursor
7114
7882
  */
7115
7883
  setCursor(cursor) {
7116
- if (this.mapAdapter.setCursor) {
7117
- this.mapAdapter.setCursor(cursor);
7118
- }
7884
+ this.onLoad().then(() => {
7885
+ if (this.mapAdapter.setCursor) {
7886
+ this.mapAdapter.setCursor(cursor);
7887
+ }
7888
+ });
7119
7889
  }
7120
7890
  getCursor() {
7121
7891
  if (this.mapAdapter.getCursor) {
@@ -7421,7 +8191,7 @@ var NgwMap = (function (exports) {
7421
8191
  _setInitMapState(states) {
7422
8192
  for (const X of states) {
7423
8193
  const state = new X(this);
7424
- this._mapState.push(state);
8194
+ this.mapState.push(state);
7425
8195
  for (const r of this.runtimeParams) {
7426
8196
  const str = r.get(state.name);
7427
8197
  if (str !== void 0) {
@@ -7457,13 +8227,15 @@ var NgwMap = (function (exports) {
7457
8227
  events.forEach((x) => {
7458
8228
  this._mapEvents[x] = (data) => {
7459
8229
  if (this.runtimeParams.length) {
7460
- const mapStatusEvent = this._mapState.find((y) => y.event === x);
7461
- if (mapStatusEvent) {
7462
- const value = mapStatusEvent.toString(mapStatusEvent.getValue());
8230
+ const mapStatusEvents = this.mapState.filter(
8231
+ (y) => y.event.includes(x)
8232
+ );
8233
+ mapStatusEvents.forEach((mapStatusEvent) => {
8234
+ const value = mapStatusEvent.toString();
7463
8235
  this.runtimeParams.forEach((r) => {
7464
8236
  r.set(mapStatusEvent.name, value);
7465
8237
  });
7466
- }
8238
+ });
7467
8239
  }
7468
8240
  if (this._eventsStatus) {
7469
8241
  this.emitter.emit(x, data);
@@ -7808,7 +8580,7 @@ var NgwMap = (function (exports) {
7808
8580
  }
7809
8581
  }
7810
8582
  const opacity = options.opacity;
7811
- if (opacity !== void 0 && opacity <= 1) {
8583
+ if (opacity !== void 0 && opacity !== null && opacity <= 1) {
7812
8584
  this.setLayerOpacity(_adapter, opacity);
7813
8585
  }
7814
8586
  const getBounds = layer && (_adapter.getBounds || _adapter.getExtent);
@@ -8039,11 +8811,11 @@ var NgwMap = (function (exports) {
8039
8811
  }
8040
8812
  return Promise.resolve();
8041
8813
  }
8042
- updateLayer(layerDef) {
8814
+ updateLayer(layerDef, options) {
8043
8815
  const layer = this.getLayer(layerDef);
8044
8816
  if (layer) {
8045
8817
  if (layer.updateLayer) {
8046
- return Promise.resolve(layer.updateLayer());
8818
+ return Promise.resolve(layer.updateLayer(options));
8047
8819
  } else if (this.isLayerVisible(layer)) {
8048
8820
  return this.hideLayer(layer, { silent: true }).then(() => {
8049
8821
  return this.showLayer(layer, { silent: true });
@@ -8960,9 +9732,10 @@ var NgwMap = (function (exports) {
8960
9732
  });
8961
9733
  }
8962
9734
  if (!options.connector) {
8963
- options.connector = new NgwConnector({
9735
+ options.connector = new NgwConnectorExtended({
8964
9736
  baseUrl: options.baseUrl || "",
8965
- auth: options.auth
9737
+ auth: options.auth,
9738
+ withCredentials: options.withCredentials
8966
9739
  });
8967
9740
  } else if (options.connector) {
8968
9741
  options.baseUrl = options.connector.options.baseUrl;
@@ -9191,8 +9964,16 @@ var NgwMap = (function (exports) {
9191
9964
  this._addPromise("identify", promise, abortController);
9192
9965
  return promise;
9193
9966
  }
9194
- fetchIdentifyGeoJson(identify, multiple = false) {
9967
+ fetchIdentifyGeoJson(identify, { multiple, signal } = {}) {
9195
9968
  const abortController = new AbortController();
9969
+ if (signal) {
9970
+ if (signal.aborted) {
9971
+ return Promise.reject(new NgwConnectorExtended.errors.AbortError());
9972
+ }
9973
+ signal.addEventListener("abort", () => {
9974
+ abortController.abort("AbortError");
9975
+ });
9976
+ }
9196
9977
  const promise = fetchIdentifyGeoJson({
9197
9978
  identify,
9198
9979
  connector: this.connector,
@@ -9210,7 +9991,7 @@ var NgwMap = (function (exports) {
9210
9991
  * @deprecated use {@link fetchIdentifyGeoJson} instead
9211
9992
  */
9212
9993
  getIdentifyGeoJson(identify, multiple = false) {
9213
- return this.fetchIdentifyGeoJson(identify, multiple);
9994
+ return this.fetchIdentifyGeoJson(identify, { multiple });
9214
9995
  }
9215
9996
  getNgwLayers() {
9216
9997
  return __async$1(this, null, function* () {
@@ -9233,7 +10014,7 @@ var NgwMap = (function (exports) {
9233
10014
  if (mem.layer.getDependLayers) {
9234
10015
  const dependLayers = mem.layer.getDependLayers();
9235
10016
  const dependFit = dependLayers.find((x) => {
9236
- return x.item && x.item.parentId === id;
10017
+ return x.item && "style_parent_id" in x.item && x.item.style_parent_id !== void 0 && x.item.style_parent_id === id;
9237
10018
  });
9238
10019
  if (dependFit) {
9239
10020
  return dependFit.layer;
@@ -9276,14 +10057,7 @@ var NgwMap = (function (exports) {
9276
10057
  item = yield this.connector.getResource(resourceId);
9277
10058
  }
9278
10059
  if (item) {
9279
- fetchNgwExtent({
9280
- resourceId: item.resource.id,
9281
- connector: this.connector
9282
- }).then((extent) => {
9283
- if (extent) {
9284
- this.fitBounds(extent, options);
9285
- }
9286
- });
10060
+ this.fitResource(item.resource.id);
9287
10061
  }
9288
10062
  }
9289
10063
  } else {
@@ -9295,6 +10069,18 @@ var NgwMap = (function (exports) {
9295
10069
  }
9296
10070
  });
9297
10071
  }
10072
+ fitResource(resource, options) {
10073
+ return __async$1(this, null, function* () {
10074
+ const resourceId = yield this.connector.resources.getIdOrFail(resource);
10075
+ const extent = yield fetchNgwExtent({
10076
+ resourceId,
10077
+ connector: this.connector
10078
+ });
10079
+ if (extent) {
10080
+ this.fitBounds(extent, options);
10081
+ }
10082
+ });
10083
+ }
9298
10084
  /** @deprecated use {@link fitLayer} instead */
9299
10085
  zoomToLayer(layerDef) {
9300
10086
  return __async$1(this, null, function* () {
@@ -9474,8 +10260,7 @@ var NgwMap = (function (exports) {
9474
10260
  group.splice(index, 1);
9475
10261
  }
9476
10262
  };
9477
- promise.then(removeFromGroup);
9478
- promise.catch(removeFromGroup);
10263
+ promise.then(removeFromGroup, removeFromGroup);
9479
10264
  group.push([promise, abortController]);
9480
10265
  }
9481
10266
  }