@webskills/ng-utils 3.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +5 -0
  2. package/esm2022/lib/angular/instanceOf.utils.mjs +4 -0
  3. package/esm2022/lib/breakpoints/breakpoints.mjs +20 -0
  4. package/esm2022/lib/color/constrast-color.mjs +24 -0
  5. package/esm2022/lib/content/anchor.utils.mjs +28 -0
  6. package/esm2022/lib/data-source/abstract-wsk-data-source.mjs +56 -0
  7. package/esm2022/lib/data-source/data-source.model.mjs +51 -0
  8. package/esm2022/lib/data-source/wsk-data-source.mjs +31 -0
  9. package/esm2022/lib/data-source/wsk-lazy-data-source.mjs +55 -0
  10. package/esm2022/lib/date-time/date-time.utils.mjs +20 -0
  11. package/esm2022/lib/date-time/date.utils.mjs +41 -0
  12. package/esm2022/lib/date-time/time.mjs +16 -0
  13. package/esm2022/lib/date-time/time.utils.mjs +99 -0
  14. package/esm2022/lib/form/abstract-control-value-accessor.directive.mjs +32 -0
  15. package/esm2022/lib/formValidation/formControlError.utils.mjs +33 -0
  16. package/esm2022/lib/formValidation/validation.utils.mjs +99 -0
  17. package/esm2022/lib/graphic.utils.mjs +11 -0
  18. package/esm2022/lib/immutability/freeze.utils.mjs +10 -0
  19. package/esm2022/lib/let/let.directive.mjs +23 -0
  20. package/esm2022/lib/locale/decimal-separator.mjs +3 -0
  21. package/esm2022/lib/object.utils.mjs +19 -0
  22. package/esm2022/lib/pipes/array/array.module.mjs +18 -0
  23. package/esm2022/lib/pipes/array/select-from-array.pipe.mjs +19 -0
  24. package/esm2022/lib/pipes/contains/contains.module.mjs +18 -0
  25. package/esm2022/lib/pipes/contains/contains.pipe.mjs +25 -0
  26. package/esm2022/lib/pipes/fallback/fallback.pipe.mjs +24 -0
  27. package/esm2022/lib/pipes/filter/filter.module.mjs +18 -0
  28. package/esm2022/lib/pipes/filter/filter.pipe.mjs +24 -0
  29. package/esm2022/lib/pipes/find/find.module.mjs +18 -0
  30. package/esm2022/lib/pipes/find/find.pipe.mjs +25 -0
  31. package/esm2022/lib/pipes/index.mjs +16 -0
  32. package/esm2022/lib/pipes/map/map.module.mjs +18 -0
  33. package/esm2022/lib/pipes/map/map.pipe.mjs +19 -0
  34. package/esm2022/lib/pipes/minutes/duration-minutes.pipe.mjs +21 -0
  35. package/esm2022/lib/pipes/minutes/minutes.module.mjs +19 -0
  36. package/esm2022/lib/pipes/minutes/minutes.pipe.mjs +21 -0
  37. package/esm2022/lib/pipes/transform/transform.pipe.mjs +21 -0
  38. package/esm2022/lib/rxjs/active-request.mjs +20 -0
  39. package/esm2022/lib/services/authn/auth.store.mjs +18 -0
  40. package/esm2022/lib/services/authn/authentication.adapter.mjs +3 -0
  41. package/esm2022/lib/services/authn/authentication.service.mjs +165 -0
  42. package/esm2022/lib/services/authn/authn.guard.mjs +42 -0
  43. package/esm2022/lib/services/authn/credentials.mjs +2 -0
  44. package/esm2022/lib/services/authn/jwt-auth-interceptor.service.mjs +37 -0
  45. package/esm2022/lib/services/authn/local-auth-status.mjs +2 -0
  46. package/esm2022/lib/services/authn/not-auth.guard.mjs +45 -0
  47. package/esm2022/lib/services/browser/browser-meta.service.mjs +69 -0
  48. package/esm2022/lib/services/browser/page-meta.mjs +2 -0
  49. package/esm2022/lib/services/configuration/config.mjs +27 -0
  50. package/esm2022/lib/services/edit/can-deactivate.guard.mjs +14 -0
  51. package/esm2022/lib/services/edit/id-compare.mjs +4 -0
  52. package/esm2022/lib/services/index.mjs +30 -0
  53. package/esm2022/lib/services/logging/ng-error-handler.mjs +16 -0
  54. package/esm2022/lib/services/routing/previous-route.service.mjs +28 -0
  55. package/esm2022/lib/services/store/abstract-entity-store.mjs +57 -0
  56. package/esm2022/lib/services/store/abstract-store.mjs +31 -0
  57. package/esm2022/lib/services/time/time.adapter.mjs +3 -0
  58. package/esm2022/lib/services/time/time.service.mjs +90 -0
  59. package/esm2022/lib/services/tracking/browser-tracking.service.mjs +77 -0
  60. package/esm2022/lib/services/tracking/click-tracking.directive.mjs +25 -0
  61. package/esm2022/lib/services/tracking/logging-backend-appender.mjs +19 -0
  62. package/esm2022/lib/services/tracking/tracking.adapter.mjs +3 -0
  63. package/esm2022/lib/services/tracking/tracking.mjs +2 -0
  64. package/esm2022/lib/services/tracking/tracking.module.mjs +18 -0
  65. package/esm2022/lib/services/tracking/tracking.service.mjs +84 -0
  66. package/esm2022/lib/services/user/local-user-account.mjs +2 -0
  67. package/esm2022/lib/services/user/user.adapter.mjs +3 -0
  68. package/esm2022/lib/services/user/user.service.mjs +50 -0
  69. package/esm2022/lib/viewport.utils.mjs +22 -0
  70. package/esm2022/lib/webcomponents/web-components.mjs +10 -0
  71. package/esm2022/public-api.mjs +26 -0
  72. package/esm2022/webskills-ng-utils.mjs +5 -0
  73. package/fesm2022/webskills-ng-utils.mjs +1808 -0
  74. package/fesm2022/webskills-ng-utils.mjs.map +1 -0
  75. package/index.d.ts +5 -0
  76. package/lib/angular/instanceOf.utils.d.ts +2 -0
  77. package/lib/breakpoints/breakpoints.d.ts +16 -0
  78. package/lib/color/constrast-color.d.ts +1 -0
  79. package/lib/content/anchor.utils.d.ts +3 -0
  80. package/lib/data-source/abstract-wsk-data-source.d.ts +35 -0
  81. package/lib/data-source/data-source.model.d.ts +51 -0
  82. package/lib/data-source/wsk-data-source.d.ts +11 -0
  83. package/lib/data-source/wsk-lazy-data-source.d.ts +25 -0
  84. package/lib/date-time/date-time.utils.d.ts +8 -0
  85. package/lib/date-time/date.utils.d.ts +17 -0
  86. package/lib/date-time/time.d.ts +15 -0
  87. package/lib/date-time/time.utils.d.ts +39 -0
  88. package/lib/form/abstract-control-value-accessor.directive.d.ts +17 -0
  89. package/lib/formValidation/formControlError.utils.d.ts +16 -0
  90. package/lib/formValidation/validation.utils.d.ts +23 -0
  91. package/lib/graphic.utils.d.ts +16 -0
  92. package/lib/immutability/freeze.utils.d.ts +1 -0
  93. package/lib/let/let.directive.d.ts +13 -0
  94. package/lib/locale/decimal-separator.d.ts +3 -0
  95. package/lib/object.utils.d.ts +7 -0
  96. package/lib/pipes/array/array.module.d.ts +8 -0
  97. package/lib/pipes/array/select-from-array.pipe.d.ts +7 -0
  98. package/lib/pipes/contains/contains.module.d.ts +8 -0
  99. package/lib/pipes/contains/contains.pipe.d.ts +13 -0
  100. package/lib/pipes/fallback/fallback.pipe.d.ts +7 -0
  101. package/lib/pipes/filter/filter.module.d.ts +8 -0
  102. package/lib/pipes/filter/filter.pipe.d.ts +12 -0
  103. package/lib/pipes/find/find.module.d.ts +8 -0
  104. package/lib/pipes/find/find.pipe.d.ts +13 -0
  105. package/lib/pipes/index.d.ts +15 -0
  106. package/lib/pipes/map/map.module.d.ts +8 -0
  107. package/lib/pipes/map/map.pipe.d.ts +7 -0
  108. package/lib/pipes/minutes/duration-minutes.pipe.d.ts +7 -0
  109. package/lib/pipes/minutes/minutes.module.d.ts +9 -0
  110. package/lib/pipes/minutes/minutes.pipe.d.ts +7 -0
  111. package/lib/pipes/transform/transform.pipe.d.ts +7 -0
  112. package/lib/rxjs/active-request.d.ts +9 -0
  113. package/lib/services/authn/auth.store.d.ts +8 -0
  114. package/lib/services/authn/authentication.adapter.d.ts +11 -0
  115. package/lib/services/authn/authentication.service.d.ts +63 -0
  116. package/lib/services/authn/authn.guard.d.ts +15 -0
  117. package/lib/services/authn/credentials.d.ts +4 -0
  118. package/lib/services/authn/jwt-auth-interceptor.service.d.ts +12 -0
  119. package/lib/services/authn/local-auth-status.d.ts +7 -0
  120. package/lib/services/authn/not-auth.guard.d.ts +17 -0
  121. package/lib/services/browser/browser-meta.service.d.ts +16 -0
  122. package/lib/services/browser/page-meta.d.ts +10 -0
  123. package/lib/services/configuration/config.d.ts +19 -0
  124. package/lib/services/edit/can-deactivate.guard.d.ts +11 -0
  125. package/lib/services/edit/id-compare.d.ts +5 -0
  126. package/lib/services/index.d.ts +29 -0
  127. package/lib/services/logging/ng-error-handler.d.ts +11 -0
  128. package/lib/services/routing/previous-route.service.d.ts +11 -0
  129. package/lib/services/store/abstract-entity-store.d.ts +16 -0
  130. package/lib/services/store/abstract-store.d.ts +13 -0
  131. package/lib/services/time/time.adapter.d.ts +7 -0
  132. package/lib/services/time/time.service.d.ts +27 -0
  133. package/lib/services/tracking/browser-tracking.service.d.ts +16 -0
  134. package/lib/services/tracking/click-tracking.directive.d.ts +10 -0
  135. package/lib/services/tracking/logging-backend-appender.d.ts +8 -0
  136. package/lib/services/tracking/tracking.adapter.d.ts +9 -0
  137. package/lib/services/tracking/tracking.d.ts +84 -0
  138. package/lib/services/tracking/tracking.module.d.ts +8 -0
  139. package/lib/services/tracking/tracking.service.d.ts +28 -0
  140. package/lib/services/user/local-user-account.d.ts +15 -0
  141. package/lib/services/user/user.adapter.d.ts +17 -0
  142. package/lib/services/user/user.service.d.ts +27 -0
  143. package/lib/viewport.utils.d.ts +2 -0
  144. package/lib/webcomponents/web-components.d.ts +2 -0
  145. package/package.json +30 -0
  146. package/public-api.d.ts +25 -0
