zavadil-ts-common 1.1.87 → 1.1.89

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.
@@ -17,7 +17,7 @@ export declare class RestClient {
17
17
  processRequestJson(endpoint: string, params?: any, requestOptions?: RequestOptions): Promise<any>;
18
18
  getJson(url: string, params?: any): Promise<any>;
19
19
  postJson(url: string, data?: object | null): Promise<any>;
20
- postForm(url: string, data: FormData): Promise<any>;
20
+ postForm(url: string, data: FormData): Promise<Response>;
21
21
  putJson(url: string, data?: object | null): Promise<any>;
22
22
  get(endpoint: string, params?: any): Promise<Response>;
23
23
  del(url: string): Promise<Response>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,435 @@
1
- export * from './cache';
2
- export * from './client';
3
- export * from './component';
4
- export * from './oauth';
5
- export * from './type';
6
- export * from './util';
7
- export * from './vector';
1
+ declare class CacheAsync<T> {
2
+ private cache?;
3
+ private supplier;
4
+ private maxAgeMs?;
5
+ private expires?;
6
+ constructor(supplier: () => Promise<T>, maxAgeMs?: number);
7
+ get(): Promise<T>;
8
+ set(v: T, expires?: Date): void;
9
+ hasCache(): boolean;
10
+ getCache(): T | undefined;
11
+ }
12
+
13
+ type SortingField = {
14
+ name: string;
15
+ desc?: boolean;
16
+ nullsLast?: boolean;
17
+ };
18
+ type SortingRequest = Array<SortingField>;
19
+ type PagingRequest = {
20
+ page: number;
21
+ size: number;
22
+ search?: string | null;
23
+ sorting?: SortingRequest | null;
24
+ };
25
+ type Page<Type> = {
26
+ totalItems: number;
27
+ pageSize: number;
28
+ pageNumber: number;
29
+ content: Array<Type>;
30
+ };
31
+
32
+ declare enum UserAlertType {
33
+ info = "info",
34
+ warning = "warning",
35
+ error = "danger"
36
+ }
37
+ type UserAlert = {
38
+ time: Date;
39
+ type: UserAlertType;
40
+ message: string;
41
+ };
42
+
43
+ type JavaHeapStats = {
44
+ heapSize: number;
45
+ heapMaxSize: number;
46
+ heapFreeSize: number;
47
+ };
48
+ type QueueStats = {
49
+ remaining: number;
50
+ loaded: number;
51
+ processed: number;
52
+ state: string;
53
+ };
54
+ type CacheStats = {
55
+ cachedItems: number;
56
+ capacity: number;
57
+ };
58
+ type HashCacheStats = CacheStats & {};
59
+
60
+ type EntityBase = {
61
+ id?: number | null;
62
+ createdOn?: Date;
63
+ lastUpdatedOn?: Date;
64
+ };
65
+ type EntityWithName = EntityBase & {
66
+ name: string;
67
+ };
68
+ type LookupTableEntity = EntityWithName & {};
69
+
70
+ declare class HashCacheAsync<K, V> {
71
+ private cache;
72
+ private supplier;
73
+ private maxSize;
74
+ constructor(supplier: (k: K) => Promise<V>, maxSize?: number);
75
+ protected obtainCache(k: K): CacheAsync<V>;
76
+ get(k: K): Promise<V>;
77
+ set(k: K, v: V, expires?: Date): void;
78
+ reset(k?: K): void;
79
+ getSize(): number;
80
+ getMaxSize(): number;
81
+ getStats(): HashCacheStats;
82
+ hasCache(k: K): boolean;
83
+ }
84
+
85
+ declare class Lazy<T> {
86
+ private cache?;
87
+ private supplier;
88
+ constructor(supplier: () => T);
89
+ get(): T;
90
+ reset(): void;
91
+ hasCache(): boolean;
92
+ }
93
+
94
+ declare class LazyAsync<T> {
95
+ private cache?;
96
+ private supplier;
97
+ private promise?;
98
+ constructor(supplier: () => Promise<T>);
99
+ get(): Promise<T>;
100
+ reset(): void;
101
+ hasCache(): boolean;
102
+ getCache(): T | undefined;
103
+ }
104
+
105
+ type RequestOptions = RequestInit & {
106
+ headers: Headers;
107
+ };
108
+ declare class RestClient {
109
+ private baseUrl;
110
+ constructor(baseUrl: string);
111
+ static pagingRequestToQueryParams(pr?: PagingRequest | null): any;
112
+ static paramsToQueryString(params?: any): string;
113
+ /**
114
+ * Override this to customize http headers.
115
+ */
116
+ getHeaders(endpoint: string): Promise<Headers>;
117
+ getUrl(endpoint: string, params?: any): URL;
118
+ getRequestOptions(endpoint: string, method?: string, data?: object | null): Promise<RequestOptions>;
119
+ processRequest(endpoint: string, params?: any, requestOptions?: RequestOptions): Promise<Response>;
120
+ processRequestJson(endpoint: string, params?: any, requestOptions?: RequestOptions): Promise<any>;
121
+ getJson(url: string, params?: any): Promise<any>;
122
+ postJson(url: string, data?: object | null): Promise<any>;
123
+ postForm(url: string, data: FormData): Promise<Response>;
124
+ putJson(url: string, data?: object | null): Promise<any>;
125
+ get(endpoint: string, params?: any): Promise<Response>;
126
+ del(url: string): Promise<Response>;
127
+ post(url: string, data?: object | null): Promise<Response>;
128
+ put(url: string, data?: object | null): Promise<Response>;
129
+ }
130
+
131
+ declare class EntityClient<T extends EntityBase> {
132
+ client: RestClient;
133
+ name: string;
134
+ constructor(client: RestClient, name: string);
135
+ loadSingle(id: number): Promise<T>;
136
+ loadPage(pr: PagingRequest): Promise<Page<T>>;
137
+ save(d: T): Promise<T>;
138
+ delete(id: number): Promise<any>;
139
+ }
140
+
141
+ declare class EntityCachedClient<T extends EntityBase> extends EntityClient<T> {
142
+ protected cache: HashCacheAsync<number, T>;
143
+ constructor(client: RestClient, name: string, maxSize?: number);
144
+ loadSingle(id: number): Promise<T>;
145
+ save(d: T): Promise<T>;
146
+ delete(id: number): Promise<any>;
147
+ reset(id?: number): void;
148
+ getStats(): HashCacheStats;
149
+ }
150
+
151
+ declare class EntityClientWithStub<T extends EntityBase, TStub extends EntityBase> extends EntityClient<T> {
152
+ loadSingle(id: number): Promise<T>;
153
+ loadSingleStub(id: number): Promise<TStub>;
154
+ save(d: T): Promise<T>;
155
+ saveStub(d: TStub): Promise<TStub>;
156
+ }
157
+
158
+ declare class LookupClient<T extends EntityBase> extends EntityClient<T> {
159
+ protected cache: LazyAsync<Array<T>>;
160
+ constructor(client: RestClient, name: string);
161
+ private loadAllInternal;
162
+ loadAll(): Promise<Array<T>>;
163
+ loadSingle(id: number): Promise<T>;
164
+ save(d: T): Promise<T>;
165
+ delete(id: number): Promise<any>;
166
+ reset(): void;
167
+ getStats(): HashCacheStats;
168
+ }
169
+
170
+ type Func = {
171
+ (arg?: any): void;
172
+ };
173
+ type FuncHandlers = Array<Func>;
174
+ type FuncHandlersCache = Map<string, FuncHandlers>;
175
+ declare class EventManager {
176
+ handlers: FuncHandlersCache;
177
+ constructor();
178
+ addEventListener(event: string, handler: Func): void;
179
+ removeEventListener(event: string, handler: Func): void;
180
+ triggerEvent(event: string, arg?: any): void;
181
+ }
182
+
183
+ declare class UserAlerts {
184
+ private maxAlerts;
185
+ private em;
186
+ alerts: Array<UserAlert>;
187
+ constructor(maxAlerts?: number);
188
+ addOnChangeHandler(h: Func): void;
189
+ removeOnChangeHandler(h: Func): void;
190
+ triggerChange(): void;
191
+ reset(): void;
192
+ remove(alert: UserAlert): void;
193
+ add(alert: UserAlert): void;
194
+ custom(type: UserAlertType, message: string): void;
195
+ err(error: string | Error): void;
196
+ warn(message: string): void;
197
+ info(message: string): void;
198
+ getSummary(): Map<UserAlertType, number>;
199
+ }
200
+
201
+ type CancelledWrapper = {
202
+ value: boolean;
203
+ };
204
+ declare class CancellablePromise {
205
+ isCancelled: CancelledWrapper;
206
+ throwWhenCancelled: boolean;
207
+ promise: Promise<any | void>;
208
+ constructor(promise: Promise<any | void>, throwWhenCancelled?: boolean);
209
+ cancel(): void;
210
+ }
211
+
212
+ type TokenRequestPayloadBase = {
213
+ targetAudience: string;
214
+ };
215
+ type RequestAccessTokenPayload = TokenRequestPayloadBase & {
216
+ idToken: string;
217
+ privilege: string;
218
+ };
219
+ type RequestIdTokenFromPrevTokenPayload = {
220
+ idToken: string;
221
+ };
222
+ type RequestIdTokenFromLoginPayload = TokenRequestPayloadBase & {
223
+ login: string;
224
+ password: string;
225
+ };
226
+ type TokenResponsePayloadBase = {
227
+ token: string;
228
+ issuedAt: Date;
229
+ expires?: Date | null;
230
+ };
231
+ type IdTokenPayload = TokenResponsePayloadBase & {};
232
+ type AccessTokenPayload = TokenResponsePayloadBase & {};
233
+ type JwKeyPayload = {
234
+ kty: string;
235
+ kid: string;
236
+ n: string;
237
+ e: string;
238
+ };
239
+ type JwksPayload = {
240
+ keys: Array<JwKeyPayload>;
241
+ };
242
+ /**
243
+ * This implements rest client for OAuth server - https://github.com/lotcz/oauth-server
244
+ * Provide basic url, /api/oauth path prefix will be added automatically
245
+ */
246
+ declare class OAuthRestClient extends RestClient {
247
+ constructor(oauthUrl: string);
248
+ jwks(): Promise<JwksPayload>;
249
+ verifyIdToken(idToken: string): Promise<IdTokenPayload>;
250
+ requestIdTokenFromLogin(request: RequestIdTokenFromLoginPayload): Promise<IdTokenPayload>;
251
+ refreshIdToken(request: RequestIdTokenFromPrevTokenPayload): Promise<IdTokenPayload>;
252
+ requestAccessToken(request: RequestAccessTokenPayload): Promise<AccessTokenPayload>;
253
+ }
254
+
255
+ /**
256
+ * Manages refresh of id and access tokens.
257
+ */
258
+ declare class OAuthTokenManager {
259
+ private eventManager;
260
+ oAuthServer: OAuthRestClient;
261
+ audience: string;
262
+ idToken?: IdTokenPayload;
263
+ accessTokens: Map<string, AccessTokenPayload>;
264
+ constructor(oAuthServerBaseUrl: string, targetAudience: string);
265
+ addIdTokenChangedHandler(handler: (t: IdTokenPayload) => any): void;
266
+ isTokenExpired(expires?: Date | null): boolean;
267
+ isTokenReadyForRefresh(issuedAt: Date, expires?: Date | null): boolean;
268
+ isValidIdToken(idToken?: IdTokenPayload): boolean;
269
+ hasValidIdToken(): boolean;
270
+ isValidAccessToken(accessToken?: AccessTokenPayload): boolean;
271
+ hasValidAccessToken(privilege: string): boolean;
272
+ reset(): void;
273
+ getIdToken(): Promise<string>;
274
+ setIdToken(token?: IdTokenPayload): void;
275
+ verifyIdToken(token: string): Promise<boolean>;
276
+ login(login: string, password: string): Promise<boolean>;
277
+ private getAccessTokenInternal;
278
+ getAccessToken(privilege: string): Promise<string>;
279
+ }
280
+
281
+ declare class OAuthSubject {
282
+ private value;
283
+ constructor(value: string);
284
+ getSubjectType(): string | null;
285
+ getSubjectContent(): string | null;
286
+ toString(): string;
287
+ }
288
+
289
+ type ServerOAuthInfoPayload = {
290
+ debugMode?: boolean;
291
+ targetAudience: string;
292
+ oauthServerUrl: string;
293
+ version: string;
294
+ };
295
+ declare class RestClientWithOAuth extends RestClient {
296
+ private insecureClient;
297
+ private tokenManager;
298
+ private serverInfo;
299
+ private defaultPrivilege;
300
+ constructor(url: string, defaultPrivilege?: string);
301
+ initializeIdToken(): Promise<boolean>;
302
+ /**
303
+ * Attempt to get ID token from URL or storage, redirect to login page when not successful
304
+ */
305
+ initialize(): Promise<boolean>;
306
+ logout(): Promise<any>;
307
+ /**
308
+ * Override this if a different privilege is needed for different endpoints
309
+ * @param url
310
+ */
311
+ getPrivilege(url: string): string;
312
+ getIdTokenFromUrl(): string | null;
313
+ getIdTokenFromLocalStorage(): IdTokenPayload | null | undefined;
314
+ saveIdTokenToLocalStorage(token: IdTokenPayload | null): void;
315
+ addIdTokenChangedHandler(handler: () => any): void;
316
+ private getServerInfoInternal;
317
+ getServerInfo(): Promise<ServerOAuthInfoPayload>;
318
+ private getTokenManagerInternal;
319
+ getTokenManager(): Promise<OAuthTokenManager>;
320
+ login(login: string, password: string): Promise<boolean>;
321
+ setIdToken(token: IdTokenPayload): Promise<boolean>;
322
+ setIdTokenRaw(token: string): Promise<boolean>;
323
+ getHeaders(endpoint: string): Promise<Headers>;
324
+ /**
325
+ * Try to obtain access token, then return true if everything is okay.
326
+ * This is basically only used when initializing and trying to determine whether we need to redirect user to login page
327
+ */
328
+ checkAccessToken(privilege?: string): Promise<boolean>;
329
+ }
330
+
331
+ declare class ObjectUtil {
332
+ static isEmpty(obj: any): boolean;
333
+ static notEmpty(obj: any): boolean;
334
+ static clone<T>(obj: T): T;
335
+ }
336
+
337
+ declare class StringUtil extends ObjectUtil {
338
+ static isEmpty(str: string | null | undefined): boolean;
339
+ static notEmpty(str: string | null | undefined): boolean;
340
+ static isBlank(str: string | null | undefined): boolean;
341
+ static notBlank(str: string | null | undefined): boolean;
342
+ static substr(str: string | null | undefined, start: number, length?: number): string;
343
+ static replace(str: string | null | undefined, find?: null | string, replace?: string): string;
344
+ static containsLineBreaks(str: string | null | undefined): boolean;
345
+ static trimLeadingSlashes(str: string | null): string;
346
+ static trimTrailingSlashes(str: string | null): string;
347
+ static trimSlashes(str: string | null): string;
348
+ static safeTruncate(str: string | null | undefined, len: number, ellipsis?: string): string;
349
+ static ellipsis(str: string | null | undefined, len: number, ellipsis?: string): string;
350
+ static safeTrim(str: string | null | undefined): string;
351
+ static safeLowercase(str: string | null | undefined): string;
352
+ static safeUppercase(str: string | null | undefined): string;
353
+ static toBigInt(str: string | null): bigint | null;
354
+ static getNonEmpty(...args: Array<string | null | undefined>): string;
355
+ static getNonBlank(...args: Array<string | null | undefined>): string;
356
+ static emptyToNull(str: string | null | undefined): string | null;
357
+ static blankToNull(str: string | null | undefined): string | null;
358
+ }
359
+
360
+ declare class ArrayUtil {
361
+ static isEmpty(arr?: Array<any> | null): boolean;
362
+ static notEmpty(arr?: Array<any> | null): boolean;
363
+ static remove(arr?: Array<any> | null, element?: any): Array<any>;
364
+ }
365
+
366
+ declare class AsyncUtil {
367
+ static sleep: (ms: number) => Promise<unknown>;
368
+ }
369
+
370
+ declare class ByteUtil {
371
+ static formatByteSize(size?: number | null): string;
372
+ }
373
+
374
+ declare class PagingUtil {
375
+ static sortingFieldToString(s: SortingField): string;
376
+ static sortingFieldFromString(s: string): SortingField;
377
+ static sortingRequestToString(s: SortingRequest): string | undefined;
378
+ static sortingRequestFromString(s?: string | null): SortingRequest;
379
+ static pagingRequestToQueryParams(pr?: PagingRequest | null): any;
380
+ static pagingRequestToString(pr?: PagingRequest): string;
381
+ static pagingRequestFromString(pr?: string): PagingRequest;
382
+ }
383
+
384
+ declare class DateUtil {
385
+ static formatNumber(n: number, digits?: number): string;
386
+ static parseDate(d: Date | string | null | undefined): Date | undefined;
387
+ static formatDateForHumans(d: Date | string | null | undefined, showTime?: boolean): string;
388
+ static formatDateTimeForHumans(d: Date | string | null | undefined): string;
389
+ static formatDateForInput(d: any): string;
390
+ static getDurationMs(d1?: Date | string | null, d2?: Date | string | null): number | null;
391
+ static getSinceDurationMs(d1?: Date | string | null): number | null;
392
+ static formatDuration(ms?: number | null): string;
393
+ }
394
+
395
+ declare class NumberUtil extends ObjectUtil {
396
+ static parseNumber(str: string | null | undefined): number | null;
397
+ static round(n: number, d?: number): number;
398
+ static portionToPercent(p: number, d?: number): string;
399
+ }
400
+
401
+ declare class JsonUtil {
402
+ static reISO: RegExp;
403
+ static dateParser(key: string, value: any): any;
404
+ static parseWithDates(json?: string | null): any;
405
+ static parse(json?: string | null): any;
406
+ }
407
+
408
+ declare class Vector2 {
409
+ x: number;
410
+ y: number;
411
+ constructor(x: number, y: number);
412
+ distanceTo(v: Vector2): number;
413
+ equalsTo(v: Vector2): boolean;
414
+ size(): number;
415
+ inSize(size: number): Vector2;
416
+ round(): Vector2;
417
+ add(v: Vector2): Vector2;
418
+ multiply(s: number): Vector2;
419
+ subtract(v: Vector2): Vector2;
420
+ sub(v: Vector2): Vector2;
421
+ toArray(): number[];
422
+ static fromArray(arr: number[]): Vector2 | undefined;
423
+ clone(): Vector2;
424
+ /***
425
+ * Return angle between AB and Y axis in radians
426
+ * @param {Vector2} b
427
+ * @returns {number}
428
+ */
429
+ getAngleToYAxis(b: Vector2): number;
430
+ getNeighborPositions(size?: number, includeCenter?: boolean): Vector2[];
431
+ getClosest(positions: Vector2[]): Vector2 | null;
432
+ toString(decimals?: number): string;
433
+ }
434
+
435
+ export { type AccessTokenPayload, ArrayUtil, AsyncUtil, ByteUtil, CacheAsync, type CacheStats, CancellablePromise, DateUtil, type EntityBase, EntityCachedClient, EntityClient, EntityClientWithStub, type EntityWithName, EventManager, type Func, type FuncHandlers, type FuncHandlersCache, HashCacheAsync, type HashCacheStats, type IdTokenPayload, type JavaHeapStats, JsonUtil, type JwKeyPayload, type JwksPayload, Lazy, LazyAsync, LookupClient, type LookupTableEntity, NumberUtil, OAuthRestClient, OAuthSubject, OAuthTokenManager, ObjectUtil, type Page, type PagingRequest, PagingUtil, type QueueStats, type RequestAccessTokenPayload, type RequestIdTokenFromLoginPayload, type RequestIdTokenFromPrevTokenPayload, type RequestOptions, RestClient, RestClientWithOAuth, type ServerOAuthInfoPayload, type SortingField, type SortingRequest, StringUtil, type TokenRequestPayloadBase, type TokenResponsePayloadBase, type UserAlert, UserAlertType, UserAlerts, Vector2 };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- var t=function(){function t(t,e){this.supplier=t,this.maxAgeMs=e}return t.prototype.get=function(){var t=this;return void 0===this.cache||this.expires&&this.expires>new Date?this.supplier().then((function(e){return t.set(e),e})):Promise.resolve(this.cache)},t.prototype.set=function(t,e){this.cache=t,this.expires=e,this.maxAgeMs&&void 0===this.expires&&(this.expires=new Date((new Date).getTime()+this.maxAgeMs))},t.prototype.hasCache=function(){return void 0!==this.cache},t.prototype.getCache=function(){return this.cache},t}(),e=function(){function e(t,e){this.cache=new Map,this.maxSize=100,this.supplier=t,e&&(this.maxSize=e)}return e.prototype.obtainCache=function(e){var n=this,r=this.cache.get(e);return r||(r=new t((function(){return n.supplier(e)})),this.cache.set(e,r)),r},e.prototype.get=function(t){return this.obtainCache(t).get()},e.prototype.set=function(t,e,n){this.obtainCache(t).set(e,n)},e.prototype.reset=function(t){t?this.cache.delete(t):this.cache.clear()},e.prototype.getSize=function(){return this.cache.size},e.prototype.getMaxSize=function(){return this.maxSize},e.prototype.getStats=function(){return{cachedItems:this.getSize(),capacity:this.getMaxSize()}},e.prototype.hasCache=function(t){return this.cache.has(t)},e}(),n=function(){function t(t){this.supplier=t}return t.prototype.get=function(){return void 0===this.cache&&(this.cache=this.supplier()),this.cache},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t}(),r=function(){function t(t){this.supplier=t}return t.prototype.get=function(){var t=this;return void 0!==this.cache?Promise.resolve(this.cache):(void 0===this.promise&&(this.promise=this.supplier().then((function(e){return t.cache=e,t.promise=void 0,e})).catch((function(e){throw t.promise=void 0,e}))),this.promise)},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t.prototype.getCache=function(){return this.cache},t}(),o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},s.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var u,c=function(){function t(){}return t.isEmpty=function(t){return null==t},t.notEmpty=function(e){return!t.isEmpty(e)},t.clone=function(t){if(null===t)throw new Error("Null cannot be cloned!");if("object"!=typeof t)throw new Error("Not an object, cannot be cloned!");return s({},t)},t}(),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.isEmpty=function(t){return c.isEmpty(t)||0===(null==t?void 0:t.length)},e.notEmpty=function(t){return!e.isEmpty(t)},e.isBlank=function(t){return e.isEmpty(e.safeTrim(t))},e.notBlank=function(t){return!e.isBlank(t)},e.substr=function(t,e,n){return this.isEmpty(t)?"":t.substring(e,n)},e.replace=function(t,e,n){return this.isEmpty(t)||this.isEmpty(e)?"":t.replace(e,String(n))},e.containsLineBreaks=function(t){return null!=t&&0!==t.trim().length&&t.includes("\n")},e.trimLeadingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\//g,"")},e.trimTrailingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/\/$/g,"")},e.trimSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\/|\/$/g,"")},e.safeTruncate=function(t,n,r){return void 0===r&&(r=""),e.isEmpty(t)||!t?"":t.length<=n?String(t):t.substring(0,n-r.length)+r},e.ellipsis=function(t,n,r){return void 0===r&&(r="..."),e.safeTruncate(t,n,r)},e.safeTrim=function(t){return e.isEmpty(t)||!t?"":t.trim()},e.safeLowercase=function(t){return e.isEmpty(t)||!t?"":t.toLowerCase()},e.safeUppercase=function(t){return e.isEmpty(t)||!t?"":t.toUpperCase()},e.toBigInt=function(t){return this.isEmpty(t)?null:BigInt(t)},e.getNonEmpty=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.find((function(t){return e.notEmpty(t)}))||""},e.getNonBlank=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.find((function(t){return e.notBlank(t)}))||""},e.emptyToNull=function(t){return e.isEmpty(t)?null:String(t)},e.blankToNull=function(t){return e.isBlank(t)?null:String(t)},e}(c),h=function(){function t(){}return t.isEmpty=function(t){return c.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.remove=function(e,n){return t.isEmpty(e)?[]:null==e?void 0:e.filter((function(t){return t!==n}))},t}(),p=function(){function t(){}return t.sleep=function(t){return new Promise((function(e){return setTimeout(e,t)}))},t}(),f=function(){function t(){}return t.formatByteSize=function(t){var e=Number(t);if(null===e||Number.isNaN(e))return"";if(0===e)return"0";var n=Math.floor(Math.log(e)/Math.log(1024));return 1*+(e/Math.pow(1024,n)).toFixed(2)+" "+["B","kB","MB","GB","TB"][n]},t}(),l={page:0,size:10},g=function(){function t(){}return t.sortingFieldToString=function(t){if(!t)return"";var e=[];return e.push(t.name),e.push(t.desc?"desc":""),e.push(t.nullsLast?"nl":""),e.join("-")},t.sortingFieldFromString=function(t){var e=t.split("-");return{name:e[0],desc:e.length>1&&"desc"===a.safeLowercase(e[1]),nullsLast:e.length>2&&"nl"===a.safeLowercase(e[2])}},t.sortingRequestToString=function(e){return e.map((function(e){return t.sortingFieldToString(e)})).join("+")},t.sortingRequestFromString=function(e){return e?e.split("+").map((function(e){return t.sortingFieldFromString(e)})):[]},t.pagingRequestToQueryParams=function(e){if(e){var n={page:e.page,size:e.size};return e.search&&(n.search=e.search),e.sorting&&(n.sorting=t.sortingRequestToString(e.sorting)),n}},t.pagingRequestToString=function(e){if(!e)return"";var n=[];return n.push(String(e.page)),n.push(String(e.size)),n.push(a.safeTrim(e.search)),n.push(e.sorting?t.sortingRequestToString(e.sorting):""),n.join(":")},t.pagingRequestFromString=function(e){if(!e||a.isEmpty(e))return s({},l);var n=e.split(":");return n.length<4?s({},l):{page:Number(n[0]),size:Number(n[1]),search:String(n[2]),sorting:a.isEmpty(n[3])?void 0:t.sortingRequestFromString(n[3])}},t}(),d=function(){function t(){}return t.formatNumber=function(t,e){return void 0===e&&(e=2),String(t).padStart(e,"0")},t.parseDate=function(t){if(t)return"string"==typeof t?new Date(t):t},t.formatDateForHumans=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate()),s="".concat(r,"-").concat(o,"-").concat(i);if(!n)return s;var u=t.formatNumber(e.getHours()),c=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(s," ").concat(u,":").concat(c,":").concat(a)},t.formatDateTimeForHumans=function(e){return t.formatDateForHumans(e,!0)},t.formatDateForInput=function(e){var n=t.parseDate(e);if(void 0===n)return"";var r=n.getFullYear(),o=t.formatNumber(n.getMonth()+1),i=t.formatNumber(n.getDate());return"".concat(r,"-").concat(o,"-").concat(i)},t.getDurationMs=function(e,n){if(e=t.parseDate(e),n=t.parseDate(n),c.isEmpty(e)||c.isEmpty(n))return null;try{return n.getTime()-e.getTime()}catch(t){return null}},t.getSinceDurationMs=function(e){return t.getDurationMs(e,new Date)},t.formatDuration=function(t){if(!t)return"";var e=Math.floor(t/1e3);t-=1e3*e;var n=Math.floor(e/60);e-=60*n;var r=Math.floor(n/60);n-=60*r;var o=Math.floor(r/24);r-=24*o;var i=[];return o>0&&i.push("".concat(o,"d")),r>0&&i.push("".concat(r,"h")),n>0&&i.push("".concat(n,"m")),e>0&&0===o&&0===r&&i.push("".concat(e,"s")),t>0&&0===o&&0===r&&0===n&&i.push("".concat(t,"ms")),i.join(" ")},t}(),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.parseNumber=function(t){if(!t)return null;var e=Number(t);return Number.isNaN(e)?null:e},e.round=function(t,e){e||(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},e.portionToPercent=function(t,n){if(null==t)return"";var r=e.round(100*t,n);return"".concat(r,"%")},e}(c),v=function(){function t(){}return t.dateParser=function(e,n){return"string"==typeof n&&t.reISO.exec(n)?new Date(n):n},t.parseWithDates=function(e){if(!a.isBlank(e))return JSON.parse(a.getNonEmpty(e),t.dateParser)},t.parse=function(e){return t.parseWithDates(e)},t.reISO=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/,t}(),m=function(){function t(t){this.baseUrl=t}return t.pagingRequestToQueryParams=function(t){return g.pagingRequestToQueryParams(t)},t.paramsToQueryString=function(t){if(!t)return"";var e=new URLSearchParams(t),n=new URLSearchParams;e.forEach((function(t,e){""!==t&&void 0!==t&&"undefined"!==t&&n.set(e,t)}));var r=n.toString();return a.isEmpty(r)?"":"?".concat(r)},t.prototype.getHeaders=function(t){var e=new Headers;return e.set("Content-Type","application/json"),Promise.resolve(e)},t.prototype.getUrl=function(t,e){var n=[a.trimTrailingSlashes(this.baseUrl),a.trimLeadingSlashes(t)].join("/"),r=new URL(n);return e&&Object.keys(e).forEach((function(t){var n=e[t];""!==n&&void 0!==n&&"undefined"!==n&&r.searchParams.set(t,n)})),r},t.prototype.getRequestOptions=function(t,e,n){return void 0===e&&(e="GET"),void 0===n&&(n=null),this.getHeaders(t).then((function(t){return{method:e,headers:t,body:null===n?null:n instanceof FormData?n:JSON.stringify(n)}}))},t.prototype.processRequest=function(t,e,n){return fetch(this.getUrl(t,e),n).then((function(t){if(!t.ok){var e={cause:t.status};return"application/json"===t.headers.get("Content-Type")?t.json().then((function(n){if(n.message)throw new Error(n.message,e);if(n.error)throw new Error(n.error,e);throw new Error(t.statusText,e)}),(function(){throw new Error(t.statusText,e)})):t.text().then((function(n){throw a.isEmpty(n)?new Error(t.statusText,e):new Error(n,e)}),(function(){throw new Error(t.statusText,e)}))}return t}))},t.prototype.processRequestJson=function(t,e,n){return this.processRequest(t,e,n).then((function(t){return t.text().then(v.parseWithDates)}))},t.prototype.getJson=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequestJson(t,e,r)}))},t.prototype.postJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return n.processRequestJson(t,null,e)}))},t.prototype.postForm=function(t,e){var n=this;return this.getRequestOptions(t,"POST",e).then((function(e){return e.headers.set("Content-Type","multipart/form-data"),n.processRequest(t,null,e)}))},t.prototype.putJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return n.processRequestJson(t,null,e)}))},t.prototype.get=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequest(t,e,r)}))},t.prototype.del=function(t){var e=this;return this.getRequestOptions(t,"DELETE").then((function(n){return e.processRequest(t,null,n)}))},t.prototype.post=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return n.processRequest(t,null,e)}))},t.prototype.put=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return n.processRequest(t,null,e)}))},t}(),T=function(){function t(t,e){this.client=t,this.name=e}return t.prototype.loadSingle=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},t.prototype.loadPage=function(t){return this.client.getJson(this.name,m.pagingRequestToQueryParams(t))},t.prototype.save=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},t.prototype.delete=function(t){return this.client.del("".concat(this.name,"/").concat(t))},t}(),k=function(t){function n(n,r,o){var i=t.call(this,n,r)||this;return i.cache=new e((function(e){return t.prototype.loadSingle.call(i,e)}),o),i}return i(n,t),n.prototype.loadSingle=function(t){return this.cache.get(t)},n.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return t.id&&n.cache.set(t.id,t),t}))},n.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset(e)}))},n.prototype.reset=function(t){this.cache.reset(t)},n.prototype.getStats=function(){return this.cache.getStats()},n}(T),S=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.loadSingle=function(t){throw new Error("Use loadSingleStub() instead!")},e.prototype.loadSingleStub=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},e.prototype.save=function(t){throw new Error("Use saveStub() instead!")},e.prototype.saveStub=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},e}(T),w=function(t){function e(e,n){var o=t.call(this,e,n)||this;return o.cache=new r((function(){return o.loadAllInternal()})),o}return i(e,t),e.prototype.loadAllInternal=function(){return this.client.getJson("".concat(this.name,"/all"))},e.prototype.loadAll=function(){return this.cache.get()},e.prototype.loadSingle=function(t){var e=this;return this.loadAll().then((function(n){var r=n.find((function(e){return e.id===t}));if(void 0===t)throw new Error("".concat(e.name," id ").concat(t," not found!"));return r}))},e.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return n.cache.reset(),t}))},e.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset()}))},e.prototype.reset=function(){this.cache.reset()},e.prototype.getStats=function(){var t,e=null===(t=this.cache.getCache())||void 0===t?void 0:t.length;return{cachedItems:e||0,capacity:e||0}},e}(T),E=function(){function t(){this.handlers=new Map}return t.prototype.addEventListener=function(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)},t.prototype.removeEventListener=function(t,e){var n=this.handlers.get(t);n&&n.splice(n.indexOf(e),1)},t.prototype.triggerEvent=function(t,e){this.handlers.has(t)&&this.handlers.get(t).forEach((function(t){return t(e)}))},t}();!function(t){t.info="info",t.warning="warning",t.error="danger"}(u||(u={}));var I=function(){function t(t){void 0===t&&(t=10),this.maxAlerts=t,this.em=new E,this.alerts=[]}return t.prototype.addOnChangeHandler=function(t){this.em.addEventListener("change",t)},t.prototype.removeOnChangeHandler=function(t){this.em.removeEventListener("change",t)},t.prototype.triggerChange=function(){this.em.triggerEvent("change")},t.prototype.reset=function(){this.alerts=[],this.triggerChange()},t.prototype.remove=function(t){this.alerts.splice(this.alerts.indexOf(t),1),this.triggerChange()},t.prototype.add=function(t){for(this.alerts.push(t);this.alerts.length>this.maxAlerts;)this.alerts.shift();this.triggerChange()},t.prototype.custom=function(t,e){this.add({time:new Date,type:t,message:e})},t.prototype.err=function(t){this.custom(u.error,"string"==typeof t?t:t.toString())},t.prototype.warn=function(t){this.custom(u.warning,t)},t.prototype.info=function(t){this.custom(u.info,t)},t.prototype.getSummary=function(){var t=new Map;Object.values(u).forEach((function(e,n){t.set(e,0)}));for(var e=0;e<this.alerts.length;e++){var n=this.alerts[e],r=t.get(n.type)||0;t.set(n.type,r+1)}return t},t}(),x=function(){function t(t,e){void 0===e&&(e=!1);var n=this;this.isCancelled={value:!1},this.throwWhenCancelled=e,this.promise=new Promise((function(e,r){t.then((function(t){if(!n.isCancelled.value)return e(t)})).catch((function(t){!n.throwWhenCancelled&&n.isCancelled.value||r(t)}))}))}return t.prototype.cancel=function(){this.isCancelled.value=!0},t}(),M=function(t){function e(e){return t.call(this,"".concat(a.trimSlashes(e),"/api/oauth"))||this}return i(e,t),e.prototype.jwks=function(){return this.getJson("jwks.json")},e.prototype.verifyIdToken=function(t){return this.getJson("id-tokens/verify/".concat(t))},e.prototype.requestIdTokenFromLogin=function(t){return this.postJson("id-tokens/from-login",t)},e.prototype.refreshIdToken=function(t){return this.postJson("id-tokens/refresh",t)},e.prototype.requestAccessToken=function(t){return this.postJson("access-tokens/from-id-token",t)},e}(m),b=function(){function t(t,e){this.eventManager=new E,this.audience=e,this.oAuthServer=new M(t),this.accessTokens=new Map}return t.prototype.addIdTokenChangedHandler=function(t){this.eventManager.addEventListener("id-token-changed",t)},t.prototype.isTokenExpired=function(t){return null!=t&&t<new Date},t.prototype.isTokenReadyForRefresh=function(t,e){return null!=e&&new Date((e.getTime()+t.getTime())/2)<new Date},t.prototype.isValidIdToken=function(t){return void 0!==t&&a.notEmpty(t.token)&&!this.isTokenExpired(t.expires)},t.prototype.hasValidIdToken=function(){return this.isValidIdToken(this.idToken)},t.prototype.isValidAccessToken=function(t){return void 0!==t&&a.notEmpty(t.token)&&!this.isTokenExpired(t.expires)},t.prototype.hasValidAccessToken=function(t){return this.isValidAccessToken(this.accessTokens.get(t))},t.prototype.reset=function(){this.idToken=void 0,this.eventManager.triggerEvent("id-token-changed",void 0),this.accessTokens.clear()},t.prototype.getIdToken=function(){var t=this;return void 0!==this.idToken&&this.hasValidIdToken()?this.isTokenReadyForRefresh(this.idToken.issuedAt,this.idToken.expires)?this.oAuthServer.refreshIdToken({idToken:this.idToken.token}).then((function(e){return t.setIdToken(e),e.token})):Promise.resolve(this.idToken.token):Promise.reject("No valid ID token!")},t.prototype.setIdToken=function(t){if(!this.isValidIdToken(t))throw new Error("Received ID token is not valid!");this.idToken=t,this.eventManager.triggerEvent("id-token-changed",t)},t.prototype.verifyIdToken=function(t){var e=this;return this.oAuthServer.verifyIdToken(t).then((function(t){return e.setIdToken(t)})).then((function(){return!0}))},t.prototype.login=function(t,e){var n=this;return this.reset(),this.oAuthServer.requestIdTokenFromLogin({login:t,password:e,targetAudience:this.audience}).then((function(t){return n.setIdToken(t),!0}))},t.prototype.getAccessTokenInternal=function(t){var e=this;return this.getIdToken().then((function(n){return e.oAuthServer.requestAccessToken({idToken:n,targetAudience:e.audience,privilege:t}).then((function(n){return e.isValidAccessToken(n)?(e.accessTokens.set(t,n),n):Promise.reject("Received access token is not valid!")}))}))},t.prototype.getAccessToken=function(t){var e=this.accessTokens.get(t);return void 0!==e&&this.isValidAccessToken(e)?(this.isTokenReadyForRefresh(e.issuedAt,e.expires)&&this.getAccessTokenInternal(t),Promise.resolve(e.token)):this.getAccessTokenInternal(t).then((function(t){return t.token}))},t}(),R=function(){function t(t){this.value=t}return t.prototype.getSubjectType=function(){return a.isEmpty(this.value)?null:this.value.split(":")[0]},t.prototype.getSubjectContent=function(){if(a.isEmpty(this.value))return null;var t=this.value.split("//");return t.length>1?t[1]:null},t.prototype.toString=function(){return this.value},t}(),A=function(t){function e(e,n){void 0===n&&(n="*");var o=t.call(this,e)||this;return o.defaultPrivilege=n,o.insecureClient=new m(e),o.serverInfo=new r((function(){return o.getServerInfoInternal()})),o.tokenManager=new r((function(){return o.getTokenManagerInternal()})),o}return i(e,t),e.prototype.initializeIdToken=function(){var t=this.getIdTokenFromUrl();if(null!==t)return this.setIdTokenRaw(t);var e=this.getIdTokenFromLocalStorage();return e?this.setIdToken(e):Promise.resolve(!1)},e.prototype.initialize=function(){var t=this;return this.initializeIdToken().then((function(e){return e?t.checkAccessToken():Promise.reject("ID token initialization failed!")})).then((function(t){return!!t||Promise.reject("Access token initialization failed!")})).catch((function(e){return console.log("OAuth initialization failed:",e),t.getServerInfo().then((function(t){var e="".concat(t.oauthServerUrl,"/login?app_name=").concat(t.targetAudience,"&redirect_url=").concat(document.location);return console.log("Redirecting:",e),document.location=e,Promise.resolve(!1)}))}))},e.prototype.logout=function(){var t=this;return this.getTokenManager().then((function(t){return t.reset()})).then((function(){return t.initialize()}))},e.prototype.getPrivilege=function(t){return this.defaultPrivilege},e.prototype.getIdTokenFromUrl=function(){return new URLSearchParams(document.location.search).get("token")},e.prototype.getIdTokenFromLocalStorage=function(){return v.parse(localStorage.getItem("id-token"))},e.prototype.saveIdTokenToLocalStorage=function(t){var e=t?JSON.stringify(t):null;null!==e?localStorage.setItem("id-token",e):localStorage.removeItem("id-token")},e.prototype.addIdTokenChangedHandler=function(t){this.getTokenManager().then((function(e){return e.addIdTokenChangedHandler(t)}))},e.prototype.getServerInfoInternal=function(){return this.insecureClient.getJson("status/oauth/info")},e.prototype.getServerInfo=function(){return this.serverInfo.get()},e.prototype.getTokenManagerInternal=function(){var t=this;return this.getServerInfo().then((function(e){var n=new b(e.oauthServerUrl,e.targetAudience);return n.addIdTokenChangedHandler((function(e){return t.saveIdTokenToLocalStorage(e)})),n}))},e.prototype.getTokenManager=function(){return this.tokenManager.get()},e.prototype.login=function(t,e){return this.getTokenManager().then((function(n){return n.login(t,e)}))},e.prototype.setIdToken=function(t){return this.getTokenManager().then((function(e){return e.setIdToken(t)})).then((function(){return!0}))},e.prototype.setIdTokenRaw=function(t){return this.getTokenManager().then((function(e){return e.verifyIdToken(t)}))},e.prototype.getHeaders=function(t){var e=this;return this.getTokenManager().then((function(n){return n.getAccessToken(e.getPrivilege(t))})).then((function(t){return{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)}}))},e.prototype.checkAccessToken=function(t){var e=this;return this.getTokenManager().then((function(n){return n.getAccessToken(a.getNonEmpty(t,e.defaultPrivilege))})).then((function(t){return!0})).catch((function(t){return console.error("Access token check failed:",t),!1}))},e}(m),P=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},t.prototype.equalsTo=function(t){return!!t&&(this.x===t.x&&this.y===t.y)},t.prototype.size=function(){return this.distanceTo(new t(0,0))},t.prototype.inSize=function(e){var n=this.size();if(0!==n){var r=e/n;return new t(this.x*r,this.y*r)}return this},t.prototype.round=function(){return new t(Math.round(this.x),Math.round(this.y))},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.multiply=function(e){return new t(this.x*e,this.y*e)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toArray=function(){return[this.x,this.y]},t.fromArray=function(e){if("object"==typeof e&&2===e.length)return new t(e[0],e[1])},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.getAngleToYAxis=function(t){var e=t.subtract(this),n=e.y<0,r=e.x/e.size(),o=Math.asin(r);return(n?Math.PI-o:o)||0},t.prototype.getNeighborPositions=function(e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=[],o=this.x+e,i=this.x-e;i<=o;i++)for(var s=this.y+e,u=this.y-e;u<=s;u++){var c=new t(i,u);!n&&this.equalsTo(c)||r.push(c)}return r},t.prototype.getClosest=function(t){if(!t||0===t.length)return null;if(1===t.length)return t[0];for(var e=t[0],n=this.distanceTo(e),r=1,o=t.length;r<o;r++){var i=this.distanceTo(t[r]);i<n&&(e=t[r],n=i)}return e},t.prototype.toString=function(t){return void 0===t&&(t=2),"[".concat(y.round(this.x,t),",").concat(y.round(this.y,t),"]")},t}();export{h as ArrayUtil,p as AsyncUtil,f as ByteUtil,t as CacheAsync,x as CancellablePromise,d as DateUtil,k as EntityCachedClient,T as EntityClient,S as EntityClientWithStub,E as EventManager,e as HashCacheAsync,v as JsonUtil,n as Lazy,r as LazyAsync,w as LookupClient,y as NumberUtil,M as OAuthRestClient,R as OAuthSubject,b as OAuthTokenManager,c as ObjectUtil,g as PagingUtil,m as RestClient,A as RestClientWithOAuth,a as StringUtil,u as UserAlertType,I as UserAlerts,P as Vector2};
1
+ var t=function(){function t(t,e){this.supplier=t,this.maxAgeMs=e}return t.prototype.get=function(){var t=this;return void 0===this.cache||this.expires&&this.expires>new Date?this.supplier().then((function(e){return t.set(e),e})):Promise.resolve(this.cache)},t.prototype.set=function(t,e){this.cache=t,this.expires=e,this.maxAgeMs&&void 0===this.expires&&(this.expires=new Date((new Date).getTime()+this.maxAgeMs))},t.prototype.hasCache=function(){return void 0!==this.cache},t.prototype.getCache=function(){return this.cache},t}(),e=function(){function e(t,e){this.cache=new Map,this.maxSize=100,this.supplier=t,e&&(this.maxSize=e)}return e.prototype.obtainCache=function(e){var n=this,r=this.cache.get(e);return r||(r=new t((function(){return n.supplier(e)})),this.cache.set(e,r)),r},e.prototype.get=function(t){return this.obtainCache(t).get()},e.prototype.set=function(t,e,n){this.obtainCache(t).set(e,n)},e.prototype.reset=function(t){t?this.cache.delete(t):this.cache.clear()},e.prototype.getSize=function(){return this.cache.size},e.prototype.getMaxSize=function(){return this.maxSize},e.prototype.getStats=function(){return{cachedItems:this.getSize(),capacity:this.getMaxSize()}},e.prototype.hasCache=function(t){return this.cache.has(t)},e}(),n=function(){function t(t){this.supplier=t}return t.prototype.get=function(){return void 0===this.cache&&(this.cache=this.supplier()),this.cache},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t}(),r=function(){function t(t){this.supplier=t}return t.prototype.get=function(){var t=this;return void 0!==this.cache?Promise.resolve(this.cache):(void 0===this.promise&&(this.promise=this.supplier().then((function(e){return t.cache=e,t.promise=void 0,e})).catch((function(e){throw t.promise=void 0,e}))),this.promise)},t.prototype.reset=function(){this.cache=void 0},t.prototype.hasCache=function(){return void 0!==this.cache},t.prototype.getCache=function(){return this.cache},t}(),o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},s.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var u,c=function(){function t(){}return t.isEmpty=function(t){return null==t},t.notEmpty=function(e){return!t.isEmpty(e)},t.clone=function(t){if(null===t)throw new Error("Null cannot be cloned!");if("object"!=typeof t)throw new Error("Not an object, cannot be cloned!");return s({},t)},t}(),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.isEmpty=function(t){return c.isEmpty(t)||0===(null==t?void 0:t.length)},e.notEmpty=function(t){return!e.isEmpty(t)},e.isBlank=function(t){return e.isEmpty(e.safeTrim(t))},e.notBlank=function(t){return!e.isBlank(t)},e.substr=function(t,e,n){return this.isEmpty(t)?"":t.substring(e,n)},e.replace=function(t,e,n){return this.isEmpty(t)||this.isEmpty(e)?"":t.replace(e,String(n))},e.containsLineBreaks=function(t){return null!=t&&0!==t.trim().length&&t.includes("\n")},e.trimLeadingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\//g,"")},e.trimTrailingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/\/$/g,"")},e.trimSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\/|\/$/g,"")},e.safeTruncate=function(t,n,r){return void 0===r&&(r=""),e.isEmpty(t)||!t?"":t.length<=n?String(t):t.substring(0,n-r.length)+r},e.ellipsis=function(t,n,r){return void 0===r&&(r="..."),e.safeTruncate(t,n,r)},e.safeTrim=function(t){return e.isEmpty(t)||!t?"":t.trim()},e.safeLowercase=function(t){return e.isEmpty(t)||!t?"":t.toLowerCase()},e.safeUppercase=function(t){return e.isEmpty(t)||!t?"":t.toUpperCase()},e.toBigInt=function(t){return this.isEmpty(t)?null:BigInt(t)},e.getNonEmpty=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.find((function(t){return e.notEmpty(t)}))||""},e.getNonBlank=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t.find((function(t){return e.notBlank(t)}))||""},e.emptyToNull=function(t){return e.isEmpty(t)?null:String(t)},e.blankToNull=function(t){return e.isBlank(t)?null:String(t)},e}(c),h=function(){function t(){}return t.isEmpty=function(t){return c.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.remove=function(e,n){return t.isEmpty(e)?[]:null==e?void 0:e.filter((function(t){return t!==n}))},t}(),p=function(){function t(){}return t.sleep=function(t){return new Promise((function(e){return setTimeout(e,t)}))},t}(),f=function(){function t(){}return t.formatByteSize=function(t){var e=Number(t);if(null===e||Number.isNaN(e))return"";if(0===e)return"0";var n=Math.floor(Math.log(e)/Math.log(1024));return 1*+(e/Math.pow(1024,n)).toFixed(2)+" "+["B","kB","MB","GB","TB"][n]},t}(),l={page:0,size:10},g=function(){function t(){}return t.sortingFieldToString=function(t){if(!t)return"";var e=[];return e.push(t.name),e.push(t.desc?"desc":""),e.push(t.nullsLast?"nl":""),e.join("-")},t.sortingFieldFromString=function(t){var e=t.split("-");return{name:e[0],desc:e.length>1&&"desc"===a.safeLowercase(e[1]),nullsLast:e.length>2&&"nl"===a.safeLowercase(e[2])}},t.sortingRequestToString=function(e){return e.map((function(e){return t.sortingFieldToString(e)})).join("+")},t.sortingRequestFromString=function(e){return e?e.split("+").map((function(e){return t.sortingFieldFromString(e)})):[]},t.pagingRequestToQueryParams=function(e){if(e){var n={page:e.page,size:e.size};return e.search&&(n.search=e.search),e.sorting&&(n.sorting=t.sortingRequestToString(e.sorting)),n}},t.pagingRequestToString=function(e){if(!e)return"";var n=[];return n.push(String(e.page)),n.push(String(e.size)),n.push(a.safeTrim(e.search)),n.push(e.sorting?t.sortingRequestToString(e.sorting):""),n.join(":")},t.pagingRequestFromString=function(e){if(!e||a.isEmpty(e))return s({},l);var n=e.split(":");return n.length<4?s({},l):{page:Number(n[0]),size:Number(n[1]),search:String(n[2]),sorting:a.isEmpty(n[3])?void 0:t.sortingRequestFromString(n[3])}},t}(),d=function(){function t(){}return t.formatNumber=function(t,e){return void 0===e&&(e=2),String(t).padStart(e,"0")},t.parseDate=function(t){if(t)return"string"==typeof t?new Date(t):t},t.formatDateForHumans=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate()),s="".concat(r,"-").concat(o,"-").concat(i);if(!n)return s;var u=t.formatNumber(e.getHours()),c=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(s," ").concat(u,":").concat(c,":").concat(a)},t.formatDateTimeForHumans=function(e){return t.formatDateForHumans(e,!0)},t.formatDateForInput=function(e){var n=t.parseDate(e);if(void 0===n)return"";var r=n.getFullYear(),o=t.formatNumber(n.getMonth()+1),i=t.formatNumber(n.getDate());return"".concat(r,"-").concat(o,"-").concat(i)},t.getDurationMs=function(e,n){if(e=t.parseDate(e),n=t.parseDate(n),c.isEmpty(e)||c.isEmpty(n))return null;try{return n.getTime()-e.getTime()}catch(t){return null}},t.getSinceDurationMs=function(e){return t.getDurationMs(e,new Date)},t.formatDuration=function(t){if(!t)return"";var e=Math.floor(t/1e3);t-=1e3*e;var n=Math.floor(e/60);e-=60*n;var r=Math.floor(n/60);n-=60*r;var o=Math.floor(r/24);r-=24*o;var i=[];return o>0&&i.push("".concat(o,"d")),r>0&&i.push("".concat(r,"h")),n>0&&i.push("".concat(n,"m")),e>0&&0===o&&0===r&&i.push("".concat(e,"s")),t>0&&0===o&&0===r&&0===n&&i.push("".concat(t,"ms")),i.join(" ")},t}(),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.parseNumber=function(t){if(!t)return null;var e=Number(t);return Number.isNaN(e)?null:e},e.round=function(t,e){e||(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},e.portionToPercent=function(t,n){if(null==t)return"";var r=e.round(100*t,n);return"".concat(r,"%")},e}(c),v=function(){function t(){}return t.dateParser=function(e,n){return"string"==typeof n&&t.reISO.exec(n)?new Date(n):n},t.parseWithDates=function(e){if(!a.isBlank(e))return JSON.parse(a.getNonEmpty(e),t.dateParser)},t.parse=function(e){return t.parseWithDates(e)},t.reISO=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/,t}(),m=function(){function t(t){this.baseUrl=t}return t.pagingRequestToQueryParams=function(t){return g.pagingRequestToQueryParams(t)},t.paramsToQueryString=function(t){if(!t)return"";var e=new URLSearchParams(t),n=new URLSearchParams;e.forEach((function(t,e){""!==t&&void 0!==t&&"undefined"!==t&&n.set(e,t)}));var r=n.toString();return a.isEmpty(r)?"":"?".concat(r)},t.prototype.getHeaders=function(t){var e=new Headers;return e.set("Content-Type","application/json"),Promise.resolve(e)},t.prototype.getUrl=function(t,e){var n=[a.trimTrailingSlashes(this.baseUrl),a.trimLeadingSlashes(t)].join("/"),r=new URL(n);return e&&Object.keys(e).forEach((function(t){var n=e[t];""!==n&&void 0!==n&&"undefined"!==n&&r.searchParams.set(t,n)})),r},t.prototype.getRequestOptions=function(t,e,n){return void 0===e&&(e="GET"),void 0===n&&(n=null),this.getHeaders(t).then((function(t){return{method:e,headers:t,body:null===n?null:n instanceof FormData?n:JSON.stringify(n)}}))},t.prototype.processRequest=function(t,e,n){return fetch(this.getUrl(t,e),n).then((function(t){if(!t.ok){var e={cause:t.status};return"application/json"===t.headers.get("Content-Type")?t.json().then((function(n){if(n.message)throw new Error(n.message,e);if(n.error)throw new Error(n.error,e);throw new Error(t.statusText,e)}),(function(){throw new Error(t.statusText,e)})):t.text().then((function(n){throw a.isEmpty(n)?new Error(t.statusText,e):new Error(n,e)}),(function(){throw new Error(t.statusText,e)}))}return t}))},t.prototype.processRequestJson=function(t,e,n){return this.processRequest(t,e,n).then((function(t){return t.text().then(v.parseWithDates)}))},t.prototype.getJson=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequestJson(t,e,r)}))},t.prototype.postJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return n.processRequestJson(t,null,e)}))},t.prototype.postForm=function(t,e){var n=this;return this.getRequestOptions(t,"POST",e).then((function(e){return e.headers.set("Content-Type","multipart/form-data"),n.processRequest(t,null,e)}))},t.prototype.putJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return n.processRequestJson(t,null,e)}))},t.prototype.get=function(t,e){var n=this;return this.getRequestOptions(t).then((function(r){return n.processRequest(t,e,r)}))},t.prototype.del=function(t){var e=this;return this.getRequestOptions(t,"DELETE").then((function(n){return e.processRequest(t,null,n)}))},t.prototype.post=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"POST",e).then((function(e){return n.processRequest(t,null,e)}))},t.prototype.put=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions(t,"PUT",e).then((function(e){return n.processRequest(t,null,e)}))},t}(),T=function(){function t(t,e){this.client=t,this.name=e}return t.prototype.loadSingle=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},t.prototype.loadPage=function(t){return this.client.getJson(this.name,m.pagingRequestToQueryParams(t))},t.prototype.save=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},t.prototype.delete=function(t){return this.client.del("".concat(this.name,"/").concat(t))},t}(),k=function(t){function n(n,r,o){var i=t.call(this,n,r)||this;return i.cache=new e((function(e){return t.prototype.loadSingle.call(i,e)}),o),i}return i(n,t),n.prototype.loadSingle=function(t){return this.cache.get(t)},n.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return t.id&&n.cache.set(t.id,t),t}))},n.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset(e)}))},n.prototype.reset=function(t){this.cache.reset(t)},n.prototype.getStats=function(){return this.cache.getStats()},n}(T),S=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.loadSingle=function(t){throw new Error("Use loadSingleStub() instead!")},e.prototype.loadSingleStub=function(t){return this.client.getJson("".concat(this.name,"/").concat(t))},e.prototype.save=function(t){throw new Error("Use saveStub() instead!")},e.prototype.saveStub=function(t){return t.id?this.client.putJson("".concat(this.name,"/").concat(t.id),t):this.client.postJson(this.name,t)},e}(T),w=function(t){function e(e,n){var o=t.call(this,e,n)||this;return o.cache=new r((function(){return o.loadAllInternal()})),o}return i(e,t),e.prototype.loadAllInternal=function(){return this.client.getJson("".concat(this.name,"/all"))},e.prototype.loadAll=function(){return this.cache.get()},e.prototype.loadSingle=function(t){var e=this;return this.loadAll().then((function(n){var r=n.find((function(e){return e.id===t}));if(void 0===t)throw new Error("".concat(e.name," id ").concat(t," not found!"));return r}))},e.prototype.save=function(e){var n=this;return t.prototype.save.call(this,e).then((function(t){return n.cache.reset(),t}))},e.prototype.delete=function(e){var n=this;return t.prototype.delete.call(this,e).then((function(){return n.cache.reset()}))},e.prototype.reset=function(){this.cache.reset()},e.prototype.getStats=function(){var t,e=null===(t=this.cache.getCache())||void 0===t?void 0:t.length;return{cachedItems:e||0,capacity:e||0}},e}(T),E=function(){function t(){this.handlers=new Map}return t.prototype.addEventListener=function(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)},t.prototype.removeEventListener=function(t,e){var n=this.handlers.get(t);n&&n.splice(n.indexOf(e),1)},t.prototype.triggerEvent=function(t,e){this.handlers.has(t)&&this.handlers.get(t).forEach((function(t){return t(e)}))},t}();!function(t){t.info="info",t.warning="warning",t.error="danger"}(u||(u={}));var I=function(){function t(t){void 0===t&&(t=10),this.maxAlerts=t,this.em=new E,this.alerts=[]}return t.prototype.addOnChangeHandler=function(t){this.em.addEventListener("change",t)},t.prototype.removeOnChangeHandler=function(t){this.em.removeEventListener("change",t)},t.prototype.triggerChange=function(){this.em.triggerEvent("change")},t.prototype.reset=function(){this.alerts=[],this.triggerChange()},t.prototype.remove=function(t){this.alerts.splice(this.alerts.indexOf(t),1),this.triggerChange()},t.prototype.add=function(t){for(this.alerts.push(t);this.alerts.length>this.maxAlerts;)this.alerts.shift();this.triggerChange()},t.prototype.custom=function(t,e){this.add({time:new Date,type:t,message:e})},t.prototype.err=function(t){this.custom(u.error,"string"==typeof t?t:t.toString())},t.prototype.warn=function(t){this.custom(u.warning,t)},t.prototype.info=function(t){this.custom(u.info,t)},t.prototype.getSummary=function(){var t=new Map;Object.values(u).forEach((function(e,n){t.set(e,0)}));for(var e=0;e<this.alerts.length;e++){var n=this.alerts[e],r=t.get(n.type)||0;t.set(n.type,r+1)}return t},t}(),x=function(){function t(t,e){void 0===e&&(e=!1);var n=this;this.isCancelled={value:!1},this.throwWhenCancelled=e,this.promise=new Promise((function(e,r){t.then((function(t){if(!n.isCancelled.value)return e(t)})).catch((function(t){!n.throwWhenCancelled&&n.isCancelled.value||r(t)}))}))}return t.prototype.cancel=function(){this.isCancelled.value=!0},t}(),M=function(t){function e(e){return t.call(this,"".concat(a.trimSlashes(e),"/api/oauth"))||this}return i(e,t),e.prototype.jwks=function(){return this.getJson("jwks.json")},e.prototype.verifyIdToken=function(t){return this.getJson("id-tokens/verify/".concat(t))},e.prototype.requestIdTokenFromLogin=function(t){return this.postJson("id-tokens/from-login",t)},e.prototype.refreshIdToken=function(t){return this.postJson("id-tokens/refresh",t)},e.prototype.requestAccessToken=function(t){return this.postJson("access-tokens/from-id-token",t)},e}(m),b=function(){function t(t,e){this.eventManager=new E,this.audience=e,this.oAuthServer=new M(t),this.accessTokens=new Map}return t.prototype.addIdTokenChangedHandler=function(t){this.eventManager.addEventListener("id-token-changed",t)},t.prototype.isTokenExpired=function(t){return null!=t&&t<new Date},t.prototype.isTokenReadyForRefresh=function(t,e){return null!=e&&new Date((e.getTime()+t.getTime())/2)<new Date},t.prototype.isValidIdToken=function(t){return void 0!==t&&a.notEmpty(t.token)&&!this.isTokenExpired(t.expires)},t.prototype.hasValidIdToken=function(){return this.isValidIdToken(this.idToken)},t.prototype.isValidAccessToken=function(t){return void 0!==t&&a.notEmpty(t.token)&&!this.isTokenExpired(t.expires)},t.prototype.hasValidAccessToken=function(t){return this.isValidAccessToken(this.accessTokens.get(t))},t.prototype.reset=function(){this.idToken=void 0,this.eventManager.triggerEvent("id-token-changed",void 0),this.accessTokens.clear()},t.prototype.getIdToken=function(){var t=this;return void 0!==this.idToken&&this.hasValidIdToken()?this.isTokenReadyForRefresh(this.idToken.issuedAt,this.idToken.expires)?this.oAuthServer.refreshIdToken({idToken:this.idToken.token}).then((function(e){return t.setIdToken(e),e.token})):Promise.resolve(this.idToken.token):Promise.reject("No valid ID token!")},t.prototype.setIdToken=function(t){if(!this.isValidIdToken(t))throw new Error("Received ID token is not valid!");this.idToken=t,this.eventManager.triggerEvent("id-token-changed",t)},t.prototype.verifyIdToken=function(t){var e=this;return this.oAuthServer.verifyIdToken(t).then((function(t){return e.setIdToken(t)})).then((function(){return!0}))},t.prototype.login=function(t,e){var n=this;return this.reset(),this.oAuthServer.requestIdTokenFromLogin({login:t,password:e,targetAudience:this.audience}).then((function(t){return n.setIdToken(t),!0}))},t.prototype.getAccessTokenInternal=function(t){var e=this;return this.getIdToken().then((function(n){return e.oAuthServer.requestAccessToken({idToken:n,targetAudience:e.audience,privilege:t}).then((function(n){return e.isValidAccessToken(n)?(e.accessTokens.set(t,n),n):Promise.reject("Received access token is not valid!")}))}))},t.prototype.getAccessToken=function(t){var e=this.accessTokens.get(t);return void 0!==e&&this.isValidAccessToken(e)?(this.isTokenReadyForRefresh(e.issuedAt,e.expires)&&this.getAccessTokenInternal(t),Promise.resolve(e.token)):this.getAccessTokenInternal(t).then((function(t){return t.token}))},t}(),R=function(){function t(t){this.value=t}return t.prototype.getSubjectType=function(){return a.isEmpty(this.value)?null:this.value.split(":")[0]},t.prototype.getSubjectContent=function(){if(a.isEmpty(this.value))return null;var t=this.value.split("//");return t.length>1?t[1]:null},t.prototype.toString=function(){return this.value},t}(),A=function(t){function e(e,n){void 0===n&&(n="*");var o=t.call(this,e)||this;return o.defaultPrivilege=n,o.insecureClient=new m(e),o.serverInfo=new r((function(){return o.getServerInfoInternal()})),o.tokenManager=new r((function(){return o.getTokenManagerInternal()})),o}return i(e,t),e.prototype.initializeIdToken=function(){var t=this.getIdTokenFromUrl();if(null!==t)return this.setIdTokenRaw(t);var e=this.getIdTokenFromLocalStorage();return e?this.setIdToken(e):Promise.resolve(!1)},e.prototype.initialize=function(){var t=this;return this.initializeIdToken().then((function(e){return e?t.checkAccessToken():Promise.reject("ID token initialization failed!")})).then((function(t){return!!t||Promise.reject("Access token initialization failed!")})).catch((function(e){return console.log("OAuth initialization failed:",e),t.getServerInfo().then((function(t){var e="".concat(t.oauthServerUrl,"/login?app_name=").concat(t.targetAudience,"&redirect_url=").concat(document.location);return console.log("Redirecting:",e),document.location=e,Promise.resolve(!1)}))}))},e.prototype.logout=function(){var t=this;return this.getTokenManager().then((function(t){return t.reset()})).then((function(){return t.initialize()}))},e.prototype.getPrivilege=function(t){return this.defaultPrivilege},e.prototype.getIdTokenFromUrl=function(){return new URLSearchParams(document.location.search).get("token")},e.prototype.getIdTokenFromLocalStorage=function(){return v.parse(localStorage.getItem("id-token"))},e.prototype.saveIdTokenToLocalStorage=function(t){var e=t?JSON.stringify(t):null;null!==e?localStorage.setItem("id-token",e):localStorage.removeItem("id-token")},e.prototype.addIdTokenChangedHandler=function(t){this.getTokenManager().then((function(e){return e.addIdTokenChangedHandler(t)}))},e.prototype.getServerInfoInternal=function(){return this.insecureClient.getJson("status/oauth/info")},e.prototype.getServerInfo=function(){return this.serverInfo.get()},e.prototype.getTokenManagerInternal=function(){var t=this;return this.getServerInfo().then((function(e){var n=new b(e.oauthServerUrl,e.targetAudience);return n.addIdTokenChangedHandler((function(e){return t.saveIdTokenToLocalStorage(e)})),n}))},e.prototype.getTokenManager=function(){return this.tokenManager.get()},e.prototype.login=function(t,e){return this.getTokenManager().then((function(n){return n.login(t,e)}))},e.prototype.setIdToken=function(t){return this.getTokenManager().then((function(e){return e.setIdToken(t)})).then((function(){return!0}))},e.prototype.setIdTokenRaw=function(t){return this.getTokenManager().then((function(e){return e.verifyIdToken(t)}))},e.prototype.getHeaders=function(e){var n=this;return this.getTokenManager().then((function(t){return t.getAccessToken(n.getPrivilege(e))})).then((function(r){return t.prototype.getHeaders.call(n,e).then((function(t){return t.set("Authorization","Bearer ".concat(r)),t}))}))},e.prototype.checkAccessToken=function(t){var e=this;return this.getTokenManager().then((function(n){return n.getAccessToken(a.getNonEmpty(t,e.defaultPrivilege))})).then((function(t){return!0})).catch((function(t){return console.error("Access token check failed:",t),!1}))},e}(m),P=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},t.prototype.equalsTo=function(t){return!!t&&(this.x===t.x&&this.y===t.y)},t.prototype.size=function(){return this.distanceTo(new t(0,0))},t.prototype.inSize=function(e){var n=this.size();if(0!==n){var r=e/n;return new t(this.x*r,this.y*r)}return this},t.prototype.round=function(){return new t(Math.round(this.x),Math.round(this.y))},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.multiply=function(e){return new t(this.x*e,this.y*e)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toArray=function(){return[this.x,this.y]},t.fromArray=function(e){if("object"==typeof e&&2===e.length)return new t(e[0],e[1])},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.getAngleToYAxis=function(t){var e=t.subtract(this),n=e.y<0,r=e.x/e.size(),o=Math.asin(r);return(n?Math.PI-o:o)||0},t.prototype.getNeighborPositions=function(e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=[],o=this.x+e,i=this.x-e;i<=o;i++)for(var s=this.y+e,u=this.y-e;u<=s;u++){var c=new t(i,u);!n&&this.equalsTo(c)||r.push(c)}return r},t.prototype.getClosest=function(t){if(!t||0===t.length)return null;if(1===t.length)return t[0];for(var e=t[0],n=this.distanceTo(e),r=1,o=t.length;r<o;r++){var i=this.distanceTo(t[r]);i<n&&(e=t[r],n=i)}return e},t.prototype.toString=function(t){return void 0===t&&(t=2),"[".concat(y.round(this.x,t),",").concat(y.round(this.y,t),"]")},t}();export{h as ArrayUtil,p as AsyncUtil,f as ByteUtil,t as CacheAsync,x as CancellablePromise,d as DateUtil,k as EntityCachedClient,T as EntityClient,S as EntityClientWithStub,E as EventManager,e as HashCacheAsync,v as JsonUtil,n as Lazy,r as LazyAsync,w as LookupClient,y as NumberUtil,M as OAuthRestClient,R as OAuthSubject,b as OAuthTokenManager,c as ObjectUtil,g as PagingUtil,m as RestClient,A as RestClientWithOAuth,a as StringUtil,u as UserAlertType,I as UserAlerts,P as Vector2};
2
2
  //# sourceMappingURL=index.esm.js.map