@osovitny/core 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1540 @@
1
+ import { format } from 'date-fns';
2
+ import js_beautify from 'js-beautify';
3
+ import Swal from 'sweetalert2';
4
+ import { v4 } from 'uuid';
5
+ import { BrowserUtils } from '@azure/msal-browser';
6
+
7
+ /*!
8
+ * @osovitny/core
9
+ * Copyright (c) 2016-2026 Osovitny
10
+ * SPDX-License-Identifier: MIT
11
+ */
12
+ const SessionStorageKeys = {
13
+ appSettings: 'appSettings',
14
+ appMSALSettings: 'appMSALSettings'
15
+ };
16
+ const AppContextStorageKeys = {
17
+ version: 'version',
18
+ currency: 'currency',
19
+ //Lists
20
+ countries: 'countries',
21
+ languages: 'languages',
22
+ timezones: 'timezones',
23
+ usStates: 'usStates'
24
+ };
25
+
26
+ /*!
27
+ * @osovitny/core
28
+ * Copyright (c) 2016-2026 Osovitny
29
+ * SPDX-License-Identifier: MIT
30
+ */
31
+ //App
32
+ function getAppSettings() {
33
+ const json = sessionStorage.getItem(SessionStorageKeys.appSettings);
34
+ return json ? JSON.parse(json) : null;
35
+ }
36
+ function resetAppSettings() {
37
+ AppSettings = getAppSettings();
38
+ let isDevMode = `${AppSettings?.isDevMode}`;
39
+ AppVersion = `${AppSettings?.version}`;
40
+ IsDevMode = (isDevMode && (isDevMode == 'True' || isDevMode == 'true'));
41
+ IsProdMode = !IsDevMode;
42
+ ClientApps = AppSettings?.clientApps;
43
+ }
44
+ function getAppSettingsById(id) {
45
+ let apps = ClientApps;
46
+ if (apps && id) {
47
+ for (let i = 0; i < apps.length; i++) {
48
+ let app = apps[i];
49
+ if (app.id == id) {
50
+ return app;
51
+ }
52
+ }
53
+ }
54
+ return null;
55
+ }
56
+ function getAppSettingsByName(name) {
57
+ let apps = ClientApps;
58
+ if (apps && name) {
59
+ for (let i = 0; i < apps.length; i++) {
60
+ let app = apps[i];
61
+ if (app.name == name) {
62
+ return app;
63
+ }
64
+ }
65
+ }
66
+ return null;
67
+ }
68
+ function getCurrentApp() {
69
+ let appSettings = getAppSettingsByName(AppName);
70
+ let appOne = getAppSettingsById(1);
71
+ if (!appSettings || !appOne) {
72
+ return null;
73
+ }
74
+ return {
75
+ id: appSettings.id,
76
+ root: appSettings.root,
77
+ one: appOne,
78
+ oneUrl: appOne?.baseUrl + appOne?.root
79
+ };
80
+ }
81
+ let AppSettings;
82
+ let AppVersion;
83
+ let IsDevMode = true;
84
+ let IsProdMode = !IsDevMode;
85
+ let ClientApps;
86
+ const AppName = g_AppName;
87
+ const LibName = g_LibName;
88
+ const ApiUrl = g_ApiUrl;
89
+ resetAppSettings();
90
+
91
+ /*!
92
+ * @osovitny/core
93
+ * Copyright (c) 2016-2026 Osovitny
94
+ * SPDX-License-Identifier: MIT
95
+ */
96
+ var AssetGroupType;
97
+ (function (AssetGroupType) {
98
+ AssetGroupType[AssetGroupType["App"] = 1] = "App";
99
+ AssetGroupType[AssetGroupType["Lib"] = 2] = "Lib";
100
+ AssetGroupType[AssetGroupType["External"] = 3] = "External";
101
+ })(AssetGroupType || (AssetGroupType = {}));
102
+ /*
103
+ formatAssetsUrl builds a typed asset URL and delegates to formatUrl.
104
+
105
+ Output pattern: {base}/{AppName}/assets/{assetGroup}/{assetType}/{file}
106
+
107
+ assetGroup tokens:
108
+ App -> {AppName} e.g. "am"
109
+ Lib -> {LibName} e.g. "@nexl"
110
+ External -> external/{libname}
111
+
112
+ assetType:
113
+ jsons - JSON data files
114
+ l10n - localization files
115
+ images - image files
116
+
117
+ Examples (AppName = "am", LibName = "@nexl", CDN disabled):
118
+ App -> /am/assets/am/jsons/countries.json?v=1
119
+ Lib -> /am/assets/@nexl/l10n/en.json?v=1
120
+ External-> /am/assets/external/somelib/jsons/file.json?v=1
121
+
122
+ Examples (CDN = "https://cdn.novaexpress.ai"):
123
+ App -> https://cdn.novaexpress.ai/am/assets/am/jsons/countries.json
124
+ Lib -> https://cdn.novaexpress.ai/am/assets/@nexl/l10n/en.json
125
+ External-> https://cdn.novaexpress.ai/am/assets/external/somelib/jsons/file.json
126
+ */
127
+ function formatAssetsUrl(assetGroupType, url) {
128
+ const path = url.replace(/^\/+/, '');
129
+ switch (assetGroupType) {
130
+ case AssetGroupType.App:
131
+ return formatUrl(`assets/{AppName}/${path}`);
132
+ case AssetGroupType.Lib:
133
+ return formatUrl(`assets/{LibName}/${path}`);
134
+ case AssetGroupType.External:
135
+ return formatUrl(`assets/external/${path}`);
136
+ default:
137
+ return url;
138
+ }
139
+ }
140
+ /*
141
+ formatUrl resolves a relative URL to its final form.
142
+
143
+ Output pattern: {base}/{AppName}/{url}
144
+
145
+ Tokens in url are resolved before building the path:
146
+ {AppName} -> AppName (e.g. "am")
147
+ {LibName} -> LibName (e.g. "@nexl")
148
+
149
+ base:
150
+ CDN disabled -> "" (relative URL, e.g. /am/assets/...)
151
+ CDN enabled -> "https://cdn.novaexpress.ai"
152
+
153
+ Absolute URLs (starting with "http") are returned as-is.
154
+ */
155
+ function formatUrl(url) {
156
+ if (!url) {
157
+ return "";
158
+ }
159
+ if (url.startsWith("http")) {
160
+ return url;
161
+ }
162
+ if (!AppSettings) {
163
+ return url;
164
+ }
165
+ const version = AppSettings.version;
166
+ const isCDNEnabled = AppSettings.cdn?.enabled;
167
+ const cdnUrl = AppSettings.cdn?.url;
168
+ const resolved = url
169
+ .replace('{AppName}', AppName ?? '')
170
+ .replace('{LibName}', LibName ?? '');
171
+ const base = (isCDNEnabled && cdnUrl)
172
+ ? cdnUrl.replace(/\/+$/, '')
173
+ : '';
174
+ const fullUrl = base + '/' + AppName + '/' + resolved.replace(/^\/+/, '');
175
+ if (fullUrl.endsWith('.json')) {
176
+ return fullUrl + '?v=' + version;
177
+ }
178
+ return fullUrl;
179
+ }
180
+
181
+ /*!
182
+ * @osovitny/core
183
+ * Copyright (c) 2016-2026 Osovitny
184
+ * SPDX-License-Identifier: MIT
185
+ */
186
+ const dateTimeFormats = {
187
+ medium: 'dd MMM yyyy HH:mm'
188
+ };
189
+ const dateFormats = {
190
+ medium: "dd MMM yyyy",
191
+ short: "dd/MM/yyyy"
192
+ };
193
+ const timeFormats = {
194
+ medium: "HH:mm:ss",
195
+ short: "HH:mm"
196
+ };
197
+
198
+ /*!
199
+ * @osovitny/core
200
+ * Copyright (c) 2016-2026 Osovitny
201
+ * SPDX-License-Identifier: MIT
202
+ */
203
+ const GAEvents = {
204
+ login: {
205
+ signin: 'osa_login_signin',
206
+ signin_success: 'osa_login_signin_success',
207
+ signup: 'osa_login_signup',
208
+ signup_success: 'osa_login_signup_success'
209
+ }
210
+ };
211
+ const GABillingEvents = {
212
+ payment: 'osa_billing_payment'
213
+ };
214
+
215
+ /*!
216
+ * @osovitny/core
217
+ * Copyright (c) 2016-2026 Osovitny
218
+ * SPDX-License-Identifier: MIT
219
+ */
220
+ class is {
221
+ /**
222
+ * @name isDate
223
+ * @summary Is the given value a date?
224
+ */
225
+ static date(value) {
226
+ return (value instanceof Date ||
227
+ (typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"));
228
+ }
229
+ /**
230
+ * @name isDateValid
231
+ * @summary Is the given date valid?
232
+ */
233
+ static dateValid(date) {
234
+ if (!is.date(date) && typeof date !== "number") {
235
+ return false;
236
+ }
237
+ let d = new Date(date);
238
+ return !isNaN(Number(d));
239
+ }
240
+ static dateInvalid(date) {
241
+ return !is.dateValid(date);
242
+ }
243
+ static objectNullOrEmpty(obj) {
244
+ return !obj || Object.keys(obj).length == 0;
245
+ }
246
+ static string(value) {
247
+ return (typeof value === 'string' || value instanceof String);
248
+ }
249
+ static emptyString(value) {
250
+ return (is.string(value) && (value.length == 0));
251
+ }
252
+ static notEmptyString(value) {
253
+ return (is.string(value) && (value.length > 0));
254
+ }
255
+ static number(value) {
256
+ return (typeof value === 'number');
257
+ }
258
+ static boolean(value) {
259
+ return (typeof value === 'boolean');
260
+ }
261
+ static array(value) {
262
+ return (value instanceof Array);
263
+ }
264
+ static emptyArray(value) {
265
+ return (is.array(value) && (value.length == 0));
266
+ }
267
+ static notEmptyArray(value) {
268
+ return (is.array(value) && (value.length > 0));
269
+ }
270
+ static undefined(value) {
271
+ return (typeof value === 'undefined');
272
+ }
273
+ }
274
+ /*
275
+ is = {
276
+ DONE string: function (obj) { return (typeof obj === 'string'); },
277
+ DONE emptyString: function (obj) { return (is.string(obj) && (obj.length == 0)); },
278
+ DONE nonEmptyString: function (obj) { return (is.string(obj) && (obj.length > 0)); },
279
+ DONE number: function (obj) { return (typeof obj === 'number'); },
280
+ DONE bool: function (obj) { return (typeof obj === 'boolean'); },
281
+ DONE array: function (obj) { return (obj instanceof Array); },
282
+ DONE emptyArray: function (obj) { return (is.array(obj) && (obj.length == 0)); },
283
+ DONE notEmptyArray: function (obj) { return (is.array(obj) && (obj.length > 0)); },
284
+ DONE undefined: function (obj) { return (typeof obj === 'undefined'); },
285
+
286
+ 'null': function (obj) { return (obj === null); },
287
+ notNull: function (obj) { return (obj !== null); },
288
+ invalid: function (obj) { return (is['null'](obj) || is.undefined(obj)); },
289
+ valid: function (obj) { return (!is['null'](obj) && !is.undefined(obj)); },
290
+
291
+ document: function (obj) { return (obj === document); },
292
+ window: function (obj) { return (obj === window); },
293
+ element: function (obj) { return (obj instanceof HTMLElement); },
294
+ event: function (obj) { return (obj instanceof Event); },
295
+ link: function (obj) { return (is.element(obj) && (obj.tagName == 'A')); }
296
+ };
297
+ */
298
+
299
+ /*!
300
+ * @osovitny/core
301
+ * Copyright (c) 2016-2026 Osovitny
302
+ * SPDX-License-Identifier: MIT
303
+ */
304
+ class Convert {
305
+ static pad(number) {
306
+ if (number < 10) {
307
+ return '0' + number;
308
+ }
309
+ return number;
310
+ }
311
+ static enumToString(enumeration, value) {
312
+ for (let k in enumeration)
313
+ if (enumeration[k] == value)
314
+ return k;
315
+ return null;
316
+ }
317
+ static enumToArray(enumeration, valueAsInt = true, notIncludes) {
318
+ const notIncludeFiler = (value) => {
319
+ if (isNaN(Number(value))) {
320
+ return false;
321
+ }
322
+ if (notIncludes) {
323
+ for (let i in notIncludes) {
324
+ if (notIncludes[i] == value)
325
+ return false;
326
+ }
327
+ }
328
+ return true;
329
+ };
330
+ if (valueAsInt) {
331
+ return Object.keys(enumeration)
332
+ .filter(notIncludeFiler)
333
+ .map(key => ({
334
+ value: parseInt(key),
335
+ text: enumeration[key]
336
+ }));
337
+ }
338
+ else {
339
+ return Object.keys(enumeration)
340
+ .filter(notIncludeFiler)
341
+ .map(key => ({
342
+ value: key,
343
+ text: enumeration[key]
344
+ }));
345
+ }
346
+ }
347
+ static stringToArray(str, separator = ',') {
348
+ if (str) {
349
+ return str.split(separator).filter(element => element);
350
+ }
351
+ return [];
352
+ }
353
+ static stringToIntArray(str, separator = ',') {
354
+ if (str) {
355
+ return str.split(separator).filter(element => element).map(value => parseInt(value));
356
+ }
357
+ return [];
358
+ }
359
+ static company2String(comp) {
360
+ let company = JSON.parse(comp);
361
+ if (company) {
362
+ return `${company.name} ${company.phone} ${company.email} ${company.websiteUrl}`;
363
+ }
364
+ }
365
+ static address2String(adr) {
366
+ let address = JSON.parse(adr);
367
+ return `${address.street} ${address.street2} ${address.city} ${address.stateOrRegion} ${address.zipcode} ${address.country}`;
368
+ }
369
+ static stringToBoolean(value) {
370
+ if (value) {
371
+ if (is.boolean(value)) {
372
+ return value;
373
+ }
374
+ if (is.string(value)) {
375
+ switch (value.toLowerCase().trim()) {
376
+ case "true":
377
+ case "yes":
378
+ case "1":
379
+ return true;
380
+ case "false":
381
+ case "no":
382
+ case "0":
383
+ case null:
384
+ return false;
385
+ }
386
+ }
387
+ }
388
+ return false;
389
+ }
390
+ }
391
+
392
+ /*!
393
+ * @osovitny/core
394
+ * Copyright (c) 2016-2026 Osovitny
395
+ * SPDX-License-Identifier: MIT
396
+ */
397
+ /**
398
+ * Returns the [year, month, day, hour, minute, seconds] tokens of the provided
399
+ * `date` as it will be rendered in the `timeZone`.
400
+ */
401
+ function tzTokenizeDate(date, timeZone) {
402
+ var dtf = getDateTimeFormat(timeZone);
403
+ return dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date);
404
+ }
405
+ var typeToPos = {
406
+ year: 0,
407
+ month: 1,
408
+ day: 2,
409
+ hour: 3,
410
+ minute: 4,
411
+ second: 5,
412
+ };
413
+ function partsOffset(dtf, date) {
414
+ try {
415
+ var formatted = dtf.formatToParts(date);
416
+ var filled = [];
417
+ for (var i = 0; i < formatted.length; i++) {
418
+ var pos = typeToPos[formatted[i].type];
419
+ if (pos >= 0) {
420
+ filled[pos] = parseInt(formatted[i].value, 10);
421
+ }
422
+ }
423
+ return filled;
424
+ }
425
+ catch (error) {
426
+ if (error instanceof RangeError) {
427
+ return [NaN];
428
+ }
429
+ throw error;
430
+ }
431
+ }
432
+ function hackyOffset(dtf, date) {
433
+ var formatted = dtf.format(date).replace(/\u200E/g, '');
434
+ var parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted);
435
+ // var [, fMonth, fDay, fYear, fHour, fMinute, fSecond] = parsed
436
+ // return [fYear, fMonth, fDay, fHour, fMinute, fSecond]
437
+ return [parsed[3], parsed[1], parsed[2], parsed[4], parsed[5], parsed[6]];
438
+ }
439
+ // Get a cached Intl.DateTimeFormat instance for the IANA `timeZone`. This can be used
440
+ // to get deterministic local date/time output according to the `en-US` locale which
441
+ // can be used to extract local time parts as necessary.
442
+ var dtfCache = {};
443
+ function getDateTimeFormat(timeZone) {
444
+ if (!dtfCache[timeZone]) {
445
+ // New browsers use `hourCycle`, IE and Chrome <73 does not support it and uses `hour12`
446
+ var testDateFormatted = new Intl.DateTimeFormat('en-US', {
447
+ hour12: false,
448
+ timeZone: 'America/New_York',
449
+ year: 'numeric',
450
+ month: 'numeric',
451
+ day: '2-digit',
452
+ hour: '2-digit',
453
+ minute: '2-digit',
454
+ second: '2-digit',
455
+ }).format(new Date('2014-06-25T04:00:00.123Z'));
456
+ var hourCycleSupported = testDateFormatted === '06/25/2014, 00:00:00' ||
457
+ testDateFormatted === '06/25/2014 00:00:00';
458
+ dtfCache[timeZone] = hourCycleSupported
459
+ ? new Intl.DateTimeFormat('en-US', {
460
+ hour12: false,
461
+ timeZone: timeZone,
462
+ year: 'numeric',
463
+ month: 'numeric',
464
+ day: '2-digit',
465
+ hour: '2-digit',
466
+ minute: '2-digit',
467
+ second: '2-digit',
468
+ })
469
+ : new Intl.DateTimeFormat('en-US', {
470
+ hourCycle: 'h23',
471
+ timeZone: timeZone,
472
+ year: 'numeric',
473
+ month: 'numeric',
474
+ day: '2-digit',
475
+ hour: '2-digit',
476
+ minute: '2-digit',
477
+ second: '2-digit',
478
+ });
479
+ }
480
+ return dtfCache[timeZone];
481
+ }
482
+
483
+ /*!
484
+ * @osovitny/core
485
+ * Copyright (c) 2016-2026 Osovitny
486
+ * SPDX-License-Identifier: MIT
487
+ */
488
+ function tzParseTimezone(timezoneString, date, isUtcDate) {
489
+ var token;
490
+ var absoluteOffset;
491
+ // Empty string
492
+ if (!timezoneString) {
493
+ return 0;
494
+ }
495
+ // Z
496
+ token = patterns.timezoneZ.exec(timezoneString);
497
+ if (token) {
498
+ return 0;
499
+ }
500
+ var hours;
501
+ // ±hh
502
+ token = patterns.timezoneHH.exec(timezoneString);
503
+ if (token) {
504
+ hours = parseInt(token[1], 10);
505
+ if (!validateTimezone(hours)) {
506
+ return NaN;
507
+ }
508
+ return -(hours * MILLISECONDS_IN_HOUR);
509
+ }
510
+ // ±hh:mm or ±hhmm
511
+ token = patterns.timezoneHHMM.exec(timezoneString);
512
+ if (token) {
513
+ hours = parseInt(token[1], 10);
514
+ var minutes = parseInt(token[2], 10);
515
+ if (!validateTimezone(hours, minutes)) {
516
+ return NaN;
517
+ }
518
+ absoluteOffset = Math.abs(hours) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE;
519
+ return hours > 0 ? -absoluteOffset : absoluteOffset;
520
+ }
521
+ // IANA time zone
522
+ if (isValidTimezoneIANAString(timezoneString)) {
523
+ date = new Date(date || Date.now());
524
+ var utcDate = isUtcDate ? date : toUtcDate(date);
525
+ var offset = calcOffset(utcDate, timezoneString);
526
+ var fixedOffset = isUtcDate ? offset : fixOffset(date, offset, timezoneString);
527
+ return -fixedOffset;
528
+ }
529
+ return NaN;
530
+ }
531
+ var MILLISECONDS_IN_HOUR = 3600000;
532
+ var MILLISECONDS_IN_MINUTE = 60000;
533
+ var patterns = {
534
+ timezone: /([Z+-].*)$/,
535
+ timezoneZ: /^(Z)$/,
536
+ timezoneHH: /^([+-]\d{2})$/,
537
+ timezoneHHMM: /^([+-]\d{2}):?(\d{2})$/,
538
+ };
539
+ function newDateUTC(fullYear, month, day, hour, minute, second, millisecond) {
540
+ var utcDate = new Date(0);
541
+ utcDate.setUTCFullYear(fullYear, month, day);
542
+ utcDate.setUTCHours(hour, minute, second, millisecond);
543
+ return utcDate;
544
+ }
545
+ function toUtcDate(date) {
546
+ return newDateUTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
547
+ }
548
+ function calcOffset(date, timezoneString) {
549
+ var tokens = tzTokenizeDate(date, timezoneString);
550
+ // ms dropped because it's not provided by tzTokenizeDate
551
+ var asUTC = newDateUTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5], 0).getTime();
552
+ var asTS = date.getTime();
553
+ var over = asTS % 1000;
554
+ asTS -= over >= 0 ? over : 1000 + over;
555
+ return asUTC - asTS;
556
+ }
557
+ function fixOffset(date, offset, timezoneString) {
558
+ var localTS = date.getTime();
559
+ // Our UTC time is just a guess because our offset is just a guess
560
+ var utcGuess = localTS - offset;
561
+ // Test whether the zone matches the offset for this ts
562
+ var o2 = calcOffset(new Date(utcGuess), timezoneString);
563
+ // If so, offset didn't change, and we're done
564
+ if (offset === o2) {
565
+ return offset;
566
+ }
567
+ // If not, change the ts by the difference in the offset
568
+ utcGuess -= o2 - offset;
569
+ // If that gives us the local time we want, we're done
570
+ var o3 = calcOffset(new Date(utcGuess), timezoneString);
571
+ if (o2 === o3) {
572
+ return o2;
573
+ }
574
+ // If it's different, we're in a hole time. The offset has changed, but we don't adjust the time
575
+ return Math.max(o2, o3);
576
+ }
577
+ function validateTimezone(hours, minutes = null) {
578
+ return -23 <= hours && hours <= 23 && (minutes == null || (0 <= minutes && minutes <= 59));
579
+ }
580
+ var validIANATimezoneCache = {};
581
+ function isValidTimezoneIANAString(timeZoneString) {
582
+ if (validIANATimezoneCache[timeZoneString])
583
+ return true;
584
+ try {
585
+ new Intl.DateTimeFormat(undefined, { timeZone: timeZoneString });
586
+ validIANATimezoneCache[timeZoneString] = true;
587
+ return true;
588
+ }
589
+ catch (error) {
590
+ return false;
591
+ }
592
+ }
593
+
594
+ /*!
595
+ * @osovitny/core
596
+ * Copyright (c) 2016-2026 Osovitny
597
+ * SPDX-License-Identifier: MIT
598
+ */
599
+ class DateConvert {
600
+ static toDate(date) {
601
+ const argStr = Object.prototype.toString.call(date);
602
+ if (date instanceof Date || (typeof date === "object" && argStr === "[object Date]")) {
603
+ return date;
604
+ }
605
+ else if (typeof date === "number" || argStr === "[object Number]" ||
606
+ typeof date === "string" || argStr === "[object String]") {
607
+ return new Date(date);
608
+ }
609
+ else {
610
+ return new Date(NaN);
611
+ }
612
+ }
613
+ static toFormattedDate(date, formatStr = 'yyyy-MM-dd HH:mm:ss') {
614
+ const parsedDate = this.toDate(date);
615
+ return format(parsedDate, formatStr);
616
+ }
617
+ static utcToLocal(dirtyDate) {
618
+ if (typeof dirtyDate === 'string') {
619
+ if (dirtyDate.indexOf("T") > -1) {
620
+ dirtyDate = dirtyDate.replace("T", " ");
621
+ }
622
+ if (dirtyDate.indexOf("Z") == -1) {
623
+ dirtyDate = dirtyDate + "Z";
624
+ }
625
+ }
626
+ let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
627
+ if (browserTimeZone) {
628
+ let date = DateConvert.toDate(dirtyDate);
629
+ let offsetMilliseconds = tzParseTimezone(browserTimeZone, date, true);
630
+ let d = new Date(date.getTime() - offsetMilliseconds);
631
+ let resultDate = new Date(0);
632
+ resultDate.setFullYear(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
633
+ resultDate.setHours(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());
634
+ return resultDate;
635
+ }
636
+ return new Date(dirtyDate);
637
+ }
638
+ }
639
+
640
+ /*!
641
+ * @osovitny/core
642
+ * Copyright (c) 2016-2026 Osovitny
643
+ * SPDX-License-Identifier: MIT
644
+ */
645
+ class XmlFormatter {
646
+ static toPrettyXML(s, options) {
647
+ if (!options) {
648
+ options = {
649
+ indent_size: 2,
650
+ indent_char: " ",
651
+ wrap_line_length: 110
652
+ };
653
+ }
654
+ return js_beautify.html(s, options);
655
+ }
656
+ }
657
+
658
+ /*!
659
+ * @osovitny/core
660
+ * Copyright (c) 2016-2026 Osovitny
661
+ * SPDX-License-Identifier: MIT
662
+ */
663
+ var DiscountCodeType;
664
+ (function (DiscountCodeType) {
665
+ DiscountCodeType[DiscountCodeType["Standard"] = 1] = "Standard";
666
+ DiscountCodeType[DiscountCodeType["UseOnce"] = 2] = "UseOnce";
667
+ })(DiscountCodeType || (DiscountCodeType = {}));
668
+ var DiscountCodeStatus;
669
+ (function (DiscountCodeStatus) {
670
+ DiscountCodeStatus[DiscountCodeStatus["Exist"] = 1] = "Exist";
671
+ DiscountCodeStatus[DiscountCodeStatus["NotFound"] = 2] = "NotFound";
672
+ DiscountCodeStatus[DiscountCodeStatus["AlreadyUsed"] = 3] = "AlreadyUsed";
673
+ })(DiscountCodeStatus || (DiscountCodeStatus = {}));
674
+ var PaymentType;
675
+ (function (PaymentType) {
676
+ PaymentType[PaymentType["FullPayment"] = 1] = "FullPayment";
677
+ PaymentType[PaymentType["WeeklyPayment"] = 2] = "WeeklyPayment";
678
+ PaymentType[PaymentType["BiWeeklyPayment"] = 3] = "BiWeeklyPayment";
679
+ PaymentType[PaymentType["MonthlyPayment"] = 4] = "MonthlyPayment";
680
+ })(PaymentType || (PaymentType = {}));
681
+ var PaymentMethod;
682
+ (function (PaymentMethod) {
683
+ PaymentMethod[PaymentMethod["None"] = 1] = "None";
684
+ PaymentMethod[PaymentMethod["Wallet"] = 2] = "Wallet";
685
+ PaymentMethod[PaymentMethod["CreditCard"] = 3] = "CreditCard";
686
+ PaymentMethod[PaymentMethod["PayPal"] = 4] = "PayPal";
687
+ PaymentMethod[PaymentMethod["Stripe"] = 5] = "Stripe";
688
+ PaymentMethod[PaymentMethod["Venmo"] = 6] = "Venmo";
689
+ PaymentMethod[PaymentMethod["ApplePay"] = 7] = "ApplePay";
690
+ PaymentMethod[PaymentMethod["GooglePay"] = 8] = "GooglePay";
691
+ })(PaymentMethod || (PaymentMethod = {}));
692
+ var PaymentStage;
693
+ (function (PaymentStage) {
694
+ //PayPal/Stripe
695
+ PaymentStage[PaymentStage["External"] = 1] = "External";
696
+ PaymentStage[PaymentStage["Internal"] = 2] = "Internal";
697
+ })(PaymentStage || (PaymentStage = {}));
698
+ var SubscriptionProvider;
699
+ (function (SubscriptionProvider) {
700
+ SubscriptionProvider[SubscriptionProvider["Product"] = 1] = "Product";
701
+ SubscriptionProvider[SubscriptionProvider["PayPal"] = 2] = "PayPal";
702
+ SubscriptionProvider[SubscriptionProvider["Stripe"] = 3] = "Stripe";
703
+ })(SubscriptionProvider || (SubscriptionProvider = {}));
704
+
705
+ /*!
706
+ * @osovitny/core
707
+ * Copyright (c) 2016-2026 Osovitny
708
+ * SPDX-License-Identifier: MIT
709
+ */
710
+ var Mode;
711
+ (function (Mode) {
712
+ Mode[Mode["View"] = 1] = "View";
713
+ Mode[Mode["Edit"] = 2] = "Edit";
714
+ Mode[Mode["Moderation"] = 3] = "Moderation";
715
+ })(Mode || (Mode = {}));
716
+ var DataViewType;
717
+ (function (DataViewType) {
718
+ DataViewType["Grid"] = "grid";
719
+ DataViewType["List"] = "list";
720
+ DataViewType["Table"] = "table";
721
+ })(DataViewType || (DataViewType = {}));
722
+ var PublishStatus;
723
+ (function (PublishStatus) {
724
+ PublishStatus[PublishStatus["Draft"] = 1] = "Draft";
725
+ PublishStatus[PublishStatus["PendingReview"] = 2] = "PendingReview";
726
+ PublishStatus[PublishStatus["Published"] = 3] = "Published";
727
+ PublishStatus[PublishStatus["Archived"] = 4] = "Archived";
728
+ })(PublishStatus || (PublishStatus = {}));
729
+ var ModerationStatus;
730
+ (function (ModerationStatus) {
731
+ ModerationStatus[ModerationStatus["Draft"] = 1] = "Draft";
732
+ ModerationStatus[ModerationStatus["PendingReview"] = 2] = "PendingReview";
733
+ ModerationStatus[ModerationStatus["Approved"] = 3] = "Approved";
734
+ ModerationStatus[ModerationStatus["Rejected"] = 4] = "Rejected"; //item is rejected by Moderator
735
+ })(ModerationStatus || (ModerationStatus = {}));
736
+
737
+ /*!
738
+ * @osovitny/core
739
+ * Copyright (c) 2016-2026 Osovitny
740
+ * SPDX-License-Identifier: MIT
741
+ */
742
+
743
+ /*!
744
+ * @osovitny/core
745
+ * Copyright (c) 2016-2026 Osovitny
746
+ * SPDX-License-Identifier: MIT
747
+ */
748
+ function throwIfAlreadyLoaded(parentModule, moduleName) {
749
+ if (parentModule) {
750
+ throw new Error(`${moduleName} has already been loaded. Import ${moduleName} modules in the AppModule only.`);
751
+ }
752
+ }
753
+
754
+ /*!
755
+ * @osovitny/core
756
+ * Copyright (c) 2016-2026 Osovitny
757
+ * SPDX-License-Identifier: MIT
758
+ */
759
+ let currentLocalizer = {
760
+ getLocalizedValue: (key, params, defaultKey) => key || defaultKey || ''
761
+ };
762
+ function setLocalizer(localizer) {
763
+ currentLocalizer = localizer;
764
+ }
765
+ function getLocalizer() {
766
+ return currentLocalizer;
767
+ }
768
+
769
+ /*!
770
+ * @osovitny/core
771
+ * Copyright (c) 2016-2026 Osovitny
772
+ * SPDX-License-Identifier: MIT
773
+ */
774
+ let currentLogger = console;
775
+ function setLogger(logger) {
776
+ currentLogger = logger;
777
+ }
778
+ function getLogger() {
779
+ return currentLogger;
780
+ }
781
+
782
+ /*!
783
+ * @osovitny/core
784
+ * Copyright (c) 2016-2026 Osovitny
785
+ * SPDX-License-Identifier: MIT
786
+ */
787
+
788
+ /*!
789
+ * @osovitny/core
790
+ * Copyright (c) 2016-2026 Osovitny
791
+ * SPDX-License-Identifier: MIT
792
+ */
793
+ //Node
794
+ class Alerts {
795
+ static areYouSure(text, title, confirmButtonText, cancelButtonText, successAction, cancelAction) {
796
+ text = getLocalizer().getLocalizedValue(text);
797
+ title = getLocalizer().getLocalizedValue(title, null, 'Notifications.AreYouSure');
798
+ confirmButtonText = getLocalizer().getLocalizedValue(confirmButtonText, null, 'Notifications.AreYouSure-ConfirmButtonText');
799
+ cancelButtonText = getLocalizer().getLocalizedValue(cancelButtonText, null, 'Notifications.AreYouSure-CancelButtonText');
800
+ Swal.fire({
801
+ text,
802
+ title,
803
+ icon: 'warning',
804
+ confirmButtonText,
805
+ cancelButtonText,
806
+ showCancelButton: true
807
+ })
808
+ .then((result) => {
809
+ if (result.value) {
810
+ if (successAction) {
811
+ successAction();
812
+ }
813
+ }
814
+ // result.dismiss can be 'cancel', 'overlay', 'close', and 'timer'
815
+ else if (result.dismiss == Swal.DismissReason.cancel || result.dismiss == Swal.DismissReason.close) {
816
+ if (cancelAction) {
817
+ cancelAction();
818
+ }
819
+ }
820
+ });
821
+ }
822
+ ;
823
+ static info(text, params, title) {
824
+ text = getLocalizer().getLocalizedValue(text, params);
825
+ title = getLocalizer().getLocalizedValue(title, null, 'Notifications.Info');
826
+ Swal.fire({
827
+ text,
828
+ title,
829
+ icon: 'info',
830
+ confirmButtonText: getLocalizer().getLocalizedValue('Notifications.Ok')
831
+ });
832
+ }
833
+ static warning(text, params, title) {
834
+ text = getLocalizer().getLocalizedValue(text, params);
835
+ title = getLocalizer().getLocalizedValue(title, null, 'Notifications.Warning');
836
+ Swal.fire({
837
+ text,
838
+ title,
839
+ icon: 'warning',
840
+ confirmButtonText: getLocalizer().getLocalizedValue('Notifications.Ok')
841
+ });
842
+ }
843
+ static error(text, params, title) {
844
+ text = getLocalizer().getLocalizedValue(text, params, 'Notifications.ErrorOccured');
845
+ title = getLocalizer().getLocalizedValue(title, null, 'Notifications.Error');
846
+ Swal.fire({
847
+ text,
848
+ title,
849
+ icon: 'error',
850
+ confirmButtonText: getLocalizer().getLocalizedValue('Notifications.Ok')
851
+ });
852
+ }
853
+ static success(text, params, title, successAction) {
854
+ text = getLocalizer().getLocalizedValue(text, params, 'Notifications.OperationSuccessFull');
855
+ title = getLocalizer().getLocalizedValue(title, null, 'Notifications.Success');
856
+ Swal.fire({
857
+ text,
858
+ title,
859
+ icon: 'success',
860
+ confirmButtonText: getLocalizer().getLocalizedValue('Notifications.Ok')
861
+ })
862
+ .then(() => {
863
+ if (successAction) {
864
+ successAction();
865
+ }
866
+ });
867
+ }
868
+ static cancel(text, params, title) {
869
+ text = getLocalizer().getLocalizedValue(text, params, 'Notifications.OperationCancelled');
870
+ title = getLocalizer().getLocalizedValue(title, null, 'Notifications.Cancelled');
871
+ Swal.fire({
872
+ text,
873
+ title,
874
+ icon: 'info'
875
+ });
876
+ }
877
+ //Standard Notifications
878
+ static notImplemented() {
879
+ let text = getLocalizer().getLocalizedValue('Notifications.NotImplemented');
880
+ this.warning(text);
881
+ }
882
+ ;
883
+ static authenticationRequired() {
884
+ let text = 'Please Log in';
885
+ let title = 'Authentication Required';
886
+ this.warning(text, null, title);
887
+ }
888
+ ;
889
+ }
890
+
891
+ /*!
892
+ * @osovitny/core
893
+ * Copyright (c) 2016-2026 Osovitny
894
+ * SPDX-License-Identifier: MIT
895
+ */
896
+
897
+ /*!
898
+ * @osovitny/core
899
+ * Copyright (c) 2016-2026 Osovitny
900
+ * SPDX-License-Identifier: MIT
901
+ */
902
+ //App
903
+ class Stopwatch {
904
+ constructor(name) {
905
+ this.name = name;
906
+ this.startTime = 0;
907
+ this.stopTime = 0;
908
+ this.running = false;
909
+ this.performance = !!window.performance;
910
+ getLogger().info(this.name + ' started.');
911
+ }
912
+ currentTime() {
913
+ return this.performance ? window.performance.now() : new Date().getTime();
914
+ }
915
+ start() {
916
+ this.startTime = this.currentTime();
917
+ this.running = true;
918
+ }
919
+ stop() {
920
+ this.stopTime = this.currentTime();
921
+ this.running = false;
922
+ }
923
+ getElapsedMilliseconds() {
924
+ if (this.running) {
925
+ this.stopTime = this.currentTime();
926
+ }
927
+ return this.stopTime - this.startTime;
928
+ }
929
+ getElapsedSeconds() {
930
+ return this.getElapsedMilliseconds() / 1000;
931
+ }
932
+ printElapsedAsMilliseconds() {
933
+ let elapsed = this.getElapsedMilliseconds();
934
+ getLogger().info(`${this.name} stopped. Execution time: ${elapsed} ms`);
935
+ }
936
+ }
937
+
938
+ /*!
939
+ * @osovitny/core
940
+ * Copyright (c) 2016-2026 Osovitny
941
+ * SPDX-License-Identifier: MIT
942
+ */
943
+ class DOM {
944
+ //Private
945
+ static dir(elem, dir, until = null, selector = null) {
946
+ let matched = [];
947
+ let truncate = until !== undefined && until != null;
948
+ while ((elem = elem[dir]) && elem.nodeType !== 9) {
949
+ if (elem.nodeType === 1) {
950
+ /*
951
+ if (truncate && jQuery(elem).is(until)) {
952
+ break;
953
+ }
954
+ */
955
+ if (selector) {
956
+ let className = selector.replace('.', '');
957
+ if (elem.classList.contains(className)) {
958
+ matched.push(elem);
959
+ }
960
+ }
961
+ else {
962
+ matched.push(elem);
963
+ }
964
+ }
965
+ }
966
+ return matched;
967
+ }
968
+ //Public
969
+ static first(elements) {
970
+ if (!elements || elements.length == 0) {
971
+ return null;
972
+ }
973
+ return elements[0];
974
+ }
975
+ static any(elements) {
976
+ if (!elements || elements.length == 0) {
977
+ return false;
978
+ }
979
+ return true;
980
+ }
981
+ static parent(elem) {
982
+ let parentElement = elem.parentElement;
983
+ let parentNode = elem.parentNode;
984
+ return parentNode && parentNode.nodeType !== 11 ? parentElement : null;
985
+ }
986
+ static parents(elem, selector = null) {
987
+ return this.dir(elem, "parentNode", null, selector);
988
+ }
989
+ static findInDocument(selector) {
990
+ let parent = $(document);
991
+ return $(parent).find(selector).get();
992
+ }
993
+ static find(elem, selector) {
994
+ return $(elem).find(selector).get();
995
+ }
996
+ static remove(nodes) {
997
+ if (nodes == null) {
998
+ return;
999
+ }
1000
+ if (!Array.isArray(nodes)) {
1001
+ if (nodes.parentNode) {
1002
+ nodes.parentNode.removeChild(nodes);
1003
+ }
1004
+ return;
1005
+ }
1006
+ if (nodes.length == 0) {
1007
+ return;
1008
+ }
1009
+ let node;
1010
+ let i = 0;
1011
+ for (; (node = nodes[i]) != null; i++) {
1012
+ if (node.parentNode) {
1013
+ node.parentNode.removeChild(node);
1014
+ }
1015
+ }
1016
+ }
1017
+ static findAndRemove(element, selector) {
1018
+ this.remove(this.find(element, selector));
1019
+ }
1020
+ static show(elem) {
1021
+ $(elem).show();
1022
+ }
1023
+ static hide(elem) {
1024
+ $(elem).hide();
1025
+ }
1026
+ static each(selector, action) {
1027
+ let parent = $(document);
1028
+ let elems = DOM.find(parent, selector);
1029
+ for (let i = 0; i < elems.length; i++) {
1030
+ let elem = elems[i];
1031
+ action(elem);
1032
+ }
1033
+ }
1034
+ //Css
1035
+ /*
1036
+ public static addClass(e: Element, className: string): Element {
1037
+ const class = e.getAttribute('class');
1038
+ if (class === null || class === '') {
1039
+ e.setAttribute('class', className);
1040
+ } else if (!DOM.hasClass(e, className)) {
1041
+ e.setAttribute('class', `${class} ${className}`);
1042
+ }
1043
+
1044
+ return e;
1045
+ }
1046
+
1047
+ public static removeClass(e: Element, className: string): Element {
1048
+ const class = e.getAttribute('class')
1049
+ if (class !== null && class !== '') {
1050
+ if (class === className) {
1051
+ e.setAttribute('class', '');
1052
+ } else {
1053
+ const result = class
1054
+ .split(' ')
1055
+ .filter((s: any) => s !== className)
1056
+ .join(' ');
1057
+ e.setAttribute('class', result);
1058
+ }
1059
+ }
1060
+
1061
+ return e;
1062
+ }
1063
+
1064
+ public static hasClass(e: Element, className: string): boolean {
1065
+ const class = e.getAttribute('class') || '';
1066
+ const r = new RegExp(`\\b${className}\\b`, '');
1067
+ return r.test(class);
1068
+ }
1069
+ */
1070
+ static addClass(elem, classNames) {
1071
+ $(elem).addClass(classNames);
1072
+ }
1073
+ static removeClass(elem, classNames) {
1074
+ $(elem).removeClass(classNames);
1075
+ }
1076
+ static hasClass(elem, className) {
1077
+ $(elem).hasClass(className);
1078
+ }
1079
+ }
1080
+
1081
+ /*!
1082
+ * @osovitny/core
1083
+ * Copyright (c) 2016-2026 Osovitny
1084
+ * SPDX-License-Identifier: MIT
1085
+ */
1086
+ class Guid {
1087
+ static newGuid() {
1088
+ return v4();
1089
+ }
1090
+ }
1091
+
1092
+ /*!
1093
+ * @osovitny/core
1094
+ * Copyright (c) 2016-2026 Osovitny
1095
+ * SPDX-License-Identifier: MIT
1096
+ */
1097
+ class Subs {
1098
+ constructor() {
1099
+ this.subs = [];
1100
+ }
1101
+ add(...subscriptions) {
1102
+ this.subs = this.subs.concat(subscriptions);
1103
+ }
1104
+ set sink(subscription) {
1105
+ this.subs.push(subscription);
1106
+ }
1107
+ unsubscribe() {
1108
+ this.subs.forEach((sub) => sub && sub.unsubscribe());
1109
+ this.subs = [];
1110
+ }
1111
+ }
1112
+
1113
+ /*!
1114
+ * @osovitny/core
1115
+ * Copyright (c) 2016-2026 Osovitny
1116
+ * SPDX-License-Identifier: MIT
1117
+ */
1118
+ //App
1119
+ class QSUtils {
1120
+ static getValue(url, name) {
1121
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1122
+ const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
1123
+ return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
1124
+ }
1125
+ static getValueByName(name) {
1126
+ return QSUtils.getValue(location.search, name);
1127
+ }
1128
+ static exists(name) {
1129
+ let value = QSUtils.getValueByName(name);
1130
+ if (value)
1131
+ return true;
1132
+ return false;
1133
+ }
1134
+ static idExists() {
1135
+ return QSUtils.exists("id");
1136
+ }
1137
+ static clear() {
1138
+ try {
1139
+ let newURL = location.href.split("?")[0];
1140
+ window.history.pushState('object', document.title, newURL);
1141
+ }
1142
+ catch (e) {
1143
+ }
1144
+ }
1145
+ static clearKey(name, reload = false, clearStorage = false) {
1146
+ try {
1147
+ let str = null;
1148
+ let newURL = null;
1149
+ str = "?" + name;
1150
+ if (location.href.indexOf(str) > -1) {
1151
+ newURL = location.href.split(str)[0];
1152
+ }
1153
+ str = "&" + name;
1154
+ if (location.href.indexOf(str) > -1) {
1155
+ newURL = location.href.split(str)[0];
1156
+ }
1157
+ if (newURL && reload) {
1158
+ if (clearStorage) {
1159
+ getLogger().info("Clearing Storage");
1160
+ localStorage.clear();
1161
+ sessionStorage.clear();
1162
+ }
1163
+ window.location.href = newURL;
1164
+ }
1165
+ else {
1166
+ window.history.pushState('object', document.title, newURL);
1167
+ }
1168
+ }
1169
+ catch (e) {
1170
+ }
1171
+ }
1172
+ static getUrlSlug() {
1173
+ let str = location.href;
1174
+ let items = str.split('/');
1175
+ let urlSlugWithQS = items[items.length - 1];
1176
+ let urlSlug = urlSlugWithQS.split("?")[0];
1177
+ return urlSlug;
1178
+ }
1179
+ //SSO
1180
+ static isSSOinProgress() {
1181
+ return location.search.indexOf("action=sso") > -1;
1182
+ }
1183
+ static clearSSO() {
1184
+ this.clearKey("action=sso");
1185
+ }
1186
+ }
1187
+
1188
+ /*!
1189
+ * @osovitny/core
1190
+ * Copyright (c) 2016-2026 Osovitny
1191
+ * SPDX-License-Identifier: MIT
1192
+ */
1193
+ class Utils {
1194
+ static copyToClipBoard(event, val) {
1195
+ event.preventDefault();
1196
+ const selBox = document.createElement('textarea');
1197
+ selBox.style.position = 'fixed';
1198
+ selBox.style.left = '0';
1199
+ selBox.style.top = '0';
1200
+ selBox.style.opacity = '0';
1201
+ selBox.value = val;
1202
+ document.body.appendChild(selBox);
1203
+ selBox.focus();
1204
+ selBox.select();
1205
+ document.execCommand('copy');
1206
+ document.body.removeChild(selBox);
1207
+ }
1208
+ static downloadFile(name, url) {
1209
+ const link = document.createElement('a');
1210
+ link.download = name;
1211
+ link.href = url;
1212
+ link.click();
1213
+ }
1214
+ static downloadBlobFile(value, fileName) {
1215
+ const nav = window.navigator;
1216
+ if (nav.msSaveOrOpenBlob) {
1217
+ nav.msSaveOrOpenBlob(value, fileName);
1218
+ }
1219
+ else {
1220
+ const downloadURL = window.URL.createObjectURL(value);
1221
+ Utils.downloadFile(fileName, downloadURL);
1222
+ }
1223
+ }
1224
+ /*
1225
+ Author:
1226
+ https://medium.com/@mhagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
1227
+ */
1228
+ static slugify(text, prefix = '', postfix = '') {
1229
+ const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;';
1230
+ const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------';
1231
+ const p = new RegExp(a.split('').join('|'), 'g');
1232
+ /*
1233
+ https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
1234
+ https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
1235
+ */
1236
+ text = text.replace(/(<([^>]+)>)/gi, '');
1237
+ let result = text
1238
+ .toString()
1239
+ .toLowerCase()
1240
+ .replace(/\s+/g, '-') // Replace spaces with -
1241
+ .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
1242
+ .replace(/&/g, '-and-') // Replace & with 'and'
1243
+ .replace(/[^\w\-]+/g, '') // Remove all non-word characters
1244
+ .replace(/\-\-+/g, '-') // Replace multiple - with single -
1245
+ .replace(/^-+/, '') // Trim - from start of text
1246
+ .replace(/-+$/, ''); // Trim - from end of text
1247
+ return prefix + result + postfix;
1248
+ }
1249
+ static generateRandom(start, end) {
1250
+ return Math.floor(Math.random() * (end - start + 1)) + start;
1251
+ }
1252
+ static sortArray(items) {
1253
+ return items?.slice().sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
1254
+ }
1255
+ }
1256
+
1257
+ /*!
1258
+ * @osovitny/core
1259
+ * Copyright (c) 2016-2026 Osovitny
1260
+ * SPDX-License-Identifier: MIT
1261
+ */
1262
+ //App
1263
+ function getMsalSettings() {
1264
+ const json = sessionStorage.getItem(SessionStorageKeys.appMSALSettings);
1265
+ return json ? JSON.parse(json) : null;
1266
+ }
1267
+ function resetMsalSettings() {
1268
+ let msalSettings = getMsalSettings();
1269
+ MSALConfig = msalSettings;
1270
+ MSALApiConfig = MSALConfig?.api;
1271
+ MSALB2CConfig = MSALConfig?.b2c;
1272
+ }
1273
+ let MSALConfig;
1274
+ let MSALApiConfig;
1275
+ let MSALB2CConfig;
1276
+
1277
+ /*!
1278
+ * @osovitny/core
1279
+ * Copyright (c) 2016-2026 Osovitny
1280
+ * SPDX-License-Identifier: MIT
1281
+ */
1282
+ //App
1283
+ class MSALB2C {
1284
+ static getAuthorityByType(type) {
1285
+ let policy = MSALB2C.getPolicyByType(type);
1286
+ return policy?.authority;
1287
+ }
1288
+ static getPolicyByType(type) {
1289
+ let policies = MSALB2CConfig?.policies;
1290
+ if (!policies) {
1291
+ return null;
1292
+ }
1293
+ for (let i = 0; i < policies.length; i++) {
1294
+ let policy = policies[i];
1295
+ if (policy.type == type) {
1296
+ return policy;
1297
+ }
1298
+ }
1299
+ return null;
1300
+ }
1301
+ }
1302
+
1303
+ /*!
1304
+ * @osovitny/core
1305
+ * Copyright (c) 2016-2026 Osovitny
1306
+ * SPDX-License-Identifier: MIT
1307
+ */
1308
+ const PolicyType = {
1309
+ signUpSignIn: 'signUpSignIn',
1310
+ signUp: 'signUp',
1311
+ editProfile: 'editProfile',
1312
+ resetPassword: 'resetPassword'
1313
+ };
1314
+
1315
+ /*!
1316
+ * @osovitny/core
1317
+ * Copyright (c) 2016-2026 Osovitny
1318
+ * SPDX-License-Identifier: MIT
1319
+ */
1320
+
1321
+ /*!
1322
+ * @osovitny/core
1323
+ * Copyright (c) 2016-2026 Osovitny
1324
+ * SPDX-License-Identifier: MIT
1325
+ */
1326
+ //App
1327
+ const MSALStorageKeys = {
1328
+ //LocalStorage
1329
+ redirectTo: 'msal.app.redirectTo'
1330
+ //SessionStorage
1331
+ };
1332
+ class MSALStorage {
1333
+ static hasRedirectValue(value) {
1334
+ return value && value !== 'null' && value !== 'undefined';
1335
+ }
1336
+ static saveRedirectState(redirectTo, calledBy) {
1337
+ if (!MSALStorage.hasRedirectValue(redirectTo)) {
1338
+ MSALStorage.clearRedirectState(calledBy);
1339
+ return;
1340
+ }
1341
+ if (redirectTo.indexOf('iam') >= 0) {
1342
+ MSALStorage.clearRedirectState(calledBy);
1343
+ return;
1344
+ }
1345
+ localStorage.setItem(MSALStorageKeys.redirectTo, redirectTo);
1346
+ getLogger().info(`MSAL. redirect state saved: ${redirectTo}. Called by: ${calledBy}`);
1347
+ }
1348
+ static getRedirectState(calledBy) {
1349
+ let redirectTo = localStorage.getItem(MSALStorageKeys.redirectTo);
1350
+ getLogger().info(`MSAL. redirect state requested: ${redirectTo}. Called by: ${calledBy}`);
1351
+ if (!MSALStorage.hasRedirectValue(redirectTo)) {
1352
+ MSALStorage.clearRedirectState(calledBy);
1353
+ return null;
1354
+ }
1355
+ return redirectTo;
1356
+ }
1357
+ static clearRedirectState(calledBy) {
1358
+ localStorage.removeItem(MSALStorageKeys.redirectTo);
1359
+ getLogger().info(`MSAL. redirect state cleared. Called by: ${calledBy}`);
1360
+ }
1361
+ }
1362
+
1363
+ /*!
1364
+ * @osovitny/core
1365
+ * Copyright (c) 2016-2026 Osovitny
1366
+ * SPDX-License-Identifier: MIT
1367
+ */
1368
+ class MSALRedirect {
1369
+ static handle(router, calledBy) {
1370
+ let redirectTo = MSALStorage.getRedirectState(calledBy);
1371
+ if (!redirectTo) {
1372
+ return;
1373
+ }
1374
+ MSALStorage.clearRedirectState(calledBy);
1375
+ router.navigate([redirectTo]);
1376
+ }
1377
+ }
1378
+
1379
+ /*!
1380
+ * @osovitny/core
1381
+ * Copyright (c) 2016-2026 Osovitny
1382
+ * SPDX-License-Identifier: MIT
1383
+ */
1384
+ //Node
1385
+ class MSALUtils {
1386
+ static isB2C() {
1387
+ if (MSALB2CConfig) {
1388
+ return true;
1389
+ }
1390
+ return false;
1391
+ }
1392
+ // Don't perform initial navigation in iframes or popups
1393
+ static initialNavigation() {
1394
+ return !BrowserUtils.isInIframe() && !BrowserUtils.isInPopup() ? 'enabledNonBlocking' : 'disabled';
1395
+ }
1396
+ static getApiScopes() {
1397
+ let scopes = [];
1398
+ if (MSALApiConfig) {
1399
+ let api = MSALApiConfig;
1400
+ for (const scope of api.scopes) {
1401
+ scopes.push(scope);
1402
+ }
1403
+ }
1404
+ return scopes;
1405
+ }
1406
+ }
1407
+
1408
+ /*!
1409
+ * @osovitny/core
1410
+ * Copyright (c) 2016-2026 Osovitny
1411
+ * SPDX-License-Identifier: MIT
1412
+ */
1413
+
1414
+ /*!
1415
+ * @osovitny/core
1416
+ * Copyright (c) 2016-2026 Osovitny
1417
+ * SPDX-License-Identifier: MIT
1418
+ */
1419
+ class BillingUtils {
1420
+ static { this.CURRENCY_SYMBOLS = {
1421
+ GBP: '£',
1422
+ EUR: '€',
1423
+ USD: '$',
1424
+ JPY: '¥',
1425
+ CAD: 'CA$',
1426
+ AUD: 'A$',
1427
+ }; }
1428
+ static convert2AmountWithCurrency(amount, currency) {
1429
+ if (!amount && amount !== 0)
1430
+ return '';
1431
+ const symbol = this.CURRENCY_SYMBOLS[currency.toUpperCase()];
1432
+ return symbol ? `${symbol}${amount}` : `${amount} ${currency}`;
1433
+ }
1434
+ }
1435
+
1436
+ /*!
1437
+ * @osovitny/core
1438
+ * Copyright (c) 2016-2026 Osovitny
1439
+ * SPDX-License-Identifier: MIT
1440
+ */
1441
+ let imageUploadUrl = AppSettings?.api?.url + AppSettings?.api?.imageUploadPath;
1442
+ const DefaultEditorOptions = {
1443
+ placeholderText: "Edit Your Content Here",
1444
+ charCounterCount: true,
1445
+ heightMin: 100,
1446
+ toolbarInline: false,
1447
+ toolbarButtons: {
1448
+ moreText: {
1449
+ buttons: [
1450
+ "bold",
1451
+ "italic",
1452
+ "underline",
1453
+ "strikeThrough",
1454
+ "subscript",
1455
+ "superscript",
1456
+ "fontFamily",
1457
+ "fontSize",
1458
+ "textColor",
1459
+ "backgroundColor",
1460
+ "inlineClass",
1461
+ "inlineStyle",
1462
+ ],
1463
+ },
1464
+ moreParagraph: {
1465
+ buttons: [
1466
+ "alignLeft",
1467
+ "alignCenter",
1468
+ "formatOLSimple",
1469
+ "alignRight",
1470
+ "alignJustify",
1471
+ "formatOL",
1472
+ "formatUL",
1473
+ "paragraphFormat",
1474
+ "paragraphStyle",
1475
+ "lineHeight",
1476
+ "outdent",
1477
+ "indent",
1478
+ "quote",
1479
+ ],
1480
+ },
1481
+ moreRich: {
1482
+ buttons: [
1483
+ "insertLink",
1484
+ "insertImage",
1485
+ "insertTable",
1486
+ "emoticons",
1487
+ "fontAwesome",
1488
+ "specialCharacters",
1489
+ "embedly",
1490
+ ],
1491
+ },
1492
+ moreMisc: {
1493
+ buttons: [
1494
+ "selectAll",
1495
+ "clearFormatting",
1496
+ "html",
1497
+ "undo",
1498
+ "redo",
1499
+ "fullscreen",
1500
+ ],
1501
+ align: "right",
1502
+ }
1503
+ },
1504
+ /*
1505
+ Upload:
1506
+ https://www.froala.com/wysiwyg-editor/docs/concepts/image/upload
1507
+ */
1508
+ imageUploadURL: imageUploadUrl,
1509
+ imageAllowedTypes: ["jpeg", "jpg", "png"],
1510
+ imageUploadParams: { uploadType: "", uploadParentId: "" }
1511
+ };
1512
+
1513
+ /*!
1514
+ * @osovitny/core
1515
+ * Copyright (c) 2016-2026 Osovitny
1516
+ * SPDX-License-Identifier: MIT
1517
+ */
1518
+ const Spinkit = {
1519
+ skChasingDots: 'sk-chasing-dots',
1520
+ skCubeGrid: 'sk-cube-grid',
1521
+ skDoubleBounce: 'sk-double-bounce',
1522
+ skRotatingPlane: 'sk-rotationg-plane',
1523
+ skSpinnerPulse: 'sk-spinner-pulse',
1524
+ skThreeBounce: 'sk-three-bounce',
1525
+ skWanderingCubes: 'sk-wandering-cubes',
1526
+ skWave: 'sk-wave',
1527
+ skLine: 'sk-line-material'
1528
+ };
1529
+
1530
+ /*
1531
+ * Public API of @osovitny/core
1532
+ */
1533
+ //Core — consts
1534
+
1535
+ /**
1536
+ * Generated bundle index. Do not edit.
1537
+ */
1538
+
1539
+ export { Alerts, ApiUrl, AppContextStorageKeys, AppName, AppSettings, AppVersion, AssetGroupType, BillingUtils, ClientApps, Convert, DOM, DataViewType, DateConvert, DefaultEditorOptions, DiscountCodeStatus, DiscountCodeType, GABillingEvents, GAEvents, Guid, IsDevMode, IsProdMode, LibName, MSALApiConfig, MSALB2C, MSALB2CConfig, MSALConfig, MSALRedirect, MSALStorage, MSALStorageKeys, MSALUtils, Mode, ModerationStatus, PaymentMethod, PaymentStage, PaymentType, PolicyType, PublishStatus, QSUtils, SessionStorageKeys, Spinkit, Stopwatch, Subs, SubscriptionProvider, Utils, XmlFormatter, dateFormats, dateTimeFormats, formatAssetsUrl, formatUrl, getAppSettings, getAppSettingsById, getAppSettingsByName, getCurrentApp, getLocalizer, getLogger, getMsalSettings, is, resetAppSettings, resetMsalSettings, setLocalizer, setLogger, throwIfAlreadyLoaded, timeFormats };
1540
+ //# sourceMappingURL=osovitny-core.mjs.map