@@ -0,0 +1,1808 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Injectable, Inject, isDevMode, Directive, PLATFORM_ID, Input, HostListener, NgModule, Pipe } from '@angular/core';
3
+ import * as i2 from '@angular/router';
4
+ import { ActivationEnd, NavigationEnd } from '@angular/router';
5
+ import { isDefined, isUndefined, isBlank, isNotBlank, forEachProp, isEqual, cloneDeep, intPattern, floatPattern } from '@webskills/ts-utils';
6
+ import * as i2$1 from '@angular/platform-browser';
7
+ import { map, catchError, tap, takeUntil, distinctUntilChanged, filter, switchMap as switchMap$1, startWith, finalize } from 'rxjs/operators';
8
+ import { BehaviorSubject, Subject, of, timer, EMPTY, combineLatest, switchMap, defer } from 'rxjs';
9
+ import { Logger, LogLevel } from '@webskills/logging';
10
+ import { isPlatformBrowser, CommonModule, formatDate } from '@angular/common';
11
+ import * as i3 from '@angular/cdk/layout';
12
+ import { DataSource } from '@angular/cdk/collections';
13
+ import { createCustomElement } from '@angular/elements';
14
+
15
+ class Config {
16
+ constructor(values) {
17
+ this.values = values;
18
+ }
19
+ get production() {
20
+ return this.values.production;
21
+ }
22
+ get apiBasePath() {
23
+ return this.values.apiBasePath;
24
+ }
25
+ /**
26
+ * Get the value for a specified config option or fallback to the specified default value.
27
+ *
28
+ * @param name of the config option
29
+ * @param defaultValue value that is used when config option is not specified elsewhere
30
+ */
31
+ getProperty(name, defaultValue) {
32
+ if (isDefined(this.values[name])) {
33
+ return this.values[name];
34
+ }
35
+ return defaultValue;
36
+ }
37
+ }
38
+ const CONFIG = new InjectionToken('Config');
39
+
40
+ class BrowserMetaService {
41
+ constructor(router, meta, config) {
42
+ this.router = router;
43
+ this.meta = meta;
44
+ this.config = config;
45
+ }
46
+ init() {
47
+ this.router.events.subscribe((event) => {
48
+ if (event instanceof ActivationEnd) {
49
+ this.setPageMetaData(event.snapshot.data?.['meta'], event.snapshot.title);
50
+ }
51
+ });
52
+ }
53
+ setPageMetaData(meta, pageTitle) {
54
+ if (isUndefined(meta)) {
55
+ meta = {};
56
+ }
57
+ const frontendUrl = this.config.getProperty('frontendUrl', 'http://localhost');
58
+ const appImage = this.config.getProperty('appImage', 'assets/app.jpg');
59
+ const socialUrl = frontendUrl + this.router.url;
60
+ const socialTitle = meta.og_title ?? pageTitle;
61
+ const socialDescription = meta.og_description ?? meta.description;
62
+ const socialImage = frontendUrl + '/' + (meta.image ?? appImage);
63
+ this.setOrRemoveTag('description', meta.description);
64
+ this.setOrRemoveTag('keywords', meta.keywords);
65
+ this.setOrRemoveTag('robots', meta.robots);
66
+ this.setOrRemoveTag('image', socialImage);
67
+ this.setOrRemoveTag('twitter:url', socialUrl);
68
+ this.setOrRemoveTag('twitter:title', socialTitle);
69
+ this.setOrRemoveTag('twitter:description', socialDescription);
70
+ this.setOrRemoveTag('twitter:image', socialImage);
71
+ this.setOrRemoveTag('twitter.card', meta.twitter_card ?? 'summary');
72
+ this.setOrRemoveTag('og:url', socialUrl, 'property');
73
+ this.setOrRemoveTag('og:title', socialTitle, 'property');
74
+ this.setOrRemoveTag('og:description', socialDescription, 'property');
75
+ this.setOrRemoveTag('og:image', socialImage, 'property');
76
+ this.setOrRemoveTag('og:type', meta.og_type ?? 'website', 'property');
77
+ }
78
+ setOrRemoveTag(attributeValue, content, attributeName = 'name') {
79
+ if (isBlank(content)) {
80
+ this.meta.removeTag(`${attributeName}='${attributeValue}'`);
81
+ }
82
+ else {
83
+ const tag = {
84
+ content,
85
+ };
86
+ tag[attributeName] = attributeValue;
87
+ this.meta.updateTag(tag);
88
+ }
89
+ }
90
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrowserMetaService, deps: [{ token: i2.Router }, { token: i2$1.Meta }, { token: CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
91
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrowserMetaService, providedIn: 'root' }); }
92
+ }
93
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrowserMetaService, decorators: [{
94
+ type: Injectable,
95
+ args: [{ providedIn: 'root' }]
96
+ }], ctorParameters: () => [{ type: i2.Router }, { type: i2$1.Meta }, { type: Config, decorators: [{
97
+ type: Inject,
98
+ args: [CONFIG]
99
+ }] }] });
100
+
101
+ class UserAdapter {
102
+ }
103
+
104
+ class UserService {
105
+ constructor(userAdapter) {
106
+ this.userAdapter = userAdapter;
107
+ this._userAccount$ = new BehaviorSubject(null);
108
+ this.userAccount$ = this._userAccount$.asObservable();
109
+ }
110
+ registerUser(registerData) {
111
+ return this.userAdapter.registerUser(registerData);
112
+ }
113
+ setUserAccount(user) {
114
+ this._userAccount$.next(user);
115
+ }
116
+ getUserAccount() {
117
+ return this._userAccount$.getValue();
118
+ }
119
+ changePassword(currentPassword, newPassword) {
120
+ return this.userAdapter.changePassword(currentPassword, newPassword);
121
+ }
122
+ requestPasswordReset(email) {
123
+ return this.userAdapter.requestPasswordReset(email);
124
+ }
125
+ confirmPasswordReset(token, newPassword) {
126
+ return this.userAdapter.confirmPasswordReset(token, newPassword);
127
+ }
128
+ changeEmailAddress(newEmailAddress, password) {
129
+ return this.userAdapter.changeEmailAddress(newEmailAddress, password);
130
+ }
131
+ confirmEmail(token) {
132
+ return this.userAdapter.confirmEmail(token);
133
+ }
134
+ confirmDeleteAccount(token) {
135
+ return this.userAdapter.confirmDeleteAccount(token);
136
+ }
137
+ deleteAccount(password) {
138
+ return this.userAdapter.deleteAccount(password);
139
+ }
140
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: UserService, deps: [{ token: UserAdapter }], target: i0.ɵɵFactoryTarget.Injectable }); }
141
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: UserService, providedIn: 'root' }); }
142
+ }
143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: UserService, decorators: [{
144
+ type: Injectable,
145
+ args: [{
146
+ providedIn: 'root',
147
+ }]
148
+ }], ctorParameters: () => [{ type: UserAdapter }] });
149
+
150
+ class AuthenticationAdapter {
151
+ }
152
+
153
+ function deepFreeze(obj) {
154
+ Object.keys(obj).forEach((name) => {
155
+ const value = obj[name];
156
+ if (typeof value === 'object' && !Object.isFrozen(value)) {
157
+ deepFreeze(value);
158
+ }
159
+ });
160
+ return Object.freeze(obj);
161
+ }
162
+
163
+ class AbstractStore {
164
+ get value$() {
165
+ return this._value$.asObservable();
166
+ }
167
+ constructor(initialValue) {
168
+ this._value$ = new BehaviorSubject(initialValue);
169
+ }
170
+ update(value) {
171
+ if (isDevMode() && isDefined(value)) {
172
+ value = deepFreeze(value);
173
+ }
174
+ this._value$.next(value);
175
+ }
176
+ getInstant() {
177
+ return this._value$.getValue();
178
+ }
179
+ ngOnDestroy() {
180
+ this._value$.complete();
181
+ }
182
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AbstractStore, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
183
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: AbstractStore, ngImport: i0 }); }
184
+ }
185
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AbstractStore, decorators: [{
186
+ type: Directive
187
+ }], ctorParameters: () => [{ type: undefined }] });
188
+
189
+ class AuthStore extends AbstractStore {
190
+ constructor() {
191
+ super({
192
+ isLoggedIn: false,
193
+ sessionId: '',
194
+ });
195
+ }
196
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
197
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthStore, providedIn: 'root' }); }
198
+ }
199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthStore, decorators: [{
200
+ type: Injectable,
201
+ args: [{ providedIn: 'root' }]
202
+ }], ctorParameters: () => [] });
203
+
204
+ class TrackingAdapter {
205
+ }
206
+
207
+ class TrackingService {
208
+ constructor(adapter, platformId) {
209
+ this.adapter = adapter;
210
+ this.isBrowser = isPlatformBrowser(platformId);
211
+ }
212
+ trackSession() {
213
+ if (!this.isBrowser) {
214
+ return;
215
+ }
216
+ const urlParams = new URLSearchParams(window.location.search);
217
+ const d = {
218
+ referrer: document.referrer,
219
+ utmCampaign: urlParams.get('utm_campaign') ?? undefined,
220
+ utmContent: urlParams.get('utm_content') ?? undefined,
221
+ utmMedium: urlParams.get('utm_medium') ?? undefined,
222
+ utmSource: urlParams.get('utm_source') ?? undefined,
223
+ utmTerm: urlParams.get('utm_term') ?? undefined,
224
+ };
225
+ this.adapter.trackSession(d);
226
+ }
227
+ trackInfo(info) {
228
+ if (!this.isBrowser) {
229
+ return;
230
+ }
231
+ const d = {
232
+ n: info.name,
233
+ d: info.data,
234
+ };
235
+ this.enrichWithUrl(d);
236
+ this.adapter.trackInfo(d);
237
+ }
238
+ trackInteraction(event) {
239
+ if (!this.isBrowser) {
240
+ return;
241
+ }
242
+ const d = {
243
+ d: event.data,
244
+ e: event.event,
245
+ c: event.component,
246
+ };
247
+ this.enrichWithUrl(d);
248
+ this.adapter.trackInteraction(d);
249
+ }
250
+ trackVisit(event) {
251
+ if (!this.isBrowser) {
252
+ return;
253
+ }
254
+ const d = {
255
+ c: event.component,
256
+ url: event.url,
257
+ };
258
+ this.enrichWithUrl(d);
259
+ this.adapter.trackVisit(d);
260
+ }
261
+ trackUserAgent(userAgent) {
262
+ if (!this.isBrowser) {
263
+ return;
264
+ }
265
+ this.adapter.trackUserAgent(userAgent);
266
+ }
267
+ enrichWithUrl(trackingEvent) {
268
+ if (isUndefined(trackingEvent.url)) {
269
+ trackingEvent.url = this.getBrowserUrl();
270
+ }
271
+ }
272
+ getBrowserUrl() {
273
+ return window.location.href;
274
+ }
275
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TrackingService, deps: [{ token: TrackingAdapter }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
276
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TrackingService, providedIn: 'root' }); }
277
+ }
278
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TrackingService, decorators: [{
279
+ type: Injectable,
280
+ args: [{ providedIn: 'root' }]
281
+ }], ctorParameters: () => [{ type: TrackingAdapter }, { type: undefined, decorators: [{
282
+ type: Inject,
283
+ args: [PLATFORM_ID]
284
+ }] }] });
285
+
286
+ class AuthenticationService {
287
+ constructor(userService, config, router, authAdapter, userAdapter, authStore, trackingService) {
288
+ this.userService = userService;
289
+ this.config = config;
290
+ this.router = router;
291
+ this.authAdapter = authAdapter;
292
+ this.userAdapter = userAdapter;
293
+ this.authStore = authStore;
294
+ this.trackingService = trackingService;
295
+ this.logger = new Logger('AuthenticationService');
296
+ this.destroyed$ = new Subject();
297
+ this.startSessionCheck();
298
+ }
299
+ ngOnDestroy() {
300
+ this.destroyed$.next();
301
+ this.destroyed$.complete();
302
+ }
303
+ /**
304
+ * Test the current session against the backend.
305
+ */
306
+ testSessionValid() {
307
+ return this.authAdapter.testSessionValid();
308
+ }
309
+ /**
310
+ * Use the existing session id to check against the backend whether the session is still active.
311
+ *
312
+ * E.g. during app (after a reload etc.) the previous login state must be restored.
313
+ */
314
+ recoverSession() {
315
+ const sessionId = localStorage.getItem('sessionId') ?? undefined;
316
+ if (isUndefined(sessionId)) {
317
+ return of(false);
318
+ }
319
+ return this.userAdapter.getUser(sessionId).pipe(map((result) => {
320
+ // -- check was successful; we store the retrieved user object and the sessionId in the store
321
+ this.insertSessionInformationIntoStore(result, sessionId);
322
+ this.logger.debug('#recoverSession: found existing session');
323
+ return true;
324
+ }), catchError(() => {
325
+ // -- check failed; we do nothing
326
+ this.logger.debug('#recoverSession: no session');
327
+ return of(false);
328
+ }));
329
+ }
330
+ insertSessionInformationIntoStore(user, sessionId) {
331
+ // store session data
332
+ this.authStore.update({
333
+ isLoggedIn: true,
334
+ sessionId: sessionId,
335
+ });
336
+ // store user data
337
+ this.userService.setUserAccount({
338
+ email: user.email,
339
+ name: user.name,
340
+ id: user.id,
341
+ avatarFileId: user.avatarFileId,
342
+ avatarUrl: user.avatarUrl,
343
+ gravatarEmail: user.gravatarEmail,
344
+ roles: user.roles,
345
+ });
346
+ }
347
+ /**
348
+ * Perform a login against the backend and store the session and user information in the frontend.
349
+ *
350
+ * @param credentials
351
+ */
352
+ login(credentials) {
353
+ return this.authAdapter.login(credentials).pipe(tap(({ sessionId, user }) => {
354
+ this.insertSessionInformationIntoStore(user, sessionId);
355
+ localStorage.setItem('sessionId', sessionId);
356
+ }), map(({ sessionId }) => {
357
+ if (isNotBlank(sessionId)) {
358
+ return void 0;
359
+ }
360
+ else {
361
+ throw new Error('could not login');
362
+ }
363
+ }));
364
+ }
365
+ /**
366
+ * Perform a logout against the backend and remove locally stored session and user information.
367
+ */
368
+ logout() {
369
+ this.logger.debug('logout');
370
+ return this.authAdapter.logout(this.getSessionId()).pipe(
371
+ // no matter whether the request was successful, we want to clear all session information on client side
372
+ catchError(() => of(void 0)), tap(() => this.resetAuthStatus()));
373
+ }
374
+ isLoggedIn() {
375
+ return this.authStore.value$.pipe(map((result) => result.isLoggedIn));
376
+ }
377
+ /**
378
+ * Reset the auth state in the app.
379
+ */
380
+ resetAuthStatus() {
381
+ this.logger.debug('#resetAuthStatus');
382
+ // remove session form local storage
383
+ localStorage.removeItem('sessionId');
384
+ // reset information in store
385
+ this.authStore.update({
386
+ isLoggedIn: false,
387
+ sessionId: '',
388
+ });
389
+ }
390
+ getSessionId() {
391
+ return this.authStore.getInstant().sessionId;
392
+ }
393
+ isLoggedInInstant() {
394
+ return this.authStore.getInstant().isLoggedIn;
395
+ }
396
+ /**
397
+ * Start a timer that continuously checks the session.
398
+ */
399
+ startSessionCheck() {
400
+ const interval = this.config.getProperty('authentication.sessionCheck.timerIntervalSeconds', 60);
401
+ timer(20 * 1000, interval * 1000)
402
+ .pipe(takeUntil(this.destroyed$))
403
+ .subscribe(() => this.validateSession());
404
+ }
405
+ validateSession() {
406
+ if (!this.isLoggedInInstant()) {
407
+ return;
408
+ }
409
+ this.testSessionValid().subscribe((result) => {
410
+ if (!result) {
411
+ this.logger.debug('#startSessionCheck: clear session');
412
+ this.appLogout();
413
+ }
414
+ });
415
+ }
416
+ /**
417
+ * Perform a logout that is triggered by the app
418
+ */
419
+ appLogout() {
420
+ this.trackingService.trackInfo({ name: 'appLogout' });
421
+ this.resetAuthStatus();
422
+ this.router.navigate(['/logout']);
423
+ }
424
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthenticationService, deps: [{ token: UserService }, { token: CONFIG }, { token: i2.Router }, { token: AuthenticationAdapter }, { token: UserAdapter }, { token: AuthStore }, { token: TrackingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
425
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthenticationService, providedIn: 'root' }); }
426
+ }
427
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthenticationService, decorators: [{
428
+ type: Injectable,
429
+ args: [{
430
+ providedIn: 'root',
431
+ }]
432
+ }], ctorParameters: () => [{ type: UserService }, { type: Config, decorators: [{
433
+ type: Inject,
434
+ args: [CONFIG]
435
+ }] }, { type: i2.Router }, { type: AuthenticationAdapter }, { type: UserAdapter }, { type: AuthStore }, { type: TrackingService }] });
436
+
437
+ class AuthGuard {
438
+ constructor(authService, router) {
439
+ this.authService = authService;
440
+ this.router = router;
441
+ }
442
+ checkLogin(state) {
443
+ return this.authService.isLoggedIn().pipe(map((isLoggedIn) => {
444
+ if (isLoggedIn) {
445
+ return true;
446
+ }
447
+ if (state.url === '/logout') {
448
+ return this.router.createUrlTree(['/login']);
449
+ }
450
+ return this.router.createUrlTree(['/login'], {
451
+ queryParams: { redirUrl: state.url },
452
+ });
453
+ }));
454
+ }
455
+ canLoad() {
456
+ return this.authService.isLoggedIn();
457
+ }
458
+ canActivate(route, state) {
459
+ return this.checkLogin(state);
460
+ }
461
+ canActivateChild(route, state) {
462
+ return this.checkLogin(state);
463
+ }
464
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthGuard, deps: [{ token: AuthenticationService }, { token: i2.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
465
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthGuard, providedIn: 'root' }); }
466
+ }
467
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthGuard, decorators: [{
468
+ type: Injectable,
469
+ args: [{
470
+ providedIn: 'root',
471
+ }]
472
+ }], ctorParameters: () => [{ type: AuthenticationService }, { type: i2.Router }] });
473
+
474
+ class PreviousRouteService {
475
+ constructor(router) {
476
+ this.router = router;
477
+ this.currentUrl = this.router.url;
478
+ router.events.subscribe((event) => {
479
+ if (event instanceof NavigationEnd) {
480
+ this.previousUrl = this.currentUrl;
481
+ this.currentUrl = event.url;
482
+ }
483
+ });
484
+ }
485
+ getPreviousUrl() {
486
+ return this.previousUrl;
487
+ }
488
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: PreviousRouteService, deps: [{ token: i2.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
489
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: PreviousRouteService, providedIn: 'root' }); }
490
+ }
491
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: PreviousRouteService, decorators: [{
492
+ type: Injectable,
493
+ args: [{
494
+ providedIn: 'root',
495
+ }]
496
+ }], ctorParameters: () => [{ type: i2.Router }] });
497
+
498
+ class NotAuthGuard {
499
+ constructor(authService, router, previousRouteService) {
500
+ this.authService = authService;
501
+ this.router = router;
502
+ this.previousRouteService = previousRouteService;
503
+ }
504
+ checkLoggedOut() {
505
+ return this.authService.isLoggedIn().pipe(map((isLoggedIn) => {
506
+ if (!isLoggedIn) {
507
+ return true;
508
+ }
509
+ if (isBlank(this.previousRouteService.getPreviousUrl())) {
510
+ return this.router.createUrlTree(['/']);
511
+ }
512
+ else {
513
+ return false;
514
+ }
515
+ }));
516
+ }
517
+ canLoad() {
518
+ return this.authService.isLoggedIn();
519
+ }
520
+ canActivate() {
521
+ return this.checkLoggedOut();
522
+ }
523
+ canActivateChild() {
524
+ return this.checkLoggedOut();
525
+ }
526
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NotAuthGuard, deps: [{ token: AuthenticationService }, { token: i2.Router }, { token: PreviousRouteService }], target: i0.ɵɵFactoryTarget.Injectable }); }
527
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NotAuthGuard, providedIn: 'root' }); }
528
+ }
529
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NotAuthGuard, decorators: [{
530
+ type: Injectable,
531
+ args: [{
532
+ providedIn: 'root',
533
+ }]
534
+ }], ctorParameters: () => [{ type: AuthenticationService }, { type: i2.Router }, { type: PreviousRouteService }] });
535
+
536
+ class JwtAuthInterceptor {
537
+ constructor(authService) {
538
+ this.authService = authService;
539
+ }
540
+ intercept(req, next) {
541
+ const idToken = this.authService.getSessionId();
542
+ if (isNotBlank(idToken) && isUndefined(req.headers.get('Authorization'))) {
543
+ const cloned = req.clone({
544
+ headers: req.headers.set('Authorization', 'Bearer ' + idToken),
545
+ });
546
+ return next.handle(cloned).pipe(this.interceptHttp401Error());
547
+ }
548
+ else {
549
+ return next.handle(req).pipe(this.interceptHttp401Error());
550
+ }
551
+ }
552
+ interceptHttp401Error() {
553
+ return tap({
554
+ error: (err) => {
555
+ if (err?.status === 401) {
556
+ this.authService.validateSession();
557
+ }
558
+ },
559
+ });
560
+ }
561
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: JwtAuthInterceptor, deps: [{ token: AuthenticationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
562
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: JwtAuthInterceptor }); }
563
+ }
564
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: JwtAuthInterceptor, decorators: [{
565
+ type: Injectable
566
+ }], ctorParameters: () => [{ type: AuthenticationService }] });
567
+
568
+ class AbstractEntityStore extends AbstractStore {
569
+ insertEntity(value) {
570
+ this.update([...this.getInstant(), value]);
571
+ }
572
+ upsertEntity(value) {
573
+ if (isUndefined(value)) {
574
+ throw new Error('entity must be defined');
575
+ }
576
+ const idx = this.getIdx(value.id);
577
+ if (idx == -1) {
578
+ this.insertEntity(value);
579
+ }
580
+ else {
581
+ this.replaceValueAtIndex(value, idx);
582
+ }
583
+ }
584
+ updateEntity(value) {
585
+ if (isUndefined(value)) {
586
+ throw new Error('entity must be defined');
587
+ }
588
+ const idx = this.getIdx(value.id);
589
+ if (idx == -1) {
590
+ throw new Error('no such entity with id ' + value.id);
591
+ }
592
+ this.replaceValueAtIndex(value, idx);
593
+ }
594
+ replaceValueAtIndex(value, idx) {
595
+ this.update([
596
+ ...this.getInstant().slice(0, idx),
597
+ value,
598
+ ...this.getInstant().slice(idx + 1),
599
+ ]);
600
+ }
601
+ deleteEntity(id) {
602
+ const idx = this.getIdx(id);
603
+ if (idx == -1) {
604
+ throw new Error('no such entity with id ' + id);
605
+ }
606
+ this.update([
607
+ ...this.getInstant().slice(0, idx),
608
+ ...this.getInstant().slice(idx + 1),
609
+ ]);
610
+ }
611
+ getIdx(id) {
612
+ return this.getInstant().findIndex((v) => v.id === id);
613
+ }
614
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AbstractEntityStore, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
615
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: AbstractEntityStore, usesInheritance: true, ngImport: i0 }); }
616
+ }
617
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AbstractEntityStore, decorators: [{
618
+ type: Directive
619
+ }] });
620
+
621
+ class TimeAdapter {
622
+ }
623
+
624
+ class TimeService {
625
+ constructor(config, timeAdapter, trackingService) {
626
+ this.config = config;
627
+ this.timeAdapter = timeAdapter;
628
+ this.trackingService = trackingService;
629
+ this.logger = new Logger('TimeService');
630
+ this.componentDestroyed$ = new Subject();
631
+ this.offset = 0;
632
+ }
633
+ init() {
634
+ const timerIntervalSeconds = this.config.getProperty('time.requestIntervalSeconds', 120);
635
+ const initialDelayMs = 50;
636
+ timer(initialDelayMs, timerIntervalSeconds * 1000)
637
+ .pipe(takeUntil(this.componentDestroyed$), switchMap(() => combineLatest([
638
+ this.timeAdapter.getServerTime(),
639
+ of(new Date()),
640
+ ]).pipe(catchError(() => EMPTY))))
641
+ .subscribe({
642
+ next: ([serverTime, requestStart]) => {
643
+ const offset = this._calcOffset(requestStart, new Date(serverTime), new Date());
644
+ if (isDefined(offset)) {
645
+ this.trackingService.trackInfo({
646
+ name: 'timeOffset',
647
+ data: offset,
648
+ });
649
+ this.offset = offset;
650
+ }
651
+ this.logger.trace('current offset:', this.offset);
652
+ },
653
+ error: (err) => {
654
+ this.logger.error(err);
655
+ },
656
+ });
657
+ }
658
+ _calcOffset(requestStart, serverTime, now) {
659
+ const maxRuntimeSeconds = this.config.getProperty('time.maxRuntimeSeconds', 5);
660
+ const runTime = now.getTime() - requestStart.getTime();
661
+ if (runTime > maxRuntimeSeconds * 1000) {
662
+ this.logger.trace('request took too long');
663
+ return undefined;
664
+ }
665
+ const offset = serverTime.getTime() + runTime / 2 - now.getTime();
666
+ if (serverTime < requestStart) {
667
+ return offset;
668
+ }
669
+ if (serverTime > now) {
670
+ return offset;
671
+ }
672
+ if (Math.abs(offset) < runTime) {
673
+ return 0;
674
+ }
675
+ return offset;
676
+ }
677
+ /**
678
+ * Get the current server time as Date object
679
+ */
680
+ getCurrentDate() {
681
+ return new Date(this.getCurrentMs());
682
+ }
683
+ /**
684
+ * Get the current server time in ms
685
+ */
686
+ getCurrentMs() {
687
+ return Date.now() + this.offset;
688
+ }
689
+ ngOnDestroy() {
690
+ this.componentDestroyed$.next();
691
+ this.componentDestroyed$.complete();
692
+ }
693
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TimeService, deps: [{ token: CONFIG }, { token: TimeAdapter }, { token: TrackingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
694
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TimeService, providedIn: 'root' }); }
695
+ }
696
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TimeService, decorators: [{
697
+ type: Injectable,
698
+ args: [{ providedIn: 'root' }]
699
+ }], ctorParameters: () => [{ type: Config, decorators: [{
700
+ type: Inject,
701
+ args: [CONFIG]
702
+ }] }, { type: TimeAdapter }, { type: TrackingService }] });
703
+
704
+ class CanDeactivateGuard {
705
+ canDeactivate(component) {
706
+ return component.canDeactivate ? component.canDeactivate() : true;
707
+ }
708
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CanDeactivateGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
709
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CanDeactivateGuard, providedIn: 'root' }); }
710
+ }
711
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CanDeactivateGuard, decorators: [{
712
+ type: Injectable,
713
+ args: [{ providedIn: 'root' }]
714
+ }] });
715
+
716
+ function idCompare(c1, c2) {
717
+ return c1 && c2 ? c1.id === c2.id : c1 === c2;
718
+ }
719
+
720
+ const Breakpoints = {
721
+ XSmall: '(max-width: 599.98px)',
722
+ Small: '(min-width: 600px) and (max-width: 1023.98px)',
723
+ Medium: '(min-width: 1024px) and (max-width: 1439.98px)',
724
+ Large: '(min-width: 1440px) and (max-width: 1919.98px)',
725
+ XLarge: '(min-width: 1920px)',
726
+ Handset: '(max-width: 599.98px) and (orientation: portrait), ' +
727
+ '(min-width: 480px) and (max-width: 959.98px) and (orientation: landscape)',
728
+ Tablet: '(min-width: 600px) and (max-width: 959.98px) and (orientation: portrait), ' +
729
+ '(min-width: 960px) and (max-width: 1439.98px) and (orientation: landscape)',
730
+ Web: '(min-width: 960px) and (orientation: portrait), ' +
731
+ '(min-width: 1440px) and (orientation: landscape)',
732
+ HandsetPortrait: '(max-width: 599.98px) and (orientation: portrait)',
733
+ TabletPortrait: '(min-width: 600px) and (max-width: 959.98px) and (orientation: portrait)',
734
+ WebPortrait: '(min-width: 960px) and (orientation: portrait)',
735
+ HandsetLandscape: '(min-width: 480px) and (max-width: 959.98px) and (orientation: landscape)',
736
+ TabletLandscape: '(min-width: 960px) and (max-width: 1439.98px) and (orientation: landscape)',
737
+ WebLandscape: '(min-width: 1440px) and (orientation: landscape)',
738
+ };
739
+
740
+ class BrowserTrackingService {
741
+ constructor(trackingService, router, breakpointObserver, platformId) {
742
+ this.trackingService = trackingService;
743
+ this.router = router;
744
+ this.breakpointObserver = breakpointObserver;
745
+ this.isBrowser = isPlatformBrowser(platformId);
746
+ }
747
+ init() {
748
+ this.router.events.subscribe((event) => {
749
+ if (event instanceof NavigationEnd && this.isBrowser) {
750
+ let baseUri = document.baseURI;
751
+ baseUri = baseUri.substring(0, baseUri.length - 1);
752
+ this.trackingService.trackVisit({ url: baseUri + event.url });
753
+ }
754
+ });
755
+ if (this.isBrowser) {
756
+ this.trackUa();
757
+ this.trackBreakpoints();
758
+ this.trackingService.trackSession();
759
+ }
760
+ }
761
+ trackBreakpoints() {
762
+ this.breakpointObserver
763
+ .observe([
764
+ Breakpoints.Handset,
765
+ Breakpoints.Tablet,
766
+ Breakpoints.Web,
767
+ Breakpoints.HandsetPortrait,
768
+ Breakpoints.TabletPortrait,
769
+ Breakpoints.WebPortrait,
770
+ Breakpoints.HandsetLandscape,
771
+ Breakpoints.TabletLandscape,
772
+ Breakpoints.WebLandscape,
773
+ ])
774
+ .subscribe((res) => {
775
+ const breakpoints = [];
776
+ forEachProp(res.breakpoints, (breakpoint, matched) => {
777
+ if (matched) {
778
+ forEachProp(Breakpoints, (bpName, bpVal) => {
779
+ if (breakpoint === bpVal) {
780
+ breakpoints.push(bpName);
781
+ }
782
+ });
783
+ }
784
+ });
785
+ this.trackingService.trackInfo({ name: 'bps', data: breakpoints });
786
+ });
787
+ }
788
+ trackUa() {
789
+ this.trackingService.trackUserAgent({
790
+ ua: navigator.userAgent,
791
+ lng: navigator.language,
792
+ res: screen.width + 'x' + screen.height,
793
+ tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
794
+ c: navigator.cookieEnabled,
795
+ });
796
+ }
797
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrowserTrackingService, deps: [{ token: TrackingService }, { token: i2.Router }, { token: i3.BreakpointObserver }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
798
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrowserTrackingService, providedIn: 'root' }); }
799
+ }
800
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrowserTrackingService, decorators: [{
801
+ type: Injectable,
802
+ args: [{ providedIn: 'root' }]
803
+ }], ctorParameters: () => [{ type: TrackingService }, { type: i2.Router }, { type: i3.BreakpointObserver }, { type: undefined, decorators: [{
804
+ type: Inject,
805
+ args: [PLATFORM_ID]
806
+ }] }] });
807
+
808
+ class ClickTrackingDirective {
809
+ onClick() {
810
+ this.trackingService.trackInteraction(this.wskClickTracking);
811
+ }
812
+ constructor(trackingService) {
813
+ this.trackingService = trackingService;
814
+ }
815
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ClickTrackingDirective, deps: [{ token: TrackingService }], target: i0.ɵɵFactoryTarget.Directive }); }
816
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: ClickTrackingDirective, selector: "[wskClickTracking]", inputs: { wskClickTracking: "wskClickTracking" }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }
817
+ }
818
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ClickTrackingDirective, decorators: [{
819
+ type: Directive,
820
+ args: [{
821
+ selector: '[wskClickTracking]',
822
+ }]
823
+ }], ctorParameters: () => [{ type: TrackingService }], propDecorators: { wskClickTracking: [{
824
+ type: Input
825
+ }], onClick: [{
826
+ type: HostListener,
827
+ args: ['click', ['$event']]
828
+ }] } });
829
+
830
+ class LoggingBackendAppender {
831
+ constructor(level, logAdapter) {
832
+ this.level = level;
833
+ this.logAdapter = logAdapter;
834
+ }
835
+ appendMessage(name, level, message, additional) {
836
+ const msgs = [];
837
+ msgs.push(message);
838
+ msgs.push(...additional);
839
+ const msg = {
840
+ name: name,
841
+ level: LogLevel[level],
842
+ messages: msgs,
843
+ };
844
+ this.logAdapter.trackLog(msg);
845
+ }
846
+ }
847
+
848
+ class TrackingModule {
849
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TrackingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
850
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: TrackingModule, declarations: [ClickTrackingDirective], imports: [CommonModule], exports: [ClickTrackingDirective] }); }
851
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TrackingModule, imports: [CommonModule] }); }
852
+ }
853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TrackingModule, decorators: [{
854
+ type: NgModule,
855
+ args: [{
856
+ imports: [CommonModule],
857
+ declarations: [ClickTrackingDirective],
858
+ exports: [ClickTrackingDirective],
859
+ }]
860
+ }] });
861
+
862
+ /**
863
+ * Use as follows in main module
864
+ * ```
865
+ * { provide: ErrorHandler, useClass: NgErrorHandler },
866
+ * ```
867
+ */
868
+ class NgErrorHandler {
869
+ constructor() {
870
+ this.logger = new Logger('NgErrorHandler');
871
+ }
872
+ handleError(error) {
873
+ this.logger.error(error.toString(), error);
874
+ }
875
+ }
876
+
877
+ class ContainsPipe {
878
+ /**
879
+ *
880
+ * @param value data that is searched
881
+ * @param func callback function in order to find the required entry
882
+ * @param data data that is passed as second argument to the callback function
883
+ */
884
+ transform(value, func, data) {
885
+ if (!value) {
886
+ return false;
887
+ }
888
+ return value.findIndex((v) => func(v, data)) > -1;
889
+ }
890
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ContainsPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
891
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: ContainsPipe, name: "contains" }); }
892
+ }
893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ContainsPipe, decorators: [{
894
+ type: Pipe,
895
+ args: [{
896
+ name: 'contains',
897
+ }]
898
+ }] });
899
+
900
+ class ContainsModule {
901
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ContainsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
902
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: ContainsModule, declarations: [ContainsPipe], imports: [CommonModule], exports: [ContainsPipe] }); }
903
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ContainsModule, imports: [CommonModule] }); }
904
+ }
905
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ContainsModule, decorators: [{
906
+ type: NgModule,
907
+ args: [{
908
+ imports: [CommonModule],
909
+ declarations: [ContainsPipe],
910
+ exports: [ContainsPipe],
911
+ }]
912
+ }] });
913
+
914
+ class FilterPipe {
915
+ /**
916
+ * @param value list that will be filtered
917
+ * @param predicate function to test each value element
918
+ * @param param optional additional parameter that is passed into the predicate function
919
+ */
920
+ transform(value, predicate, param) {
921
+ if (!value) {
922
+ return undefined;
923
+ }
924
+ return value.filter((v) => predicate(v, param));
925
+ }
926
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FilterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
927
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: FilterPipe, name: "filter" }); }
928
+ }
929
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FilterPipe, decorators: [{
930
+ type: Pipe,
931
+ args: [{
932
+ name: 'filter',
933
+ }]
934
+ }] });
935
+
936
+ class FilterModule {
937
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FilterModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
938
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: FilterModule, declarations: [FilterPipe], imports: [CommonModule], exports: [FilterPipe] }); }
939
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FilterModule, imports: [CommonModule] }); }
940
+ }
941
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FilterModule, decorators: [{
942
+ type: NgModule,
943
+ args: [{
944
+ imports: [CommonModule],
945
+ declarations: [FilterPipe],
946
+ exports: [FilterPipe],
947
+ }]
948
+ }] });
949
+
950
+ class FindPipe {
951
+ /**
952
+ *
953
+ * @param value data that is searched
954
+ * @param func callback function in order to find the required entry
955
+ * @param data data that is passed as second argument to the callback function
956
+ */
957
+ transform(value, func, data) {
958
+ if (!value) {
959
+ return undefined;
960
+ }
961
+ return value.find((v) => func(v, data));
962
+ }
963
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FindPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
964
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: FindPipe, name: "find" }); }
965
+ }
966
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FindPipe, decorators: [{
967
+ type: Pipe,
968
+ args: [{
969
+ name: 'find',
970
+ }]
971
+ }] });
972
+
973
+ class FindModule {
974
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FindModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
975
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: FindModule, declarations: [FindPipe], imports: [CommonModule], exports: [FindPipe] }); }
976
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FindModule, imports: [CommonModule] }); }
977
+ }
978
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FindModule, decorators: [{
979
+ type: NgModule,
980
+ args: [{
981
+ imports: [CommonModule],
982
+ declarations: [FindPipe],
983
+ exports: [FindPipe],
984
+ }]
985
+ }] });
986
+
987
+ class MapPipe {
988
+ transform(value, func) {
989
+ if (!value) {
990
+ return undefined;
991
+ }
992
+ return value.map(func);
993
+ }
994
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MapPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
995
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: MapPipe, name: "map" }); }
996
+ }
997
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MapPipe, decorators: [{
998
+ type: Pipe,
999
+ args: [{
1000
+ name: 'map',
1001
+ }]
1002
+ }] });
1003
+
1004
+ class MapModule {
1005
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1006
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: MapModule, declarations: [MapPipe], imports: [CommonModule], exports: [MapPipe] }); }
1007
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MapModule, imports: [CommonModule] }); }
1008
+ }
1009
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MapModule, decorators: [{
1010
+ type: NgModule,
1011
+ args: [{
1012
+ imports: [CommonModule],
1013
+ declarations: [MapPipe],
1014
+ exports: [MapPipe],
1015
+ }]
1016
+ }] });
1017
+
1018
+ /**
1019
+ * local time format: hours with optional minutes
1020
+ * valid: 9, 9:00, 9:30, 9:30:59
1021
+ */
1022
+ const hoursMinutesSecondsPattern = /^([0-1]?[0-9]|2[0-3])(:([0-5][0-9]))?(:([0-5][0-9]))?$/;
1023
+ /**
1024
+ * local time format: hours with optional minutes, seconds and fractions
1025
+ * valid: 9, 9:00, 9:30, 9:30:59, 9:30:59.843396
1026
+ */
1027
+ const hoursMinutesSecondsFractionsPattern = /^([0-1]?[0-9]|2[0-3])(:([0-5][0-9]))?(:([0-5][0-9]))?(.([0-9]+))?$/;
1028
+ /**
1029
+ * locale time format: minutes with optional hours
1030
+ * valid: 0, 30, 0:30, 12:00, 12:30
1031
+ */
1032
+ const minutesHoursPattern = /^(([0-1]?[0-9]|2[0-3]):)?([0-5][0-9])$/;
1033
+
1034
+ /**
1035
+ * Convert specified time string (hh:mm) to minutes of day. E.g. 2:01 to 121.
1036
+ *
1037
+ * @param timeString hours with optional minutes and seconds (e.g. 16:23)
1038
+ */
1039
+ function convertTimeToMinutes(timeString) {
1040
+ if (isBlank(timeString)) {
1041
+ return 0;
1042
+ }
1043
+ const match = timeString.match(hoursMinutesSecondsFractionsPattern);
1044
+ if (!match) {
1045
+ return 0;
1046
+ }
1047
+ const hours = parseInt(match[1] ?? '0', 10);
1048
+ const minutes = parseInt(match[3] ?? '0', 10);
1049
+ return hours * 60 + minutes;
1050
+ }
1051
+ /**
1052
+ * convert 61 to 1:01
1053
+ *
1054
+ * @param minutes
1055
+ */
1056
+ function convertMinutesToTime(minutes) {
1057
+ if (isUndefined(minutes)) {
1058
+ return '';
1059
+ }
1060
+ const hoursFragment = Math.floor(minutes / 60);
1061
+ const minutesFragment = minutes - hoursFragment * 60;
1062
+ const minutesFragmentString = minutesFragment.toString().padStart(2, '0');
1063
+ return `${hoursFragment}:${minutesFragmentString}`;
1064
+ }
1065
+ /**
1066
+ * reformat e.g. "9" to "9:00:00"
1067
+ *
1068
+ * @param timeString hours with optional minutes
1069
+ * @param includeSeconds set to false (default: true) when seconds shall not be displayed
1070
+ */
1071
+ function formatLocalTimeString(timeString, includeSeconds = true) {
1072
+ if (isBlank(timeString)) {
1073
+ return includeSeconds ? '0:00:00' : '0:00';
1074
+ }
1075
+ const match = timeString.match(hoursMinutesSecondsPattern);
1076
+ if (!match) {
1077
+ return includeSeconds ? '0:00:00' : '0:00';
1078
+ }
1079
+ if (isDefined(match[5])) {
1080
+ return includeSeconds ? timeString : `${match[1]}:${match[3]}`;
1081
+ }
1082
+ if (isDefined(match[3])) {
1083
+ return includeSeconds
1084
+ ? `${match[1]}:${match[3]}:00`
1085
+ : `${match[1]}:${match[3]}`;
1086
+ }
1087
+ return timeString + (includeSeconds ? ':00:00' : ':00');
1088
+ }
1089
+ /**
1090
+ * reformat e.g. 45 to "0:45"
1091
+ *
1092
+ * @param timeString minutes with optional hours
1093
+ */
1094
+ function formatDurationString(timeString) {
1095
+ if (isBlank(timeString)) {
1096
+ return '0:00';
1097
+ }
1098
+ const match = timeString.match(minutesHoursPattern);
1099
+ if (!match) {
1100
+ // -- try to handle minutes e.g. "90" which should "1:30"
1101
+ const timeNumber = parseInt(timeString, 10);
1102
+ if (isNaN(timeNumber)) {
1103
+ return '0:00';
1104
+ }
1105
+ return convertMinutesToTime(timeNumber);
1106
+ }
1107
+ if (timeString.includes(':')) {
1108
+ return timeString;
1109
+ }
1110
+ return '0:' + timeString;
1111
+ }
1112
+ /**
1113
+ * convert e.g. 1000ms to 1s
1114
+ *
1115
+ * @param ms milliseconds
1116
+ * @return seconds
1117
+ */
1118
+ function convertMsToSeconds(ms) {
1119
+ return Math.floor(ms / 1000);
1120
+ }
1121
+ /**
1122
+ * convert e.g. 1s to 1000ms
1123
+ *
1124
+ * @param second
1125
+ * @return milliseconds
1126
+ */
1127
+ function convertSecondsToMs(second) {
1128
+ return Math.floor(second * 1000);
1129
+ }
1130
+
1131
+ class MinutesPipe {
1132
+ transform(minutes) {
1133
+ if (isUndefined(minutes)) {
1134
+ return undefined;
1135
+ }
1136
+ return convertMinutesToTime(minutes);
1137
+ }
1138
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MinutesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1139
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: MinutesPipe, name: "minutes" }); }
1140
+ }
1141
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MinutesPipe, decorators: [{
1142
+ type: Pipe,
1143
+ args: [{
1144
+ name: 'minutes',
1145
+ }]
1146
+ }] });
1147
+
1148
+ class DurationMinutesPipe {
1149
+ transform(minutes) {
1150
+ if (isUndefined(minutes)) {
1151
+ return undefined;
1152
+ }
1153
+ return formatDurationString(minutes.toString());
1154
+ }
1155
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: DurationMinutesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1156
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: DurationMinutesPipe, name: "durationMinutes" }); }
1157
+ }
1158
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: DurationMinutesPipe, decorators: [{
1159
+ type: Pipe,
1160
+ args: [{
1161
+ name: 'durationMinutes',
1162
+ }]
1163
+ }] });
1164
+
1165
+ class MinutesModule {
1166
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MinutesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1167
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: MinutesModule, declarations: [MinutesPipe, DurationMinutesPipe], imports: [CommonModule], exports: [MinutesPipe, DurationMinutesPipe] }); }
1168
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MinutesModule, imports: [CommonModule] }); }
1169
+ }
1170
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: MinutesModule, decorators: [{
1171
+ type: NgModule,
1172
+ args: [{
1173
+ imports: [CommonModule],
1174
+ declarations: [MinutesPipe, DurationMinutesPipe],
1175
+ exports: [MinutesPipe, DurationMinutesPipe],
1176
+ }]
1177
+ }] });
1178
+
1179
+ class SelectFromArrayPipe {
1180
+ transform(value, index) {
1181
+ if (!value) {
1182
+ return undefined;
1183
+ }
1184
+ return value[index];
1185
+ }
1186
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: SelectFromArrayPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1187
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: SelectFromArrayPipe, name: "selectFromArray" }); }
1188
+ }
1189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: SelectFromArrayPipe, decorators: [{
1190
+ type: Pipe,
1191
+ args: [{
1192
+ name: 'selectFromArray',
1193
+ }]
1194
+ }] });
1195
+
1196
+ class ArrayModule {
1197
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ArrayModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1198
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: ArrayModule, declarations: [SelectFromArrayPipe], imports: [CommonModule], exports: [SelectFromArrayPipe] }); }
1199
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ArrayModule, imports: [CommonModule] }); }
1200
+ }
1201
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ArrayModule, decorators: [{
1202
+ type: NgModule,
1203
+ args: [{
1204
+ imports: [CommonModule],
1205
+ declarations: [SelectFromArrayPipe],
1206
+ exports: [SelectFromArrayPipe],
1207
+ }]
1208
+ }] });
1209
+
1210
+ class TransformPipe {
1211
+ transform(value, func) {
1212
+ if (isUndefined(value)) {
1213
+ return undefined;
1214
+ }
1215
+ return func(value);
1216
+ }
1217
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TransformPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1218
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: TransformPipe, isStandalone: true, name: "transform" }); }
1219
+ }
1220
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TransformPipe, decorators: [{
1221
+ type: Pipe,
1222
+ args: [{
1223
+ name: 'transform',
1224
+ standalone: true,
1225
+ }]
1226
+ }] });
1227
+
1228
+ class FallbackPipe {
1229
+ transform(value, fallback) {
1230
+ if (isUndefined(value)) {
1231
+ return fallback;
1232
+ }
1233
+ if (typeof value === 'string' && isBlank(value)) {
1234
+ return fallback;
1235
+ }
1236
+ return value;
1237
+ }
1238
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FallbackPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1239
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: FallbackPipe, isStandalone: true, name: "fallback" }); }
1240
+ }
1241
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: FallbackPipe, decorators: [{
1242
+ type: Pipe,
1243
+ args: [{
1244
+ name: 'fallback',
1245
+ standalone: true,
1246
+ }]
1247
+ }] });
1248
+
1249
+ var Comparator;
1250
+ (function (Comparator) {
1251
+ Comparator["SIM"] = "sim";
1252
+ Comparator["NSIM"] = "nsim";
1253
+ Comparator["EQ"] = "eq";
1254
+ Comparator["NEQ"] = "neq";
1255
+ Comparator["LEQ"] = "leq";
1256
+ Comparator["LESS"] = "less";
1257
+ Comparator["GEQ"] = "geq";
1258
+ Comparator["GTR"] = "gtr";
1259
+ })(Comparator || (Comparator = {}));
1260
+ /**
1261
+ * Store that hold the active requests parameters for a table.
1262
+ */
1263
+ class RequestParamsHolder {
1264
+ constructor() {
1265
+ this.destroy$ = new Subject();
1266
+ this._params$ = new BehaviorSubject({
1267
+ pageParams: undefined,
1268
+ filterParams: undefined,
1269
+ sortParams: undefined,
1270
+ });
1271
+ this.params$ = this._params$.pipe(takeUntil(this.destroy$), distinctUntilChanged(isEqual));
1272
+ }
1273
+ get params() {
1274
+ return this._params$.getValue();
1275
+ }
1276
+ /**
1277
+ * Update/patch specified params. All other params remain untouched.
1278
+ * In order to remove params, they must be provided with the value 'undefined'
1279
+ *
1280
+ * @param params to be updated
1281
+ */
1282
+ updateParam(params) {
1283
+ const value = {
1284
+ ...this._params$.getValue(),
1285
+ ...cloneDeep(params),
1286
+ };
1287
+ this._params$.next(isDevMode() ? deepFreeze(value) : value);
1288
+ }
1289
+ destroy() {
1290
+ this.destroy$.next(null);
1291
+ this.destroy$.complete();
1292
+ }
1293
+ }
1294
+
1295
+ class AbstractWskDataSource extends DataSource {
1296
+ constructor() {
1297
+ super(...arguments);
1298
+ this._destroy$ = new Subject();
1299
+ this.load$ = new Subject();
1300
+ this._data$ = new BehaviorSubject([]);
1301
+ this.data$ = this._data$.pipe(takeUntil(this._destroy$));
1302
+ this.destroy$ = this._destroy$.asObservable();
1303
+ this._totalElements$ = new BehaviorSubject(0);
1304
+ /**
1305
+ * Stream of current amount of all available elements.
1306
+ */
1307
+ this.totalElements$ = this._totalElements$.pipe(takeUntil(this.destroy$));
1308
+ this._loading$ = new BehaviorSubject(false);
1309
+ /**
1310
+ * data is requested
1311
+ */
1312
+ this.loading$ = this._loading$.pipe(takeUntil(this.destroy$));
1313
+ this._requestParams = new RequestParamsHolder();
1314
+ }
1315
+ get totalElements() {
1316
+ return this._totalElements$.value;
1317
+ }
1318
+ get data() {
1319
+ return this._data$.value;
1320
+ }
1321
+ get requestParams() {
1322
+ return this._requestParams;
1323
+ }
1324
+ connect() {
1325
+ return combineLatest([
1326
+ this.load$.pipe(startWith('replace')),
1327
+ this.requestParams.params$.pipe(tap((params) => this.onRequestParamsChange(params))),
1328
+ ]).pipe(takeUntil(this.destroy$), tap(() => this._loading$.next(true)), switchMap$1(([mode, params]) => this.cb({
1329
+ ...params,
1330
+ pageParams: this.buildPageParams(params),
1331
+ }).pipe(tap({
1332
+ next: () => this._loading$.next(false),
1333
+ error: () => this._loading$.next(false),
1334
+ }), catchError(() => of(void 0)), filter((ret) => isDefined(ret)), map((ret) => [mode, ret]))), tap(([mode, page]) => {
1335
+ this._totalElements$.next(page.totalElements);
1336
+ this.storeNewData(mode, page);
1337
+ }), map(() => this.data));
1338
+ }
1339
+ disconnect() {
1340
+ this._destroy$.next();
1341
+ this._destroy$.complete();
1342
+ this._requestParams.destroy();
1343
+ }
1344
+ }
1345
+
1346
+ class WskDataSource extends AbstractWskDataSource {
1347
+ constructor(cb, defaultRequestParams) {
1348
+ super();
1349
+ this.cb = cb;
1350
+ if (defaultRequestParams) {
1351
+ this.requestParams.updateParam(defaultRequestParams);
1352
+ }
1353
+ }
1354
+ reload() {
1355
+ this.load$.next();
1356
+ }
1357
+ buildPageParams(params) {
1358
+ return params.pageParams;
1359
+ }
1360
+ storeNewData(_mode, page) {
1361
+ this._data$.next(page.content);
1362
+ }
1363
+ hasMore() {
1364
+ if (isUndefined(this.requestParams.params.pageParams)) {
1365
+ return false;
1366
+ }
1367
+ const { page, size } = this.requestParams.params.pageParams;
1368
+ return (page + 1) * size < this.totalElements;
1369
+ }
1370
+ onRequestParamsChange() {
1371
+ // nop
1372
+ }
1373
+ }
1374
+
1375
+ class WskLazyDataSource extends AbstractWskDataSource {
1376
+ constructor(cb, defaultRequestParams, batchSize = 15) {
1377
+ super();
1378
+ this.cb = cb;
1379
+ this.batchSize = batchSize;
1380
+ this.offset = 0;
1381
+ this.requestSize = batchSize;
1382
+ if (defaultRequestParams) {
1383
+ this.requestParams.updateParam(defaultRequestParams);
1384
+ }
1385
+ }
1386
+ hasMore() {
1387
+ return this.totalElements > this.data.length;
1388
+ }
1389
+ /**
1390
+ * Reload current page
1391
+ */
1392
+ reload() {
1393
+ this.requestSize = this.offset + this.requestSize;
1394
+ this.offset = 0;
1395
+ this.load$.next('replace');
1396
+ }
1397
+ storeNewData(mode, page) {
1398
+ if (mode === 'append') {
1399
+ this._data$.next([...this.data, ...page.content]);
1400
+ }
1401
+ else if (mode === 'replace') {
1402
+ this._data$.next(page.content);
1403
+ }
1404
+ }
1405
+ buildPageParams() {
1406
+ return {
1407
+ page: this.offset / this.requestSize,
1408
+ size: this.requestSize,
1409
+ };
1410
+ }
1411
+ appendNextPage() {
1412
+ if (!this.hasMore()) {
1413
+ return;
1414
+ }
1415
+ if (this._loading$.getValue()) {
1416
+ return;
1417
+ }
1418
+ this.offset = this.offset + this.requestSize;
1419
+ this.requestSize = this.batchSize;
1420
+ this.load$.next('append');
1421
+ }
1422
+ onRequestParamsChange() {
1423
+ this.requestSize = this.batchSize;
1424
+ this.offset = 0;
1425
+ this._data$.next([]);
1426
+ }
1427
+ }
1428
+
1429
+ /**
1430
+ * 2020-04-28
1431
+ *
1432
+ * @param date
1433
+ */
1434
+ function getLocalDateString(date) {
1435
+ if (isUndefined(date)) {
1436
+ return null;
1437
+ }
1438
+ if (typeof date === 'string') {
1439
+ date = new Date(date);
1440
+ }
1441
+ if (date instanceof Date) {
1442
+ const year = date.getFullYear();
1443
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
1444
+ const dateD = date.getDate().toString().padStart(2, '0');
1445
+ return `${year}-${month}-${dateD}`;
1446
+ }
1447
+ return null;
1448
+ }
1449
+ /**
1450
+ * Formats a date according to locale rules.
1451
+ * If value is undefined or null return empty string, else return the formatted date string.
1452
+ *
1453
+ * @param value The date to format, as a Date or a number
1454
+ * @param format The date-time components to include, using predefined options or a custom format string
1455
+ * @param locale A locale code for the locale format rules to use
1456
+ * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`)
1457
+ *
1458
+ */
1459
+ function formatDateWithFallback(value, format, locale, timezone) {
1460
+ if (value === undefined || value === null) {
1461
+ return '';
1462
+ }
1463
+ else {
1464
+ return formatDate(value, format, locale, timezone);
1465
+ }
1466
+ }
1467
+
1468
+ /**
1469
+ * Use the browser time and time zone to get a time zone free date (i.e. a UTC based date) of the beginning of today.
1470
+ *
1471
+ * @param todayDate current date with timezone
1472
+ * @returns {Date}
1473
+ */
1474
+ function getTodayAsUtc(todayDate) {
1475
+ if (!(todayDate instanceof Date)) {
1476
+ return todayDate;
1477
+ }
1478
+ // shift the date to today's day (from UTC perspective); effectively removes the timezone information from the date
1479
+ todayDate = new Date(todayDate.getTime() - todayDate.getTimezoneOffset() * 60 * 1000);
1480
+ // set the new date to the start of the day
1481
+ todayDate.setUTCHours(0, 0, 0, 0);
1482
+ return todayDate;
1483
+ }
1484
+ function zonedTimeToUtc(date) {
1485
+ return new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
1486
+ }
1487
+
1488
+ function hexToRGB(hex) {
1489
+ return {
1490
+ r: parseInt(hex.substring(1, 3), 16),
1491
+ g: parseInt(hex.substring(3, 5), 16),
1492
+ b: parseInt(hex.substring(5, 7), 16),
1493
+ };
1494
+ }
1495
+ function calculateLuminance(rgb) {
1496
+ const a = [rgb.r, rgb.g, rgb.b].map((v) => {
1497
+ v /= 255;
1498
+ return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
1499
+ });
1500
+ return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2];
1501
+ }
1502
+ const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
1503
+ function getContrastTextColor(hexColor, light = '#ffffff', dark = '#000000') {
1504
+ if (!hexColorRegex.test(hexColor)) {
1505
+ return dark;
1506
+ }
1507
+ const rgbColor = hexToRGB(hexColor);
1508
+ const luminance = calculateLuminance(rgbColor);
1509
+ return luminance > 0.5 ? dark : light;
1510
+ }
1511
+
1512
+ function decorateLinks(element, renderer, router, extras, commandHandler, hrefHandler) {
1513
+ element.querySelectorAll('a').forEach((a) => {
1514
+ if (a.hasAttribute('data-link')) {
1515
+ return;
1516
+ }
1517
+ const href = a.getAttribute('href');
1518
+ if (isUndefined(href)) {
1519
+ return;
1520
+ }
1521
+ if (href.startsWith('http')) {
1522
+ return;
1523
+ }
1524
+ if (isDefined(hrefHandler)) {
1525
+ renderer.setAttribute(a, 'href', hrefHandler(href));
1526
+ }
1527
+ a.setAttribute('data-link', href);
1528
+ const commands = isUndefined(commandHandler)
1529
+ ? [href]
1530
+ : commandHandler(href);
1531
+ renderer.listen(a, 'click', (evt) => {
1532
+ evt.stopPropagation();
1533
+ evt.preventDefault();
1534
+ router.navigate(commands, extras);
1535
+ });
1536
+ });
1537
+ }
1538
+
1539
+ class LetDirective {
1540
+ constructor(viewContainer, templateRef) {
1541
+ this.context = { wskLet: null };
1542
+ viewContainer.createEmbeddedView(templateRef, this.context);
1543
+ }
1544
+ set wskLet(value) {
1545
+ this.context.wskLet = value;
1546
+ }
1547
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: LetDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
1548
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: LetDirective, isStandalone: true, selector: "[wskLet]", inputs: { wskLet: "wskLet" }, ngImport: i0 }); }
1549
+ }
1550
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: LetDirective, decorators: [{
1551
+ type: Directive,
1552
+ args: [{
1553
+ selector: '[wskLet]',
1554
+ standalone: true,
1555
+ }]
1556
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }], propDecorators: { wskLet: [{
1557
+ type: Input
1558
+ }] } });
1559
+
1560
+ function registerWebComponent(tagName, component, injector) {
1561
+ if (isDefined(customElements.get(tagName))) {
1562
+ return;
1563
+ }
1564
+ const elem = createCustomElement(component, { injector });
1565
+ customElements.define(tagName, elem);
1566
+ }
1567
+
1568
+ /**
1569
+ * Recursively remove all fields from an object with given names.
1570
+ *
1571
+ * @param obj object that will be modified
1572
+ * @param keys array of keys that will be removed
1573
+ */
1574
+ function removeKeys(obj, ...keys) {
1575
+ for (const prop in obj) {
1576
+ if (Object.prototype.hasOwnProperty.call(obj, prop)) {
1577
+ if (keys.includes(prop)) {
1578
+ delete obj[prop];
1579
+ }
1580
+ else if (typeof obj[prop] === 'object') {
1581
+ removeKeys(obj[prop], ...keys);
1582
+ }
1583
+ }
1584
+ }
1585
+ }
1586
+
1587
+ /**
1588
+ * Test whether the specified is within the rectangle.
1589
+ *
1590
+ * @param {Point} p
1591
+ * @param {Rect} b
1592
+ * @returns {boolean}
1593
+ */
1594
+ function isInRect(p, b) {
1595
+ return p.x >= b.tl.x && p.x <= b.br.x && p.y >= b.tl.y && p.y <= b.br.y;
1596
+ }
1597
+
1598
+ function isElementInViewport(el) {
1599
+ const rect = el.nativeElement.getBoundingClientRect();
1600
+ // const w = rect.width;
1601
+ // const h = rect.height;
1602
+ const box = {
1603
+ tl: { x: 0, y: 0 },
1604
+ br: {
1605
+ x: window.innerWidth || document.documentElement.clientWidth,
1606
+ y: window.innerHeight || document.documentElement.clientHeight,
1607
+ },
1608
+ };
1609
+ const tl = { x: rect.left, y: rect.top };
1610
+ const tr = { x: rect.right, y: rect.top };
1611
+ const bl = { x: rect.left, y: rect.bottom };
1612
+ const br = { x: rect.right, y: rect.bottom };
1613
+ return (isInRect(tl, box) ||
1614
+ isInRect(tr, box) ||
1615
+ isInRect(bl, box) ||
1616
+ isInRect(br, box));
1617
+ }
1618
+
1619
+ const DECIMAL_SEPARATOR = new InjectionToken('DecimalSeparator');
1620
+
1621
+ class AbstractControlValueAccessor {
1622
+ constructor(_renderer, _elementRef) {
1623
+ this._renderer = _renderer;
1624
+ this._elementRef = _elementRef;
1625
+ this.onChange = () => {
1626
+ // nop
1627
+ };
1628
+ this.onTouched = () => {
1629
+ // nop
1630
+ };
1631
+ }
1632
+ setProperty(key, value) {
1633
+ this._renderer.setProperty(this._elementRef.nativeElement, key, value);
1634
+ }
1635
+ registerOnChange(fn) {
1636
+ this.onChange = fn;
1637
+ }
1638
+ registerOnTouched(fn) {
1639
+ this.onTouched = fn;
1640
+ }
1641
+ setDisabledState(isDisabled) {
1642
+ this.setProperty('disabled', isDisabled);
1643
+ }
1644
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AbstractControlValueAccessor, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
1645
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.3", type: AbstractControlValueAccessor, ngImport: i0 }); }
1646
+ }
1647
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AbstractControlValueAccessor, decorators: [{
1648
+ type: Directive
1649
+ }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }] });
1650
+
1651
+ /**
1652
+ * Create a validator function that tests for an int value.
1653
+ */
1654
+ function int() {
1655
+ return (control) => {
1656
+ const value = control.value;
1657
+ if (isUndefined(value)) {
1658
+ return null;
1659
+ }
1660
+ if (isBlank(value)) {
1661
+ return null;
1662
+ }
1663
+ if (typeof value !== 'string') {
1664
+ return { int: true };
1665
+ }
1666
+ if (value.match(intPattern)) {
1667
+ return null;
1668
+ }
1669
+ return { int: true };
1670
+ };
1671
+ }
1672
+ /**
1673
+ * Create a validator function that tests for a float value.
1674
+ *
1675
+ * @param separator
1676
+ * @param decimalPlaces
1677
+ */
1678
+ function float(separator = '.', decimalPlaces) {
1679
+ const _floatPattern = decimalPlaces ?? 0 > 1
1680
+ ? `^[0-9]+(\\.[0-9]{1,${decimalPlaces}})?$`
1681
+ : floatPattern;
1682
+ return (control) => {
1683
+ let value = control.value;
1684
+ if (typeof value === 'number') {
1685
+ value = value.toString(10);
1686
+ }
1687
+ else if (typeof value === 'string') {
1688
+ if (isBlank(value)) {
1689
+ return null;
1690
+ }
1691
+ }
1692
+ else {
1693
+ return { float: true };
1694
+ }
1695
+ if (separator === ',') {
1696
+ const match = value.replace(',', '.').match(_floatPattern);
1697
+ if (match) {
1698
+ return null;
1699
+ }
1700
+ }
1701
+ else {
1702
+ if (value.match(_floatPattern)) {
1703
+ return null;
1704
+ }
1705
+ }
1706
+ return { float: true };
1707
+ };
1708
+ }
1709
+ /**
1710
+ * Create a validator function that tests for local time format.
1711
+ * Valid values e.g.: 9, 9:00, 9:30
1712
+ */
1713
+ function localTime() {
1714
+ return (control) => {
1715
+ const value = control.value;
1716
+ if (isBlank(value)) {
1717
+ return null;
1718
+ }
1719
+ if (typeof value !== 'string') {
1720
+ return { localTime: true };
1721
+ }
1722
+ if (value.match(hoursMinutesSecondsPattern)) {
1723
+ return null;
1724
+ }
1725
+ return { localTime: true };
1726
+ };
1727
+ }
1728
+ /**
1729
+ * Create a validator function that tests for duration format.
1730
+ * Valid values e.g.: 0, 30, 0:30, 12:00, 12:30
1731
+ */
1732
+ function duration() {
1733
+ return (control) => {
1734
+ const value = control.value;
1735
+ if (isBlank(value)) {
1736
+ return null;
1737
+ }
1738
+ if (typeof value !== 'string') {
1739
+ return { duration: true };
1740
+ }
1741
+ if (value.match(minutesHoursPattern)) {
1742
+ return null;
1743
+ }
1744
+ return { duration: true };
1745
+ };
1746
+ }
1747
+
1748
+ /**
1749
+ * remove FormControlError and the Error Object itself if empty
1750
+ *
1751
+ * @param control FormControl which has the error
1752
+ * @param errorName Name of Errorkey
1753
+ */
1754
+ function removeFormControlError(control, errorName) {
1755
+ if (control?.errors && control?.errors[errorName]) {
1756
+ delete control.errors[errorName];
1757
+ if (Object.keys(control.errors).length === 0) {
1758
+ control.setErrors(null);
1759
+ }
1760
+ }
1761
+ }
1762
+ /**
1763
+ * updates FormControlError
1764
+ *
1765
+ * @param control FormControl which has the error
1766
+ * @param errorName Name of Errorkey
1767
+ * @param flag Boolean
1768
+ */
1769
+ function updateFormControlError(control, errorName, flag) {
1770
+ if (flag) {
1771
+ const error = control?.errors ?? {};
1772
+ error[errorName] = flag;
1773
+ control?.setErrors(error);
1774
+ control?.markAsTouched();
1775
+ }
1776
+ else {
1777
+ removeFormControlError(control, errorName);
1778
+ }
1779
+ }
1780
+
1781
+ function indicate(indicator) {
1782
+ return (source) => source.pipe(prepare(() => indicator.next(true)), finalize(() => {
1783
+ indicator.next(false);
1784
+ }));
1785
+ }
1786
+ /**
1787
+ * Invokes a callback upon subscription.
1788
+ *
1789
+ * @param callback function to invoke upon subscription
1790
+ * @returns stream which will invoke callback
1791
+ */
1792
+ function prepare(callback) {
1793
+ return (source) => defer(() => {
1794
+ callback();
1795
+ return source;
1796
+ });
1797
+ }
1798
+
1799
+ function instanceOfOnChanges(object) {
1800
+ return 'ngOnChanges' in object;
1801
+ }
1802
+
1803
+ /**
1804
+ * Generated bundle index. Do not edit.
1805
+ */
1806
+
1807
+ export { AbstractControlValueAccessor, AbstractEntityStore, AbstractStore, AbstractWskDataSource, ArrayModule, AuthGuard, AuthStore, AuthenticationAdapter, AuthenticationService, Breakpoints, BrowserMetaService, BrowserTrackingService, CONFIG, CanDeactivateGuard, ClickTrackingDirective, Comparator, Config, ContainsModule, ContainsPipe, DECIMAL_SEPARATOR, DurationMinutesPipe, FallbackPipe, FilterModule, FilterPipe, FindModule, FindPipe, JwtAuthInterceptor, LetDirective, LoggingBackendAppender, MapModule, MapPipe, MinutesModule, MinutesPipe, NgErrorHandler, NotAuthGuard, PreviousRouteService, RequestParamsHolder, SelectFromArrayPipe, TimeAdapter, TimeService, TrackingAdapter, TrackingModule, TrackingService, TransformPipe, UserAdapter, UserService, WskDataSource, WskLazyDataSource, convertMinutesToTime, convertMsToSeconds, convertSecondsToMs, convertTimeToMinutes, decorateLinks, deepFreeze, duration, float, formatDateWithFallback, formatDurationString, formatLocalTimeString, getContrastTextColor, getLocalDateString, getTodayAsUtc, hoursMinutesSecondsFractionsPattern, hoursMinutesSecondsPattern, idCompare, indicate, instanceOfOnChanges, int, isElementInViewport, isInRect, localTime, minutesHoursPattern, prepare, registerWebComponent, removeFormControlError, removeKeys, updateFormControlError, zonedTimeToUtc };
1808
+ //# sourceMappingURL=webskills-ng-utils.mjs.map