@acorex/core 5.0.5 → 5.0.9

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 (73) hide show
  1. package/acorex-core.d.ts +5 -0
  2. package/bundles/acorex-core.umd.js +1333 -0
  3. package/bundles/acorex-core.umd.js.map +1 -0
  4. package/config/tailwind.config.js +209 -0
  5. package/esm2015/acorex-core.js +5 -0
  6. package/esm2015/lib/config/configs.js +30 -0
  7. package/esm2015/lib/core.module.js +18 -0
  8. package/esm2015/lib/dateTime/datetime.class.js +260 -0
  9. package/esm2015/lib/dateTime/datetime.module.js +31 -0
  10. package/esm2015/lib/dateTime/datetime.pipe.js +25 -0
  11. package/esm2015/lib/dateTime/georgian.calendar.js +162 -0
  12. package/esm2015/lib/dateTime/index.js +5 -0
  13. package/esm2015/lib/dateTime/jalali.calendar.js +327 -0
  14. package/esm2015/lib/platform/index.js +2 -0
  15. package/esm2015/lib/platform/platform.service.js +132 -0
  16. package/esm2015/lib/translation/index.js +4 -0
  17. package/esm2015/lib/translation/translation.module.js +18 -0
  18. package/esm2015/lib/translation/translator.js +26 -0
  19. package/esm2015/lib/translation/translator.pipe.js +15 -0
  20. package/esm2015/lib/utils/drawing-util.js +27 -0
  21. package/esm2015/lib/utils/index.js +4 -0
  22. package/esm2015/lib/utils/object-util.js +83 -0
  23. package/esm2015/lib/utils/safe.pipe.js +30 -0
  24. package/esm2015/public-api.js +11 -0
  25. package/fesm2015/acorex-core.js +1169 -0
  26. package/fesm2015/acorex-core.js.map +1 -0
  27. package/lib/config/configs.d.ts +9 -0
  28. package/lib/core.module.d.ts +7 -0
  29. package/lib/dateTime/datetime.class.d.ts +86 -0
  30. package/lib/dateTime/datetime.module.d.ts +8 -0
  31. package/lib/dateTime/datetime.pipe.d.ts +8 -0
  32. package/lib/dateTime/georgian.calendar.d.ts +19 -0
  33. package/{src/lib/dateTime/index.ts → lib/dateTime/index.d.ts} +1 -1
  34. package/lib/dateTime/jalali.calendar.d.ts +34 -0
  35. package/lib/platform/index.d.ts +1 -0
  36. package/lib/platform/platform.service.d.ts +23 -0
  37. package/{src/lib/translation/index.ts → lib/translation/index.d.ts} +1 -1
  38. package/lib/translation/translation.module.d.ts +7 -0
  39. package/lib/translation/translator.d.ts +9 -0
  40. package/lib/translation/translator.pipe.d.ts +7 -0
  41. package/lib/utils/drawing-util.d.ts +17 -0
  42. package/{src/lib/utils/index.ts → lib/utils/index.d.ts} +1 -1
  43. package/lib/utils/object-util.d.ts +7 -0
  44. package/lib/utils/safe.pipe.d.ts +10 -0
  45. package/package.json +18 -14
  46. package/{src/public-api.ts → public-api.d.ts} +1 -2
  47. package/karma.conf.js +0 -44
  48. package/ng-package.json +0 -11
  49. package/src/lib/config/configs.ts +0 -36
  50. package/src/lib/core.module.ts +0 -10
  51. package/src/lib/dateTime/datetime.class.ts +0 -395
  52. package/src/lib/dateTime/datetime.module.ts +0 -11
  53. package/src/lib/dateTime/datetime.pipe.ts +0 -20
  54. package/src/lib/dateTime/georgian.calendar.ts +0 -157
  55. package/src/lib/dateTime/jalali.calendar.ts +0 -376
  56. package/src/lib/http/http-error.class.ts +0 -7
  57. package/src/lib/http/http-events.interceptor.ts +0 -14
  58. package/src/lib/http/http-request.class.ts +0 -14
  59. package/src/lib/http/http-result.class.ts +0 -34
  60. package/src/lib/http/http.module.ts +0 -25
  61. package/src/lib/http/http.service.ts +0 -159
  62. package/src/lib/platform/index.ts +0 -1
  63. package/src/lib/platform/platform.service.ts +0 -185
  64. package/src/lib/translation/translation.module.ts +0 -12
  65. package/src/lib/translation/translator.pipe.ts +0 -9
  66. package/src/lib/translation/translator.ts +0 -31
  67. package/src/lib/utils/drawing-util.ts +0 -43
  68. package/src/lib/utils/object-util.ts +0 -82
  69. package/src/lib/utils/safe.pipe.ts +0 -24
  70. package/src/test.ts +0 -26
  71. package/tsconfig.lib.json +0 -20
  72. package/tsconfig.lib.prod.json +0 -10
  73. package/tsconfig.spec.json +0 -17
