@stemy/ngx-utils 13.6.10 → 13.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/ngx-utils/utils/cached-factory.mjs +21 -0
- package/esm2020/public_api.mjs +6 -5
- package/fesm2015/stemy-ngx-utils.mjs +1259 -1239
- package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
- package/fesm2020/stemy-ngx-utils.mjs +1238 -1218
- package/fesm2020/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/utils/cached-factory.d.ts +3 -0
- package/package.json +1 -1
- package/public_api.d.ts +5 -4
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, PLATFORM_ID, Injectable, Inject, Optional, Injector, EventEmitter, isDevMode, ErrorHandler, NgZone, Pipe, Directive, Input, Output, HostBinding, HostListener, Component, ContentChildren, ViewChild, ContentChild, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
|
-
import moment from 'moment';
|
|
5
|
-
import { first, skipWhile, mergeMap, timeout, map } from 'rxjs/operators';
|
|
6
|
-
import { Subject, BehaviorSubject, Observable, Subscription, from, TimeoutError, combineLatest } from 'rxjs';
|
|
7
|
-
import { Invokable } from 'invokable';
|
|
8
4
|
import * as i2 from '@angular/router';
|
|
9
5
|
import { ActivatedRouteSnapshot, NavigationEnd, DefaultUrlSerializer, UrlTree, UrlSegmentGroup, UrlSegment, UrlSerializer } from '@angular/router';
|
|
6
|
+
import { BehaviorSubject, Observable, Subject, Subscription, from, TimeoutError, combineLatest } from 'rxjs';
|
|
7
|
+
import { skipWhile, first, mergeMap, timeout, map } from 'rxjs/operators';
|
|
10
8
|
import * as i1$3 from '@angular/common';
|
|
11
9
|
import { isPlatformBrowser, isPlatformServer, DOCUMENT, APP_BASE_HREF, CommonModule } from '@angular/common';
|
|
12
10
|
import * as i1 from 'ngx-device-detector';
|
|
13
11
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
|
12
|
+
import moment from 'moment';
|
|
13
|
+
import { Invokable } from 'invokable';
|
|
14
14
|
import * as i1$1 from '@angular/common/http';
|
|
15
15
|
import { HttpClient, HttpHeaders, HttpParams, HttpUrlEncodingCodec, HttpEventType } from '@angular/common/http';
|
|
16
16
|
import JSON5 from 'json5';
|
|
@@ -530,1259 +530,1385 @@ class AjaxRequestHandler {
|
|
|
530
530
|
}
|
|
531
531
|
AjaxRequestHandler.isOverridden = false;
|
|
532
532
|
|
|
533
|
-
class
|
|
534
|
-
static
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
return
|
|
533
|
+
class ArrayUtils {
|
|
534
|
+
static has(arr, ...items) {
|
|
535
|
+
if (!ObjectUtils.isArray(arr) || !ObjectUtils.isArray(items))
|
|
536
|
+
return false;
|
|
537
|
+
for (let i = 0; i < items.length; i++) {
|
|
538
|
+
if (arr.indexOf(items[i]) >= 0)
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
541
|
+
return false;
|
|
542
542
|
}
|
|
543
|
-
static
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
let
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
remaining--;
|
|
543
|
+
static match(arr, str) {
|
|
544
|
+
if (!ObjectUtils.isArray(arr) || !ObjectUtils.isString(str))
|
|
545
|
+
return false;
|
|
546
|
+
for (let i = 0; i < arr.length; i++) {
|
|
547
|
+
if (arr[i] instanceof RegExp) {
|
|
548
|
+
const regex = arr[i];
|
|
549
|
+
if (regex.test(str))
|
|
550
|
+
return true;
|
|
552
551
|
}
|
|
553
552
|
}
|
|
554
|
-
return
|
|
555
|
-
}
|
|
556
|
-
static businessSubtract(date, amount, unit) {
|
|
557
|
-
return DateUtils.businessAdd(date, -amount, unit);
|
|
553
|
+
return false;
|
|
558
554
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
this.next = null;
|
|
555
|
+
static any(arr, cb) {
|
|
556
|
+
if (!ObjectUtils.isArray(arr) || !ObjectUtils.isFunction(cb))
|
|
557
|
+
return false;
|
|
558
|
+
for (let i = 0; i < arr.length; i++) {
|
|
559
|
+
if (cb(arr[i]))
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
return false;
|
|
568
563
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328,
|
|
576
|
-
320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456,
|
|
577
|
-
446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335,
|
|
578
|
-
329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512,
|
|
579
|
-
505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405,
|
|
580
|
-
399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328,
|
|
581
|
-
324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271,
|
|
582
|
-
268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456,
|
|
583
|
-
451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388,
|
|
584
|
-
385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335,
|
|
585
|
-
332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
|
|
586
|
-
289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259
|
|
587
|
-
];
|
|
588
|
-
const shg_table = [
|
|
589
|
-
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
|
590
|
-
17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
|
|
591
|
-
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
|
|
592
|
-
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
|
|
593
|
-
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
|
594
|
-
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
|
|
595
|
-
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
|
596
|
-
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
|
|
597
|
-
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
598
|
-
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
599
|
-
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
600
|
-
23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
601
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
602
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
603
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
604
|
-
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
|
605
|
-
];
|
|
606
|
-
class CanvasUtils {
|
|
607
|
-
static manipulatePixels(canvas, ctx, colorTransformer) {
|
|
608
|
-
const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
609
|
-
const pixels = imgData.data;
|
|
610
|
-
for (let i = 0, n = pixels.length; i < n; i += 4) {
|
|
611
|
-
const clr = new CanvasColor(pixels[i], pixels[i + 1], pixels[i + 2], pixels[i + 3]);
|
|
612
|
-
const greyscale = clr.r * .3 + clr.g * .59 + clr.b * .11;
|
|
613
|
-
const color = colorTransformer(clr, greyscale);
|
|
614
|
-
pixels[i] = color.r;
|
|
615
|
-
pixels[i + 1] = color.g;
|
|
616
|
-
pixels[i + 2] = color.b;
|
|
617
|
-
pixels[i + 3] = color.a;
|
|
564
|
+
static move(arr, oldIndex, newIndex) {
|
|
565
|
+
if (!ObjectUtils.isArray(arr))
|
|
566
|
+
return [];
|
|
567
|
+
const length = arr.length;
|
|
568
|
+
while (oldIndex < 0) {
|
|
569
|
+
oldIndex += length;
|
|
618
570
|
}
|
|
619
|
-
|
|
571
|
+
while (newIndex < 0) {
|
|
572
|
+
newIndex += length;
|
|
573
|
+
}
|
|
574
|
+
if (newIndex >= length) {
|
|
575
|
+
let k = newIndex - length + 1;
|
|
576
|
+
while (k--) {
|
|
577
|
+
arr.push(undefined);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
arr.splice(newIndex, 0, arr.splice(oldIndex, 1)[0]);
|
|
581
|
+
return arr;
|
|
620
582
|
}
|
|
621
|
-
static
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
});
|
|
583
|
+
static reversed(arr) {
|
|
584
|
+
const result = [];
|
|
585
|
+
if (!ObjectUtils.isArray(arr))
|
|
586
|
+
return result;
|
|
587
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
588
|
+
result.push(arr[i]);
|
|
589
|
+
}
|
|
590
|
+
return result;
|
|
630
591
|
}
|
|
631
|
-
static
|
|
632
|
-
if (
|
|
633
|
-
return;
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
try {
|
|
642
|
-
imageData = ctx.getImageData(top_x, top_y, width, height);
|
|
592
|
+
static min(arr, cb) {
|
|
593
|
+
if (!ObjectUtils.isArray(arr))
|
|
594
|
+
return null;
|
|
595
|
+
let min = Number.MAX_SAFE_INTEGER;
|
|
596
|
+
let result = null;
|
|
597
|
+
for (let i = 0; i < arr.length; i++) {
|
|
598
|
+
const current = cb(arr[i], i);
|
|
599
|
+
if (current < min || result === null) {
|
|
600
|
+
min = current;
|
|
601
|
+
result = arr[i];
|
|
643
602
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
603
|
+
}
|
|
604
|
+
return result;
|
|
605
|
+
}
|
|
606
|
+
static max(arr, cb) {
|
|
607
|
+
if (!ObjectUtils.isArray(arr))
|
|
608
|
+
return null;
|
|
609
|
+
let max = Number.MIN_SAFE_INTEGER;
|
|
610
|
+
let result = null;
|
|
611
|
+
for (let i = 0; i < arr.length; i++) {
|
|
612
|
+
const current = cb(arr[i], i);
|
|
613
|
+
if (current > max || result === null) {
|
|
614
|
+
max = current;
|
|
615
|
+
result = arr[i];
|
|
656
616
|
}
|
|
657
617
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
618
|
+
return result;
|
|
619
|
+
}
|
|
620
|
+
static chunk(arr, size) {
|
|
621
|
+
if (!ObjectUtils.isArray(arr))
|
|
622
|
+
return [];
|
|
623
|
+
size = Math.max(1, size);
|
|
624
|
+
const result = [];
|
|
625
|
+
for (let i = 0; i < arr.length; i += size) {
|
|
626
|
+
result.push(arr.slice(i, i + size));
|
|
661
627
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
628
|
+
return result;
|
|
629
|
+
}
|
|
630
|
+
static unique(arr) {
|
|
631
|
+
if (!ObjectUtils.isArray(arr))
|
|
632
|
+
return [];
|
|
633
|
+
return arr.filter((value, index, self) => {
|
|
634
|
+
return self.indexOf(value) === index;
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Use this service to determine which is the current environment
|
|
641
|
+
*/
|
|
642
|
+
class UniversalService {
|
|
643
|
+
constructor(platformId, dds) {
|
|
644
|
+
this.platformId = platformId;
|
|
645
|
+
this.dds = dds;
|
|
646
|
+
const info = this.dds.getDeviceInfo();
|
|
647
|
+
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
|
|
648
|
+
}
|
|
649
|
+
get isBrowser() {
|
|
650
|
+
return isPlatformBrowser(this.platformId);
|
|
651
|
+
}
|
|
652
|
+
get isServer() {
|
|
653
|
+
return isPlatformServer(this.platformId);
|
|
654
|
+
}
|
|
655
|
+
get deviceInfo() {
|
|
656
|
+
return this.isServer
|
|
657
|
+
? {
|
|
658
|
+
userAgent: "angular-universal",
|
|
659
|
+
os: "unknown",
|
|
660
|
+
browser: "node",
|
|
661
|
+
device: "node",
|
|
662
|
+
os_version: "unknown",
|
|
663
|
+
browser_version: "unknown",
|
|
664
|
+
deviceType: "unknown",
|
|
665
|
+
orientation: "landscape"
|
|
676
666
|
}
|
|
677
|
-
|
|
678
|
-
stack.next = stackStart;
|
|
679
|
-
let stackIn = null;
|
|
680
|
-
let stackOut = null;
|
|
681
|
-
yw = yi = 0;
|
|
682
|
-
const mul_sum = mul_table[radius];
|
|
683
|
-
const shg_sum = shg_table[radius];
|
|
684
|
-
for (y = 0; y < height; y++) {
|
|
685
|
-
r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;
|
|
686
|
-
r_out_sum = radiusPlus1 * (pr = pixels[yi]);
|
|
687
|
-
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
|
|
688
|
-
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
|
|
689
|
-
a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
|
|
690
|
-
r_sum += sumFactor * pr;
|
|
691
|
-
g_sum += sumFactor * pg;
|
|
692
|
-
b_sum += sumFactor * pb;
|
|
693
|
-
a_sum += sumFactor * pa;
|
|
694
|
-
stack = stackStart;
|
|
695
|
-
for (i = 0; i < radiusPlus1; i++) {
|
|
696
|
-
stack.r = pr;
|
|
697
|
-
stack.g = pg;
|
|
698
|
-
stack.b = pb;
|
|
699
|
-
stack.a = pa;
|
|
700
|
-
stack = stack.next;
|
|
701
|
-
}
|
|
702
|
-
for (i = 1; i < radiusPlus1; i++) {
|
|
703
|
-
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
|
|
704
|
-
r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);
|
|
705
|
-
g_sum += (stack.g = (pg = pixels[p + 1])) * rbs;
|
|
706
|
-
b_sum += (stack.b = (pb = pixels[p + 2])) * rbs;
|
|
707
|
-
a_sum += (stack.a = (pa = pixels[p + 3])) * rbs;
|
|
708
|
-
r_in_sum += pr;
|
|
709
|
-
g_in_sum += pg;
|
|
710
|
-
b_in_sum += pb;
|
|
711
|
-
a_in_sum += pa;
|
|
712
|
-
stack = stack.next;
|
|
713
|
-
}
|
|
714
|
-
stackIn = stackStart;
|
|
715
|
-
stackOut = stackEnd;
|
|
716
|
-
for (x = 0; x < width; x++) {
|
|
717
|
-
pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
|
|
718
|
-
if (pa != 0) {
|
|
719
|
-
pa = 255 / pa;
|
|
720
|
-
pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;
|
|
721
|
-
pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
|
|
722
|
-
pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
|
|
723
|
-
}
|
|
724
|
-
else {
|
|
725
|
-
pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
|
|
726
|
-
}
|
|
727
|
-
r_sum -= r_out_sum;
|
|
728
|
-
g_sum -= g_out_sum;
|
|
729
|
-
b_sum -= b_out_sum;
|
|
730
|
-
a_sum -= a_out_sum;
|
|
731
|
-
r_out_sum -= stackIn.r;
|
|
732
|
-
g_out_sum -= stackIn.g;
|
|
733
|
-
b_out_sum -= stackIn.b;
|
|
734
|
-
a_out_sum -= stackIn.a;
|
|
735
|
-
p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;
|
|
736
|
-
r_in_sum += (stackIn.r = pixels[p]);
|
|
737
|
-
g_in_sum += (stackIn.g = pixels[p + 1]);
|
|
738
|
-
b_in_sum += (stackIn.b = pixels[p + 2]);
|
|
739
|
-
a_in_sum += (stackIn.a = pixels[p + 3]);
|
|
740
|
-
r_sum += r_in_sum;
|
|
741
|
-
g_sum += g_in_sum;
|
|
742
|
-
b_sum += b_in_sum;
|
|
743
|
-
a_sum += a_in_sum;
|
|
744
|
-
stackIn = stackIn.next;
|
|
745
|
-
r_out_sum += (pr = stackOut.r);
|
|
746
|
-
g_out_sum += (pg = stackOut.g);
|
|
747
|
-
b_out_sum += (pb = stackOut.b);
|
|
748
|
-
a_out_sum += (pa = stackOut.a);
|
|
749
|
-
r_in_sum -= pr;
|
|
750
|
-
g_in_sum -= pg;
|
|
751
|
-
b_in_sum -= pb;
|
|
752
|
-
a_in_sum -= pa;
|
|
753
|
-
stackOut = stackOut.next;
|
|
754
|
-
yi += 4;
|
|
755
|
-
}
|
|
756
|
-
yw += width;
|
|
757
|
-
}
|
|
758
|
-
for (x = 0; x < width; x++) {
|
|
759
|
-
g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;
|
|
760
|
-
yi = x << 2;
|
|
761
|
-
r_out_sum = radiusPlus1 * (pr = pixels[yi]);
|
|
762
|
-
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
|
|
763
|
-
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
|
|
764
|
-
a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
|
|
765
|
-
r_sum += sumFactor * pr;
|
|
766
|
-
g_sum += sumFactor * pg;
|
|
767
|
-
b_sum += sumFactor * pb;
|
|
768
|
-
a_sum += sumFactor * pa;
|
|
769
|
-
stack = stackStart;
|
|
770
|
-
for (i = 0; i < radiusPlus1; i++) {
|
|
771
|
-
stack.r = pr;
|
|
772
|
-
stack.g = pg;
|
|
773
|
-
stack.b = pb;
|
|
774
|
-
stack.a = pa;
|
|
775
|
-
stack = stack.next;
|
|
776
|
-
}
|
|
777
|
-
yp = width;
|
|
778
|
-
for (i = 1; i <= radius; i++) {
|
|
779
|
-
yi = (yp + x) << 2;
|
|
780
|
-
r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);
|
|
781
|
-
g_sum += (stack.g = (pg = pixels[yi + 1])) * rbs;
|
|
782
|
-
b_sum += (stack.b = (pb = pixels[yi + 2])) * rbs;
|
|
783
|
-
a_sum += (stack.a = (pa = pixels[yi + 3])) * rbs;
|
|
784
|
-
r_in_sum += pr;
|
|
785
|
-
g_in_sum += pg;
|
|
786
|
-
b_in_sum += pb;
|
|
787
|
-
a_in_sum += pa;
|
|
788
|
-
stack = stack.next;
|
|
789
|
-
if (i < heightMinus1) {
|
|
790
|
-
yp += width;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
yi = x;
|
|
794
|
-
stackIn = stackStart;
|
|
795
|
-
stackOut = stackEnd;
|
|
796
|
-
for (y = 0; y < height; y++) {
|
|
797
|
-
p = yi << 2;
|
|
798
|
-
pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
|
|
799
|
-
if (pa > 0) {
|
|
800
|
-
pa = 255 / pa;
|
|
801
|
-
pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;
|
|
802
|
-
pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
|
|
803
|
-
pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
|
|
804
|
-
}
|
|
805
|
-
else {
|
|
806
|
-
pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;
|
|
807
|
-
}
|
|
808
|
-
r_sum -= r_out_sum;
|
|
809
|
-
g_sum -= g_out_sum;
|
|
810
|
-
b_sum -= b_out_sum;
|
|
811
|
-
a_sum -= a_out_sum;
|
|
812
|
-
r_out_sum -= stackIn.r;
|
|
813
|
-
g_out_sum -= stackIn.g;
|
|
814
|
-
b_out_sum -= stackIn.b;
|
|
815
|
-
a_out_sum -= stackIn.a;
|
|
816
|
-
p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;
|
|
817
|
-
r_sum += (r_in_sum += (stackIn.r = pixels[p]));
|
|
818
|
-
g_sum += (g_in_sum += (stackIn.g = pixels[p + 1]));
|
|
819
|
-
b_sum += (b_in_sum += (stackIn.b = pixels[p + 2]));
|
|
820
|
-
a_sum += (a_in_sum += (stackIn.a = pixels[p + 3]));
|
|
821
|
-
stackIn = stackIn.next;
|
|
822
|
-
r_out_sum += (pr = stackOut.r);
|
|
823
|
-
g_out_sum += (pg = stackOut.g);
|
|
824
|
-
b_out_sum += (pb = stackOut.b);
|
|
825
|
-
a_out_sum += (pa = stackOut.a);
|
|
826
|
-
r_in_sum -= pr;
|
|
827
|
-
g_in_sum -= pg;
|
|
828
|
-
b_in_sum -= pb;
|
|
829
|
-
a_in_sum -= pa;
|
|
830
|
-
stackOut = stackOut.next;
|
|
831
|
-
yi += width;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
ctx.putImageData(imageData, top_x, top_y);
|
|
667
|
+
: this.dds.getDeviceInfo();
|
|
835
668
|
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
const context = canvas.getContext("2d");
|
|
839
|
-
if (!canvas) {
|
|
840
|
-
canvas = document.createElement("canvas");
|
|
841
|
-
document.body.appendChild(canvas);
|
|
842
|
-
}
|
|
843
|
-
canvas.width = maxWidth + maxHeight;
|
|
844
|
-
canvas.height = maxHeight * 2;
|
|
845
|
-
let fontSize = CanvasUtils.halveValidateFontSize(startSize, (size) => {
|
|
846
|
-
CanvasUtils.setFontProps(context, font, size);
|
|
847
|
-
const maxTextLinesWidth = CanvasUtils.getTextWidth(context, lines);
|
|
848
|
-
return maxWidth - maxTextLinesWidth;
|
|
849
|
-
});
|
|
850
|
-
const bitmapHeight = CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, fontSize, lineHeightPercent);
|
|
851
|
-
if (bitmapHeight > maxHeight) {
|
|
852
|
-
fontSize = CanvasUtils.halveValidateFontSize(fontSize, (size) => {
|
|
853
|
-
return maxHeight - CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, size, lineHeightPercent);
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
return fontSize;
|
|
669
|
+
get browserName() {
|
|
670
|
+
return (this.dds.browser || "").toLowerCase();
|
|
857
671
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
for (let i = 0; i < lines.length; i++) {
|
|
861
|
-
const line = lines[i];
|
|
862
|
-
context.fillText(line, x, y);
|
|
863
|
-
if (i < lines.length - 1) {
|
|
864
|
-
y += size * lineHeightPercent;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
return y;
|
|
672
|
+
get browserVersion() {
|
|
673
|
+
return this.dds.browser_version;
|
|
868
674
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
const lineHeight = context.measureText("M").width * 1.3;
|
|
872
|
-
const lines = [];
|
|
873
|
-
let line = "";
|
|
874
|
-
for (let n = 0; n < words.length; n++) {
|
|
875
|
-
const testLine = line + words[n] + " ";
|
|
876
|
-
const metrics = context.measureText(testLine);
|
|
877
|
-
const testWidth = metrics.width;
|
|
878
|
-
if (testWidth > maxWidth && n > 0) {
|
|
879
|
-
lines.push(line);
|
|
880
|
-
line = words[n] + " ";
|
|
881
|
-
}
|
|
882
|
-
else {
|
|
883
|
-
line = testLine;
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
lines.push(line);
|
|
887
|
-
y -= lineHeight * .5 * lines.length;
|
|
888
|
-
lines.forEach(l => {
|
|
889
|
-
context.fillText(l, x, y);
|
|
890
|
-
y += lineHeight;
|
|
891
|
-
});
|
|
675
|
+
get isExplorer() {
|
|
676
|
+
return this.checkBrowser("ie");
|
|
892
677
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
context.textAlign = align;
|
|
896
|
-
context.textBaseline = baseLine;
|
|
678
|
+
get isEdge() {
|
|
679
|
+
return this.checkBrowser("edge");
|
|
897
680
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
for (let i = 0; i < lines.length; i++) {
|
|
901
|
-
const line = lines[i];
|
|
902
|
-
maxWidth = Math.max(maxWidth, context.measureText(line).width);
|
|
903
|
-
}
|
|
904
|
-
return maxWidth;
|
|
681
|
+
get isChrome() {
|
|
682
|
+
return this.checkBrowser("chrome");
|
|
905
683
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const height = canvas.height;
|
|
909
|
-
context.clearRect(0, 0, width, height);
|
|
910
|
-
const textY = CanvasUtils.drawLines(context, lines, font, fontSize, lineHeightPercent, "left", "top", fontSize * .5, fontSize * .5);
|
|
911
|
-
const imageData = context.getImageData(0, 0, width, height);
|
|
912
|
-
let textHeight = 0;
|
|
913
|
-
yLoop: for (let y = 0; y < height; y++) {
|
|
914
|
-
for (let x = 0; x < width; x++) {
|
|
915
|
-
const index = (x + y * width) * 4;
|
|
916
|
-
if (imageData.data[index + 3] > 0) {
|
|
917
|
-
textHeight = y + 1;
|
|
918
|
-
continue yLoop;
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
return Math.max(textHeight, textY + fontSize);
|
|
684
|
+
get isFirefox() {
|
|
685
|
+
return this.checkBrowser("firefox");
|
|
923
686
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
let lastFontSize = 0;
|
|
927
|
-
let direction;
|
|
928
|
-
for (let i = 0; i < 20; i++) {
|
|
929
|
-
direction = callback(fontSize);
|
|
930
|
-
const tempSize = fontSize;
|
|
931
|
-
if (direction < 0) {
|
|
932
|
-
fontSize = fontSize - (Math.abs(fontSize - lastFontSize) / 2);
|
|
933
|
-
}
|
|
934
|
-
else {
|
|
935
|
-
fontSize = fontSize + (Math.abs(fontSize - lastFontSize) / 2);
|
|
936
|
-
}
|
|
937
|
-
lastFontSize = tempSize;
|
|
938
|
-
if (Math.abs(fontSize - lastFontSize) < 0.1) {
|
|
939
|
-
break;
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
fontSize = Math.floor(fontSize);
|
|
943
|
-
return fontSize;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
class FileUtils {
|
|
948
|
-
static getExtension(file) {
|
|
949
|
-
return file ? file.name.substr(file.name.lastIndexOf(".")).toLowerCase() : null;
|
|
950
|
-
}
|
|
951
|
-
static getName(file) {
|
|
952
|
-
return file ? file.name.substr(0, file.name.lastIndexOf(".")) : null;
|
|
953
|
-
}
|
|
954
|
-
static toFile(blob, fileName) {
|
|
955
|
-
const data = blob;
|
|
956
|
-
data.lastModifiedDate = new Date();
|
|
957
|
-
data.name = fileName.split(/\\|\//g).pop();
|
|
958
|
-
return data;
|
|
959
|
-
}
|
|
960
|
-
static dataToBlob(data) {
|
|
961
|
-
const parts = data.split(",");
|
|
962
|
-
const byteString = atob(parts[1]);
|
|
963
|
-
const mimeString = parts[0].split(":")[1].split(";")[0];
|
|
964
|
-
const ab = new ArrayBuffer(byteString.length);
|
|
965
|
-
const ia = new Uint8Array(ab);
|
|
966
|
-
for (let i = 0; i < byteString.length; i++) {
|
|
967
|
-
ia[i] = byteString.charCodeAt(i);
|
|
968
|
-
}
|
|
969
|
-
return new Blob([ab], { type: mimeString });
|
|
687
|
+
get isSafari() {
|
|
688
|
+
return this.checkBrowser("safari");
|
|
970
689
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
throw Error("FileSaver library is not loaded. Please load it: https://www.npmjs.com/package/file-saver");
|
|
974
|
-
}
|
|
975
|
-
saveAs(blob, fileName);
|
|
690
|
+
get isTablet() {
|
|
691
|
+
return this.dds.isTablet();
|
|
976
692
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
return;
|
|
980
|
-
FileUtils.saveBlob(new Blob([JSON.stringify(json, null, 4)]), fileName);
|
|
693
|
+
get isMobile() {
|
|
694
|
+
return this.dds.isMobile();
|
|
981
695
|
}
|
|
982
|
-
|
|
983
|
-
return
|
|
984
|
-
// @dynamic
|
|
985
|
-
reader => reader.readAsText(file));
|
|
696
|
+
get isDesktop() {
|
|
697
|
+
return this.dds.isDesktop();
|
|
986
698
|
}
|
|
987
|
-
|
|
988
|
-
return
|
|
989
|
-
// @dynamic
|
|
990
|
-
reader => reader.readAsBinaryString(file));
|
|
699
|
+
get isCrawler() {
|
|
700
|
+
return this.crawler;
|
|
991
701
|
}
|
|
992
|
-
|
|
993
|
-
return
|
|
994
|
-
// @dynamic
|
|
995
|
-
reader => reader.readAsDataURL(file));
|
|
702
|
+
checkBrowser(name) {
|
|
703
|
+
return this.browserName.includes(name) || false;
|
|
996
704
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
705
|
+
}
|
|
706
|
+
UniversalService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, deps: [{ token: PLATFORM_ID }, { token: i1.DeviceDetectorService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
707
|
+
UniversalService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService });
|
|
708
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, decorators: [{
|
|
709
|
+
type: Injectable
|
|
710
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
711
|
+
type: Inject,
|
|
712
|
+
args: [PLATFORM_ID]
|
|
713
|
+
}] }, { type: i1.DeviceDetectorService }]; } });
|
|
714
|
+
|
|
715
|
+
const emptySnapshot = new ActivatedRouteSnapshot();
|
|
716
|
+
const emptyData = { id: "" };
|
|
717
|
+
const emptyParams = {};
|
|
718
|
+
const emptySegments = [];
|
|
719
|
+
const emptyComponents = [];
|
|
720
|
+
class StateService extends BehaviorSubject {
|
|
721
|
+
constructor(injector, zone, universal, router = null) {
|
|
722
|
+
super(null);
|
|
723
|
+
this.injector = injector;
|
|
724
|
+
this.zone = zone;
|
|
725
|
+
this.universal = universal;
|
|
726
|
+
this.router = router;
|
|
727
|
+
this.handleRouterEvent = (event) => {
|
|
728
|
+
if (!(event instanceof NavigationEnd))
|
|
1009
729
|
return;
|
|
730
|
+
const routerStateSnapshot = this.router.routerState.snapshot;
|
|
731
|
+
let snapshot = routerStateSnapshot.root;
|
|
732
|
+
let context = this.contexts?.getContext("primary");
|
|
733
|
+
let segments = snapshot.url;
|
|
734
|
+
const components = [];
|
|
735
|
+
const snapshots = [];
|
|
736
|
+
while (snapshot) {
|
|
737
|
+
snapshots.push(snapshot);
|
|
738
|
+
segments = segments.concat(snapshot.url);
|
|
739
|
+
if (context) {
|
|
740
|
+
if (context.outlet && context.outlet.isActivated)
|
|
741
|
+
components.push(context.outlet.component);
|
|
742
|
+
context = context.children.getContext("primary");
|
|
743
|
+
}
|
|
744
|
+
snapshot = snapshot.firstChild;
|
|
1010
745
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
746
|
+
this.comp = components[components.length - 1];
|
|
747
|
+
this.shot = snapshots[snapshots.length - 1];
|
|
748
|
+
this.stateInfo = {
|
|
749
|
+
url: routerStateSnapshot.url,
|
|
750
|
+
segments: segments,
|
|
751
|
+
components: components
|
|
752
|
+
};
|
|
753
|
+
this.next(this.shot);
|
|
754
|
+
};
|
|
755
|
+
if (!this.router)
|
|
756
|
+
return;
|
|
757
|
+
this.globalExtras = {
|
|
758
|
+
queryParamsHandling: "merge"
|
|
759
|
+
};
|
|
760
|
+
this.router.events.subscribe(this.handleRouterEvent);
|
|
761
|
+
this.stateInfo = {
|
|
762
|
+
url: "",
|
|
763
|
+
segments: [],
|
|
764
|
+
components: []
|
|
765
|
+
};
|
|
766
|
+
this.contexts = router.rootContexts;
|
|
1022
767
|
}
|
|
1023
|
-
static
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
const reader = new FileReader();
|
|
1028
|
-
reader.onload = (event) => resolve(event.target.result);
|
|
1029
|
-
reader.onerror = reject;
|
|
1030
|
-
callback(reader);
|
|
768
|
+
static toPath(route, params) {
|
|
769
|
+
let path = route.path || "";
|
|
770
|
+
ObjectUtils.iterate(params, (value, key) => {
|
|
771
|
+
path = path.replace(`:${key}`, `${value}`);
|
|
1031
772
|
});
|
|
773
|
+
return path;
|
|
1032
774
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
class GenericValue extends Subject {
|
|
1036
|
-
constructor(value = null) {
|
|
1037
|
-
super();
|
|
1038
|
-
this._value = value;
|
|
1039
|
-
}
|
|
1040
|
-
get value() {
|
|
1041
|
-
return this._value;
|
|
1042
|
-
}
|
|
1043
|
-
set value(value) {
|
|
1044
|
-
if (value == this._value)
|
|
1045
|
-
return;
|
|
1046
|
-
this._value = value;
|
|
1047
|
-
this.next(value);
|
|
775
|
+
get component() {
|
|
776
|
+
return this.comp;
|
|
1048
777
|
}
|
|
1049
|
-
|
|
1050
|
-
this.
|
|
778
|
+
get snapshot() {
|
|
779
|
+
return this.shot || emptySnapshot;
|
|
1051
780
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
class FileSystemEntry {
|
|
1055
|
-
constructor(label, meta, image, data, parent, openCb) {
|
|
1056
|
-
this.label = label;
|
|
1057
|
-
this.meta = meta;
|
|
1058
|
-
this.image = image;
|
|
1059
|
-
this.data = data;
|
|
1060
|
-
this.parent = parent;
|
|
1061
|
-
this.openCb = openCb;
|
|
1062
|
-
this.path = !parent ? [this] : parent.path.concat([this]);
|
|
1063
|
-
this.level = this.path.length - 1;
|
|
1064
|
-
this.classes = this.path
|
|
1065
|
-
.filter(t => typeof t.data === "string" && t.data.length > 0).map(t => t.data)
|
|
1066
|
-
.concat([`level-${this.level}`]);
|
|
781
|
+
get route() {
|
|
782
|
+
return this.snapshot.routeConfig;
|
|
1067
783
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
this.result.then(res => {
|
|
1071
|
-
if (Array.isArray(res))
|
|
1072
|
-
return;
|
|
1073
|
-
this.result = null;
|
|
1074
|
-
});
|
|
1075
|
-
return this.result;
|
|
784
|
+
get data() {
|
|
785
|
+
return this.snapshot.data || emptyData;
|
|
1076
786
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
class Rect {
|
|
1080
|
-
constructor(x, y, width, height, rotation = 0) {
|
|
1081
|
-
this.x = x;
|
|
1082
|
-
this.y = y;
|
|
1083
|
-
this.width = width;
|
|
1084
|
-
this.height = height;
|
|
1085
|
-
this.rotation = rotation;
|
|
787
|
+
get params() {
|
|
788
|
+
return this.snapshot.params || emptyParams;
|
|
1086
789
|
}
|
|
1087
|
-
get
|
|
1088
|
-
return
|
|
790
|
+
get queryParams() {
|
|
791
|
+
return this.snapshot.queryParams || emptyParams;
|
|
1089
792
|
}
|
|
1090
|
-
get
|
|
1091
|
-
return this.
|
|
793
|
+
get url() {
|
|
794
|
+
return this.stateInfo.url || "";
|
|
1092
795
|
}
|
|
1093
|
-
get
|
|
1094
|
-
return this.
|
|
796
|
+
get urlSegments() {
|
|
797
|
+
return this.stateInfo.segments || emptySegments;
|
|
1095
798
|
}
|
|
1096
|
-
get
|
|
1097
|
-
return this.
|
|
799
|
+
get components() {
|
|
800
|
+
return this.stateInfo.components || emptyComponents;
|
|
1098
801
|
}
|
|
1099
|
-
get
|
|
1100
|
-
return this.
|
|
802
|
+
get routerConfig() {
|
|
803
|
+
return this.router.config;
|
|
1101
804
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
const
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
805
|
+
async reload() {
|
|
806
|
+
const routerStateSnapshot = this.router.routerState.snapshot;
|
|
807
|
+
const resolvers = this.route.resolve || {};
|
|
808
|
+
const keys = Object.keys(resolvers);
|
|
809
|
+
for (const key of keys) {
|
|
810
|
+
const resolver = this.injector.get(resolvers[key]);
|
|
811
|
+
let resolved = resolver.resolve(this.snapshot, routerStateSnapshot);
|
|
812
|
+
if (resolved instanceof Observable) {
|
|
813
|
+
resolved = resolved.toPromise();
|
|
814
|
+
}
|
|
815
|
+
if (resolved instanceof Promise) {
|
|
816
|
+
resolved = await resolved;
|
|
817
|
+
}
|
|
818
|
+
this.data[key] = resolved;
|
|
819
|
+
}
|
|
1117
820
|
}
|
|
1118
|
-
|
|
1119
|
-
return
|
|
821
|
+
async navigateByUrl(url, navigationExtras = {}) {
|
|
822
|
+
return this.navigate(url, navigationExtras);
|
|
1120
823
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
824
|
+
async navigate(url, navigationExtras = {}) {
|
|
825
|
+
if (!this.router)
|
|
826
|
+
return false;
|
|
827
|
+
const [tree, extras] = this.createUrlTree(url, navigationExtras);
|
|
828
|
+
return this.zone.run(() => {
|
|
829
|
+
return this.router.navigateByUrl(tree, extras);
|
|
830
|
+
});
|
|
1123
831
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
832
|
+
async open(url, target = "_blank", navigationExtras = {}) {
|
|
833
|
+
if (!this.router)
|
|
834
|
+
return false;
|
|
835
|
+
const [tree, extras] = this.createUrlTree(url, navigationExtras);
|
|
836
|
+
return this.zone.run(() => {
|
|
837
|
+
return this.openInNewWindow(tree, target) || this.router.navigateByUrl(tree, extras);
|
|
838
|
+
});
|
|
1126
839
|
}
|
|
1127
|
-
|
|
1128
|
-
return
|
|
840
|
+
subscribeImmediately(next, error, complete) {
|
|
841
|
+
return this.pipe(skipWhile(v => v == null)).subscribe(next, error, complete);
|
|
1129
842
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
843
|
+
openInNewWindow(tree, target) {
|
|
844
|
+
if (!this.universal.isBrowser)
|
|
845
|
+
return false;
|
|
846
|
+
const baseUrl = window.location.href.replace(this.router.url, "");
|
|
847
|
+
try {
|
|
848
|
+
const serialized = this.router.serializeUrl(tree);
|
|
849
|
+
const separator = serialized.startsWith("/") ? "" : "/";
|
|
850
|
+
window.open(baseUrl + separator + serialized, target);
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
catch (e) {
|
|
854
|
+
console.log(`Can't open new window: ${e}`);
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
1132
857
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
858
|
+
createUrlTree(url, extras) {
|
|
859
|
+
if (!this.router)
|
|
860
|
+
return null;
|
|
861
|
+
extras = Object.assign(extras, this.globalExtras, extras || {});
|
|
862
|
+
if (ObjectUtils.isArray(url)) {
|
|
863
|
+
return [this.router.createUrlTree(url, extras), extras];
|
|
864
|
+
}
|
|
865
|
+
if (ObjectUtils.isString(url)) {
|
|
866
|
+
return [this.router.parseUrl(url), extras];
|
|
867
|
+
}
|
|
868
|
+
return [url, extras];
|
|
1135
869
|
}
|
|
1136
870
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
871
|
+
StateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: UniversalService }, { token: i2.Router, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
872
|
+
StateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService });
|
|
873
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService, decorators: [{
|
|
874
|
+
type: Injectable
|
|
875
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.NgZone }, { type: UniversalService }, { type: i2.Router, decorators: [{
|
|
876
|
+
type: Optional
|
|
877
|
+
}] }]; } });
|
|
878
|
+
|
|
879
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
880
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
881
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
882
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
883
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
884
|
+
};
|
|
885
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
886
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
887
|
+
};
|
|
888
|
+
class AuthGuard {
|
|
889
|
+
constructor(injector, state, auth) {
|
|
890
|
+
this.injector = injector;
|
|
891
|
+
this.state = state;
|
|
892
|
+
this.auth = auth;
|
|
1150
893
|
}
|
|
1151
|
-
|
|
1152
|
-
return
|
|
894
|
+
static guardAuthenticated(auth) {
|
|
895
|
+
return Promise.resolve(auth.isAuthenticated);
|
|
1153
896
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
return new Point(this.x * p.x, this.y * p.y);
|
|
1157
|
-
}
|
|
1158
|
-
return new Point(this.x * p, this.y * p);
|
|
897
|
+
static guardNotAuthenticated(auth) {
|
|
898
|
+
return Promise.resolve(!auth.isAuthenticated);
|
|
1159
899
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
const y = b.y - this.y;
|
|
1163
|
-
return Math.sqrt(x * x + y * y);
|
|
900
|
+
static guardNothing() {
|
|
901
|
+
return Promise.resolve(true);
|
|
1164
902
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
903
|
+
static guardAuthField(auth, expression = `auth.isAuthenticated`) {
|
|
904
|
+
// @dynamic
|
|
905
|
+
const lambda = () => {
|
|
906
|
+
return Promise.resolve(ObjectUtils.evaluate(expression, { auth }));
|
|
907
|
+
};
|
|
908
|
+
return lambda;
|
|
1168
909
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
|
|
910
|
+
static guardStateField(state, expression = `state.data`) {
|
|
911
|
+
// @dynamic
|
|
912
|
+
const lambda = () => {
|
|
913
|
+
return Promise.resolve(ObjectUtils.evaluate(expression, { state }));
|
|
914
|
+
};
|
|
915
|
+
return lambda;
|
|
1174
916
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
const bSlope = yDelta_b / xDelta_b;
|
|
1182
|
-
const x = (aSlope * bSlope * (a.y - this.y) + bSlope * (a.x + b.x) - aSlope * (b.x + this.x)) / (2 * (bSlope - aSlope));
|
|
1183
|
-
const y = -1 * (x - (a.x + b.x) / 2) / aSlope + (a.y + b.y) / 2;
|
|
1184
|
-
const center = new Point(x, y);
|
|
1185
|
-
return new Circle(center.x, center.y, center.distance(this));
|
|
917
|
+
static guardAuthStateField(auth, state, expression = `auth.isAuthenticated`) {
|
|
918
|
+
// @dynamic
|
|
919
|
+
const lambda = () => {
|
|
920
|
+
return Promise.resolve(ObjectUtils.evaluate(expression, { auth, state }));
|
|
921
|
+
};
|
|
922
|
+
return lambda;
|
|
1186
923
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
const a = Math.asin(c.radius / pd.length);
|
|
1190
|
-
const b = Math.atan2(pd.y, pd.x);
|
|
1191
|
-
// Tangent points
|
|
1192
|
-
let t = b - a;
|
|
1193
|
-
const t1 = new Point(c.x + c.radius * Math.sin(t), c.y + c.radius * -Math.cos(t));
|
|
1194
|
-
t = b + a;
|
|
1195
|
-
const t2 = new Point(c.x + c.radius * -Math.sin(t), c.y + c.radius * Math.cos(t));
|
|
1196
|
-
return [t1, t2];
|
|
924
|
+
static wildRouteMatch(segments) {
|
|
925
|
+
return { consumed: segments };
|
|
1197
926
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
return Math.atan2(diff.y, diff.x) * 180 / Math.PI;
|
|
927
|
+
static noRouteMatch() {
|
|
928
|
+
return null;
|
|
1201
929
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
return p.add(rotated);
|
|
930
|
+
checkRouteMenu(route) {
|
|
931
|
+
if (!route.data || !route.data.name)
|
|
932
|
+
return Promise.resolve(false);
|
|
933
|
+
return this.checkRoute(route);
|
|
1207
934
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
935
|
+
checkRoute(route, next) {
|
|
936
|
+
const routeData = route.data || {};
|
|
937
|
+
if (!routeData.guards)
|
|
938
|
+
return Promise.resolve(!route.canActivate || this.auth.isAuthenticated);
|
|
939
|
+
return new Promise(resolve => {
|
|
940
|
+
const guards = routeData.guards.map(g => {
|
|
941
|
+
const guard = ReflectUtils.resolve(g, this.injector);
|
|
942
|
+
return guard(this.auth, route, next);
|
|
943
|
+
});
|
|
944
|
+
Promise.all(guards).then(results => {
|
|
945
|
+
resolve(results.indexOf(false) < 0);
|
|
946
|
+
});
|
|
947
|
+
});
|
|
1218
948
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
949
|
+
canActivate(next, state) {
|
|
950
|
+
const route = next.routeConfig;
|
|
951
|
+
return new Promise(resolve => {
|
|
952
|
+
this.auth.checkAuthenticated().then(() => {
|
|
953
|
+
this.checkRoute(route, next).then(hasRights => {
|
|
954
|
+
resolve(hasRights);
|
|
955
|
+
if (!hasRights) {
|
|
956
|
+
this.getReturnState(route).then(returnState => {
|
|
957
|
+
if (!returnState)
|
|
958
|
+
return;
|
|
959
|
+
this.state.navigate(returnState, { queryParams: next.queryParams });
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
});
|
|
1221
965
|
}
|
|
1222
|
-
|
|
1223
|
-
if (
|
|
966
|
+
getConfig(route, config, path) {
|
|
967
|
+
if (!config)
|
|
1224
968
|
return null;
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
if (typeof value !== "string")
|
|
1240
|
-
return value;
|
|
1241
|
-
if (value.length < 8) {
|
|
1242
|
-
return value;
|
|
969
|
+
const match = config.findIndex(t => t == route);
|
|
970
|
+
if (match >= 0)
|
|
971
|
+
return config;
|
|
972
|
+
for (const subConfig of config) {
|
|
973
|
+
if (subConfig.path)
|
|
974
|
+
path.push(subConfig.path);
|
|
975
|
+
const loadedChildren = (subConfig["_loadedConfig"] || { routes: null }).routes || subConfig["_loadedRoutes"];
|
|
976
|
+
const match = this.getConfig(route, subConfig.children || loadedChildren, path);
|
|
977
|
+
if (!match) {
|
|
978
|
+
if (subConfig.path)
|
|
979
|
+
path.length -= 1;
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
return match;
|
|
1243
983
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
984
|
+
return null;
|
|
985
|
+
}
|
|
986
|
+
getReturnState(route) {
|
|
987
|
+
if (!route)
|
|
988
|
+
return Promise.resolve(null);
|
|
989
|
+
if (ObjectUtils.isObject(route.data) && ObjectUtils.isArray(route.data.returnState)) {
|
|
990
|
+
return Promise.resolve(route.data.returnState);
|
|
1246
991
|
}
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
|
|
992
|
+
const path = [];
|
|
993
|
+
const config = this.getConfig(route, this.state.routerConfig, path);
|
|
994
|
+
return new Promise(resolve => {
|
|
995
|
+
this.getReturnStateRecursive(config).then(rs => {
|
|
996
|
+
if (!ObjectUtils.isArray(rs)) {
|
|
997
|
+
resolve(rs);
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
resolve(path.concat(rs));
|
|
1001
|
+
});
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
getReturnStateRecursive(config, c = 0) {
|
|
1005
|
+
if (!config || c >= config.length)
|
|
1006
|
+
return Promise.resolve(null);
|
|
1007
|
+
return new Promise(resolve => {
|
|
1008
|
+
const route = config[c];
|
|
1009
|
+
const check = !route.component ? Promise.resolve(false) : this.checkRoute(route);
|
|
1010
|
+
check.then(res => {
|
|
1011
|
+
if (res) {
|
|
1012
|
+
resolve([route.path]);
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
this.getReturnStateRecursive(config, c + 1).then(resolve);
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
AuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard, deps: [{ token: Injector }, { token: StateService }, { token: AUTH_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1021
|
+
AuthGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard });
|
|
1022
|
+
__decorate([
|
|
1023
|
+
FactoryDependencies(AUTH_SERVICE),
|
|
1024
|
+
__metadata("design:type", Function),
|
|
1025
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
1026
|
+
__metadata("design:returntype", Function)
|
|
1027
|
+
], AuthGuard, "guardAuthField", null);
|
|
1028
|
+
__decorate([
|
|
1029
|
+
FactoryDependencies(StateService),
|
|
1030
|
+
__metadata("design:type", Function),
|
|
1031
|
+
__metadata("design:paramtypes", [StateService, String]),
|
|
1032
|
+
__metadata("design:returntype", Function)
|
|
1033
|
+
], AuthGuard, "guardStateField", null);
|
|
1034
|
+
__decorate([
|
|
1035
|
+
FactoryDependencies(AUTH_SERVICE, StateService),
|
|
1036
|
+
__metadata("design:type", Function),
|
|
1037
|
+
__metadata("design:paramtypes", [Object, StateService, String]),
|
|
1038
|
+
__metadata("design:returntype", Function)
|
|
1039
|
+
], AuthGuard, "guardAuthStateField", null);
|
|
1040
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard, decorators: [{
|
|
1041
|
+
type: Injectable
|
|
1042
|
+
}], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
|
|
1043
|
+
type: Inject,
|
|
1044
|
+
args: [Injector]
|
|
1045
|
+
}] }, { type: StateService, decorators: [{
|
|
1046
|
+
type: Inject,
|
|
1047
|
+
args: [StateService]
|
|
1048
|
+
}] }, { type: undefined, decorators: [{
|
|
1049
|
+
type: Inject,
|
|
1050
|
+
args: [AUTH_SERVICE]
|
|
1051
|
+
}] }]; } });
|
|
1052
|
+
|
|
1053
|
+
function cachedFactory(types) {
|
|
1054
|
+
let cached = null;
|
|
1055
|
+
return (injector) => {
|
|
1056
|
+
if (cached !== null) {
|
|
1057
|
+
return cached;
|
|
1058
|
+
}
|
|
1059
|
+
const subInjector = Injector.create({
|
|
1060
|
+
providers: types.map(type => {
|
|
1061
|
+
return {
|
|
1062
|
+
provide: type,
|
|
1063
|
+
useClass: type,
|
|
1064
|
+
};
|
|
1065
|
+
}),
|
|
1066
|
+
parent: injector
|
|
1067
|
+
});
|
|
1068
|
+
cached = types.map(type => subInjector.get(type));
|
|
1069
|
+
return cached;
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
class BlurStack {
|
|
1074
|
+
constructor() {
|
|
1075
|
+
this.r = 0;
|
|
1076
|
+
this.g = 0;
|
|
1077
|
+
this.b = 0;
|
|
1078
|
+
this.a = 0;
|
|
1079
|
+
this.next = null;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
const mul_table = [
|
|
1083
|
+
512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512,
|
|
1084
|
+
454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512,
|
|
1085
|
+
482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456,
|
|
1086
|
+
437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512,
|
|
1087
|
+
497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328,
|
|
1088
|
+
320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456,
|
|
1089
|
+
446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335,
|
|
1090
|
+
329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512,
|
|
1091
|
+
505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405,
|
|
1092
|
+
399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328,
|
|
1093
|
+
324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271,
|
|
1094
|
+
268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456,
|
|
1095
|
+
451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388,
|
|
1096
|
+
385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335,
|
|
1097
|
+
332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
|
|
1098
|
+
289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259
|
|
1099
|
+
];
|
|
1100
|
+
const shg_table = [
|
|
1101
|
+
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
|
1102
|
+
17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
|
|
1103
|
+
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
|
|
1104
|
+
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
|
|
1105
|
+
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
|
1106
|
+
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
|
|
1107
|
+
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
|
1108
|
+
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
|
|
1109
|
+
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
1110
|
+
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
1111
|
+
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
|
1112
|
+
23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
1113
|
+
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
1114
|
+
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
1115
|
+
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
|
1116
|
+
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
|
1117
|
+
];
|
|
1118
|
+
class CanvasUtils {
|
|
1119
|
+
static manipulatePixels(canvas, ctx, colorTransformer) {
|
|
1120
|
+
const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
1121
|
+
const pixels = imgData.data;
|
|
1122
|
+
for (let i = 0, n = pixels.length; i < n; i += 4) {
|
|
1123
|
+
const clr = new CanvasColor(pixels[i], pixels[i + 1], pixels[i + 2], pixels[i + 3]);
|
|
1124
|
+
const greyscale = clr.r * .3 + clr.g * .59 + clr.b * .11;
|
|
1125
|
+
const color = colorTransformer(clr, greyscale);
|
|
1126
|
+
pixels[i] = color.r;
|
|
1127
|
+
pixels[i + 1] = color.g;
|
|
1128
|
+
pixels[i + 2] = color.b;
|
|
1129
|
+
pixels[i + 3] = color.a;
|
|
1250
1130
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1131
|
+
ctx.putImageData(imgData, 0, 0);
|
|
1132
|
+
}
|
|
1133
|
+
static thresholding(canvas, ctx, threshold = 50, colorTransformer) {
|
|
1134
|
+
const min = new CanvasColor(0, 0, 0, 255);
|
|
1135
|
+
const max = new CanvasColor(0, 0, 0, 0);
|
|
1136
|
+
colorTransformer = ObjectUtils.isFunction(colorTransformer) ? colorTransformer : ((color, limit) => {
|
|
1137
|
+
return limit ? max : min;
|
|
1138
|
+
});
|
|
1139
|
+
CanvasUtils.manipulatePixels(canvas, ctx, (color, greyscale) => {
|
|
1140
|
+
return colorTransformer(color, greyscale > threshold, greyscale);
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
static stackBlur(canvas, ctx, radius = 10) {
|
|
1144
|
+
if (isNaN(radius) || radius < 1)
|
|
1145
|
+
return;
|
|
1146
|
+
radius |= 0;
|
|
1147
|
+
const top_x = 0;
|
|
1148
|
+
const top_y = 0;
|
|
1149
|
+
const width = canvas.width;
|
|
1150
|
+
const height = canvas.height;
|
|
1151
|
+
let imageData = null;
|
|
1152
|
+
try {
|
|
1153
|
+
try {
|
|
1154
|
+
imageData = ctx.getImageData(top_x, top_y, width, height);
|
|
1155
|
+
}
|
|
1156
|
+
catch (e) {
|
|
1157
|
+
// NOTE: this part is supposedly only needed if you want to work with local files
|
|
1158
|
+
// so it might be okay to remove the whole try/catch block and just use
|
|
1159
|
+
// imageData = ctx.getImageData( top_x, top_y, width, height );
|
|
1160
|
+
try {
|
|
1161
|
+
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
|
1162
|
+
imageData = ctx.getImageData(top_x, top_y, width, height);
|
|
1163
|
+
}
|
|
1164
|
+
catch (e) {
|
|
1165
|
+
alert("Cannot access local image");
|
|
1166
|
+
throw new Error("unable to access local image data: " + e);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1253
1169
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1170
|
+
catch (e) {
|
|
1171
|
+
alert("Cannot access image");
|
|
1172
|
+
throw new Error("unable to access image data: " + e);
|
|
1173
|
+
}
|
|
1174
|
+
const pixels = imageData.data;
|
|
1175
|
+
let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
|
|
1176
|
+
const div = radius + radius + 1;
|
|
1177
|
+
const widthMinus1 = width - 1;
|
|
1178
|
+
const heightMinus1 = height - 1;
|
|
1179
|
+
const radiusPlus1 = radius + 1;
|
|
1180
|
+
const sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
|
|
1181
|
+
const stackStart = new BlurStack();
|
|
1182
|
+
let stackEnd = null;
|
|
1183
|
+
let stack = stackStart;
|
|
1184
|
+
for (i = 1; i < div; i++) {
|
|
1185
|
+
stack = stack.next = new BlurStack();
|
|
1186
|
+
if (i == radiusPlus1) {
|
|
1187
|
+
stackEnd = stack;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
stack.next = stackStart;
|
|
1191
|
+
let stackIn = null;
|
|
1192
|
+
let stackOut = null;
|
|
1193
|
+
yw = yi = 0;
|
|
1194
|
+
const mul_sum = mul_table[radius];
|
|
1195
|
+
const shg_sum = shg_table[radius];
|
|
1196
|
+
for (y = 0; y < height; y++) {
|
|
1197
|
+
r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;
|
|
1198
|
+
r_out_sum = radiusPlus1 * (pr = pixels[yi]);
|
|
1199
|
+
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
|
|
1200
|
+
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
|
|
1201
|
+
a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
|
|
1202
|
+
r_sum += sumFactor * pr;
|
|
1203
|
+
g_sum += sumFactor * pg;
|
|
1204
|
+
b_sum += sumFactor * pb;
|
|
1205
|
+
a_sum += sumFactor * pa;
|
|
1206
|
+
stack = stackStart;
|
|
1207
|
+
for (i = 0; i < radiusPlus1; i++) {
|
|
1208
|
+
stack.r = pr;
|
|
1209
|
+
stack.g = pg;
|
|
1210
|
+
stack.b = pb;
|
|
1211
|
+
stack.a = pa;
|
|
1212
|
+
stack = stack.next;
|
|
1213
|
+
}
|
|
1214
|
+
for (i = 1; i < radiusPlus1; i++) {
|
|
1215
|
+
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
|
|
1216
|
+
r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);
|
|
1217
|
+
g_sum += (stack.g = (pg = pixels[p + 1])) * rbs;
|
|
1218
|
+
b_sum += (stack.b = (pb = pixels[p + 2])) * rbs;
|
|
1219
|
+
a_sum += (stack.a = (pa = pixels[p + 3])) * rbs;
|
|
1220
|
+
r_in_sum += pr;
|
|
1221
|
+
g_in_sum += pg;
|
|
1222
|
+
b_in_sum += pb;
|
|
1223
|
+
a_in_sum += pa;
|
|
1224
|
+
stack = stack.next;
|
|
1225
|
+
}
|
|
1226
|
+
stackIn = stackStart;
|
|
1227
|
+
stackOut = stackEnd;
|
|
1228
|
+
for (x = 0; x < width; x++) {
|
|
1229
|
+
pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
|
|
1230
|
+
if (pa != 0) {
|
|
1231
|
+
pa = 255 / pa;
|
|
1232
|
+
pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;
|
|
1233
|
+
pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
|
|
1234
|
+
pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
|
|
1235
|
+
}
|
|
1236
|
+
else {
|
|
1237
|
+
pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
|
|
1238
|
+
}
|
|
1239
|
+
r_sum -= r_out_sum;
|
|
1240
|
+
g_sum -= g_out_sum;
|
|
1241
|
+
b_sum -= b_out_sum;
|
|
1242
|
+
a_sum -= a_out_sum;
|
|
1243
|
+
r_out_sum -= stackIn.r;
|
|
1244
|
+
g_out_sum -= stackIn.g;
|
|
1245
|
+
b_out_sum -= stackIn.b;
|
|
1246
|
+
a_out_sum -= stackIn.a;
|
|
1247
|
+
p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;
|
|
1248
|
+
r_in_sum += (stackIn.r = pixels[p]);
|
|
1249
|
+
g_in_sum += (stackIn.g = pixels[p + 1]);
|
|
1250
|
+
b_in_sum += (stackIn.b = pixels[p + 2]);
|
|
1251
|
+
a_in_sum += (stackIn.a = pixels[p + 3]);
|
|
1252
|
+
r_sum += r_in_sum;
|
|
1253
|
+
g_sum += g_in_sum;
|
|
1254
|
+
b_sum += b_in_sum;
|
|
1255
|
+
a_sum += a_in_sum;
|
|
1256
|
+
stackIn = stackIn.next;
|
|
1257
|
+
r_out_sum += (pr = stackOut.r);
|
|
1258
|
+
g_out_sum += (pg = stackOut.g);
|
|
1259
|
+
b_out_sum += (pb = stackOut.b);
|
|
1260
|
+
a_out_sum += (pa = stackOut.a);
|
|
1261
|
+
r_in_sum -= pr;
|
|
1262
|
+
g_in_sum -= pg;
|
|
1263
|
+
b_in_sum -= pb;
|
|
1264
|
+
a_in_sum -= pa;
|
|
1265
|
+
stackOut = stackOut.next;
|
|
1266
|
+
yi += 4;
|
|
1267
|
+
}
|
|
1268
|
+
yw += width;
|
|
1269
|
+
}
|
|
1270
|
+
for (x = 0; x < width; x++) {
|
|
1271
|
+
g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;
|
|
1272
|
+
yi = x << 2;
|
|
1273
|
+
r_out_sum = radiusPlus1 * (pr = pixels[yi]);
|
|
1274
|
+
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
|
|
1275
|
+
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
|
|
1276
|
+
a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
|
|
1277
|
+
r_sum += sumFactor * pr;
|
|
1278
|
+
g_sum += sumFactor * pg;
|
|
1279
|
+
b_sum += sumFactor * pb;
|
|
1280
|
+
a_sum += sumFactor * pa;
|
|
1281
|
+
stack = stackStart;
|
|
1282
|
+
for (i = 0; i < radiusPlus1; i++) {
|
|
1283
|
+
stack.r = pr;
|
|
1284
|
+
stack.g = pg;
|
|
1285
|
+
stack.b = pb;
|
|
1286
|
+
stack.a = pa;
|
|
1287
|
+
stack = stack.next;
|
|
1288
|
+
}
|
|
1289
|
+
yp = width;
|
|
1290
|
+
for (i = 1; i <= radius; i++) {
|
|
1291
|
+
yi = (yp + x) << 2;
|
|
1292
|
+
r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);
|
|
1293
|
+
g_sum += (stack.g = (pg = pixels[yi + 1])) * rbs;
|
|
1294
|
+
b_sum += (stack.b = (pb = pixels[yi + 2])) * rbs;
|
|
1295
|
+
a_sum += (stack.a = (pa = pixels[yi + 3])) * rbs;
|
|
1296
|
+
r_in_sum += pr;
|
|
1297
|
+
g_in_sum += pg;
|
|
1298
|
+
b_in_sum += pb;
|
|
1299
|
+
a_in_sum += pa;
|
|
1300
|
+
stack = stack.next;
|
|
1301
|
+
if (i < heightMinus1) {
|
|
1302
|
+
yp += width;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
yi = x;
|
|
1306
|
+
stackIn = stackStart;
|
|
1307
|
+
stackOut = stackEnd;
|
|
1308
|
+
for (y = 0; y < height; y++) {
|
|
1309
|
+
p = yi << 2;
|
|
1310
|
+
pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
|
|
1311
|
+
if (pa > 0) {
|
|
1312
|
+
pa = 255 / pa;
|
|
1313
|
+
pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;
|
|
1314
|
+
pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
|
|
1315
|
+
pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
|
|
1316
|
+
}
|
|
1317
|
+
else {
|
|
1318
|
+
pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;
|
|
1319
|
+
}
|
|
1320
|
+
r_sum -= r_out_sum;
|
|
1321
|
+
g_sum -= g_out_sum;
|
|
1322
|
+
b_sum -= b_out_sum;
|
|
1323
|
+
a_sum -= a_out_sum;
|
|
1324
|
+
r_out_sum -= stackIn.r;
|
|
1325
|
+
g_out_sum -= stackIn.g;
|
|
1326
|
+
b_out_sum -= stackIn.b;
|
|
1327
|
+
a_out_sum -= stackIn.a;
|
|
1328
|
+
p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;
|
|
1329
|
+
r_sum += (r_in_sum += (stackIn.r = pixels[p]));
|
|
1330
|
+
g_sum += (g_in_sum += (stackIn.g = pixels[p + 1]));
|
|
1331
|
+
b_sum += (b_in_sum += (stackIn.b = pixels[p + 2]));
|
|
1332
|
+
a_sum += (a_in_sum += (stackIn.a = pixels[p + 3]));
|
|
1333
|
+
stackIn = stackIn.next;
|
|
1334
|
+
r_out_sum += (pr = stackOut.r);
|
|
1335
|
+
g_out_sum += (pg = stackOut.g);
|
|
1336
|
+
b_out_sum += (pb = stackOut.b);
|
|
1337
|
+
a_out_sum += (pa = stackOut.a);
|
|
1338
|
+
r_in_sum -= pr;
|
|
1339
|
+
g_in_sum -= pg;
|
|
1340
|
+
b_in_sum -= pb;
|
|
1341
|
+
a_in_sum -= pa;
|
|
1342
|
+
stackOut = stackOut.next;
|
|
1343
|
+
yi += width;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
ctx.putImageData(imageData, top_x, top_y);
|
|
1347
|
+
}
|
|
1348
|
+
static measureTextFontSize(maxWidth, maxHeight, lines, font, lineHeightPercent = 1.1, canvas) {
|
|
1349
|
+
const startSize = maxHeight;
|
|
1350
|
+
const context = canvas.getContext("2d");
|
|
1351
|
+
if (!canvas) {
|
|
1352
|
+
canvas = document.createElement("canvas");
|
|
1353
|
+
document.body.appendChild(canvas);
|
|
1354
|
+
}
|
|
1355
|
+
canvas.width = maxWidth + maxHeight;
|
|
1356
|
+
canvas.height = maxHeight * 2;
|
|
1357
|
+
let fontSize = CanvasUtils.halveValidateFontSize(startSize, (size) => {
|
|
1358
|
+
CanvasUtils.setFontProps(context, font, size);
|
|
1359
|
+
const maxTextLinesWidth = CanvasUtils.getTextWidth(context, lines);
|
|
1360
|
+
return maxWidth - maxTextLinesWidth;
|
|
1361
|
+
});
|
|
1362
|
+
const bitmapHeight = CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, fontSize, lineHeightPercent);
|
|
1363
|
+
if (bitmapHeight > maxHeight) {
|
|
1364
|
+
fontSize = CanvasUtils.halveValidateFontSize(fontSize, (size) => {
|
|
1365
|
+
return maxHeight - CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, size, lineHeightPercent);
|
|
1366
|
+
});
|
|
1256
1367
|
}
|
|
1257
|
-
return
|
|
1368
|
+
return fontSize;
|
|
1258
1369
|
}
|
|
1259
|
-
static
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1370
|
+
static drawLines(context, lines, font, size, lineHeightPercent = 1.1, align = "left", baseLine = "top", x = 0, y = 0) {
|
|
1371
|
+
CanvasUtils.setFontProps(context, font, size, align, baseLine);
|
|
1372
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1373
|
+
const line = lines[i];
|
|
1374
|
+
context.fillText(line, x, y);
|
|
1375
|
+
if (i < lines.length - 1) {
|
|
1376
|
+
y += size * lineHeightPercent;
|
|
1265
1377
|
}
|
|
1266
|
-
return fnBody;
|
|
1267
|
-
}
|
|
1268
|
-
if (value instanceof RegExp) {
|
|
1269
|
-
return "_PxEgEr_" + value;
|
|
1270
1378
|
}
|
|
1271
|
-
return
|
|
1379
|
+
return y;
|
|
1272
1380
|
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
script.onreadystatechange = () => {
|
|
1286
|
-
if (script.readyState === "loaded" || script.readyState === "complete") {
|
|
1287
|
-
script.onreadystatechange = null;
|
|
1288
|
-
resolve(script);
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1381
|
+
static wrapText(context, text, x, y, maxWidth) {
|
|
1382
|
+
const words = text.split(" ");
|
|
1383
|
+
const lineHeight = context.measureText("M").width * 1.3;
|
|
1384
|
+
const lines = [];
|
|
1385
|
+
let line = "";
|
|
1386
|
+
for (let n = 0; n < words.length; n++) {
|
|
1387
|
+
const testLine = line + words[n] + " ";
|
|
1388
|
+
const metrics = context.measureText(testLine);
|
|
1389
|
+
const testWidth = metrics.width;
|
|
1390
|
+
if (testWidth > maxWidth && n > 0) {
|
|
1391
|
+
lines.push(line);
|
|
1392
|
+
line = words[n] + " ";
|
|
1291
1393
|
}
|
|
1292
1394
|
else {
|
|
1293
|
-
|
|
1294
|
-
script.onload = () => resolve(script);
|
|
1395
|
+
line = testLine;
|
|
1295
1396
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1397
|
+
}
|
|
1398
|
+
lines.push(line);
|
|
1399
|
+
y -= lineHeight * .5 * lines.length;
|
|
1400
|
+
lines.forEach(l => {
|
|
1401
|
+
context.fillText(l, x, y);
|
|
1402
|
+
y += lineHeight;
|
|
1298
1403
|
});
|
|
1299
|
-
return this.scriptPromises[src];
|
|
1300
1404
|
}
|
|
1301
|
-
static
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1405
|
+
static setFontProps(context, font, fontSize, align = "left", baseLine = "top") {
|
|
1406
|
+
context.font = `${fontSize}px ${font}`;
|
|
1407
|
+
context.textAlign = align;
|
|
1408
|
+
context.textBaseline = baseLine;
|
|
1409
|
+
}
|
|
1410
|
+
static getTextWidth(context, lines) {
|
|
1411
|
+
let maxWidth = 0;
|
|
1412
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1413
|
+
const line = lines[i];
|
|
1414
|
+
maxWidth = Math.max(maxWidth, context.measureText(line).width);
|
|
1415
|
+
}
|
|
1416
|
+
return maxWidth;
|
|
1417
|
+
}
|
|
1418
|
+
static getTextBitmapHeight(canvas, context, lines, font, fontSize, lineHeightPercent) {
|
|
1419
|
+
const width = canvas.width;
|
|
1420
|
+
const height = canvas.height;
|
|
1421
|
+
context.clearRect(0, 0, width, height);
|
|
1422
|
+
const textY = CanvasUtils.drawLines(context, lines, font, fontSize, lineHeightPercent, "left", "top", fontSize * .5, fontSize * .5);
|
|
1423
|
+
const imageData = context.getImageData(0, 0, width, height);
|
|
1424
|
+
let textHeight = 0;
|
|
1425
|
+
yLoop: for (let y = 0; y < height; y++) {
|
|
1426
|
+
for (let x = 0; x < width; x++) {
|
|
1427
|
+
const index = (x + y * width) * 4;
|
|
1428
|
+
if (imageData.data[index + 3] > 0) {
|
|
1429
|
+
textHeight = y + 1;
|
|
1430
|
+
continue yLoop;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return Math.max(textHeight, textY + fontSize);
|
|
1435
|
+
}
|
|
1436
|
+
static halveValidateFontSize(startSize, callback) {
|
|
1437
|
+
let fontSize = startSize;
|
|
1438
|
+
let lastFontSize = 0;
|
|
1439
|
+
let direction;
|
|
1440
|
+
for (let i = 0; i < 20; i++) {
|
|
1441
|
+
direction = callback(fontSize);
|
|
1442
|
+
const tempSize = fontSize;
|
|
1443
|
+
if (direction < 0) {
|
|
1444
|
+
fontSize = fontSize - (Math.abs(fontSize - lastFontSize) / 2);
|
|
1316
1445
|
}
|
|
1317
1446
|
else {
|
|
1318
|
-
|
|
1319
|
-
link.onload = () => resolve(link);
|
|
1447
|
+
fontSize = fontSize + (Math.abs(fontSize - lastFontSize) / 2);
|
|
1320
1448
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1449
|
+
lastFontSize = tempSize;
|
|
1450
|
+
if (Math.abs(fontSize - lastFontSize) < 0.1) {
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
fontSize = Math.floor(fontSize);
|
|
1455
|
+
return fontSize;
|
|
1325
1456
|
}
|
|
1326
|
-
}
|
|
1327
|
-
LoaderUtils.scriptPromises = {};
|
|
1328
|
-
LoaderUtils.stylePromises = {};
|
|
1457
|
+
}
|
|
1329
1458
|
|
|
1330
|
-
class
|
|
1331
|
-
static
|
|
1332
|
-
|
|
1333
|
-
return Math.abs(a - b) < epsilon;
|
|
1459
|
+
class DateUtils {
|
|
1460
|
+
static isHoliday(date) {
|
|
1461
|
+
return moment(date).isoWeekday() > 5;
|
|
1334
1462
|
}
|
|
1335
|
-
static
|
|
1336
|
-
return
|
|
1463
|
+
static isBusinessDay(date) {
|
|
1464
|
+
return moment(date).isoWeekday() < 6;
|
|
1337
1465
|
}
|
|
1338
|
-
static
|
|
1339
|
-
|
|
1340
|
-
return Math.round(value * precision / divider) / precision;
|
|
1466
|
+
static add(date, amount, unit) {
|
|
1467
|
+
return moment(date).add(amount, unit).toDate();
|
|
1341
1468
|
}
|
|
1342
|
-
static
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
let
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
if (MathUtils.equal(v, x, epsilon)) {
|
|
1352
|
-
return i;
|
|
1353
|
-
}
|
|
1354
|
-
if (v < x) {
|
|
1355
|
-
s = i + 1;
|
|
1356
|
-
}
|
|
1357
|
-
else {
|
|
1358
|
-
e = i - 1;
|
|
1469
|
+
static businessAdd(date, amount, unit, freeDays = []) {
|
|
1470
|
+
const signal = amount < 0 ? -1 : 1;
|
|
1471
|
+
const freeMoments = freeDays.map(d => moment(d));
|
|
1472
|
+
let remaining = Math.abs(amount);
|
|
1473
|
+
let day = date;
|
|
1474
|
+
while (remaining) {
|
|
1475
|
+
day = DateUtils.add(day, signal, unit);
|
|
1476
|
+
if (DateUtils.isBusinessDay(day) && !freeMoments.some(m => m.isSame(day, "day"))) {
|
|
1477
|
+
remaining--;
|
|
1359
1478
|
}
|
|
1360
1479
|
}
|
|
1361
|
-
|
|
1362
|
-
const a = values[s];
|
|
1363
|
-
const b = values[m];
|
|
1364
|
-
return Math.abs(a - x) < Math.abs(b - x) ? s : m;
|
|
1480
|
+
return day;
|
|
1365
1481
|
}
|
|
1366
|
-
static
|
|
1367
|
-
|
|
1368
|
-
return values[index] ?? null;
|
|
1482
|
+
static businessSubtract(date, amount, unit) {
|
|
1483
|
+
return DateUtils.businessAdd(date, -amount, unit);
|
|
1369
1484
|
}
|
|
1370
|
-
}
|
|
1371
|
-
MathUtils.EPSILON = 1e-9;
|
|
1485
|
+
}
|
|
1372
1486
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
class UniversalService {
|
|
1377
|
-
constructor(platformId, dds) {
|
|
1378
|
-
this.platformId = platformId;
|
|
1379
|
-
this.dds = dds;
|
|
1380
|
-
const info = this.dds.getDeviceInfo();
|
|
1381
|
-
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
|
|
1382
|
-
}
|
|
1383
|
-
get isBrowser() {
|
|
1384
|
-
return isPlatformBrowser(this.platformId);
|
|
1487
|
+
class FileUtils {
|
|
1488
|
+
static getExtension(file) {
|
|
1489
|
+
return file ? file.name.substr(file.name.lastIndexOf(".")).toLowerCase() : null;
|
|
1385
1490
|
}
|
|
1386
|
-
|
|
1387
|
-
return
|
|
1491
|
+
static getName(file) {
|
|
1492
|
+
return file ? file.name.substr(0, file.name.lastIndexOf(".")) : null;
|
|
1388
1493
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
browser: "node",
|
|
1395
|
-
device: "node",
|
|
1396
|
-
os_version: "unknown",
|
|
1397
|
-
browser_version: "unknown",
|
|
1398
|
-
deviceType: "unknown",
|
|
1399
|
-
orientation: "landscape"
|
|
1400
|
-
}
|
|
1401
|
-
: this.dds.getDeviceInfo();
|
|
1494
|
+
static toFile(blob, fileName) {
|
|
1495
|
+
const data = blob;
|
|
1496
|
+
data.lastModifiedDate = new Date();
|
|
1497
|
+
data.name = fileName.split(/\\|\//g).pop();
|
|
1498
|
+
return data;
|
|
1402
1499
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1500
|
+
static dataToBlob(data) {
|
|
1501
|
+
const parts = data.split(",");
|
|
1502
|
+
const byteString = atob(parts[1]);
|
|
1503
|
+
const mimeString = parts[0].split(":")[1].split(";")[0];
|
|
1504
|
+
const ab = new ArrayBuffer(byteString.length);
|
|
1505
|
+
const ia = new Uint8Array(ab);
|
|
1506
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
1507
|
+
ia[i] = byteString.charCodeAt(i);
|
|
1508
|
+
}
|
|
1509
|
+
return new Blob([ab], { type: mimeString });
|
|
1405
1510
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1511
|
+
static saveBlob(blob, fileName) {
|
|
1512
|
+
if (typeof saveAs == "undefined") {
|
|
1513
|
+
throw Error("FileSaver library is not loaded. Please load it: https://www.npmjs.com/package/file-saver");
|
|
1514
|
+
}
|
|
1515
|
+
saveAs(blob, fileName);
|
|
1408
1516
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1517
|
+
static saveJson(json, fileName) {
|
|
1518
|
+
if (!ObjectUtils.isObject(json))
|
|
1519
|
+
return;
|
|
1520
|
+
FileUtils.saveBlob(new Blob([JSON.stringify(json, null, 4)]), fileName);
|
|
1411
1521
|
}
|
|
1412
|
-
|
|
1413
|
-
return
|
|
1522
|
+
static readFileAsText(file) {
|
|
1523
|
+
return FileUtils.readFile(
|
|
1524
|
+
// @dynamic
|
|
1525
|
+
reader => reader.readAsText(file));
|
|
1414
1526
|
}
|
|
1415
|
-
|
|
1416
|
-
return
|
|
1527
|
+
static readFileAsBinaryString(file) {
|
|
1528
|
+
return FileUtils.readFile(
|
|
1529
|
+
// @dynamic
|
|
1530
|
+
reader => reader.readAsBinaryString(file));
|
|
1417
1531
|
}
|
|
1418
|
-
|
|
1419
|
-
return
|
|
1532
|
+
static readFileAsDataURL(file) {
|
|
1533
|
+
return FileUtils.readFile(
|
|
1534
|
+
// @dynamic
|
|
1535
|
+
reader => reader.readAsDataURL(file));
|
|
1420
1536
|
}
|
|
1421
|
-
|
|
1422
|
-
return
|
|
1537
|
+
static readDataFromUrl(http, url) {
|
|
1538
|
+
return new Promise(
|
|
1539
|
+
// @dynamic
|
|
1540
|
+
(resolve, reject) => {
|
|
1541
|
+
if (!url) {
|
|
1542
|
+
reject({
|
|
1543
|
+
message: "The url is not specified"
|
|
1544
|
+
});
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
if ((/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/g).test(url)) {
|
|
1548
|
+
resolve(url);
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
first()(http.get(url, {
|
|
1552
|
+
responseType: "blob"
|
|
1553
|
+
})).subscribe((blob) => {
|
|
1554
|
+
FileUtils.readFileAsDataURL(blob).then(resolve, reject);
|
|
1555
|
+
}, reason => {
|
|
1556
|
+
if (reason.status > 0)
|
|
1557
|
+
reject(reason);
|
|
1558
|
+
else
|
|
1559
|
+
resolve(url);
|
|
1560
|
+
});
|
|
1561
|
+
});
|
|
1423
1562
|
}
|
|
1424
|
-
|
|
1425
|
-
return
|
|
1563
|
+
static readFile(callback) {
|
|
1564
|
+
return new Promise(
|
|
1565
|
+
// @dynamic
|
|
1566
|
+
(resolve, reject) => {
|
|
1567
|
+
const reader = new FileReader();
|
|
1568
|
+
reader.onload = (event) => resolve(event.target.result);
|
|
1569
|
+
reader.onerror = reject;
|
|
1570
|
+
callback(reader);
|
|
1571
|
+
});
|
|
1426
1572
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
class GenericValue extends Subject {
|
|
1576
|
+
constructor(value = null) {
|
|
1577
|
+
super();
|
|
1578
|
+
this._value = value;
|
|
1429
1579
|
}
|
|
1430
|
-
get
|
|
1431
|
-
return this.
|
|
1580
|
+
get value() {
|
|
1581
|
+
return this._value;
|
|
1432
1582
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1583
|
+
set value(value) {
|
|
1584
|
+
if (value == this._value)
|
|
1585
|
+
return;
|
|
1586
|
+
this._value = value;
|
|
1587
|
+
this.next(value);
|
|
1435
1588
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1589
|
+
setJustValue(value) {
|
|
1590
|
+
this._value = value;
|
|
1438
1591
|
}
|
|
1439
|
-
}
|
|
1440
|
-
UniversalService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, deps: [{ token: PLATFORM_ID }, { token: i1.DeviceDetectorService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1441
|
-
UniversalService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService });
|
|
1442
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, decorators: [{
|
|
1443
|
-
type: Injectable
|
|
1444
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1445
|
-
type: Inject,
|
|
1446
|
-
args: [PLATFORM_ID]
|
|
1447
|
-
}] }, { type: i1.DeviceDetectorService }]; } });
|
|
1592
|
+
}
|
|
1448
1593
|
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
this.
|
|
1458
|
-
this.
|
|
1459
|
-
this.
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
if (!(event instanceof NavigationEnd))
|
|
1463
|
-
return;
|
|
1464
|
-
const routerStateSnapshot = this.router.routerState.snapshot;
|
|
1465
|
-
let snapshot = routerStateSnapshot.root;
|
|
1466
|
-
let context = this.contexts?.getContext("primary");
|
|
1467
|
-
let segments = snapshot.url;
|
|
1468
|
-
const components = [];
|
|
1469
|
-
const snapshots = [];
|
|
1470
|
-
while (snapshot) {
|
|
1471
|
-
snapshots.push(snapshot);
|
|
1472
|
-
segments = segments.concat(snapshot.url);
|
|
1473
|
-
if (context) {
|
|
1474
|
-
if (context.outlet && context.outlet.isActivated)
|
|
1475
|
-
components.push(context.outlet.component);
|
|
1476
|
-
context = context.children.getContext("primary");
|
|
1477
|
-
}
|
|
1478
|
-
snapshot = snapshot.firstChild;
|
|
1479
|
-
}
|
|
1480
|
-
this.comp = components[components.length - 1];
|
|
1481
|
-
this.shot = snapshots[snapshots.length - 1];
|
|
1482
|
-
this.stateInfo = {
|
|
1483
|
-
url: routerStateSnapshot.url,
|
|
1484
|
-
segments: segments,
|
|
1485
|
-
components: components
|
|
1486
|
-
};
|
|
1487
|
-
this.next(this.shot);
|
|
1488
|
-
};
|
|
1489
|
-
if (!this.router)
|
|
1490
|
-
return;
|
|
1491
|
-
this.globalExtras = {
|
|
1492
|
-
queryParamsHandling: "merge"
|
|
1493
|
-
};
|
|
1494
|
-
this.router.events.subscribe(this.handleRouterEvent);
|
|
1495
|
-
this.stateInfo = {
|
|
1496
|
-
url: "",
|
|
1497
|
-
segments: [],
|
|
1498
|
-
components: []
|
|
1499
|
-
};
|
|
1500
|
-
this.contexts = router.rootContexts;
|
|
1594
|
+
class FileSystemEntry {
|
|
1595
|
+
constructor(label, meta, image, data, parent, openCb) {
|
|
1596
|
+
this.label = label;
|
|
1597
|
+
this.meta = meta;
|
|
1598
|
+
this.image = image;
|
|
1599
|
+
this.data = data;
|
|
1600
|
+
this.parent = parent;
|
|
1601
|
+
this.openCb = openCb;
|
|
1602
|
+
this.path = !parent ? [this] : parent.path.concat([this]);
|
|
1603
|
+
this.level = this.path.length - 1;
|
|
1604
|
+
this.classes = this.path
|
|
1605
|
+
.filter(t => typeof t.data === "string" && t.data.length > 0).map(t => t.data)
|
|
1606
|
+
.concat([`level-${this.level}`]);
|
|
1501
1607
|
}
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1608
|
+
open() {
|
|
1609
|
+
this.result = this.result || this.openCb(this.data, this);
|
|
1610
|
+
this.result.then(res => {
|
|
1611
|
+
if (Array.isArray(res))
|
|
1612
|
+
return;
|
|
1613
|
+
this.result = null;
|
|
1506
1614
|
});
|
|
1507
|
-
return
|
|
1615
|
+
return this.result;
|
|
1508
1616
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
class Rect {
|
|
1620
|
+
constructor(x, y, width, height, rotation = 0) {
|
|
1621
|
+
this.x = x;
|
|
1622
|
+
this.y = y;
|
|
1623
|
+
this.width = width;
|
|
1624
|
+
this.height = height;
|
|
1625
|
+
this.rotation = rotation;
|
|
1511
1626
|
}
|
|
1512
|
-
get
|
|
1513
|
-
return this.
|
|
1627
|
+
get center() {
|
|
1628
|
+
return new Point(this.x, this.y);
|
|
1514
1629
|
}
|
|
1515
|
-
get
|
|
1516
|
-
return this.
|
|
1630
|
+
get left() {
|
|
1631
|
+
return this.x - this.width * .5;
|
|
1517
1632
|
}
|
|
1518
|
-
get
|
|
1519
|
-
return this.
|
|
1633
|
+
get right() {
|
|
1634
|
+
return this.x + this.width * .5;
|
|
1520
1635
|
}
|
|
1521
|
-
get
|
|
1522
|
-
return this.
|
|
1636
|
+
get bottom() {
|
|
1637
|
+
return this.y - this.height * .5;
|
|
1523
1638
|
}
|
|
1524
|
-
get
|
|
1525
|
-
return this.
|
|
1639
|
+
get top() {
|
|
1640
|
+
return this.y + this.height * .5;
|
|
1526
1641
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1642
|
+
distance(p) {
|
|
1643
|
+
p = p.rotateAround(this.center, -this.rotation);
|
|
1644
|
+
const x = Math.max(this.left - p.x, 0, p.x - this.right);
|
|
1645
|
+
const y = Math.max(this.bottom - p.y, 0, p.y - this.top);
|
|
1646
|
+
return Math.sqrt(x * x + y * y);
|
|
1529
1647
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1648
|
+
}
|
|
1649
|
+
class Circle {
|
|
1650
|
+
constructor(x, y, radius) {
|
|
1651
|
+
this.x = x;
|
|
1652
|
+
this.y = y;
|
|
1653
|
+
this.radius = radius;
|
|
1532
1654
|
}
|
|
1533
|
-
get
|
|
1534
|
-
return this.
|
|
1655
|
+
get center() {
|
|
1656
|
+
return new Point(this.x, this.y);
|
|
1535
1657
|
}
|
|
1536
|
-
get
|
|
1537
|
-
return this.
|
|
1658
|
+
get left() {
|
|
1659
|
+
return new Point(this.x - this.radius, this.y);
|
|
1538
1660
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
const resolvers = this.route.resolve || {};
|
|
1542
|
-
const keys = Object.keys(resolvers);
|
|
1543
|
-
for (const key of keys) {
|
|
1544
|
-
const resolver = this.injector.get(resolvers[key]);
|
|
1545
|
-
let resolved = resolver.resolve(this.snapshot, routerStateSnapshot);
|
|
1546
|
-
if (resolved instanceof Observable) {
|
|
1547
|
-
resolved = resolved.toPromise();
|
|
1548
|
-
}
|
|
1549
|
-
if (resolved instanceof Promise) {
|
|
1550
|
-
resolved = await resolved;
|
|
1551
|
-
}
|
|
1552
|
-
this.data[key] = resolved;
|
|
1553
|
-
}
|
|
1661
|
+
get right() {
|
|
1662
|
+
return new Point(this.x + this.radius, this.y);
|
|
1554
1663
|
}
|
|
1555
|
-
|
|
1556
|
-
return this.
|
|
1664
|
+
get top() {
|
|
1665
|
+
return new Point(this.x, this.y + this.radius);
|
|
1666
|
+
}
|
|
1667
|
+
get bottom() {
|
|
1668
|
+
return new Point(this.x, this.y - this.radius);
|
|
1669
|
+
}
|
|
1670
|
+
get rect() {
|
|
1671
|
+
return new Rect(this.x, this.y, this.radius * 2, this.radius * 2);
|
|
1672
|
+
}
|
|
1673
|
+
distance(p) {
|
|
1674
|
+
return this.center.distance(p) - this.radius;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
class Point {
|
|
1678
|
+
constructor(x, y) {
|
|
1679
|
+
this.x = x;
|
|
1680
|
+
this.y = y;
|
|
1557
1681
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
return false;
|
|
1561
|
-
const [tree, extras] = this.createUrlTree(url, navigationExtras);
|
|
1562
|
-
return this.zone.run(() => {
|
|
1563
|
-
return this.router.navigateByUrl(tree, extras);
|
|
1564
|
-
});
|
|
1682
|
+
get length() {
|
|
1683
|
+
return this.distance(Point.Zero);
|
|
1565
1684
|
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
return false;
|
|
1569
|
-
const [tree, extras] = this.createUrlTree(url, navigationExtras);
|
|
1570
|
-
return this.zone.run(() => {
|
|
1571
|
-
return this.openInNewWindow(tree, target) || this.router.navigateByUrl(tree, extras);
|
|
1572
|
-
});
|
|
1685
|
+
get perpendicular() {
|
|
1686
|
+
return new Point(this.y, -this.x);
|
|
1573
1687
|
}
|
|
1574
|
-
|
|
1575
|
-
return this.
|
|
1688
|
+
add(p) {
|
|
1689
|
+
return new Point(this.x + p.x, this.y + p.y);
|
|
1576
1690
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
return false;
|
|
1580
|
-
const baseUrl = window.location.href.replace(this.router.url, "");
|
|
1581
|
-
try {
|
|
1582
|
-
const serialized = this.router.serializeUrl(tree);
|
|
1583
|
-
const separator = serialized.startsWith("/") ? "" : "/";
|
|
1584
|
-
window.open(baseUrl + separator + serialized, target);
|
|
1585
|
-
return true;
|
|
1586
|
-
}
|
|
1587
|
-
catch (e) {
|
|
1588
|
-
console.log(`Can't open new window: ${e}`);
|
|
1589
|
-
return false;
|
|
1590
|
-
}
|
|
1691
|
+
subtract(p) {
|
|
1692
|
+
return new Point(this.x - p.x, this.y - p.y);
|
|
1591
1693
|
}
|
|
1592
|
-
|
|
1593
|
-
if (
|
|
1594
|
-
return
|
|
1595
|
-
extras = Object.assign(extras, this.globalExtras, extras || {});
|
|
1596
|
-
if (ObjectUtils.isArray(url)) {
|
|
1597
|
-
return [this.router.createUrlTree(url, extras), extras];
|
|
1598
|
-
}
|
|
1599
|
-
if (ObjectUtils.isString(url)) {
|
|
1600
|
-
return [this.router.parseUrl(url), extras];
|
|
1694
|
+
multiply(p) {
|
|
1695
|
+
if (p instanceof Point) {
|
|
1696
|
+
return new Point(this.x * p.x, this.y * p.y);
|
|
1601
1697
|
}
|
|
1602
|
-
return
|
|
1698
|
+
return new Point(this.x * p, this.y * p);
|
|
1603
1699
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
type: Injectable
|
|
1609
|
-
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.NgZone }, { type: UniversalService }, { type: i2.Router, decorators: [{
|
|
1610
|
-
type: Optional
|
|
1611
|
-
}] }]; } });
|
|
1612
|
-
|
|
1613
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1614
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1615
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1616
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1617
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1618
|
-
};
|
|
1619
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
1620
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1621
|
-
};
|
|
1622
|
-
class AuthGuard {
|
|
1623
|
-
constructor(injector, state, auth) {
|
|
1624
|
-
this.injector = injector;
|
|
1625
|
-
this.state = state;
|
|
1626
|
-
this.auth = auth;
|
|
1700
|
+
distance(b) {
|
|
1701
|
+
const x = b.x - this.x;
|
|
1702
|
+
const y = b.y - this.y;
|
|
1703
|
+
return Math.sqrt(x * x + y * y);
|
|
1627
1704
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1705
|
+
lerp(p, ratio) {
|
|
1706
|
+
const diff = p.subtract(this);
|
|
1707
|
+
return this.add(diff.multiply(ratio));
|
|
1630
1708
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1709
|
+
perpendicularTo(p, length) {
|
|
1710
|
+
const diff = p.perpendicular.subtract(this.perpendicular);
|
|
1711
|
+
const ratio = length / diff.length;
|
|
1712
|
+
const center = this.lerp(p, .5);
|
|
1713
|
+
return center.add(diff.multiply(ratio));
|
|
1633
1714
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1715
|
+
circleWith(a, b) {
|
|
1716
|
+
const yDelta_a = b.y - a.y;
|
|
1717
|
+
const xDelta_a = b.x - a.x;
|
|
1718
|
+
const yDelta_b = this.y - b.y;
|
|
1719
|
+
const xDelta_b = this.x - b.x;
|
|
1720
|
+
const aSlope = yDelta_a / xDelta_a;
|
|
1721
|
+
const bSlope = yDelta_b / xDelta_b;
|
|
1722
|
+
const x = (aSlope * bSlope * (a.y - this.y) + bSlope * (a.x + b.x) - aSlope * (b.x + this.x)) / (2 * (bSlope - aSlope));
|
|
1723
|
+
const y = -1 * (x - (a.x + b.x) / 2) / aSlope + (a.y + b.y) / 2;
|
|
1724
|
+
const center = new Point(x, y);
|
|
1725
|
+
return new Circle(center.x, center.y, center.distance(this));
|
|
1636
1726
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
const
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1727
|
+
tangents(c) {
|
|
1728
|
+
const pd = c.center.subtract(this);
|
|
1729
|
+
const a = Math.asin(c.radius / pd.length);
|
|
1730
|
+
const b = Math.atan2(pd.y, pd.x);
|
|
1731
|
+
// Tangent points
|
|
1732
|
+
let t = b - a;
|
|
1733
|
+
const t1 = new Point(c.x + c.radius * Math.sin(t), c.y + c.radius * -Math.cos(t));
|
|
1734
|
+
t = b + a;
|
|
1735
|
+
const t2 = new Point(c.x + c.radius * -Math.sin(t), c.y + c.radius * Math.cos(t));
|
|
1736
|
+
return [t1, t2];
|
|
1643
1737
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
return Promise.resolve(ObjectUtils.evaluate(expression, { state }));
|
|
1648
|
-
};
|
|
1649
|
-
return lambda;
|
|
1738
|
+
angle(p) {
|
|
1739
|
+
const diff = p.subtract(this);
|
|
1740
|
+
return Math.atan2(diff.y, diff.x) * 180 / Math.PI;
|
|
1650
1741
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
return lambda;
|
|
1742
|
+
rotateAround(p, angle) {
|
|
1743
|
+
const rotation = (p.angle(this) + angle) * Math.PI / 180;
|
|
1744
|
+
const distance = p.distance(this);
|
|
1745
|
+
const rotated = new Point(Math.cos(rotation) * distance, Math.sin(rotation) * distance);
|
|
1746
|
+
return p.add(rotated);
|
|
1657
1747
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1748
|
+
}
|
|
1749
|
+
Point.Zero = new Point(0, 0);
|
|
1750
|
+
|
|
1751
|
+
class Initializer {
|
|
1752
|
+
constructor(callback, shouldInit = true) {
|
|
1753
|
+
this.callback = callback;
|
|
1754
|
+
this.shouldInit = shouldInit;
|
|
1755
|
+
this.initialized = !this.shouldInit;
|
|
1756
|
+
// @ts-ignore
|
|
1757
|
+
return Invokable.create(this);
|
|
1660
1758
|
}
|
|
1661
|
-
|
|
1662
|
-
return
|
|
1759
|
+
get isInitialized() {
|
|
1760
|
+
return this.initialized;
|
|
1663
1761
|
}
|
|
1664
|
-
|
|
1665
|
-
if (
|
|
1666
|
-
return
|
|
1667
|
-
|
|
1762
|
+
[Invokable.call]() {
|
|
1763
|
+
if (this.initialized)
|
|
1764
|
+
return null;
|
|
1765
|
+
this.initialized = true;
|
|
1766
|
+
return this.callback();
|
|
1668
1767
|
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
return
|
|
1674
|
-
const guards = routeData.guards.map(g => {
|
|
1675
|
-
const guard = ReflectUtils.resolve(g, this.injector);
|
|
1676
|
-
return guard(this.auth, route, next);
|
|
1677
|
-
});
|
|
1678
|
-
Promise.all(guards).then(results => {
|
|
1679
|
-
resolve(results.indexOf(false) < 0);
|
|
1680
|
-
});
|
|
1681
|
-
});
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
class JSONfn {
|
|
1771
|
+
static parse(text) {
|
|
1772
|
+
return JSON.parse(text, JSONfn.reviver);
|
|
1682
1773
|
}
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1774
|
+
static stringify(obj) {
|
|
1775
|
+
return JSON.stringify(obj, JSONfn.replacer);
|
|
1776
|
+
}
|
|
1777
|
+
static reviver(key, value) {
|
|
1778
|
+
const iso8061 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:.\d+)?(?:Z|[+-]\d\d:\d\d)$/;
|
|
1779
|
+
if (typeof value !== "string")
|
|
1780
|
+
return value;
|
|
1781
|
+
if (value.length < 8) {
|
|
1782
|
+
return value;
|
|
1783
|
+
}
|
|
1784
|
+
if (value.match(iso8061)) {
|
|
1785
|
+
return new Date(value);
|
|
1786
|
+
}
|
|
1787
|
+
const prefix = value.substring(0, 8);
|
|
1788
|
+
if (prefix === "function") {
|
|
1789
|
+
return new Function(`return ${value}`)();
|
|
1790
|
+
}
|
|
1791
|
+
if (prefix === "_NuFrRa_") {
|
|
1792
|
+
return new Function(`return ${value.slice(8)}`)();
|
|
1793
|
+
}
|
|
1794
|
+
if (prefix === "_PxEgEr_") {
|
|
1795
|
+
return new Function(`return ${value.slice(8)}`)();
|
|
1796
|
+
}
|
|
1797
|
+
return value;
|
|
1798
|
+
}
|
|
1799
|
+
static replacer(key, value) {
|
|
1800
|
+
if (value instanceof Function || typeof value === "function") {
|
|
1801
|
+
const fnBody = value.toString();
|
|
1802
|
+
if (fnBody.length < 8 || fnBody.substring(0, 8) !== "function") {
|
|
1803
|
+
// this is ES6 Arrow Function
|
|
1804
|
+
return "_NuFrRa_" + fnBody;
|
|
1805
|
+
}
|
|
1806
|
+
return fnBody;
|
|
1807
|
+
}
|
|
1808
|
+
if (value instanceof RegExp) {
|
|
1809
|
+
return "_PxEgEr_" + value;
|
|
1810
|
+
}
|
|
1811
|
+
return value;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
class LoaderUtils {
|
|
1816
|
+
static loadScript(src, async = false, type = "text/javascript") {
|
|
1817
|
+
this.scriptPromises[src] = this.scriptPromises[src] || new Promise((resolve, reject) => {
|
|
1818
|
+
// Load script
|
|
1819
|
+
const script = document.createElement("script");
|
|
1820
|
+
script.type = type;
|
|
1821
|
+
script.src = src;
|
|
1822
|
+
script.async = async;
|
|
1823
|
+
if (script.readyState) {
|
|
1824
|
+
// Internet explorer
|
|
1825
|
+
script.onreadystatechange = () => {
|
|
1826
|
+
if (script.readyState === "loaded" || script.readyState === "complete") {
|
|
1827
|
+
script.onreadystatechange = null;
|
|
1828
|
+
resolve(script);
|
|
1695
1829
|
}
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
else {
|
|
1833
|
+
// Other browsers
|
|
1834
|
+
script.onload = () => resolve(script);
|
|
1835
|
+
}
|
|
1836
|
+
script.onerror = (error) => reject(error);
|
|
1837
|
+
document.body.appendChild(script);
|
|
1698
1838
|
});
|
|
1839
|
+
return this.scriptPromises[src];
|
|
1699
1840
|
}
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
if (
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1841
|
+
static loadStyle(src) {
|
|
1842
|
+
this.stylePromises[src] = this.stylePromises[src] || new Promise((resolve, reject) => {
|
|
1843
|
+
// Load script
|
|
1844
|
+
const link = document.createElement("link");
|
|
1845
|
+
link.rel = "stylesheet";
|
|
1846
|
+
link.type = "text/css";
|
|
1847
|
+
link.href = src;
|
|
1848
|
+
if (link.readyState) {
|
|
1849
|
+
// Internet explorer
|
|
1850
|
+
link.onreadystatechange = () => {
|
|
1851
|
+
if (link.readyState === "loaded" || link.readyState === "complete") {
|
|
1852
|
+
link.onreadystatechange = null;
|
|
1853
|
+
resolve(link);
|
|
1854
|
+
}
|
|
1855
|
+
};
|
|
1715
1856
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1857
|
+
else {
|
|
1858
|
+
// Other browsers
|
|
1859
|
+
link.onload = () => resolve(link);
|
|
1860
|
+
}
|
|
1861
|
+
link.onerror = (error) => reject(error);
|
|
1862
|
+
document.body.appendChild(link);
|
|
1863
|
+
});
|
|
1864
|
+
return this.stylePromises[src];
|
|
1719
1865
|
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1866
|
+
}
|
|
1867
|
+
LoaderUtils.scriptPromises = {};
|
|
1868
|
+
LoaderUtils.stylePromises = {};
|
|
1869
|
+
|
|
1870
|
+
class MathUtils {
|
|
1871
|
+
static equal(a, b, epsilon = null) {
|
|
1872
|
+
epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : MathUtils.EPSILON;
|
|
1873
|
+
return Math.abs(a - b) < epsilon;
|
|
1874
|
+
}
|
|
1875
|
+
static clamp(value, min, max) {
|
|
1876
|
+
return Math.max(Math.min(value, max), min);
|
|
1877
|
+
}
|
|
1878
|
+
static round(value, precision = 2, divider = 1) {
|
|
1879
|
+
precision = Math.pow(10, precision);
|
|
1880
|
+
return Math.round(value * precision / divider) / precision;
|
|
1881
|
+
}
|
|
1882
|
+
static approxIndex(x, values, epsilon = null) {
|
|
1883
|
+
if (!Array.isArray(values) || values.length == 0) {
|
|
1884
|
+
return -1;
|
|
1725
1885
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1886
|
+
let s = 0;
|
|
1887
|
+
let e = values.length - 1;
|
|
1888
|
+
while (s <= e) {
|
|
1889
|
+
const i = Math.floor((s + e) / 2);
|
|
1890
|
+
const v = values[i];
|
|
1891
|
+
if (MathUtils.equal(v, x, epsilon)) {
|
|
1892
|
+
return i;
|
|
1893
|
+
}
|
|
1894
|
+
if (v < x) {
|
|
1895
|
+
s = i + 1;
|
|
1896
|
+
}
|
|
1897
|
+
else {
|
|
1898
|
+
e = i - 1;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
const m = Math.max(e, 0);
|
|
1902
|
+
const a = values[s];
|
|
1903
|
+
const b = values[m];
|
|
1904
|
+
return Math.abs(a - x) < Math.abs(b - x) ? s : m;
|
|
1737
1905
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
return new Promise(resolve => {
|
|
1742
|
-
const route = config[c];
|
|
1743
|
-
const check = !route.component ? Promise.resolve(false) : this.checkRoute(route);
|
|
1744
|
-
check.then(res => {
|
|
1745
|
-
if (res) {
|
|
1746
|
-
resolve([route.path]);
|
|
1747
|
-
return;
|
|
1748
|
-
}
|
|
1749
|
-
this.getReturnStateRecursive(config, c + 1).then(resolve);
|
|
1750
|
-
});
|
|
1751
|
-
});
|
|
1906
|
+
static approximate(x, values, epsilon = null) {
|
|
1907
|
+
const index = MathUtils.approxIndex(x, values, epsilon);
|
|
1908
|
+
return values[index] ?? null;
|
|
1752
1909
|
}
|
|
1753
1910
|
}
|
|
1754
|
-
|
|
1755
|
-
AuthGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard });
|
|
1756
|
-
__decorate([
|
|
1757
|
-
FactoryDependencies(AUTH_SERVICE),
|
|
1758
|
-
__metadata("design:type", Function),
|
|
1759
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
1760
|
-
__metadata("design:returntype", Function)
|
|
1761
|
-
], AuthGuard, "guardAuthField", null);
|
|
1762
|
-
__decorate([
|
|
1763
|
-
FactoryDependencies(StateService),
|
|
1764
|
-
__metadata("design:type", Function),
|
|
1765
|
-
__metadata("design:paramtypes", [StateService, String]),
|
|
1766
|
-
__metadata("design:returntype", Function)
|
|
1767
|
-
], AuthGuard, "guardStateField", null);
|
|
1768
|
-
__decorate([
|
|
1769
|
-
FactoryDependencies(AUTH_SERVICE, StateService),
|
|
1770
|
-
__metadata("design:type", Function),
|
|
1771
|
-
__metadata("design:paramtypes", [Object, StateService, String]),
|
|
1772
|
-
__metadata("design:returntype", Function)
|
|
1773
|
-
], AuthGuard, "guardAuthStateField", null);
|
|
1774
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard, decorators: [{
|
|
1775
|
-
type: Injectable
|
|
1776
|
-
}], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
|
|
1777
|
-
type: Inject,
|
|
1778
|
-
args: [Injector]
|
|
1779
|
-
}] }, { type: StateService, decorators: [{
|
|
1780
|
-
type: Inject,
|
|
1781
|
-
args: [StateService]
|
|
1782
|
-
}] }, { type: undefined, decorators: [{
|
|
1783
|
-
type: Inject,
|
|
1784
|
-
args: [AUTH_SERVICE]
|
|
1785
|
-
}] }]; } });
|
|
1911
|
+
MathUtils.EPSILON = 1e-9;
|
|
1786
1912
|
|
|
1787
1913
|
class TimerUtils {
|
|
1788
1914
|
static createTimeout(func, time) {
|
|
@@ -1936,112 +2062,6 @@ class StringUtils {
|
|
|
1936
2062
|
}
|
|
1937
2063
|
}
|
|
1938
2064
|
|
|
1939
|
-
class ArrayUtils {
|
|
1940
|
-
static has(arr, ...items) {
|
|
1941
|
-
if (!ObjectUtils.isArray(arr) || !ObjectUtils.isArray(items))
|
|
1942
|
-
return false;
|
|
1943
|
-
for (let i = 0; i < items.length; i++) {
|
|
1944
|
-
if (arr.indexOf(items[i]) >= 0)
|
|
1945
|
-
return true;
|
|
1946
|
-
}
|
|
1947
|
-
return false;
|
|
1948
|
-
}
|
|
1949
|
-
static match(arr, str) {
|
|
1950
|
-
if (!ObjectUtils.isArray(arr) || !ObjectUtils.isString(str))
|
|
1951
|
-
return false;
|
|
1952
|
-
for (let i = 0; i < arr.length; i++) {
|
|
1953
|
-
if (arr[i] instanceof RegExp) {
|
|
1954
|
-
const regex = arr[i];
|
|
1955
|
-
if (regex.test(str))
|
|
1956
|
-
return true;
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
return false;
|
|
1960
|
-
}
|
|
1961
|
-
static any(arr, cb) {
|
|
1962
|
-
if (!ObjectUtils.isArray(arr) || !ObjectUtils.isFunction(cb))
|
|
1963
|
-
return false;
|
|
1964
|
-
for (let i = 0; i < arr.length; i++) {
|
|
1965
|
-
if (cb(arr[i]))
|
|
1966
|
-
return true;
|
|
1967
|
-
}
|
|
1968
|
-
return false;
|
|
1969
|
-
}
|
|
1970
|
-
static move(arr, oldIndex, newIndex) {
|
|
1971
|
-
if (!ObjectUtils.isArray(arr))
|
|
1972
|
-
return [];
|
|
1973
|
-
const length = arr.length;
|
|
1974
|
-
while (oldIndex < 0) {
|
|
1975
|
-
oldIndex += length;
|
|
1976
|
-
}
|
|
1977
|
-
while (newIndex < 0) {
|
|
1978
|
-
newIndex += length;
|
|
1979
|
-
}
|
|
1980
|
-
if (newIndex >= length) {
|
|
1981
|
-
let k = newIndex - length + 1;
|
|
1982
|
-
while (k--) {
|
|
1983
|
-
arr.push(undefined);
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
arr.splice(newIndex, 0, arr.splice(oldIndex, 1)[0]);
|
|
1987
|
-
return arr;
|
|
1988
|
-
}
|
|
1989
|
-
static reversed(arr) {
|
|
1990
|
-
const result = [];
|
|
1991
|
-
if (!ObjectUtils.isArray(arr))
|
|
1992
|
-
return result;
|
|
1993
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1994
|
-
result.push(arr[i]);
|
|
1995
|
-
}
|
|
1996
|
-
return result;
|
|
1997
|
-
}
|
|
1998
|
-
static min(arr, cb) {
|
|
1999
|
-
if (!ObjectUtils.isArray(arr))
|
|
2000
|
-
return null;
|
|
2001
|
-
let min = Number.MAX_SAFE_INTEGER;
|
|
2002
|
-
let result = null;
|
|
2003
|
-
for (let i = 0; i < arr.length; i++) {
|
|
2004
|
-
const current = cb(arr[i], i);
|
|
2005
|
-
if (current < min || result === null) {
|
|
2006
|
-
min = current;
|
|
2007
|
-
result = arr[i];
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
return result;
|
|
2011
|
-
}
|
|
2012
|
-
static max(arr, cb) {
|
|
2013
|
-
if (!ObjectUtils.isArray(arr))
|
|
2014
|
-
return null;
|
|
2015
|
-
let max = Number.MIN_SAFE_INTEGER;
|
|
2016
|
-
let result = null;
|
|
2017
|
-
for (let i = 0; i < arr.length; i++) {
|
|
2018
|
-
const current = cb(arr[i], i);
|
|
2019
|
-
if (current > max || result === null) {
|
|
2020
|
-
max = current;
|
|
2021
|
-
result = arr[i];
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
return result;
|
|
2025
|
-
}
|
|
2026
|
-
static chunk(arr, size) {
|
|
2027
|
-
if (!ObjectUtils.isArray(arr))
|
|
2028
|
-
return [];
|
|
2029
|
-
size = Math.max(1, size);
|
|
2030
|
-
const result = [];
|
|
2031
|
-
for (let i = 0; i < arr.length; i += size) {
|
|
2032
|
-
result.push(arr.slice(i, i + size));
|
|
2033
|
-
}
|
|
2034
|
-
return result;
|
|
2035
|
-
}
|
|
2036
|
-
static unique(arr) {
|
|
2037
|
-
if (!ObjectUtils.isArray(arr))
|
|
2038
|
-
return [];
|
|
2039
|
-
return arr.filter((value, index, self) => {
|
|
2040
|
-
return self.indexOf(value) === index;
|
|
2041
|
-
});
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
2065
|
class SetUtils {
|
|
2046
2066
|
static equals(set, obj) {
|
|
2047
2067
|
if (!ObjectUtils.isSet(set) || !ObjectUtils.isSet(obj))
|
|
@@ -5753,5 +5773,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
|
|
|
5753
5773
|
* Generated bundle index. Do not edit.
|
|
5754
5774
|
*/
|
|
5755
5775
|
|
|
5756
|
-
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileSystemEntry, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, ValuedPromise, ValuesPipe, Vector, WASI_IMPLEMENTATION, WasmService };
|
|
5776
|
+
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileSystemEntry, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, ValuedPromise, ValuesPipe, Vector, WASI_IMPLEMENTATION, WasmService, cachedFactory };
|
|
5757
5777
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|