@tomtom-org/maps-sdk 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE.txt +164 -0
- package/README.md +154 -0
- package/core/dist/THIRD_PARTY.txt +61 -0
- package/core/dist/core.cjs.js +515 -0
- package/core/dist/core.cjs.js.map +1 -0
- package/core/dist/core.cjs.min.js +2 -0
- package/core/dist/core.cjs.min.js.map +1 -0
- package/core/dist/core.es.js +2 -0
- package/core/dist/core.es.js.map +1 -0
- package/core/dist/index.d.ts +4674 -0
- package/core/main.js +6 -0
- package/core/package.json +50 -0
- package/map/dist/THIRD_PARTY.txt +346 -0
- package/map/dist/index.d.ts +8511 -0
- package/map/dist/map.cjs.js +7346 -0
- package/map/dist/map.cjs.js.map +1 -0
- package/map/dist/map.cjs.min.js +2 -0
- package/map/dist/map.cjs.min.js.map +1 -0
- package/map/dist/map.es.js +2 -0
- package/map/dist/map.es.js.map +1 -0
- package/map/main.js +6 -0
- package/map/package.json +53 -0
- package/package.json +87 -0
- package/sdk-examples-collage.png +0 -0
- package/services/dist/THIRD_PARTY.txt +96 -0
- package/services/dist/index.d.ts +6985 -0
- package/services/dist/services.cjs.js +5009 -0
- package/services/dist/services.cjs.js.map +1 -0
- package/services/dist/services.cjs.min.js +2 -0
- package/services/dist/services.cjs.min.js.map +1 -0
- package/services/dist/services.es.js +2 -0
- package/services/dist/services.es.js.map +1 -0
- package/services/main.js +6 -0
- package/services/package.json +51 -0
- package/tomtom-logo-big.svg +6 -0
|
@@ -0,0 +1,5009 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const core = require("@tomtom-org/maps-sdk/core");
|
|
4
|
+
var APICode = /* @__PURE__ */ ((APICode2) => {
|
|
5
|
+
APICode2[APICode2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
6
|
+
APICode2[APICode2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
7
|
+
return APICode2;
|
|
8
|
+
})(APICode || {});
|
|
9
|
+
class SDKError extends Error {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new SDKError instance.
|
|
12
|
+
*
|
|
13
|
+
* @param message - Human-readable error description
|
|
14
|
+
* @param service - Name of the service where the error occurred
|
|
15
|
+
* @param issues - Optional array of Zod validation issues for detailed error information
|
|
16
|
+
*/
|
|
17
|
+
constructor(message, service, issues) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.service = service;
|
|
20
|
+
this.issues = issues;
|
|
21
|
+
if (Error.captureStackTrace) {
|
|
22
|
+
Error.captureStackTrace(this, SDKError);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const APIErrorCode = {
|
|
27
|
+
[APICode.TOO_MANY_REQUESTS]: "Too Many Requests: The API Key is over QPS (Queries per second)",
|
|
28
|
+
[APICode.FORBIDDEN]: "Request failed with status code 403"
|
|
29
|
+
};
|
|
30
|
+
class SDKServiceError extends SDKError {
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new SDKServiceError instance.
|
|
33
|
+
*
|
|
34
|
+
* If the status code matches a known error in {@link APIErrorCode},
|
|
35
|
+
* the message will be automatically replaced with the standardized message.
|
|
36
|
+
*
|
|
37
|
+
* @param message - Error message from the API or custom message
|
|
38
|
+
* @param service - Name of the service that generated the error
|
|
39
|
+
* @param status - HTTP status code of the failed request
|
|
40
|
+
*/
|
|
41
|
+
constructor(message, service, status) {
|
|
42
|
+
super(message, service);
|
|
43
|
+
this.status = status;
|
|
44
|
+
if (this.status && APIErrorCode[this.status]) {
|
|
45
|
+
this.message = APIErrorCode[this.status];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const parseDefaultResponseError = (error, serviceName) => {
|
|
50
|
+
const { data, message, status } = error;
|
|
51
|
+
const errorMessage = data?.error || data?.errorText || message;
|
|
52
|
+
return new SDKServiceError(errorMessage, serviceName, status);
|
|
53
|
+
};
|
|
54
|
+
const buildResponseError = (error, serviceName, parseResponseError) => {
|
|
55
|
+
if (error.status) {
|
|
56
|
+
const fetchError = error;
|
|
57
|
+
if (parseResponseError) {
|
|
58
|
+
return parseResponseError(fetchError, serviceName);
|
|
59
|
+
}
|
|
60
|
+
return parseDefaultResponseError(fetchError, serviceName);
|
|
61
|
+
}
|
|
62
|
+
return new SDKError(error.message, serviceName);
|
|
63
|
+
};
|
|
64
|
+
const buildValidationError = (error, serviceName) => new SDKError(error.message, serviceName, error.issues);
|
|
65
|
+
function $constructor(name, initializer2, params) {
|
|
66
|
+
function init(inst, def) {
|
|
67
|
+
var _a;
|
|
68
|
+
Object.defineProperty(inst, "_zod", {
|
|
69
|
+
value: inst._zod ?? {},
|
|
70
|
+
enumerable: false
|
|
71
|
+
});
|
|
72
|
+
(_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
|
|
73
|
+
inst._zod.traits.add(name);
|
|
74
|
+
initializer2(inst, def);
|
|
75
|
+
for (const k in _.prototype) {
|
|
76
|
+
if (!(k in inst))
|
|
77
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
78
|
+
}
|
|
79
|
+
inst._zod.constr = _;
|
|
80
|
+
inst._zod.def = def;
|
|
81
|
+
}
|
|
82
|
+
const Parent = params?.Parent ?? Object;
|
|
83
|
+
class Definition extends Parent {
|
|
84
|
+
}
|
|
85
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
86
|
+
function _(def) {
|
|
87
|
+
var _a;
|
|
88
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
89
|
+
init(inst, def);
|
|
90
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
91
|
+
for (const fn of inst._zod.deferred) {
|
|
92
|
+
fn();
|
|
93
|
+
}
|
|
94
|
+
return inst;
|
|
95
|
+
}
|
|
96
|
+
Object.defineProperty(_, "init", { value: init });
|
|
97
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
98
|
+
value: (inst) => {
|
|
99
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
100
|
+
return true;
|
|
101
|
+
return inst?._zod?.traits?.has(name);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(_, "name", { value: name });
|
|
105
|
+
return _;
|
|
106
|
+
}
|
|
107
|
+
class $ZodAsyncError extends Error {
|
|
108
|
+
constructor() {
|
|
109
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const globalConfig = {};
|
|
113
|
+
function config(newConfig) {
|
|
114
|
+
return globalConfig;
|
|
115
|
+
}
|
|
116
|
+
function getEnumValues(entries) {
|
|
117
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
118
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
119
|
+
return values;
|
|
120
|
+
}
|
|
121
|
+
function jsonStringifyReplacer(_, value) {
|
|
122
|
+
if (typeof value === "bigint")
|
|
123
|
+
return value.toString();
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
function cached(getter) {
|
|
127
|
+
return {
|
|
128
|
+
get value() {
|
|
129
|
+
{
|
|
130
|
+
const value = getter();
|
|
131
|
+
Object.defineProperty(this, "value", { value });
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function nullish(input) {
|
|
138
|
+
return input === null || input === void 0;
|
|
139
|
+
}
|
|
140
|
+
function cleanRegex(source) {
|
|
141
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
142
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
143
|
+
return source.slice(start, end);
|
|
144
|
+
}
|
|
145
|
+
const EVALUATING = Symbol("evaluating");
|
|
146
|
+
function defineLazy(object2, key, getter) {
|
|
147
|
+
let value = void 0;
|
|
148
|
+
Object.defineProperty(object2, key, {
|
|
149
|
+
get() {
|
|
150
|
+
if (value === EVALUATING) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
if (value === void 0) {
|
|
154
|
+
value = EVALUATING;
|
|
155
|
+
value = getter();
|
|
156
|
+
}
|
|
157
|
+
return value;
|
|
158
|
+
},
|
|
159
|
+
set(v) {
|
|
160
|
+
Object.defineProperty(object2, key, {
|
|
161
|
+
value: v
|
|
162
|
+
// configurable: true,
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
configurable: true
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function assignProp(target, prop, value) {
|
|
169
|
+
Object.defineProperty(target, prop, {
|
|
170
|
+
value,
|
|
171
|
+
writable: true,
|
|
172
|
+
enumerable: true,
|
|
173
|
+
configurable: true
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function mergeDefs(...defs) {
|
|
177
|
+
const mergedDescriptors = {};
|
|
178
|
+
for (const def of defs) {
|
|
179
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
180
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
181
|
+
}
|
|
182
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
183
|
+
}
|
|
184
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
185
|
+
};
|
|
186
|
+
function isObject$1(data) {
|
|
187
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
188
|
+
}
|
|
189
|
+
function isPlainObject$1(o) {
|
|
190
|
+
if (isObject$1(o) === false)
|
|
191
|
+
return false;
|
|
192
|
+
const ctor = o.constructor;
|
|
193
|
+
if (ctor === void 0)
|
|
194
|
+
return true;
|
|
195
|
+
const prot = ctor.prototype;
|
|
196
|
+
if (isObject$1(prot) === false)
|
|
197
|
+
return false;
|
|
198
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
204
|
+
function escapeRegex(str) {
|
|
205
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
206
|
+
}
|
|
207
|
+
function clone(inst, def, params) {
|
|
208
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
209
|
+
if (!def || params?.parent)
|
|
210
|
+
cl._zod.parent = inst;
|
|
211
|
+
return cl;
|
|
212
|
+
}
|
|
213
|
+
function normalizeParams(_params) {
|
|
214
|
+
const params = _params;
|
|
215
|
+
if (!params)
|
|
216
|
+
return {};
|
|
217
|
+
if (typeof params === "string")
|
|
218
|
+
return { error: () => params };
|
|
219
|
+
if (params?.message !== void 0) {
|
|
220
|
+
if (params?.error !== void 0)
|
|
221
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
222
|
+
params.error = params.message;
|
|
223
|
+
}
|
|
224
|
+
delete params.message;
|
|
225
|
+
if (typeof params.error === "string")
|
|
226
|
+
return { ...params, error: () => params.error };
|
|
227
|
+
return params;
|
|
228
|
+
}
|
|
229
|
+
function optionalKeys(shape) {
|
|
230
|
+
return Object.keys(shape).filter((k) => {
|
|
231
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
function extend$1(schema, shape) {
|
|
235
|
+
if (!isPlainObject$1(shape)) {
|
|
236
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
237
|
+
}
|
|
238
|
+
const checks = schema._zod.def.checks;
|
|
239
|
+
const hasChecks = checks && checks.length > 0;
|
|
240
|
+
if (hasChecks) {
|
|
241
|
+
throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
|
|
242
|
+
}
|
|
243
|
+
const def = mergeDefs(schema._zod.def, {
|
|
244
|
+
get shape() {
|
|
245
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
246
|
+
assignProp(this, "shape", _shape);
|
|
247
|
+
return _shape;
|
|
248
|
+
},
|
|
249
|
+
checks: []
|
|
250
|
+
});
|
|
251
|
+
return clone(schema, def);
|
|
252
|
+
}
|
|
253
|
+
function partial$1(Class, schema, mask) {
|
|
254
|
+
const def = mergeDefs(schema._zod.def, {
|
|
255
|
+
get shape() {
|
|
256
|
+
const oldShape = schema._zod.def.shape;
|
|
257
|
+
const shape = { ...oldShape };
|
|
258
|
+
{
|
|
259
|
+
for (const key in oldShape) {
|
|
260
|
+
shape[key] = Class ? new Class({
|
|
261
|
+
type: "optional",
|
|
262
|
+
innerType: oldShape[key]
|
|
263
|
+
}) : oldShape[key];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
assignProp(this, "shape", shape);
|
|
267
|
+
return shape;
|
|
268
|
+
},
|
|
269
|
+
checks: []
|
|
270
|
+
});
|
|
271
|
+
return clone(schema, def);
|
|
272
|
+
}
|
|
273
|
+
function aborted(x, startIndex = 0) {
|
|
274
|
+
if (x.aborted === true)
|
|
275
|
+
return true;
|
|
276
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
277
|
+
if (x.issues[i]?.continue !== true) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
function prefixIssues(path, issues) {
|
|
284
|
+
return issues.map((iss) => {
|
|
285
|
+
var _a;
|
|
286
|
+
(_a = iss).path ?? (_a.path = []);
|
|
287
|
+
iss.path.unshift(path);
|
|
288
|
+
return iss;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function unwrapMessage(message) {
|
|
292
|
+
return typeof message === "string" ? message : message?.message;
|
|
293
|
+
}
|
|
294
|
+
function finalizeIssue(iss, ctx, config2) {
|
|
295
|
+
const full = { ...iss, path: iss.path ?? [] };
|
|
296
|
+
if (!iss.message) {
|
|
297
|
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
|
|
298
|
+
full.message = message;
|
|
299
|
+
}
|
|
300
|
+
delete full.inst;
|
|
301
|
+
delete full.continue;
|
|
302
|
+
if (!ctx?.reportInput) {
|
|
303
|
+
delete full.input;
|
|
304
|
+
}
|
|
305
|
+
return full;
|
|
306
|
+
}
|
|
307
|
+
function getLengthableOrigin(input) {
|
|
308
|
+
if (Array.isArray(input))
|
|
309
|
+
return "array";
|
|
310
|
+
if (typeof input === "string")
|
|
311
|
+
return "string";
|
|
312
|
+
return "unknown";
|
|
313
|
+
}
|
|
314
|
+
function issue(...args) {
|
|
315
|
+
const [iss, input, inst] = args;
|
|
316
|
+
if (typeof iss === "string") {
|
|
317
|
+
return {
|
|
318
|
+
message: iss,
|
|
319
|
+
code: "custom",
|
|
320
|
+
input,
|
|
321
|
+
inst
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
return { ...iss };
|
|
325
|
+
}
|
|
326
|
+
const initializer = (inst, def) => {
|
|
327
|
+
inst.name = "$ZodError";
|
|
328
|
+
Object.defineProperty(inst, "_zod", {
|
|
329
|
+
value: inst._zod,
|
|
330
|
+
enumerable: false
|
|
331
|
+
});
|
|
332
|
+
Object.defineProperty(inst, "issues", {
|
|
333
|
+
value: def,
|
|
334
|
+
enumerable: false
|
|
335
|
+
});
|
|
336
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
337
|
+
Object.defineProperty(inst, "toString", {
|
|
338
|
+
value: () => inst.message,
|
|
339
|
+
enumerable: false
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
const $ZodError = $constructor("$ZodError", initializer);
|
|
343
|
+
const $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
344
|
+
function toDotPath(_path) {
|
|
345
|
+
const segs = [];
|
|
346
|
+
const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
347
|
+
for (const seg of path) {
|
|
348
|
+
if (typeof seg === "number")
|
|
349
|
+
segs.push(`[${seg}]`);
|
|
350
|
+
else if (typeof seg === "symbol")
|
|
351
|
+
segs.push(`[${JSON.stringify(String(seg))}]`);
|
|
352
|
+
else if (/[^\w$]/.test(seg))
|
|
353
|
+
segs.push(`[${JSON.stringify(seg)}]`);
|
|
354
|
+
else {
|
|
355
|
+
if (segs.length)
|
|
356
|
+
segs.push(".");
|
|
357
|
+
segs.push(seg);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return segs.join("");
|
|
361
|
+
}
|
|
362
|
+
function prettifyError(error) {
|
|
363
|
+
const lines = [];
|
|
364
|
+
const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
|
|
365
|
+
for (const issue2 of issues) {
|
|
366
|
+
lines.push(`✖ ${issue2.message}`);
|
|
367
|
+
if (issue2.path?.length)
|
|
368
|
+
lines.push(` → at ${toDotPath(issue2.path)}`);
|
|
369
|
+
}
|
|
370
|
+
return lines.join("\n");
|
|
371
|
+
}
|
|
372
|
+
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
373
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
374
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
375
|
+
if (result instanceof Promise) {
|
|
376
|
+
throw new $ZodAsyncError();
|
|
377
|
+
}
|
|
378
|
+
if (result.issues.length) {
|
|
379
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
380
|
+
captureStackTrace(e, _params?.callee);
|
|
381
|
+
throw e;
|
|
382
|
+
}
|
|
383
|
+
return result.value;
|
|
384
|
+
};
|
|
385
|
+
const parse = /* @__PURE__ */ _parse($ZodRealError);
|
|
386
|
+
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
387
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
388
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
389
|
+
if (result instanceof Promise)
|
|
390
|
+
result = await result;
|
|
391
|
+
if (result.issues.length) {
|
|
392
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
393
|
+
captureStackTrace(e, params?.callee);
|
|
394
|
+
throw e;
|
|
395
|
+
}
|
|
396
|
+
return result.value;
|
|
397
|
+
};
|
|
398
|
+
const parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
399
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
400
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
401
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
402
|
+
if (result instanceof Promise) {
|
|
403
|
+
throw new $ZodAsyncError();
|
|
404
|
+
}
|
|
405
|
+
return result.issues.length ? {
|
|
406
|
+
success: false,
|
|
407
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
408
|
+
} : { success: true, data: result.value };
|
|
409
|
+
};
|
|
410
|
+
const safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
411
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
412
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
413
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
414
|
+
if (result instanceof Promise)
|
|
415
|
+
result = await result;
|
|
416
|
+
return result.issues.length ? {
|
|
417
|
+
success: false,
|
|
418
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
419
|
+
} : { success: true, data: result.value };
|
|
420
|
+
};
|
|
421
|
+
const safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
422
|
+
const string$1 = (params) => {
|
|
423
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
424
|
+
return new RegExp(`^${regex}$`);
|
|
425
|
+
};
|
|
426
|
+
const number$1 = /^-?\d+(?:\.\d+)?/;
|
|
427
|
+
const boolean$1 = /^(?:true|false)$/i;
|
|
428
|
+
const _undefined$2 = /^undefined$/i;
|
|
429
|
+
const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
430
|
+
var _a;
|
|
431
|
+
inst._zod ?? (inst._zod = {});
|
|
432
|
+
inst._zod.def = def;
|
|
433
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
434
|
+
});
|
|
435
|
+
const numericOriginMap = {
|
|
436
|
+
number: "number",
|
|
437
|
+
bigint: "bigint",
|
|
438
|
+
object: "date"
|
|
439
|
+
};
|
|
440
|
+
const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
441
|
+
$ZodCheck.init(inst, def);
|
|
442
|
+
const origin = numericOriginMap[typeof def.value];
|
|
443
|
+
inst._zod.onattach.push((inst2) => {
|
|
444
|
+
const bag = inst2._zod.bag;
|
|
445
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
446
|
+
if (def.value < curr) {
|
|
447
|
+
if (def.inclusive)
|
|
448
|
+
bag.maximum = def.value;
|
|
449
|
+
else
|
|
450
|
+
bag.exclusiveMaximum = def.value;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
inst._zod.check = (payload) => {
|
|
454
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
payload.issues.push({
|
|
458
|
+
origin,
|
|
459
|
+
code: "too_big",
|
|
460
|
+
maximum: def.value,
|
|
461
|
+
input: payload.value,
|
|
462
|
+
inclusive: def.inclusive,
|
|
463
|
+
inst,
|
|
464
|
+
continue: !def.abort
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
});
|
|
468
|
+
const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
469
|
+
$ZodCheck.init(inst, def);
|
|
470
|
+
const origin = numericOriginMap[typeof def.value];
|
|
471
|
+
inst._zod.onattach.push((inst2) => {
|
|
472
|
+
const bag = inst2._zod.bag;
|
|
473
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
474
|
+
if (def.value > curr) {
|
|
475
|
+
if (def.inclusive)
|
|
476
|
+
bag.minimum = def.value;
|
|
477
|
+
else
|
|
478
|
+
bag.exclusiveMinimum = def.value;
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
inst._zod.check = (payload) => {
|
|
482
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
payload.issues.push({
|
|
486
|
+
origin,
|
|
487
|
+
code: "too_small",
|
|
488
|
+
minimum: def.value,
|
|
489
|
+
input: payload.value,
|
|
490
|
+
inclusive: def.inclusive,
|
|
491
|
+
inst,
|
|
492
|
+
continue: !def.abort
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
});
|
|
496
|
+
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
497
|
+
var _a;
|
|
498
|
+
$ZodCheck.init(inst, def);
|
|
499
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
500
|
+
const val = payload.value;
|
|
501
|
+
return !nullish(val) && val.length !== void 0;
|
|
502
|
+
});
|
|
503
|
+
inst._zod.onattach.push((inst2) => {
|
|
504
|
+
const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
505
|
+
if (def.maximum < curr)
|
|
506
|
+
inst2._zod.bag.maximum = def.maximum;
|
|
507
|
+
});
|
|
508
|
+
inst._zod.check = (payload) => {
|
|
509
|
+
const input = payload.value;
|
|
510
|
+
const length = input.length;
|
|
511
|
+
if (length <= def.maximum)
|
|
512
|
+
return;
|
|
513
|
+
const origin = getLengthableOrigin(input);
|
|
514
|
+
payload.issues.push({
|
|
515
|
+
origin,
|
|
516
|
+
code: "too_big",
|
|
517
|
+
maximum: def.maximum,
|
|
518
|
+
inclusive: true,
|
|
519
|
+
input,
|
|
520
|
+
inst,
|
|
521
|
+
continue: !def.abort
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
});
|
|
525
|
+
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
526
|
+
var _a;
|
|
527
|
+
$ZodCheck.init(inst, def);
|
|
528
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
529
|
+
const val = payload.value;
|
|
530
|
+
return !nullish(val) && val.length !== void 0;
|
|
531
|
+
});
|
|
532
|
+
inst._zod.onattach.push((inst2) => {
|
|
533
|
+
const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
534
|
+
if (def.minimum > curr)
|
|
535
|
+
inst2._zod.bag.minimum = def.minimum;
|
|
536
|
+
});
|
|
537
|
+
inst._zod.check = (payload) => {
|
|
538
|
+
const input = payload.value;
|
|
539
|
+
const length = input.length;
|
|
540
|
+
if (length >= def.minimum)
|
|
541
|
+
return;
|
|
542
|
+
const origin = getLengthableOrigin(input);
|
|
543
|
+
payload.issues.push({
|
|
544
|
+
origin,
|
|
545
|
+
code: "too_small",
|
|
546
|
+
minimum: def.minimum,
|
|
547
|
+
inclusive: true,
|
|
548
|
+
input,
|
|
549
|
+
inst,
|
|
550
|
+
continue: !def.abort
|
|
551
|
+
});
|
|
552
|
+
};
|
|
553
|
+
});
|
|
554
|
+
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
555
|
+
var _a;
|
|
556
|
+
$ZodCheck.init(inst, def);
|
|
557
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
558
|
+
const val = payload.value;
|
|
559
|
+
return !nullish(val) && val.length !== void 0;
|
|
560
|
+
});
|
|
561
|
+
inst._zod.onattach.push((inst2) => {
|
|
562
|
+
const bag = inst2._zod.bag;
|
|
563
|
+
bag.minimum = def.length;
|
|
564
|
+
bag.maximum = def.length;
|
|
565
|
+
bag.length = def.length;
|
|
566
|
+
});
|
|
567
|
+
inst._zod.check = (payload) => {
|
|
568
|
+
const input = payload.value;
|
|
569
|
+
const length = input.length;
|
|
570
|
+
if (length === def.length)
|
|
571
|
+
return;
|
|
572
|
+
const origin = getLengthableOrigin(input);
|
|
573
|
+
const tooBig = length > def.length;
|
|
574
|
+
payload.issues.push({
|
|
575
|
+
origin,
|
|
576
|
+
...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
|
|
577
|
+
inclusive: true,
|
|
578
|
+
exact: true,
|
|
579
|
+
input: payload.value,
|
|
580
|
+
inst,
|
|
581
|
+
continue: !def.abort
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
});
|
|
585
|
+
const version = {
|
|
586
|
+
major: 4,
|
|
587
|
+
minor: 1,
|
|
588
|
+
patch: 12
|
|
589
|
+
};
|
|
590
|
+
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
591
|
+
var _a;
|
|
592
|
+
inst ?? (inst = {});
|
|
593
|
+
inst._zod.def = def;
|
|
594
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
595
|
+
inst._zod.version = version;
|
|
596
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
597
|
+
if (inst._zod.traits.has("$ZodCheck")) {
|
|
598
|
+
checks.unshift(inst);
|
|
599
|
+
}
|
|
600
|
+
for (const ch of checks) {
|
|
601
|
+
for (const fn of ch._zod.onattach) {
|
|
602
|
+
fn(inst);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (checks.length === 0) {
|
|
606
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
607
|
+
inst._zod.deferred?.push(() => {
|
|
608
|
+
inst._zod.run = inst._zod.parse;
|
|
609
|
+
});
|
|
610
|
+
} else {
|
|
611
|
+
const runChecks = (payload, checks2, ctx) => {
|
|
612
|
+
let isAborted = aborted(payload);
|
|
613
|
+
let asyncResult;
|
|
614
|
+
for (const ch of checks2) {
|
|
615
|
+
if (ch._zod.def.when) {
|
|
616
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
617
|
+
if (!shouldRun)
|
|
618
|
+
continue;
|
|
619
|
+
} else if (isAborted) {
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
const currLen = payload.issues.length;
|
|
623
|
+
const _ = ch._zod.check(payload);
|
|
624
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
625
|
+
throw new $ZodAsyncError();
|
|
626
|
+
}
|
|
627
|
+
if (asyncResult || _ instanceof Promise) {
|
|
628
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
629
|
+
await _;
|
|
630
|
+
const nextLen = payload.issues.length;
|
|
631
|
+
if (nextLen === currLen)
|
|
632
|
+
return;
|
|
633
|
+
if (!isAborted)
|
|
634
|
+
isAborted = aborted(payload, currLen);
|
|
635
|
+
});
|
|
636
|
+
} else {
|
|
637
|
+
const nextLen = payload.issues.length;
|
|
638
|
+
if (nextLen === currLen)
|
|
639
|
+
continue;
|
|
640
|
+
if (!isAborted)
|
|
641
|
+
isAborted = aborted(payload, currLen);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (asyncResult) {
|
|
645
|
+
return asyncResult.then(() => {
|
|
646
|
+
return payload;
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
return payload;
|
|
650
|
+
};
|
|
651
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
652
|
+
if (aborted(canary)) {
|
|
653
|
+
canary.aborted = true;
|
|
654
|
+
return canary;
|
|
655
|
+
}
|
|
656
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
657
|
+
if (checkResult instanceof Promise) {
|
|
658
|
+
if (ctx.async === false)
|
|
659
|
+
throw new $ZodAsyncError();
|
|
660
|
+
return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
|
|
661
|
+
}
|
|
662
|
+
return inst._zod.parse(checkResult, ctx);
|
|
663
|
+
};
|
|
664
|
+
inst._zod.run = (payload, ctx) => {
|
|
665
|
+
if (ctx.skipChecks) {
|
|
666
|
+
return inst._zod.parse(payload, ctx);
|
|
667
|
+
}
|
|
668
|
+
if (ctx.direction === "backward") {
|
|
669
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
670
|
+
if (canary instanceof Promise) {
|
|
671
|
+
return canary.then((canary2) => {
|
|
672
|
+
return handleCanaryResult(canary2, payload, ctx);
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
676
|
+
}
|
|
677
|
+
const result = inst._zod.parse(payload, ctx);
|
|
678
|
+
if (result instanceof Promise) {
|
|
679
|
+
if (ctx.async === false)
|
|
680
|
+
throw new $ZodAsyncError();
|
|
681
|
+
return result.then((result2) => runChecks(result2, checks, ctx));
|
|
682
|
+
}
|
|
683
|
+
return runChecks(result, checks, ctx);
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
inst["~standard"] = {
|
|
687
|
+
validate: (value) => {
|
|
688
|
+
try {
|
|
689
|
+
const r = safeParse(inst, value);
|
|
690
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
691
|
+
} catch (_) {
|
|
692
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
vendor: "zod",
|
|
696
|
+
version: 1
|
|
697
|
+
};
|
|
698
|
+
});
|
|
699
|
+
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
700
|
+
$ZodType.init(inst, def);
|
|
701
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
702
|
+
inst._zod.parse = (payload, _) => {
|
|
703
|
+
if (def.coerce)
|
|
704
|
+
try {
|
|
705
|
+
payload.value = String(payload.value);
|
|
706
|
+
} catch (_2) {
|
|
707
|
+
}
|
|
708
|
+
if (typeof payload.value === "string")
|
|
709
|
+
return payload;
|
|
710
|
+
payload.issues.push({
|
|
711
|
+
expected: "string",
|
|
712
|
+
code: "invalid_type",
|
|
713
|
+
input: payload.value,
|
|
714
|
+
inst
|
|
715
|
+
});
|
|
716
|
+
return payload;
|
|
717
|
+
};
|
|
718
|
+
});
|
|
719
|
+
const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
720
|
+
$ZodType.init(inst, def);
|
|
721
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
|
|
722
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
723
|
+
if (def.coerce)
|
|
724
|
+
try {
|
|
725
|
+
payload.value = Number(payload.value);
|
|
726
|
+
} catch (_) {
|
|
727
|
+
}
|
|
728
|
+
const input = payload.value;
|
|
729
|
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
730
|
+
return payload;
|
|
731
|
+
}
|
|
732
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
733
|
+
payload.issues.push({
|
|
734
|
+
expected: "number",
|
|
735
|
+
code: "invalid_type",
|
|
736
|
+
input,
|
|
737
|
+
inst,
|
|
738
|
+
...received ? { received } : {}
|
|
739
|
+
});
|
|
740
|
+
return payload;
|
|
741
|
+
};
|
|
742
|
+
});
|
|
743
|
+
const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
744
|
+
$ZodType.init(inst, def);
|
|
745
|
+
inst._zod.pattern = boolean$1;
|
|
746
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
747
|
+
if (def.coerce)
|
|
748
|
+
try {
|
|
749
|
+
payload.value = Boolean(payload.value);
|
|
750
|
+
} catch (_) {
|
|
751
|
+
}
|
|
752
|
+
const input = payload.value;
|
|
753
|
+
if (typeof input === "boolean")
|
|
754
|
+
return payload;
|
|
755
|
+
payload.issues.push({
|
|
756
|
+
expected: "boolean",
|
|
757
|
+
code: "invalid_type",
|
|
758
|
+
input,
|
|
759
|
+
inst
|
|
760
|
+
});
|
|
761
|
+
return payload;
|
|
762
|
+
};
|
|
763
|
+
});
|
|
764
|
+
const $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) => {
|
|
765
|
+
$ZodType.init(inst, def);
|
|
766
|
+
inst._zod.pattern = _undefined$2;
|
|
767
|
+
inst._zod.values = /* @__PURE__ */ new Set([void 0]);
|
|
768
|
+
inst._zod.optin = "optional";
|
|
769
|
+
inst._zod.optout = "optional";
|
|
770
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
771
|
+
const input = payload.value;
|
|
772
|
+
if (typeof input === "undefined")
|
|
773
|
+
return payload;
|
|
774
|
+
payload.issues.push({
|
|
775
|
+
expected: "undefined",
|
|
776
|
+
code: "invalid_type",
|
|
777
|
+
input,
|
|
778
|
+
inst
|
|
779
|
+
});
|
|
780
|
+
return payload;
|
|
781
|
+
};
|
|
782
|
+
});
|
|
783
|
+
const $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
784
|
+
$ZodType.init(inst, def);
|
|
785
|
+
inst._zod.parse = (payload) => payload;
|
|
786
|
+
});
|
|
787
|
+
const $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
788
|
+
$ZodType.init(inst, def);
|
|
789
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
790
|
+
if (def.coerce) {
|
|
791
|
+
try {
|
|
792
|
+
payload.value = new Date(payload.value);
|
|
793
|
+
} catch (_err) {
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
const input = payload.value;
|
|
797
|
+
const isDate = input instanceof Date;
|
|
798
|
+
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
|
799
|
+
if (isValidDate)
|
|
800
|
+
return payload;
|
|
801
|
+
payload.issues.push({
|
|
802
|
+
expected: "date",
|
|
803
|
+
code: "invalid_type",
|
|
804
|
+
input,
|
|
805
|
+
...isDate ? { received: "Invalid Date" } : {},
|
|
806
|
+
inst
|
|
807
|
+
});
|
|
808
|
+
return payload;
|
|
809
|
+
};
|
|
810
|
+
});
|
|
811
|
+
function handleArrayResult(result, final, index) {
|
|
812
|
+
if (result.issues.length) {
|
|
813
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
814
|
+
}
|
|
815
|
+
final.value[index] = result.value;
|
|
816
|
+
}
|
|
817
|
+
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
818
|
+
$ZodType.init(inst, def);
|
|
819
|
+
inst._zod.parse = (payload, ctx) => {
|
|
820
|
+
const input = payload.value;
|
|
821
|
+
if (!Array.isArray(input)) {
|
|
822
|
+
payload.issues.push({
|
|
823
|
+
expected: "array",
|
|
824
|
+
code: "invalid_type",
|
|
825
|
+
input,
|
|
826
|
+
inst
|
|
827
|
+
});
|
|
828
|
+
return payload;
|
|
829
|
+
}
|
|
830
|
+
payload.value = Array(input.length);
|
|
831
|
+
const proms = [];
|
|
832
|
+
for (let i = 0; i < input.length; i++) {
|
|
833
|
+
const item = input[i];
|
|
834
|
+
const result = def.element._zod.run({
|
|
835
|
+
value: item,
|
|
836
|
+
issues: []
|
|
837
|
+
}, ctx);
|
|
838
|
+
if (result instanceof Promise) {
|
|
839
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
|
|
840
|
+
} else {
|
|
841
|
+
handleArrayResult(result, payload, i);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (proms.length) {
|
|
845
|
+
return Promise.all(proms).then(() => payload);
|
|
846
|
+
}
|
|
847
|
+
return payload;
|
|
848
|
+
};
|
|
849
|
+
});
|
|
850
|
+
function handlePropertyResult(result, final, key, input) {
|
|
851
|
+
if (result.issues.length) {
|
|
852
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
853
|
+
}
|
|
854
|
+
if (result.value === void 0) {
|
|
855
|
+
if (key in input) {
|
|
856
|
+
final.value[key] = void 0;
|
|
857
|
+
}
|
|
858
|
+
} else {
|
|
859
|
+
final.value[key] = result.value;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function normalizeDef(def) {
|
|
863
|
+
const keys = Object.keys(def.shape);
|
|
864
|
+
for (const k of keys) {
|
|
865
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
866
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
const okeys = optionalKeys(def.shape);
|
|
870
|
+
return {
|
|
871
|
+
...def,
|
|
872
|
+
keys,
|
|
873
|
+
keySet: new Set(keys),
|
|
874
|
+
numKeys: keys.length,
|
|
875
|
+
optionalKeys: new Set(okeys)
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
879
|
+
const unrecognized = [];
|
|
880
|
+
const keySet = def.keySet;
|
|
881
|
+
const _catchall = def.catchall._zod;
|
|
882
|
+
const t = _catchall.def.type;
|
|
883
|
+
for (const key of Object.keys(input)) {
|
|
884
|
+
if (keySet.has(key))
|
|
885
|
+
continue;
|
|
886
|
+
if (t === "never") {
|
|
887
|
+
unrecognized.push(key);
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
891
|
+
if (r instanceof Promise) {
|
|
892
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
893
|
+
} else {
|
|
894
|
+
handlePropertyResult(r, payload, key, input);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (unrecognized.length) {
|
|
898
|
+
payload.issues.push({
|
|
899
|
+
code: "unrecognized_keys",
|
|
900
|
+
keys: unrecognized,
|
|
901
|
+
input,
|
|
902
|
+
inst
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
if (!proms.length)
|
|
906
|
+
return payload;
|
|
907
|
+
return Promise.all(proms).then(() => {
|
|
908
|
+
return payload;
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
912
|
+
$ZodType.init(inst, def);
|
|
913
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
914
|
+
if (!desc?.get) {
|
|
915
|
+
const sh = def.shape;
|
|
916
|
+
Object.defineProperty(def, "shape", {
|
|
917
|
+
get: () => {
|
|
918
|
+
const newSh = { ...sh };
|
|
919
|
+
Object.defineProperty(def, "shape", {
|
|
920
|
+
value: newSh
|
|
921
|
+
});
|
|
922
|
+
return newSh;
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
927
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
928
|
+
const shape = def.shape;
|
|
929
|
+
const propValues = {};
|
|
930
|
+
for (const key in shape) {
|
|
931
|
+
const field = shape[key]._zod;
|
|
932
|
+
if (field.values) {
|
|
933
|
+
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
934
|
+
for (const v of field.values)
|
|
935
|
+
propValues[key].add(v);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return propValues;
|
|
939
|
+
});
|
|
940
|
+
const isObject2 = isObject$1;
|
|
941
|
+
const catchall = def.catchall;
|
|
942
|
+
let value;
|
|
943
|
+
inst._zod.parse = (payload, ctx) => {
|
|
944
|
+
value ?? (value = _normalized.value);
|
|
945
|
+
const input = payload.value;
|
|
946
|
+
if (!isObject2(input)) {
|
|
947
|
+
payload.issues.push({
|
|
948
|
+
expected: "object",
|
|
949
|
+
code: "invalid_type",
|
|
950
|
+
input,
|
|
951
|
+
inst
|
|
952
|
+
});
|
|
953
|
+
return payload;
|
|
954
|
+
}
|
|
955
|
+
payload.value = {};
|
|
956
|
+
const proms = [];
|
|
957
|
+
const shape = value.shape;
|
|
958
|
+
for (const key of value.keys) {
|
|
959
|
+
const el = shape[key];
|
|
960
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
961
|
+
if (r instanceof Promise) {
|
|
962
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
963
|
+
} else {
|
|
964
|
+
handlePropertyResult(r, payload, key, input);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
if (!catchall) {
|
|
968
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
969
|
+
}
|
|
970
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
971
|
+
};
|
|
972
|
+
});
|
|
973
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
974
|
+
for (const result of results) {
|
|
975
|
+
if (result.issues.length === 0) {
|
|
976
|
+
final.value = result.value;
|
|
977
|
+
return final;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
981
|
+
if (nonaborted.length === 1) {
|
|
982
|
+
final.value = nonaborted[0].value;
|
|
983
|
+
return nonaborted[0];
|
|
984
|
+
}
|
|
985
|
+
final.issues.push({
|
|
986
|
+
code: "invalid_union",
|
|
987
|
+
input: final.value,
|
|
988
|
+
inst,
|
|
989
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
990
|
+
});
|
|
991
|
+
return final;
|
|
992
|
+
}
|
|
993
|
+
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
994
|
+
$ZodType.init(inst, def);
|
|
995
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
996
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
997
|
+
defineLazy(inst._zod, "values", () => {
|
|
998
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
999
|
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1000
|
+
}
|
|
1001
|
+
return void 0;
|
|
1002
|
+
});
|
|
1003
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1004
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
1005
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1006
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1007
|
+
}
|
|
1008
|
+
return void 0;
|
|
1009
|
+
});
|
|
1010
|
+
const single = def.options.length === 1;
|
|
1011
|
+
const first = def.options[0]._zod.run;
|
|
1012
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1013
|
+
if (single) {
|
|
1014
|
+
return first(payload, ctx);
|
|
1015
|
+
}
|
|
1016
|
+
let async = false;
|
|
1017
|
+
const results = [];
|
|
1018
|
+
for (const option of def.options) {
|
|
1019
|
+
const result = option._zod.run({
|
|
1020
|
+
value: payload.value,
|
|
1021
|
+
issues: []
|
|
1022
|
+
}, ctx);
|
|
1023
|
+
if (result instanceof Promise) {
|
|
1024
|
+
results.push(result);
|
|
1025
|
+
async = true;
|
|
1026
|
+
} else {
|
|
1027
|
+
if (result.issues.length === 0)
|
|
1028
|
+
return result;
|
|
1029
|
+
results.push(result);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
if (!async)
|
|
1033
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
1034
|
+
return Promise.all(results).then((results2) => {
|
|
1035
|
+
return handleUnionResults(results2, payload, inst, ctx);
|
|
1036
|
+
});
|
|
1037
|
+
};
|
|
1038
|
+
});
|
|
1039
|
+
const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1040
|
+
$ZodUnion.init(inst, def);
|
|
1041
|
+
const _super = inst._zod.parse;
|
|
1042
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
1043
|
+
const propValues = {};
|
|
1044
|
+
for (const option of def.options) {
|
|
1045
|
+
const pv = option._zod.propValues;
|
|
1046
|
+
if (!pv || Object.keys(pv).length === 0)
|
|
1047
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
1048
|
+
for (const [k, v] of Object.entries(pv)) {
|
|
1049
|
+
if (!propValues[k])
|
|
1050
|
+
propValues[k] = /* @__PURE__ */ new Set();
|
|
1051
|
+
for (const val of v) {
|
|
1052
|
+
propValues[k].add(val);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
return propValues;
|
|
1057
|
+
});
|
|
1058
|
+
const disc = cached(() => {
|
|
1059
|
+
const opts = def.options;
|
|
1060
|
+
const map = /* @__PURE__ */ new Map();
|
|
1061
|
+
for (const o of opts) {
|
|
1062
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
1063
|
+
if (!values || values.size === 0)
|
|
1064
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
1065
|
+
for (const v of values) {
|
|
1066
|
+
if (map.has(v)) {
|
|
1067
|
+
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
1068
|
+
}
|
|
1069
|
+
map.set(v, o);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
return map;
|
|
1073
|
+
});
|
|
1074
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1075
|
+
const input = payload.value;
|
|
1076
|
+
if (!isObject$1(input)) {
|
|
1077
|
+
payload.issues.push({
|
|
1078
|
+
code: "invalid_type",
|
|
1079
|
+
expected: "object",
|
|
1080
|
+
input,
|
|
1081
|
+
inst
|
|
1082
|
+
});
|
|
1083
|
+
return payload;
|
|
1084
|
+
}
|
|
1085
|
+
const opt = disc.value.get(input?.[def.discriminator]);
|
|
1086
|
+
if (opt) {
|
|
1087
|
+
return opt._zod.run(payload, ctx);
|
|
1088
|
+
}
|
|
1089
|
+
if (def.unionFallback) {
|
|
1090
|
+
return _super(payload, ctx);
|
|
1091
|
+
}
|
|
1092
|
+
payload.issues.push({
|
|
1093
|
+
code: "invalid_union",
|
|
1094
|
+
errors: [],
|
|
1095
|
+
note: "No matching discriminator",
|
|
1096
|
+
discriminator: def.discriminator,
|
|
1097
|
+
input,
|
|
1098
|
+
path: [def.discriminator],
|
|
1099
|
+
inst
|
|
1100
|
+
});
|
|
1101
|
+
return payload;
|
|
1102
|
+
};
|
|
1103
|
+
});
|
|
1104
|
+
const $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
1105
|
+
$ZodType.init(inst, def);
|
|
1106
|
+
const items = def.items;
|
|
1107
|
+
const optStart = items.length - [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
|
|
1108
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1109
|
+
const input = payload.value;
|
|
1110
|
+
if (!Array.isArray(input)) {
|
|
1111
|
+
payload.issues.push({
|
|
1112
|
+
input,
|
|
1113
|
+
inst,
|
|
1114
|
+
expected: "tuple",
|
|
1115
|
+
code: "invalid_type"
|
|
1116
|
+
});
|
|
1117
|
+
return payload;
|
|
1118
|
+
}
|
|
1119
|
+
payload.value = [];
|
|
1120
|
+
const proms = [];
|
|
1121
|
+
if (!def.rest) {
|
|
1122
|
+
const tooBig = input.length > items.length;
|
|
1123
|
+
const tooSmall = input.length < optStart - 1;
|
|
1124
|
+
if (tooBig || tooSmall) {
|
|
1125
|
+
payload.issues.push({
|
|
1126
|
+
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
|
|
1127
|
+
input,
|
|
1128
|
+
inst,
|
|
1129
|
+
origin: "array"
|
|
1130
|
+
});
|
|
1131
|
+
return payload;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
let i = -1;
|
|
1135
|
+
for (const item of items) {
|
|
1136
|
+
i++;
|
|
1137
|
+
if (i >= input.length) {
|
|
1138
|
+
if (i >= optStart)
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
const result = item._zod.run({
|
|
1142
|
+
value: input[i],
|
|
1143
|
+
issues: []
|
|
1144
|
+
}, ctx);
|
|
1145
|
+
if (result instanceof Promise) {
|
|
1146
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
|
|
1147
|
+
} else {
|
|
1148
|
+
handleTupleResult(result, payload, i);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
if (def.rest) {
|
|
1152
|
+
const rest = input.slice(items.length);
|
|
1153
|
+
for (const el of rest) {
|
|
1154
|
+
i++;
|
|
1155
|
+
const result = def.rest._zod.run({
|
|
1156
|
+
value: el,
|
|
1157
|
+
issues: []
|
|
1158
|
+
}, ctx);
|
|
1159
|
+
if (result instanceof Promise) {
|
|
1160
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i)));
|
|
1161
|
+
} else {
|
|
1162
|
+
handleTupleResult(result, payload, i);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
if (proms.length)
|
|
1167
|
+
return Promise.all(proms).then(() => payload);
|
|
1168
|
+
return payload;
|
|
1169
|
+
};
|
|
1170
|
+
});
|
|
1171
|
+
function handleTupleResult(result, final, index) {
|
|
1172
|
+
if (result.issues.length) {
|
|
1173
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
1174
|
+
}
|
|
1175
|
+
final.value[index] = result.value;
|
|
1176
|
+
}
|
|
1177
|
+
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1178
|
+
$ZodType.init(inst, def);
|
|
1179
|
+
const values = getEnumValues(def.entries);
|
|
1180
|
+
const valuesSet = new Set(values);
|
|
1181
|
+
inst._zod.values = valuesSet;
|
|
1182
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1183
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1184
|
+
const input = payload.value;
|
|
1185
|
+
if (valuesSet.has(input)) {
|
|
1186
|
+
return payload;
|
|
1187
|
+
}
|
|
1188
|
+
payload.issues.push({
|
|
1189
|
+
code: "invalid_value",
|
|
1190
|
+
values,
|
|
1191
|
+
input,
|
|
1192
|
+
inst
|
|
1193
|
+
});
|
|
1194
|
+
return payload;
|
|
1195
|
+
};
|
|
1196
|
+
});
|
|
1197
|
+
const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
1198
|
+
$ZodType.init(inst, def);
|
|
1199
|
+
if (def.values.length === 0) {
|
|
1200
|
+
throw new Error("Cannot create literal schema with no valid values");
|
|
1201
|
+
}
|
|
1202
|
+
inst._zod.values = new Set(def.values);
|
|
1203
|
+
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
1204
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1205
|
+
const input = payload.value;
|
|
1206
|
+
if (inst._zod.values.has(input)) {
|
|
1207
|
+
return payload;
|
|
1208
|
+
}
|
|
1209
|
+
payload.issues.push({
|
|
1210
|
+
code: "invalid_value",
|
|
1211
|
+
values: def.values,
|
|
1212
|
+
input,
|
|
1213
|
+
inst
|
|
1214
|
+
});
|
|
1215
|
+
return payload;
|
|
1216
|
+
};
|
|
1217
|
+
});
|
|
1218
|
+
function handleOptionalResult(result, input) {
|
|
1219
|
+
if (result.issues.length && input === void 0) {
|
|
1220
|
+
return { issues: [], value: void 0 };
|
|
1221
|
+
}
|
|
1222
|
+
return result;
|
|
1223
|
+
}
|
|
1224
|
+
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1225
|
+
$ZodType.init(inst, def);
|
|
1226
|
+
inst._zod.optin = "optional";
|
|
1227
|
+
inst._zod.optout = "optional";
|
|
1228
|
+
defineLazy(inst._zod, "values", () => {
|
|
1229
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1230
|
+
});
|
|
1231
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1232
|
+
const pattern = def.innerType._zod.pattern;
|
|
1233
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1234
|
+
});
|
|
1235
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1236
|
+
if (def.innerType._zod.optin === "optional") {
|
|
1237
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1238
|
+
if (result instanceof Promise)
|
|
1239
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1240
|
+
return handleOptionalResult(result, payload.value);
|
|
1241
|
+
}
|
|
1242
|
+
if (payload.value === void 0) {
|
|
1243
|
+
return payload;
|
|
1244
|
+
}
|
|
1245
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1246
|
+
};
|
|
1247
|
+
});
|
|
1248
|
+
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
1249
|
+
$ZodCheck.init(inst, def);
|
|
1250
|
+
$ZodType.init(inst, def);
|
|
1251
|
+
inst._zod.parse = (payload, _) => {
|
|
1252
|
+
return payload;
|
|
1253
|
+
};
|
|
1254
|
+
inst._zod.check = (payload) => {
|
|
1255
|
+
const input = payload.value;
|
|
1256
|
+
const r = def.fn(input);
|
|
1257
|
+
if (r instanceof Promise) {
|
|
1258
|
+
return r.then((r2) => handleRefineResult(r2, payload, input, inst));
|
|
1259
|
+
}
|
|
1260
|
+
handleRefineResult(r, payload, input, inst);
|
|
1261
|
+
return;
|
|
1262
|
+
};
|
|
1263
|
+
});
|
|
1264
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
1265
|
+
if (!result) {
|
|
1266
|
+
const _iss = {
|
|
1267
|
+
code: "custom",
|
|
1268
|
+
input,
|
|
1269
|
+
inst,
|
|
1270
|
+
// incorporates params.error into issue reporting
|
|
1271
|
+
path: [...inst._zod.def.path ?? []],
|
|
1272
|
+
// incorporates params.error into issue reporting
|
|
1273
|
+
continue: !inst._zod.def.abort
|
|
1274
|
+
// params: inst._zod.def.params,
|
|
1275
|
+
};
|
|
1276
|
+
if (inst._zod.def.params)
|
|
1277
|
+
_iss.params = inst._zod.def.params;
|
|
1278
|
+
payload.issues.push(issue(_iss));
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
function _string(Class, params) {
|
|
1282
|
+
return new Class({
|
|
1283
|
+
type: "string",
|
|
1284
|
+
...normalizeParams(params)
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
function _number(Class, params) {
|
|
1288
|
+
return new Class({
|
|
1289
|
+
type: "number",
|
|
1290
|
+
checks: [],
|
|
1291
|
+
...normalizeParams(params)
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
function _boolean(Class, params) {
|
|
1295
|
+
return new Class({
|
|
1296
|
+
type: "boolean",
|
|
1297
|
+
...normalizeParams(params)
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
function _undefined$1(Class, params) {
|
|
1301
|
+
return new Class({
|
|
1302
|
+
type: "undefined",
|
|
1303
|
+
...normalizeParams(params)
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
function _any(Class) {
|
|
1307
|
+
return new Class({
|
|
1308
|
+
type: "any"
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
function _date(Class, params) {
|
|
1312
|
+
return new Class({
|
|
1313
|
+
type: "date",
|
|
1314
|
+
...normalizeParams(params)
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
function _lte(value, params) {
|
|
1318
|
+
return new $ZodCheckLessThan({
|
|
1319
|
+
check: "less_than",
|
|
1320
|
+
...normalizeParams(params),
|
|
1321
|
+
value,
|
|
1322
|
+
inclusive: true
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
function _gt(value, params) {
|
|
1326
|
+
return new $ZodCheckGreaterThan({
|
|
1327
|
+
check: "greater_than",
|
|
1328
|
+
...normalizeParams(params),
|
|
1329
|
+
value,
|
|
1330
|
+
inclusive: false
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
function _gte(value, params) {
|
|
1334
|
+
return new $ZodCheckGreaterThan({
|
|
1335
|
+
check: "greater_than",
|
|
1336
|
+
...normalizeParams(params),
|
|
1337
|
+
value,
|
|
1338
|
+
inclusive: true
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
function _positive(params) {
|
|
1342
|
+
return _gt(0, params);
|
|
1343
|
+
}
|
|
1344
|
+
function _maxLength(maximum, params) {
|
|
1345
|
+
const ch = new $ZodCheckMaxLength({
|
|
1346
|
+
check: "max_length",
|
|
1347
|
+
...normalizeParams(params),
|
|
1348
|
+
maximum
|
|
1349
|
+
});
|
|
1350
|
+
return ch;
|
|
1351
|
+
}
|
|
1352
|
+
function _minLength(minimum, params) {
|
|
1353
|
+
return new $ZodCheckMinLength({
|
|
1354
|
+
check: "min_length",
|
|
1355
|
+
...normalizeParams(params),
|
|
1356
|
+
minimum
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
function _length(length, params) {
|
|
1360
|
+
return new $ZodCheckLengthEquals({
|
|
1361
|
+
check: "length_equals",
|
|
1362
|
+
...normalizeParams(params),
|
|
1363
|
+
length
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
function _refine(Class, fn, _params) {
|
|
1367
|
+
const schema = new Class({
|
|
1368
|
+
type: "custom",
|
|
1369
|
+
check: "custom",
|
|
1370
|
+
fn,
|
|
1371
|
+
...normalizeParams(_params)
|
|
1372
|
+
});
|
|
1373
|
+
return schema;
|
|
1374
|
+
}
|
|
1375
|
+
const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
1376
|
+
if (!inst._zod)
|
|
1377
|
+
throw new Error("Uninitialized schema in ZodMiniType.");
|
|
1378
|
+
$ZodType.init(inst, def);
|
|
1379
|
+
inst.def = def;
|
|
1380
|
+
inst.type = def.type;
|
|
1381
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
1382
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
1383
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
1384
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
1385
|
+
inst.check = (...checks) => {
|
|
1386
|
+
return inst.clone(
|
|
1387
|
+
{
|
|
1388
|
+
...def,
|
|
1389
|
+
checks: [
|
|
1390
|
+
...def.checks ?? [],
|
|
1391
|
+
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
1392
|
+
]
|
|
1393
|
+
}
|
|
1394
|
+
// { parent: true }
|
|
1395
|
+
);
|
|
1396
|
+
};
|
|
1397
|
+
inst.clone = (_def, params) => clone(inst, _def, params);
|
|
1398
|
+
inst.brand = () => inst;
|
|
1399
|
+
inst.register = ((reg, meta) => {
|
|
1400
|
+
reg.add(inst, meta);
|
|
1401
|
+
return inst;
|
|
1402
|
+
});
|
|
1403
|
+
});
|
|
1404
|
+
const ZodMiniString = /* @__PURE__ */ $constructor("ZodMiniString", (inst, def) => {
|
|
1405
|
+
$ZodString.init(inst, def);
|
|
1406
|
+
ZodMiniType.init(inst, def);
|
|
1407
|
+
});
|
|
1408
|
+
function string(params) {
|
|
1409
|
+
return _string(ZodMiniString, params);
|
|
1410
|
+
}
|
|
1411
|
+
const ZodMiniNumber = /* @__PURE__ */ $constructor("ZodMiniNumber", (inst, def) => {
|
|
1412
|
+
$ZodNumber.init(inst, def);
|
|
1413
|
+
ZodMiniType.init(inst, def);
|
|
1414
|
+
});
|
|
1415
|
+
function number(params) {
|
|
1416
|
+
return _number(ZodMiniNumber, params);
|
|
1417
|
+
}
|
|
1418
|
+
const ZodMiniBoolean = /* @__PURE__ */ $constructor("ZodMiniBoolean", (inst, def) => {
|
|
1419
|
+
$ZodBoolean.init(inst, def);
|
|
1420
|
+
ZodMiniType.init(inst, def);
|
|
1421
|
+
});
|
|
1422
|
+
function boolean(params) {
|
|
1423
|
+
return _boolean(ZodMiniBoolean, params);
|
|
1424
|
+
}
|
|
1425
|
+
const ZodMiniUndefined = /* @__PURE__ */ $constructor("ZodMiniUndefined", (inst, def) => {
|
|
1426
|
+
$ZodUndefined.init(inst, def);
|
|
1427
|
+
ZodMiniType.init(inst, def);
|
|
1428
|
+
});
|
|
1429
|
+
function _undefined(params) {
|
|
1430
|
+
return _undefined$1(ZodMiniUndefined, params);
|
|
1431
|
+
}
|
|
1432
|
+
const ZodMiniAny = /* @__PURE__ */ $constructor("ZodMiniAny", (inst, def) => {
|
|
1433
|
+
$ZodAny.init(inst, def);
|
|
1434
|
+
ZodMiniType.init(inst, def);
|
|
1435
|
+
});
|
|
1436
|
+
function any() {
|
|
1437
|
+
return _any(ZodMiniAny);
|
|
1438
|
+
}
|
|
1439
|
+
const ZodMiniDate = /* @__PURE__ */ $constructor("ZodMiniDate", (inst, def) => {
|
|
1440
|
+
$ZodDate.init(inst, def);
|
|
1441
|
+
ZodMiniType.init(inst, def);
|
|
1442
|
+
});
|
|
1443
|
+
function date(params) {
|
|
1444
|
+
return _date(ZodMiniDate, params);
|
|
1445
|
+
}
|
|
1446
|
+
const ZodMiniArray = /* @__PURE__ */ $constructor("ZodMiniArray", (inst, def) => {
|
|
1447
|
+
$ZodArray.init(inst, def);
|
|
1448
|
+
ZodMiniType.init(inst, def);
|
|
1449
|
+
});
|
|
1450
|
+
function array(element, params) {
|
|
1451
|
+
return new ZodMiniArray({
|
|
1452
|
+
type: "array",
|
|
1453
|
+
element,
|
|
1454
|
+
...normalizeParams(params)
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
function keyof(schema) {
|
|
1458
|
+
const shape = schema._zod.def.shape;
|
|
1459
|
+
return _enum(Object.keys(shape));
|
|
1460
|
+
}
|
|
1461
|
+
const ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
|
|
1462
|
+
$ZodObject.init(inst, def);
|
|
1463
|
+
ZodMiniType.init(inst, def);
|
|
1464
|
+
defineLazy(inst, "shape", () => def.shape);
|
|
1465
|
+
});
|
|
1466
|
+
function object(shape, params) {
|
|
1467
|
+
const def = {
|
|
1468
|
+
type: "object",
|
|
1469
|
+
shape: shape ?? {},
|
|
1470
|
+
...normalizeParams(params)
|
|
1471
|
+
};
|
|
1472
|
+
return new ZodMiniObject(def);
|
|
1473
|
+
}
|
|
1474
|
+
function extend(schema, shape) {
|
|
1475
|
+
return extend$1(schema, shape);
|
|
1476
|
+
}
|
|
1477
|
+
function partial(schema, mask) {
|
|
1478
|
+
return partial$1(ZodMiniOptional, schema);
|
|
1479
|
+
}
|
|
1480
|
+
const ZodMiniUnion = /* @__PURE__ */ $constructor("ZodMiniUnion", (inst, def) => {
|
|
1481
|
+
$ZodUnion.init(inst, def);
|
|
1482
|
+
ZodMiniType.init(inst, def);
|
|
1483
|
+
});
|
|
1484
|
+
function union(options, params) {
|
|
1485
|
+
return new ZodMiniUnion({
|
|
1486
|
+
type: "union",
|
|
1487
|
+
options,
|
|
1488
|
+
...normalizeParams(params)
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
const ZodMiniDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodMiniDiscriminatedUnion", (inst, def) => {
|
|
1492
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
1493
|
+
ZodMiniType.init(inst, def);
|
|
1494
|
+
});
|
|
1495
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
1496
|
+
return new ZodMiniDiscriminatedUnion({
|
|
1497
|
+
type: "union",
|
|
1498
|
+
options,
|
|
1499
|
+
discriminator,
|
|
1500
|
+
...normalizeParams(params)
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
const ZodMiniTuple = /* @__PURE__ */ $constructor("ZodMiniTuple", (inst, def) => {
|
|
1504
|
+
$ZodTuple.init(inst, def);
|
|
1505
|
+
ZodMiniType.init(inst, def);
|
|
1506
|
+
});
|
|
1507
|
+
function tuple(items, _paramsOrRest, _params) {
|
|
1508
|
+
const hasRest = _paramsOrRest instanceof $ZodType;
|
|
1509
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
1510
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
1511
|
+
return new ZodMiniTuple({
|
|
1512
|
+
type: "tuple",
|
|
1513
|
+
items,
|
|
1514
|
+
rest,
|
|
1515
|
+
...normalizeParams(params)
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
const ZodMiniEnum = /* @__PURE__ */ $constructor("ZodMiniEnum", (inst, def) => {
|
|
1519
|
+
$ZodEnum.init(inst, def);
|
|
1520
|
+
ZodMiniType.init(inst, def);
|
|
1521
|
+
inst.options = Object.values(def.entries);
|
|
1522
|
+
});
|
|
1523
|
+
function _enum(values, params) {
|
|
1524
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1525
|
+
return new ZodMiniEnum({
|
|
1526
|
+
type: "enum",
|
|
1527
|
+
entries,
|
|
1528
|
+
...normalizeParams(params)
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
const ZodMiniLiteral = /* @__PURE__ */ $constructor("ZodMiniLiteral", (inst, def) => {
|
|
1532
|
+
$ZodLiteral.init(inst, def);
|
|
1533
|
+
ZodMiniType.init(inst, def);
|
|
1534
|
+
});
|
|
1535
|
+
function literal(value, params) {
|
|
1536
|
+
return new ZodMiniLiteral({
|
|
1537
|
+
type: "literal",
|
|
1538
|
+
values: Array.isArray(value) ? value : [value],
|
|
1539
|
+
...normalizeParams(params)
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
const ZodMiniOptional = /* @__PURE__ */ $constructor("ZodMiniOptional", (inst, def) => {
|
|
1543
|
+
$ZodOptional.init(inst, def);
|
|
1544
|
+
ZodMiniType.init(inst, def);
|
|
1545
|
+
});
|
|
1546
|
+
function optional(innerType) {
|
|
1547
|
+
return new ZodMiniOptional({
|
|
1548
|
+
type: "optional",
|
|
1549
|
+
innerType
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
const ZodMiniCustom = /* @__PURE__ */ $constructor("ZodMiniCustom", (inst, def) => {
|
|
1553
|
+
$ZodCustom.init(inst, def);
|
|
1554
|
+
ZodMiniType.init(inst, def);
|
|
1555
|
+
});
|
|
1556
|
+
function refine(fn, _params = {}) {
|
|
1557
|
+
return _refine(ZodMiniCustom, fn, _params);
|
|
1558
|
+
}
|
|
1559
|
+
const commonServiceRequestSchema = partial(
|
|
1560
|
+
object({
|
|
1561
|
+
apiKey: string(),
|
|
1562
|
+
commonBaseURL: string(),
|
|
1563
|
+
customServiceBaseURL: string(),
|
|
1564
|
+
language: string()
|
|
1565
|
+
})
|
|
1566
|
+
);
|
|
1567
|
+
class ValidationError extends Error {
|
|
1568
|
+
constructor(zodError) {
|
|
1569
|
+
super(prettifyError(zodError));
|
|
1570
|
+
this.issues = zodError.issues;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
const validateRequestSchema = (params, config2) => {
|
|
1574
|
+
const requestSchema = config2?.schema ? extend(commonServiceRequestSchema, config2.schema.shape) : commonServiceRequestSchema;
|
|
1575
|
+
const mergedSchema = requestSchema.check(
|
|
1576
|
+
refine(
|
|
1577
|
+
(data) => "commonBaseURL" in data || "customServiceBaseURL" in data,
|
|
1578
|
+
"commonBaseURL or customServiceBaseURL is required"
|
|
1579
|
+
)
|
|
1580
|
+
);
|
|
1581
|
+
let refinedMergedSchema;
|
|
1582
|
+
if (config2?.refinements?.length) {
|
|
1583
|
+
refinedMergedSchema = mergedSchema;
|
|
1584
|
+
for (const refinement of config2.refinements) {
|
|
1585
|
+
refinedMergedSchema = refinedMergedSchema.check(refine(refinement.check, refinement.message));
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
const validation = (refinedMergedSchema ?? mergedSchema).safeParse(params);
|
|
1589
|
+
if (!validation.success) {
|
|
1590
|
+
throw new ValidationError(validation.error);
|
|
1591
|
+
}
|
|
1592
|
+
return params;
|
|
1593
|
+
};
|
|
1594
|
+
const callService = async (params, template, serviceName) => {
|
|
1595
|
+
const customApiVersion = template.getAPIVersion?.(params);
|
|
1596
|
+
const mergedParams = core.mergeFromGlobal({ ...params, ...customApiVersion && { apiVersion: customApiVersion } });
|
|
1597
|
+
if (params.validateRequest === void 0 || params.validateRequest) {
|
|
1598
|
+
try {
|
|
1599
|
+
validateRequestSchema(mergedParams, template.requestValidation);
|
|
1600
|
+
} catch (e) {
|
|
1601
|
+
return Promise.reject(buildValidationError(e, serviceName));
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
const apiRequest = template.buildRequest(mergedParams);
|
|
1605
|
+
const headers = core.generateTomTomHeaders(mergedParams);
|
|
1606
|
+
params.onAPIRequest?.(apiRequest);
|
|
1607
|
+
try {
|
|
1608
|
+
const apiResponse = await template.sendRequest(apiRequest, headers);
|
|
1609
|
+
params.onAPIResponse?.(apiRequest, apiResponse);
|
|
1610
|
+
return template.parseResponse(await apiResponse.data, mergedParams);
|
|
1611
|
+
} catch (e) {
|
|
1612
|
+
params.onAPIResponse?.(apiRequest, e);
|
|
1613
|
+
return Promise.reject(buildResponseError(e, serviceName, template.parseResponseError));
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
const returnOrThrow = async (response) => {
|
|
1617
|
+
if (response.ok) {
|
|
1618
|
+
return { data: await response.json(), status: response.status };
|
|
1619
|
+
}
|
|
1620
|
+
let message;
|
|
1621
|
+
let errorBody;
|
|
1622
|
+
const contentType = response.headers.get("content-type");
|
|
1623
|
+
if (!response.bodyUsed) {
|
|
1624
|
+
if (contentType?.includes("application/json")) {
|
|
1625
|
+
errorBody = await response.json();
|
|
1626
|
+
message = errorBody?.errorText ?? errorBody?.message ?? errorBody?.detailedError?.message;
|
|
1627
|
+
} else if (contentType?.includes("text/xml")) {
|
|
1628
|
+
errorBody = await response.text();
|
|
1629
|
+
message = response.statusText;
|
|
1630
|
+
}
|
|
1631
|
+
} else {
|
|
1632
|
+
message = response.statusText;
|
|
1633
|
+
}
|
|
1634
|
+
throw { status: response.status, message, data: errorBody };
|
|
1635
|
+
};
|
|
1636
|
+
const get = async (url, headers) => returnOrThrow(await fetch(url, { headers }));
|
|
1637
|
+
const post = async (input, headers) => returnOrThrow(
|
|
1638
|
+
await fetch(input.url, {
|
|
1639
|
+
method: "POST",
|
|
1640
|
+
body: JSON.stringify(input.data),
|
|
1641
|
+
headers: { ...headers, "Content-Type": "application/json" }
|
|
1642
|
+
})
|
|
1643
|
+
);
|
|
1644
|
+
const fetchWith = async (input, headers) => {
|
|
1645
|
+
const method = input.method;
|
|
1646
|
+
if (method === "GET") {
|
|
1647
|
+
return get(input.url, headers);
|
|
1648
|
+
}
|
|
1649
|
+
if (method === "POST") {
|
|
1650
|
+
return post(input, headers);
|
|
1651
|
+
}
|
|
1652
|
+
throw Error(`Unsupported HTTP method received: ${method}`);
|
|
1653
|
+
};
|
|
1654
|
+
const lineStringCoordsSchema = array(array(number()));
|
|
1655
|
+
const geometrySchema = object({
|
|
1656
|
+
type: _enum([
|
|
1657
|
+
"Point",
|
|
1658
|
+
"MultiPoint",
|
|
1659
|
+
"LineString",
|
|
1660
|
+
"MultiLineString",
|
|
1661
|
+
"Polygon",
|
|
1662
|
+
"MultiPolygon",
|
|
1663
|
+
"GeometryCollection",
|
|
1664
|
+
"Circle"
|
|
1665
|
+
]),
|
|
1666
|
+
coordinates: union([
|
|
1667
|
+
array(number()),
|
|
1668
|
+
lineStringCoordsSchema,
|
|
1669
|
+
array(array(array(number()))),
|
|
1670
|
+
array(array(array(array(number()))))
|
|
1671
|
+
]),
|
|
1672
|
+
radius: optional(number()),
|
|
1673
|
+
radiusMeters: optional(number()),
|
|
1674
|
+
bbox: optional(array(number()))
|
|
1675
|
+
}).check(
|
|
1676
|
+
refine(
|
|
1677
|
+
(data) => data.type === "Circle" ? Boolean(data.radius) : true,
|
|
1678
|
+
'type: "Circle" must have radius property'
|
|
1679
|
+
)
|
|
1680
|
+
);
|
|
1681
|
+
const featureSchema = object({
|
|
1682
|
+
type: literal("Feature"),
|
|
1683
|
+
geometry: geometrySchema,
|
|
1684
|
+
id: optional(union([string(), number()])),
|
|
1685
|
+
properties: any(),
|
|
1686
|
+
bbox: optional(array(number()))
|
|
1687
|
+
});
|
|
1688
|
+
const featureCollectionSchema = object({
|
|
1689
|
+
type: literal("FeatureCollection"),
|
|
1690
|
+
features: array(featureSchema),
|
|
1691
|
+
id: optional(union([string(), number()])),
|
|
1692
|
+
properties: any(),
|
|
1693
|
+
bbox: optional(array(number()))
|
|
1694
|
+
});
|
|
1695
|
+
const hasLngLatSchema = union([
|
|
1696
|
+
tuple([number().check(_gte(-180), _lte(180)), number().check(_gte(-90), _lte(90))]),
|
|
1697
|
+
tuple([
|
|
1698
|
+
number().check(_gte(-180), _lte(180)),
|
|
1699
|
+
number().check(_gte(-90), _lte(90)),
|
|
1700
|
+
number()
|
|
1701
|
+
]),
|
|
1702
|
+
object({
|
|
1703
|
+
type: literal("Point"),
|
|
1704
|
+
coordinates: array(number())
|
|
1705
|
+
}),
|
|
1706
|
+
featureSchema
|
|
1707
|
+
]);
|
|
1708
|
+
const geoJsonbBoxSchema = union([array(number()).check(_length(4)), array(number()).check(_length(6))]);
|
|
1709
|
+
const geoJSONObjectSchema = union([geometrySchema, featureSchema, featureCollectionSchema]);
|
|
1710
|
+
const hasBBoxSchema = union([geoJsonbBoxSchema, geoJSONObjectSchema, array(geoJSONObjectSchema)]);
|
|
1711
|
+
const autocompleteSearchRequestMandatory = object({
|
|
1712
|
+
query: string()
|
|
1713
|
+
});
|
|
1714
|
+
const autocompleteSearchRequestOptional = partial(
|
|
1715
|
+
object({
|
|
1716
|
+
position: hasLngLatSchema,
|
|
1717
|
+
limit: number().check(_lte(100)),
|
|
1718
|
+
radiusMeters: number(),
|
|
1719
|
+
countries: array(string()),
|
|
1720
|
+
resultType: array(string())
|
|
1721
|
+
})
|
|
1722
|
+
);
|
|
1723
|
+
const autocompleteSearchRequestSchema = extend(
|
|
1724
|
+
autocompleteSearchRequestMandatory,
|
|
1725
|
+
autocompleteSearchRequestOptional.shape
|
|
1726
|
+
);
|
|
1727
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
1728
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
1729
|
+
var root = freeGlobal || freeSelf || Function("return this")();
|
|
1730
|
+
var Symbol$1 = root.Symbol;
|
|
1731
|
+
var objectProto$b = Object.prototype;
|
|
1732
|
+
var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
|
|
1733
|
+
var nativeObjectToString$1 = objectProto$b.toString;
|
|
1734
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
|
1735
|
+
function getRawTag(value) {
|
|
1736
|
+
var isOwn = hasOwnProperty$8.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
1737
|
+
try {
|
|
1738
|
+
value[symToStringTag$1] = void 0;
|
|
1739
|
+
var unmasked = true;
|
|
1740
|
+
} catch (e) {
|
|
1741
|
+
}
|
|
1742
|
+
var result = nativeObjectToString$1.call(value);
|
|
1743
|
+
if (unmasked) {
|
|
1744
|
+
if (isOwn) {
|
|
1745
|
+
value[symToStringTag$1] = tag;
|
|
1746
|
+
} else {
|
|
1747
|
+
delete value[symToStringTag$1];
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return result;
|
|
1751
|
+
}
|
|
1752
|
+
var objectProto$a = Object.prototype;
|
|
1753
|
+
var nativeObjectToString = objectProto$a.toString;
|
|
1754
|
+
function objectToString(value) {
|
|
1755
|
+
return nativeObjectToString.call(value);
|
|
1756
|
+
}
|
|
1757
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
1758
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
|
1759
|
+
function baseGetTag(value) {
|
|
1760
|
+
if (value == null) {
|
|
1761
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
1762
|
+
}
|
|
1763
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
1764
|
+
}
|
|
1765
|
+
function isObjectLike(value) {
|
|
1766
|
+
return value != null && typeof value == "object";
|
|
1767
|
+
}
|
|
1768
|
+
var symbolTag$2 = "[object Symbol]";
|
|
1769
|
+
function isSymbol(value) {
|
|
1770
|
+
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$2;
|
|
1771
|
+
}
|
|
1772
|
+
function arrayMap(array2, iteratee) {
|
|
1773
|
+
var index = -1, length = array2 == null ? 0 : array2.length, result = Array(length);
|
|
1774
|
+
while (++index < length) {
|
|
1775
|
+
result[index] = iteratee(array2[index], index, array2);
|
|
1776
|
+
}
|
|
1777
|
+
return result;
|
|
1778
|
+
}
|
|
1779
|
+
var isArray = Array.isArray;
|
|
1780
|
+
var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
|
|
1781
|
+
function baseToString(value) {
|
|
1782
|
+
if (typeof value == "string") {
|
|
1783
|
+
return value;
|
|
1784
|
+
}
|
|
1785
|
+
if (isArray(value)) {
|
|
1786
|
+
return arrayMap(value, baseToString) + "";
|
|
1787
|
+
}
|
|
1788
|
+
if (isSymbol(value)) {
|
|
1789
|
+
return symbolToString ? symbolToString.call(value) : "";
|
|
1790
|
+
}
|
|
1791
|
+
var result = value + "";
|
|
1792
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
1793
|
+
}
|
|
1794
|
+
function isObject(value) {
|
|
1795
|
+
var type = typeof value;
|
|
1796
|
+
return value != null && (type == "object" || type == "function");
|
|
1797
|
+
}
|
|
1798
|
+
function identity(value) {
|
|
1799
|
+
return value;
|
|
1800
|
+
}
|
|
1801
|
+
var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
1802
|
+
function isFunction(value) {
|
|
1803
|
+
if (!isObject(value)) {
|
|
1804
|
+
return false;
|
|
1805
|
+
}
|
|
1806
|
+
var tag = baseGetTag(value);
|
|
1807
|
+
return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
|
|
1808
|
+
}
|
|
1809
|
+
var coreJsData = root["__core-js_shared__"];
|
|
1810
|
+
var maskSrcKey = (function() {
|
|
1811
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
|
|
1812
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
1813
|
+
})();
|
|
1814
|
+
function isMasked(func) {
|
|
1815
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
1816
|
+
}
|
|
1817
|
+
var funcProto$2 = Function.prototype;
|
|
1818
|
+
var funcToString$2 = funcProto$2.toString;
|
|
1819
|
+
function toSource(func) {
|
|
1820
|
+
if (func != null) {
|
|
1821
|
+
try {
|
|
1822
|
+
return funcToString$2.call(func);
|
|
1823
|
+
} catch (e) {
|
|
1824
|
+
}
|
|
1825
|
+
try {
|
|
1826
|
+
return func + "";
|
|
1827
|
+
} catch (e) {
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
return "";
|
|
1831
|
+
}
|
|
1832
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
1833
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
1834
|
+
var funcProto$1 = Function.prototype, objectProto$9 = Object.prototype;
|
|
1835
|
+
var funcToString$1 = funcProto$1.toString;
|
|
1836
|
+
var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
|
1837
|
+
var reIsNative = RegExp(
|
|
1838
|
+
"^" + funcToString$1.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
1839
|
+
);
|
|
1840
|
+
function baseIsNative(value) {
|
|
1841
|
+
if (!isObject(value) || isMasked(value)) {
|
|
1842
|
+
return false;
|
|
1843
|
+
}
|
|
1844
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
1845
|
+
return pattern.test(toSource(value));
|
|
1846
|
+
}
|
|
1847
|
+
function getValue(object2, key) {
|
|
1848
|
+
return object2 == null ? void 0 : object2[key];
|
|
1849
|
+
}
|
|
1850
|
+
function getNative(object2, key) {
|
|
1851
|
+
var value = getValue(object2, key);
|
|
1852
|
+
return baseIsNative(value) ? value : void 0;
|
|
1853
|
+
}
|
|
1854
|
+
var WeakMap = getNative(root, "WeakMap");
|
|
1855
|
+
function apply(func, thisArg, args) {
|
|
1856
|
+
switch (args.length) {
|
|
1857
|
+
case 0:
|
|
1858
|
+
return func.call(thisArg);
|
|
1859
|
+
case 1:
|
|
1860
|
+
return func.call(thisArg, args[0]);
|
|
1861
|
+
case 2:
|
|
1862
|
+
return func.call(thisArg, args[0], args[1]);
|
|
1863
|
+
case 3:
|
|
1864
|
+
return func.call(thisArg, args[0], args[1], args[2]);
|
|
1865
|
+
}
|
|
1866
|
+
return func.apply(thisArg, args);
|
|
1867
|
+
}
|
|
1868
|
+
var HOT_COUNT = 800, HOT_SPAN = 16;
|
|
1869
|
+
var nativeNow = Date.now;
|
|
1870
|
+
function shortOut(func) {
|
|
1871
|
+
var count = 0, lastCalled = 0;
|
|
1872
|
+
return function() {
|
|
1873
|
+
var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
|
|
1874
|
+
lastCalled = stamp;
|
|
1875
|
+
if (remaining > 0) {
|
|
1876
|
+
if (++count >= HOT_COUNT) {
|
|
1877
|
+
return arguments[0];
|
|
1878
|
+
}
|
|
1879
|
+
} else {
|
|
1880
|
+
count = 0;
|
|
1881
|
+
}
|
|
1882
|
+
return func.apply(void 0, arguments);
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
function constant(value) {
|
|
1886
|
+
return function() {
|
|
1887
|
+
return value;
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
var defineProperty = (function() {
|
|
1891
|
+
try {
|
|
1892
|
+
var func = getNative(Object, "defineProperty");
|
|
1893
|
+
func({}, "", {});
|
|
1894
|
+
return func;
|
|
1895
|
+
} catch (e) {
|
|
1896
|
+
}
|
|
1897
|
+
})();
|
|
1898
|
+
var baseSetToString = !defineProperty ? identity : function(func, string2) {
|
|
1899
|
+
return defineProperty(func, "toString", {
|
|
1900
|
+
"configurable": true,
|
|
1901
|
+
"enumerable": false,
|
|
1902
|
+
"value": constant(string2),
|
|
1903
|
+
"writable": true
|
|
1904
|
+
});
|
|
1905
|
+
};
|
|
1906
|
+
var setToString = shortOut(baseSetToString);
|
|
1907
|
+
function arrayEach(array2, iteratee) {
|
|
1908
|
+
var index = -1, length = array2 == null ? 0 : array2.length;
|
|
1909
|
+
while (++index < length) {
|
|
1910
|
+
if (iteratee(array2[index], index, array2) === false) {
|
|
1911
|
+
break;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
return array2;
|
|
1915
|
+
}
|
|
1916
|
+
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
1917
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
1918
|
+
function isIndex(value, length) {
|
|
1919
|
+
var type = typeof value;
|
|
1920
|
+
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
1921
|
+
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
1922
|
+
}
|
|
1923
|
+
function baseAssignValue(object2, key, value) {
|
|
1924
|
+
if (key == "__proto__" && defineProperty) {
|
|
1925
|
+
defineProperty(object2, key, {
|
|
1926
|
+
"configurable": true,
|
|
1927
|
+
"enumerable": true,
|
|
1928
|
+
"value": value,
|
|
1929
|
+
"writable": true
|
|
1930
|
+
});
|
|
1931
|
+
} else {
|
|
1932
|
+
object2[key] = value;
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
function eq(value, other) {
|
|
1936
|
+
return value === other || value !== value && other !== other;
|
|
1937
|
+
}
|
|
1938
|
+
var objectProto$8 = Object.prototype;
|
|
1939
|
+
var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
|
|
1940
|
+
function assignValue(object2, key, value) {
|
|
1941
|
+
var objValue = object2[key];
|
|
1942
|
+
if (!(hasOwnProperty$6.call(object2, key) && eq(objValue, value)) || value === void 0 && !(key in object2)) {
|
|
1943
|
+
baseAssignValue(object2, key, value);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function copyObject(source, props, object2, customizer) {
|
|
1947
|
+
var isNew = !object2;
|
|
1948
|
+
object2 || (object2 = {});
|
|
1949
|
+
var index = -1, length = props.length;
|
|
1950
|
+
while (++index < length) {
|
|
1951
|
+
var key = props[index];
|
|
1952
|
+
var newValue = void 0;
|
|
1953
|
+
if (newValue === void 0) {
|
|
1954
|
+
newValue = source[key];
|
|
1955
|
+
}
|
|
1956
|
+
if (isNew) {
|
|
1957
|
+
baseAssignValue(object2, key, newValue);
|
|
1958
|
+
} else {
|
|
1959
|
+
assignValue(object2, key, newValue);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
return object2;
|
|
1963
|
+
}
|
|
1964
|
+
var nativeMax = Math.max;
|
|
1965
|
+
function overRest(func, start, transform) {
|
|
1966
|
+
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
|
|
1967
|
+
return function() {
|
|
1968
|
+
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array2 = Array(length);
|
|
1969
|
+
while (++index < length) {
|
|
1970
|
+
array2[index] = args[start + index];
|
|
1971
|
+
}
|
|
1972
|
+
index = -1;
|
|
1973
|
+
var otherArgs = Array(start + 1);
|
|
1974
|
+
while (++index < start) {
|
|
1975
|
+
otherArgs[index] = args[index];
|
|
1976
|
+
}
|
|
1977
|
+
otherArgs[start] = transform(array2);
|
|
1978
|
+
return apply(func, this, otherArgs);
|
|
1979
|
+
};
|
|
1980
|
+
}
|
|
1981
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
1982
|
+
function isLength(value) {
|
|
1983
|
+
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
1984
|
+
}
|
|
1985
|
+
function isArrayLike(value) {
|
|
1986
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
1987
|
+
}
|
|
1988
|
+
var objectProto$7 = Object.prototype;
|
|
1989
|
+
function isPrototype(value) {
|
|
1990
|
+
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$7;
|
|
1991
|
+
return value === proto;
|
|
1992
|
+
}
|
|
1993
|
+
function baseTimes(n, iteratee) {
|
|
1994
|
+
var index = -1, result = Array(n);
|
|
1995
|
+
while (++index < n) {
|
|
1996
|
+
result[index] = iteratee(index);
|
|
1997
|
+
}
|
|
1998
|
+
return result;
|
|
1999
|
+
}
|
|
2000
|
+
var argsTag$2 = "[object Arguments]";
|
|
2001
|
+
function baseIsArguments(value) {
|
|
2002
|
+
return isObjectLike(value) && baseGetTag(value) == argsTag$2;
|
|
2003
|
+
}
|
|
2004
|
+
var objectProto$6 = Object.prototype;
|
|
2005
|
+
var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
|
|
2006
|
+
var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
|
|
2007
|
+
var isArguments = baseIsArguments(/* @__PURE__ */ (function() {
|
|
2008
|
+
return arguments;
|
|
2009
|
+
})()) ? baseIsArguments : function(value) {
|
|
2010
|
+
return isObjectLike(value) && hasOwnProperty$5.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
|
|
2011
|
+
};
|
|
2012
|
+
function stubFalse() {
|
|
2013
|
+
return false;
|
|
2014
|
+
}
|
|
2015
|
+
var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
2016
|
+
var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
|
|
2017
|
+
var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
|
|
2018
|
+
var Buffer$1 = moduleExports$2 ? root.Buffer : void 0;
|
|
2019
|
+
var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : void 0;
|
|
2020
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
2021
|
+
var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", errorTag$1 = "[object Error]", funcTag$1 = "[object Function]", mapTag$4 = "[object Map]", numberTag$2 = "[object Number]", objectTag$3 = "[object Object]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$2 = "[object String]", weakMapTag$2 = "[object WeakMap]";
|
|
2022
|
+
var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$3 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
|
|
2023
|
+
var typedArrayTags = {};
|
|
2024
|
+
typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
|
|
2025
|
+
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] = typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$2] = typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] = typedArrayTags[weakMapTag$2] = false;
|
|
2026
|
+
function baseIsTypedArray(value) {
|
|
2027
|
+
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
2028
|
+
}
|
|
2029
|
+
function baseUnary(func) {
|
|
2030
|
+
return function(value) {
|
|
2031
|
+
return func(value);
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
2035
|
+
var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module;
|
|
2036
|
+
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
2037
|
+
var freeProcess = moduleExports$1 && freeGlobal.process;
|
|
2038
|
+
var nodeUtil = (function() {
|
|
2039
|
+
try {
|
|
2040
|
+
var types = freeModule$1 && freeModule$1.require && freeModule$1.require("util").types;
|
|
2041
|
+
if (types) {
|
|
2042
|
+
return types;
|
|
2043
|
+
}
|
|
2044
|
+
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
2045
|
+
} catch (e) {
|
|
2046
|
+
}
|
|
2047
|
+
})();
|
|
2048
|
+
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
2049
|
+
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
2050
|
+
function arrayLikeKeys(value, inherited) {
|
|
2051
|
+
var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
|
|
2052
|
+
for (var key in value) {
|
|
2053
|
+
if (!(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
2054
|
+
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
2055
|
+
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
2056
|
+
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
|
|
2057
|
+
isIndex(key, length)))) {
|
|
2058
|
+
result.push(key);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
return result;
|
|
2062
|
+
}
|
|
2063
|
+
function overArg(func, transform) {
|
|
2064
|
+
return function(arg) {
|
|
2065
|
+
return func(transform(arg));
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
function nativeKeysIn(object2) {
|
|
2069
|
+
var result = [];
|
|
2070
|
+
if (object2 != null) {
|
|
2071
|
+
for (var key in Object(object2)) {
|
|
2072
|
+
result.push(key);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
return result;
|
|
2076
|
+
}
|
|
2077
|
+
var objectProto$5 = Object.prototype;
|
|
2078
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
2079
|
+
function baseKeysIn(object2) {
|
|
2080
|
+
if (!isObject(object2)) {
|
|
2081
|
+
return nativeKeysIn(object2);
|
|
2082
|
+
}
|
|
2083
|
+
var isProto = isPrototype(object2), result = [];
|
|
2084
|
+
for (var key in object2) {
|
|
2085
|
+
if (!(key == "constructor" && (isProto || !hasOwnProperty$4.call(object2, key)))) {
|
|
2086
|
+
result.push(key);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
return result;
|
|
2090
|
+
}
|
|
2091
|
+
function keysIn(object2) {
|
|
2092
|
+
return isArrayLike(object2) ? arrayLikeKeys(object2) : baseKeysIn(object2);
|
|
2093
|
+
}
|
|
2094
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
|
|
2095
|
+
function isKey(value, object2) {
|
|
2096
|
+
if (isArray(value)) {
|
|
2097
|
+
return false;
|
|
2098
|
+
}
|
|
2099
|
+
var type = typeof value;
|
|
2100
|
+
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
|
|
2101
|
+
return true;
|
|
2102
|
+
}
|
|
2103
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object2 != null && value in Object(object2);
|
|
2104
|
+
}
|
|
2105
|
+
var nativeCreate = getNative(Object, "create");
|
|
2106
|
+
function hashClear() {
|
|
2107
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
2108
|
+
this.size = 0;
|
|
2109
|
+
}
|
|
2110
|
+
function hashDelete(key) {
|
|
2111
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
2112
|
+
this.size -= result ? 1 : 0;
|
|
2113
|
+
return result;
|
|
2114
|
+
}
|
|
2115
|
+
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
|
|
2116
|
+
var objectProto$4 = Object.prototype;
|
|
2117
|
+
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
2118
|
+
function hashGet(key) {
|
|
2119
|
+
var data = this.__data__;
|
|
2120
|
+
if (nativeCreate) {
|
|
2121
|
+
var result = data[key];
|
|
2122
|
+
return result === HASH_UNDEFINED$1 ? void 0 : result;
|
|
2123
|
+
}
|
|
2124
|
+
return hasOwnProperty$3.call(data, key) ? data[key] : void 0;
|
|
2125
|
+
}
|
|
2126
|
+
var objectProto$3 = Object.prototype;
|
|
2127
|
+
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
2128
|
+
function hashHas(key) {
|
|
2129
|
+
var data = this.__data__;
|
|
2130
|
+
return nativeCreate ? data[key] !== void 0 : hasOwnProperty$2.call(data, key);
|
|
2131
|
+
}
|
|
2132
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
2133
|
+
function hashSet(key, value) {
|
|
2134
|
+
var data = this.__data__;
|
|
2135
|
+
this.size += this.has(key) ? 0 : 1;
|
|
2136
|
+
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
2137
|
+
return this;
|
|
2138
|
+
}
|
|
2139
|
+
function Hash(entries) {
|
|
2140
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
2141
|
+
this.clear();
|
|
2142
|
+
while (++index < length) {
|
|
2143
|
+
var entry = entries[index];
|
|
2144
|
+
this.set(entry[0], entry[1]);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
Hash.prototype.clear = hashClear;
|
|
2148
|
+
Hash.prototype["delete"] = hashDelete;
|
|
2149
|
+
Hash.prototype.get = hashGet;
|
|
2150
|
+
Hash.prototype.has = hashHas;
|
|
2151
|
+
Hash.prototype.set = hashSet;
|
|
2152
|
+
function listCacheClear() {
|
|
2153
|
+
this.__data__ = [];
|
|
2154
|
+
this.size = 0;
|
|
2155
|
+
}
|
|
2156
|
+
function assocIndexOf(array2, key) {
|
|
2157
|
+
var length = array2.length;
|
|
2158
|
+
while (length--) {
|
|
2159
|
+
if (eq(array2[length][0], key)) {
|
|
2160
|
+
return length;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
return -1;
|
|
2164
|
+
}
|
|
2165
|
+
var arrayProto = Array.prototype;
|
|
2166
|
+
var splice = arrayProto.splice;
|
|
2167
|
+
function listCacheDelete(key) {
|
|
2168
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
2169
|
+
if (index < 0) {
|
|
2170
|
+
return false;
|
|
2171
|
+
}
|
|
2172
|
+
var lastIndex = data.length - 1;
|
|
2173
|
+
if (index == lastIndex) {
|
|
2174
|
+
data.pop();
|
|
2175
|
+
} else {
|
|
2176
|
+
splice.call(data, index, 1);
|
|
2177
|
+
}
|
|
2178
|
+
--this.size;
|
|
2179
|
+
return true;
|
|
2180
|
+
}
|
|
2181
|
+
function listCacheGet(key) {
|
|
2182
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
2183
|
+
return index < 0 ? void 0 : data[index][1];
|
|
2184
|
+
}
|
|
2185
|
+
function listCacheHas(key) {
|
|
2186
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
2187
|
+
}
|
|
2188
|
+
function listCacheSet(key, value) {
|
|
2189
|
+
var data = this.__data__, index = assocIndexOf(data, key);
|
|
2190
|
+
if (index < 0) {
|
|
2191
|
+
++this.size;
|
|
2192
|
+
data.push([key, value]);
|
|
2193
|
+
} else {
|
|
2194
|
+
data[index][1] = value;
|
|
2195
|
+
}
|
|
2196
|
+
return this;
|
|
2197
|
+
}
|
|
2198
|
+
function ListCache(entries) {
|
|
2199
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
2200
|
+
this.clear();
|
|
2201
|
+
while (++index < length) {
|
|
2202
|
+
var entry = entries[index];
|
|
2203
|
+
this.set(entry[0], entry[1]);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
ListCache.prototype.clear = listCacheClear;
|
|
2207
|
+
ListCache.prototype["delete"] = listCacheDelete;
|
|
2208
|
+
ListCache.prototype.get = listCacheGet;
|
|
2209
|
+
ListCache.prototype.has = listCacheHas;
|
|
2210
|
+
ListCache.prototype.set = listCacheSet;
|
|
2211
|
+
var Map$1 = getNative(root, "Map");
|
|
2212
|
+
function mapCacheClear() {
|
|
2213
|
+
this.size = 0;
|
|
2214
|
+
this.__data__ = {
|
|
2215
|
+
"hash": new Hash(),
|
|
2216
|
+
"map": new (Map$1 || ListCache)(),
|
|
2217
|
+
"string": new Hash()
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2220
|
+
function isKeyable(value) {
|
|
2221
|
+
var type = typeof value;
|
|
2222
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
2223
|
+
}
|
|
2224
|
+
function getMapData(map, key) {
|
|
2225
|
+
var data = map.__data__;
|
|
2226
|
+
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
2227
|
+
}
|
|
2228
|
+
function mapCacheDelete(key) {
|
|
2229
|
+
var result = getMapData(this, key)["delete"](key);
|
|
2230
|
+
this.size -= result ? 1 : 0;
|
|
2231
|
+
return result;
|
|
2232
|
+
}
|
|
2233
|
+
function mapCacheGet(key) {
|
|
2234
|
+
return getMapData(this, key).get(key);
|
|
2235
|
+
}
|
|
2236
|
+
function mapCacheHas(key) {
|
|
2237
|
+
return getMapData(this, key).has(key);
|
|
2238
|
+
}
|
|
2239
|
+
function mapCacheSet(key, value) {
|
|
2240
|
+
var data = getMapData(this, key), size = data.size;
|
|
2241
|
+
data.set(key, value);
|
|
2242
|
+
this.size += data.size == size ? 0 : 1;
|
|
2243
|
+
return this;
|
|
2244
|
+
}
|
|
2245
|
+
function MapCache(entries) {
|
|
2246
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
2247
|
+
this.clear();
|
|
2248
|
+
while (++index < length) {
|
|
2249
|
+
var entry = entries[index];
|
|
2250
|
+
this.set(entry[0], entry[1]);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
2254
|
+
MapCache.prototype["delete"] = mapCacheDelete;
|
|
2255
|
+
MapCache.prototype.get = mapCacheGet;
|
|
2256
|
+
MapCache.prototype.has = mapCacheHas;
|
|
2257
|
+
MapCache.prototype.set = mapCacheSet;
|
|
2258
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
2259
|
+
function memoize(func, resolver) {
|
|
2260
|
+
if (typeof func != "function" || resolver != null && typeof resolver != "function") {
|
|
2261
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
2262
|
+
}
|
|
2263
|
+
var memoized = function() {
|
|
2264
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
2265
|
+
if (cache.has(key)) {
|
|
2266
|
+
return cache.get(key);
|
|
2267
|
+
}
|
|
2268
|
+
var result = func.apply(this, args);
|
|
2269
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
2270
|
+
return result;
|
|
2271
|
+
};
|
|
2272
|
+
memoized.cache = new (memoize.Cache || MapCache)();
|
|
2273
|
+
return memoized;
|
|
2274
|
+
}
|
|
2275
|
+
memoize.Cache = MapCache;
|
|
2276
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
2277
|
+
function memoizeCapped(func) {
|
|
2278
|
+
var result = memoize(func, function(key) {
|
|
2279
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
2280
|
+
cache.clear();
|
|
2281
|
+
}
|
|
2282
|
+
return key;
|
|
2283
|
+
});
|
|
2284
|
+
var cache = result.cache;
|
|
2285
|
+
return result;
|
|
2286
|
+
}
|
|
2287
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
2288
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
2289
|
+
var stringToPath = memoizeCapped(function(string2) {
|
|
2290
|
+
var result = [];
|
|
2291
|
+
if (string2.charCodeAt(0) === 46) {
|
|
2292
|
+
result.push("");
|
|
2293
|
+
}
|
|
2294
|
+
string2.replace(rePropName, function(match, number2, quote, subString) {
|
|
2295
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number2 || match);
|
|
2296
|
+
});
|
|
2297
|
+
return result;
|
|
2298
|
+
});
|
|
2299
|
+
function toString(value) {
|
|
2300
|
+
return value == null ? "" : baseToString(value);
|
|
2301
|
+
}
|
|
2302
|
+
function castPath(value, object2) {
|
|
2303
|
+
if (isArray(value)) {
|
|
2304
|
+
return value;
|
|
2305
|
+
}
|
|
2306
|
+
return isKey(value, object2) ? [value] : stringToPath(toString(value));
|
|
2307
|
+
}
|
|
2308
|
+
function toKey(value) {
|
|
2309
|
+
if (typeof value == "string" || isSymbol(value)) {
|
|
2310
|
+
return value;
|
|
2311
|
+
}
|
|
2312
|
+
var result = value + "";
|
|
2313
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
2314
|
+
}
|
|
2315
|
+
function baseGet(object2, path) {
|
|
2316
|
+
path = castPath(path, object2);
|
|
2317
|
+
var index = 0, length = path.length;
|
|
2318
|
+
while (object2 != null && index < length) {
|
|
2319
|
+
object2 = object2[toKey(path[index++])];
|
|
2320
|
+
}
|
|
2321
|
+
return index && index == length ? object2 : void 0;
|
|
2322
|
+
}
|
|
2323
|
+
function arrayPush(array2, values) {
|
|
2324
|
+
var index = -1, length = values.length, offset = array2.length;
|
|
2325
|
+
while (++index < length) {
|
|
2326
|
+
array2[offset + index] = values[index];
|
|
2327
|
+
}
|
|
2328
|
+
return array2;
|
|
2329
|
+
}
|
|
2330
|
+
var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : void 0;
|
|
2331
|
+
function isFlattenable(value) {
|
|
2332
|
+
return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
2333
|
+
}
|
|
2334
|
+
function baseFlatten(array2, depth, predicate, isStrict, result) {
|
|
2335
|
+
var index = -1, length = array2.length;
|
|
2336
|
+
predicate || (predicate = isFlattenable);
|
|
2337
|
+
result || (result = []);
|
|
2338
|
+
while (++index < length) {
|
|
2339
|
+
var value = array2[index];
|
|
2340
|
+
if (predicate(value)) {
|
|
2341
|
+
{
|
|
2342
|
+
arrayPush(result, value);
|
|
2343
|
+
}
|
|
2344
|
+
} else {
|
|
2345
|
+
result[result.length] = value;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
return result;
|
|
2349
|
+
}
|
|
2350
|
+
function flatten(array2) {
|
|
2351
|
+
var length = array2 == null ? 0 : array2.length;
|
|
2352
|
+
return length ? baseFlatten(array2) : [];
|
|
2353
|
+
}
|
|
2354
|
+
function flatRest(func) {
|
|
2355
|
+
return setToString(overRest(func, void 0, flatten), func + "");
|
|
2356
|
+
}
|
|
2357
|
+
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
2358
|
+
var objectTag$2 = "[object Object]";
|
|
2359
|
+
var funcProto = Function.prototype, objectProto$2 = Object.prototype;
|
|
2360
|
+
var funcToString = funcProto.toString;
|
|
2361
|
+
var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
|
2362
|
+
var objectCtorString = funcToString.call(Object);
|
|
2363
|
+
function isPlainObject(value) {
|
|
2364
|
+
if (!isObjectLike(value) || baseGetTag(value) != objectTag$2) {
|
|
2365
|
+
return false;
|
|
2366
|
+
}
|
|
2367
|
+
var proto = getPrototype(value);
|
|
2368
|
+
if (proto === null) {
|
|
2369
|
+
return true;
|
|
2370
|
+
}
|
|
2371
|
+
var Ctor = hasOwnProperty$1.call(proto, "constructor") && proto.constructor;
|
|
2372
|
+
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
|
|
2373
|
+
}
|
|
2374
|
+
function baseSlice(array2, start, end) {
|
|
2375
|
+
var index = -1, length = array2.length;
|
|
2376
|
+
if (start < 0) {
|
|
2377
|
+
start = -start > length ? 0 : length + start;
|
|
2378
|
+
}
|
|
2379
|
+
end = end > length ? length : end;
|
|
2380
|
+
if (end < 0) {
|
|
2381
|
+
end += length;
|
|
2382
|
+
}
|
|
2383
|
+
length = start > end ? 0 : end - start >>> 0;
|
|
2384
|
+
start >>>= 0;
|
|
2385
|
+
var result = Array(length);
|
|
2386
|
+
while (++index < length) {
|
|
2387
|
+
result[index] = array2[index + start];
|
|
2388
|
+
}
|
|
2389
|
+
return result;
|
|
2390
|
+
}
|
|
2391
|
+
function stackClear() {
|
|
2392
|
+
this.__data__ = new ListCache();
|
|
2393
|
+
this.size = 0;
|
|
2394
|
+
}
|
|
2395
|
+
function stackDelete(key) {
|
|
2396
|
+
var data = this.__data__, result = data["delete"](key);
|
|
2397
|
+
this.size = data.size;
|
|
2398
|
+
return result;
|
|
2399
|
+
}
|
|
2400
|
+
function stackGet(key) {
|
|
2401
|
+
return this.__data__.get(key);
|
|
2402
|
+
}
|
|
2403
|
+
function stackHas(key) {
|
|
2404
|
+
return this.__data__.has(key);
|
|
2405
|
+
}
|
|
2406
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
2407
|
+
function stackSet(key, value) {
|
|
2408
|
+
var data = this.__data__;
|
|
2409
|
+
if (data instanceof ListCache) {
|
|
2410
|
+
var pairs = data.__data__;
|
|
2411
|
+
if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
2412
|
+
pairs.push([key, value]);
|
|
2413
|
+
this.size = ++data.size;
|
|
2414
|
+
return this;
|
|
2415
|
+
}
|
|
2416
|
+
data = this.__data__ = new MapCache(pairs);
|
|
2417
|
+
}
|
|
2418
|
+
data.set(key, value);
|
|
2419
|
+
this.size = data.size;
|
|
2420
|
+
return this;
|
|
2421
|
+
}
|
|
2422
|
+
function Stack(entries) {
|
|
2423
|
+
var data = this.__data__ = new ListCache(entries);
|
|
2424
|
+
this.size = data.size;
|
|
2425
|
+
}
|
|
2426
|
+
Stack.prototype.clear = stackClear;
|
|
2427
|
+
Stack.prototype["delete"] = stackDelete;
|
|
2428
|
+
Stack.prototype.get = stackGet;
|
|
2429
|
+
Stack.prototype.has = stackHas;
|
|
2430
|
+
Stack.prototype.set = stackSet;
|
|
2431
|
+
var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
2432
|
+
var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
|
|
2433
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
2434
|
+
var Buffer = moduleExports ? root.Buffer : void 0;
|
|
2435
|
+
Buffer ? Buffer.allocUnsafe : void 0;
|
|
2436
|
+
function cloneBuffer(buffer, isDeep) {
|
|
2437
|
+
{
|
|
2438
|
+
return buffer.slice();
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
function arrayFilter(array2, predicate) {
|
|
2442
|
+
var index = -1, length = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
|
|
2443
|
+
while (++index < length) {
|
|
2444
|
+
var value = array2[index];
|
|
2445
|
+
if (predicate(value, index, array2)) {
|
|
2446
|
+
result[resIndex++] = value;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
return result;
|
|
2450
|
+
}
|
|
2451
|
+
function stubArray() {
|
|
2452
|
+
return [];
|
|
2453
|
+
}
|
|
2454
|
+
var objectProto$1 = Object.prototype;
|
|
2455
|
+
var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
|
|
2456
|
+
var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
|
|
2457
|
+
var getSymbols = !nativeGetSymbols$1 ? stubArray : function(object2) {
|
|
2458
|
+
if (object2 == null) {
|
|
2459
|
+
return [];
|
|
2460
|
+
}
|
|
2461
|
+
object2 = Object(object2);
|
|
2462
|
+
return arrayFilter(nativeGetSymbols$1(object2), function(symbol) {
|
|
2463
|
+
return propertyIsEnumerable.call(object2, symbol);
|
|
2464
|
+
});
|
|
2465
|
+
};
|
|
2466
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
2467
|
+
var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object2) {
|
|
2468
|
+
var result = [];
|
|
2469
|
+
while (object2) {
|
|
2470
|
+
arrayPush(result, getSymbols(object2));
|
|
2471
|
+
object2 = getPrototype(object2);
|
|
2472
|
+
}
|
|
2473
|
+
return result;
|
|
2474
|
+
};
|
|
2475
|
+
function baseGetAllKeys(object2, keysFunc, symbolsFunc) {
|
|
2476
|
+
var result = keysFunc(object2);
|
|
2477
|
+
return isArray(object2) ? result : arrayPush(result, symbolsFunc(object2));
|
|
2478
|
+
}
|
|
2479
|
+
function getAllKeysIn(object2) {
|
|
2480
|
+
return baseGetAllKeys(object2, keysIn, getSymbolsIn);
|
|
2481
|
+
}
|
|
2482
|
+
var DataView = getNative(root, "DataView");
|
|
2483
|
+
var Promise$1 = getNative(root, "Promise");
|
|
2484
|
+
var Set$1 = getNative(root, "Set");
|
|
2485
|
+
var mapTag$3 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
|
|
2486
|
+
var dataViewTag$2 = "[object DataView]";
|
|
2487
|
+
var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap);
|
|
2488
|
+
var getTag = baseGetTag;
|
|
2489
|
+
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag(new Map$1()) != mapTag$3 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$3 || WeakMap && getTag(new WeakMap()) != weakMapTag$1) {
|
|
2490
|
+
getTag = function(value) {
|
|
2491
|
+
var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
|
|
2492
|
+
if (ctorString) {
|
|
2493
|
+
switch (ctorString) {
|
|
2494
|
+
case dataViewCtorString:
|
|
2495
|
+
return dataViewTag$2;
|
|
2496
|
+
case mapCtorString:
|
|
2497
|
+
return mapTag$3;
|
|
2498
|
+
case promiseCtorString:
|
|
2499
|
+
return promiseTag;
|
|
2500
|
+
case setCtorString:
|
|
2501
|
+
return setTag$3;
|
|
2502
|
+
case weakMapCtorString:
|
|
2503
|
+
return weakMapTag$1;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
return result;
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
var objectProto = Object.prototype;
|
|
2510
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
2511
|
+
function initCloneArray(array2) {
|
|
2512
|
+
var length = array2.length, result = new array2.constructor(length);
|
|
2513
|
+
if (length && typeof array2[0] == "string" && hasOwnProperty.call(array2, "index")) {
|
|
2514
|
+
result.index = array2.index;
|
|
2515
|
+
result.input = array2.input;
|
|
2516
|
+
}
|
|
2517
|
+
return result;
|
|
2518
|
+
}
|
|
2519
|
+
var Uint8Array = root.Uint8Array;
|
|
2520
|
+
function cloneArrayBuffer(arrayBuffer) {
|
|
2521
|
+
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
2522
|
+
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
|
|
2523
|
+
return result;
|
|
2524
|
+
}
|
|
2525
|
+
function cloneDataView(dataView, isDeep) {
|
|
2526
|
+
var buffer = cloneArrayBuffer(dataView.buffer);
|
|
2527
|
+
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
|
2528
|
+
}
|
|
2529
|
+
var reFlags = /\w*$/;
|
|
2530
|
+
function cloneRegExp(regexp) {
|
|
2531
|
+
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
|
2532
|
+
result.lastIndex = regexp.lastIndex;
|
|
2533
|
+
return result;
|
|
2534
|
+
}
|
|
2535
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
2536
|
+
function cloneSymbol(symbol) {
|
|
2537
|
+
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
|
2538
|
+
}
|
|
2539
|
+
function cloneTypedArray(typedArray, isDeep) {
|
|
2540
|
+
var buffer = cloneArrayBuffer(typedArray.buffer);
|
|
2541
|
+
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
|
2542
|
+
}
|
|
2543
|
+
var boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]";
|
|
2544
|
+
var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
|
|
2545
|
+
function initCloneByTag(object2, tag, isDeep) {
|
|
2546
|
+
var Ctor = object2.constructor;
|
|
2547
|
+
switch (tag) {
|
|
2548
|
+
case arrayBufferTag$1:
|
|
2549
|
+
return cloneArrayBuffer(object2);
|
|
2550
|
+
case boolTag$1:
|
|
2551
|
+
case dateTag$1:
|
|
2552
|
+
return new Ctor(+object2);
|
|
2553
|
+
case dataViewTag$1:
|
|
2554
|
+
return cloneDataView(object2);
|
|
2555
|
+
case float32Tag$1:
|
|
2556
|
+
case float64Tag$1:
|
|
2557
|
+
case int8Tag$1:
|
|
2558
|
+
case int16Tag$1:
|
|
2559
|
+
case int32Tag$1:
|
|
2560
|
+
case uint8Tag$1:
|
|
2561
|
+
case uint8ClampedTag$1:
|
|
2562
|
+
case uint16Tag$1:
|
|
2563
|
+
case uint32Tag$1:
|
|
2564
|
+
return cloneTypedArray(object2);
|
|
2565
|
+
case mapTag$2:
|
|
2566
|
+
return new Ctor();
|
|
2567
|
+
case numberTag$1:
|
|
2568
|
+
case stringTag$1:
|
|
2569
|
+
return new Ctor(object2);
|
|
2570
|
+
case regexpTag$1:
|
|
2571
|
+
return cloneRegExp(object2);
|
|
2572
|
+
case setTag$2:
|
|
2573
|
+
return new Ctor();
|
|
2574
|
+
case symbolTag$1:
|
|
2575
|
+
return cloneSymbol(object2);
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
var mapTag$1 = "[object Map]";
|
|
2579
|
+
function baseIsMap(value) {
|
|
2580
|
+
return isObjectLike(value) && getTag(value) == mapTag$1;
|
|
2581
|
+
}
|
|
2582
|
+
var nodeIsMap = nodeUtil && nodeUtil.isMap;
|
|
2583
|
+
var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
|
|
2584
|
+
var setTag$1 = "[object Set]";
|
|
2585
|
+
function baseIsSet(value) {
|
|
2586
|
+
return isObjectLike(value) && getTag(value) == setTag$1;
|
|
2587
|
+
}
|
|
2588
|
+
var nodeIsSet = nodeUtil && nodeUtil.isSet;
|
|
2589
|
+
var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
|
|
2590
|
+
var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]";
|
|
2591
|
+
var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
|
|
2592
|
+
var cloneableTags = {};
|
|
2593
|
+
cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
|
2594
|
+
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
|
|
2595
|
+
function baseClone(value, bitmask, customizer, key, object2, stack) {
|
|
2596
|
+
var result;
|
|
2597
|
+
if (customizer) {
|
|
2598
|
+
result = object2 ? customizer(value, key, object2, stack) : customizer(value);
|
|
2599
|
+
}
|
|
2600
|
+
if (result !== void 0) {
|
|
2601
|
+
return result;
|
|
2602
|
+
}
|
|
2603
|
+
if (!isObject(value)) {
|
|
2604
|
+
return value;
|
|
2605
|
+
}
|
|
2606
|
+
var isArr = isArray(value);
|
|
2607
|
+
if (isArr) {
|
|
2608
|
+
result = initCloneArray(value);
|
|
2609
|
+
} else {
|
|
2610
|
+
var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
|
|
2611
|
+
if (isBuffer(value)) {
|
|
2612
|
+
return cloneBuffer(value);
|
|
2613
|
+
}
|
|
2614
|
+
if (tag == objectTag || tag == argsTag || isFunc && !object2) {
|
|
2615
|
+
result = {};
|
|
2616
|
+
} else {
|
|
2617
|
+
if (!cloneableTags[tag]) {
|
|
2618
|
+
return object2 ? value : {};
|
|
2619
|
+
}
|
|
2620
|
+
result = initCloneByTag(value, tag);
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
stack || (stack = new Stack());
|
|
2624
|
+
var stacked = stack.get(value);
|
|
2625
|
+
if (stacked) {
|
|
2626
|
+
return stacked;
|
|
2627
|
+
}
|
|
2628
|
+
stack.set(value, result);
|
|
2629
|
+
if (isSet(value)) {
|
|
2630
|
+
value.forEach(function(subValue) {
|
|
2631
|
+
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
|
2632
|
+
});
|
|
2633
|
+
} else if (isMap(value)) {
|
|
2634
|
+
value.forEach(function(subValue, key2) {
|
|
2635
|
+
result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
var keysFunc = getAllKeysIn;
|
|
2639
|
+
var props = isArr ? void 0 : keysFunc(value);
|
|
2640
|
+
arrayEach(props || value, function(subValue, key2) {
|
|
2641
|
+
if (props) {
|
|
2642
|
+
key2 = subValue;
|
|
2643
|
+
subValue = value[key2];
|
|
2644
|
+
}
|
|
2645
|
+
assignValue(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
|
2646
|
+
});
|
|
2647
|
+
return result;
|
|
2648
|
+
}
|
|
2649
|
+
function last(array2) {
|
|
2650
|
+
var length = array2 == null ? 0 : array2.length;
|
|
2651
|
+
return length ? array2[length - 1] : void 0;
|
|
2652
|
+
}
|
|
2653
|
+
function parent(object2, path) {
|
|
2654
|
+
return path.length < 2 ? object2 : baseGet(object2, baseSlice(path, 0, -1));
|
|
2655
|
+
}
|
|
2656
|
+
function isNil(value) {
|
|
2657
|
+
return value == null;
|
|
2658
|
+
}
|
|
2659
|
+
function baseUnset(object2, path) {
|
|
2660
|
+
path = castPath(path, object2);
|
|
2661
|
+
object2 = parent(object2, path);
|
|
2662
|
+
return object2 == null || delete object2[toKey(last(path))];
|
|
2663
|
+
}
|
|
2664
|
+
function customOmitClone(value) {
|
|
2665
|
+
return isPlainObject(value) ? void 0 : value;
|
|
2666
|
+
}
|
|
2667
|
+
var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
|
|
2668
|
+
var omit = flatRest(function(object2, paths) {
|
|
2669
|
+
var result = {};
|
|
2670
|
+
if (object2 == null) {
|
|
2671
|
+
return result;
|
|
2672
|
+
}
|
|
2673
|
+
var isDeep = false;
|
|
2674
|
+
paths = arrayMap(paths, function(path) {
|
|
2675
|
+
path = castPath(path, object2);
|
|
2676
|
+
isDeep || (isDeep = path.length > 1);
|
|
2677
|
+
return path;
|
|
2678
|
+
});
|
|
2679
|
+
copyObject(object2, getAllKeysIn(object2), result);
|
|
2680
|
+
if (isDeep) {
|
|
2681
|
+
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
|
|
2682
|
+
}
|
|
2683
|
+
var length = paths.length;
|
|
2684
|
+
while (length--) {
|
|
2685
|
+
baseUnset(result, paths[length]);
|
|
2686
|
+
}
|
|
2687
|
+
return result;
|
|
2688
|
+
});
|
|
2689
|
+
const poiCategoriesToID = {
|
|
2690
|
+
SPORTS_CENTER: 7320,
|
|
2691
|
+
STADIUM: 7374,
|
|
2692
|
+
RESTAURANT: 7315,
|
|
2693
|
+
CAFE_PUB: 9376,
|
|
2694
|
+
HEALTH_CARE_SERVICE: 9663,
|
|
2695
|
+
HOSPITAL: 7321,
|
|
2696
|
+
HOSPITAL_POLYCLINIC: 7321,
|
|
2697
|
+
DOCTOR: 9373,
|
|
2698
|
+
SHOP: 9361,
|
|
2699
|
+
MARIJUANA_DISPENSARY: 9364,
|
|
2700
|
+
MARKET: 7332,
|
|
2701
|
+
PUBLIC_AMENITY: 9932,
|
|
2702
|
+
ROAD_TRAFFIC_CONTROL_CENTER: 7301,
|
|
2703
|
+
POST_OFFICE: 7324,
|
|
2704
|
+
COLLEGE_UNIVERSITY: 7377,
|
|
2705
|
+
OPEN_PARKING_AREA: 7369,
|
|
2706
|
+
CLUB_ASSOCIATION: 9937,
|
|
2707
|
+
CAMPING_GROUND: 7360,
|
|
2708
|
+
HOLIDAY_RENTAL: 7304,
|
|
2709
|
+
VACATION_RENTAL: 7304,
|
|
2710
|
+
AMUSEMENT_PARK: 9902,
|
|
2711
|
+
RESIDENTIAL_ACCOMMODATION: 7303,
|
|
2712
|
+
AGRICULTURAL_BUSINESS: 7335,
|
|
2713
|
+
AGRICULTURE: 7335,
|
|
2714
|
+
AIRPORT: 7383,
|
|
2715
|
+
COMPANY: 9352,
|
|
2716
|
+
NIGHTLIFE: 9379,
|
|
2717
|
+
REPAIR_SHOP: 7310,
|
|
2718
|
+
REPAIR_FACILITY: 7310,
|
|
2719
|
+
HOTEL_MOTEL: 7314,
|
|
2720
|
+
SCHOOL: 7372,
|
|
2721
|
+
AUTOMOTIVE_DEALER: 9910,
|
|
2722
|
+
MOVIE_THEATER: 7342,
|
|
2723
|
+
CINEMA: 7342,
|
|
2724
|
+
THEATER: 7318,
|
|
2725
|
+
PARK_RECREATION_AREA: 9362,
|
|
2726
|
+
PLACE_OF_WORSHIP: 7339,
|
|
2727
|
+
IMPORTANT_TOURIST_ATTRACTION: 7376,
|
|
2728
|
+
TOURIST_ATTRACTION: 7376,
|
|
2729
|
+
TRAIL_SYSTEM: 7302,
|
|
2730
|
+
TRAILS: 7302,
|
|
2731
|
+
RAILWAY_STATION: 7380,
|
|
2732
|
+
PUBLIC_TRANSPORT_STOP: 9942,
|
|
2733
|
+
EXCHANGE: 9160,
|
|
2734
|
+
MARINA: 7347,
|
|
2735
|
+
WEIGH_STATION: 7359,
|
|
2736
|
+
CAR_WASH: 9155,
|
|
2737
|
+
LEISURE_CENTER: 9378,
|
|
2738
|
+
ACCESS_GATEWAY: 7389,
|
|
2739
|
+
GEOGRAPHIC_FEATURE: 8099,
|
|
2740
|
+
URBAN_STATION: 7380004,
|
|
2741
|
+
ADVENTURE_VEHICLE_TRAIL: 7302003,
|
|
2742
|
+
ADVERTISING_COMPANY: 9352003,
|
|
2743
|
+
AFGHAN_RESTAURANT: 7315081,
|
|
2744
|
+
AFRICAN_RESTAURANT: 7315002,
|
|
2745
|
+
AGRICULTURAL_SUPPLIES: 9361073,
|
|
2746
|
+
AGRICULTURAL_TECHNOLOGY: 9352012,
|
|
2747
|
+
AIRFIELD: 7383005,
|
|
2748
|
+
AIRLINE_COMPANY: 9352034,
|
|
2749
|
+
AIRLINE_ACCESS: 7389002,
|
|
2750
|
+
ALGERIAN_RESTAURANT: 7315082,
|
|
2751
|
+
AMBULANCE_UNIT: 9663005,
|
|
2752
|
+
AMERICAN_RESTAURANT: 7315003,
|
|
2753
|
+
AMPHITHEATER: 7318007,
|
|
2754
|
+
AMUSEMENT_ARCADE: 9902002,
|
|
2755
|
+
AMUSEMENT_PLACE: 9902004,
|
|
2756
|
+
ANIMAL_SERVICES: 9361048,
|
|
2757
|
+
ANIMAL_SHELTER: 9352045,
|
|
2758
|
+
ANTIQUE_ART_SHOP: 9361049,
|
|
2759
|
+
APARTMENT_RENTAL: 7304006,
|
|
2760
|
+
AQUATIC_ZOO: 9927004,
|
|
2761
|
+
ARABIAN_RESTAURANT: 7315083,
|
|
2762
|
+
ARCH: 7376012,
|
|
2763
|
+
ARGENTINIAN_RESTAURANT: 7315084,
|
|
2764
|
+
ARMENIAN_RESTAURANT: 7315085,
|
|
2765
|
+
ART_SCHOOL: 7372012,
|
|
2766
|
+
ASHRAM: 7339007,
|
|
2767
|
+
ASIAN_RESTAURANT: 7315062,
|
|
2768
|
+
ATHLETICS_TRACK: 7374002,
|
|
2769
|
+
ATV_DEALER: 9910009,
|
|
2770
|
+
AUSTRALIAN_RESTAURANT: 7315086,
|
|
2771
|
+
AUSTRIAN_RESTAURANT: 7315004,
|
|
2772
|
+
AUTOMOBILE_COMPANY: 9352013,
|
|
2773
|
+
AUTOMOBILE_MANUFACTURING: 9352041,
|
|
2774
|
+
BAGS_LEATHERWEAR: 9361058,
|
|
2775
|
+
BANQUET_ROOMS: 7315146,
|
|
2776
|
+
BAR: 9379004,
|
|
2777
|
+
BARBECUE_RESTAURANT: 7315005,
|
|
2778
|
+
BASEBALL_PARK: 7374009,
|
|
2779
|
+
BASKETBALL_ARENA: 7374012,
|
|
2780
|
+
BASQUE_RESTAURANT: 7315087,
|
|
2781
|
+
BATTLEFIELD: 9362002,
|
|
2782
|
+
BAY: 8099016,
|
|
2783
|
+
BEACH_CLUB: 9937002,
|
|
2784
|
+
BEAUTY_SALON: 9361067,
|
|
2785
|
+
BEAUTY_SUPPLIES: 9361050,
|
|
2786
|
+
B_B_GUEST_HOUSE: 7314002,
|
|
2787
|
+
BELGIAN_RESTAURANT: 7315006,
|
|
2788
|
+
BETTING_STATION: 9361072,
|
|
2789
|
+
BISTRO: 7315007,
|
|
2790
|
+
BLOOD_BANK: 9663004,
|
|
2791
|
+
BOAT_DEALER: 9910004,
|
|
2792
|
+
BOAT_LAUNCHING_RAMP: 9362032,
|
|
2793
|
+
BOATING_EQUIPMENT_ACCESSORIES: 9361083,
|
|
2794
|
+
BODYSHOP: 7310002,
|
|
2795
|
+
BOLIVIAN_RESTAURANT: 7315088,
|
|
2796
|
+
BOOK_SHOP: 9361002,
|
|
2797
|
+
BOSNIAN_RESTAURANT: 7315089,
|
|
2798
|
+
BOWLING_CENTER: 9378002,
|
|
2799
|
+
BRAZILIAN_RESTAURANT: 7315072,
|
|
2800
|
+
BRIDGE: 7376010,
|
|
2801
|
+
BRIDGE_TUNNEL_OPERATIONS: 9352035,
|
|
2802
|
+
BRITISH_RESTAURANT: 7315008,
|
|
2803
|
+
BUFFET_RESTAURANT: 7315142,
|
|
2804
|
+
BUILDING: 7376002,
|
|
2805
|
+
BULGARIAN_RESTAURANT: 7315090,
|
|
2806
|
+
BUNGALOW_RENTAL: 7304004,
|
|
2807
|
+
BURMESE_RESTAURANT: 7315091,
|
|
2808
|
+
BUS_DEALER: 9910008,
|
|
2809
|
+
BUS_CHARTER_COMPANY: 9352025,
|
|
2810
|
+
BUS_LINES: 9352027,
|
|
2811
|
+
BUS_STOP: 9942002,
|
|
2812
|
+
BUSINESS_SERVICES: 9352039,
|
|
2813
|
+
CABARET_THEATER: 7318006,
|
|
2814
|
+
CABINS_LODGES: 7314007,
|
|
2815
|
+
CABLE_TELEPHONE_COMPANY: 9352040,
|
|
2816
|
+
CAFE: 9376002,
|
|
2817
|
+
CAFETERIA: 7315147,
|
|
2818
|
+
CALIFORNIAN_RESTAURANT: 7315009,
|
|
2819
|
+
CAMBODIAN_RESTAURANT: 7315092,
|
|
2820
|
+
CANADIAN_RESTAURANT: 7315010,
|
|
2821
|
+
CAPE: 8099020,
|
|
2822
|
+
CAR_DEALER: 9910002,
|
|
2823
|
+
CAR_GLASS_REPLACEMENT_SHOP: 7310003,
|
|
2824
|
+
CARAVAN_SITE: 7360003,
|
|
2825
|
+
CARIBBEAN_RESTAURANT: 7315011,
|
|
2826
|
+
CATERING_SERVICES: 9352043,
|
|
2827
|
+
CAVE: 8099003,
|
|
2828
|
+
C_DS_DVD_VIDEOS: 9361003,
|
|
2829
|
+
VIDEO_RENTAL_SHOP: 9361044,
|
|
2830
|
+
CEMETERY: 9362003,
|
|
2831
|
+
CHALET_RENTAL: 7304005,
|
|
2832
|
+
CHEMICAL_COMPANY: 9352014,
|
|
2833
|
+
CHICKEN_RESTAURANT: 7315070,
|
|
2834
|
+
CHILD_CARE_FACILITY: 7372003,
|
|
2835
|
+
CHILEAN_RESTAURANT: 7315093,
|
|
2836
|
+
CHINESE_RESTAURANT: 7315012,
|
|
2837
|
+
CHRISTMAS_HOLIDAY_SHOP: 9361082,
|
|
2838
|
+
CHURCH: 7339002,
|
|
2839
|
+
CLEANING_SERVICES: 9352029,
|
|
2840
|
+
CHILDRENS_CLOTHES: 9361004,
|
|
2841
|
+
FOOTWEAR_SHOE_REPAIRS: 9361005,
|
|
2842
|
+
CLOTHING_SHOP: 9361006,
|
|
2843
|
+
MENS_CLOTHING: 9361007,
|
|
2844
|
+
SPECIALTY_CLOTHING_SHOP: 9361079,
|
|
2845
|
+
WOMENS_CLOTHING: 9361008,
|
|
2846
|
+
COACH_STOP: 9942005,
|
|
2847
|
+
COCKTAIL_BAR: 9379006,
|
|
2848
|
+
COFFEE_SHOP: 9376006,
|
|
2849
|
+
COLOMBIAN_RESTAURANT: 7315094,
|
|
2850
|
+
COMEDY_CLUB: 9379009,
|
|
2851
|
+
COMPUTER_DATA_SERVICES: 9352004,
|
|
2852
|
+
SOFTWARE_COMPANY: 9352005,
|
|
2853
|
+
CONCERT_HALL: 7318002,
|
|
2854
|
+
CONDOMINIUM_COMPLEX: 7303006,
|
|
2855
|
+
CONSTRUCTION_COMPANY: 9352032,
|
|
2856
|
+
CONSTRUCTION_MATERIAL_EQUIPMENT: 9361042,
|
|
2857
|
+
CONVENIENCE_STORE: 9361009,
|
|
2858
|
+
CORSICAN_RESTAURANT: 7315095,
|
|
2859
|
+
COTTAGE_RENTAL: 7304002,
|
|
2860
|
+
COVE: 8099017,
|
|
2861
|
+
CREOLE_RESTAURANT: 7315063,
|
|
2862
|
+
CREPERIE: 7315013,
|
|
2863
|
+
CRICKET_GROUND: 7374003,
|
|
2864
|
+
CUBAN_RESTAURANT: 7315096,
|
|
2865
|
+
CULINARY_SCHOOL: 7372015,
|
|
2866
|
+
CYPRIOT_RESTAURANT: 7315097,
|
|
2867
|
+
CZECH_RESTAURANT: 7315068,
|
|
2868
|
+
DAM: 7376007,
|
|
2869
|
+
DANCE_STUDIO_SCHOOL: 9378003,
|
|
2870
|
+
DANISH_RESTAURANT: 7315098,
|
|
2871
|
+
DELICATESSEN: 9361060,
|
|
2872
|
+
DINNER_THEATER: 7318008,
|
|
2873
|
+
DISCO_CLUB: 9379002,
|
|
2874
|
+
DIVERSIFIED_FINANCIALS: 9352006,
|
|
2875
|
+
DOMINICAN_RESTAURANT: 7315099,
|
|
2876
|
+
DONGBEI_RESTAURANT: 7315057,
|
|
2877
|
+
DOUGHNUT_RESTAURANT: 7315079,
|
|
2878
|
+
DRIVE_THROUGH_BOTTLE_SHOP: 9361076,
|
|
2879
|
+
DRIVE_IN_MOVIES: 7342003,
|
|
2880
|
+
DRIVING_SCHOOL: 7372016,
|
|
2881
|
+
DRUG_STORE: 9361051,
|
|
2882
|
+
DRY_CLEANER: 9361010,
|
|
2883
|
+
DUNE: 8099005,
|
|
2884
|
+
DUTCH_RESTAURANT: 7315014,
|
|
2885
|
+
EGYPTIAN_RESTAURANT: 7315100,
|
|
2886
|
+
ELECTRICAL_APPLIANCES_SHOP: 9361052,
|
|
2887
|
+
CAMERAS_PHOTOGRAPHY: 9361011,
|
|
2888
|
+
COMPUTER_COMPUTER_SUPPLIES: 9361012,
|
|
2889
|
+
CONSUMER_ELECTRONICS: 9361013,
|
|
2890
|
+
OFFICE_EQUIPMENT: 9361014,
|
|
2891
|
+
ENGLISH_RESTAURANT: 7315101,
|
|
2892
|
+
EQUIPMENT_RENTAL: 9352038,
|
|
2893
|
+
EROTIC_RESTAURANT: 7315132,
|
|
2894
|
+
ETHIOPIAN_RESTAURANT: 7315102,
|
|
2895
|
+
EXOTIC_RESTAURANT: 7315133,
|
|
2896
|
+
FACTORY_OUTLET: 9361016,
|
|
2897
|
+
FAIRGROUND: 9362017,
|
|
2898
|
+
FARM: 7335004,
|
|
2899
|
+
FARMERS_MARKET: 7332004,
|
|
2900
|
+
FAST_FOOD: 7315015,
|
|
2901
|
+
PHILIPPINE_RESTAURANT: 7315016,
|
|
2902
|
+
FINNISH_RESTAURANT: 7315104,
|
|
2903
|
+
FISHING_HUNTING_AREA: 9362016,
|
|
2904
|
+
FITNESS_CLUB_CENTER: 7320002,
|
|
2905
|
+
FLATS_APARTMENT_COMPLEX: 7303003,
|
|
2906
|
+
FLORISTS: 9361017,
|
|
2907
|
+
FLYING_CLUB: 9378004,
|
|
2908
|
+
FONDUE_RESTAURANT: 7315134,
|
|
2909
|
+
BAKERY: 9361018,
|
|
2910
|
+
BUTCHER: 9361019,
|
|
2911
|
+
FISHMONGER: 9361020,
|
|
2912
|
+
FOOD_MARKET: 9361021,
|
|
2913
|
+
GREENGROCER: 9361022,
|
|
2914
|
+
GROCERY_STORE: 9361023,
|
|
2915
|
+
OTHER_FOOD_SHOPS: 9361024,
|
|
2916
|
+
WINE_SPIRITS: 9361025,
|
|
2917
|
+
FOOTBALL_STADIUM: 7374010,
|
|
2918
|
+
FOREST_AREA: 9362015,
|
|
2919
|
+
FRENCH_RESTAURANT: 7315017,
|
|
2920
|
+
FUNERAL_SERVICE_MORTUARIES: 9352036,
|
|
2921
|
+
FURNITURE_HOME_FURNISHINGS: 9361054,
|
|
2922
|
+
FUSION_RESTAURANT: 7315071,
|
|
2923
|
+
CAR_REPAIR_AND_SERVICE: 7310004,
|
|
2924
|
+
GENERAL_PRACTITIONER: 9373002,
|
|
2925
|
+
GERMAN_RESTAURANT: 7315018,
|
|
2926
|
+
GIFTS_CARDS_NOVELTIES_SOUVENIRS: 9361026,
|
|
2927
|
+
GLASSWARE_CERAMIC_SHOP: 9361055,
|
|
2928
|
+
GOLD_EXCHANGE: 9160003,
|
|
2929
|
+
GREEK_RESTAURANT: 7315019,
|
|
2930
|
+
GRILL_RESTAURANT: 7315020,
|
|
2931
|
+
GUANGDONG_RESTAURANT: 7315054,
|
|
2932
|
+
GURUDWARA: 7339006,
|
|
2933
|
+
HAIRDRESSER: 9361027,
|
|
2934
|
+
HAMBURGER_RESTAURANT: 7315069,
|
|
2935
|
+
HARBOR: 8099018,
|
|
2936
|
+
HARDWARE_STORE: 9361069,
|
|
2937
|
+
HAWAIIAN_RESTAURANT: 7315021,
|
|
2938
|
+
HIGH_SCHOOL: 7372006,
|
|
2939
|
+
HIKING_TRAIL: 7302004,
|
|
2940
|
+
HILL: 8099025,
|
|
2941
|
+
HISTORIC_SITE: 9362004,
|
|
2942
|
+
HISTORICAL_PARK: 9362005,
|
|
2943
|
+
HOBBY_SHOP: 9361053,
|
|
2944
|
+
HOCKEY_CLUB: 9937003,
|
|
2945
|
+
HOME_APPLIANCE_REPAIR: 9352044,
|
|
2946
|
+
HORSE_RACING_TRACK: 7374005,
|
|
2947
|
+
HORSE_RIDING_CENTER: 7320003,
|
|
2948
|
+
HORTICULTURE: 7335002,
|
|
2949
|
+
HOSPITAL_FOR_WOMEN_AND_CHILDREN: 7321005,
|
|
2950
|
+
HOSPITAL_OF_CHINESE_MEDICINE: 7321004,
|
|
2951
|
+
HOSTEL: 7314004,
|
|
2952
|
+
HOT_POT_RESTAURANT: 7315058,
|
|
2953
|
+
HOTEL: 7314003,
|
|
2954
|
+
CARPET_FLOOR_COVERINGS: 9361028,
|
|
2955
|
+
CURTAINS_TEXTILES: 9361029,
|
|
2956
|
+
DO_IT_YOURSELF_CENTERS: 9361030,
|
|
2957
|
+
HOUSE_GARDEN_FURNITURE_FITTINGS: 9361031,
|
|
2958
|
+
GARDEN_CENTERS_SERVICES: 9361032,
|
|
2959
|
+
GLASS_WINDOWS_STORE: 9361080,
|
|
2960
|
+
KITCHENS_BATHROOMS: 9361033,
|
|
2961
|
+
LIGHTING_SHOPS: 9361034,
|
|
2962
|
+
PAINTING_DECORATING: 9361035,
|
|
2963
|
+
HUNAN_RESTAURANT: 7315052,
|
|
2964
|
+
HUNGARIAN_RESTAURANT: 7315022,
|
|
2965
|
+
ICE_CREAM_PARLOR: 7315078,
|
|
2966
|
+
ICE_HOCKEY_ARENA: 7374008,
|
|
2967
|
+
IMPORT_EXPORT_AND_DISTRIBUTION: 9352042,
|
|
2968
|
+
INDIAN_RESTAURANT: 7315023,
|
|
2969
|
+
INDONESIAN_RESTAURANT: 7315024,
|
|
2970
|
+
INFORMAL_MARKET: 7332002,
|
|
2971
|
+
INSURANCE_COMPANY: 9352007,
|
|
2972
|
+
INTERNATIONAL_RESTAURANT: 7315073,
|
|
2973
|
+
INTERNATIONAL_RAILROAD_STATION: 7380002,
|
|
2974
|
+
INTERNET_CAFE: 9376004,
|
|
2975
|
+
INVESTMENT_ADVISOR: 9352037,
|
|
2976
|
+
IRANIAN_RESTAURANT: 7315105,
|
|
2977
|
+
IRISH_RESTAURANT: 7315065,
|
|
2978
|
+
ISLAND: 8099022,
|
|
2979
|
+
ISRAELI_RESTAURANT: 7315106,
|
|
2980
|
+
ITALIAN_RESTAURANT: 7315025,
|
|
2981
|
+
JAMAICAN_RESTAURANT: 7315066,
|
|
2982
|
+
JAPANESE_RESTAURANT: 7315026,
|
|
2983
|
+
JAZZ_CLUB: 9379008,
|
|
2984
|
+
JEWELRY_CLOCKS_WATCHES: 9361036,
|
|
2985
|
+
JEWISH_RESTAURANT: 7315027,
|
|
2986
|
+
JUNIOR_COLLEGE_COMMUNITY_COLLEGE: 7377003,
|
|
2987
|
+
KARAOKE_CLUB: 9379010,
|
|
2988
|
+
KOREAN_RESTAURANT: 7315028,
|
|
2989
|
+
KOSHER_RESTAURANT: 7315067,
|
|
2990
|
+
LAGOON: 8099019,
|
|
2991
|
+
LAKESHORE: 9362006,
|
|
2992
|
+
LANGUAGE_SCHOOL: 7372010,
|
|
2993
|
+
LATIN_AMERICAN_RESTAURANT: 7315029,
|
|
2994
|
+
LAUNDRY: 9361045,
|
|
2995
|
+
LEBANESE_RESTAURANT: 7315030,
|
|
2996
|
+
LEGAL_SERVICES: 9352023,
|
|
2997
|
+
LOCAL_POST_OFFICE: 7324003,
|
|
2998
|
+
LOCAL_SPECIALITIES_SHOP: 9361056,
|
|
2999
|
+
LOCALE: 8099027,
|
|
3000
|
+
LOTTERY_SHOP: 9361071,
|
|
3001
|
+
LUXEMBOURGIAN_RESTAURANT: 7315107,
|
|
3002
|
+
MACROBIOTIC_RESTAURANT: 7315135,
|
|
3003
|
+
MAGHRIB_RESTAURANT: 7315108,
|
|
3004
|
+
DELIVERY_SERVICE: 9352008,
|
|
3005
|
+
MALTESE_RESTAURANT: 7315031,
|
|
3006
|
+
MANUFACTURING_COMPANY: 9352011,
|
|
3007
|
+
MARINE_ELECTRONIC_EQUIPMENT: 9361065,
|
|
3008
|
+
MARSH: 8099023,
|
|
3009
|
+
MAURITIAN_RESTAURANT: 7315109,
|
|
3010
|
+
MAUSOLEUM_GRAVE: 7376011,
|
|
3011
|
+
MECHANICAL_ENGINEERING: 9352016,
|
|
3012
|
+
MEDICAL_SUPPLIES_EQUIPMENT: 9361043,
|
|
3013
|
+
MEDITERRANEAN_RESTAURANT: 7315032,
|
|
3014
|
+
MEMORIAL: 9362007,
|
|
3015
|
+
SUBWAY_STATION: 7380005,
|
|
3016
|
+
MEXICAN_RESTAURANT: 7315033,
|
|
3017
|
+
MICROBREWERY: 9376007,
|
|
3018
|
+
MIDDLE_EASTERN_RESTAURANT: 7315034,
|
|
3019
|
+
MIDDLE_SCHOOL: 7372014,
|
|
3020
|
+
MILITARY_AIRPORT: 7383004,
|
|
3021
|
+
MINERAL_HOT_SPRINGS: 8099021,
|
|
3022
|
+
MINING_COMPANY: 9352031,
|
|
3023
|
+
MOBILE_PHONE_SHOP: 9361075,
|
|
3024
|
+
MONGOLIAN_RESTAURANT: 7315110,
|
|
3025
|
+
MONUMENT: 7376003,
|
|
3026
|
+
MOROCCAN_RESTAURANT: 7315074,
|
|
3027
|
+
MOSQUE: 7339003,
|
|
3028
|
+
MOTEL: 7314006,
|
|
3029
|
+
MOTOR_RACING_STADIUM: 7374011,
|
|
3030
|
+
MOTORCYCLE_DEALER: 9910003,
|
|
3031
|
+
MOTORCYCLE_REPAIR: 7310008,
|
|
3032
|
+
MOUNTAIN_BIKE_TRAIL: 7302002,
|
|
3033
|
+
MOUNTAIN_PEAK: 8099002,
|
|
3034
|
+
MOVING_STORAGE_COMPANY: 9352033,
|
|
3035
|
+
MULTI_PURPOSE_STADIUM: 7374006,
|
|
3036
|
+
MUSIC_CENTER: 7318003,
|
|
3037
|
+
MUSIC_INSTRUMENTS_STORE: 9361059,
|
|
3038
|
+
MUSSELS_RESTAURANT: 7315136,
|
|
3039
|
+
NAIL_SALON: 9361068,
|
|
3040
|
+
NATIONAL_RAILROAD_STATION: 7380003,
|
|
3041
|
+
NATURAL_RECREATION_ATTRACTION: 9362030,
|
|
3042
|
+
NEPALESE_RESTAURANT: 7315111,
|
|
3043
|
+
NETBALL_STADIUM: 7374014,
|
|
3044
|
+
NEWSAGENTS_TOBACCONISTS: 9361037,
|
|
3045
|
+
NORWEGIAN_RESTAURANT: 7315112,
|
|
3046
|
+
OASIS: 8099011,
|
|
3047
|
+
OBSERVATORY: 7376005,
|
|
3048
|
+
OEM: 9352021,
|
|
3049
|
+
OIL_NATURAL_GAS: 9352030,
|
|
3050
|
+
OPERA_HOUSE: 7318004,
|
|
3051
|
+
OPTICIAN: 9361038,
|
|
3052
|
+
ORGANIC_FOOD_RESTAURANT: 7315075,
|
|
3053
|
+
ORIENTAL_RESTAURANT: 7315035,
|
|
3054
|
+
OTHER_REPAIR_SHOPS: 7310005,
|
|
3055
|
+
OTHER_WINTER_SPORT: 9362025,
|
|
3056
|
+
PAGODA: 7339008,
|
|
3057
|
+
PAKISTANI_RESTAURANT: 7315127,
|
|
3058
|
+
PAN: 8099009,
|
|
3059
|
+
PARK: 9362008,
|
|
3060
|
+
PARKWAY: 9362009,
|
|
3061
|
+
PASSENGER_TRANSPORT_TICKET_OFFICE: 9932002,
|
|
3062
|
+
PAWN_SHOP: 9361070,
|
|
3063
|
+
PEDESTRIAN_SUBWAY: 9932003,
|
|
3064
|
+
PERSONAL_CARE_FACILITY: 9663003,
|
|
3065
|
+
PERSONAL_SERVICE: 9663002,
|
|
3066
|
+
PERUVIAN_RESTAURANT: 7315061,
|
|
3067
|
+
PET_SUPPLIES: 9361064,
|
|
3068
|
+
PHARMACEUTICAL_COMPANY: 9352018,
|
|
3069
|
+
PHOTO_LAB_DEVELOPMENT: 9361046,
|
|
3070
|
+
PHOTOCOPY_SHOP: 9361047,
|
|
3071
|
+
PICNIC_AREA: 9362033,
|
|
3072
|
+
PIZZERIA: 7315036,
|
|
3073
|
+
PLAIN_FLAT: 8099007,
|
|
3074
|
+
PLANETARIUM: 7376006,
|
|
3075
|
+
PLATEAU: 8099008,
|
|
3076
|
+
POLISH_RESTAURANT: 7315037,
|
|
3077
|
+
POLYNESIAN_RESTAURANT: 7315129,
|
|
3078
|
+
PORTUGUESE_RESTAURANT: 7315038,
|
|
3079
|
+
PRE_SCHOOL: 7372004,
|
|
3080
|
+
PRESERVE: 9362010,
|
|
3081
|
+
PRIMARY_PRODUCER: 7335003,
|
|
3082
|
+
PRIMARY_SCHOOL: 7372005,
|
|
3083
|
+
PRIVATE_AIRPORT: 7383003,
|
|
3084
|
+
PRIVATE_CLUB: 9379003,
|
|
3085
|
+
PROVENCAL_RESTAURANT: 7315130,
|
|
3086
|
+
PUB: 9376003,
|
|
3087
|
+
PUB_FOOD: 7315039,
|
|
3088
|
+
PUBLIC_MARKET: 7332003,
|
|
3089
|
+
PUBLIC_AIRPORT: 7383002,
|
|
3090
|
+
PUBLIC_CALL_BOX: 9932004,
|
|
3091
|
+
PUBLIC_HEALTH_TECHNOLOGY_COMPANY: 9352017,
|
|
3092
|
+
PUBLISHING_TECHNOLOGIES: 9352019,
|
|
3093
|
+
QUARRY: 8099026,
|
|
3094
|
+
RACE_TRACK: 7374013,
|
|
3095
|
+
RAILROAD_SIDING: 7380006,
|
|
3096
|
+
RAPIDS: 8099015,
|
|
3097
|
+
REAL_ESTATE_COMPANY: 9352009,
|
|
3098
|
+
REAL_ESTATE_AGENT: 9361015,
|
|
3099
|
+
RECREATION_AREA: 9362011,
|
|
3100
|
+
RECREATIONAL_CAMPING_GROUND: 7360002,
|
|
3101
|
+
RECREATIONAL_VEHICLE_DEALER: 9910005,
|
|
3102
|
+
RECYCLING_SHOP: 9361057,
|
|
3103
|
+
REEF: 8099014,
|
|
3104
|
+
RESERVOIR: 8099013,
|
|
3105
|
+
RESIDENTIAL_ESTATE: 7303004,
|
|
3106
|
+
RESORT: 7314005,
|
|
3107
|
+
REST_CAMP: 7314008,
|
|
3108
|
+
RETAIL_OUTLET: 9361063,
|
|
3109
|
+
RETIREMENT_COMMUNITY: 7303002,
|
|
3110
|
+
RIDGE: 8099004,
|
|
3111
|
+
RIVER_CROSSING: 8099024,
|
|
3112
|
+
ROAD_RESCUE: 9932006,
|
|
3113
|
+
ROADSIDE_RESTAURANT: 7315041,
|
|
3114
|
+
ROCK_CLIMBING_TRAIL: 7302006,
|
|
3115
|
+
ROCKS: 8099012,
|
|
3116
|
+
RUGBY_GROUND: 7374007,
|
|
3117
|
+
ROMANIAN_RESTAURANT: 7315131,
|
|
3118
|
+
RUSSIAN_RESTAURANT: 7315040,
|
|
3119
|
+
SALAD_BAR: 7315143,
|
|
3120
|
+
CAR_ACCESSORIES: 7310006,
|
|
3121
|
+
SANDWICH_RESTAURANT: 7315042,
|
|
3122
|
+
SAUNA_SOLARIUM_MASSAGE: 9378005,
|
|
3123
|
+
SAVINGS_INSTITUTION: 9352010,
|
|
3124
|
+
SAVOY_RESTAURANT: 7315113,
|
|
3125
|
+
SCANDINAVIAN_RESTAURANT: 7315114,
|
|
3126
|
+
SCOTTISH_RESTAURANT: 7315115,
|
|
3127
|
+
SEAFOOD: 7315043,
|
|
3128
|
+
SEASHORE: 9362013,
|
|
3129
|
+
SECURED_ENTRANCE: 7389004,
|
|
3130
|
+
SECURITY_PRODUCTS: 9361078,
|
|
3131
|
+
SENIOR_HIGH_SCHOOL: 7372007,
|
|
3132
|
+
SERVICE_COMPANY: 9352002,
|
|
3133
|
+
SHANDONG_RESTAURANT: 7315053,
|
|
3134
|
+
SHANGHAI_RESTAURANT: 7315055,
|
|
3135
|
+
SHOPPING_SERVICE: 9361062,
|
|
3136
|
+
SICHUAN_RESTAURANT: 7315056,
|
|
3137
|
+
SICILIAN_RESTAURANT: 7315116,
|
|
3138
|
+
SKI_RESORT: 9362026,
|
|
3139
|
+
SLAVIC_RESTAURANT: 7315117,
|
|
3140
|
+
SLOVAK_RESTAURANT: 7315080,
|
|
3141
|
+
SNACKS_RESTAURANT: 7315139,
|
|
3142
|
+
SNOOKER_POOL_BILLIARD: 9378006,
|
|
3143
|
+
SOCCER_STADIUM: 7374004,
|
|
3144
|
+
SOUL_FOOD: 7315064,
|
|
3145
|
+
SOUP_RESTAURANT: 7315140,
|
|
3146
|
+
SPANISH_RESTAURANT: 7315044,
|
|
3147
|
+
SPECIAL_HOSPITAL: 7321003,
|
|
3148
|
+
SPECIAL_SCHOOL: 7372013,
|
|
3149
|
+
SPECIALIST: 9373003,
|
|
3150
|
+
SPECIALTY_FOODS: 9361061,
|
|
3151
|
+
SPORT_SCHOOL: 7372011,
|
|
3152
|
+
SPORTS_EQUIPMENT_CLOTHING: 9361039,
|
|
3153
|
+
STAMP_SHOP: 9361074,
|
|
3154
|
+
STATION_ACCESS: 7389003,
|
|
3155
|
+
STATUE: 7376013,
|
|
3156
|
+
STEAK_HOUSE: 7315045,
|
|
3157
|
+
STOCK_EXCHANGE: 9160002,
|
|
3158
|
+
SUDANESE_RESTAURANT: 7315118,
|
|
3159
|
+
SUPERMARKETS_HYPERMARKETS: 7332005,
|
|
3160
|
+
SURINAMESE_RESTAURANT: 7315046,
|
|
3161
|
+
SUSHI_RESTAURANT: 7315148,
|
|
3162
|
+
SWEDISH_RESTAURANT: 7315119,
|
|
3163
|
+
SWISS_RESTAURANT: 7315047,
|
|
3164
|
+
SYNAGOG: 7339004,
|
|
3165
|
+
SYRIAN_RESTAURANT: 7315120,
|
|
3166
|
+
TAILOR_SHOP: 9361077,
|
|
3167
|
+
TAIWANESE_RESTAURANT: 7315059,
|
|
3168
|
+
TAKEOUT_FOOD: 7315145,
|
|
3169
|
+
TAPAS_RESTAURANT: 7315076,
|
|
3170
|
+
TAX_SERVICES: 9352022,
|
|
3171
|
+
TAXI_STAND: 9942003,
|
|
3172
|
+
TAXI_LIMOUSINE_SHUTTLE_SERVICE: 9352026,
|
|
3173
|
+
TEA_HOUSE: 9376005,
|
|
3174
|
+
TECHNICAL_SCHOOL: 7372009,
|
|
3175
|
+
TELECOMMUNICATIONS: 9352020,
|
|
3176
|
+
TEMPLE: 7339005,
|
|
3177
|
+
TEPPANYAKI_RESTAURANT: 7315121,
|
|
3178
|
+
THAI_RESTAURANT: 7315048,
|
|
3179
|
+
THEMATIC_SPORT_CENTER: 7320005,
|
|
3180
|
+
TIBETAN_RESTAURANT: 7315122,
|
|
3181
|
+
PUBLIC_TOILET: 9932005,
|
|
3182
|
+
TOWER: 7376009,
|
|
3183
|
+
TOWNHOUSE_COMPLEX: 7303005,
|
|
3184
|
+
TOYS_GAMES_SHOP: 9361040,
|
|
3185
|
+
TRAFFIC_SERVICE_CENTER: 7301002,
|
|
3186
|
+
TRAFFIC_CONTROL_DEPARTMENT: 7301002,
|
|
3187
|
+
STREETCAR_STOP: 9942004,
|
|
3188
|
+
TRANSPORT_COMPANY: 9352024,
|
|
3189
|
+
TRAVEL_AGENT: 9361041,
|
|
3190
|
+
TRUCK_DEALER: 9910006,
|
|
3191
|
+
TRUCK_REPAIR_AND_SERVICE: 7310009,
|
|
3192
|
+
TRUCK_WASH: 9155003,
|
|
3193
|
+
TUNISIAN_RESTAURANT: 7315123,
|
|
3194
|
+
TUNNEL: 7376008,
|
|
3195
|
+
TURKISH_RESTAURANT: 7315049,
|
|
3196
|
+
TIRE_SERVICE: 7310007,
|
|
3197
|
+
URUGUAYAN_RESTAURANT: 7315124,
|
|
3198
|
+
VALLEY: 8099006,
|
|
3199
|
+
VAN_DEALER: 9910007,
|
|
3200
|
+
VARIETY_STORE: 9361081,
|
|
3201
|
+
VEGETARIAN_RESTAURANT: 7315050,
|
|
3202
|
+
VENEZUELAN_RESTAURANT: 7315125,
|
|
3203
|
+
VIETNAMESE_RESTAURANT: 7315051,
|
|
3204
|
+
VILLA_RENTAL: 7304003,
|
|
3205
|
+
VOCATIONAL_SCHOOL: 7372008,
|
|
3206
|
+
WATER_HOLE: 7376014,
|
|
3207
|
+
WEDDING_SERVICES: 9352046,
|
|
3208
|
+
WEIGH_SCALES: 7359003,
|
|
3209
|
+
WELL: 8099010,
|
|
3210
|
+
WELSH_RESTAURANT: 7315126,
|
|
3211
|
+
WESTERN_RESTAURANT: 7315060,
|
|
3212
|
+
WHOLESALE_CLUB: 9361066,
|
|
3213
|
+
WILDERNESS_AREA: 9362014,
|
|
3214
|
+
WILDLIFE_PARK: 9927005,
|
|
3215
|
+
WINE_BAR: 9379007,
|
|
3216
|
+
YACHT_BASIN: 7347003,
|
|
3217
|
+
YOGURT_JUICE_BAR: 7315149,
|
|
3218
|
+
ZOO: 9927003,
|
|
3219
|
+
ZOOS_ARBORETA_BOTANICAL_GARDEN: 9927,
|
|
3220
|
+
ELECTRONICS_COMPANY: 9352015,
|
|
3221
|
+
RIVER_SCENIC_AREA: 9362036,
|
|
3222
|
+
HORSE_RIDING_TRAIL: 7302005,
|
|
3223
|
+
NATURAL_TOURIST_ATTRACTION: 7376004,
|
|
3224
|
+
OPEN_CAR_PARKING_AREA: 7369002,
|
|
3225
|
+
MEDICINAL_MARIJUANA_DISPENSARY: 9364002,
|
|
3226
|
+
RECREATIONAL_MARIJUANA_DISPENSARY: 9364003,
|
|
3227
|
+
ICE_SKATING_RINK: 9360,
|
|
3228
|
+
TENNIS_COURT: 9369,
|
|
3229
|
+
GOLF_COURSE: 9911,
|
|
3230
|
+
WATER_SPORT: 9371,
|
|
3231
|
+
SWIMMING_POOL: 7338,
|
|
3232
|
+
RESTAURANT_AREA: 9359,
|
|
3233
|
+
DENTIST: 9374,
|
|
3234
|
+
VETERINARIAN: 9375,
|
|
3235
|
+
PHARMACY: 7326,
|
|
3236
|
+
EMERGENCY_ROOM: 9956,
|
|
3237
|
+
DEPARTMENT_STORE: 7327,
|
|
3238
|
+
SHOPPING_CENTER: 7373,
|
|
3239
|
+
FIRE_STATION_BRIGADE: 7392,
|
|
3240
|
+
NON_GOVERNMENTAL_ORGANIZATION: 9152,
|
|
3241
|
+
PRISON_CORRECTIONAL_FACILITY: 9154,
|
|
3242
|
+
EMBASSY: 7365,
|
|
3243
|
+
LIBRARY: 9913,
|
|
3244
|
+
TRANSPORT_AUTHORITY_VEHICLE_REGISTRATION: 9151,
|
|
3245
|
+
WELFARE_ORGANIZATION: 9153,
|
|
3246
|
+
NATIVE_RESERVATION: 9389,
|
|
3247
|
+
COURTHOUSE: 9363,
|
|
3248
|
+
POLICE_STATION: 7322,
|
|
3249
|
+
PRIMARY_RESOURCE_UTILITY: 9150,
|
|
3250
|
+
GOVERNMENT_OFFICE: 7367,
|
|
3251
|
+
MILITARY_INSTALLATION: 9388,
|
|
3252
|
+
RENT_A_CAR_PARKING: 9930,
|
|
3253
|
+
MUSEUM: 7317,
|
|
3254
|
+
INDUSTRIAL_BUILDING: 9383,
|
|
3255
|
+
PARKING_GARAGE: 7313,
|
|
3256
|
+
TOURIST_INFORMATION_OFFICE: 7316,
|
|
3257
|
+
MEDIA_FACILITY: 9158,
|
|
3258
|
+
WINERY: 7349,
|
|
3259
|
+
EMERGENCY_MEDICAL_SERVICE: 7391,
|
|
3260
|
+
CASINO: 7341,
|
|
3261
|
+
MANUFACTURING_FACILITY: 9156,
|
|
3262
|
+
COMMERCIAL_BUILDING: 9382,
|
|
3263
|
+
CULTURAL_CENTER: 7319,
|
|
3264
|
+
EXHIBITION_CONVENTION_CENTER: 9377,
|
|
3265
|
+
RENT_A_CAR_FACILITY: 7312,
|
|
3266
|
+
TRUCK_STOP: 7358,
|
|
3267
|
+
ADVENTURE_SPORTS_FACILITY: 7305,
|
|
3268
|
+
ADVENTURE_SPORTS_VENUE: 7305,
|
|
3269
|
+
REST_AREA: 7395,
|
|
3270
|
+
RESEARCH_FACILITY: 9157,
|
|
3271
|
+
COURIER_DROP_BOX: 7388,
|
|
3272
|
+
GAS_STATION: 7311,
|
|
3273
|
+
PETROL_STATION: 7311,
|
|
3274
|
+
FUEL_FACILITIES: 7311,
|
|
3275
|
+
MOTORING_ORGANIZATION_OFFICE: 7368,
|
|
3276
|
+
CASH_DISPENSER: 7397,
|
|
3277
|
+
ATM: 7397,
|
|
3278
|
+
COMMUNITY_CENTER: 7363,
|
|
3279
|
+
BEACH: 9357,
|
|
3280
|
+
PORT_WAREHOUSE_FACILITY: 9159,
|
|
3281
|
+
ELECTRIC_VEHICLE_STATION: 7309,
|
|
3282
|
+
SCENIC_PANORAMIC_VIEW: 7337,
|
|
3283
|
+
ENTERTAINMENT: 9900,
|
|
3284
|
+
BUSINESS_PARK: 7378,
|
|
3285
|
+
BANK: 7328,
|
|
3286
|
+
HELIPAD_HELICOPTER_LANDING: 7308,
|
|
3287
|
+
CHECKPOINT: 9955,
|
|
3288
|
+
FRONTIER_CROSSING: 7366,
|
|
3289
|
+
MOUNTAIN_PASS: 9935,
|
|
3290
|
+
TOLL_GATE: 7375,
|
|
3291
|
+
FERRY_TERMINAL: 7352
|
|
3292
|
+
};
|
|
3293
|
+
const appendCommonParams = (urlParams, params) => {
|
|
3294
|
+
urlParams.append("apiVersion", String(params.apiVersion));
|
|
3295
|
+
urlParams.append("key", params.apiKey);
|
|
3296
|
+
params.language && urlParams.append("language", params.language);
|
|
3297
|
+
};
|
|
3298
|
+
const appendByRepeatingParamName = (urlParams, paramName, paramArray) => {
|
|
3299
|
+
for (const param of paramArray || []) {
|
|
3300
|
+
urlParams.append(paramName, param);
|
|
3301
|
+
}
|
|
3302
|
+
};
|
|
3303
|
+
const appendByJoiningParamValue = (urlParams, name, values) => {
|
|
3304
|
+
if (Array.isArray(values) && values.length > 0) {
|
|
3305
|
+
urlParams.append(name, values.join(","));
|
|
3306
|
+
}
|
|
3307
|
+
};
|
|
3308
|
+
const appendOptionalParam = (urlParams, name, value) => {
|
|
3309
|
+
!isNil(value) && urlParams.append(name, String(value));
|
|
3310
|
+
};
|
|
3311
|
+
const appendLatLonParamsFromPosition = (urlParams, hasLngLat) => {
|
|
3312
|
+
const position = core.getPosition(hasLngLat);
|
|
3313
|
+
if (position) {
|
|
3314
|
+
urlParams.append("lat", String(position[1]));
|
|
3315
|
+
urlParams.append("lon", String(position[0]));
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
const mapPOICategoriesToIDs = (poiCategories) => {
|
|
3319
|
+
return poiCategories.map((poiCategory) => {
|
|
3320
|
+
if (typeof poiCategory !== "number") {
|
|
3321
|
+
return poiCategoriesToID[poiCategory];
|
|
3322
|
+
}
|
|
3323
|
+
return poiCategory;
|
|
3324
|
+
});
|
|
3325
|
+
};
|
|
3326
|
+
const PLACES_URL_PATH = "/maps/orbis/places";
|
|
3327
|
+
const appendCommonSearchParams = (searchUrl, params) => {
|
|
3328
|
+
const urlParams = searchUrl.searchParams;
|
|
3329
|
+
appendCommonParams(urlParams, params);
|
|
3330
|
+
appendOptionalParam(urlParams, "limit", params.limit);
|
|
3331
|
+
appendLatLonParamsFromPosition(urlParams, params.position);
|
|
3332
|
+
appendByJoiningParamValue(urlParams, "fuelSet", params.fuelTypes);
|
|
3333
|
+
appendByJoiningParamValue(urlParams, "idxSet", params.indexes);
|
|
3334
|
+
appendByJoiningParamValue(urlParams, "brandSet", params.poiBrands);
|
|
3335
|
+
params.poiCategories && appendByJoiningParamValue(urlParams, "categorySet", mapPOICategoriesToIDs(params.poiCategories));
|
|
3336
|
+
appendByJoiningParamValue(urlParams, "connectorSet", params.connectors);
|
|
3337
|
+
appendByJoiningParamValue(urlParams, "mapcodes", params.mapcodes);
|
|
3338
|
+
appendByJoiningParamValue(urlParams, "extendedPostalCodesFor", params.extendedPostalCodesFor);
|
|
3339
|
+
appendOptionalParam(urlParams, "minPowerKW", params.minPowerKW);
|
|
3340
|
+
appendOptionalParam(urlParams, "maxPowerKW", params.maxPowerKW);
|
|
3341
|
+
appendOptionalParam(urlParams, "view", params.view);
|
|
3342
|
+
appendOptionalParam(urlParams, "openingHours", params.openingHours);
|
|
3343
|
+
appendOptionalParam(urlParams, "timeZone", params.timeZone);
|
|
3344
|
+
appendOptionalParam(urlParams, "relatedPois", params.relatedPois);
|
|
3345
|
+
appendByJoiningParamValue(urlParams, "entityTypeSet", params.geographyTypes);
|
|
3346
|
+
};
|
|
3347
|
+
const buildUrlBasePath$9 = (mergedOptions) => mergedOptions.customServiceBaseURL || `${mergedOptions.commonBaseURL}${PLACES_URL_PATH}/autocomplete/${mergedOptions.query}.json`;
|
|
3348
|
+
const buildAutocompleteSearchRequest = (params) => {
|
|
3349
|
+
const url = new URL(`${buildUrlBasePath$9(params)}`);
|
|
3350
|
+
const urlParams = url.searchParams;
|
|
3351
|
+
params.language = params.language ?? "en-GB";
|
|
3352
|
+
appendCommonParams(urlParams, params);
|
|
3353
|
+
appendOptionalParam(urlParams, "limit", params.limit);
|
|
3354
|
+
appendLatLonParamsFromPosition(urlParams, params.position);
|
|
3355
|
+
appendByJoiningParamValue(urlParams, "countrySet", params.countries);
|
|
3356
|
+
appendOptionalParam(urlParams, "radius", params.radiusMeters);
|
|
3357
|
+
appendByJoiningParamValue(urlParams, "resultSet", params.resultType);
|
|
3358
|
+
return url;
|
|
3359
|
+
};
|
|
3360
|
+
const csvLatLngToPosition = (csv) => {
|
|
3361
|
+
const splitLatLng = csv.split(",");
|
|
3362
|
+
return [Number(splitLatLng[1]), Number(splitLatLng[0])];
|
|
3363
|
+
};
|
|
3364
|
+
const positionToCSVLatLon = (position) => `${position[1]},${position[0]}`;
|
|
3365
|
+
const hasTopLeftPoint = (bbox) => {
|
|
3366
|
+
return bbox.topLeftPoint !== void 0;
|
|
3367
|
+
};
|
|
3368
|
+
const apiToGeoJSONBBox = (apiBBox) => {
|
|
3369
|
+
let westSouth;
|
|
3370
|
+
let eastNorth;
|
|
3371
|
+
if (hasTopLeftPoint(apiBBox)) {
|
|
3372
|
+
westSouth = [apiBBox.topLeftPoint.lon, apiBBox.btmRightPoint.lat];
|
|
3373
|
+
eastNorth = [apiBBox.btmRightPoint.lon, apiBBox.topLeftPoint.lat];
|
|
3374
|
+
} else {
|
|
3375
|
+
westSouth = csvLatLngToPosition(apiBBox.southWest);
|
|
3376
|
+
eastNorth = csvLatLngToPosition(apiBBox.northEast);
|
|
3377
|
+
}
|
|
3378
|
+
return [westSouth[0], westSouth[1], eastNorth[0], eastNorth[1]];
|
|
3379
|
+
};
|
|
3380
|
+
const latLonAPIToPosition = (point) => {
|
|
3381
|
+
return [point.lon, point.lat];
|
|
3382
|
+
};
|
|
3383
|
+
const parseAutocompleteSearchResponse = (apiResponse) => {
|
|
3384
|
+
const { position, ...geoBias } = apiResponse.context.geoBias || {};
|
|
3385
|
+
return {
|
|
3386
|
+
...apiResponse,
|
|
3387
|
+
context: {
|
|
3388
|
+
...apiResponse.context,
|
|
3389
|
+
geoBias: {
|
|
3390
|
+
...position && { position: latLonAPIToPosition(position) },
|
|
3391
|
+
radiusMeters: geoBias.radius
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
};
|
|
3395
|
+
};
|
|
3396
|
+
const autocompleteSearchTemplate = {
|
|
3397
|
+
requestValidation: { schema: autocompleteSearchRequestSchema },
|
|
3398
|
+
buildRequest: buildAutocompleteSearchRequest,
|
|
3399
|
+
sendRequest: get,
|
|
3400
|
+
parseResponse: parseAutocompleteSearchResponse
|
|
3401
|
+
};
|
|
3402
|
+
const autocompleteSearch = async (params, customTemplate) => callService(params, { ...autocompleteSearchTemplate, ...customTemplate }, "Autocomplete");
|
|
3403
|
+
const customize$8 = {
|
|
3404
|
+
autocompleteSearch,
|
|
3405
|
+
buildAutocompleteSearchRequest,
|
|
3406
|
+
parseAutocompleteSearchResponse,
|
|
3407
|
+
autocompleteSearchTemplate
|
|
3408
|
+
};
|
|
3409
|
+
const evChargingStationsAvailabilityRequestSchema = object({
|
|
3410
|
+
id: string()
|
|
3411
|
+
});
|
|
3412
|
+
const parseEVChargingStationsAvailabilityResponseError = (apiError, serviceName) => {
|
|
3413
|
+
const errorMessage = apiError.data?.detailedError?.message ?? apiError.message;
|
|
3414
|
+
return new SDKServiceError(errorMessage, serviceName, apiError.status);
|
|
3415
|
+
};
|
|
3416
|
+
const buildUrlBasePath$8 = (params) => params.customServiceBaseURL ?? `${params.commonBaseURL}${PLACES_URL_PATH}/ev/id`;
|
|
3417
|
+
const buildEVChargingStationsAvailabilityRequest = (params) => {
|
|
3418
|
+
const url = new URL(buildUrlBasePath$8(params));
|
|
3419
|
+
const urlParams = url.searchParams;
|
|
3420
|
+
appendCommonParams(urlParams, params);
|
|
3421
|
+
urlParams.append("id", params.id);
|
|
3422
|
+
return url;
|
|
3423
|
+
};
|
|
3424
|
+
const toChargingPointAvailability = (chargingStations) => {
|
|
3425
|
+
const availability = { count: 0, statusCounts: {} };
|
|
3426
|
+
for (const station of chargingStations) {
|
|
3427
|
+
for (const chargingPoint of station.chargingPoints) {
|
|
3428
|
+
availability.count++;
|
|
3429
|
+
availability.statusCounts[chargingPoint.status] = (availability.statusCounts[chargingPoint.status] || 0) + 1;
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
return availability;
|
|
3433
|
+
};
|
|
3434
|
+
const areEqual = (connectorA, connectorB) => connectorA.type === connectorB.type && connectorA.ratedPowerKW === connectorB.ratedPowerKW;
|
|
3435
|
+
const addConnectorStatus = (connectors, status, availabilities) => {
|
|
3436
|
+
if (!connectors) {
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
for (const connector of connectors) {
|
|
3440
|
+
const existingAvailability = availabilities.find(
|
|
3441
|
+
(connectorAvailability) => areEqual(connector, connectorAvailability.connector)
|
|
3442
|
+
);
|
|
3443
|
+
if (existingAvailability) {
|
|
3444
|
+
existingAvailability.count++;
|
|
3445
|
+
if (status) {
|
|
3446
|
+
const statusCounts = existingAvailability.statusCounts;
|
|
3447
|
+
statusCounts[status] = (statusCounts[status] || 0) + 1;
|
|
3448
|
+
}
|
|
3449
|
+
} else {
|
|
3450
|
+
availabilities.push({
|
|
3451
|
+
connector,
|
|
3452
|
+
count: 1,
|
|
3453
|
+
statusCounts: status ? {
|
|
3454
|
+
[status]: 1
|
|
3455
|
+
} : {}
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
};
|
|
3460
|
+
const toConnectorCounts = (connectors) => {
|
|
3461
|
+
const availabilities = [];
|
|
3462
|
+
addConnectorStatus(connectors, void 0, availabilities);
|
|
3463
|
+
return availabilities;
|
|
3464
|
+
};
|
|
3465
|
+
const toConnectorBasedAvailabilities = (chargingStations) => {
|
|
3466
|
+
const availabilities = [];
|
|
3467
|
+
for (const station of chargingStations) {
|
|
3468
|
+
for (const chargingPoint of station.chargingPoints) {
|
|
3469
|
+
addConnectorStatus(chargingPoint.connectors, chargingPoint.status, availabilities);
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
return availabilities;
|
|
3473
|
+
};
|
|
3474
|
+
const parseYyyymmddDate = (dateYyyymmdd) => {
|
|
3475
|
+
const splitDate = dateYyyymmdd.split("-");
|
|
3476
|
+
return {
|
|
3477
|
+
year: Number.parseInt(splitDate[0]),
|
|
3478
|
+
month: Number.parseInt(splitDate[1]),
|
|
3479
|
+
day: Number.parseInt(splitDate[2])
|
|
3480
|
+
};
|
|
3481
|
+
};
|
|
3482
|
+
const parseMoment = (momentApi) => {
|
|
3483
|
+
const { year, month, day } = parseYyyymmddDate(momentApi.date);
|
|
3484
|
+
return {
|
|
3485
|
+
dateYYYYMMDD: momentApi.date,
|
|
3486
|
+
year,
|
|
3487
|
+
month,
|
|
3488
|
+
day,
|
|
3489
|
+
hour: momentApi.hour,
|
|
3490
|
+
minute: momentApi.minute,
|
|
3491
|
+
date: new Date(year, month - 1, day, momentApi.hour, momentApi.minute)
|
|
3492
|
+
};
|
|
3493
|
+
};
|
|
3494
|
+
const alwaysOpenInThisPeriod = (timeRanges) => timeRanges.length === 1 && timeRanges[0].start.hour === 0 && timeRanges[0].end.hour === 0;
|
|
3495
|
+
const parseOpeningHours = (openingHoursApi) => {
|
|
3496
|
+
const timeRanges = openingHoursApi.timeRanges.map(
|
|
3497
|
+
(timeRangeApi) => ({
|
|
3498
|
+
start: parseMoment(timeRangeApi.startTime),
|
|
3499
|
+
end: parseMoment(timeRangeApi.endTime)
|
|
3500
|
+
})
|
|
3501
|
+
);
|
|
3502
|
+
return {
|
|
3503
|
+
mode: openingHoursApi.mode,
|
|
3504
|
+
timeRanges,
|
|
3505
|
+
alwaysOpenThisPeriod: alwaysOpenInThisPeriod(timeRanges)
|
|
3506
|
+
};
|
|
3507
|
+
};
|
|
3508
|
+
const parseSearchAPIResult = (result) => {
|
|
3509
|
+
const { position, entryPoints, poi, id, dist, boundingBox, chargingPark, ...rest } = result;
|
|
3510
|
+
const connectors = chargingPark?.connectors?.map((connector) => ({
|
|
3511
|
+
...omit(connector, "connectorType"),
|
|
3512
|
+
type: connector.connectorType
|
|
3513
|
+
}));
|
|
3514
|
+
return {
|
|
3515
|
+
...core.toPointFeature(latLonAPIToPosition(position)),
|
|
3516
|
+
...boundingBox && { bbox: apiToGeoJSONBBox(boundingBox) },
|
|
3517
|
+
id,
|
|
3518
|
+
properties: {
|
|
3519
|
+
...omit(rest, "viewport"),
|
|
3520
|
+
...dist && { distance: dist },
|
|
3521
|
+
...entryPoints && {
|
|
3522
|
+
entryPoints: entryPoints.map((entrypoint) => ({
|
|
3523
|
+
...entrypoint,
|
|
3524
|
+
position: latLonAPIToPosition(entrypoint.position)
|
|
3525
|
+
}))
|
|
3526
|
+
},
|
|
3527
|
+
...connectors && {
|
|
3528
|
+
chargingPark: {
|
|
3529
|
+
...chargingPark,
|
|
3530
|
+
connectors,
|
|
3531
|
+
connectorCounts: toConnectorCounts(connectors)
|
|
3532
|
+
}
|
|
3533
|
+
},
|
|
3534
|
+
poi: {
|
|
3535
|
+
...omit(poi, "categorySet", "openingHours"),
|
|
3536
|
+
brands: poi?.brands?.map((brand) => brand.name) ?? [],
|
|
3537
|
+
categoryIds: poi?.categorySet?.map((category) => category.id) ?? [],
|
|
3538
|
+
...poi?.openingHours && { openingHours: parseOpeningHours(poi?.openingHours) }
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
};
|
|
3542
|
+
};
|
|
3543
|
+
const parseSummaryAPI = (summary) => {
|
|
3544
|
+
const { geoBias, ...rest } = summary;
|
|
3545
|
+
return {
|
|
3546
|
+
...geoBias && { geoBias: latLonAPIToPosition(geoBias) },
|
|
3547
|
+
...rest
|
|
3548
|
+
};
|
|
3549
|
+
};
|
|
3550
|
+
const parseEVChargingStationsAvailabilityResponse = (apiResponse) => {
|
|
3551
|
+
const result = apiResponse.results?.[0];
|
|
3552
|
+
return result ? {
|
|
3553
|
+
id: result.id,
|
|
3554
|
+
accessType: result.accessType,
|
|
3555
|
+
chargingStations: result.chargingStations,
|
|
3556
|
+
chargingPointAvailability: toChargingPointAvailability(result.chargingStations),
|
|
3557
|
+
connectorAvailabilities: toConnectorBasedAvailabilities(result.chargingStations),
|
|
3558
|
+
...result.openingHours && { openingHours: parseOpeningHours(result.openingHours) }
|
|
3559
|
+
} : void 0;
|
|
3560
|
+
};
|
|
3561
|
+
const evChargingStationsAvailabilityTemplate = {
|
|
3562
|
+
requestValidation: { schema: evChargingStationsAvailabilityRequestSchema },
|
|
3563
|
+
buildRequest: buildEVChargingStationsAvailabilityRequest,
|
|
3564
|
+
sendRequest: get,
|
|
3565
|
+
parseResponse: parseEVChargingStationsAvailabilityResponse,
|
|
3566
|
+
parseResponseError: parseEVChargingStationsAvailabilityResponseError
|
|
3567
|
+
};
|
|
3568
|
+
const customize$7 = {
|
|
3569
|
+
buildEVChargingStationsAvailabilityRequest,
|
|
3570
|
+
parseEVChargingStationsAvailabilityResponse,
|
|
3571
|
+
evChargingStationsAvailabilityTemplate
|
|
3572
|
+
};
|
|
3573
|
+
const commonGeocodeAndFuzzySearchParamsSchema = partial(
|
|
3574
|
+
object({
|
|
3575
|
+
typeahead: boolean(),
|
|
3576
|
+
offset: number().check(_lte(1900)),
|
|
3577
|
+
radiusMeters: number(),
|
|
3578
|
+
boundingBox: hasBBoxSchema,
|
|
3579
|
+
countries: array(string())
|
|
3580
|
+
})
|
|
3581
|
+
);
|
|
3582
|
+
const placesParamsMandatory = object({
|
|
3583
|
+
query: string()
|
|
3584
|
+
});
|
|
3585
|
+
const placesParamsOptional = partial(
|
|
3586
|
+
object({
|
|
3587
|
+
position: hasLngLatSchema,
|
|
3588
|
+
limit: number().check(_lte(100)),
|
|
3589
|
+
extendedPostalCodesFor: array(string()),
|
|
3590
|
+
mapcodes: array(string()),
|
|
3591
|
+
view: _enum(core.views),
|
|
3592
|
+
geographyTypes: array(string())
|
|
3593
|
+
})
|
|
3594
|
+
);
|
|
3595
|
+
const commonPlacesParamsSchema = extend(placesParamsMandatory, placesParamsOptional.shape);
|
|
3596
|
+
const geocodingRequestSchema = extend(commonPlacesParamsSchema, commonGeocodeAndFuzzySearchParamsSchema.shape);
|
|
3597
|
+
const arrayToCSV = (input) => !input ? "" : Array.isArray(input) ? input.join(",") : typeof input === "string" ? input : String(input);
|
|
3598
|
+
const sampleWithinMaxLength = (array2, maxLength) => {
|
|
3599
|
+
const length = array2.length;
|
|
3600
|
+
if (length <= maxLength) {
|
|
3601
|
+
return array2;
|
|
3602
|
+
}
|
|
3603
|
+
const sampledArray = [];
|
|
3604
|
+
let i;
|
|
3605
|
+
const increment = Math.ceil(length / maxLength);
|
|
3606
|
+
for (i = 0; i < length; i += increment) {
|
|
3607
|
+
sampledArray.push(array2[i]);
|
|
3608
|
+
}
|
|
3609
|
+
if (i >= length - increment) {
|
|
3610
|
+
if (sampledArray.length < maxLength) {
|
|
3611
|
+
sampledArray.push(array2[length - 1]);
|
|
3612
|
+
} else {
|
|
3613
|
+
sampledArray[sampledArray.length - 1] = array2[length - 1];
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
return sampledArray;
|
|
3617
|
+
};
|
|
3618
|
+
const buildUrlBasePath$7 = (params) => params.customServiceBaseURL || `${params.commonBaseURL}${PLACES_URL_PATH}/geocode`;
|
|
3619
|
+
const buildGeocodingRequest = (params) => {
|
|
3620
|
+
const url = new URL(`${buildUrlBasePath$7(params)}/${params.query}.json`);
|
|
3621
|
+
const urlParams = url.searchParams;
|
|
3622
|
+
appendCommonParams(urlParams, params);
|
|
3623
|
+
params.typeahead && urlParams.append("typeahead", String(params.typeahead));
|
|
3624
|
+
!isNil(params.limit) && urlParams.append("limit", String(params.limit));
|
|
3625
|
+
!isNil(params.offset) && urlParams.append("ofs", String(params.offset));
|
|
3626
|
+
appendLatLonParamsFromPosition(urlParams, params.position);
|
|
3627
|
+
params.countries && urlParams.append("countrySet", arrayToCSV(params.countries));
|
|
3628
|
+
!isNil(params.radiusMeters) && urlParams.append("radius", String(params.radiusMeters));
|
|
3629
|
+
const bbox = params.boundingBox && core.bboxFromGeoJSON(params.boundingBox);
|
|
3630
|
+
if (bbox) {
|
|
3631
|
+
urlParams.append("topLeft", arrayToCSV([bbox[3], bbox[0]]));
|
|
3632
|
+
urlParams.append("btmRight", arrayToCSV([bbox[1], bbox[2]]));
|
|
3633
|
+
}
|
|
3634
|
+
params.extendedPostalCodesFor && urlParams.append("extendedPostalCodesFor", arrayToCSV(params.extendedPostalCodesFor));
|
|
3635
|
+
params.mapcodes && urlParams.append("mapcodes", arrayToCSV(params.mapcodes));
|
|
3636
|
+
params.view && urlParams.append("view", params.view);
|
|
3637
|
+
params.geographyTypes && urlParams.append("entityTypeSet", arrayToCSV(params.geographyTypes));
|
|
3638
|
+
return url;
|
|
3639
|
+
};
|
|
3640
|
+
const parseApiResult = (result) => {
|
|
3641
|
+
const { position, boundingBox, dist, entryPoints, addressRanges, entityType, id, ...rest } = result;
|
|
3642
|
+
return {
|
|
3643
|
+
...core.toPointFeature(latLonAPIToPosition(position)),
|
|
3644
|
+
...boundingBox && { bbox: apiToGeoJSONBBox(boundingBox) },
|
|
3645
|
+
id,
|
|
3646
|
+
properties: {
|
|
3647
|
+
...omit(rest, "viewport"),
|
|
3648
|
+
...dist && { distance: dist },
|
|
3649
|
+
...entityType && { geographyType: entityType.split(",") },
|
|
3650
|
+
...entryPoints && {
|
|
3651
|
+
entryPoints: entryPoints.map((entrypoint) => ({
|
|
3652
|
+
...entrypoint,
|
|
3653
|
+
position: latLonAPIToPosition(entrypoint.position)
|
|
3654
|
+
}))
|
|
3655
|
+
},
|
|
3656
|
+
...addressRanges && {
|
|
3657
|
+
addressRanges: {
|
|
3658
|
+
...addressRanges,
|
|
3659
|
+
from: latLonAPIToPosition(addressRanges.from),
|
|
3660
|
+
to: latLonAPIToPosition(addressRanges.to)
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
};
|
|
3665
|
+
};
|
|
3666
|
+
const parseGeocodingResponse = (apiResponse) => {
|
|
3667
|
+
const results = apiResponse.results;
|
|
3668
|
+
const features = results.map(parseApiResult);
|
|
3669
|
+
const bbox = core.bboxOnlyIfWithArea(core.bboxFromGeoJSON(features));
|
|
3670
|
+
return {
|
|
3671
|
+
type: "FeatureCollection",
|
|
3672
|
+
features,
|
|
3673
|
+
...bbox && { bbox }
|
|
3674
|
+
};
|
|
3675
|
+
};
|
|
3676
|
+
const geocodingTemplate = {
|
|
3677
|
+
requestValidation: { schema: geocodingRequestSchema },
|
|
3678
|
+
buildRequest: buildGeocodingRequest,
|
|
3679
|
+
sendRequest: get,
|
|
3680
|
+
parseResponse: parseGeocodingResponse
|
|
3681
|
+
};
|
|
3682
|
+
const customize$6 = {
|
|
3683
|
+
buildGeocodingRequest,
|
|
3684
|
+
parseGeocodingResponse,
|
|
3685
|
+
geocodingTemplate
|
|
3686
|
+
};
|
|
3687
|
+
const geometryDataRequestMandatory = object({
|
|
3688
|
+
geometries: union([
|
|
3689
|
+
featureCollectionSchema,
|
|
3690
|
+
array(union([string(), featureSchema])).check(_minLength(1), _maxLength(20))
|
|
3691
|
+
])
|
|
3692
|
+
});
|
|
3693
|
+
const geometryDataRequestOptional = partial(
|
|
3694
|
+
object({
|
|
3695
|
+
zoom: number().check(_gte(0), _lte(22))
|
|
3696
|
+
})
|
|
3697
|
+
);
|
|
3698
|
+
const geometryDataRequestSchema = extend(geometryDataRequestMandatory, geometryDataRequestOptional.shape);
|
|
3699
|
+
const buildUrlBasePath$6 = (params) => params.customServiceBaseURL || `${params.commonBaseURL}${PLACES_URL_PATH}/additionalData.json`;
|
|
3700
|
+
const getGeometryIDs = (placesArray) => placesArray.map((place) => place.properties.dataSources?.geometry?.id).filter((id) => id);
|
|
3701
|
+
const appendGeometries = (urlParams, geometries) => {
|
|
3702
|
+
let geometryIDs;
|
|
3703
|
+
if (Array.isArray(geometries)) {
|
|
3704
|
+
if (typeof geometries[0] === "string") {
|
|
3705
|
+
geometryIDs = geometries;
|
|
3706
|
+
} else {
|
|
3707
|
+
geometryIDs = getGeometryIDs(geometries);
|
|
3708
|
+
}
|
|
3709
|
+
} else {
|
|
3710
|
+
geometryIDs = getGeometryIDs(geometries.features);
|
|
3711
|
+
}
|
|
3712
|
+
urlParams.append("geometries", arrayToCSV(geometryIDs));
|
|
3713
|
+
};
|
|
3714
|
+
const buildGeometryDataRequest = (params) => {
|
|
3715
|
+
const url = new URL(buildUrlBasePath$6(params));
|
|
3716
|
+
const urlParams = url.searchParams;
|
|
3717
|
+
urlParams.append("apiVersion", String(params.apiVersion));
|
|
3718
|
+
urlParams.append("key", params.apiKey);
|
|
3719
|
+
appendGeometries(urlParams, params.geometries);
|
|
3720
|
+
appendOptionalParam(urlParams, "geometriesZoom", params.zoom);
|
|
3721
|
+
return url;
|
|
3722
|
+
};
|
|
3723
|
+
const parseGeometryDataResponse = (apiResponse) => {
|
|
3724
|
+
const features = apiResponse.additionalData.flatMap(
|
|
3725
|
+
(data) => data.geometryData?.features.map((feature) => ({
|
|
3726
|
+
...feature,
|
|
3727
|
+
bbox: core.bboxFromGeoJSON(feature.geometry)
|
|
3728
|
+
}))
|
|
3729
|
+
).filter((feature) => feature);
|
|
3730
|
+
return {
|
|
3731
|
+
type: "FeatureCollection",
|
|
3732
|
+
bbox: core.bboxFromGeoJSON(features),
|
|
3733
|
+
features
|
|
3734
|
+
};
|
|
3735
|
+
};
|
|
3736
|
+
const geometryDataTemplate = {
|
|
3737
|
+
requestValidation: { schema: geometryDataRequestSchema },
|
|
3738
|
+
buildRequest: buildGeometryDataRequest,
|
|
3739
|
+
sendRequest: get,
|
|
3740
|
+
parseResponse: parseGeometryDataResponse
|
|
3741
|
+
};
|
|
3742
|
+
const customize$5 = {
|
|
3743
|
+
buildGeometryDataRequest,
|
|
3744
|
+
parseGeometryDataResponse,
|
|
3745
|
+
geometryDataTemplate
|
|
3746
|
+
};
|
|
3747
|
+
const poiCategoriesToIdZodObject = object(poiCategoriesToID);
|
|
3748
|
+
const searchExtraParamsOptional = partial(
|
|
3749
|
+
object({
|
|
3750
|
+
indexes: array(string()),
|
|
3751
|
+
poiCategories: array(union([number(), keyof(poiCategoriesToIdZodObject)])),
|
|
3752
|
+
poiBrands: array(string()),
|
|
3753
|
+
connectors: array(string()),
|
|
3754
|
+
fuelTypes: array(string()),
|
|
3755
|
+
openingHours: string(),
|
|
3756
|
+
timeZone: string(),
|
|
3757
|
+
relatedPois: string(),
|
|
3758
|
+
minPowerKW: number(),
|
|
3759
|
+
maxPowerKW: number(),
|
|
3760
|
+
minFuzzyLevel: number(),
|
|
3761
|
+
mixFuzzyLevel: number()
|
|
3762
|
+
})
|
|
3763
|
+
);
|
|
3764
|
+
const commonSearchParamsSchema = extend(commonPlacesParamsSchema, searchExtraParamsOptional.shape);
|
|
3765
|
+
const geometrySearchRequestMandatory = object({
|
|
3766
|
+
geometries: array(union([featureCollectionSchema, geometrySchema]))
|
|
3767
|
+
});
|
|
3768
|
+
const geometrySearchRequestSchema = extend(commonSearchParamsSchema, geometrySearchRequestMandatory.shape);
|
|
3769
|
+
const findFiftyLargestPolygons = (searchGeometry) => {
|
|
3770
|
+
let polygonSizeMap = /* @__PURE__ */ new Map();
|
|
3771
|
+
searchGeometry.coordinates.forEach((polygon) => {
|
|
3772
|
+
const bboxOfPolygon = core.bboxFromCoordsArray(polygon[0]);
|
|
3773
|
+
if (bboxOfPolygon) {
|
|
3774
|
+
const polygonSize = Math.abs((bboxOfPolygon[2] - bboxOfPolygon[0]) * (bboxOfPolygon[3] - bboxOfPolygon[1]));
|
|
3775
|
+
polygonSizeMap.set(polygon, polygonSize);
|
|
3776
|
+
}
|
|
3777
|
+
});
|
|
3778
|
+
polygonSizeMap = new Map([...polygonSizeMap.entries()].sort((a, b) => b[1] - a[1]).splice(0, 50));
|
|
3779
|
+
return [...polygonSizeMap.keys()];
|
|
3780
|
+
};
|
|
3781
|
+
const sdkGeometryToApiGeometries = (searchGeometry) => {
|
|
3782
|
+
switch (searchGeometry.type) {
|
|
3783
|
+
case "Circle":
|
|
3784
|
+
return [
|
|
3785
|
+
{
|
|
3786
|
+
type: "CIRCLE",
|
|
3787
|
+
radius: searchGeometry.radius,
|
|
3788
|
+
position: positionToCSVLatLon(searchGeometry.coordinates)
|
|
3789
|
+
}
|
|
3790
|
+
];
|
|
3791
|
+
case "Polygon":
|
|
3792
|
+
return [
|
|
3793
|
+
{
|
|
3794
|
+
type: "POLYGON",
|
|
3795
|
+
vertices: sampleWithinMaxLength(searchGeometry.coordinates[0], 50).map(
|
|
3796
|
+
(coord) => positionToCSVLatLon(coord)
|
|
3797
|
+
)
|
|
3798
|
+
}
|
|
3799
|
+
];
|
|
3800
|
+
case "MultiPolygon": {
|
|
3801
|
+
if (searchGeometry.coordinates.length > 50) {
|
|
3802
|
+
return findFiftyLargestPolygons(searchGeometry).flatMap(
|
|
3803
|
+
(polygonCoords) => sdkGeometryToApiGeometries({ type: "Polygon", coordinates: polygonCoords })
|
|
3804
|
+
);
|
|
3805
|
+
}
|
|
3806
|
+
return searchGeometry.coordinates.flatMap(
|
|
3807
|
+
(polygonCoords) => sdkGeometryToApiGeometries({ type: "Polygon", coordinates: polygonCoords })
|
|
3808
|
+
);
|
|
3809
|
+
}
|
|
3810
|
+
case "FeatureCollection":
|
|
3811
|
+
return searchGeometry.features.flatMap((feature) => sdkGeometryToApiGeometries(feature.geometry));
|
|
3812
|
+
default:
|
|
3813
|
+
throw new Error(`Type ${searchGeometry.type} is not supported`);
|
|
3814
|
+
}
|
|
3815
|
+
};
|
|
3816
|
+
const buildUrlBasePath$5 = (mergedOptions) => mergedOptions.customServiceBaseURL ?? `${mergedOptions.commonBaseURL}${PLACES_URL_PATH}/geometrySearch/${mergedOptions.query}.json`;
|
|
3817
|
+
const buildGeometrySearchRequest = (params) => {
|
|
3818
|
+
const url = new URL(`${buildUrlBasePath$5(params)}`);
|
|
3819
|
+
appendCommonSearchParams(url, params);
|
|
3820
|
+
return {
|
|
3821
|
+
url,
|
|
3822
|
+
data: {
|
|
3823
|
+
geometryList: params.geometries.flatMap(sdkGeometryToApiGeometries)
|
|
3824
|
+
}
|
|
3825
|
+
};
|
|
3826
|
+
};
|
|
3827
|
+
const parseGeometrySearchResponse = (apiResponse) => {
|
|
3828
|
+
const features = apiResponse.results.map(parseSearchAPIResult);
|
|
3829
|
+
const bbox = core.bboxOnlyIfWithArea(core.bboxFromGeoJSON(features));
|
|
3830
|
+
return {
|
|
3831
|
+
type: "FeatureCollection",
|
|
3832
|
+
properties: {
|
|
3833
|
+
...parseSummaryAPI(apiResponse.summary)
|
|
3834
|
+
},
|
|
3835
|
+
features,
|
|
3836
|
+
...bbox && { bbox }
|
|
3837
|
+
};
|
|
3838
|
+
};
|
|
3839
|
+
const geometrySearchTemplate = {
|
|
3840
|
+
requestValidation: { schema: geometrySearchRequestSchema },
|
|
3841
|
+
buildRequest: buildGeometrySearchRequest,
|
|
3842
|
+
sendRequest: post,
|
|
3843
|
+
parseResponse: parseGeometrySearchResponse
|
|
3844
|
+
};
|
|
3845
|
+
const geometrySearch = async (params, customTemplate) => callService(params, { ...geometrySearchTemplate, ...customTemplate }, "GeometrySearch");
|
|
3846
|
+
const customize$4 = {
|
|
3847
|
+
geometrySearch,
|
|
3848
|
+
buildGeometrySearchRequest,
|
|
3849
|
+
parseGeometrySearchResponse,
|
|
3850
|
+
geometrySearchTemplate
|
|
3851
|
+
};
|
|
3852
|
+
const placeByIdRequestMandatory = object({
|
|
3853
|
+
entityId: string()
|
|
3854
|
+
});
|
|
3855
|
+
const placeByIdRequestOptional = partial(
|
|
3856
|
+
object({
|
|
3857
|
+
mapcodes: array(string()),
|
|
3858
|
+
view: _enum(core.views),
|
|
3859
|
+
openingHours: string(),
|
|
3860
|
+
timeZone: string(),
|
|
3861
|
+
relatedPois: string()
|
|
3862
|
+
})
|
|
3863
|
+
);
|
|
3864
|
+
const placeByIdRequestSchema = extend(placeByIdRequestMandatory, placeByIdRequestOptional.shape);
|
|
3865
|
+
const buildUrlBasePath$4 = (params) => params.customServiceBaseURL || `${params.commonBaseURL}${PLACES_URL_PATH}/place.json`;
|
|
3866
|
+
const buildPlaceByIdRequest = (params) => {
|
|
3867
|
+
const url = new URL(`${buildUrlBasePath$4(params)}`);
|
|
3868
|
+
const urlParams = url.searchParams;
|
|
3869
|
+
appendCommonParams(urlParams, params);
|
|
3870
|
+
appendOptionalParam(urlParams, "entityId", params.entityId);
|
|
3871
|
+
appendByJoiningParamValue(urlParams, "mapcodes", params.mapcodes);
|
|
3872
|
+
appendOptionalParam(urlParams, "view", params.view);
|
|
3873
|
+
appendOptionalParam(urlParams, "openingHours", params.openingHours);
|
|
3874
|
+
appendOptionalParam(urlParams, "timeZone", params.timeZone);
|
|
3875
|
+
appendOptionalParam(urlParams, "relatedPois", params.relatedPois);
|
|
3876
|
+
return url;
|
|
3877
|
+
};
|
|
3878
|
+
const parsePlaceByIdResponse = (apiResponse) => apiResponse.results?.length ? parseSearchAPIResult(apiResponse.results[0]) : void 0;
|
|
3879
|
+
const placeByIdTemplate = {
|
|
3880
|
+
requestValidation: { schema: placeByIdRequestSchema },
|
|
3881
|
+
buildRequest: buildPlaceByIdRequest,
|
|
3882
|
+
sendRequest: get,
|
|
3883
|
+
parseResponse: parsePlaceByIdResponse
|
|
3884
|
+
};
|
|
3885
|
+
const customize$3 = {
|
|
3886
|
+
buildPlaceByIdRequest,
|
|
3887
|
+
parsePlaceByIdResponse,
|
|
3888
|
+
placeByIdTemplate
|
|
3889
|
+
};
|
|
3890
|
+
const routeTypes = ["fast", "short", "efficient", "thrilling"];
|
|
3891
|
+
const loadTypes = [
|
|
3892
|
+
"USHazmatClass1",
|
|
3893
|
+
"USHazmatClass2",
|
|
3894
|
+
"USHazmatClass3",
|
|
3895
|
+
"USHazmatClass4",
|
|
3896
|
+
"USHazmatClass5",
|
|
3897
|
+
"USHazmatClass6",
|
|
3898
|
+
"USHazmatClass7",
|
|
3899
|
+
"USHazmatClass8",
|
|
3900
|
+
"USHazmatClass9",
|
|
3901
|
+
"otherHazmatExplosive",
|
|
3902
|
+
"otherHazmatGeneral",
|
|
3903
|
+
"otherHazmatHarmfulToWater"
|
|
3904
|
+
];
|
|
3905
|
+
const positiveNumber = number().check(_positive());
|
|
3906
|
+
const nonNegativeNumber = number().check(_gte(0));
|
|
3907
|
+
const percentageNumber = number().check(_gte(0), _lte(100));
|
|
3908
|
+
const optionalPositiveNumber = optional(positiveNumber);
|
|
3909
|
+
const optionalNonNegativeNumber = optional(nonNegativeNumber);
|
|
3910
|
+
const optionalNormalizedNumber = optional(number().check(_gte(0), _lte(1)));
|
|
3911
|
+
const speedToConsumptionRateSchema = object({
|
|
3912
|
+
speedKMH: number(),
|
|
3913
|
+
consumptionUnitsPer100KM: number()
|
|
3914
|
+
});
|
|
3915
|
+
const efficiencySchema = optional(
|
|
3916
|
+
object({
|
|
3917
|
+
acceleration: optionalNormalizedNumber,
|
|
3918
|
+
deceleration: optionalNormalizedNumber,
|
|
3919
|
+
uphill: optionalNormalizedNumber,
|
|
3920
|
+
downhill: optionalNormalizedNumber
|
|
3921
|
+
})
|
|
3922
|
+
);
|
|
3923
|
+
const baseConsumptionModelSchema = {
|
|
3924
|
+
efficiency: efficiencySchema
|
|
3925
|
+
};
|
|
3926
|
+
const speedConsumptionArray = array(speedToConsumptionRateSchema).check(_minLength(1), _maxLength(25));
|
|
3927
|
+
const combustionConsumptionModelSchema = object({
|
|
3928
|
+
...baseConsumptionModelSchema,
|
|
3929
|
+
speedsToConsumptionsLiters: speedConsumptionArray,
|
|
3930
|
+
auxiliaryPowerInLitersPerHour: optionalNonNegativeNumber,
|
|
3931
|
+
fuelEnergyDensityInMJoulesPerLiter: optional(number().check(_gte(1)))
|
|
3932
|
+
});
|
|
3933
|
+
const electricConsumptionModelSchema = object({
|
|
3934
|
+
...baseConsumptionModelSchema,
|
|
3935
|
+
speedsToConsumptionsKWH: speedConsumptionArray,
|
|
3936
|
+
auxiliaryPowerInkW: optionalNonNegativeNumber,
|
|
3937
|
+
consumptionInKWHPerKMAltitudeGain: optional(number().check(_lte(500))),
|
|
3938
|
+
recuperationInKWHPerKMAltitudeLoss: optionalNonNegativeNumber
|
|
3939
|
+
});
|
|
3940
|
+
const chargingConnectorSchema = object({
|
|
3941
|
+
currentType: _enum(core.currentTypes),
|
|
3942
|
+
plugTypes: array(_enum(core.plugTypes)).check(_minLength(1)),
|
|
3943
|
+
efficiency: optionalNormalizedNumber,
|
|
3944
|
+
baseLoadInkW: optionalNonNegativeNumber,
|
|
3945
|
+
maxPowerInkW: optionalNonNegativeNumber,
|
|
3946
|
+
maxVoltageInV: optionalNonNegativeNumber,
|
|
3947
|
+
maxCurrentInA: optionalNonNegativeNumber,
|
|
3948
|
+
voltageRange: optional(
|
|
3949
|
+
object({
|
|
3950
|
+
minVoltageInV: optionalNonNegativeNumber,
|
|
3951
|
+
maxVoltageInV: optional(number())
|
|
3952
|
+
})
|
|
3953
|
+
)
|
|
3954
|
+
});
|
|
3955
|
+
const batteryCurveSchema = object({
|
|
3956
|
+
stateOfChargeInkWh: nonNegativeNumber,
|
|
3957
|
+
maxPowerInkW: positiveNumber
|
|
3958
|
+
});
|
|
3959
|
+
const chargingModelSchema = object({
|
|
3960
|
+
maxChargeKWH: positiveNumber,
|
|
3961
|
+
batteryCurve: optional(array(batteryCurveSchema).check(_maxLength(20))),
|
|
3962
|
+
chargingConnectors: optional(array(chargingConnectorSchema).check(_minLength(1))),
|
|
3963
|
+
chargingTimeOffsetInSec: optionalNonNegativeNumber
|
|
3964
|
+
});
|
|
3965
|
+
const combustionEngineModelSchema = object({ consumption: combustionConsumptionModelSchema });
|
|
3966
|
+
const electricEngineModelSchema = object({
|
|
3967
|
+
consumption: electricConsumptionModelSchema,
|
|
3968
|
+
charging: optional(chargingModelSchema)
|
|
3969
|
+
});
|
|
3970
|
+
const vehicleDimensionsSchema = optional(
|
|
3971
|
+
object({
|
|
3972
|
+
lengthMeters: optionalPositiveNumber,
|
|
3973
|
+
widthMeters: optionalPositiveNumber,
|
|
3974
|
+
heightMeters: optionalPositiveNumber,
|
|
3975
|
+
weightKG: optionalPositiveNumber,
|
|
3976
|
+
axleWeightKG: optionalPositiveNumber
|
|
3977
|
+
})
|
|
3978
|
+
);
|
|
3979
|
+
const predefinedVehicleModelSchema = object({ variantId: string() });
|
|
3980
|
+
const explicitVehicleModelSchema = object({
|
|
3981
|
+
dimensions: vehicleDimensionsSchema,
|
|
3982
|
+
engine: optional(union([combustionEngineModelSchema, electricEngineModelSchema]))
|
|
3983
|
+
});
|
|
3984
|
+
const vehicleModelSchema = optional(union([predefinedVehicleModelSchema, explicitVehicleModelSchema]));
|
|
3985
|
+
const genericVehicleStateSchema = object({
|
|
3986
|
+
heading: optional(number().check(_gte(0), _lte(360)))
|
|
3987
|
+
});
|
|
3988
|
+
const combustionVehicleStateSchema = extend(
|
|
3989
|
+
genericVehicleStateSchema,
|
|
3990
|
+
object({ currentFuelInLiters: nonNegativeNumber }).shape
|
|
3991
|
+
);
|
|
3992
|
+
const electricVehicleStateByPercentageSchema = extend(
|
|
3993
|
+
genericVehicleStateSchema,
|
|
3994
|
+
object({ currentChargePCT: percentageNumber }).shape
|
|
3995
|
+
);
|
|
3996
|
+
const electricVehicleStateByKwhSchema = extend(
|
|
3997
|
+
genericVehicleStateSchema,
|
|
3998
|
+
object({ currentChargeInkWh: nonNegativeNumber }).shape
|
|
3999
|
+
);
|
|
4000
|
+
const electricVehicleStateSchema = union([electricVehicleStateByPercentageSchema, electricVehicleStateByKwhSchema]);
|
|
4001
|
+
const chargingPreferencesPCTSchema = object({
|
|
4002
|
+
minChargeAtDestinationPCT: percentageNumber,
|
|
4003
|
+
minChargeAtChargingStopsPCT: number().check(_gte(0), _lte(50))
|
|
4004
|
+
});
|
|
4005
|
+
const chargingPreferencesKWHSchema = object({
|
|
4006
|
+
minChargeAtDestinationInkWh: nonNegativeNumber,
|
|
4007
|
+
minChargeAtChargingStopsInkWh: nonNegativeNumber
|
|
4008
|
+
});
|
|
4009
|
+
const chargingPreferencesSchema = union([chargingPreferencesPCTSchema, chargingPreferencesKWHSchema]);
|
|
4010
|
+
const electricVehiclePreferencesSchema = object({
|
|
4011
|
+
chargingPreferences: optional(chargingPreferencesSchema)
|
|
4012
|
+
});
|
|
4013
|
+
const vehicleRestrictionsSchema = optional(
|
|
4014
|
+
object({
|
|
4015
|
+
loadTypes: optional(array(_enum(loadTypes))),
|
|
4016
|
+
maxSpeedKMH: optional(number().check(_gte(0), _lte(250))),
|
|
4017
|
+
adrCode: optional(_enum(["B", "C", "D", "E"])),
|
|
4018
|
+
commercial: optional(boolean())
|
|
4019
|
+
})
|
|
4020
|
+
);
|
|
4021
|
+
const baseVehicleParamsSchema = {
|
|
4022
|
+
model: vehicleModelSchema,
|
|
4023
|
+
restrictions: vehicleRestrictionsSchema
|
|
4024
|
+
};
|
|
4025
|
+
const genericVehicleParamsSchema = object({
|
|
4026
|
+
...baseVehicleParamsSchema,
|
|
4027
|
+
engineType: _undefined(),
|
|
4028
|
+
state: optional(genericVehicleStateSchema),
|
|
4029
|
+
preferences: optional(object({}))
|
|
4030
|
+
});
|
|
4031
|
+
const combustionVehicleParamsSchema = object({
|
|
4032
|
+
...baseVehicleParamsSchema,
|
|
4033
|
+
engineType: literal("combustion"),
|
|
4034
|
+
state: optional(combustionVehicleStateSchema),
|
|
4035
|
+
preferences: optional(object({}))
|
|
4036
|
+
});
|
|
4037
|
+
const electricVehicleParamsSchema = object({
|
|
4038
|
+
...baseVehicleParamsSchema,
|
|
4039
|
+
engineType: literal("electric"),
|
|
4040
|
+
state: optional(electricVehicleStateSchema),
|
|
4041
|
+
preferences: optional(electricVehiclePreferencesSchema)
|
|
4042
|
+
});
|
|
4043
|
+
const vehicleParametersSchema = union([
|
|
4044
|
+
discriminatedUnion("engineType", [combustionVehicleParamsSchema, electricVehicleParamsSchema]),
|
|
4045
|
+
genericVehicleParamsSchema
|
|
4046
|
+
]);
|
|
4047
|
+
const commonRoutingRequestSchema = partial(
|
|
4048
|
+
object({
|
|
4049
|
+
costModel: partial(
|
|
4050
|
+
object({
|
|
4051
|
+
avoid: array(_enum(core.avoidableTypes)),
|
|
4052
|
+
traffic: optional(_enum(["live", "historical"])),
|
|
4053
|
+
routeType: optional(_enum(routeTypes)),
|
|
4054
|
+
thrillingParams: optional(
|
|
4055
|
+
object({
|
|
4056
|
+
hilliness: optional(_enum(["low", "normal", "high"])),
|
|
4057
|
+
windingness: optional(_enum(["low", "normal", "high"]))
|
|
4058
|
+
})
|
|
4059
|
+
)
|
|
4060
|
+
})
|
|
4061
|
+
),
|
|
4062
|
+
travelMode: string(),
|
|
4063
|
+
vehicle: vehicleParametersSchema,
|
|
4064
|
+
when: object({
|
|
4065
|
+
option: _enum(["departAt", "arriveBy"]),
|
|
4066
|
+
date: date()
|
|
4067
|
+
})
|
|
4068
|
+
})
|
|
4069
|
+
);
|
|
4070
|
+
const budgetTypes = [
|
|
4071
|
+
"timeMinutes",
|
|
4072
|
+
"remainingChargeCPT",
|
|
4073
|
+
"spentChargePCT",
|
|
4074
|
+
"spentFuelLiters",
|
|
4075
|
+
"distanceKM"
|
|
4076
|
+
];
|
|
4077
|
+
const reachableRangeRequestSchemaMandatory = object({
|
|
4078
|
+
origin: hasLngLatSchema,
|
|
4079
|
+
budget: object({
|
|
4080
|
+
type: _enum(budgetTypes),
|
|
4081
|
+
value: number().check(_gte(0))
|
|
4082
|
+
})
|
|
4083
|
+
});
|
|
4084
|
+
const reachableRangeRequestSchemaOptional = object({
|
|
4085
|
+
maxFerryLengthMeters: optional(number().check(_gte(0)))
|
|
4086
|
+
});
|
|
4087
|
+
const reachableRangeRequestSchema = extend(
|
|
4088
|
+
commonRoutingRequestSchema,
|
|
4089
|
+
extend(reachableRangeRequestSchemaMandatory, reachableRangeRequestSchemaOptional.shape).shape
|
|
4090
|
+
);
|
|
4091
|
+
const reachableRangeRequestValidationConfig = {
|
|
4092
|
+
schema: reachableRangeRequestSchema
|
|
4093
|
+
// refinements: [evRangeRefinement, fuelRangeRefinement, departArriveRefinement]
|
|
4094
|
+
};
|
|
4095
|
+
const appendConsumptionEfficiency = (urlParams, efficiency) => {
|
|
4096
|
+
if (efficiency) {
|
|
4097
|
+
!isNil(efficiency.acceleration) && urlParams.append("accelerationEfficiency", String(efficiency.acceleration));
|
|
4098
|
+
!isNil(efficiency.deceleration) && urlParams.append("decelerationEfficiency", String(efficiency.deceleration));
|
|
4099
|
+
!isNil(efficiency.uphill) && urlParams.append("uphillEfficiency", String(efficiency.uphill));
|
|
4100
|
+
!isNil(efficiency.downhill) && urlParams.append("downhillEfficiency", String(efficiency.downhill));
|
|
4101
|
+
}
|
|
4102
|
+
};
|
|
4103
|
+
const buildSpeedToConsumptionString = (speedsToConsumptions) => speedsToConsumptions.map((speedToConsumption) => `${speedToConsumption.speedKMH},${speedToConsumption.consumptionUnitsPer100KM}`).join(":");
|
|
4104
|
+
const appendCombustionEngine = (urlParams, engine) => {
|
|
4105
|
+
const consumptionModel = engine.consumption;
|
|
4106
|
+
consumptionModel.speedsToConsumptionsLiters && urlParams.append(
|
|
4107
|
+
"constantSpeedConsumptionInLitersPerHundredkm",
|
|
4108
|
+
buildSpeedToConsumptionString(consumptionModel.speedsToConsumptionsLiters)
|
|
4109
|
+
);
|
|
4110
|
+
!isNil(consumptionModel.auxiliaryPowerInLitersPerHour) && urlParams.append("auxiliaryPowerInLitersPerHour", String(consumptionModel.auxiliaryPowerInLitersPerHour));
|
|
4111
|
+
!isNil(consumptionModel.fuelEnergyDensityInMJoulesPerLiter) && urlParams.append(
|
|
4112
|
+
"fuelEnergyDensityInMJoulesPerLiter",
|
|
4113
|
+
String(consumptionModel.fuelEnergyDensityInMJoulesPerLiter)
|
|
4114
|
+
);
|
|
4115
|
+
};
|
|
4116
|
+
const appendElectricConsumptionModel = (urlParams, model) => {
|
|
4117
|
+
model.speedsToConsumptionsKWH && urlParams.append(
|
|
4118
|
+
"constantSpeedConsumptionInkWhPerHundredkm",
|
|
4119
|
+
buildSpeedToConsumptionString(model.speedsToConsumptionsKWH)
|
|
4120
|
+
);
|
|
4121
|
+
!isNil(model.auxiliaryPowerInkW) && urlParams.append("auxiliaryPowerInkW", String(model.auxiliaryPowerInkW));
|
|
4122
|
+
!isNil(model.consumptionInKWHPerKMAltitudeGain) && urlParams.append("consumptionInkWhPerkmAltitudeGain", String(model.consumptionInKWHPerKMAltitudeGain));
|
|
4123
|
+
!isNil(model.recuperationInKWHPerKMAltitudeLoss) && urlParams.append("recuperationInkWhPerkmAltitudeLoss", String(model.recuperationInKWHPerKMAltitudeLoss));
|
|
4124
|
+
};
|
|
4125
|
+
const appendChargingModel = (urlParams, engine) => {
|
|
4126
|
+
const chargingModel = engine.charging;
|
|
4127
|
+
if (chargingModel?.maxChargeKWH) {
|
|
4128
|
+
urlParams.append("maxChargeInkWh", String(chargingModel.maxChargeKWH));
|
|
4129
|
+
}
|
|
4130
|
+
};
|
|
4131
|
+
const appendVehicleState = (urlParams, vehicleParams) => {
|
|
4132
|
+
if (!vehicleParams.state) {
|
|
4133
|
+
return;
|
|
4134
|
+
}
|
|
4135
|
+
vehicleParams.state.heading && urlParams.append("vehicleHeading", String(vehicleParams.state.heading));
|
|
4136
|
+
if (!("engineType" in vehicleParams)) {
|
|
4137
|
+
return;
|
|
4138
|
+
}
|
|
4139
|
+
if (vehicleParams.engineType === "combustion") {
|
|
4140
|
+
const combustionState = vehicleParams.state;
|
|
4141
|
+
combustionState.currentFuelInLiters && urlParams.append("currentFuelInLiters", String(combustionState.currentFuelInLiters));
|
|
4142
|
+
} else if (vehicleParams.engineType === "electric") {
|
|
4143
|
+
const electricState = vehicleParams.state;
|
|
4144
|
+
const kwhElectricState = electricState;
|
|
4145
|
+
const pctElectricState = electricState;
|
|
4146
|
+
if (kwhElectricState.currentChargeInkWh) {
|
|
4147
|
+
urlParams.append("currentChargeInkWh", String(kwhElectricState.currentChargeInkWh));
|
|
4148
|
+
} else if (pctElectricState.currentChargePCT && vehicleParams.model && "engine" in vehicleParams.model && vehicleParams.model.engine) {
|
|
4149
|
+
const engine = vehicleParams.model.engine;
|
|
4150
|
+
const maxChargeKWH = engine.charging?.maxChargeKWH;
|
|
4151
|
+
if (maxChargeKWH) {
|
|
4152
|
+
urlParams.append(
|
|
4153
|
+
"currentChargeInkWh",
|
|
4154
|
+
String(maxChargeKWH * pctElectricState.currentChargePCT / 100)
|
|
4155
|
+
);
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
};
|
|
4160
|
+
const appendVehiclePreferences = (urlParams, vehicleParams) => {
|
|
4161
|
+
if (!vehicleParams.preferences) {
|
|
4162
|
+
return;
|
|
4163
|
+
}
|
|
4164
|
+
if ("engineType" in vehicleParams && vehicleParams.engineType === "electric") {
|
|
4165
|
+
const preferences = vehicleParams.preferences;
|
|
4166
|
+
if (preferences.chargingPreferences) {
|
|
4167
|
+
const chargingPrefs = preferences.chargingPreferences;
|
|
4168
|
+
const kwhChargingPrefs = chargingPrefs;
|
|
4169
|
+
const pctChargingPrefs = chargingPrefs;
|
|
4170
|
+
if (kwhChargingPrefs.minChargeAtChargingStopsInkWh || kwhChargingPrefs.minChargeAtDestinationInkWh) {
|
|
4171
|
+
urlParams.append("minChargeAtDestinationInkWh", String(kwhChargingPrefs.minChargeAtDestinationInkWh));
|
|
4172
|
+
urlParams.append(
|
|
4173
|
+
"minChargeAtChargingStopsInkWh",
|
|
4174
|
+
String(kwhChargingPrefs.minChargeAtChargingStopsInkWh)
|
|
4175
|
+
);
|
|
4176
|
+
} else if ((pctChargingPrefs.minChargeAtChargingStopsPCT || pctChargingPrefs.minChargeAtDestinationPCT) && vehicleParams.model && "engine" in vehicleParams.model && vehicleParams.model.engine) {
|
|
4177
|
+
const engine = vehicleParams.model.engine;
|
|
4178
|
+
const maxChargeKWH = engine.charging?.maxChargeKWH;
|
|
4179
|
+
if (maxChargeKWH) {
|
|
4180
|
+
urlParams.append(
|
|
4181
|
+
"minChargeAtDestinationInkWh",
|
|
4182
|
+
String(maxChargeKWH * pctChargingPrefs.minChargeAtDestinationPCT / 100)
|
|
4183
|
+
);
|
|
4184
|
+
urlParams.append(
|
|
4185
|
+
"minChargeAtChargingStopsInkWh",
|
|
4186
|
+
String(maxChargeKWH * pctChargingPrefs.minChargeAtChargingStopsPCT / 100)
|
|
4187
|
+
);
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
};
|
|
4193
|
+
const appendVehicleDimensions = (urlParams, dimensions) => {
|
|
4194
|
+
if (dimensions) {
|
|
4195
|
+
dimensions.lengthMeters && urlParams.append("vehicleLength", String(dimensions.lengthMeters));
|
|
4196
|
+
dimensions.heightMeters && urlParams.append("vehicleHeight", String(dimensions.heightMeters));
|
|
4197
|
+
dimensions.widthMeters && urlParams.append("vehicleWidth", String(dimensions.widthMeters));
|
|
4198
|
+
dimensions.weightKG && urlParams.append("vehicleWeight", String(dimensions.weightKG));
|
|
4199
|
+
dimensions.axleWeightKG && urlParams.append("vehicleAxleWeight", String(dimensions.axleWeightKG));
|
|
4200
|
+
}
|
|
4201
|
+
};
|
|
4202
|
+
const appendVehicleRestrictions = (urlParams, vehicleParams) => {
|
|
4203
|
+
const restrictions = vehicleParams.restrictions;
|
|
4204
|
+
if (!restrictions) {
|
|
4205
|
+
return;
|
|
4206
|
+
}
|
|
4207
|
+
appendByRepeatingParamName(urlParams, "vehicleLoadType", restrictions.loadTypes);
|
|
4208
|
+
restrictions.adrCode && urlParams.append("vehicleAdrTunnelRestrictionCode", restrictions.adrCode);
|
|
4209
|
+
restrictions.commercial && urlParams.append("vehicleCommercial", String(restrictions.commercial));
|
|
4210
|
+
restrictions.maxSpeedKMH && urlParams.append("vehicleMaxSpeed", String(restrictions.maxSpeedKMH));
|
|
4211
|
+
};
|
|
4212
|
+
const appendVehicleEngineModel = (urlParams, engineType, engine) => {
|
|
4213
|
+
appendConsumptionEfficiency(urlParams, engine.consumption.efficiency);
|
|
4214
|
+
if (engineType === "electric") {
|
|
4215
|
+
appendElectricConsumptionModel(urlParams, engine.consumption);
|
|
4216
|
+
appendChargingModel(urlParams, engine);
|
|
4217
|
+
} else {
|
|
4218
|
+
appendCombustionEngine(urlParams, engine);
|
|
4219
|
+
}
|
|
4220
|
+
};
|
|
4221
|
+
const appendVehicleModel = (urlParams, vehicleParams) => {
|
|
4222
|
+
if (!vehicleParams.model) {
|
|
4223
|
+
return;
|
|
4224
|
+
}
|
|
4225
|
+
if ("variantId" in vehicleParams.model) {
|
|
4226
|
+
urlParams.append("vehicleModelId", vehicleParams.model.variantId);
|
|
4227
|
+
} else {
|
|
4228
|
+
appendVehicleDimensions(urlParams, vehicleParams.model.dimensions);
|
|
4229
|
+
if (vehicleParams.model.engine) {
|
|
4230
|
+
appendVehicleEngineModel(
|
|
4231
|
+
urlParams,
|
|
4232
|
+
"engineType" in vehicleParams ? vehicleParams.engineType : void 0,
|
|
4233
|
+
vehicleParams.model.engine
|
|
4234
|
+
);
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
};
|
|
4238
|
+
const appendVehicleParams = (urlParams, vehicleParams) => {
|
|
4239
|
+
if (!vehicleParams) {
|
|
4240
|
+
return;
|
|
4241
|
+
}
|
|
4242
|
+
if (vehicleParams.engineType === "electric") {
|
|
4243
|
+
urlParams.append("vehicleEngineType", "electric");
|
|
4244
|
+
}
|
|
4245
|
+
appendVehicleModel(urlParams, vehicleParams);
|
|
4246
|
+
appendVehicleState(urlParams, vehicleParams);
|
|
4247
|
+
appendVehiclePreferences(urlParams, vehicleParams);
|
|
4248
|
+
appendVehicleRestrictions(urlParams, vehicleParams);
|
|
4249
|
+
};
|
|
4250
|
+
const appendWhenParams = (urlParams, when) => {
|
|
4251
|
+
if (when?.date) {
|
|
4252
|
+
const formattedDate = when.date.toISOString();
|
|
4253
|
+
if (when.option === "departAt") {
|
|
4254
|
+
urlParams.append("departAt", formattedDate);
|
|
4255
|
+
} else if (when.option === "arriveBy") {
|
|
4256
|
+
urlParams.append("arriveAt", formattedDate);
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
};
|
|
4260
|
+
const appendCommonRoutingParams = (urlParams, params) => {
|
|
4261
|
+
const costModel = params.costModel;
|
|
4262
|
+
appendByRepeatingParamName(urlParams, "avoid", costModel?.avoid);
|
|
4263
|
+
appendOptionalParam(urlParams, "traffic", costModel?.traffic);
|
|
4264
|
+
appendWhenParams(urlParams, params.when);
|
|
4265
|
+
appendOptionalParam(urlParams, "routeType", costModel?.routeType);
|
|
4266
|
+
appendOptionalParam(urlParams, "travelMode", params.travelMode);
|
|
4267
|
+
appendVehicleParams(urlParams, params.vehicle);
|
|
4268
|
+
};
|
|
4269
|
+
const buildUrlBasePath$3 = (params) => params.customServiceBaseURL || `${params.commonBaseURL}/routing/1/calculateReachableRange/${positionToCSVLatLon(
|
|
4270
|
+
core.getPositionStrict(params.origin)
|
|
4271
|
+
)}/json`;
|
|
4272
|
+
const buildReachableRangeRequest = (params) => {
|
|
4273
|
+
const url = new URL(buildUrlBasePath$3(params));
|
|
4274
|
+
const urlParams = url.searchParams;
|
|
4275
|
+
appendCommonParams(urlParams, params);
|
|
4276
|
+
appendCommonRoutingParams(urlParams, params);
|
|
4277
|
+
appendOptionalParam(urlParams, "maxFerryLengthInMeters", params.maxFerryLengthMeters);
|
|
4278
|
+
return url;
|
|
4279
|
+
};
|
|
4280
|
+
const parseReachableRangeResponse = (apiResponse, params) => {
|
|
4281
|
+
const geometry = {
|
|
4282
|
+
type: "Polygon",
|
|
4283
|
+
coordinates: [apiResponse.reachableRange.boundary.map((point) => [point.longitude, point.latitude])]
|
|
4284
|
+
};
|
|
4285
|
+
const bbox = core.bboxFromGeoJSON(geometry);
|
|
4286
|
+
return { type: "Feature", geometry, bbox, properties: params };
|
|
4287
|
+
};
|
|
4288
|
+
const reachableRangeTemplate = {
|
|
4289
|
+
requestValidation: reachableRangeRequestValidationConfig,
|
|
4290
|
+
buildRequest: buildReachableRangeRequest,
|
|
4291
|
+
sendRequest: get,
|
|
4292
|
+
parseResponse: parseReachableRangeResponse
|
|
4293
|
+
};
|
|
4294
|
+
const customize$2 = {
|
|
4295
|
+
buildReachableRangeRequest,
|
|
4296
|
+
parseReachableRangeResponse,
|
|
4297
|
+
reachableRangeTemplate
|
|
4298
|
+
};
|
|
4299
|
+
const buildUrlBasePath$2 = (params) => params.customServiceBaseURL || `${params.commonBaseURL}${PLACES_URL_PATH}/reverseGeocode`;
|
|
4300
|
+
const buildRevGeoRequest = (params) => {
|
|
4301
|
+
const lngLat = core.getPositionStrict(params.position);
|
|
4302
|
+
const url = new URL(`${buildUrlBasePath$2(params)}/${lngLat[1]},${lngLat[0]}.json`);
|
|
4303
|
+
const urlParams = url.searchParams;
|
|
4304
|
+
appendCommonParams(urlParams, params);
|
|
4305
|
+
params.allowFreeformNewline && urlParams.append("allowFreeformNewline", String(params.allowFreeformNewline));
|
|
4306
|
+
params.geographyType && urlParams.append("entityType", arrayToCSV(params.geographyType));
|
|
4307
|
+
!isNil(params.heading) && urlParams.append("heading", String(params.heading));
|
|
4308
|
+
params.mapcodes && urlParams.append("mapcodes", arrayToCSV(params.mapcodes));
|
|
4309
|
+
params.number && urlParams.append("number", params.number);
|
|
4310
|
+
!isNil(params.radiusMeters) && urlParams.append("radius", String(params.radiusMeters));
|
|
4311
|
+
params.returnSpeedLimit && urlParams.append("returnSpeedLimit", String(params.returnSpeedLimit));
|
|
4312
|
+
params.returnRoadUse && urlParams.append("returnRoadUse", String(params.returnRoadUse));
|
|
4313
|
+
params.roadUses && urlParams.append("roadUse", JSON.stringify(params.roadUses));
|
|
4314
|
+
return url;
|
|
4315
|
+
};
|
|
4316
|
+
const parseRevGeoResponse = (apiResponse, params) => {
|
|
4317
|
+
const pointFeature = core.toPointFeature(core.getPositionStrict(params.position));
|
|
4318
|
+
const firstApiResult = apiResponse.addresses[0];
|
|
4319
|
+
const { boundingBox, sideOfStreet, offsetPosition, ...address } = firstApiResult?.address || {};
|
|
4320
|
+
return {
|
|
4321
|
+
// The requested coordinates are the primary ones, and set as the GeoJSON Feature geometry:
|
|
4322
|
+
...pointFeature,
|
|
4323
|
+
...boundingBox && { bbox: apiToGeoJSONBBox(boundingBox) },
|
|
4324
|
+
id: core.generateId(),
|
|
4325
|
+
...firstApiResult && {
|
|
4326
|
+
properties: {
|
|
4327
|
+
type: firstApiResult?.entityType ? "Geography" : !address.streetNumber ? "Street" : "Point Address",
|
|
4328
|
+
address,
|
|
4329
|
+
...firstApiResult.dataSources && { dataSources: firstApiResult.dataSources },
|
|
4330
|
+
...firstApiResult.mapcodes && { mapcodes: firstApiResult.mapcodes },
|
|
4331
|
+
...sideOfStreet && { sideOfStreet },
|
|
4332
|
+
...offsetPosition && { offsetPosition: csvLatLngToPosition(offsetPosition) },
|
|
4333
|
+
// The reverse geocoded coordinates are secondary and set in the GeoJSON properties:
|
|
4334
|
+
originalPosition: csvLatLngToPosition(firstApiResult.position)
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
};
|
|
4338
|
+
};
|
|
4339
|
+
const revGeocodeRequestMandatory = object({
|
|
4340
|
+
position: hasLngLatSchema
|
|
4341
|
+
});
|
|
4342
|
+
const revGeocodeRequestOptional = partial(
|
|
4343
|
+
object({
|
|
4344
|
+
allowFreeformNewline: boolean(),
|
|
4345
|
+
geographyType: array(string()),
|
|
4346
|
+
heading: number().check(_gte(-360), _lte(360)),
|
|
4347
|
+
mapcodes: array(string()),
|
|
4348
|
+
number: string(),
|
|
4349
|
+
radiusMeters: number(),
|
|
4350
|
+
returnMatchType: boolean(),
|
|
4351
|
+
returnRoadUse: boolean(),
|
|
4352
|
+
returnSpeedLimit: boolean(),
|
|
4353
|
+
roadUses: array(string()),
|
|
4354
|
+
view: _enum(core.views)
|
|
4355
|
+
})
|
|
4356
|
+
);
|
|
4357
|
+
const revGeocodeRequestSchema = extend(revGeocodeRequestMandatory, revGeocodeRequestOptional.shape);
|
|
4358
|
+
const reverseGeocodingTemplate = {
|
|
4359
|
+
requestValidation: { schema: revGeocodeRequestSchema },
|
|
4360
|
+
buildRequest: buildRevGeoRequest,
|
|
4361
|
+
sendRequest: get,
|
|
4362
|
+
parseResponse: parseRevGeoResponse
|
|
4363
|
+
};
|
|
4364
|
+
const customize$1 = {
|
|
4365
|
+
buildRevGeoRequest,
|
|
4366
|
+
parseRevGeoResponse,
|
|
4367
|
+
reverseGeocodingTemplate
|
|
4368
|
+
};
|
|
4369
|
+
const waypointLikeSchema = union([hasLngLatSchema, geometrySchema]);
|
|
4370
|
+
const pathLikeSchema = union([lineStringCoordsSchema, featureSchema]);
|
|
4371
|
+
const calculateRouteRequestSchemaMandatory = object({
|
|
4372
|
+
locations: array(union([waypointLikeSchema, pathLikeSchema])).check(_minLength(1))
|
|
4373
|
+
});
|
|
4374
|
+
const calculateRouteRequestSchemaOptional = partial(
|
|
4375
|
+
object({
|
|
4376
|
+
computeAdditionalTravelTimeFor: _enum(["none", "all"]),
|
|
4377
|
+
vehicleHeading: number().check(_gte(0), _lte(359.5)),
|
|
4378
|
+
// TODO add proper instructionsInfo check
|
|
4379
|
+
// instructionsType: z.enum(instructionsTypes),
|
|
4380
|
+
maxAlternatives: number().check(_gte(0), _lte(5)),
|
|
4381
|
+
sectionTypes: array(_enum(core.inputSectionTypesWithGuidance))
|
|
4382
|
+
})
|
|
4383
|
+
);
|
|
4384
|
+
const calculateRouteRequestSchema = extend(
|
|
4385
|
+
commonRoutingRequestSchema,
|
|
4386
|
+
extend(calculateRouteRequestSchemaMandatory, calculateRouteRequestSchemaOptional.shape).shape
|
|
4387
|
+
);
|
|
4388
|
+
const calculateRoutelocationsRefinement = {
|
|
4389
|
+
check: (data) => {
|
|
4390
|
+
const routePlanningLocationTypes = data.locations.map(core.getRoutePlanningLocationType);
|
|
4391
|
+
if (!routePlanningLocationTypes.includes("path")) {
|
|
4392
|
+
return data.locations.length >= 2;
|
|
4393
|
+
}
|
|
4394
|
+
return true;
|
|
4395
|
+
},
|
|
4396
|
+
message: "When passing waypoints only: at least 2 must be defined. If passing also paths, at least one path must be defined"
|
|
4397
|
+
};
|
|
4398
|
+
const routeRequestValidationConfig = {
|
|
4399
|
+
schema: calculateRouteRequestSchema,
|
|
4400
|
+
refinements: [calculateRoutelocationsRefinement]
|
|
4401
|
+
};
|
|
4402
|
+
const getChargingPreferences = (params) => params.vehicle?.preferences?.chargingPreferences;
|
|
4403
|
+
const buildUrlBasePath$1 = (params) => params.customServiceBaseURL || `${params.commonBaseURL}/maps/orbis/routing/${getChargingPreferences(params) ? "calculateLongDistanceEVRoute" : "calculateRoute"}`;
|
|
4404
|
+
const getWaypointProps = (waypointInput) => waypointInput.properties || null;
|
|
4405
|
+
const defaultUseEntryPointOption = "main-when-available";
|
|
4406
|
+
const buildLocationsStringFromWaypoints = (waypointInputs, useEntryPoint) => waypointInputs.map((waypointInput) => {
|
|
4407
|
+
const lngLatString = positionToCSVLatLon(core.getPositionStrict(waypointInput, { useEntryPoint }));
|
|
4408
|
+
const radius = getWaypointProps(waypointInput)?.radiusMeters;
|
|
4409
|
+
return radius ? `circle(${lngLatString},${radius})` : lngLatString;
|
|
4410
|
+
}).join(":");
|
|
4411
|
+
const getPositionsFromPath = (pathLike) => {
|
|
4412
|
+
if (Array.isArray(pathLike)) {
|
|
4413
|
+
return pathLike;
|
|
4414
|
+
}
|
|
4415
|
+
return pathLike.geometry.coordinates;
|
|
4416
|
+
};
|
|
4417
|
+
const getFirstAndLastPoints = (locations, types, useEntryPoint) => {
|
|
4418
|
+
let firstPoint;
|
|
4419
|
+
const firstRoutePlanningLocation = locations[0];
|
|
4420
|
+
if (types[0] === "path") {
|
|
4421
|
+
const positions = getPositionsFromPath(firstRoutePlanningLocation);
|
|
4422
|
+
firstPoint = positions[0];
|
|
4423
|
+
} else {
|
|
4424
|
+
firstPoint = core.getPositionStrict(firstRoutePlanningLocation, { useEntryPoint });
|
|
4425
|
+
}
|
|
4426
|
+
const lastRoutePlanningLocation = locations[locations.length - 1];
|
|
4427
|
+
let lastPoint;
|
|
4428
|
+
if (types[types.length - 1] === "path") {
|
|
4429
|
+
const positions = getPositionsFromPath(lastRoutePlanningLocation);
|
|
4430
|
+
lastPoint = positions[positions.length - 1];
|
|
4431
|
+
} else {
|
|
4432
|
+
lastPoint = core.getPositionStrict(lastRoutePlanningLocation, { useEntryPoint });
|
|
4433
|
+
}
|
|
4434
|
+
return [firstPoint, lastPoint];
|
|
4435
|
+
};
|
|
4436
|
+
const buildLocationsString = (locations, routePlanningLocationTypes, useEntryPoint) => buildLocationsStringFromWaypoints(
|
|
4437
|
+
routePlanningLocationTypes.includes("path") ? getFirstAndLastPoints(locations, routePlanningLocationTypes, useEntryPoint) : locations,
|
|
4438
|
+
useEntryPoint
|
|
4439
|
+
);
|
|
4440
|
+
const appendSectionTypes = (urlParams, sectionTypes, instructionsInclude) => {
|
|
4441
|
+
const effectiveSectionTypes = (sectionTypes ?? (instructionsInclude ? core.inputSectionTypesWithGuidance : core.inputSectionTypes)).map((sectionType) => sectionType === "vehicleRestricted" ? "travelMode" : sectionType);
|
|
4442
|
+
appendByRepeatingParamName(urlParams, "sectionType", effectiveSectionTypes);
|
|
4443
|
+
};
|
|
4444
|
+
const appendGuidanceParams = (urlParams, params) => {
|
|
4445
|
+
if (params?.guidance) {
|
|
4446
|
+
const guidance = params.guidance;
|
|
4447
|
+
urlParams.append("instructionsType", guidance.type);
|
|
4448
|
+
urlParams.append("guidanceVersion", String(guidance.version ?? 2));
|
|
4449
|
+
urlParams.append("instructionPhonetics", guidance.phonetics ?? "IPA");
|
|
4450
|
+
urlParams.append("instructionRoadShieldReferences", guidance.roadShieldReferences ?? "all");
|
|
4451
|
+
urlParams.append("language", params.language ?? "en-US");
|
|
4452
|
+
}
|
|
4453
|
+
};
|
|
4454
|
+
const toLatLngPointApi = (position) => ({
|
|
4455
|
+
latitude: position[1],
|
|
4456
|
+
longitude: position[0]
|
|
4457
|
+
});
|
|
4458
|
+
const appendPathPostData = (pathRoutePlanningLocation, routePlanningLocationIndex, locations, supportingPoints, pointWaypoints) => {
|
|
4459
|
+
const supportingPointsLengthBeforePath = supportingPoints.length;
|
|
4460
|
+
for (const position of getPositionsFromPath(pathRoutePlanningLocation)) {
|
|
4461
|
+
supportingPoints.push(toLatLngPointApi(position));
|
|
4462
|
+
}
|
|
4463
|
+
if (!Array.isArray(pathRoutePlanningLocation)) {
|
|
4464
|
+
const legs = pathRoutePlanningLocation.properties.sections.leg;
|
|
4465
|
+
legs.forEach((leg, legIndex) => {
|
|
4466
|
+
if (routePlanningLocationIndex > 0 || legIndex > 0) {
|
|
4467
|
+
pointWaypoints.push({
|
|
4468
|
+
supportingPointIndex: supportingPointsLengthBeforePath + leg.startPointIndex,
|
|
4469
|
+
waypointSourceType: "USER_DEFINED"
|
|
4470
|
+
});
|
|
4471
|
+
}
|
|
4472
|
+
});
|
|
4473
|
+
if (routePlanningLocationIndex < locations.length - 1) {
|
|
4474
|
+
pointWaypoints.push({
|
|
4475
|
+
supportingPointIndex: supportingPointsLengthBeforePath + pathRoutePlanningLocation.geometry.coordinates.length - 1,
|
|
4476
|
+
waypointSourceType: "USER_DEFINED"
|
|
4477
|
+
});
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4480
|
+
};
|
|
4481
|
+
const appendWaypointPostData = (waypoint, routePlanningLocationIndex, locations, supportingPoints, pointWaypoints, useEntryPoint) => {
|
|
4482
|
+
supportingPoints.push(toLatLngPointApi(core.getPositionStrict(waypoint, { useEntryPoint })));
|
|
4483
|
+
if (routePlanningLocationIndex > 0 && routePlanningLocationIndex < locations.length - 1) {
|
|
4484
|
+
pointWaypoints.push({
|
|
4485
|
+
supportingPointIndex: supportingPoints.length - 1,
|
|
4486
|
+
waypointSourceType: "USER_DEFINED"
|
|
4487
|
+
});
|
|
4488
|
+
}
|
|
4489
|
+
};
|
|
4490
|
+
const buildlocationsPostData = (locations, types, useEntryPoints) => {
|
|
4491
|
+
const supportingPoints = [];
|
|
4492
|
+
const pointWaypoints = [];
|
|
4493
|
+
locations.forEach((routePlanningLocation, routePlanningLocationIndex) => {
|
|
4494
|
+
if (types[routePlanningLocationIndex] === "path") {
|
|
4495
|
+
appendPathPostData(
|
|
4496
|
+
routePlanningLocation,
|
|
4497
|
+
routePlanningLocationIndex,
|
|
4498
|
+
locations,
|
|
4499
|
+
supportingPoints,
|
|
4500
|
+
pointWaypoints
|
|
4501
|
+
);
|
|
4502
|
+
} else {
|
|
4503
|
+
appendWaypointPostData(
|
|
4504
|
+
routePlanningLocation,
|
|
4505
|
+
routePlanningLocationIndex,
|
|
4506
|
+
locations,
|
|
4507
|
+
supportingPoints,
|
|
4508
|
+
pointWaypoints,
|
|
4509
|
+
useEntryPoints
|
|
4510
|
+
);
|
|
4511
|
+
}
|
|
4512
|
+
});
|
|
4513
|
+
return { supportingPoints, ...pointWaypoints.length && { pointWaypoints } };
|
|
4514
|
+
};
|
|
4515
|
+
const buildPostData = (params, types, useEntryPoints) => {
|
|
4516
|
+
const pathsIncluded = types.includes("path");
|
|
4517
|
+
const isLdevr = !!getChargingPreferences(params);
|
|
4518
|
+
if (!pathsIncluded && !isLdevr) {
|
|
4519
|
+
return null;
|
|
4520
|
+
}
|
|
4521
|
+
const vehicleModel = params.vehicle?.model;
|
|
4522
|
+
const chargingModel = vehicleModel?.engine?.charging;
|
|
4523
|
+
return {
|
|
4524
|
+
...pathsIncluded && buildlocationsPostData(params.locations, types, useEntryPoints),
|
|
4525
|
+
...isLdevr && chargingModel && {
|
|
4526
|
+
chargingParameters: omit(chargingModel, "maxChargeKWH")
|
|
4527
|
+
}
|
|
4528
|
+
};
|
|
4529
|
+
};
|
|
4530
|
+
const buildCalculateRouteRequest = (params) => {
|
|
4531
|
+
const routePlanningLocationTypes = params.locations.map(core.getRoutePlanningLocationType);
|
|
4532
|
+
const useEntryPoints = params.useEntryPoints ?? defaultUseEntryPointOption;
|
|
4533
|
+
const url = new URL(
|
|
4534
|
+
`${buildUrlBasePath$1(params)}/${buildLocationsString(params.locations, routePlanningLocationTypes, useEntryPoints)}/json`
|
|
4535
|
+
);
|
|
4536
|
+
const urlParams = url.searchParams;
|
|
4537
|
+
appendCommonParams(urlParams, params);
|
|
4538
|
+
if (!("language" in params)) {
|
|
4539
|
+
urlParams.append("language", "en-GB");
|
|
4540
|
+
}
|
|
4541
|
+
appendCommonRoutingParams(urlParams, params);
|
|
4542
|
+
appendOptionalParam(urlParams, "computeTravelTimeFor", params.computeAdditionalTravelTimeFor);
|
|
4543
|
+
appendGuidanceParams(urlParams, params);
|
|
4544
|
+
!isNil(params.maxAlternatives) && urlParams.append("maxAlternatives", String(params.maxAlternatives));
|
|
4545
|
+
appendSectionTypes(urlParams, params.sectionTypes, !!params.guidance?.type);
|
|
4546
|
+
for (const representation of params.extendedRouteRepresentations ?? ["distance", "travelTime"]) {
|
|
4547
|
+
urlParams.append("extendedRouteRepresentation", representation);
|
|
4548
|
+
}
|
|
4549
|
+
const postData = buildPostData(params, routePlanningLocationTypes, useEntryPoints);
|
|
4550
|
+
return postData ? { method: "POST", url, data: postData } : { method: "GET", url };
|
|
4551
|
+
};
|
|
4552
|
+
const toCurrentType = (apiCurrentType) => {
|
|
4553
|
+
switch (apiCurrentType) {
|
|
4554
|
+
case "Direct_Current":
|
|
4555
|
+
return "DC";
|
|
4556
|
+
case "Alternating_Current_1_Phase":
|
|
4557
|
+
return "AC1";
|
|
4558
|
+
case "Alternating_Current_3_Phase":
|
|
4559
|
+
return "AC3";
|
|
4560
|
+
default:
|
|
4561
|
+
return void 0;
|
|
4562
|
+
}
|
|
4563
|
+
};
|
|
4564
|
+
const toChargingSpeed = (powerInKW) => {
|
|
4565
|
+
if (powerInKW < 12) {
|
|
4566
|
+
return "slow";
|
|
4567
|
+
} else if (powerInKW < 50) {
|
|
4568
|
+
return "regular";
|
|
4569
|
+
} else if (powerInKW < 150) {
|
|
4570
|
+
return "fast";
|
|
4571
|
+
}
|
|
4572
|
+
return "ultra-fast";
|
|
4573
|
+
};
|
|
4574
|
+
const toChargingStop = (chargingInformationAtEndOfLeg, maxChargeKWH) => {
|
|
4575
|
+
const chargingConnectionInfo = chargingInformationAtEndOfLeg.chargingConnectionInfo;
|
|
4576
|
+
const chargingParkLocation = chargingInformationAtEndOfLeg.chargingParkLocation;
|
|
4577
|
+
const coordinates = [chargingParkLocation.coordinate.longitude, chargingParkLocation.coordinate.latitude];
|
|
4578
|
+
const addressParts = [chargingParkLocation.street, chargingParkLocation.houseNumber].filter(Boolean);
|
|
4579
|
+
const freeformAddress = addressParts.length > 0 ? addressParts.join(", ") : "";
|
|
4580
|
+
return {
|
|
4581
|
+
type: "Feature",
|
|
4582
|
+
id: chargingInformationAtEndOfLeg.chargingParkId,
|
|
4583
|
+
geometry: { type: "Point", coordinates },
|
|
4584
|
+
properties: {
|
|
4585
|
+
...omit(chargingInformationAtEndOfLeg, ["chargingConnectionInfo", "chargingParkLocation"]),
|
|
4586
|
+
type: "POI",
|
|
4587
|
+
address: {
|
|
4588
|
+
freeformAddress,
|
|
4589
|
+
...chargingParkLocation.street && { streetName: chargingParkLocation.street },
|
|
4590
|
+
...chargingParkLocation.houseNumber && { streetNumber: chargingParkLocation.houseNumber },
|
|
4591
|
+
...chargingParkLocation.city && { municipality: chargingParkLocation.city },
|
|
4592
|
+
...chargingParkLocation.region && { countrySubdivision: chargingParkLocation.region },
|
|
4593
|
+
...chargingParkLocation.postalCode && { postalCode: chargingParkLocation.postalCode },
|
|
4594
|
+
...chargingParkLocation.country && { country: chargingParkLocation.country }
|
|
4595
|
+
},
|
|
4596
|
+
...chargingConnectionInfo && {
|
|
4597
|
+
chargingConnectionInfo: {
|
|
4598
|
+
plugType: chargingConnectionInfo.chargingPlugType,
|
|
4599
|
+
currentInA: chargingConnectionInfo.chargingCurrentInA,
|
|
4600
|
+
voltageInV: chargingConnectionInfo.chargingVoltageInV,
|
|
4601
|
+
chargingPowerInkW: chargingConnectionInfo.chargingPowerInkW,
|
|
4602
|
+
currentType: toCurrentType(chargingConnectionInfo.chargingCurrentType),
|
|
4603
|
+
chargingSpeed: toChargingSpeed(chargingConnectionInfo.chargingPowerInkW)
|
|
4604
|
+
}
|
|
4605
|
+
},
|
|
4606
|
+
...maxChargeKWH && {
|
|
4607
|
+
targetChargeInPCT: 100 * chargingInformationAtEndOfLeg.targetChargeInkWh / maxChargeKWH
|
|
4608
|
+
},
|
|
4609
|
+
...chargingInformationAtEndOfLeg.chargingParkPowerInkW && {
|
|
4610
|
+
chargingParkSpeed: toChargingSpeed(chargingInformationAtEndOfLeg.chargingParkPowerInkW)
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
};
|
|
4614
|
+
};
|
|
4615
|
+
const parseSummary = (apiSummary, params) => {
|
|
4616
|
+
const maxChargeKWH = params?.vehicle?.model?.engine?.charging?.maxChargeKWH;
|
|
4617
|
+
return {
|
|
4618
|
+
...apiSummary,
|
|
4619
|
+
departureTime: new Date(apiSummary.departureTime),
|
|
4620
|
+
arrivalTime: new Date(apiSummary.arrivalTime),
|
|
4621
|
+
// EV-specific fields:
|
|
4622
|
+
...maxChargeKWH && apiSummary.batteryConsumptionInkWh && {
|
|
4623
|
+
batteryConsumptionInPCT: 100 * apiSummary.batteryConsumptionInkWh / maxChargeKWH
|
|
4624
|
+
},
|
|
4625
|
+
...maxChargeKWH && apiSummary.remainingChargeAtArrivalInkWh && {
|
|
4626
|
+
remainingChargeAtArrivalInPCT: 100 * apiSummary.remainingChargeAtArrivalInkWh / maxChargeKWH
|
|
4627
|
+
},
|
|
4628
|
+
...apiSummary.chargingInformationAtEndOfLeg && {
|
|
4629
|
+
chargingInformationAtEndOfLeg: toChargingStop(apiSummary.chargingInformationAtEndOfLeg, maxChargeKWH)
|
|
4630
|
+
}
|
|
4631
|
+
};
|
|
4632
|
+
};
|
|
4633
|
+
const parseRoutePath = (apiRouteLegs) => ({
|
|
4634
|
+
type: "LineString",
|
|
4635
|
+
coordinates: apiRouteLegs.flatMap(
|
|
4636
|
+
(apiLeg) => apiLeg.points?.map((apiPoint) => [apiPoint.longitude, apiPoint.latitude])
|
|
4637
|
+
)
|
|
4638
|
+
});
|
|
4639
|
+
const parseLegSectionProps = (apiLegs, params) => apiLegs.reduce((accumulatedParsedLegs, nextApiLeg, currentIndex) => {
|
|
4640
|
+
const lastLegEndPointIndex = currentIndex === 0 ? 0 : accumulatedParsedLegs[currentIndex - 1]?.endPointIndex;
|
|
4641
|
+
let endPointIndex;
|
|
4642
|
+
if (!isNil(lastLegEndPointIndex)) {
|
|
4643
|
+
if (lastLegEndPointIndex === 0) {
|
|
4644
|
+
endPointIndex = nextApiLeg.points?.length > 0 ? nextApiLeg.points.length - 1 : 0;
|
|
4645
|
+
} else {
|
|
4646
|
+
endPointIndex = lastLegEndPointIndex + nextApiLeg.points?.length;
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4649
|
+
accumulatedParsedLegs.push({
|
|
4650
|
+
...!isNil(lastLegEndPointIndex) && { startPointIndex: lastLegEndPointIndex },
|
|
4651
|
+
...endPointIndex && { endPointIndex },
|
|
4652
|
+
summary: parseSummary(nextApiLeg.summary, params),
|
|
4653
|
+
id: core.generateId()
|
|
4654
|
+
});
|
|
4655
|
+
return accumulatedParsedLegs;
|
|
4656
|
+
}, []);
|
|
4657
|
+
const toSectionProps = (apiSection) => ({
|
|
4658
|
+
id: core.generateId(),
|
|
4659
|
+
startPointIndex: apiSection.startPointIndex,
|
|
4660
|
+
endPointIndex: apiSection.endPointIndex
|
|
4661
|
+
});
|
|
4662
|
+
const toRoadStretchSectionProps = (apiSection) => ({
|
|
4663
|
+
...toSectionProps(apiSection),
|
|
4664
|
+
index: apiSection.importantRoadStretchIndex,
|
|
4665
|
+
streetName: apiSection.streetName?.text,
|
|
4666
|
+
roadNumbers: apiSection.roadNumbers
|
|
4667
|
+
});
|
|
4668
|
+
const toCountrySectionProps = (apiSection) => ({
|
|
4669
|
+
...toSectionProps(apiSection),
|
|
4670
|
+
countryCodeISO3: apiSection.countryCode
|
|
4671
|
+
});
|
|
4672
|
+
const toVehicleRestrictedSectionProps = (apiSection) => apiSection.travelMode === "other" ? toSectionProps(apiSection) : null;
|
|
4673
|
+
const toTrafficSectionProps = (apiSection) => ({
|
|
4674
|
+
...toSectionProps(apiSection),
|
|
4675
|
+
delayInSeconds: apiSection.delayInSeconds,
|
|
4676
|
+
effectiveSpeedInKmh: apiSection.effectiveSpeedInKmh,
|
|
4677
|
+
simpleCategory: apiSection.simpleCategory.toLowerCase(),
|
|
4678
|
+
magnitudeOfDelay: core.indexedMagnitudes[apiSection.magnitudeOfDelay],
|
|
4679
|
+
tec: apiSection.tec
|
|
4680
|
+
});
|
|
4681
|
+
const toLaneSectionProps = (apiSection) => ({
|
|
4682
|
+
...toSectionProps(apiSection),
|
|
4683
|
+
lanes: apiSection.lanes,
|
|
4684
|
+
laneSeparators: apiSection.laneSeparators,
|
|
4685
|
+
properties: apiSection.properties
|
|
4686
|
+
});
|
|
4687
|
+
const toSpeedLimitSectionProps = (apiSection) => ({
|
|
4688
|
+
...toSectionProps(apiSection),
|
|
4689
|
+
maxSpeedLimitInKmh: apiSection.maxSpeedLimitInKmh
|
|
4690
|
+
});
|
|
4691
|
+
const toRoadShieldsSectionProps = (apiSection) => ({
|
|
4692
|
+
...toSectionProps(apiSection),
|
|
4693
|
+
roadShieldReferences: apiSection.roadShieldReferences
|
|
4694
|
+
});
|
|
4695
|
+
const ensureInit = (sectionType, result) => {
|
|
4696
|
+
if (!result[sectionType]) {
|
|
4697
|
+
result[sectionType] = [];
|
|
4698
|
+
}
|
|
4699
|
+
return result[sectionType];
|
|
4700
|
+
};
|
|
4701
|
+
const getSectionMapping = (apiSection) => {
|
|
4702
|
+
switch (apiSection.sectionType) {
|
|
4703
|
+
case "CAR_TRAIN":
|
|
4704
|
+
return { sectionType: "carTrain", mappingFunction: toSectionProps };
|
|
4705
|
+
case "COUNTRY":
|
|
4706
|
+
return { sectionType: "country", mappingFunction: toCountrySectionProps };
|
|
4707
|
+
case "FERRY":
|
|
4708
|
+
return { sectionType: "ferry", mappingFunction: toSectionProps };
|
|
4709
|
+
case "MOTORWAY":
|
|
4710
|
+
return { sectionType: "motorway", mappingFunction: toSectionProps };
|
|
4711
|
+
case "PEDESTRIAN":
|
|
4712
|
+
return { sectionType: "pedestrian", mappingFunction: toSectionProps };
|
|
4713
|
+
case "TOLL_VIGNETTE":
|
|
4714
|
+
return { sectionType: "tollVignette", mappingFunction: toCountrySectionProps };
|
|
4715
|
+
case "TOLL":
|
|
4716
|
+
return { sectionType: "toll", mappingFunction: toSectionProps };
|
|
4717
|
+
case "TRAFFIC":
|
|
4718
|
+
return { sectionType: "traffic", mappingFunction: toTrafficSectionProps };
|
|
4719
|
+
case "TRAVEL_MODE":
|
|
4720
|
+
return { sectionType: "vehicleRestricted", mappingFunction: toVehicleRestrictedSectionProps };
|
|
4721
|
+
case "TUNNEL":
|
|
4722
|
+
return { sectionType: "tunnel", mappingFunction: toSectionProps };
|
|
4723
|
+
case "UNPAVED":
|
|
4724
|
+
return { sectionType: "unpaved", mappingFunction: toSectionProps };
|
|
4725
|
+
case "URBAN":
|
|
4726
|
+
return { sectionType: "urban", mappingFunction: toSectionProps };
|
|
4727
|
+
case "CARPOOL":
|
|
4728
|
+
return { sectionType: "carpool", mappingFunction: toSectionProps };
|
|
4729
|
+
case "LOW_EMISSION_ZONE":
|
|
4730
|
+
return { sectionType: "lowEmissionZone", mappingFunction: toSectionProps };
|
|
4731
|
+
case "LANES":
|
|
4732
|
+
return { sectionType: "lanes", mappingFunction: toLaneSectionProps };
|
|
4733
|
+
case "SPEED_LIMIT":
|
|
4734
|
+
return { sectionType: "speedLimit", mappingFunction: toSpeedLimitSectionProps };
|
|
4735
|
+
case "ROAD_SHIELDS":
|
|
4736
|
+
return { sectionType: "roadShields", mappingFunction: toRoadShieldsSectionProps };
|
|
4737
|
+
case "IMPORTANT_ROAD_STRETCH":
|
|
4738
|
+
return { sectionType: "importantRoadStretch", mappingFunction: toRoadStretchSectionProps };
|
|
4739
|
+
}
|
|
4740
|
+
};
|
|
4741
|
+
const parseSectionsAndAppendToResult = (apiSections, result) => {
|
|
4742
|
+
if (!Array.isArray(apiSections)) {
|
|
4743
|
+
return;
|
|
4744
|
+
}
|
|
4745
|
+
for (const apiSection of apiSections) {
|
|
4746
|
+
const sectionMapping = getSectionMapping(apiSection);
|
|
4747
|
+
const mappedSection = sectionMapping?.mappingFunction(apiSection);
|
|
4748
|
+
if (mappedSection) {
|
|
4749
|
+
ensureInit(sectionMapping.sectionType, result).push(mappedSection);
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
};
|
|
4753
|
+
const parseSections = (apiRoute, params) => {
|
|
4754
|
+
const result = {
|
|
4755
|
+
leg: parseLegSectionProps(apiRoute.legs, params)
|
|
4756
|
+
// (the rest of sections are parsed below)
|
|
4757
|
+
};
|
|
4758
|
+
parseSectionsAndAppendToResult(apiRoute.sections, result);
|
|
4759
|
+
return result;
|
|
4760
|
+
};
|
|
4761
|
+
const DELTA = 1e-4;
|
|
4762
|
+
const similar = (a, b) => Math.abs(a[0] - b[0]) < DELTA && Math.abs(a[1] - b[1]) < DELTA;
|
|
4763
|
+
const parseGuidance = (apiGuidance, path) => {
|
|
4764
|
+
const instructions = [];
|
|
4765
|
+
let lastInstructionPathIndex = 0;
|
|
4766
|
+
for (const apiInstruction of apiGuidance.instructions) {
|
|
4767
|
+
const maneuverPoint = [apiInstruction.maneuverPoint.longitude, apiInstruction.maneuverPoint.latitude];
|
|
4768
|
+
for (let pathIndex = lastInstructionPathIndex; pathIndex < path.length; pathIndex++) {
|
|
4769
|
+
if (similar(path[pathIndex], maneuverPoint)) {
|
|
4770
|
+
lastInstructionPathIndex = pathIndex;
|
|
4771
|
+
break;
|
|
4772
|
+
}
|
|
4773
|
+
if (pathIndex === path.length - 1) {
|
|
4774
|
+
break;
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
instructions.push({
|
|
4778
|
+
...apiInstruction,
|
|
4779
|
+
maneuverPoint,
|
|
4780
|
+
pathPointIndex: lastInstructionPathIndex,
|
|
4781
|
+
routePath: apiInstruction.routePath.map((apiPoint) => ({
|
|
4782
|
+
...apiPoint,
|
|
4783
|
+
point: [apiPoint.point.longitude, apiPoint.point.latitude]
|
|
4784
|
+
}))
|
|
4785
|
+
});
|
|
4786
|
+
}
|
|
4787
|
+
return { instructions };
|
|
4788
|
+
};
|
|
4789
|
+
const parseRoute = (apiRoute, index, params) => {
|
|
4790
|
+
const geometry = parseRoutePath(apiRoute.legs);
|
|
4791
|
+
const bbox = core.bboxFromGeoJSON(geometry);
|
|
4792
|
+
const id = core.generateId();
|
|
4793
|
+
return {
|
|
4794
|
+
type: "Feature",
|
|
4795
|
+
geometry,
|
|
4796
|
+
id,
|
|
4797
|
+
...bbox && { bbox },
|
|
4798
|
+
properties: {
|
|
4799
|
+
id,
|
|
4800
|
+
index,
|
|
4801
|
+
summary: parseSummary(apiRoute.summary, params),
|
|
4802
|
+
sections: parseSections(apiRoute, params),
|
|
4803
|
+
...apiRoute.guidance && { guidance: parseGuidance(apiRoute.guidance, geometry.coordinates) },
|
|
4804
|
+
...apiRoute.progress && { progress: apiRoute.progress }
|
|
4805
|
+
}
|
|
4806
|
+
};
|
|
4807
|
+
};
|
|
4808
|
+
const parseCalculateRouteResponse = (apiResponse, params) => {
|
|
4809
|
+
const features = apiResponse.routes.map((apiRoute, index) => parseRoute(apiRoute, index, params));
|
|
4810
|
+
const bbox = core.bboxFromGeoJSON(features);
|
|
4811
|
+
return { type: "FeatureCollection", ...bbox && { bbox }, features };
|
|
4812
|
+
};
|
|
4813
|
+
const parseRoutingResponseError = (apiError, serviceName) => {
|
|
4814
|
+
const { data, message, status } = apiError;
|
|
4815
|
+
const errorMessage = data?.error?.description ?? data?.detailedError?.message ?? message;
|
|
4816
|
+
return new SDKServiceError(errorMessage, serviceName, status);
|
|
4817
|
+
};
|
|
4818
|
+
const calculateRouteTemplate = {
|
|
4819
|
+
requestValidation: routeRequestValidationConfig,
|
|
4820
|
+
buildRequest: buildCalculateRouteRequest,
|
|
4821
|
+
sendRequest: fetchWith,
|
|
4822
|
+
parseResponse: parseCalculateRouteResponse,
|
|
4823
|
+
parseResponseError: parseRoutingResponseError,
|
|
4824
|
+
getAPIVersion: () => 2
|
|
4825
|
+
};
|
|
4826
|
+
const customize = {
|
|
4827
|
+
buildCalculateRouteRequest,
|
|
4828
|
+
parseCalculateRouteResponse,
|
|
4829
|
+
calculateRouteTemplate
|
|
4830
|
+
};
|
|
4831
|
+
const customizeService = {
|
|
4832
|
+
reverseGeocode: customize$1,
|
|
4833
|
+
geocode: customize$6,
|
|
4834
|
+
geometryData: customize$5,
|
|
4835
|
+
geometrySearch: customize$4,
|
|
4836
|
+
calculateRoute: customize,
|
|
4837
|
+
reachableRange: customize$2,
|
|
4838
|
+
evChargingStationsAvailability: customize$7,
|
|
4839
|
+
placeByID: customize$3,
|
|
4840
|
+
autocompleteSearch: customize$8
|
|
4841
|
+
};
|
|
4842
|
+
const evChargingStationsAvailability = async (params, customTemplate) => callService(
|
|
4843
|
+
params,
|
|
4844
|
+
{ ...evChargingStationsAvailabilityTemplate, ...customTemplate },
|
|
4845
|
+
"EVChargingStationsAvailability"
|
|
4846
|
+
);
|
|
4847
|
+
const buildPlaceWithEVAvailability = async (place) => {
|
|
4848
|
+
const availabilityId = place.properties.dataSources?.chargingAvailability?.id;
|
|
4849
|
+
if (!availabilityId) {
|
|
4850
|
+
return place;
|
|
4851
|
+
}
|
|
4852
|
+
try {
|
|
4853
|
+
const availability = await evChargingStationsAvailability({ id: availabilityId });
|
|
4854
|
+
const poi = place.properties.poi;
|
|
4855
|
+
return availability ? {
|
|
4856
|
+
...place,
|
|
4857
|
+
properties: {
|
|
4858
|
+
...place.properties,
|
|
4859
|
+
// We override poi opening hours with the ones from the EV call, which might be better supported:
|
|
4860
|
+
...poi && { poi: { ...poi, openingHours: availability.openingHours } },
|
|
4861
|
+
chargingPark: {
|
|
4862
|
+
...place.properties.chargingPark,
|
|
4863
|
+
availability
|
|
4864
|
+
}
|
|
4865
|
+
}
|
|
4866
|
+
} : place;
|
|
4867
|
+
} catch (e) {
|
|
4868
|
+
console.error(e);
|
|
4869
|
+
return place;
|
|
4870
|
+
}
|
|
4871
|
+
};
|
|
4872
|
+
const buildPlacesWithEVAvailability = async (places, options = { includeIfAvailabilityUnknown: true }) => {
|
|
4873
|
+
const placesWithAvailability = [];
|
|
4874
|
+
for (const place of places.features) {
|
|
4875
|
+
const placeWithAvailability = await buildPlaceWithEVAvailability(place);
|
|
4876
|
+
if (placeWithAvailability.properties.chargingPark?.availability || options.includeIfAvailabilityUnknown) {
|
|
4877
|
+
placesWithAvailability.push(placeWithAvailability);
|
|
4878
|
+
}
|
|
4879
|
+
}
|
|
4880
|
+
return { ...places, features: placesWithAvailability, bbox: core.bboxFromGeoJSON(placesWithAvailability) };
|
|
4881
|
+
};
|
|
4882
|
+
const geocode = async (params, customTemplate) => callService(params, { ...geocodingTemplate, ...customTemplate }, "Geocode");
|
|
4883
|
+
const geocodeOne = async (query) => (await geocode({ query, limit: 1 })).features[0];
|
|
4884
|
+
const mergePlacesWithGeometries = (places, geometries) => {
|
|
4885
|
+
const placesIdMap = places.features.reduce(
|
|
4886
|
+
(acc, place) => {
|
|
4887
|
+
const geometryId = place.properties.dataSources?.geometry?.id;
|
|
4888
|
+
if (geometryId) {
|
|
4889
|
+
acc[geometryId] = {
|
|
4890
|
+
...place.properties,
|
|
4891
|
+
placeCoordinates: place.geometry.coordinates
|
|
4892
|
+
};
|
|
4893
|
+
}
|
|
4894
|
+
return acc;
|
|
4895
|
+
},
|
|
4896
|
+
{}
|
|
4897
|
+
);
|
|
4898
|
+
const features = geometries.features.map((feature) => {
|
|
4899
|
+
if (feature.id && placesIdMap[feature.id]) {
|
|
4900
|
+
return { ...feature, properties: placesIdMap[feature.id] };
|
|
4901
|
+
}
|
|
4902
|
+
return feature;
|
|
4903
|
+
});
|
|
4904
|
+
return {
|
|
4905
|
+
type: "FeatureCollection",
|
|
4906
|
+
bbox: geometries.bbox,
|
|
4907
|
+
features
|
|
4908
|
+
};
|
|
4909
|
+
};
|
|
4910
|
+
async function geometryData(params, customTemplate) {
|
|
4911
|
+
const geometryResult = await callService(params, { ...geometryDataTemplate, ...customTemplate }, "GeometryData");
|
|
4912
|
+
if (!Array.isArray(params.geometries) && params.geometries.type === "FeatureCollection") {
|
|
4913
|
+
return mergePlacesWithGeometries(params.geometries, geometryResult);
|
|
4914
|
+
}
|
|
4915
|
+
return geometryResult;
|
|
4916
|
+
}
|
|
4917
|
+
const placeById = async (params, customTemplate) => callService(params, { ...placeByIdTemplate, ...customTemplate }, "PlaceById");
|
|
4918
|
+
const reverseGeocode = async (params, customTemplate) => callService(params, { ...reverseGeocodingTemplate, ...customTemplate }, "ReverseGeocode");
|
|
4919
|
+
const calculateRoute = async (params, customTemplate) => callService(params, { ...calculateRouteTemplate, ...customTemplate }, "Routing");
|
|
4920
|
+
const fuzzySearchRequestOptional = partial(
|
|
4921
|
+
object({
|
|
4922
|
+
minFuzzyLevel: number().check(_gte(1), _lte(4)),
|
|
4923
|
+
maxFuzzyLevel: number().check(_gte(1), _lte(4))
|
|
4924
|
+
})
|
|
4925
|
+
);
|
|
4926
|
+
const fuzzySearchRequestSchema = extend(
|
|
4927
|
+
commonSearchParamsSchema,
|
|
4928
|
+
extend(commonGeocodeAndFuzzySearchParamsSchema, fuzzySearchRequestOptional.shape).shape
|
|
4929
|
+
);
|
|
4930
|
+
const buildUrlBasePath = (mergedOptions) => mergedOptions.customServiceBaseURL ?? `${mergedOptions.commonBaseURL}${PLACES_URL_PATH}/search/${mergedOptions.query}.json`;
|
|
4931
|
+
const buildFuzzySearchRequest = (params) => {
|
|
4932
|
+
const url = new URL(`${buildUrlBasePath(params)}`);
|
|
4933
|
+
appendCommonSearchParams(url, params);
|
|
4934
|
+
const urlParams = url.searchParams;
|
|
4935
|
+
appendOptionalParam(urlParams, "typeahead", params.typeahead);
|
|
4936
|
+
appendOptionalParam(urlParams, "ofs", params.offset);
|
|
4937
|
+
appendByJoiningParamValue(urlParams, "countrySet", params.countries);
|
|
4938
|
+
appendOptionalParam(urlParams, "radius", params.radiusMeters);
|
|
4939
|
+
const bbox = params.boundingBox && core.bboxFromGeoJSON(params.boundingBox);
|
|
4940
|
+
if (bbox) {
|
|
4941
|
+
urlParams.append("topLeft", arrayToCSV([bbox[3], bbox[0]]));
|
|
4942
|
+
urlParams.append("btmRight", arrayToCSV([bbox[1], bbox[2]]));
|
|
4943
|
+
}
|
|
4944
|
+
appendOptionalParam(urlParams, "minFuzzyLevel", params.minFuzzyLevel);
|
|
4945
|
+
appendOptionalParam(urlParams, "maxFuzzyLevel", params.maxFuzzyLevel);
|
|
4946
|
+
return url;
|
|
4947
|
+
};
|
|
4948
|
+
const queryIntentApiToSdk = (intentApi) => {
|
|
4949
|
+
let intent;
|
|
4950
|
+
switch (intentApi.type) {
|
|
4951
|
+
case "COORDINATE":
|
|
4952
|
+
intent = { ...intentApi, details: { position: latLonAPIToPosition(intentApi.details) } };
|
|
4953
|
+
break;
|
|
4954
|
+
case "NEARBY":
|
|
4955
|
+
intent = {
|
|
4956
|
+
...intentApi,
|
|
4957
|
+
details: {
|
|
4958
|
+
position: latLonAPIToPosition({ lon: intentApi.details.lon, lat: intentApi.details.lat }),
|
|
4959
|
+
text: intentApi.details.text,
|
|
4960
|
+
query: intentApi.details.query
|
|
4961
|
+
}
|
|
4962
|
+
};
|
|
4963
|
+
break;
|
|
4964
|
+
case "BOOKMARK":
|
|
4965
|
+
case "W3W":
|
|
4966
|
+
intent = intentApi;
|
|
4967
|
+
}
|
|
4968
|
+
return intent;
|
|
4969
|
+
};
|
|
4970
|
+
const parseFuzzySearchResponse = (apiResponse) => {
|
|
4971
|
+
const features = apiResponse.results.map(parseSearchAPIResult);
|
|
4972
|
+
const bbox = core.bboxOnlyIfWithArea(core.bboxFromGeoJSON(features));
|
|
4973
|
+
return {
|
|
4974
|
+
type: "FeatureCollection",
|
|
4975
|
+
properties: {
|
|
4976
|
+
...parseSummaryAPI(apiResponse.summary),
|
|
4977
|
+
queryIntent: apiResponse.summary.queryIntent.map(queryIntentApiToSdk)
|
|
4978
|
+
},
|
|
4979
|
+
features,
|
|
4980
|
+
...bbox && { bbox }
|
|
4981
|
+
};
|
|
4982
|
+
};
|
|
4983
|
+
const fuzzySearchTemplate = {
|
|
4984
|
+
requestValidation: { schema: fuzzySearchRequestSchema },
|
|
4985
|
+
buildRequest: buildFuzzySearchRequest,
|
|
4986
|
+
sendRequest: get,
|
|
4987
|
+
parseResponse: parseFuzzySearchResponse
|
|
4988
|
+
};
|
|
4989
|
+
const fuzzySearch = async (params, customTemplate) => callService(params, { ...fuzzySearchTemplate, ...customTemplate }, "FuzzySearch");
|
|
4990
|
+
const search = async (params, customTemplate) => "geometries" in params ? geometrySearch(params, customTemplate) : fuzzySearch(params, customTemplate);
|
|
4991
|
+
exports.APIErrorCode = APIErrorCode;
|
|
4992
|
+
exports.SDKError = SDKError;
|
|
4993
|
+
exports.SDKServiceError = SDKServiceError;
|
|
4994
|
+
exports.autocompleteSearch = autocompleteSearch;
|
|
4995
|
+
exports.buildPlaceWithEVAvailability = buildPlaceWithEVAvailability;
|
|
4996
|
+
exports.buildPlacesWithEVAvailability = buildPlacesWithEVAvailability;
|
|
4997
|
+
exports.buildResponseError = buildResponseError;
|
|
4998
|
+
exports.buildValidationError = buildValidationError;
|
|
4999
|
+
exports.calculateRoute = calculateRoute;
|
|
5000
|
+
exports.customizeService = customizeService;
|
|
5001
|
+
exports.evChargingStationsAvailability = evChargingStationsAvailability;
|
|
5002
|
+
exports.geocode = geocode;
|
|
5003
|
+
exports.geocodeOne = geocodeOne;
|
|
5004
|
+
exports.geometryData = geometryData;
|
|
5005
|
+
exports.parseDefaultResponseError = parseDefaultResponseError;
|
|
5006
|
+
exports.placeById = placeById;
|
|
5007
|
+
exports.reverseGeocode = reverseGeocode;
|
|
5008
|
+
exports.search = search;
|
|
5009
|
+
//# sourceMappingURL=services.cjs.js.map
|