@@ -0,0 +1,1169 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Pipe, NgModule, Injectable } from '@angular/core';
3
+ import * as i1 from '@angular/platform-browser';
4
+ import { Subject } from 'rxjs';
5
+ import merge from 'lodash-es/merge';
6
+
7
+ // @dynamic
8
+ class AXObjectUtil {
9
+ static deepJSONClone(obj) {
10
+ return obj ? JSON.parse(JSON.stringify(obj)) : null;
11
+ }
12
+ static deepCopy(obj) {
13
+ let copy;
14
+ // Handle the 3 simple types, and null or undefined
15
+ if (null == obj || 'object' !== typeof obj) {
16
+ return obj;
17
+ }
18
+ // Handle Date
19
+ if (obj instanceof Date) {
20
+ copy = new Date();
21
+ copy.setTime(obj.getTime());
22
+ return copy;
23
+ }
24
+ // Handle Array
25
+ if (obj instanceof Array) {
26
+ copy = [];
27
+ for (let i = 0, len = obj.length; i < len; i++) {
28
+ copy[i] = AXObjectUtil.deepCopy(obj[i]);
29
+ }
30
+ return copy;
31
+ }
32
+ // Handle Object
33
+ if (obj instanceof Object) {
34
+ copy = {};
35
+ for (const attr in obj) {
36
+ if (obj.hasOwnProperty(attr)) {
37
+ copy[attr] = AXObjectUtil.deepCopy(obj[attr]);
38
+ }
39
+ }
40
+ return copy;
41
+ }
42
+ throw new Error('Unable to copy obj! Its type isn\'t supported.');
43
+ }
44
+ static fetchProp(obj, prop) {
45
+ if (typeof obj === 'undefined') {
46
+ return false;
47
+ }
48
+ const index = prop.indexOf('.');
49
+ if (index > -1) {
50
+ return AXObjectUtil.fetchProp(obj[prop.substring(0, index)], prop.substr(index + 1));
51
+ }
52
+ return obj[prop];
53
+ }
54
+ static getPropByPath(obj, path, defaultVal) {
55
+ path = path
56
+ .replace(/\[/g, '.')
57
+ .replace(/]/g, '')
58
+ .split('.');
59
+ path.forEach((level) => {
60
+ if (obj) {
61
+ obj = obj[level];
62
+ }
63
+ });
64
+ if (obj === undefined) {
65
+ return defaultVal;
66
+ }
67
+ return obj;
68
+ }
69
+ static setPropByPath(obj, path, value) {
70
+ if (Object(obj) !== obj) {
71
+ return obj;
72
+ } // When obj is not an object
73
+ // If not yet an array, get the keys from the string-path
74
+ if (!Array.isArray(path)) {
75
+ path = path.toString().match(/[^.[\]]+/g) || [];
76
+ }
77
+ path.slice(0, -1).reduce((a, c, i) => // Iterate all of them except the last one
78
+ Object(a[c]) === a[c] // Does the key exist and is its value an object?
79
+ // Yes: then follow that path
80
+ ? a[c]
81
+ // No: create the key. Is the next key a potential array-index?
82
+ : a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1]
83
+ ? [] // Yes: assign a new array object
84
+ : {}, // No: assign a new plain object
85
+ obj)[path[path.length - 1]] = value; // Finally assign the value to the last key
86
+ return obj; // Return the top-level object to allow chaining
87
+ }
88
+ }
89
+
90
+ // @dynamic
91
+ class AXDrawingUtil {
92
+ static collision(a, b) {
93
+ const ac = a.getBoundingClientRect();
94
+ const bc = b.getBoundingClientRect();
95
+ if (ac.left < bc.left + bc.width && ac.left + ac.width > bc.left &&
96
+ ac.top < bc.top + bc.height && ac.top + ac.height > bc.top) {
97
+ return true;
98
+ }
99
+ else {
100
+ return false;
101
+ }
102
+ }
103
+ static isInElementBound(pos, element) {
104
+ const elBound = element.getBoundingClientRect();
105
+ return AXDrawingUtil.isInRecPoint(pos, {
106
+ left: elBound.x,
107
+ width: elBound.width,
108
+ top: elBound.y,
109
+ height: elBound.height
110
+ });
111
+ }
112
+ static isInRecPoint(pos, rec) {
113
+ return pos.x >= rec.left && pos.x <= (rec.left + rec.width) && pos.y >= rec.top && (pos.y <= (rec.top + rec.height));
114
+ }
115
+ }
116
+
117
+ class AXSafePipe {
118
+ constructor(sanitizer) {
119
+ this.sanitizer = sanitizer;
120
+ }
121
+ transform(value, type) {
122
+ if (value == null || value == undefined || value == '')
123
+ return null;
124
+ switch (type) {
125
+ case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
126
+ case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
127
+ case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
128
+ case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
129
+ case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
130
+ default: throw new Error(`Invalid safe type specified: ${type}`);
131
+ }
132
+ }
133
+ }
134
+ AXSafePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXSafePipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
135
+ AXSafePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXSafePipe, name: "safe" });
136
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXSafePipe, decorators: [{
137
+ type: Pipe,
138
+ args: [{
139
+ name: 'safe',
140
+ pure: true
141
+ }]
142
+ }], ctorParameters: function () { return [{ type: i1.DomSanitizer }]; } });
143
+
144
+ class AXCoreModule {
145
+ }
146
+ AXCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
147
+ AXCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, declarations: [AXSafePipe], exports: [AXSafePipe] });
148
+ AXCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, providers: [], imports: [[]] });
149
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, decorators: [{
150
+ type: NgModule,
151
+ args: [{
152
+ imports: [],
153
+ exports: [AXSafePipe],
154
+ declarations: [AXSafePipe],
155
+ providers: [],
156
+ }]
157
+ }] });
158
+
159
+ // @dynamic
160
+ class AXConfig {
161
+ static get onChange() {
162
+ return AXConfig.dataChangeSubject.asObservable();
163
+ }
164
+ static set(arg1, arg2) {
165
+ if (arg1 && typeof arg1 == 'string') {
166
+ AXObjectUtil.setPropByPath(AXConfig.dataModel, arg1, arg2);
167
+ AXConfig.dataChangeSubject.next(AXConfig.dataModel);
168
+ return;
169
+ }
170
+ if (arg1 && typeof arg1 == 'object') {
171
+ //TODO : fix override
172
+ Object.assign(AXConfig.dataModel, arg1);
173
+ AXConfig.dataChangeSubject.next(AXConfig.dataModel);
174
+ return;
175
+ }
176
+ if (!arg1 && !arg2) {
177
+ return AXConfig.dataChangeSubject.asObservable();
178
+ }
179
+ }
180
+ static get(path, defaultValue) {
181
+ return AXObjectUtil.getPropByPath(AXConfig.dataModel, path) || defaultValue;
182
+ }
183
+ }
184
+ AXConfig.dataModel = {};
185
+ AXConfig.dataChangeSubject = new Subject();
186
+
187
+ // @dynamic
188
+ class AXDateTime {
189
+ constructor(value = new Date(), calendar = AXConfig.get('dateTime.type') || 'gregorian') {
190
+ this._calendar =
191
+ // typeof calendar == 'string'
192
+ // ? eval(`new ${AX_CALENDARS.find((c) => c.name == calendar).type}()`)
193
+ // : calendar;
194
+ typeof calendar == 'string'
195
+ ? AXConfig.get(`dateTime.calendars.${calendar}`)
196
+ : calendar;
197
+ if (value instanceof Date) {
198
+ this._date = value;
199
+ }
200
+ else {
201
+ this._date = new Date(value);
202
+ }
203
+ }
204
+ static convert(value, calendar = AXConfig.get('dateTime.type') || 'gregorian') {
205
+ let date;
206
+ if (typeof value === 'string' || value instanceof String) {
207
+ date = new AXDateTime(value, calendar);
208
+ }
209
+ else if (value instanceof Date) {
210
+ date = new AXDateTime(value, calendar);
211
+ }
212
+ else if (value instanceof AXDateTime) {
213
+ date = new AXDateTime(value.date, calendar);
214
+ }
215
+ return date;
216
+ }
217
+ get date() {
218
+ return this._date;
219
+ }
220
+ get calendar() {
221
+ return this._calendar;
222
+ }
223
+ clone() {
224
+ return new AXDateTime(this.date, this.calendar.name());
225
+ }
226
+ get dayOfMonth() {
227
+ return this._calendar.dayOfMonth(this.date);
228
+ }
229
+ get dayOfYear() {
230
+ return this._calendar.dayOfYear(this.date);
231
+ }
232
+ get dayOfWeek() {
233
+ return this._calendar.dayOfWeek(this.date);
234
+ }
235
+ get hour() {
236
+ return this._date.getHours();
237
+ }
238
+ get minute() {
239
+ return this._date.getMinutes();
240
+ }
241
+ get second() {
242
+ return this._date.getSeconds();
243
+ }
244
+ get year() {
245
+ return this._calendar.year(this.date);
246
+ }
247
+ get monthOfYear() {
248
+ return this._calendar.monthOfYear(this.date);
249
+ }
250
+ get weekOfYear() {
251
+ return this._calendar.weekOfYear(this.date);
252
+ }
253
+ get month() {
254
+ return new AXCalendarMonth(this);
255
+ }
256
+ add(unit, amount) {
257
+ return this._calendar.add(this.date, unit, amount);
258
+ }
259
+ set(unit = 'day', value) {
260
+ return this._calendar.set(this.date, unit, value);
261
+ }
262
+ duration(end, unit = 'day') {
263
+ const range = new AXDateTimeRange(this, AXDateTime.convert(end, this.calendar.name()));
264
+ return range.duration();
265
+ }
266
+ startOf(unit = 'day') {
267
+ return this._calendar.startOf(this.date, unit);
268
+ }
269
+ endOf(unit = 'day') {
270
+ return this._calendar.endOf(this.date, unit);
271
+ }
272
+ format(format = AXConfig.get('dateTime.shortDateFormat') ||
273
+ 'DDD, dd MMM yyyy') {
274
+ format = format.replace('ss', this.pad(this.date.getSeconds(), 2));
275
+ format = format.replace('s', this.date.getSeconds().toString());
276
+ format = format.replace('dd', this.pad(this.calendar.dayOfMonth(this.date), 2));
277
+ format = format.replace('d', this.calendar.dayOfMonth(this.date).toString());
278
+ format = format.replace('mm', this.pad(this.date.getMinutes(), 2));
279
+ format = format.replace('m', this.date.getMinutes().toString());
280
+ format = format.replace('MMMM', this.calendar.monthNames[this.calendar.monthOfYear(this.date) - 1]);
281
+ format = format.replace('MMM', this.calendar.monthShortNames[this.calendar.monthOfYear(this.date) - 1]);
282
+ format = format.replace('MM', this.pad(this.calendar.monthOfYear(this.date), 2));
283
+ format = format.replace(/M(?![ao])/, this.calendar.monthOfYear(this.date).toString());
284
+ format = format.replace('DDDD', this.calendar.dayNames[this.calendar.dayOfWeek(this.date) - 1]);
285
+ format = format.replace('DDD', this.calendar.dayShortNames[this.calendar.dayOfWeek(this.date) - 1]);
286
+ format = format.replace(/D(?!e)/, this.calendar.dayNames[this.calendar.dayOfWeek(this.date) - 1].substring(0, 3));
287
+ format = format.replace('yyyy', this.calendar.year(this.date).toString());
288
+ format = format.replace('YYYY', this.calendar.year(this.date).toString());
289
+ format = format.replace('yy', this.calendar.year(this.date).toString().substring(2));
290
+ format = format.replace('YY', this.calendar.year(this.date).toString().substring(2));
291
+ format = format.replace('HH', this.pad(this.date.getHours(), 2));
292
+ format = format.replace('H', this.date.getHours().toString());
293
+ return format;
294
+ }
295
+ pad(n, width, z = '0') {
296
+ n = n + '';
297
+ return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
298
+ }
299
+ toString() {
300
+ return this.format();
301
+ }
302
+ equal(value, unit = 'day') {
303
+ return this.compare(value, unit) == 0;
304
+ }
305
+ compare(value, unit = 'day') {
306
+ const val = AXDateTime.convert(value);
307
+ const func = (v1, v2) => {
308
+ if (v1 == v2) {
309
+ return 0;
310
+ }
311
+ else if (v1 > v2) {
312
+ return 1;
313
+ }
314
+ else {
315
+ return -1;
316
+ }
317
+ };
318
+ let p = 0;
319
+ switch (unit) {
320
+ case 'year':
321
+ return func(this.year, val.year);
322
+ case 'week':
323
+ p = this.compare(val, 'year');
324
+ return p == 0 ? func(this.weekOfYear, val.weekOfYear) : p;
325
+ case 'month':
326
+ p = this.compare(val, 'year');
327
+ return p == 0 ? func(this.monthOfYear, val.monthOfYear) : p;
328
+ case 'day':
329
+ p = this.compare(val, 'year');
330
+ return p == 0 ? func(this.dayOfYear, val.dayOfYear) : p;
331
+ case 'hour':
332
+ p = this.compare(val, 'day');
333
+ return p == 0 ? func(this.hour, val.hour) : p;
334
+ case 'minute':
335
+ p = this.compare(val, 'hour');
336
+ return p == 0 ? func(this.minute, val.minute) : p;
337
+ case 'second':
338
+ p = this.compare(val, 'minute');
339
+ return p == 0 ? func(this.second, val.second) : p;
340
+ default:
341
+ return func(this.date.getTime(), val.date.getTime());
342
+ }
343
+ }
344
+ convert(calendar) {
345
+ return AXDateTime.convert(this, calendar);
346
+ }
347
+ }
348
+ class AXCalendarMonth {
349
+ constructor(date) {
350
+ this.index = date.date.getMonth();
351
+ this.name = date.format('MMMM');
352
+ this.range = new AXDateTimeRange(new AXDateTime(date.startOf('month').date, date.calendar), new AXDateTime(date.endOf('month').date, date.calendar));
353
+ }
354
+ get range() {
355
+ return this._range;
356
+ }
357
+ set range(v) {
358
+ this._range = v;
359
+ }
360
+ }
361
+ class AXDateTimeRange {
362
+ constructor(startTime, endTime) {
363
+ this._startTime = startTime;
364
+ this._endTime = endTime;
365
+ }
366
+ get startTime() {
367
+ return this._startTime;
368
+ }
369
+ get endTime() {
370
+ return this._endTime;
371
+ }
372
+ duration() {
373
+ const result = {
374
+ miliseconds: 0,
375
+ seconds: 0,
376
+ minutes: 0,
377
+ hours: 0,
378
+ days: 0,
379
+ months: 0,
380
+ years: 0,
381
+ total: {
382
+ miliseconds: 0,
383
+ seconds: 0,
384
+ minutes: 0,
385
+ hours: 0,
386
+ days: 0,
387
+ weeks: 0,
388
+ months: 0,
389
+ years: 0,
390
+ },
391
+ };
392
+ const one_second = 1000;
393
+ const one_min = one_second * 60;
394
+ const one_hour = one_min * 60;
395
+ const one_day = one_hour * 24;
396
+ const one_week = one_day * 7;
397
+ const one_year = 365.25 * one_day;
398
+ const one_month = one_year / 12;
399
+ const startTime = this._startTime.date.getTime();
400
+ const endTime = this._endTime.date.getTime();
401
+ const diff = Math.abs(endTime - startTime);
402
+ //
403
+ result.total.miliseconds = diff;
404
+ result.total.seconds = Number((diff / one_second).toFixed(2));
405
+ result.total.minutes = Number((diff / one_min).toFixed(2));
406
+ result.total.hours = Number((diff / one_hour).toFixed(2));
407
+ result.total.days = Number((diff / one_day).toFixed(2));
408
+ result.total.weeks = Number((diff / one_week).toFixed(2));
409
+ //
410
+ // let months = (this.endTime.year - this.startTime.year) * 12;
411
+ // months += this.endTime.monthOfYear - this.startTime.monthOfYear + 1;
412
+ // if (this.endTime.dayOfYear < this.startTime.dayOfYear) {
413
+ // months--;
414
+ // }
415
+ // result.total.months = Math.abs(months);
416
+ // TODO: review
417
+ result.total.months = Number((diff / one_month).toFixed(2));
418
+ result.total.years = Number((diff / one_year).toFixed(2));
419
+ //
420
+ result.miliseconds = result.total.miliseconds % 1000;
421
+ result.seconds = Number((result.total.seconds % 60).toFixed(0));
422
+ result.minutes = Number((result.total.minutes % 60).toFixed(0));
423
+ result.hours = Number((result.total.hours % 24).toFixed(0));
424
+ // TODO: review
425
+ result.days = Number((result.total.days % 30.4).toFixed(0));
426
+ result.months = Number((result.total.months % 12).toFixed(0));
427
+ result.years = Number(result.total.years.toFixed(0));
428
+ return result;
429
+ }
430
+ enumurate(unit = 'day', amount = 1) {
431
+ // TODO: setptemper savingtime issue
432
+ const result = [];
433
+ let item = this._startTime.clone();
434
+ while (item.compare(this._endTime, unit) < 1) {
435
+ result.push(item);
436
+ item = item.add(unit, amount);
437
+ }
438
+ return result;
439
+ }
440
+ includes(value, unit = 'day') {
441
+ // TODO: ??
442
+ return true;
443
+ }
444
+ }
445
+
446
+ class AXDateTimePipe {
447
+ constructor() { }
448
+ transform(value, format, calendar) {
449
+ if (value == null) {
450
+ return '';
451
+ }
452
+ const date = value instanceof AXDateTime ? value.clone() : AXDateTime.convert(value, calendar);
453
+ if (!format) {
454
+ return date.toString();
455
+ }
456
+ else {
457
+ return date.format(format);
458
+ }
459
+ }
460
+ }
461
+ AXDateTimePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
462
+ AXDateTimePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimePipe, name: "axDate" });
463
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimePipe, decorators: [{
464
+ type: Pipe,
465
+ args: [{ name: 'axDate' }]
466
+ }], ctorParameters: function () { return []; } });
467
+
468
+ class GeorgianCalendar {
469
+ constructor() {
470
+ this.monthNames = [
471
+ "January", "February", "March",
472
+ "April", "May", "June", "July",
473
+ "August", "September", "October",
474
+ "November", "December"
475
+ ];
476
+ this.monthShortNames = [
477
+ "Jan", "Feb", "Mar",
478
+ "Apr", "May", "Jun", "Jul",
479
+ "Aug", "Sep", "Oct",
480
+ "Nov", "Dec"
481
+ ];
482
+ this.dayNames = [
483
+ "Sunday", "Monday", "Tuesday", "Wednesday",
484
+ "Thursday", "Friday", "Saturday"
485
+ ];
486
+ this.dayShortNames = [
487
+ "Sun", "Mon", "Tue", "Wed",
488
+ "Thu", "Fri", "Sat"
489
+ ];
490
+ }
491
+ name() {
492
+ return 'gregorian';
493
+ }
494
+ dayOfMonth(date) {
495
+ return date.getDate();
496
+ }
497
+ dayOfYear(date) {
498
+ let result = 0;
499
+ let m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
500
+ if (this.isLeap(date)) {
501
+ m[1] = 29;
502
+ }
503
+ for (let i = 0; i < date.getMonth(); i++) {
504
+ result = result + m[i];
505
+ }
506
+ result += date.getDate();
507
+ return result;
508
+ }
509
+ dayOfWeek(date) {
510
+ return date.getDay() + 1;
511
+ }
512
+ weekOfYear(date) {
513
+ const firstDay = new AXDateTime(date).startOf('year');
514
+ return Math.ceil((((date.getTime() - firstDay.date.getTime()) / 86400000) + firstDay.date.getDay() + 1) / 7);
515
+ }
516
+ year(date) {
517
+ return date.getFullYear();
518
+ }
519
+ monthOfYear(date) {
520
+ return date.getMonth() + 1;
521
+ }
522
+ add(date, unit, amount) {
523
+ let value = date.valueOf();
524
+ switch (unit) {
525
+ case 'second':
526
+ value += 1000 * amount;
527
+ break;
528
+ case 'minute':
529
+ value += 60000 * amount;
530
+ break;
531
+ case 'hour':
532
+ value += 3600000 * amount;
533
+ break;
534
+ case 'month':
535
+ const v = new Date(value);
536
+ var mo = date.getMonth();
537
+ var yr = date.getFullYear();
538
+ mo = (mo + amount) % 12;
539
+ if (0 > mo) {
540
+ yr += (date.getMonth() + amount - mo - 12) / 12;
541
+ mo += 12;
542
+ }
543
+ else
544
+ yr += ((date.getMonth() + amount - mo) / 12);
545
+ v.setMonth(mo);
546
+ v.setFullYear(yr);
547
+ value = v.valueOf();
548
+ break;
549
+ case 'week':
550
+ value += 7 * 86400000 * amount;
551
+ break;
552
+ case 'year':
553
+ const yv = new Date(value);
554
+ yv.setFullYear(yv.getFullYear() + amount);
555
+ value = yv.valueOf();
556
+ break;
557
+ case 'day':
558
+ default:
559
+ value += 86400000 * amount;
560
+ }
561
+ return new AXDateTime(new Date(value), this.name());
562
+ }
563
+ set(date, unit, value) {
564
+ throw new Error("Method not implemented.");
565
+ }
566
+ startOf(date, unit) {
567
+ const clone = new Date(date.valueOf());
568
+ switch (unit) {
569
+ case 'second':
570
+ clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 0);
571
+ return new AXDateTime(clone, this.name());
572
+ case 'minute':
573
+ clone.setHours(clone.getHours(), clone.getMinutes(), 0, 0);
574
+ return new AXDateTime(clone, this.name());
575
+ case 'hour':
576
+ clone.setHours(clone.getHours(), 0, 0, 0);
577
+ return new AXDateTime(clone, this.name());
578
+ default:
579
+ case 'day':
580
+ clone.setHours(0, 0, 0, 0);
581
+ return new AXDateTime(clone, this.name());
582
+ case "week":
583
+ const index = 0;
584
+ const start = index >= 0 ? index : 0;
585
+ const day = clone.getDay();
586
+ const diff = clone.getDate() - day + (start > day ? start - 7 : start);
587
+ clone.setDate(diff);
588
+ return new AXDateTime(clone, this.name()).startOf('day');
589
+ case "month":
590
+ clone.setDate(1);
591
+ return new AXDateTime(clone, this.name()).startOf('day');
592
+ case "year":
593
+ clone.setMonth(0);
594
+ clone.setDate(1);
595
+ return new AXDateTime(clone, this.name()).startOf('day');
596
+ }
597
+ }
598
+ endOf(date, unit) {
599
+ const clone = new Date(date.valueOf());
600
+ switch (unit) {
601
+ case 'second':
602
+ clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 999);
603
+ return new AXDateTime(clone, this.name());
604
+ case 'minute':
605
+ clone.setHours(clone.getHours(), clone.getMinutes(), 59, 999);
606
+ return new AXDateTime(clone, this.name());
607
+ case 'hour':
608
+ clone.setHours(clone.getHours(), 59, 59, 999);
609
+ return new AXDateTime(clone, this.name());
610
+ default:
611
+ case 'day':
612
+ clone.setHours(23, 59, 59, 999);
613
+ return new AXDateTime(clone, this.name());
614
+ case 'week':
615
+ return this.startOf(date, 'week').add('day', 6).endOf('day');
616
+ case 'month':
617
+ return new AXDateTime(new Date(date.getFullYear(), date.getMonth() + 1, 0), this.name()).endOf('day');
618
+ case "year":
619
+ clone.setMonth(11);
620
+ return new AXDateTime(clone, this.name()).endOf('month');
621
+ }
622
+ }
623
+ isLeap(date) {
624
+ let leapYear = new Date(date.getFullYear(), 1, 29);
625
+ return leapYear.getDate() == 29;
626
+ }
627
+ }
628
+
629
+ class JalaliCalendar {
630
+ constructor() {
631
+ this.monthNames = ("فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند").split("_");
632
+ this.monthShortNames = ("فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند").split("_");
633
+ this.dayNames = ("شنبه_یکشنبه_دوشنبه_سه شنبه_چهارشنبه_پنج شنبه_جمعه").split("_");
634
+ this.dayShortNames = "ش_ی_د_س_چ_پ_ج".split("_");
635
+ }
636
+ name() {
637
+ return 'jalali';
638
+ }
639
+ dayOfMonth(date) {
640
+ return this.toJalali(date).day;
641
+ }
642
+ dayOfYear(date) {
643
+ const j = this.toJalali(date);
644
+ return (j.month <= 6 ? ((j.month - 1) * 31) : ((6 * 31) + (j.month - 7) * 30)) + j.day;
645
+ }
646
+ dayOfWeek(date) {
647
+ return date.getDay() == 6 ? 1 : date.getDay() + 2;
648
+ }
649
+ weekOfYear(date) {
650
+ //TODO : apply jalali
651
+ const firstDay = new AXDateTime(date).startOf('year');
652
+ return Math.ceil((((date.getTime() - firstDay.date.getTime()) / 86400000) + firstDay.date.getDay() + 1) / 7);
653
+ }
654
+ year(date) {
655
+ return this.toJalali(date).year;
656
+ }
657
+ monthOfYear(date) {
658
+ return this.toJalali(date).month;
659
+ }
660
+ add(date, unit, amount) {
661
+ let value = date.valueOf();
662
+ switch (unit) {
663
+ case 'second':
664
+ value += 1000 * amount;
665
+ break;
666
+ case 'minute':
667
+ value += 60000 * amount;
668
+ break;
669
+ case 'hour':
670
+ value += 3600000 * amount;
671
+ break;
672
+ case 'month':
673
+ {
674
+ const v = new Date(value);
675
+ let jd = this.dayOfMonth(date);
676
+ let jm = this.monthOfYear(date);
677
+ let jy = this.year(date);
678
+ jm = (jm + amount) % 12;
679
+ if (0 > jm) {
680
+ jy += (this.monthOfYear(date) + amount - jm - 12) / 12;
681
+ jm += 12;
682
+ }
683
+ else {
684
+ jy += ((this.monthOfYear(date) + amount - jm) / 12);
685
+ }
686
+ const vv = this.toGregorian(jy, jm, jd);
687
+ v.setFullYear(vv.getFullYear());
688
+ v.setMonth(vv.getMonth());
689
+ v.setDate(vv.getDate());
690
+ value = v.valueOf();
691
+ break;
692
+ }
693
+ case 'week':
694
+ value += 7 * 86400000 * amount;
695
+ break;
696
+ case 'year':
697
+ {
698
+ const v = new Date(value);
699
+ let jd = this.dayOfMonth(date);
700
+ let jm = this.monthOfYear(date);
701
+ let jy = this.year(date);
702
+ const vv = this.toGregorian(jy + amount, jm, jd);
703
+ v.setFullYear(vv.getFullYear());
704
+ v.setMonth(vv.getMonth());
705
+ v.setDate(vv.getDate());
706
+ value = v.valueOf();
707
+ }
708
+ break;
709
+ case 'day':
710
+ default:
711
+ value += 86400000 * amount;
712
+ }
713
+ return new AXDateTime(new Date(value), this.name());
714
+ }
715
+ set(date, unit, value) {
716
+ throw new Error("Method not implemented.");
717
+ }
718
+ startOf(date, unit) {
719
+ const clone = new Date(date.valueOf());
720
+ switch (unit) {
721
+ case 'second':
722
+ clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 0);
723
+ return new AXDateTime(clone, this.name());
724
+ case 'minute':
725
+ clone.setHours(clone.getHours(), clone.getMinutes(), 0, 0);
726
+ return new AXDateTime(clone, this.name());
727
+ case 'hour':
728
+ clone.setHours(clone.getHours(), 0, 0, 0);
729
+ return new AXDateTime(clone, this.name());
730
+ default:
731
+ case 'day':
732
+ clone.setHours(0, 0, 0, 0);
733
+ return new AXDateTime(clone, this.name());
734
+ case "week":
735
+ return new AXDateTime(clone, this.name()).add('day', -this.dayOfWeek(clone) + 1).startOf('day');
736
+ case "month":
737
+ {
738
+ const jy = this.year(date);
739
+ const jm = this.monthOfYear(date);
740
+ const gDate = this.toGregorian(jy, jm, 1);
741
+ return new AXDateTime(gDate, this.name()).startOf('day');
742
+ }
743
+ case "year":
744
+ {
745
+ const jy = this.year(date);
746
+ const gDate = this.toGregorian(jy, 1, 1);
747
+ return new AXDateTime(gDate, this.name()).startOf('day');
748
+ }
749
+ }
750
+ }
751
+ endOf(date, unit) {
752
+ const clone = new Date(date.valueOf());
753
+ switch (unit) {
754
+ case 'second':
755
+ clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 999);
756
+ return new AXDateTime(clone, this.name());
757
+ case 'minute':
758
+ clone.setHours(clone.getHours(), clone.getMinutes(), 59, 999);
759
+ return new AXDateTime(clone, this.name());
760
+ case 'hour':
761
+ clone.setHours(clone.getHours(), 59, 59, 999);
762
+ return new AXDateTime(clone, this.name());
763
+ default:
764
+ case 'day':
765
+ clone.setHours(23, 59, 59, 999);
766
+ return new AXDateTime(clone, this.name());
767
+ case 'week':
768
+ {
769
+ return this.startOf(date, 'week').add('day', 6).endOf('day');
770
+ }
771
+ case 'month':
772
+ {
773
+ const jy = this.year(date);
774
+ const jm = this.monthOfYear(date);
775
+ const jd = this.monthLength(jy, jm);
776
+ const gDate = this.toGregorian(jy, jm, jd);
777
+ return new AXDateTime(gDate, this.name()).endOf('day');
778
+ }
779
+ case "year":
780
+ let jy = this.year(date);
781
+ const gDate = this.toGregorian(jy, 12, this.monthLength(jy, 12));
782
+ return new AXDateTime(gDate, this.name()).endOf('day');
783
+ }
784
+ }
785
+ toJalali(date) {
786
+ const gy = date.getFullYear();
787
+ const gm = date.getMonth() + 1;
788
+ const gd = date.getDate();
789
+ const r = this.d2j(this.g2d(gy, gm, gd));
790
+ return {
791
+ year: r.jy,
792
+ month: r.jm,
793
+ day: r.jd,
794
+ };
795
+ }
796
+ /*
797
+ Converts a Jalaali date to Gregorian.
798
+ */
799
+ toGregorian(jy, jm, jd) {
800
+ const g = this.d2g(this.j2d(jy, jm, jd));
801
+ return new Date(g.gy, g.gm - 1, g.gd);
802
+ }
803
+ /*
804
+ Checks whether a Jalaali date is valid or not.
805
+ */
806
+ isValid(jy, jm, jd) {
807
+ return jy >= -61 && jy <= 3177 &&
808
+ jm >= 1 && jm <= 12 &&
809
+ jd >= 1 && jd <= this.monthLength(jy, jm);
810
+ }
811
+ /*
812
+ Is this a leap year or not?
813
+ */
814
+ isLeapYear(jy) {
815
+ return this.jalCal(jy).leap === 0;
816
+ }
817
+ /*
818
+ Number of days in a given month in a Jalaali year.
819
+ */
820
+ monthLength(jy, jm) {
821
+ if (jm <= 6)
822
+ return 31;
823
+ if (jm <= 11)
824
+ return 30;
825
+ if (this.isLeapYear(jy))
826
+ return 30;
827
+ return 29;
828
+ }
829
+ jalCal(jy) {
830
+ // Jalaali years starting the 33-year rule.
831
+ let breaks = [-61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210,
832
+ 1635, 2060, 2097, 2192, 2262, 2324, 2394, 2456, 3178
833
+ ], bl = breaks.length, gy = jy + 621, leapJ = -14, jp = breaks[0], jm, jump, leap, leapG, march, n, i;
834
+ if (jy < jp || jy >= breaks[bl - 1])
835
+ throw new Error('Invalid Jalaali year ' + jy);
836
+ // Find the limiting years for the Jalaali year jy.
837
+ for (i = 1; i < bl; i += 1) {
838
+ jm = breaks[i];
839
+ jump = jm - jp;
840
+ if (jy < jm)
841
+ break;
842
+ leapJ = leapJ + this.div(jump, 33) * 8 + this.div(this.mod(jump, 33), 4);
843
+ jp = jm;
844
+ }
845
+ n = jy - jp;
846
+ // Find the number of leap years from AD 621 to the beginning
847
+ // of the current Jalaali year in the Persian calendar.
848
+ leapJ = leapJ + this.div(n, 33) * 8 + this.div(this.mod(n, 33) + 3, 4);
849
+ if (this.mod(jump, 33) === 4 && jump - n === 4)
850
+ leapJ += 1;
851
+ // And the same in the Gregorian calendar (until the year gy).
852
+ leapG = this.div(gy, 4) - this.div((this.div(gy, 100) + 1) * 3, 4) - 150;
853
+ // Determine the Gregorian date of Farvardin the 1st.
854
+ march = 20 + leapJ - leapG;
855
+ // Find how many years have passed since the last leap year.
856
+ if (jump - n < 6)
857
+ n = n - jump + this.div(jump + 4, 33) * 33;
858
+ leap = this.mod(this.mod(n + 1, 33) - 1, 4);
859
+ if (leap === -1) {
860
+ leap = 4;
861
+ }
862
+ return {
863
+ leap: leap,
864
+ gy: gy,
865
+ march: march
866
+ };
867
+ }
868
+ /*
869
+ Converts a date of the Jalaali calendar to the Julian Day number.
870
+ @param jy Jalaali year (1 to 3100)
871
+ @param jm Jalaali month (1 to 12)
872
+ @param jd Jalaali day (1 to 29/31)
873
+ @return Julian Day number
874
+ */
875
+ j2d(jy, jm, jd) {
876
+ let r = this.jalCal(jy);
877
+ return this.g2d(r.gy, 3, r.march) + (jm - 1) * 31 - this.div(jm, 7) * (jm - 7) + jd - 1;
878
+ }
879
+ /*
880
+ Converts the Julian Day number to a date in the Jalaali calendar.
881
+ @param jdn Julian Day number
882
+ @return
883
+ jy: Jalaali year (1 to 3100)
884
+ jm: Jalaali month (1 to 12)
885
+ jd: Jalaali day (1 to 29/31)
886
+ */
887
+ d2j(jdn) {
888
+ let gy = this.d2g(jdn).gy // Calculate Gregorian year (gy).
889
+ , jy = gy - 621, r = this.jalCal(jy), jdn1f = this.g2d(gy, 3, r.march), jd, jm, k;
890
+ // Find number of days that passed since 1 Farvardin.
891
+ k = jdn - jdn1f;
892
+ if (k >= 0) {
893
+ if (k <= 185) {
894
+ // The first 6 months.
895
+ jm = 1 + this.div(k, 31);
896
+ jd = this.mod(k, 31) + 1;
897
+ return {
898
+ jy: jy,
899
+ jm: jm,
900
+ jd: jd
901
+ };
902
+ }
903
+ else {
904
+ // The remaining months.
905
+ k -= 186;
906
+ }
907
+ }
908
+ else {
909
+ // Previous Jalaali year.
910
+ jy -= 1;
911
+ k += 179;
912
+ if (r.leap === 1)
913
+ k += 1;
914
+ }
915
+ jm = 7 + this.div(k, 30);
916
+ jd = this.mod(k, 30) + 1;
917
+ return {
918
+ jy: jy,
919
+ jm: jm,
920
+ jd: jd
921
+ };
922
+ }
923
+ g2d(gy, gm, gd) {
924
+ let d = this.div((gy + this.div(gm - 8, 6) + 100100) * 1461, 4)
925
+ + this.div(153 * this.mod(gm + 9, 12) + 2, 5)
926
+ + gd - 34840408;
927
+ d = d - this.div(this.div(gy + 100100 + this.div(gm - 8, 6), 100) * 3, 4) + 752;
928
+ return d;
929
+ }
930
+ d2g(jdn) {
931
+ let j, i, gd, gm, gy;
932
+ j = 4 * jdn + 139361631;
933
+ j = j + this.div(this.div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908;
934
+ i = this.div(this.mod(j, 1461), 4) * 5 + 308;
935
+ gd = this.div(this.mod(i, 153), 5) + 1;
936
+ gm = this.mod(this.div(i, 153), 12) + 1;
937
+ gy = this.div(j, 1461) - 100100 + this.div(8 - gm, 6);
938
+ return {
939
+ gy: gy,
940
+ gm: gm,
941
+ gd: gd
942
+ };
943
+ }
944
+ /*
945
+ Utility helper functions.
946
+ */
947
+ div(a, b) {
948
+ return ~~(a / b);
949
+ }
950
+ mod(a, b) {
951
+ return a - ~~(a / b) * b;
952
+ }
953
+ }
954
+
955
+ class AXDateTimeModule {
956
+ constructor() {
957
+ AXConfig.set({
958
+ dateTime: {
959
+ calendars: {
960
+ jalali: new JalaliCalendar(),
961
+ gregorian: new GeorgianCalendar()
962
+ }
963
+ }
964
+ });
965
+ }
966
+ }
967
+ AXDateTimeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
968
+ AXDateTimeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, declarations: [AXDateTimePipe], exports: [AXDateTimePipe] });
969
+ AXDateTimeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, providers: [], imports: [[]] });
970
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, decorators: [{
971
+ type: NgModule,
972
+ args: [{
973
+ imports: [],
974
+ exports: [AXDateTimePipe],
975
+ declarations: [AXDateTimePipe],
976
+ providers: [],
977
+ }]
978
+ }], ctorParameters: function () { return []; } });
979
+
980
+ // @dynamic
981
+ class AXTranslator {
982
+ static get onChange() {
983
+ return AXTranslator.dataChangeSubject.asObservable();
984
+ }
985
+ static load(lang, value) {
986
+ if (typeof value === 'object') {
987
+ if (!AXTranslator[`__data__${lang}`]) {
988
+ AXTranslator[`__data__${lang}`] = {};
989
+ }
990
+ AXTranslator[`__data__${lang}`] = merge(AXTranslator[`__data__${lang}`], value);
991
+ }
992
+ }
993
+ static use(lang) {
994
+ AXTranslator.lang = lang;
995
+ }
996
+ static get(key, lang) {
997
+ return AXObjectUtil.getPropByPath(AXTranslator[`__data__${lang || AXTranslator.lang}`], key) || key;
998
+ }
999
+ }
1000
+ AXTranslator.lang = 'en';
1001
+ AXTranslator.dataChangeSubject = new Subject();
1002
+
1003
+ class AXTranslatorPipe {
1004
+ transform(value, lang) {
1005
+ return AXTranslator.get(value, lang);
1006
+ }
1007
+ }
1008
+ AXTranslatorPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslatorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1009
+ AXTranslatorPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslatorPipe, name: "trans" });
1010
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslatorPipe, decorators: [{
1011
+ type: Pipe,
1012
+ args: [{ name: 'trans', pure: true }]
1013
+ }] });
1014
+
1015
+ class AXTranslationModule {
1016
+ }
1017
+ AXTranslationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1018
+ AXTranslationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, declarations: [AXTranslatorPipe], exports: [AXTranslatorPipe] });
1019
+ AXTranslationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, providers: [], imports: [[]] });
1020
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, decorators: [{
1021
+ type: NgModule,
1022
+ args: [{
1023
+ imports: [],
1024
+ exports: [AXTranslatorPipe],
1025
+ declarations: [AXTranslatorPipe],
1026
+ providers: [],
1027
+ }]
1028
+ }] });
1029
+
1030
+ const isChrome = (win) => testUserAgent(win, /Chrome/i);
1031
+ const isFirefox = (win) => testUserAgent(win, /Firefox/i);
1032
+ const isEdge = (win) => testUserAgent(win, /Edge/i);
1033
+ const isSafari = (win) => testUserAgent(win, /Safari/i);
1034
+ const isOpera = (win) => testUserAgent(win, /Opera/i) || testUserAgent(win, /OPR/i);
1035
+ const isMSIE = (win) => testUserAgent(win, /MSIE/i) || testUserAgent(win, /Trident/i);
1036
+ const isMobileWeb = (win) => isMobile(win) && !isHybrid(win);
1037
+ const isIpad = (win) => {
1038
+ // iOS 12 and below
1039
+ if (testUserAgent(win, /iPad/i)) {
1040
+ return true;
1041
+ }
1042
+ // iOS 13+
1043
+ if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
1044
+ return true;
1045
+ }
1046
+ return false;
1047
+ };
1048
+ const isIphone = (win) => testUserAgent(win, /iPhone/i);
1049
+ const isIOS = (win) => testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
1050
+ const isAndroid = (win) => testUserAgent(win, /android|sink/i);
1051
+ const isAndroidTablet = (win) => {
1052
+ return isAndroid(win) && !testUserAgent(win, /mobile/i);
1053
+ };
1054
+ const isPhablet = (win) => {
1055
+ const width = win.innerWidth;
1056
+ const height = win.innerHeight;
1057
+ const smallest = Math.min(width, height);
1058
+ const largest = Math.max(width, height);
1059
+ return (smallest > 390 && smallest < 520) &&
1060
+ (largest > 620 && largest < 800);
1061
+ };
1062
+ const isTablet = (win) => {
1063
+ const width = win.innerWidth;
1064
+ const height = win.innerHeight;
1065
+ const smallest = Math.min(width, height);
1066
+ const largest = Math.max(width, height);
1067
+ return (isIpad(win) ||
1068
+ isAndroidTablet(win) ||
1069
+ ((smallest > 460 && smallest < 820) &&
1070
+ (largest > 780 && largest < 1400)));
1071
+ };
1072
+ const isMobile = (win) => matchMedia(win, '(any-pointer:coarse)');
1073
+ const isDesktop = (win) => !isMobile(win);
1074
+ const isHybrid = (win) => isCordova(win) || isCapacitorNative(win);
1075
+ const isCordova = (win) => !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
1076
+ const isCapacitorNative = (win) => {
1077
+ const capacitor = win['Capacitor'];
1078
+ return !!(capacitor && capacitor.isNative);
1079
+ };
1080
+ const isElectron = (win) => testUserAgent(win, /electron/i);
1081
+ const isPWA = (win) => !!(win.matchMedia('(display-mode: standalone)').matches || win.navigator.standalone);
1082
+ const testUserAgent = (win, expr) => expr.test(win.navigator.userAgent);
1083
+ const matchMedia = (win, query) => win.matchMedia(query).matches;
1084
+ const PLATFORMS_MAP = {
1085
+ 'Android': isAndroid,
1086
+ 'iOS': isIOS,
1087
+ 'Desktop': isDesktop,
1088
+ 'Mobile': isMobile,
1089
+ 'Chrome': isChrome,
1090
+ 'Firefox': isFirefox,
1091
+ 'Safari': isSafari,
1092
+ 'Edge': isEdge,
1093
+ 'Opera': isOpera,
1094
+ 'Hybrid': isHybrid,
1095
+ 'PWA': isPWA,
1096
+ 'Electron': isElectron,
1097
+ };
1098
+ class AXPlatformEvent {
1099
+ }
1100
+ class AXPlatform {
1101
+ constructor() {
1102
+ this.resize = new Subject();
1103
+ this.click = new Subject();
1104
+ this.scroll = new Subject();
1105
+ window.addEventListener('resize', (e) => {
1106
+ this.resize.next({
1107
+ nativeEvent: e,
1108
+ source: this
1109
+ });
1110
+ });
1111
+ document.addEventListener('click', (e) => {
1112
+ this.click.next({
1113
+ nativeEvent: e,
1114
+ source: this
1115
+ });
1116
+ }, true);
1117
+ document.addEventListener('scroll', (e) => {
1118
+ this.scroll.next({
1119
+ nativeEvent: e,
1120
+ source: this
1121
+ });
1122
+ }, true);
1123
+ }
1124
+ isRtl() {
1125
+ return document.dir == 'rtl' || document.body.dir == 'rtl' || document.body.style.direction == 'rtl';
1126
+ }
1127
+ isLandscape() {
1128
+ return window.innerHeight < window.innerWidth;
1129
+ }
1130
+ isPortrate() {
1131
+ return !this.isLandscape();
1132
+ }
1133
+ is(name) {
1134
+ return PLATFORMS_MAP[name](window) || false;
1135
+ }
1136
+ switchDarkMode() {
1137
+ const _html = document.getElementsByTagName("html")[0];
1138
+ const _class = 'ax-dark-mode';
1139
+ const _isDark = _html.classList.contains(_class);
1140
+ if (_isDark) {
1141
+ _html.classList.remove(_class);
1142
+ localStorage.setItem("MODE", "light");
1143
+ }
1144
+ else {
1145
+ _html.classList.add(_class);
1146
+ localStorage.setItem("MODE", "dark");
1147
+ }
1148
+ }
1149
+ }
1150
+ AXPlatform.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXPlatform, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1151
+ AXPlatform.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXPlatform, providedIn: 'platform' });
1152
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXPlatform, decorators: [{
1153
+ type: Injectable,
1154
+ args: [{
1155
+ providedIn: 'platform',
1156
+ }]
1157
+ }], ctorParameters: function () { return []; } });
1158
+
1159
+ /**
1160
+ * Public API refrences of core libraries
1161
+ * @module @acorex/core
1162
+ */
1163
+
1164
+ /**
1165
+ * Generated bundle index. Do not edit.
1166
+ */
1167
+
1168
+ export { AXCalendarMonth, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXDrawingUtil, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXTranslationModule, AXTranslator, AXTranslatorPipe, GeorgianCalendar, testUserAgent };
1169
+ //# sourceMappingURL=acorex-core.js.map