all files / pdfviewer/annotation/ redaction-annotation.js

4.94% Statements 44/890
0% Branches 0/1133
3.92% Functions 2/51
4.98% Lines 44/883
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 17651×   1× 1× 1×                             1×                                                                                                                                                                                                                                                                                                                                                       1×                                                                             1×                                                                                                                                                                           1×                             1×                                                                                                                                                                                                                                                                                                                                                             1×                                                                                                                                     1×                                     1×                       1×                             1×                                                                   1×                                                                                                                                 1×                                                                                                                                                                                       1×             1×                     1×                                                                                                                                                                             1×                 1×                                                                                         1×                                                                                                                                                                                                   1×                                                                                                       1×                                                   1×                                     1×                                       1×     1×                             1×                     1×                                                                                                 1×                                                           1×                                                                                                         1×                           1×                                                                                                                                                                                                                                                                                                                       1×                                                                     1×                           1×     1×                                                                                                                                                                                   1×                                           1×                                                                                               1×                             1×                                   1×   1×    
define(["require", "exports", "../../index", "@syncfusion/ej2-base"], function (require, exports, index_1, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Redaction = (function () {
        function Redaction(pdfviewer, pdfViewerBase) {
            this.redactionPageNumbers = [];
            this.redactionCount = 0;
            this.isAddAnnotationProgramatically = false;
            this.isRepeat = false;
            this.overlayText = '';
            this.isRedactionHovered = false;
            this.previousTool = '';
            this.isAnnotationHoverd = false;
            this.hoveredRedactionAnnotName = '';
            this.hoveredRedactionId = '';
            this.pdfViewer = pdfviewer;
            this.pdfViewerBase = pdfViewerBase;
            this.initializeRedactionProperties();
        }
        Redaction.prototype.updateAddAnnotationDetails = function (options, offset) {
            if (!options) {
                offset = options.bound || { x: 10, y: 10 };
            }
            else {
                offset.x = options.bound && !ej2_base_1.isNullOrUndefined(options.bound.x) ? options.bound.x : 10;
                offset.y = options.bound && !ej2_base_1.isNullOrUndefined(options.bound.y) ? options.bound.y : 10;
            }
            var annotationSelectorSettings = options.annotationSelectorSettings ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.annotationSelectorSettings) ||
                this.pdfViewer.annotationSelectorSettings;
            var annotationSettings = this.pdfViewer.annotationModule.updateSettings(this.pdfViewer.redactionSettings);
            var allowedInteractions = options.allowedInteractions ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.allowedInteractions) ||
                this.pdfViewer.annotationSettings.allowedInteractions;
            var currentDateString = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
            var annotationName = 'redaction_' + this.pdfViewer.annotation.createGUID();
            var pageNumber = options.pageNumber !== undefined ? options.pageNumber : 0;
            var author = options.author ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.author) ||
                this.pdfViewer.annotationSettings.author ||
                'Guest';
            var markerFillColor = this.pdfViewer.annotationModule.hexToRgba(options.markerFillColor ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.markerFillColor) ||
                'rgba(255, 255, 255, 1)');
            var fillColor = this.pdfViewer.annotationModule.hexToRgba(options.fillColor ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.fillColor) ||
                'rgba(0, 0, 0, 0)');
            var markerBorderColor = this.pdfViewer.annotationModule.
                hexToRgba(options.markerBorderColor ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.markerBorderColor) ||
                'rgba(255, 0, 0, 1)');
            var markerOpacity = options.markerOpacity ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.markerOpacity) ||
                1;
            var isPrint = !ej2_base_1.isNullOrUndefined(options.isPrint) ?
                !!options.isPrint :
                (this.pdfViewer.redactionSettings && !ej2_base_1.isNullOrUndefined(this.pdfViewer.redactionSettings.isPrint)) ?
                    !!this.pdfViewer.redactionSettings.isPrint :
                    true;
            var isLock = !ej2_base_1.isNullOrUndefined(options.isLock) ?
                !!options.isLock :
                (this.pdfViewer.redactionSettings && !ej2_base_1.isNullOrUndefined(this.pdfViewer.redactionSettings.isLock)) ?
                    !!this.pdfViewer.redactionSettings.isLock :
                    false;
            var overlayText = options.overlayText ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.overlayText) ||
                '';
            var fontColor = this.pdfViewer.annotationModule.hexToRgba(options.fontColor ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.fontColor) ||
                'rgba(255, 0, 0, 1)');
            var fontSize = !ej2_base_1.isNullOrUndefined(options.fontSize) ?
                options.fontSize || 10 :
                (this.pdfViewer.redactionSettings && !ej2_base_1.isNullOrUndefined(this.pdfViewer.redactionSettings.fontSize)) ?
                    this.pdfViewer.redactionSettings.fontSize || 10 :
                    10;
            var fontFamily = options.fontFamily ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.fontFamily) ||
                'Helvetica';
            var textAlign = options.textAlignment ||
                (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.textAlignment) ||
                'center';
            var width = options.bound ? options.bound.width : 100;
            var height = options.bound ? options.bound.height : 50;
            annotationSettings.isLock = isLock;
            annotationSettings.minHeight = options.minHeight || 0;
            annotationSettings.minWidth = options.minWidth || 0;
            annotationSettings.maxWidth = options.maxWidth || 0;
            annotationSettings.maxHeight = options.maxHeight || 0;
            var redactionAnnotation = [];
            var redaction = {
                Id: ('redaction' + this.redactionCount++) || 'redaction_' + this.pdfViewer.annotation.createGUID(),
                AllowedInteractions: options.allowedInteractions || allowedInteractions,
                AnnotName: annotationName,
                AnnotType: 'redaction',
                AnnotationSelectorSettings: annotationSelectorSettings,
                AnnotationSettings: annotationSettings,
                Author: author,
                Bounds: {
                    X: offset.x,
                    Y: offset.y,
                    Width: width,
                    Height: height,
                    Left: offset.x, Top: offset.y,
                    Location: { X: offset.x, Y: offset.y },
                    Size: { Height: height, IsEmpty: false, Width: width }
                },
                Comments: [],
                CustomData: options.customData || null,
                CreatedDate: currentDateString,
                ExistingCustomData: null,
                FillColor: fillColor,
                FontColor: fontColor,
                FontSize: fontSize,
                FontFamily: fontFamily,
                IsCommentLock: false,
                IsLocked: isLock,
                IsPrint: isPrint,
                MarkerFillColor: markerFillColor,
                MarkerBorderColor: markerBorderColor,
                MarkerOpacity: markerOpacity,
                ModifiedDate: currentDateString,
                Note: '',
                OverlayText: overlayText,
                IsRepeat: options.isRepeat || false,
                RotateAngle: 'RotateAngle0',
                ShapeAnnotationType: 'Redaction',
                State: '',
                StateModel: 'Review',
                Subject: 'Redaction',
                TextAlign: textAlign
            };
            redactionAnnotation[0] = redaction;
            var storeObject = this.pdfViewer.annotationsCollection.get(this.pdfViewerBase.documentId + '_annotations_redaction');
            var annotObject = [];
            if (storeObject) {
                annotObject = JSON.parse(JSON.stringify(storeObject));
            }
            var annotationObject = {
                shapeAnnotationType: 'Redaction',
                author: author,
                modifiedDate: currentDateString,
                subject: 'Redaction',
                note: '',
                bounds: {
                    left: offset.x,
                    top: offset.y,
                    width: width,
                    height: height,
                    right: offset.x + width,
                    bottom: offset.y + height
                },
                rotateAngle: '0',
                isLocked: isLock,
                annotName: annotationName,
                pageNumber: pageNumber,
                annotationId: annotationName,
                annotationSelectorSettings: annotationSelectorSettings,
                customData: options.customData || {},
                overlayText: overlayText,
                isRepeat: options.isRepeat || false,
                fontColor: fontColor,
                fillColor: fillColor,
                fontSize: fontSize,
                fontFamily: fontFamily,
                textAlign: textAlign,
                markerFillColor: markerFillColor,
                markerBorderColor: markerBorderColor,
                markerOpacity: markerOpacity,
                isPrint: isPrint,
                id: redactionAnnotation[0].Id,
                comments: [],
                review: {},
                isCommentLock: false,
                isReadonly: false,
                annotationSettings: annotationSettings,
                allowedInteractions: allowedInteractions
            };
            var index = this.pdfViewer.annotation.getPageCollection(annotObject, pageNumber);
            if (index === -1 || !annotObject[index]) {
                var pageAnnotations = {
                    pageIndex: pageNumber,
                    annotations: [annotationObject]
                };
                annotObject.push(pageAnnotations);
            }
            else {
                annotObject[index].annotations.push(annotationObject);
            }
            redactionAnnotation[0].Id = annotationObject.id;
            return { redactionAnnotation: redactionAnnotation };
        };
        Redaction.prototype.handleRedactionHover = function (annotation, pageIndex, currentAnnot) {
            var currentAnnotationId = annotation.id || '';
            this.previousTool = this.pdfViewer.tool;
            this.hoveredRedactionAnnotName = annotation.annotName;
            var selectedAnnotationIsRedaction = false;
            if (this.pdfViewer.selectedItems.annotations && this.pdfViewer.selectedItems.annotations.length > 0 && this.pdfViewer.selectedItems.annotations[0].id === 'diagram_helper') {
                selectedAnnotationIsRedaction = true;
            }
            if (currentAnnotationId !== 'diagram_helper' && this.hoveredRedactionId !== 'diagram_helper' && !selectedAnnotationIsRedaction) {
                if (this.isRedactionHovered && this.hoveredRedactionId !== currentAnnotationId) {
                    this.resetRedactionHover();
                }
                if (!this.isRedactionHovered || this.hoveredRedactionId !== currentAnnotationId) {
                    annotation.originalFillColor = annotation.markerFillColor || '';
                    if (annotation.wrapper && annotation.wrapper.children && annotation.wrapper.children.length > 0 && annotation.fillColor) {
                        var fillColor = index_1.updateColorWithOpacity(annotation.fillColor, 1);
                        annotation.wrapper.children[0].style.fill = fillColor;
                        annotation.wrapper.children[0].style.strokeColor = fillColor;
                        annotation.wrapper.children[0].style.opacity = 1;
                    }
                    if (annotation.annotationAddMode === 'TextRedaction') {
                        this.orginalFillColor = annotation.markerFillColor;
                        this.orginalBorderColor = annotation.markerBorderColor;
                        this.orginalOpacity = annotation.markerOpacity;
                    }
                    if (annotation.overlayText) {
                        this.pdfViewer.annotation.redactionOverlayTextModule.renderRedactionOverlayText(annotation, currentAnnot);
                    }
                    this.isAnnotationHoverd = true;
                    var canvasElement = document.getElementById(this.pdfViewer.element.id + '_annotationCanvas_' + pageIndex);
                    if (canvasElement) {
                        this.pdfViewer.renderDrawing(canvasElement, pageIndex);
                    }
                    this.isAnnotationHoverd = false;
                    this.isRedactionHovered = true;
                    this.hoveredRedactionId = currentAnnotationId;
                }
            }
        };
        Redaction.prototype.resetRedactionHover = function () {
            if (this.isRedactionHovered) {
                this.pdfViewer.tool = this.previousTool;
                this.previousTool = '';
                this.isAnnotationHoverd = false;
                if (this.pdfViewer.selectedItems && this.pdfViewer.selectedItems.annotations) {
                    for (var i = 0; i < this.pdfViewer.selectedItems.annotations.length; i++) {
                        var annotation = this.pdfViewer.selectedItems.annotations[i];
                        if (annotation && annotation.shapeAnnotationType === 'Redaction') {
                            if (annotation.overlayText) {
                                this.pdfViewer.annotation.redactionOverlayTextModule.removeRedactionOverlayText(annotation);
                            }
                            if (annotation.originalFillColor) {
                                if (annotation.wrapper && annotation.wrapper.children && annotation.wrapper.children.length > 0) {
                                    var opacity = annotation.markerOpacity > 1 ? annotation.markerOpacity / 100 :
                                        annotation.markerOpacity;
                                    var fillColor = index_1.updateColorWithOpacity(annotation.originalFillColor, annotation.markerOpacity);
                                    annotation.wrapper.children[0].style.fill = fillColor;
                                    annotation.wrapper.children[0].style.strokeColor = annotation.markerBorderColor;
                                    annotation.wrapper.children[0].style.opacity = opacity;
                                }
                                delete annotation.originalFillColor;
                            }
                            var canvasElement = document.getElementById(this.pdfViewer.element.id + '_annotationCanvas_' + annotation.pageIndex);
                            if (canvasElement) {
                                this.pdfViewer.renderDrawing(canvasElement, annotation.pageIndex);
                            }
                        }
                    }
                }
                if (this.pdfViewer.nameTable) {
                    if (this.hoveredRedactionId && this.pdfViewer.nameTable[this.hoveredRedactionId]) {
                        var annotation = this.pdfViewer.nameTable[this.hoveredRedactionId];
                        if (annotation && annotation.shapeAnnotationType === 'Redaction') {
                            if (annotation.overlayText) {
                                this.pdfViewer.annotation.redactionOverlayTextModule.removeRedactionOverlayText(annotation);
                            }
                            if (annotation.originalFillColor) {
                                if (annotation.wrapper && annotation.wrapper.children && annotation.wrapper.children.length > 0) {
                                    var opacity = annotation.markerOpacity > 1 ? annotation.markerOpacity / 100 :
                                        annotation.markerOpacity;
                                    var fillColor = index_1.updateColorWithOpacity(annotation.originalFillColor, annotation.markerOpacity);
                                    annotation.wrapper.children[0].style.fill = fillColor;
                                    annotation.wrapper.children[0].style.strokeColor = annotation.markerBorderColor;
                                    annotation.wrapper.children[0].style.opacity = opacity;
                                }
                                delete annotation.originalFillColor;
                            }
                            var canvasElement = document.getElementById(this.pdfViewer.element.id + '_annotationCanvas_' + annotation.pageIndex);
                            if (canvasElement) {
                                this.pdfViewer.renderDrawing(canvasElement, annotation.pageIndex);
                            }
                        }
                    }
                    else {
                        for (var key in this.pdfViewer.nameTable) {
                            if (Object.prototype.hasOwnProperty.call(this.pdfViewer.nameTable, key)) {
                                var annotation = this.pdfViewer.nameTable[key];
                                if (annotation && annotation.shapeAnnotationType === 'Redaction') {
                                    if (annotation.overlayText) {
                                        this.pdfViewer.annotation.redactionOverlayTextModule.removeRedactionOverlayText(annotation);
                                    }
                                    if (annotation.originalFillColor) {
                                        if (annotation.wrapper && annotation.wrapper.children && annotation.wrapper.children.length > 0) {
                                            var opacity = annotation.markerOpacity > 1 ? annotation.markerOpacity / 100 :
                                                annotation.markerOpacity;
                                            var fillColor = index_1.updateColorWithOpacity(annotation.originalFillColor, annotation.markerOpacity);
                                            annotation.wrapper.children[0].style.fill = fillColor;
                                            annotation.wrapper.children[0].style.strokeColor = annotation.markerBorderColor;
                                            annotation.wrapper.children[0].style.opacity = opacity;
                                        }
                                        delete annotation.originalFillColor;
                                    }
                                    var canvasElement = document.getElementById(this.pdfViewer.element.id + '_annotationCanvas_' + annotation.pageIndex);
                                    if (canvasElement) {
                                        this.pdfViewer.renderDrawing(canvasElement, annotation.pageIndex);
                                    }
                                }
                            }
                        }
                    }
                }
                this.isRedactionHovered = false;
                this.hoveredRedactionId = '';
            }
        };
        Redaction.prototype.initializeRedactionProperties = function () {
            if (this.pdfViewer.redactionSettings) {
                this.redactionFillColor = this.pdfViewer.redactionSettings.markerFillColor || 'rgba(0, 0, 0, 1)';
                this.redactionMarkerFillColor = this.pdfViewer.redactionSettings.markerFillColor || 'rgba(255, 255, 255, 1)';
                this.redactionBorderColor = this.pdfViewer.redactionSettings.markerBorderColor || 'rgba(255, 0, 0, 1)';
                this.redactionOutlineOpacity = this.pdfViewer.redactionSettings.markerOpacity || 1;
            }
            else {
                this.redactionFillColor = 'rgba(0, 0, 0, 1)';
                this.redactionMarkerFillColor = 'rgba(255, 255, 255, 1)';
                this.redactionBorderColor = 'rgba(255, 0, 0, 1)';
                this.redactionOutlineOpacity = 1;
            }
            this.redactionPageNumbers = [];
        };
        Redaction.prototype.renderRedactionAnnotations = function (redactionAnnotations, pageNumber, isImportAction, isAnnotOrderAction) {
            var isAdded = false;
            if (!isImportAction) {
                for (var p = 0; p < this.redactionPageNumbers.length; p++) {
                    if (this.redactionPageNumbers[parseInt(p.toString(), 10)] === pageNumber) {
                        var pageAnnotations = this.getAnnotations(pageNumber, null);
                        if (pageAnnotations !== null && redactionAnnotations) {
                            for (var k = 0; k < pageAnnotations.length; k++) {
                                for (var l = 0; l < pageAnnotations.length; l++) {
                                    var redactAnnot = redactionAnnotations[l] ? redactionAnnotations[l] :
                                        redactionAnnotations;
                                    var annotationName = redactAnnot.annotName ?
                                        redactAnnot.annotName : redactAnnot.AnnotName;
                                    var pageAnnotationName = pageAnnotations[k].annotName ?
                                        pageAnnotations[k].annotName : pageAnnotations[k].AnnotName;
                                    if (pageAnnotationName && annotationName && pageAnnotationName === annotationName) {
                                        isAdded = true;
                                        break;
                                    }
                                }
                                if (isAdded) {
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }
            if (redactionAnnotations && (!isAdded || isAnnotOrderAction)) {
                if (redactionAnnotations.length > 0) {
                    this.redactionPageNumbers.push(pageNumber);
                    for (var i = 0; i < redactionAnnotations.length; i++) {
                        var annotation = redactionAnnotations[i];
                        annotation.annotationAddMode =
                            this.pdfViewer.annotationModule.findAnnotationMode(annotation, pageNumber, annotation.AnnotType);
                        var annotationObject = {};
                        var position = annotation.Bound ? annotation.Bound : annotation.Bounds;
                        var author = annotation.Author || '';
                        annotation.AnnotationSettings = annotation.AnnotationSettings ?
                            annotation.AnnotationSettings : this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
                        annotation.allowedInteractions = annotation.AllowedInteractions ?
                            annotation.AllowedInteractions :
                            this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
                        var isPrint = true;
                        if (!ej2_base_1.isNullOrUndefined(annotation.IsPrint)) {
                            isPrint = annotation.IsPrint;
                        }
                        else {
                            isPrint = !ej2_base_1.isNullOrUndefined(annotation.isPrint) ? annotation.isPrint : annotation.AnnotationSettings.isPrint;
                        }
                        if (annotation.IsLocked) {
                            annotation.AnnotationSettings.isLock = annotation.IsLocked;
                        }
                        annotationObject = {
                            shapeAnnotationType: 'Redaction',
                            author: author,
                            modifiedDate: annotation.ModifiedDate || new Date().toLocaleString(),
                            subject: annotation.Subject || '',
                            note: annotation.Note || '',
                            bounds: {
                                left: position.X,
                                top: position.Y,
                                width: position.Width,
                                height: position.Height,
                                right: position.Right,
                                bottom: position.Bottom
                            },
                            rotateAngle: annotation.RotateAngle || '0',
                            isLocked: annotation.IsLocked || false,
                            annotName: annotation.AnnotName,
                            pageNumber: pageNumber,
                            annotationSelectorSettings: annotation.AnnotationSelectorSettings || this.pdfViewer.annotationSelectorSettings,
                            customData: this.pdfViewer.annotation.getCustomData(annotation),
                            overlayText: annotation.OverlayText || '',
                            isRepeat: annotation.IsRepeat,
                            fontColor: annotation.FontColor || 'rgba(255, 0, 0, 1)',
                            fillColor: annotation.FillColor || 'rgba(0, 0, 0, 1)',
                            fontSize: annotation.FontSize || 14,
                            fontFamily: annotation.FontFamily || 'Helvetica',
                            textAlign: annotation.TextAlign || 'center',
                            markerFillColor: annotation.MarkerFillColor || 'rgba(255, 255, 255, 1)',
                            markerBorderColor: annotation.MarkerBorderColor || 'rgba(255, 0, 0, 1)',
                            markerOpacity: annotation.MarkerOpacity || 1,
                            annotationSettings: annotation.AnnotationSettings,
                            allowedInteractions: annotation.allowedInteractions,
                            isPrint: isPrint,
                            annotationId: annotation.AnnotName || '',
                            id: (annotation.Id || ('redaction' + this.redactionCount++) || this.pdfViewer.annotationModule.createGUID() || 'redaction_id'),
                            comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
                            review: {
                                state: annotation.State, stateModel: annotation.StateModel,
                                modifiedDate: annotation.ModifiedDate, author: annotation.Author
                            },
                            isCommentLock: false,
                            isReadonly: annotation.IsReadonly || false,
                            originalName: annotation.OriginalName ? annotation.OriginalName : null
                        };
                        var annot = {
                            author: author,
                            modifiedDate: annotationObject.modifiedDate,
                            annotName: annotationObject.annotName,
                            pageIndex: pageNumber,
                            bounds: {
                                x: position.X,
                                y: position.Y,
                                width: position.Width,
                                height: position.Height
                            },
                            strokeColor: annotationObject.markerBorderColor,
                            fillColor: annotationObject.fillColor,
                            thickness: 1,
                            comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
                            id: annotationObject.id,
                            shapeAnnotationType: 'Redaction',
                            annotType: 'Redaction',
                            subject: annotationObject.subject,
                            notes: annotationObject.note,
                            annotationSelectorSettings: annotationObject.annotationSelectorSettings,
                            annotationSettings: annotationObject.annotationSettings,
                            annotationAddMode: annotation.annotationAddMode,
                            allowedInteractions: annotation.allowedInteractions,
                            isLocked: annotation.isLocked,
                            isPrint: isPrint,
                            overlayText: annotationObject.overlayText,
                            isRepeat: annotationObject.isRepeat,
                            markerFillColor: annotationObject.markerFillColor,
                            markerBorderColor: annotationObject.markerBorderColor || 'rgba(255, 0, 0, 1)',
                            markerOpacity: annotationObject.markerOpacity || 1,
                            fontColor: annotationObject.fontColor,
                            fontSize: annotationObject.fontSize,
                            fontFamily: annotationObject.fontFamily,
                            textAlign: annotationObject.textAlign
                        };
                        this.pdfViewer.add(annot);
                        this.drawRedactionAnnotation(pageNumber, annot);
                        this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotationObject, '_annotations_redaction');
                        if (this.isAddAnnotationProgramatically) {
                            var settings = {
                                shapeAnnotationType: annotationObject.shapeAnnotationType,
                                markerBorderColor: annot.strokeColor,
                                markerFillColor: annotationObject.markerFillColor,
                                opacity: annot.opacity,
                                overlayText: annotationObject.overlayText || '',
                                fontColor: annotationObject.fontColor,
                                fontSize: annotationObject.fontSize || 14,
                                fontFamily: annotationObject.fontFamily,
                                textAlign: annotationObject.textAlign,
                                author: author,
                                subject: annotationObject.subject,
                                modifiedDate: annotationObject.modifiedDate
                            };
                            this.pdfViewer.fireAnnotationAdd(annot.pageIndex || 0, annot.annotName || '', 'Redaction', annot.bounds, settings);
                        }
                    }
                    if (this.pdfViewer.toolbarModule && this.pdfViewer.toolbarModule.redactionToolbarModule) {
                        this.pdfViewer.toolbarModule.redactionToolbarModule.showHideRedactIcon(true);
                    }
                }
                else if (redactionAnnotations.shapeAnnotationType && redactionAnnotations.shapeAnnotationType === 'Redaction') {
                    var annotation = this.createAnnotationObject(redactionAnnotations);
                    if (!ej2_base_1.isNullOrUndefined(redactionAnnotations.formFieldAnnotationType) &&
                        redactionAnnotations.formFieldAnnotationType !== '') {
                        this.pdfViewer.annotationModule.isFormFieldShape = true;
                    }
                    else {
                        this.pdfViewer.annotationModule.isFormFieldShape = false;
                    }
                    if (annotation) {
                        this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotation, '_annotations_redaction');
                        this.pdfViewer.annotationModule.triggerAnnotationAdd(redactionAnnotations);
                    }
                }
            }
        };
        Redaction.prototype.createAnnotationObject = function (annotation) {
            var bounds;
            var annotationName = this.pdfViewer.annotation.createGUID();
            if (!annotation.formFieldAnnotationType) {
                var commentsDivid = this.pdfViewer.annotation.stickyNotesAnnotationModule.addComments('redaction', (annotation.pageIndex + 1), annotation.shapeAnnotationType);
                if (commentsDivid) {
                    document.getElementById(commentsDivid).id = annotationName;
                }
            }
            if (annotation.id) {
                var obj = this.pdfViewer.nameTable[annotation.id];
                this.updateRedactionProperties(obj);
            }
            annotation.annotName = annotationName;
            if (annotation.wrapper.bounds) {
                bounds = {
                    left: annotation.wrapper.bounds.x,
                    top: annotation.wrapper.bounds.y, height: annotation.wrapper.bounds.height, width: annotation.wrapper.bounds.width,
                    right: annotation.wrapper.bounds.right, bottom: annotation.wrapper.bounds.bottom
                };
            }
            else {
                bounds = {
                    left: 0, top: 0, height: 0, width: 0, right: 0, bottom: 0
                };
            }
            var annotationObject = {
                shapeAnnotationType: 'Redaction',
                author: annotation.author,
                modifiedDate: annotation.modifiedDate || new Date().toLocaleString(),
                subject: annotation.subject || '',
                note: annotation.note || '',
                bounds: bounds,
                rotateAngle: annotation.rotateAngle || '0',
                isLocked: annotation.isLocked || false,
                annotName: annotation.annotName,
                pageNumber: annotation.pageIndex,
                annotationSelectorSettings: annotation.annotationSelectorSettings || this.pdfViewer.annotationSelectorSettings,
                customData: this.pdfViewer.redactionSettings.customData || {},
                overlayText: annotation.overlayText || '',
                isRepeat: annotation.isRepeat,
                fontColor: annotation.fontColor || 'rgba(255, 0, 0, 1)',
                fillColor: annotation.fillColor || 'rgba(0, 0, 0, 1)',
                fontSize: annotation.fontSize || 14,
                fontFamily: annotation.fontFamily || 'Helvetica',
                textAlign: annotation.textAlign || 'center',
                markerFillColor: annotation.markerFillColor || 'rgba(255, 255, 255, 1)',
                markerBorderColor: annotation.markerBorderColor || 'rgba(255, 0, 0, 1)',
                markerOpacity: annotation.markerOpacity || 1,
                annotationSettings: annotation.annotationSettings,
                allowedInteractions: this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation),
                isPrint: annotation.isPrint,
                annotationId: annotation.annotName || '',
                id: annotation.id || '',
                comments: annotation.comments,
                isCommentLock: annotation.isCommentLock,
                isReadonly: annotation.isReadonly || false,
                review: {
                    state: '',
                    stateModel: '',
                    modifiedDate: this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime(),
                    author: annotation.author
                }
            };
            this.updateRedactionProperties(annotationObject);
            return annotationObject;
        };
        Redaction.prototype.updateRedactionProperties = function (annotation) {
            if (!this.pdfViewer.redactionSettings) {
                return;
            }
            var rs = this.pdfViewer.redactionSettings;
            annotation.fillColor = !ej2_base_1.isNullOrUndefined(rs.fillColor) ? rs.fillColor : !ej2_base_1.isNullOrUndefined(annotation.fillColor) ? annotation.fillColor : 'rgba(0, 0, 0, 1)';
            annotation.fontColor = !ej2_base_1.isNullOrUndefined(rs.fontColor) ? rs.fontColor : !ej2_base_1.isNullOrUndefined(annotation.fontColor) ? annotation.fontColor : 'rgba(255, 0, 0, 1)';
            annotation.isRepeat = !ej2_base_1.isNullOrUndefined(rs.isRepeat) ? rs.isRepeat :
                !ej2_base_1.isNullOrUndefined(annotation.isRepeat) ? annotation.isRepeat : false;
            annotation.overlayText = !ej2_base_1.isNullOrUndefined(rs.overlayText) ? rs.overlayText : !ej2_base_1.isNullOrUndefined(annotation.overlayText) ? annotation.overlayText : '';
            annotation.fontSize = !ej2_base_1.isNullOrUndefined(rs.fontSize) ? rs.fontSize :
                !ej2_base_1.isNullOrUndefined(annotation.fontSize) ? annotation.fontSize : 14;
            annotation.fontFamily = !ej2_base_1.isNullOrUndefined(rs.fontFamily) ? rs.fontFamily : !ej2_base_1.isNullOrUndefined(annotation.fontFamily) ? annotation.fontFamily : 'Helvetica';
            annotation.textAlign = !ej2_base_1.isNullOrUndefined(rs.textAlignment) ? rs.textAlignment : !ej2_base_1.isNullOrUndefined(annotation.textAlign) ? annotation.textAlign : 'center';
            annotation.markerFillColor = !ej2_base_1.isNullOrUndefined(rs.markerFillColor) ? rs.markerFillColor : !ej2_base_1.isNullOrUndefined(annotation.markerFillColor) ? annotation.markerFillColor : 'rgba(255, 255, 255, 1)';
            annotation.markerBorderColor = !ej2_base_1.isNullOrUndefined(rs.markerBorderColor) ? rs.markerBorderColor : !ej2_base_1.isNullOrUndefined(annotation.markerBorderColor) ? annotation.markerBorderColor : 'rgba(255, 0, 0, 1)';
            annotation.markerOpacity = !ej2_base_1.isNullOrUndefined(rs.markerOpacity) ? rs.markerOpacity :
                !ej2_base_1.isNullOrUndefined(annotation.markerOpacity) ? annotation.markerOpacity : 1;
        };
        Redaction.prototype.drawRedactionAnnotation = function (pageNumber, annotation, canvas) {
            var bounds = annotation.bounds;
            if (canvas) {
                this.pdfViewer.renderDrawing(canvas, pageNumber);
            }
            else {
                var canvasElement = this.pdfViewerBase.getAnnotationCanvas('_annotationCanvas_', pageNumber);
                if (canvasElement) {
                    this.pdfViewer.renderDrawing(canvasElement, pageNumber);
                }
            }
        };
        Redaction.prototype.getSettings = function (annotation) {
            var settings = {};
            settings.pageNumber = annotation.pageNumber;
            settings.bounds = annotation.bounds;
            settings.annotationSelectorSettings = this.getSelector('Redaction', annotation.subject);
            settings.markerFillColor = annotation.markerFillColor || this.redactionFillColor;
            settings.markerBorderColor = annotation.markerBorderColor || this.redactionBorderColor;
            settings.markerOpacity = annotation.markerOpacity || this.redactionOutlineOpacity;
            settings.overlayText = annotation.overlayText || '';
            settings.fontColor = annotation.fontColor || 'rgba(255, 0, 0, 1)';
            settings.fontSize = annotation.fontSize || 14;
            settings.fontFamily = annotation.fontFamily || 'Helvetica';
            settings.textAlign = annotation.textAlign || 'center';
            return settings;
        };
        Redaction.prototype.setAnnotationType = function (type) {
            if (type === 'Redaction') {
                this.initializeRedactionProperties();
                var modifiedDate = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
                var author = (this.pdfViewer.annotationSettings.author !== 'Guest') ?
                    this.pdfViewer.annotationSettings.author :
                    (this.pdfViewer.redactionSettings && this.pdfViewer.redactionSettings.author) ?
                        this.pdfViewer.redactionSettings.author : 'Guest';
                var opacity = this.pdfViewer.redactionSettings.markerOpacity ? (this.pdfViewer.redactionSettings.markerOpacity > 1 ?
                    (this.pdfViewer.redactionSettings.markerOpacity / 100) : this.pdfViewer.redactionSettings.markerOpacity) : 1;
                this.pdfViewer.drawingObject = {
                    shapeAnnotationType: 'Redaction',
                    strokeColor: this.redactionBorderColor,
                    fillColor: this.pdfViewer.redactionSettings.fillColor || 'rgba(0, 0, 0, 1)',
                    fontColor: this.pdfViewer.redactionSettings.fontColor || 'rgba(255, 0, 0, 1)',
                    opacity: opacity,
                    notes: '',
                    thickness: 1,
                    fontSize: 14,
                    fontFamily: 'Helvetica',
                    borderDashArray: '0',
                    textAlign: 'center',
                    modifiedDate: modifiedDate,
                    author: author,
                    subject: 'Redaction',
                    overlayText: this.pdfViewer.redactionSettings.overlayText || '',
                    markerFillColor: this.redactionMarkerFillColor,
                    markerBorderColor: this.redactionBorderColor,
                    markerOpacity: this.redactionOutlineOpacity,
                    isCommentLock: false
                };
                this.pdfViewer.tool = 'DrawTool';
            }
        };
        Redaction.prototype.updateRedactionAnnotationCollections = function (annotation, pageNumber) {
            var currentAnnotObject = null;
            if (annotation) {
                var isLock = false;
                if (annotation.IsLocked) {
                    isLock = annotation.IsLocked;
                }
                var author = annotation.Author || '';
                var allowedInteractions = annotation.AllowedInteractions ||
                    this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
                if (annotation.Bound) {
                    var annotationObject = {
                        id: 'redaction' + this.redactionCount++,
                        shapeAnnotationType: 'Redaction',
                        author: author,
                        modifiedDate: annotation.ModifiedDate || new Date().toLocaleString(),
                        subject: annotation.Subject || '',
                        note: annotation.Note || '',
                        overlayText: annotation.OverlayText || '',
                        fontColor: annotation.FontColor || 'rgba(255, 0, 0, 1)',
                        fontSize: annotation.FontSize || 14,
                        fontFamily: annotation.FontFamily || 'Helvetica',
                        textAlign: annotation.TextAlign || 'center',
                        markerFillColor: annotation.MarkerFillColor || 'rgba(255, 255, 255, 1)',
                        markerBorderColor: annotation.MarkerBorderColor || 'rgba(255, 0, 0, 1)',
                        markerOpacity: annotation.MarkerOpacity || 1,
                        fillColor: annotation.fillColor || 'rgba(0, 0, 0, 1)',
                        isRepeat: annotation.IsRepeat || false,
                        bounds: {
                            left: annotation.Bound.X,
                            top: annotation.Bound.Y,
                            width: annotation.Bound.Width,
                            height: annotation.Bound.Height,
                            right: annotation.Bound.Right,
                            bottom: annotation.Bound.Bottom
                        },
                        rotateAngle: annotation.RotateAngle || '0',
                        isLocked: isLock,
                        annotationId: annotation.AnnotName,
                        pageNumber: pageNumber,
                        customData: this.pdfViewer.annotation.getCustomData(annotation),
                        allowedInteractions: allowedInteractions,
                        annotName: annotation.AnnotName,
                        annotationSelectorSettings: this.getSelector('Redaction', annotation.Subject),
                        annotationSettings: annotation.AnnotationSettings ||
                            this.pdfViewer.annotationModule.updateAnnotationSettings(annotation),
                        isPrint: annotation.IsPrint !== undefined ? annotation.IsPrint : true,
                        comments: annotation.Comments ? this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author) : [],
                        review: {
                            state: annotation.State,
                            stateModel: annotation.StateModel,
                            modifiedDate: annotation.ModifiedDate,
                            author: annotation.Author
                        },
                        isCommentLock: annotation.IsCommentLock,
                        isReadonly: annotation.IsReadonly || false
                    };
                    if (annotationObject.isLocked) {
                        annotationObject.annotationSettings.isLock = annotationObject.isLocked;
                    }
                    currentAnnotObject = annotationObject;
                }
            }
            return currentAnnotObject;
        };
        Redaction.prototype.modifyInCollection = function (property, pageNumber, annotationBase) {
            if (!ej2_base_1.isNullOrUndefined(annotationBase.formFieldAnnotationType) &&
                annotationBase.formFieldAnnotationType !== '') {
                this.pdfViewer.annotationModule.isFormFieldShape = true;
            }
            else {
                this.pdfViewer.annotationModule.isFormFieldShape = false;
            }
            this.pdfViewerBase.updateDocumentEditedProperty(true);
            var currentAnnotObject = null;
            if (annotationBase) {
                if (property === 'bounds') {
                    this.pdfViewer.annotationModule.stickyNotesAnnotationModule.updateAnnotationModifiedDate(annotationBase, true);
                }
            }
            var pageAnnotations = this.getAnnotations(pageNumber, null);
            if (pageAnnotations != null && annotationBase) {
                for (var i = 0; i < pageAnnotations.length; i++) {
                    if (annotationBase.id === pageAnnotations[i].id ||
                        annotationBase.annotName === pageAnnotations[i].annotName) {
                        if (property === 'bounds') {
                            pageAnnotations[i].bounds = {
                                left: annotationBase.bounds.x,
                                top: annotationBase.bounds.y,
                                height: annotationBase.bounds.height,
                                width: annotationBase.bounds.width,
                                right: annotationBase.bounds.right ? annotationBase.bounds.right : annotationBase.wrapper.bounds.right,
                                bottom: annotationBase.bounds.bottom ? annotationBase.bounds.bottom : annotationBase.wrapper.bounds.bottom
                            };
                        }
                        else if (property === 'fillColor') {
                            pageAnnotations[i].fillColor = annotationBase.fillColor;
                        }
                        else if (property === 'useOverlayText') {
                            pageAnnotations[i].useOverlayText = annotationBase.useOverlayText;
                        }
                        else if (property === 'isRepeat') {
                            pageAnnotations[i].isRepeat = annotationBase.isRepeat;
                        }
                        else if (property === 'fill') {
                            pageAnnotations[i].markerFillColor = annotationBase.wrapper.children[0].style.fill;
                        }
                        else if (property === 'stroke') {
                            pageAnnotations[i].markerBorderColor = annotationBase.wrapper.children[0].style.strokeColor;
                        }
                        else if (property === 'opacity') {
                            pageAnnotations[i].markerOpacity = annotationBase.markerOpacity;
                        }
                        else if (property === 'overlayText') {
                            pageAnnotations[i].overlayText = annotationBase.overlayText;
                        }
                        else if (property === 'fontColor') {
                            pageAnnotations[i].fontColor = annotationBase.fontColor;
                        }
                        else if (property === 'fontSize') {
                            pageAnnotations[i].fontSize = annotationBase.fontSize;
                        }
                        else if (property === 'fontFamily') {
                            pageAnnotations[i].fontFamily = annotationBase.fontFamily;
                        }
                        else if (property === 'textAlign') {
                            pageAnnotations[i].textAlign = annotationBase.textAlign;
                        }
                        else if (property === 'notes') {
                            pageAnnotations[i].note = annotationBase.notes;
                        }
                        else if (property === 'delete') {
                            currentAnnotObject = pageAnnotations.splice(i, 1)[0];
                            break;
                        }
                        else if (property === 'isLock') {
                            if (pageAnnotations[i].annotationSettings) {
                                pageAnnotations[i].annotationSettings.isLock = annotationBase.isLock;
                            }
                            pageAnnotations[i].isLock = annotationBase.isLock;
                        }
                        else if (property === 'allowedInteractions') {
                            pageAnnotations[i].allowedInteractions = annotationBase.allowedInteractions;
                        }
                        else if (property === 'isPrint') {
                            if (pageAnnotations[i].annotationSettings) {
                                pageAnnotations[i].annotationSettings.isPrint = annotationBase.isPrint;
                            }
                            pageAnnotations[i].isPrint = annotationBase.isPrint;
                        }
                        this.pdfViewer.annotationModule.storeAnnotationCollections(pageAnnotations[i], pageNumber);
                    }
                }
                this.manageAnnotations(pageAnnotations, pageNumber);
            }
            return currentAnnotObject;
        };
        Redaction.prototype.addInCollection = function (pageNumber, annotationBase) {
            var pageAnnotations = this.getAnnotations(pageNumber, null);
            if (pageAnnotations) {
                pageAnnotations.push(annotationBase);
            }
            this.manageAnnotations(pageAnnotations, pageNumber);
        };
        Redaction.prototype.manageAnnotations = function (pageAnnotations, pageNumber) {
            var storeObject = this.pdfViewer.annotationsCollection.get(this.pdfViewerBase.documentId + '_annotations_redaction');
            if (storeObject) {
                this.pdfViewer.annotationsCollection.delete(this.pdfViewerBase.documentId + '_annotations_redaction');
                var index = this.pdfViewer.annotationModule.getPageCollection(storeObject, pageNumber);
                if (index != null && storeObject[parseInt(index.toString(), 10)]) {
                    storeObject[parseInt(index.toString(), 10)].annotations = pageAnnotations;
                }
                this.pdfViewer.annotationsCollection.set(this.pdfViewerBase.documentId + '_annotations_redaction', storeObject);
            }
        };
        Redaction.prototype.saveImportedRedactionAnnotations = function (annotation, pageIndex) {
            if (annotation) {
                var annotationObject = {
                    shapeAnnotationType: 'Redaction',
                    author: annotation.Author || '',
                    modifiedDate: annotation.ModifiedDate || new Date().toLocaleString(),
                    subject: annotation.Subject || '',
                    note: annotation.Note || '',
                    bounds: {
                        left: annotation.Bounds.X,
                        top: annotation.Bounds.Y,
                        width: annotation.Bounds.Width,
                        height: annotation.Bounds.Height,
                        right: annotation.Bounds.X + annotation.Bounds.Width,
                        bottom: annotation.Bounds.Y + annotation.Bounds.Height
                    },
                    rotateAngle: annotation.RotateAngle || '0',
                    isLocked: annotation.IsLocked || false,
                    annotName: annotation.AnnotName,
                    pageNumber: pageIndex,
                    annotationId: annotation.AnnotName,
                    annotationSelectorSettings: annotation.AnnotationSelectorSettings || this.pdfViewer.annotationSelectorSettings,
                    customData: this.pdfViewer.annotation.getCustomData(annotation),
                    overlayText: annotation.OverlayText || '',
                    isRepeat: annotation.IsRepeat || false,
                    fontColor: annotation.FontColor || 'rgba(255, 0, 0, 1)',
                    fillColor: annotation.FillColor || 'rgba(0, 0, 0, 1)',
                    fontSize: annotation.FontSize || 14,
                    fontFamily: annotation.FontFamily || 'Helvetica',
                    textAlign: annotation.TextAlign || 'center',
                    markerFillColor: annotation.MarkerFillColor || 'rgba(255, 255, 255, 1)',
                    markerBorderColor: annotation.MarkerBorderColor || 'rgba(255, 0, 0, 1)',
                    markerOpacity: annotation.MarkerOpacity || 1,
                    isPrint: annotation.IsPrint !== undefined ? annotation.IsPrint : true,
                    id: (annotation.Id || this.pdfViewer.annotationModule.createGUID() || 'redaction_id'),
                    comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
                    review: {
                        state: annotation.State,
                        stateModel: annotation.StateModel,
                        modifiedDate: annotation.ModifiedDate,
                        author: annotation.Author
                    },
                    isCommentLock: annotation.IsCommentLock || false,
                    isReadonly: annotation.IsReadonly || false,
                    annotationSettings: annotation.AnnotationSettings || this.pdfViewer.annotationModule.updateAnnotationSettings(annotation),
                    allowedInteractions: annotation.AllowedInteractions ||
                        this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation)
                };
                var annot = {
                    author: annotationObject.author,
                    modifiedDate: annotationObject.modifiedDate,
                    annotName: annotationObject.annotName,
                    pageIndex: pageIndex,
                    bounds: {
                        left: annotationObject.bounds.left,
                        top: annotationObject.bounds.top,
                        width: annotationObject.bounds.width,
                        height: annotationObject.bounds.height
                    },
                    strokeColor: annotationObject.markerBorderColor,
                    fillColor: annotationObject.fillColor,
                    opacity: annotationObject.markerOpacity,
                    thickness: 1,
                    id: annotationObject.annotName,
                    shapeAnnotationType: 'Redaction',
                    annotType: 'Redaction',
                    subject: annotationObject.subject,
                    notes: annotationObject.note,
                    annotationSelectorSettings: annotationObject.annotationSelectorSettings,
                    annotationSettings: annotationObject.annotationSettings,
                    annotationAddMode: 'Imported Annotation',
                    isLocked: annotationObject.isLocked,
                    isPrint: annotationObject.isPrint,
                    overlayText: annotationObject.overlayText,
                    isRepeat: annotationObject.isRepeat,
                    markerFillColor: annotationObject.markerFillColor,
                    markerBorderColor: annotationObject.markerBorderColor,
                    markerOpacity: annotationObject.markerOpacity,
                    fontColor: annotationObject.fontColor,
                    fontSize: annotationObject.fontSize,
                    fontFamily: annotationObject.fontFamily,
                    textAlign: annotationObject.textAlign
                };
                this.pdfViewer.add(annot);
                this.pdfViewer.annotationModule.storeAnnotations(pageIndex, annotationObject, '_annotations_redaction');
            }
        };
        Redaction.prototype.getSelector = function (type, subject) {
            return {
                resizerShape: 'Square',
                resizerSize: 8,
                resizerFillColor: '#FF4081',
                resizerBorderColor: '#FF4081',
                selectionBorderColor: '#FF4081'
            };
        };
        Redaction.prototype.saveRedactionAnnotations = function () {
            var storeObject = this.pdfViewer.annotationsCollection.get(this.pdfViewerBase.documentId + '_annotations_redaction');
            var annotations = [];
            for (var j = 0; j < this.pdfViewerBase.pageCount; j++) {
                annotations[j] = [];
            }
            if (storeObject && !this.pdfViewer.annotationSettings.skipDownload) {
                var annotationCollection = JSON.parse(JSON.stringify(storeObject));
                for (var i = 0; i < annotationCollection.length; i++) {
                    var newArray = [];
                    var pageAnnotationObject = annotationCollection[i];
                    if (pageAnnotationObject) {
                        for (var z = 0; pageAnnotationObject.annotations.length > z; z++) {
                            this.pdfViewer.annotationModule.updateModifiedDate(pageAnnotationObject.annotations[z]);
                            var bounds = pageAnnotationObject.annotations[z].bounds;
                            if (pageAnnotationObject.annotations[z].bounds.length > 1) {
                                bounds = this.combineBounds(pageAnnotationObject.annotations[z], true);
                            }
                            pageAnnotationObject.annotations[z].bounds = JSON.stringify(this.pdfViewer.annotation
                                .getBounds(bounds, pageAnnotationObject.pageIndex));
                            var markerFillColorString = pageAnnotationObject.annotations[z].markerFillColor || '';
                            pageAnnotationObject.annotations[z].markerFillColor =
                                JSON.stringify(this.getRgbCode(markerFillColorString));
                            var markerBorderColorString = pageAnnotationObject.annotations[z].markerBorderColor || '';
                            pageAnnotationObject.annotations[z].markerBorderColor =
                                JSON.stringify(this.getRgbCode(markerBorderColorString));
                            var fillColorString = pageAnnotationObject.annotations[z].fillColor || '';
                            pageAnnotationObject.annotations[z].fillColor = JSON.stringify(this.getRgbCode(fillColorString));
                            var opacity = pageAnnotationObject.annotations[z].markerOpacity > 1 ?
                                pageAnnotationObject.annotations[z].markerOpacity / 100 :
                                pageAnnotationObject.annotations[z].markerOpacity;
                            pageAnnotationObject.annotations[z].markerOpacity = opacity;
                            if (pageAnnotationObject.annotations[z].fontColor) {
                                var fontColorString = pageAnnotationObject.annotations[z].fontColor || '';
                                pageAnnotationObject.annotations[z].fontColor = JSON.stringify(this.getRgbCode(fontColorString));
                            }
                        }
                        pageAnnotationObject.annotations = pageAnnotationObject.annotations.filter(function (item) { return item; });
                        newArray = pageAnnotationObject.annotations;
                    }
                    annotations[pageAnnotationObject.pageIndex] = newArray;
                }
            }
            return JSON.stringify(annotations);
        };
        Redaction.prototype.combineBounds = function (newAnnotation, canSaved) {
            var combineBounds = [];
            var newBounds = [];
            var x = 0;
            var y = 0;
            var width = 0;
            var height = 0;
            var currentTop = 0;
            var nextTop = 0;
            var currentLeft = 0;
            var nextLeft = 0;
            var currentRotation = 0;
            var isEqual = false;
            for (var i = 0; i < newAnnotation.bounds.length; i++) {
                var newAnnotationBounds = newAnnotation.bounds[parseInt(i.toString(), 10)];
                currentTop = newAnnotationBounds.top ?
                    newAnnotationBounds.top : newAnnotationBounds.Top;
                nextTop = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ? newAnnotation.bounds[i + 1].top ?
                    newAnnotation.bounds[i + 1].top : newAnnotation.bounds[i + 1].Top : 0;
                currentLeft = newAnnotationBounds.left ?
                    newAnnotationBounds.left : newAnnotationBounds.Left;
                nextLeft = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ? newAnnotation.bounds[i + 1].left ?
                    newAnnotation.bounds[i + 1].left : newAnnotation.bounds[i + 1].Left : 0;
                var pageRotate = this.pdfViewerBase.pageSize[newAnnotation.pageNumber].rotation;
                currentRotation = !ej2_base_1.isNullOrUndefined(newAnnotationBounds.rotation) ? newAnnotationBounds.rotation : pageRotate ? pageRotate : 0;
                var rotation180Exists = (currentRotation === 0) || (currentRotation === 2) || (currentRotation === 180);
                if (rotation180Exists) {
                    var currentRight = newAnnotationBounds.right ?
                        newAnnotationBounds.right : newAnnotationBounds.Right;
                    var nextRight = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ?
                        newAnnotation.bounds[i + 1].right ? newAnnotation.bounds[i + 1].right : newAnnotation.bounds[i + 1].Right : 0;
                    isEqual = ((nextRight === 0 || Math.abs(currentLeft - nextRight) < 0.5) ||
                        (nextLeft === 0 || Math.abs(currentRight - nextLeft) < 0.5));
                }
                else {
                    var currentBottom = newAnnotationBounds.bottom ? newAnnotationBounds.bottom : newAnnotationBounds.Bottom;
                    var nextBottom = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ? newAnnotation.bounds[i + 1].bottom ?
                        newAnnotation.bounds[i + 1].bottom : newAnnotation.bounds[i + 1].Bottom : 0;
                    isEqual = (nextBottom === 0 || (Math.abs(nextBottom - currentTop) < 0.5) || Math.abs(nextTop - currentBottom) < 0.5);
                }
                if (newAnnotation.bounds.length > 1 && i < newAnnotation.bounds.length - 1 && (currentTop === nextTop ||
                    currentLeft === nextLeft) && isEqual) {
                    newBounds.push(newAnnotationBounds);
                }
                else {
                    if (i === newAnnotation.bounds.length - 1 || newAnnotation.bounds.length >= 1) {
                        newBounds.push(newAnnotationBounds);
                    }
                    if (newBounds.length >= 1) {
                        x = newBounds.reduce(function (min, rect) { return (rect.left ? rect.left : rect.Left || 0) < min ?
                            (rect.left ? rect.left : rect.Left || 0) : min; }, Infinity);
                        y = newBounds.reduce(function (min, rect) { return (rect.top ? rect.top : rect.Top || 0) < min ?
                            (rect.top ? rect.top : rect.Top || 0) : min; }, Infinity);
                        if (!this.pdfViewerBase.clientSideRendering || rotation180Exists) {
                            if (!rotation180Exists) {
                                width = newBounds[0].width ? newBounds[0].width : newBounds[0].Width;
                            }
                            else {
                                height = newBounds[0].height ? newBounds[0].height : newBounds[0].Height;
                            }
                            for (var j = 0; j < newBounds.length; j++) {
                                if (!rotation180Exists) {
                                    height += newBounds[parseInt(j.toString(), 10)].height ?
                                        newBounds[parseInt(j.toString(), 10)].height : newBounds[parseInt(j.toString(), 10)].Height;
                                }
                                else if ((!isNaN(newBounds[parseInt(j.toString(), 10)].width) &&
                                    newBounds[parseInt(j.toString(), 10)].width > 0) || (!isNaN(newBounds[parseInt(j.toString(), 10)].Width) &&
                                    newBounds[parseInt(j.toString(), 10)].Width > 0)) {
                                    width += newBounds[parseInt(j.toString(), 10)].width ?
                                        newBounds[parseInt(j.toString(), 10)].width : newBounds[parseInt(j.toString(), 10)].Width;
                                }
                            }
                        }
                        else {
                            width += newBounds[0].width ? newBounds[0].width : newBounds[0].Width;
                            height = newBounds.reduce(function (sum, rect) { return sum + (rect.height ? rect.height : rect.Height || 0); }, 0);
                        }
                        if (width !== 0 && height !== 0) {
                            var zoomFactor = this.pdfViewerBase.getZoomFactor();
                            var factor = canSaved ? 1 : zoomFactor;
                            var bounds = {
                                x: this.getMagnifiedValue(x - 0.5, factor),
                                y: this.getMagnifiedValue(y - 0.5, factor),
                                width: this.getMagnifiedValue(width + 0.5, factor),
                                height: this.getMagnifiedValue(height + 0.5, factor),
                                left: this.getMagnifiedValue(x - 0.5, factor),
                                top: this.getMagnifiedValue(y - 0.5, factor)
                            };
                            combineBounds.push(bounds);
                        }
                        newBounds = [];
                        width = 0;
                        height = 0;
                    }
                }
            }
            return combineBounds;
        };
        Redaction.prototype.deleteTextRedactAnnotation = function () {
            var textMarkUpModule = this.pdfViewer.annotationModule.textMarkupAnnotationModule;
            if (textMarkUpModule.currentTextMarkupAnnotation) {
                var isLock = false;
                if (textMarkUpModule.currentTextMarkupAnnotation.annotationSettings) {
                    isLock = textMarkUpModule.currentTextMarkupAnnotation.annotationSettings.isLock;
                    if (this.pdfViewer.annotationModule.checkAllowedInteractions('Delete', textMarkUpModule.currentTextMarkupAnnotation)) {
                        isLock = false;
                    }
                }
                if (!isLock) {
                    var deletedAnnotation = null;
                    textMarkUpModule.showHideDropletDiv(true);
                    var annotation = textMarkUpModule.currentTextMarkupAnnotation;
                    var pageAnnotations = this.getAnnotations(textMarkUpModule.selectTextMarkupCurrentPage, null);
                    if (pageAnnotations) {
                        for (var i = 0; i < pageAnnotations.length; i++) {
                            if (textMarkUpModule.currentTextMarkupAnnotation.annotName ===
                                pageAnnotations[parseInt(i.toString(), 10)].annotName) {
                                deletedAnnotation = pageAnnotations.splice(i, 1)[0];
                                this.pdfViewer.annotationModule.addAction(textMarkUpModule.selectTextMarkupCurrentPage, i, deletedAnnotation, 'Text Markup Deleted', null);
                                textMarkUpModule.currentAnnotationIndex = i;
                                this.pdfViewer.annotation.stickyNotesAnnotationModule.findPosition(deletedAnnotation, 'textMarkup');
                                var removeDiv = document.getElementById(deletedAnnotation.annotName);
                                if (removeDiv) {
                                    if (removeDiv.parentElement.childElementCount === 1) {
                                        this.pdfViewer.annotationModule.stickyNotesAnnotationModule.updateAccordionContainer(removeDiv);
                                    }
                                    else {
                                        removeDiv.remove();
                                    }
                                }
                            }
                        }
                        this.pdfViewer.annotationModule.updateAnnotationCollection(textMarkUpModule.currentTextMarkupAnnotation);
                        this.manageAnnotations(pageAnnotations, textMarkUpModule.selectTextMarkupCurrentPage);
                        this.pdfViewer.annotationModule.updateImportAnnotationCollection(textMarkUpModule.currentTextMarkupAnnotation, textMarkUpModule.currentTextMarkupAnnotation.pageNumber, 'Redaction');
                        var annotationId = textMarkUpModule.currentTextMarkupAnnotation.annotName;
                        var annotationBounds = textMarkUpModule.currentTextMarkupAnnotation.bounds;
                        textMarkUpModule.currentTextMarkupAnnotation = null;
                        this.pdfViewer.annotationModule.renderAnnotations(textMarkUpModule.selectTextMarkupCurrentPage, null, null, null);
                        this.pdfViewerBase.updateDocumentEditedProperty(true);
                        textMarkUpModule.currentAnnotationIndex = null;
                        textMarkUpModule.selectTextMarkupCurrentPage = null;
                        if (ej2_base_1.Browser.isDevice && !this.pdfViewer.enableDesktopMode) {
                            this.pdfViewer.toolbarModule.annotationToolbarModule.hideMobileAnnotationToolbar();
                            this.pdfViewer.toolbarModule.showToolbar(true);
                        }
                    }
                }
            }
        };
        Redaction.prototype.onTextRedactMouseMove = function (event) {
            var eventTarget = event.target;
            var pageIndex = parseInt(eventTarget.id.split('_text_')[1], 10) || parseInt(eventTarget.id.split('_textLayer_')[1], 10) || parseInt(eventTarget.id.split('_annotationCanvas_')[1], 10);
            if (event.target && (eventTarget.id.indexOf('_text') > -1 || eventTarget.id.indexOf('_annotationCanvas') > -1 || eventTarget.classList.contains('e-pv-hyperlink')) && this.pdfViewer.annotation) {
                pageIndex = this.pdfViewer.annotation.getEventPageNumber(event);
                var canvas = this.pdfViewerBase.getElement('_annotationCanvas_' + pageIndex);
                var currentAnnot = this.getCurrentMarkupAnnotation(event.clientX, event.clientY, pageIndex, canvas);
                if (currentAnnot) {
                    var annotObject = void 0;
                    var annotationKeys = Object.keys(this.pdfViewer.nameTable);
                    for (var i = 0; i < annotationKeys.length; i++) {
                        annotObject = this.pdfViewer.nameTable[annotationKeys[parseInt(i.toString(), 10)]];
                        if (!ej2_base_1.isNullOrUndefined(annotObject) && currentAnnot.annotationId === annotObject.annotName) {
                            annotObject = this.pdfViewer.nameTable[annotationKeys[parseInt(i.toString(), 10)]];
                            break;
                        }
                    }
                    this.handleRedactionHover(annotObject, annotObject.pageNumber, currentAnnot);
                    this.pdfViewerBase.isRedactionMousedOver = true;
                }
                else {
                    this.resetRedactionHover();
                    this.pdfViewerBase.isRedactionMousedOver = false;
                }
            }
        };
        Redaction.prototype.onTextRedactAnnotationTouchEnd = function (event) {
            var pageNumber = this.pdfViewer.annotationModule.getEventPageNumber(event);
            if (!ej2_base_1.isNullOrUndefined(pageNumber) && !isNaN(pageNumber)) {
                this.pdfViewer.annotationModule.textMarkupAnnotationModule.clearCurrentAnnotationSelection(pageNumber);
                var touchCanvas = this.pdfViewerBase.getElement('_annotationCanvas_' + pageNumber);
                this.clearCurrentSelectedAnnotation();
                var currentAnnot = this.getCurrentMarkupAnnotation(event.touches[0].clientX, event.touches[0].clientY, pageNumber, touchCanvas);
                if (currentAnnot) {
                    this.onTextRedactTouchEnd(currentAnnot, touchCanvas, event, pageNumber);
                }
            }
            else if (ej2_base_1.Browser.isDevice && !this.pdfViewer.enableDesktopMode) {
                this.clearAnnotationSelection(pageNumber);
            }
            else {
                this.pdfViewer.annotationModule.textMarkupAnnotationModule.clearCurrentAnnotation();
                this.pdfViewer.annotationModule.textMarkupAnnotationModule.clearCurrentAnnotationSelection(pageNumber);
            }
        };
        Redaction.prototype.onTextRedactTouchEnd = function (currentAnnot, touchCanvas, event, pageNumber) {
            var isLock = false;
            if (currentAnnot.annotationSettings && currentAnnot.annotationSettings.isLock) {
                isLock = currentAnnot.annotationSettings.isLock;
            }
            if (!isLock) {
                this.pdfViewer.annotationModule.textMarkupAnnotationModule.selectAnnotation(currentAnnot, touchCanvas, pageNumber, event);
                this.pdfViewer.annotationModule.textMarkupAnnotationModule.selectTextMarkupCurrentPage = pageNumber;
                var accordionExpand = document.getElementById(this.pdfViewer.element.id + '_accordionContainer' + (pageNumber + 1));
                if (accordionExpand) {
                    accordionExpand.ej2_instances[0].expandItem(true);
                }
                var comments = document.getElementById(currentAnnot.annotName);
                if (comments) {
                    if (!ej2_base_1.Browser.isDevice) {
                        comments.firstChild.click();
                    }
                }
            }
        };
        Redaction.prototype.clearCurrentSelectedAnnotation = function () {
            this.clearAnnotationSelection(this.pdfViewer.currentPageNumber - 1);
        };
        Redaction.prototype.clearAnnotationSelection = function (pageNumber) {
            var _this = this;
            var canvasIds = [
                '_annotationCanvas_' + pageNumber,
                '_blendAnnotationsIntoCanvas_' + pageNumber
            ];
            canvasIds.forEach(function (id) {
                var canvas = _this.pdfViewerBase.getElement(id);
                if (canvas) {
                    var context = canvas.getContext('2d');
                    context.setLineDash([]);
                    _this.pdfViewer.annotationModule.renderAnnotations(pageNumber, null, null, null);
                }
            });
        };
        Redaction.prototype.onTextRedactAnnotationMouseUp = function (event) {
            var pageNumber = this.pdfViewer.annotationModule.getEventPageNumber(event);
            if (!ej2_base_1.isNullOrUndefined(pageNumber) && !isNaN(pageNumber)) {
                var canvas = this.pdfViewerBase.getElement('_annotationCanvas_' + pageNumber);
                this.clearCurrentSelectedAnnotation();
                var currentAnnot = this.getCurrentMarkupAnnotation(event.clientX, event.clientY, pageNumber, canvas);
                if (currentAnnot && !window.getSelection().toString()) {
                    this.onTextRedactMouseUp(currentAnnot, event, canvas, pageNumber);
                }
            }
        };
        Redaction.prototype.getCurrentMarkupAnnotation = function (clientX, clientY, pageNumber, canvas) {
            var currentTextRedactAnnotations = [];
            if (canvas) {
                var canvasParentPosition = canvas.parentElement.getBoundingClientRect();
                if (canvas.clientWidth !== canvas.parentElement.clientWidth) {
                    canvasParentPosition = canvas.getBoundingClientRect();
                }
                var leftClickPosition = clientX - canvasParentPosition.left;
                var topClickPosition = clientY - canvasParentPosition.top;
                var annotationList = this.getAnnotations(pageNumber, null);
                var isAnnotationGot = false;
                if (annotationList) {
                    for (var i = 0; i < annotationList.length; i++) {
                        var annotation = annotationList[parseInt(i.toString(), 10)];
                        for (var j = 0; j < annotation.bounds.length; j++) {
                            var bound = annotation.bounds[parseInt(j.toString(), 10)];
                            var left = bound.left ? bound.left : bound.Left;
                            var top_1 = bound.top ? bound.top : bound.Top;
                            var width = bound.width ? bound.width : bound.Width;
                            var height = bound.height ? bound.height : bound.Height;
                            if (leftClickPosition >= this.getMagnifiedValue(left, this.pdfViewerBase.getZoomFactor()) &&
                                leftClickPosition <= this.getMagnifiedValue(left + width, this.pdfViewerBase.getZoomFactor()) &&
                                topClickPosition >= this.getMagnifiedValue(top_1, this.pdfViewerBase.getZoomFactor()) &&
                                topClickPosition <= this.getMagnifiedValue(top_1 + height, this.pdfViewerBase.getZoomFactor())) {
                                currentTextRedactAnnotations.push(annotation);
                                isAnnotationGot = true;
                            }
                            else {
                                if (isAnnotationGot) {
                                    isAnnotationGot = false;
                                    break;
                                }
                            }
                        }
                    }
                }
                var currentAnnot = null;
                if (currentTextRedactAnnotations.length > 1) {
                    currentAnnot = this.compareCurrentAnnotations(currentTextRedactAnnotations);
                }
                else if (currentTextRedactAnnotations.length === 1) {
                    currentAnnot = currentTextRedactAnnotations[0];
                }
                return currentAnnot;
            }
            else {
                return null;
            }
        };
        Redaction.prototype.compareCurrentAnnotations = function (annotations) {
            var previousX;
            var currentAnnotation = null;
            for (var i = 0; i < annotations.length; i++) {
                if (i === annotations.length - 1) {
                    break;
                }
                var firstAnnotBounds = annotations[parseInt(i.toString(), 10)].bounds;
                var firstXposition = firstAnnotBounds[0].left ? firstAnnotBounds[0].left : firstAnnotBounds[0].Left;
                var firstYposition = firstAnnotBounds[0].top ? firstAnnotBounds[0].top : firstAnnotBounds[0].Top;
                var secondAnnotBounds = annotations[i + 1].bounds;
                var secondXposition = secondAnnotBounds[0].left ? secondAnnotBounds[0].left : secondAnnotBounds[0].Left;
                var secondYposition = secondAnnotBounds[0].top ? secondAnnotBounds[0].top : secondAnnotBounds[0].Top;
                if ((firstXposition < secondXposition) || (firstYposition < secondYposition)) {
                    previousX = secondXposition;
                    currentAnnotation = annotations[i + 1];
                }
                else {
                    previousX = firstXposition;
                    currentAnnotation = annotations[parseInt(i.toString(), 10)];
                }
                if (previousX && (i === (annotations.length - 2))) {
                    if ((previousX === firstXposition) && (previousX === secondXposition)) {
                        previousX = secondXposition;
                        currentAnnotation = annotations[i + 1];
                    }
                }
            }
            return currentAnnotation;
        };
        Redaction.prototype.onTextRedactMouseUp = function (currentAnnot, event, canvas, pageNumber) {
            var isLock = false;
            var isSelection = false;
            if (currentAnnot.annotationSettings && currentAnnot.annotationSettings.isLock) {
                isLock = currentAnnot.annotationSettings.isLock;
                if (isLock && this.pdfViewer.annotationModule.checkAllowedInteractions('Select', currentAnnot)) {
                    isLock = false;
                    if (this.pdfViewer.annotationModule.checkAllowedInteractions('PropertyChange', currentAnnot)) {
                        isSelection = false;
                    }
                    else {
                        isSelection = true;
                    }
                }
            }
            if (!isLock) {
                var canvasParentPosition = canvas.parentElement.getBoundingClientRect();
                var leftClickPosition = event.clientX - canvasParentPosition.left;
                var topClickPosition = event.clientY - canvasParentPosition.top;
                this.pdfViewer.annotation.textMarkupAnnotationModule.annotationClickPosition = { x: leftClickPosition, y: topClickPosition };
                this.pdfViewer.annotation.textMarkupAnnotationModule.selectAnnotation(currentAnnot, canvas, pageNumber, event);
                this.pdfViewer.toolbarModule.redactionToolbarModule.showHideDeleteIcon(true);
                var commentPanelDiv = document.getElementById(this.pdfViewer.element.id + '_commantPanel');
                if (commentPanelDiv && commentPanelDiv.style.display === 'block') {
                    var accordionExpand = document.getElementById(this.pdfViewer.element.id + '_accordionContainer' + (pageNumber + 1));
                    if (accordionExpand) {
                        accordionExpand.ej2_instances[0].expandItem(true);
                    }
                    var comments = document.getElementById(currentAnnot.annotName);
                    if (comments) {
                        comments.firstChild.click();
                    }
                }
                if (!ej2_base_1.isBlazor()) {
                    if (this.pdfViewer.toolbarModule && this.pdfViewer.toolbarModule.redactionToolbarModule) {
                        this.pdfViewer.toolbarModule.redactionToolbarModule.isToolbarHidden = true;
                        this.pdfViewer.toolbarModule.redactionToolbarModule.
                            showRedactionToolbar(this.pdfViewer.toolbarModule.redactionItem);
                    }
                    if (currentAnnot) {
                        var annotObject = void 0;
                        var annotationKeys = Object.keys(this.pdfViewer.nameTable);
                        for (var i = 0; i < annotationKeys.length; i++) {
                            annotObject = this.pdfViewer.nameTable[annotationKeys[parseInt(i.toString(), 10)]];
                            if (!ej2_base_1.isNullOrUndefined(annotObject) && currentAnnot.annotationId === annotObject.annotName) {
                                annotObject = this.pdfViewer.nameTable[annotationKeys[parseInt(i.toString(), 10)]];
                                break;
                            }
                        }
                    }
                }
            }
        };
        Redaction.prototype.renderTextRedactAnnotationsInPage = function (textRedactAnnotations, pageNumber, isImportTextMarkup, isAnnotOrderAction) {
            var canvasId = '_annotationCanvas_';
            var canvas = this.pdfViewerBase.getAnnotationCanvas(canvasId, pageNumber);
            if (isImportTextMarkup) {
                this.renderTextRedactAnnotations(null, pageNumber, canvas, this.pdfViewerBase.getZoomFactor());
                this.renderTextRedactAnnotations(textRedactAnnotations, pageNumber, canvas, this.pdfViewerBase.getZoomFactor(), true);
                if (textRedactAnnotations && this.pdfViewer.toolbarModule && this.pdfViewer.toolbarModule.redactionToolbarModule) {
                    this.pdfViewer.toolbarModule.redactionToolbarModule.showHideRedactIcon(true);
                }
            }
            else {
                this.renderTextRedactAnnotations(textRedactAnnotations, pageNumber, canvas, this.pdfViewerBase.getZoomFactor(), null, isAnnotOrderAction);
            }
        };
        Redaction.prototype.renderTextRedactAnnotations = function (textRedactAnnotations, pageNumber, canvas, factor, isImportAction, isAnnotOrderAction) {
            if (canvas) {
                var context = canvas.getContext('2d');
                context.setTransform(1, 0, 0, 1, 0, 0);
                context.setLineDash([]);
                var annotations_1;
                if (!isImportAction && !isAnnotOrderAction) {
                    annotations_1 = this.getAnnotations(pageNumber, textRedactAnnotations);
                }
                else {
                    annotations_1 = textRedactAnnotations;
                }
                if (textRedactAnnotations) {
                    textRedactAnnotations.forEach(function (textMarkupAnnotation) {
                        var exists = annotations_1.some(function (existingAnnotation) {
                            return existingAnnotation.annotName === textMarkupAnnotation.AnnotName;
                        });
                        if (!exists) {
                            annotations_1.push(textMarkupAnnotation);
                        }
                    });
                }
                if (annotations_1) {
                    var distinctAnnotations = [];
                    for (var i = 0; i < annotations_1.length; i++) {
                        var duplicateFound = false;
                        for (var j = 0; j < distinctAnnotations.length; j++) {
                            if (annotations_1[parseInt(i.toString(), 10)].AnnotName ===
                                distinctAnnotations[parseInt(j.toString(), 10)].AnnotName &&
                                annotations_1[parseInt(i.toString(), 10)].annotName === distinctAnnotations[parseInt(j.toString(), 10)].annotName) {
                                duplicateFound = true;
                                break;
                            }
                        }
                        if (!duplicateFound) {
                            distinctAnnotations.push(annotations_1[parseInt(i.toString(), 10)]);
                        }
                    }
                    annotations_1 = distinctAnnotations;
                }
                if (annotations_1) {
                    for (var i = 0; i < annotations_1.length; i++) {
                        var annotation = annotations_1[parseInt(i.toString(), 10)];
                        if (annotation.annotName === this.hoveredRedactionAnnotName) {
                            if (!this.isRedactionHovered && this.isAnnotationHoverd) {
                                var fillColor = index_1.updateColorWithOpacity(annotation.fillColor, 1);
                                annotation.markerFillColor = fillColor;
                                annotation.markerBorderColor = fillColor;
                                annotation.markerOpacity = 1;
                                this.isAnnotationHoverd = false;
                            }
                            else {
                                if (this.orginalFillColor) {
                                    var fillColor = index_1.updateColorWithOpacity(this.orginalFillColor, annotation.markerOpacity);
                                    annotation.markerFillColor = fillColor;
                                    annotation.markerBorderColor = this.orginalBorderColor;
                                    annotation.markerOpacity = this.orginalOpacity;
                                    if (annotation.overlayText) {
                                        this.pdfViewer.annotation.redactionOverlayTextModule.removeRedactionOverlayText(annotation);
                                    }
                                }
                            }
                        }
                        var annotationObject = null;
                        var isAnnotationRotated = void 0;
                        if (annotation.RedactionType === 'textRedact' || annotation.TextMarkupAnnotationType) {
                            if (isImportAction) {
                                if (this.pdfViewerBase.isJsonImported) {
                                    var newArray = [];
                                    for (var i_1 = 0; i_1 < annotation.Bounds.length; i_1++) {
                                        annotation.Bounds[parseInt(i_1.toString(), 10)] = this.pdfViewerBase.
                                            importJsonForRotatedDocuments(annotation.Rotate, pageNumber, annotation.Bounds[parseInt(i_1.toString(), 10)], annotation.AnnotationRotation);
                                        annotation.Bounds[parseInt(i_1.toString(), 10)].left = annotation.Bounds[parseInt(i_1.toString(), 10)].X;
                                        annotation.Bounds[parseInt(i_1.toString(), 10)].top = annotation.Bounds[parseInt(i_1.toString(), 10)].Y;
                                        newArray.push(annotation.Bounds[parseInt(i_1.toString(), 10)]);
                                    }
                                    annotation.Bounds = newArray;
                                    isAnnotationRotated = this.pdfViewerBase.isPageRotated;
                                }
                            }
                            annotation.annotationAddMode = this.pdfViewer.annotationModule.
                                findAnnotationMode(annotation, pageNumber, annotation.AnnotType);
                            annotation.allowedInteractions = annotation.AllowedInteractions ? annotation.AllowedInteractions :
                                this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
                            annotation.AnnotationSettings = annotation.AnnotationSettings ? annotation.AnnotationSettings :
                                this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
                            if (annotation.IsLocked) {
                                annotation.AnnotationSettings.isLock = annotation.IsLocked;
                            }
                            annotationObject = {
                                shapeAnnotationType: 'Redaction', annotType: 'TextRedaction', fillColor: annotation.FillColor,
                                allowedInteractions: annotation.allowedInteractions, markerOpacity: annotation.MarkerOpacity,
                                bounds: annotation.Bounds, author: annotation.Author, subject: annotation.Subject,
                                modifiedDate: annotation.ModifiedDate, note: annotation.Note, annotationId: annotation.AnnotName,
                                annotName: annotation.AnnotName, id: annotation.AnnotName, comments: this.pdfViewer.annotationModule.getAnnotationComments(annotation.Comments, annotation, annotation.Author),
                                review: { state: annotation.State, stateModel: annotation.StateModel,
                                    modifiedDate: annotation.ModifiedDate, author: annotation.Author }, pageNumber: pageNumber,
                                pageIndex: pageNumber, redactionContent: annotation.TextMarkupContent,
                                annotationSelectorSettings: this.getSettings(annotation),
                                customData: this.pdfViewer.annotation.getCustomData(annotation), annotationAddMode: annotation.annotationAddMode, annotationSettings: annotation.AnnotationSettings,
                                isLocked: annotation.IsLocked, isPrint: annotation.IsPrint, isCommentLock: annotation.IsCommentLock,
                                rotateAngle: annotation.AnnotationRotation,
                                markerBorderColor: annotation.MarkerBorderColor,
                                markerFillColor: annotation.MarkerFillColor,
                                fontFamily: annotation.FontFamily,
                                fontSize: annotation.FontSize,
                                textAlign: annotation.TextAlignment,
                                fontColor: annotation.FontColor,
                                isRepeat: annotation.IsRepeat,
                                overlayText: annotation.OverlayText
                            };
                            if (ej2_base_1.isNullOrUndefined(annotation.TextMarkupContent) && ej2_base_1.isNullOrUndefined(annotation.textMarkupContent)) {
                                var markedBounds = annotation.Bounds;
                                var storedData = this.pdfViewerBase.getStoredData(pageNumber, true);
                                if (ej2_base_1.isNullOrUndefined(storedData)) {
                                    this.pdfViewerBase.requestForTextExtraction(pageNumber, annotationObject);
                                }
                                else {
                                    var pageCharText = storedData.pageText.split('');
                                    var characterBounds = this.pdfViewerBase.textLayer.
                                        characterBound[parseInt(pageNumber.toString(), 10)];
                                    var textMarkupContent = this.pdfViewerBase.
                                        textMarkUpContent(markedBounds, pageCharText, characterBounds);
                                    annotationObject.redactionContent = textMarkupContent;
                                }
                            }
                            if (annotation.annotName !== this.hoveredRedactionAnnotName) {
                                this.pdfViewer.add(annotationObject);
                                this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotationObject, '_annotations_redaction');
                            }
                            if (this.isAddAnnotationProgramatically) {
                                var settings = {
                                    shapeAnnotationType: annotation.shapeAnnotationType,
                                    markerBorderColor: annotation.markerBorderColor,
                                    markerFillColor: annotation.markerFillColor,
                                    opacity: annotation.markerOpacity,
                                    overlayText: annotation.overlayText || '',
                                    fontColor: annotation.fontColor,
                                    fontSize: annotation.fontSize || 14,
                                    fontFamily: annotation.fontFamily,
                                    textAlign: annotation.textAlign,
                                    author: annotation.author,
                                    subject: annotation.subject,
                                    modifiedDate: annotation.modifiedDate
                                };
                                this.pdfViewer.fireAnnotationAdd(annotationObject.pageNumber, annotationObject.annotName, 'Redaction', annotationObject.bounds, settings);
                            }
                        }
                        if (annotation.RedactionType !== 'redaction') {
                            annotationObject = annotationObject ? annotationObject : annotation;
                        }
                        this.drawTextRedactAnnotation(annotationObject, factor, pageNumber, context);
                    }
                }
            }
        };
        Redaction.prototype.getAddedAnnotation = function (type, color, opacity, bounds, author, subject, predefinedDate, note, isCommentLock, rect, pageNumber, textContent, startIndex, endIndex, isMultiSelect, allowedInteractions, annotationRotate) {
            var modifiedDate = predefinedDate ? predefinedDate : this.pdfViewer.annotation.
                stickyNotesAnnotationModule.getDateAndTime();
            var annotationName = this.pdfViewer.annotation.createGUID();
            var commentsDivid = this.pdfViewer.annotation.stickyNotesAnnotationModule.addComments('textMarkup', pageNumber + 1, type);
            if (commentsDivid) {
                document.getElementById(commentsDivid).id = annotationName;
            }
            var annotationSettings = this.pdfViewer.annotationSettings;
            var isPrint = true;
            var annotation = {
                shapeAnnotationType: type, fillColor: this.pdfViewer.redactionSettings.fillColor, markerOpacity: opacity,
                bounds: bounds, author: author, annotType: 'TextRedaction',
                allowedInteractions: allowedInteractions, subject: subject, modifiedDate: modifiedDate, note: note,
                annotName: annotationName, id: annotationName, comments: [], review: { state: '', stateModel: '', author: author, modifiedDate: modifiedDate },
                pageNumber: pageNumber, pageIndex: pageNumber, redactionContent: textContent, annotationId: annotationName,
                annotationSelectorSettings: this.pdfViewer.redactionSettings.annotationSelectorSettings,
                customData: this.pdfViewer.annotation.getTextMarkupData(subject), annotationAddMode: 'TextRedaction',
                annotationSettings: annotationSettings, isPrint: isPrint, isCommentLock: isCommentLock,
                rotateAngle: annotationRotate.toString(), markerBorderColor: this.pdfViewer.redactionSettings.markerBorderColor,
                markerFillColor: color, fontFamily: this.pdfViewer.redactionSettings.fontFamily,
                fontSize: this.pdfViewer.redactionSettings.fontSize,
                textAlign: this.pdfViewer.redactionSettings.textAlignment,
                fontColor: this.pdfViewer.redactionSettings.fontColor,
                isRepeat: this.pdfViewer.redactionSettings.isRepeat,
                overlayText: this.pdfViewer.redactionSettings.overlayText,
                isLocked: false
            };
            annotation.annotationSettings = this.pdfViewer.annotationModule.updateAnnotationSettings(annotation);
            var isSkip = false;
            this.pdfViewer.add(annotation);
            var storedIndex = this.pdfViewer.annotationModule.storeAnnotations(pageNumber, annotation, '_annotations_redaction');
            this.pdfViewer.annotationModule.addAction(pageNumber, storedIndex, annotation, 'Addition', null);
            return annotation;
        };
        Redaction.prototype.getPageContext = function (pageNumber, canvasId) {
            var canvas;
            if (canvasId === '_annotationCanvas_') {
                canvas = this.pdfViewerBase.getAnnotationCanvas(canvasId, pageNumber);
            }
            else {
                canvas = this.pdfViewerBase.getElement(canvasId + pageNumber);
            }
            var context = null;
            if (canvas) {
                context = canvas.getContext('2d');
            }
            return context;
        };
        Redaction.prototype.getMagnifiedValue = function (value, factor) {
            return value * factor;
        };
        Redaction.prototype.drawTextRedactAnnotation = function (newAnnotation, zoomFactor, pageNumber, newcanvas) {
            if (newAnnotation && newAnnotation.bounds && !ej2_base_1.isNullOrUndefined(newAnnotation.bounds.length)) {
                var newBounds = [];
                var x = 0;
                var y = 0;
                var width = 0;
                var height = 0;
                var currentTop = 0;
                var nextTop = 0;
                var currentLeft = 0;
                var nextLeft = 0;
                var currentRotation = 0;
                var isEqual = false;
                for (var i = 0; i < newAnnotation.bounds.length; i++) {
                    var newAnnotationBounds = newAnnotation.bounds[parseInt(i.toString(), 10)];
                    currentTop = newAnnotationBounds.top ?
                        newAnnotationBounds.top : newAnnotationBounds.Top;
                    nextTop = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ? newAnnotation.bounds[i + 1].top ?
                        newAnnotation.bounds[i + 1].top : newAnnotation.bounds[i + 1].Top : 0;
                    currentLeft = newAnnotationBounds.left ?
                        newAnnotationBounds.left : newAnnotationBounds.Left;
                    nextLeft = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ? newAnnotation.bounds[i + 1].left ?
                        newAnnotation.bounds[i + 1].left : newAnnotation.bounds[i + 1].Left : 0;
                    var pageRotate = this.pdfViewerBase.pageSize[newAnnotation.pageNumber].rotation;
                    currentRotation = !ej2_base_1.isNullOrUndefined(newAnnotationBounds.rotation) ?
                        newAnnotationBounds.rotation : pageRotate ? pageRotate : 0;
                    var rotation180Exists = (currentRotation === 0) || (currentRotation === 2) || (currentRotation === 180);
                    if (rotation180Exists) {
                        var currentRight = newAnnotationBounds.right ?
                            newAnnotationBounds.right : newAnnotationBounds.Right;
                        var nextRight = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ?
                            newAnnotation.bounds[i + 1].right ? newAnnotation.bounds[i + 1].right : newAnnotation.bounds[i + 1].Right : 0;
                        isEqual = ((nextRight === 0 || Math.abs(currentLeft - nextRight) < 0.5) ||
                            (nextLeft === 0 || Math.abs(currentRight - nextLeft) < 0.5));
                    }
                    else {
                        var currentBottom = newAnnotationBounds.bottom ? newAnnotationBounds.bottom : newAnnotationBounds.Bottom;
                        var nextBottom = !ej2_base_1.isNullOrUndefined(newAnnotation.bounds[i + 1]) ? newAnnotation.bounds[i + 1].bottom ?
                            newAnnotation.bounds[i + 1].bottom : newAnnotation.bounds[i + 1].Bottom : 0;
                        isEqual = (nextBottom === 0 || (Math.abs(nextBottom - currentTop) < 0.5) || Math.abs(nextTop - currentBottom) < 0.5);
                    }
                    if (newAnnotation.bounds.length > 1 && i < newAnnotation.bounds.length - 1 && (currentTop === nextTop ||
                        currentLeft === nextLeft) && isEqual) {
                        newBounds.push(newAnnotationBounds);
                    }
                    else {
                        if (i === newAnnotation.bounds.length - 1 || newAnnotation.bounds.length >= 1) {
                            newBounds.push(newAnnotationBounds);
                        }
                        if (newBounds.length >= 1) {
                            x = newBounds.reduce(function (min, rect) { return (rect.left ? rect.left : rect.Left || 0) < min ?
                                (rect.left ? rect.left : rect.Left || 0) : min; }, Infinity);
                            y = newBounds.reduce(function (min, rect) { return (rect.top ? rect.top : rect.Top || 0) < min ?
                                (rect.top ? rect.top : rect.Top || 0) : min; }, Infinity);
                            if (!this.pdfViewerBase.clientSideRendering || rotation180Exists) {
                                if (!rotation180Exists) {
                                    width = newBounds[0].width ? newBounds[0].width : newBounds[0].Width;
                                }
                                else {
                                    height = newBounds[0].height ? newBounds[0].height : newBounds[0].Height;
                                }
                                for (var j = 0; j < newBounds.length; j++) {
                                    if (!rotation180Exists) {
                                        height += newBounds[parseInt(j.toString(), 10)].height ?
                                            newBounds[parseInt(j.toString(), 10)].height : newBounds[parseInt(j.toString(), 10)].Height;
                                    }
                                    else if ((!isNaN(newBounds[parseInt(j.toString(), 10)].width) &&
                                        newBounds[parseInt(j.toString(), 10)].width > 0) ||
                                        (!isNaN(newBounds[parseInt(j.toString(), 10)].Width) &&
                                            newBounds[parseInt(j.toString(), 10)].Width > 0)) {
                                        width += newBounds[parseInt(j.toString(), 10)].width ?
                                            newBounds[parseInt(j.toString(), 10)].width : newBounds[parseInt(j.toString(), 10)].Width;
                                    }
                                }
                            }
                            else {
                                width += newBounds[0].width ? newBounds[0].width : newBounds[0].Width;
                                height = newBounds.reduce(function (sum, rect) { return sum + (rect.height ? rect.height : rect.Height || 0); }, 0);
                            }
                            if (width !== 0 && height !== 0) {
                                this.renderTextRedactAnnotation(newcanvas, this.getMagnifiedValue(x - 0.5, zoomFactor), this.getMagnifiedValue(y - 0.5, zoomFactor), this.getMagnifiedValue(width + 0.5, zoomFactor), this.getMagnifiedValue(height + 0.5, zoomFactor), newAnnotation.markerOpacity, newAnnotation.markerFillColor, newAnnotation.markerBorderColor, zoomFactor, pageNumber);
                            }
                            newBounds = [];
                            width = 0;
                            height = 0;
                        }
                    }
                }
            }
        };
        Redaction.prototype.renderTextRedactAnnotation = function (context, x, y, width, height, opacity, color, borderColor, zoomFactor, pageIndex) {
            var ratio;
            if (context.canvas.id === this.pdfViewer.element.id + '_print_annotation_layer_' + pageIndex) {
                ratio = this.pdfViewerBase.getZoomRatio(zoomFactor);
            }
            else {
                ratio = this.pdfViewerBase.getZoomRatio();
            }
            if (context) {
                context.beginPath();
                context.rect(x * ratio, y * ratio, width * ratio, height * ratio);
                context.closePath();
                context.globalAlpha = opacity;
                context.fillStyle = color;
                context.strokeStyle = borderColor;
                context.lineWidth = 1;
                context.msFillRule = 'nonzero';
                context.fill();
                context.stroke();
                context.save();
            }
        };
        Redaction.prototype.drawTextRedact = function (type, bounds, pageNumber, rect, factor, textContent, startIndex, endIndex, isMultiSelect, targetElement) {
            var annotation = null;
            var author = 'Guest';
            var subject;
            var context = this.getPageContext(pageNumber, '_annotationCanvas_');
            var modifiedDate = this.pdfViewer.annotation.stickyNotesAnnotationModule.getDateAndTime();
            var allowedInteractions;
            var pageDetails = this.pdfViewerBase.pageSize[parseInt(pageNumber.toString(), 10)];
            var annotationRotate = 0;
            var pageRotation = this.pdfViewerBase.getAngle(pageDetails.rotation);
            if (ej2_base_1.isNullOrUndefined(context)) {
                var pageDiv = document.getElementById(this.pdfViewer.element.id + '_pageDiv_' + pageNumber);
                if (pageDiv && pageDetails && pageDetails.width && pageDetails.height) {
                    var canvas = this.pdfViewer.annotationModule.createBlendAnnotationsIntoCanvas(pageDiv, pageDetails.width, pageDetails.height, pageNumber);
                    context = canvas.getContext('2d');
                }
            }
            if (context) {
                context.setLineDash([]);
                subject = (this.pdfViewer.highlightSettings.subject !== '' && this.pdfViewer.highlightSettings.subject) ? this.pdfViewer.highlightSettings.subject : this.pdfViewer.annotationSettings.subject ? this.pdfViewer.annotationSettings.subject : 'Highlight';
                author = (this.pdfViewer.highlightSettings.author !== 'Guest' && this.pdfViewer.highlightSettings.author) ? this.pdfViewer.highlightSettings.author : this.pdfViewer.annotationSettings.author ? this.pdfViewer.annotationSettings.author : 'Guest';
                allowedInteractions = this.pdfViewer.highlightSettings.allowedInteractions ? this.pdfViewer.highlightSettings.allowedInteractions : ['None'];
                var opacity = this.pdfViewer.redactionSettings.markerOpacity ? (this.pdfViewer.redactionSettings.markerOpacity > 1 ?
                    (this.pdfViewer.redactionSettings.markerOpacity / 100) : this.pdfViewer.redactionSettings.markerOpacity) : 1;
                annotation = this.getAddedAnnotation(type, this.pdfViewer.redactionSettings.markerFillColor, opacity, bounds, author, subject, modifiedDate, '', false, rect, pageNumber, textContent, startIndex, endIndex, isMultiSelect, allowedInteractions, annotationRotate);
                if (annotation) {
                    this.drawTextRedactAnnotation(annotation, factor, pageNumber, context);
                }
                if (annotation) {
                    this.pdfViewerBase.updateDocumentEditedProperty(true);
                    var settings = {
                        shapeAnnotationType: annotation.shapeAnnotationType,
                        markerBorderColor: annotation.markerBorderColor,
                        markerFillColor: annotation.markerFillColor,
                        opacity: annotation.markerOpacity,
                        overlayText: annotation.overlayText || '',
                        fontColor: annotation.fontColor,
                        fontSize: annotation.fontSize || 14,
                        fontFamily: annotation.fontFamily,
                        textAlign: annotation.textAlign,
                        author: annotation.author,
                        subject: annotation.subject,
                        modifiedDate: annotation.modifiedDate
                    };
                    this.pdfViewer.fireAnnotationAdd(pageNumber, annotation.annotName, 'Redaction', annotation.bounds, settings, textContent, startIndex, endIndex);
                }
            }
        };
        Redaction.prototype.getRgbCode = function (colorString) {
            if (!colorString.match(/#([a-z0-9]+)/gi) && !colorString.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/)) {
                colorString = this.pdfViewer.annotationModule.nameToHash(colorString);
            }
            var stringArray = colorString.split(',');
            if (ej2_base_1.isNullOrUndefined(stringArray[1])) {
                colorString = this.pdfViewer.annotationModule.getValue(colorString, 'rgba');
                stringArray = colorString.split(',');
            }
            var r = parseInt(stringArray[0].split('(')[1], 10);
            var g = parseInt(stringArray[1], 10);
            var b = parseInt(stringArray[2], 10);
            var a = parseFloat(stringArray[3]);
            return { r: r, g: g, b: b, a: a };
        };
        Redaction.prototype.getAnnotations = function (pageIndex, redactionAnnotations) {
            var annotationCollection = [];
            var storeObject = this.pdfViewer.annotationsCollection.get(this.pdfViewerBase.documentId + '_annotations_redaction');
            if (storeObject) {
                var annotObject = JSON.parse(JSON.stringify(storeObject));
                var index = this.pdfViewer.annotationModule.getPageCollection(annotObject, pageIndex);
                if (index != null && annotObject[parseInt(index.toString(), 10)]) {
                    annotationCollection = annotObject[parseInt(index.toString(), 10)].annotations;
                }
                else {
                    annotationCollection = redactionAnnotations;
                }
            }
            else {
                annotationCollection = redactionAnnotations;
            }
            return annotationCollection;
        };
        return Redaction;
    }());
    exports.Redaction = Redaction;
});