all files / action/ draw.js

90.37% Statements 3668/4059
81.18% Branches 1872/2306
95.39% Functions 145/152
90.29% Lines 3626/4016
63 statements, 12 functions, 62 branches Ignored     
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 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424  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× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324×     324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324×   1× 616× 308×   308×   1× 324× 324×   1× 308× 308×   1× 114305× 114305×   4582× 4582×   2953× 2953×   10895× 10895×   1072× 1072×   14162× 14162×   358× 358×   2× 2×   983× 983×   1463× 1463×   431× 431×   47× 47×   2× 2×   342× 342×   28× 28×   571× 571×   125× 125×   663× 663×   201× 201×   15× 15×   335× 335×   728× 728×   5783× 5783×         26× 26× 26×   431× 431×   431× 431×   831× 831×   51× 51×   13311× 13311×   2× 2×   2× 2×   9× 9×   2× 2×   9× 9×   9× 9×   5× 5×   5× 5×   138× 138×   120× 120×   225× 225×   23× 23×   501× 501×   1975× 1975× 1975×   2974× 2974×   431× 431×   415× 415×   22× 22×   828× 828×   56× 56×   47× 47×   32× 32×   15396× 15396×   7412× 7412×   11× 11×   1× 1×   212× 212×   24× 24×   13× 13×   20× 20×   1× 1×   24× 24×   399× 399×   138× 138×   260× 260×   263× 263×   123× 123×   8933× 8933×   1× 1×   1× 1×   72× 72×   155× 155×   10× 10×   2055× 2055×   4× 4×   3× 3×   140× 140×   60× 60×   45× 45×   257× 257×   45× 45×   257× 257×         209× 209×   8971× 8971×   5× 5×   7× 7×           1× 6550×   1× 114305× 114305× 114298×   114305× 114298×   114305× 1062×   114305× 324×     1× 441× 441× 441× 441× 441× 441× 441× 441× 441× 441× 441× 441×   441× 441× 441× 441× 441× 441× 441×     441× 441× 441× 441× 441× 441× 441× 441× 441× 441× 441×   1× 2055× 2055× 29× 29× 29× 29× 29× 29× 1×       1× 4× 4× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1×     1× 11772×   1× 5132× 5132× 5132× 5132× 5132× 5132× 5132× 2764×   2368× 2363×   5× 5×   5132× 1672×   5132× 4792× 4792× 112×     5132× 5132× 5132× 1× 1× 1×   5132× 285×   5132× 3777×   5132× 4× 4× 4× 4× 4× 4×   5132× 5132× 5132× 5132× 1×   5131× 115× 115× 115×   5131× 5131× 2367× 2367× 2366× 2366× 1341×     2367× 1341× 4× 4× 4× 4× 4× 4×     1337×   1341× 1341× 1341×   2367× 2361× 2361× 2361×     5131× 5131× 5131× 5131× 3777×   1354× 115×   1239× 1239×         5131× 4× 4×     1× 14984× 14984× 14984× 14984× 14984× 952×   14032× 14032× 14032× 14032× 8494× 8494×     5538× 5538×   14032× 14032× 14032×   1× 1672× 1672× 1672× 1672× 733× 733× 45× 45×   688× 150× 150×   733× 19×   714× 69× 69×   733×     1× 112× 112× 112× 112× 112× 112× 112× 112× 3× 3× 3× 2×   3× 2× 2×     1× 1×   3× 3× 3× 3× 3×     109× 109× 109×     109×     109×     109×       112×     68× 68× 68×       68×       68× 67× 67× 67× 67×   68× 68× 68× 68×             68×   11× 11× 11×   5× 5× 5×   5× 5× 5×   3× 3× 3×   4× 4× 4×   3× 3× 3×   4× 4× 4×   2× 2× 2×   2× 2× 2×   1× 1× 1×   4× 4× 4×   112× 44×   44× 42×   44×   112× 3× 3× 3×   112×         112× 112× 112× 112× 2× 2×   112× 112× 112× 112× 2×                         112× 112× 112× 112×   1× 112× 112× 112× 112× 112× 112× 112× 112× 112× 112× 3× 3× 3×   109× 4× 4× 4×   112×         112×           1× 112× 112× 110×   2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2×   2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2×           1× 9401× 9401× 9401× 9401× 9401× 9401× 9401× 9401× 9401× 9401× 9401× 9401×   9401×   9401×   9401×   9401×   9401×   9401×   9401×   9401×   9401×   9401×   9401×   9401× 8639×   8639× 8639×   9401× 9401× 9401×     1× 3483× 3483× 3483× 3483× 3483× 3483× 3483× 3482×   3483× 1342× 1342× 1342×   3483× 3483× 3483× 3483× 1925×     1558×   3483×     3483× 174× 174× 174× 174×   3309× 40× 40× 40× 40× 40× 40× 80× 80× 80×       40× 40× 40×     40× 40×     3269×   3483× 2040× 2040× 2040× 2040× 2040× 1239× 1239× 1239× 1239× 1239× 1239× 1239× 1239× 1239× 1239× 1239× 1239× 1239× 1239×     801× 763×     2040× 2040×   3483× 3483×   1× 370× 370×   86× 86×   216× 216×   6× 6×   6× 6×   6× 6×     44× 44×     1× 5131× 5131× 5131× 5131× 5131× 5131× 5131× 5131× 2764×   2367× 2362×   5× 5×   5131× 5131× 5131× 1924×   5131× 5131× 1865×     3266×   5131× 5131× 5131× 5131× 5131× 5131× 5131× 5131× 5131×   962× 962× 201×   962×   43× 43× 19×   43× 43×   243× 243× 243× 243× 243× 173× 173×   243× 243× 243× 243× 243× 29×   243×   102× 102×   204× 204× 29×   204×   185× 181×     4×   185×     185× 185×     185×     185×     185× 185× 185× 3×   185× 185× 58×   185×   141× 141× 141× 141× 141×                                               141× 282× 282× 282× 282× 282× 282×     141×         141× 20×   141×   1865× 1865×   146× 146× 44×   146×               183×     183× 183× 183×   1057× 1057×   5131×   1× 42× 42× 42× 42× 42× 42× 42× 42×   1× 2049× 2049× 2049× 2049×   1× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273× 3273×     1× 763× 763× 763× 763× 763× 763× 174× 174× 174× 174×   589× 40× 40× 40× 80× 80× 80× 80× 80× 80× 80× 80×     40× 40× 40×     40× 40× 40× 40×     549× 549×   763× 763× 763× 763× 549× 549× 549× 549× 549× 549×   763×   1× 1788× 1788× 1788× 217×   1788× 1788× 1788× 1788× 1693×     95×   1788×     1788× 1788× 650× 650× 348×   302× 302×       1788×     1419× 129×   129×     1290×   1290×   1419×     122× 52×   52×     70×   70×   122×     122× 54×   54×     68×   68×   122×     124× 54×   54×     70×   70×   124×     1× 962× 962× 962× 962× 962× 962× 962×   962×       962×   962× 962× 962× 962×   962× 962× 962× 962× 962× 962× 9×       9×       953×   962× 776× 776×   962× 9×       9×       953×   962× 962× 962×   1×                 1× 1240× 1240× 1240× 1240× 1240× 1240×   1240× 1240×   1240×   1240× 1240× 1240× 1240× 1240× 1240× 1240× 1240× 1240× 1240×   1× 102× 102× 102× 102× 102× 102× 102× 102× 102× 102×   102× 102× 102× 102× 102× 102× 102× 102× 102× 102× 102× 102×   1× 1248× 1248× 1248× 1248× 1248× 1248× 1248×   1× 364× 2× 2×   2× 2× 2×   2× 2×     364×   1× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216× 216×     216×   216× 80× 80× 80× 80× 80× 80×   136× 136× 136× 136× 136× 136× 136×     1× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86×   80×   86× 83× 83× 83× 83× 83× 83× 83× 83× 83× 83× 83×   3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×     1× 34× 34× 34× 34× 34× 34× 34× 34× 34×   3×   34× 34× 34× 34× 34× 34× 34× 34× 34× 34× 34× 34× 1× 1× 1×     1× 1× 1× 1× 1× 1×     1×     1×       33× 33× 33× 33× 3×   33× 33× 33× 27×   33× 33× 33× 33× 33× 33× 33× 3×   33×         1× 10× 10× 10× 10× 10× 10× 10× 10× 10× 10× 10× 10× 10× 10× 9× 9×     9× 9× 9× 3×   9× 9× 9× 9× 9× 9× 9× 3×   6×     6× 3×     1× 1× 1× 1×     1× 1× 1× 1× 1× 1× 1×     1×     1× 1×             1× 6× 6× 6× 6× 6×   3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×   3× 3× 3× 3× 3× 3× 3×                                   3× 3× 3× 3×       3× 3×   3×   3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×   3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×     3× 3×                           3× 3×     1× 6× 6× 6× 6× 6× 6× 3× 3× 3× 3×         3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×   3× 3× 3× 3× 3×     3×   3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×     1× 6× 6× 6× 6× 6× 3× 3× 3× 3×       3×   3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×   3× 3× 3× 3× 3×     3×   3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3× 3×     1× 146× 146× 146× 146× 146× 102× 102×   102×                 146× 146× 146× 146×       146× 146× 146× 146× 146× 68×     78×   146× 146×   1× 1865× 1865× 1865× 1865× 1865× 1865× 1865× 1865× 1865× 1865× 1865× 1865× 232× 232×   1865× 1865× 1873× 1873× 1873×     1873× 1299× 7×       574×       1873× 1873× 1873× 1873× 1873× 1873×   1873× 1873× 1873× 1873× 11×   11×               1862×   1873× 1873× 688×   1873× 623×   1873× 573×   1873× 1873× 7× 7×   1873× 931×     942× 942× 942× 21× 21×   942× 15× 15×     1873×   1865× 1865× 1865× 620×     1× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36× 36×   1× 1139× 1139× 1139× 1139× 605× 527× 527× 527× 527×   78× 78× 78× 78× 78×     534× 534× 174× 174× 174× 174×   360× 360× 360× 360× 360×     1139×   1× 68× 68× 68× 68× 68× 68×         68×     68×     68× 68× 68×   68× 68× 68× 68× 68× 68× 68× 68× 96× 96× 96× 68× 68×     68×     68× 68×   68× 68× 68× 68× 68× 68× 68×             68× 68× 68× 68× 68× 68× 68×     28× 18×   10× 8×   28× 10× 10× 10×   18× 18× 18× 18×   28× 28×   96× 96× 96× 96×   68× 68×   68× 68× 68× 68×       1× 931× 931× 931× 931× 931× 931× 879×     52×   931×     931× 3×   931× 931× 931× 931× 931× 931× 931× 931× 931× 931× 931× 1806× 1806× 1806× 695× 695×     695× 4×   695× 695× 695× 695× 695× 695× 691× 691×   4× 4× 4×   695× 695× 695× 695× 695× 695× 695×     1111× 174×   937× 150×   1111× 595× 595×   516× 516× 516×   1111× 1111× 1111×   1806× 1806× 1806× 1806×   931×     931× 931× 931× 931× 931×       1× 931× 931× 931× 931× 931× 931× 931× 931× 931×           931×   931×   931×       931×           1× 12170× 12170× 12170× 12170× 12170× 12170× 12170× 12170× 12170× 1494× 1494×     1× 10414× 10414× 10414× 10414× 2877× 2877×   2877× 2877× 1473× 1473× 1473× 1473×   2877× 2877× 2877× 2877×     7537× 7537×   7537× 7537× 6003× 6003× 6003× 6003×   7537× 7537× 7091×     446×   7537× 7537×     1× 18330× 18330× 18330× 18330× 9165× 9165× 9165×     18330× 278× 278×   17× 17×   278× 59× 59×     278×   278× 59× 59×         18052× 18052×   13139× 13139×       1× 18688× 18688× 18688× 9344×   9344× 9344× 9344× 9344×   141× 59× 59×   141×   141× 59× 59×         1× 19152× 19152× 9576× 4254×     9576× 9576× 4254×       1× 8510× 8510× 2630×   5880× 59×   8510× 614×   7896× 384×   8510× 8510× 8510× 4256×   8510×     5380× 5380× 5380× 5380×   1462× 1462× 1462×   1272× 1272× 1272×   8510× 8510×   1× 2224× 2224× 2224× 2224× 2224× 728× 728×   2224× 2224× 2224× 2224×       2224×   1× 1240× 1240× 1240× 1240× 1240×   1240× 29×     1211× 147×   1211×   1240× 1240× 1240× 1240× 29×     1211× 1211×   1240× 83×       1157×     1240× 1240× 11×       1× 329× 329× 329× 329× 329× 329× 330× 330× 329×   330× 330× 330× 330× 330×           330× 330× 330× 330× 330× 330×       330× 330×                 330× 330× 330×   330× 298× 298× 298×   330×     330×   329× 1× 1× 1×     1× 5× 5× 5×   1× 330× 330× 4× 4× 4× 4× 4× 4× 4×     326× 326× 326×     1× 761× 761× 761× 761×                               761× 761×   761× 761× 761× 761× 761× 761× 761× 761× 761×   761×   761× 761× 761× 761×   761× 761× 728×   761× 1×         761×     761× 15×   761× 433×   761×   1× 259× 259× 5× 5× 5× 5×   5× 5× 4× 4× 4×   5× 5×     1× 47× 47× 20×   47× 47× 47× 47× 47× 47× 1× 1×   47× 47× 47× 2× 2× 2× 2×   45× 12× 12× 12× 12× 12×         12× 12×   12× 12×     12× 12× 12× 12×       33×   2× 2× 2× 2× 2× 2×   1×   2× 2× 2× 2× 2× 2× 2× 2×   2× 2× 2× 2× 2× 2×       2× 2× 2× 2×     2× 2× 2× 2× 1× 1×       31×         31× 31× 2× 2×     29× 29×       47× 47× 47× 47× 47× 20×   47× 47× 47× 47× 47× 47×   1× 31× 31× 31× 31× 31× 31× 31× 31× 20×   31×     31× 16×   31× 14× 14×   31× 2× 2× 2× 2× 2× 2× 2× 2× 1×       1× 1× 1× 1×     2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2×   2×   2×   2×   2× 2× 2×   2×     2× 2× 2× 2× 2× 2× 2×     31×   2× 2× 2×   2× 2× 2×   2× 2× 2× 2×   16× 16× 16×   9× 9× 9× 9×   31× 31× 31× 31× 31× 31×   1× 2× 2× 2× 2× 2× 2× 2×     2× 2× 2× 2×   2× 2× 2× 2× 2× 2× 2× 2× 2×   1× 2× 2×   2×   2×         2× 2× 2× 2× 2×           2× 2×     2× 2×   2× 2× 2× 2× 2×   1× 2× 2×   2×       2×           2× 2× 2× 2× 1× 1× 1×             2×               2× 2×   2× 2× 2× 1×       1×   2×   2× 2× 2× 2× 2× 2× 2×   1× 16× 16× 16× 16× 16× 16× 16× 16× 16× 16× 16× 2×       1× 33× 33× 33× 33× 33× 33× 33× 23×   33× 33× 3×         1× 155× 155× 155× 155× 155× 155× 155× 155× 155×   155× 155×               1× 2× 2× 2× 2× 2× 2× 2×   2× 2× 2×         1× 342× 342× 342× 341× 341× 341× 341× 341× 341× 341× 341× 341×   341× 341× 341×   5×   341× 341× 341× 157×   341× 1×   340× 157×   341× 341× 341× 341× 341× 341× 341×   341× 341× 341× 341× 341×     108× 108× 27× 27× 27× 27× 27×   108× 108× 108× 108× 108×   108× 108× 23× 23×       233× 208×   208× 208×     25×   233× 126×   233×       1× 256× 256× 256× 256× 142× 142× 142× 142× 142× 104× 104×       114× 2× 2×     112× 112× 112× 2×     110× 2×     112× 112×     1× 399× 399× 399× 399× 399×   399×   399× 399× 399×   399× 287×     112×           112×     1× 145× 145× 145× 145× 145× 145× 32× 32× 32× 32× 32× 32×   113× 2× 2× 2× 2× 2×     111× 104× 104× 104× 104× 104× 104× 104× 104× 104×                                           7× 7× 7× 7× 7× 7× 7×   7×     111× 111× 111× 111× 111× 111× 111× 111× 111× 3× 3×   3×     3× 3×   3×       108× 1× 1×   1×     1× 1×   1×       111×     111×     111×         111×         111× 111× 111×   145×   1× 144× 144× 6× 6× 6× 6× 6× 6×     1× 111× 111× 107×   4× 4× 4× 4× 64× 64× 64× 64× 64× 4× 4×   60× 60× 60× 60× 60×     1× 693× 693× 693× 693× 693× 693× 693× 693× 693× 76× 76×   693× 693× 693× 693× 523×   693× 693× 693× 76× 76×   693× 693× 693× 693× 693× 693× 693× 693×   693× 693× 693× 693× 693× 693× 693× 693×   1× 650× 650× 650×   1× 9469× 9469× 2037× 2037× 2037× 2037× 2037×     7432× 7365× 7365×       1× 665× 665× 665× 665× 243× 243×   243× 243× 243× 243× 243× 243×     422×   665× 1×       1× 203× 203× 203× 85× 85× 85×   203× 203× 203× 203× 203× 85×     118× 4×     114×     203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 203× 16× 16×   203×     203× 203× 203× 118×   203× 203× 203× 203× 203× 203× 94×     109× 109×   203× 203× 3×   203× 203× 62× 34×       28×   62× 62× 62× 62×   203× 203× 203× 91×   203× 203× 203× 101× 101×   101×   203× 203× 52× 52× 53× 25× 25×   53×   52× 52× 52× 52× 52× 51×   52× 28× 28×   52× 52× 25×     203× 203× 141× 141×   141× 141×   203× 203× 203× 94×     109× 109×         1× 203× 203× 203× 203× 203× 203×       203×   203× 203× 203×       203×   203× 203× 203× 203× 203×     203× 91×   91× 91× 91× 91× 91×   91× 91× 91× 91×   203× 203×   1× 17× 17× 17× 17× 9×   17× 8×         17× 17× 17× 17× 17× 17× 17×   17× 17×   1× 17× 17× 16× 16× 16× 16× 9× 9× 9×     7× 7× 7× 7× 7× 7×   7× 7× 7× 7×   7× 7×   7× 7×   7×   7×   7× 7× 7× 7× 7× 5×       7×   7×       16× 16× 16× 9×         16× 16×   16× 8×       1× 16× 16× 16× 8× 8× 8× 1×   7×     8×     8×     8× 2× 2× 2×     6× 6× 6× 6× 6× 6× 6× 6× 6×   6× 6×   6× 6× 6× 6×   6× 6× 6× 6× 6×   6×           1× 20× 20× 20× 20× 20× 20×   20× 18× 18× 18× 15× 15× 15×     3× 3× 3× 3×   18× 18× 18× 18× 72× 72×   18× 18× 18× 2× 2× 2× 2× 2× 2× 2×   18× 2× 2× 2×       1× 11× 11×   11× 11× 11×   11× 11× 11× 11× 11× 11×   1× 331× 331× 331× 331× 331× 331× 331× 331×     331× 331× 331×     1× 1×   331× 331× 331× 331× 331× 331× 331× 331× 329× 329× 326× 326×     3×   329× 329× 328× 328× 328× 325× 325×   328× 1×     329× 329× 328× 327× 327×           2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2×     1× 335× 335× 335× 1340×   335× 335× 335×   335× 334×           334× 334×   334× 334× 334×   1× 1× 1× 335×         1×       1×     1×                           1×                                                           1× 335× 335× 335× 335× 335× 335× 2× 2×   333× 333× 332× 332×   333×     333×   3×   330× 7× 7×   7×       323×     1× 335× 335× 4× 4× 4× 4×       331× 331×   331× 10×   331×     1× 5× 5× 5× 5× 5× 3× 3×   2× 1× 1× 1× 1× 1× 1× 1×       1× 1× 1× 1×     1× 2× 2× 2×         2×       1× 335× 335× 335×     1× 5783×   1× 662× 662× 656×   6× 4×   2×   1×                                                                                                                     1×                     1× 47× 47× 47× 47× 50× 50× 29× 29×     47× 29×     29× 29× 29× 29× 29× 24× 20× 20× 20×     20×       20×                                                 4×                                 4× 4×     4×       4×                 29×   29×   29× 29×   29×           29× 29× 29×   29×   29× 29× 29×       1× 20× 20× 20× 20× 20× 16×   20×   1× 4× 4× 4×   4×   4×   1× 11786× 11786× 11786× 11786× 11786× 11786× 11786× 1841×       9945×     11786×   99×     99× 99× 99× 11×     88×       88×   99× 34×   99× 11× 11× 11×             11× 3× 2× 2× 2×   1× 1×   3×         8× 4× 2× 2× 2×   2× 2×   4× 4× 4×       11× 11×   88×             88×       11687×   11687× 7× 7×   11687×     11786× 34×     1× 35× 35×     35× 35× 35× 35× 35× 35× 35× 35× 35× 35× 35× 35× 35× 35× 8849× 3194722× 3194722× 3194722× 3194722× 3194722× 3194722× 3194722× 3194722× 3194722× 3194722× 3194722× 3194722× 8357772× 8357772× 8357772× 8357772× 8357772× 8357772× 22113936× 22113936× 22113936× 7490040×   14623896× 14623896× 14623896× 14623896× 14623896× 14623896× 14623896× 14623896× 14623896×     3194722× 3194722× 3194722× 3194722×     35× 35× 35×   1× 27172× 27172× 11775×     1× 224× 224× 224× 94× 94× 94× 94×     130×   224×   1× 27172× 27172× 27172× 27172× 27172×   27172×     27172× 27172× 1× 1× 1× 1×   1× 1× 1× 1× 1× 1× 1×   27171× 4×     27167× 11772×   27172× 27172× 27172× 27168× 27168× 27168× 27168× 27168× 27168×   27172× 4×               27172× 27172× 27172×   3378×     23794×   23614× 23614×   97× 97×       97× 97× 97× 97× 97×   97× 97× 97×   6× 6× 6× 6× 6× 6× 6× 6× 6× 6×                       6× 6× 6× 6× 6× 6× 6× 6× 6× 6×   6× 6× 6× 6× 6× 6×             6× 6× 3× 3× 3×   3× 3× 3× 3× 3× 3× 3× 3× 3×   3× 3×     3× 3× 3×     6× 6×   58× 58× 58× 58× 96× 38× 38× 38× 38×   96× 96× 96× 96× 96× 96× 96× 96× 96× 96× 96× 96× 68×   28×     96× 96× 96× 96× 96×   96×   96× 96× 96× 96× 96× 96× 96×     58× 58×   6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6× 6×   13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13×   23794×       23794×     1× 24× 24×       24×   24× 24× 24× 24×   24×   1× 24× 24× 24× 24× 24× 24× 24× 24× 24× 24×   1× 20× 20× 17× 17× 17× 3× 3× 3× 3× 30×     27× 27×       27× 27× 27×       3× 3×     3× 3×         14×     14×       14× 5×     14× 14× 14×       3× 3× 3× 3×     1× 49× 49× 49×   49× 49× 49×   34×   49× 49× 49× 49× 49× 49×   1× 17× 17× 17× 17× 1×   17× 17× 557× 541× 541× 541× 1× 1×   540× 363× 363×   540× 540× 540× 540× 540× 540× 2160× 2160×   540×     16× 16×     17× 17× 557× 557× 17×     1× 20× 20×   20×   20× 20× 4×   20× 20×   20×   1× 568× 568× 568× 391×   391× 391×     177× 177× 177× 177× 177× 177× 177×     1× 420× 420× 420× 420× 420× 420×   420× 420×   420×   420× 420× 420× 420× 420× 420× 297× 297× 297× 297×   123× 77× 77× 77× 77×   46× 46× 46× 46× 46×   420× 420× 420× 420× 420× 420× 420× 420× 420×   1× 719× 719× 719× 4× 4×   4× 4× 4×   4×   4×   4×   4× 4× 4× 4× 4× 4× 4×   4×   715× 715× 715× 715× 715× 715× 715× 715× 715× 715× 138×   715×                     1× 105× 105× 105× 105×         1× 2160×   1× 360× 360× 360× 360× 360× 360× 113×   247× 1×     246×     1× 420× 420× 420× 420× 420× 420×                 420× 420×   420× 420× 420× 420× 420× 420× 420× 420× 420× 420× 420× 420× 420× 420× 420×   420×   420×   420×   420× 420× 420× 420× 420×   1× 2876× 2876× 2876× 2876× 2876× 1373×   1503× 5×   1498× 4×   1494× 7×   1487×     1487×   1× 11504× 11504× 117×   11387×   1× 49×   16×   33×   1× 2860× 2860× 2860× 2860×   267×   2860×   1× 263× 263× 188× 188× 188× 188× 188× 188× 188×     1× 43× 43× 43× 43× 43×     43× 43×     43× 14×     29× 29× 29× 29× 29× 29× 29× 2× 2× 2×           2× 2× 2×   2× 2× 2× 2× 2× 2×     2×     2× 2× 2× 2× 2× 2× 2× 2×   2× 2× 2×   2× 2× 2× 2×   2×   2×   2× 2× 2×     2×             2× 2× 2×   2×   2×   2×   2×   2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 2× 1× 1× 1× 1× 1×       1×     1× 1×     1× 1× 1× 1× 1×       1×     29× 24× 23× 23× 23×   24×         24×   24× 24× 23×     1× 1× 1×   1× 1× 1×     24×     24×     5× 5×     5× 4× 4× 4×     1× 1× 1×   1× 1× 1×     5× 5× 5×       29× 29× 29× 29× 29× 29× 29× 29× 29×     1×   1×    
/* istanbul ignore next */ 
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
/* istanbul ignore next */ 
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
define(["require", "exports", "@syncfusion/ej2-base", "../index", "@syncfusion/ej2-popups"], function (require, exports, ej2_base_1, index_1, ej2_popups_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Draw = (function () {
        function Draw(parent) {
            this.isInitialLoading = false;
            this.fileName = '';
            this.isErrorImage = false;
            this.isShapeTextInserted = false;
            this.isRotateZoom = false;
            this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, outlineColor: '', radius: null, outlineWidth: null };
            this.tempTextSettings = { text: 'Enter Text', fontFamily: '', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false, strikethrough: false };
            this.tempAdjValue = '';
            this.tempFilter = '';
            this.tempUndoRedoStep = 0;
            this.tempFreehandCounter = 0;
            this.tempCurrFhdIndex = 0;
            this.tempZoomFactor = null;
            this.isCancelAction = false;
            this.rotatedFlipCropSel = false;
            this.zoomCrop = { width: 0, height: 0 };
            this.isImageEdited = false;
            this.isFileChanged = false;
            this.isNewPath = false;
            this.isResizeSelect = false;
            this.arrowDimension = { bar: { width: 10, height: 32, ratioX: null, ratioY: null },
                arrow: { width: 24, height: 24, ratioX: null, ratioY: null }, arrowSolid: { width: 32, height: 32, ratioX: null, ratioY: null },
                circle: { width: 10, height: 10, ratioX: null, ratioY: null }, square: { width: 20, height: 20, ratioX: null, ratioY: null } };
            this.origDim = { width: 0, height: 0 };
            this.isImageApply = false;
            this.imgCanvasPoints = [];
            this.isCropSelect = false;
            this.isDownScale = false;
            this.preventStraightening = false;
            this.tempObjColl = [];
            this.tempPointColl = {};
            this.imageBackgroundColor = '';
            this.allowRedactStraighten = true;
            this.isNullExtension = true;
            this.isRedactStraighten = false;
            this.parent = parent;
            this.addEventListener();
        }
        Draw.prototype.destroy = function () {
            if (this.parent.isDestroyed) {
                return;
            }
            this.removeEventListener();
        };
        Draw.prototype.addEventListener = function () {
            this.parent.on('draw', this.draw, this);
            this.parent.on('destroyed', this.destroy, this);
        };
        Draw.prototype.removeEventListener = function () {
            this.parent.off('draw', this.draw);
            this.parent.off('destroyed', this.destroy);
        };
        Draw.prototype.draw = function (args) {
            this.updatePrivateVariables();
            switch (args.prop) {
                case 'drawObject':
                    this.drawObject(args.value['canvas'], args.value['obj'], args.value['isCropRatio'], args.value['points'], args.value['isPreventDrag'], args.value['saveContext'], args.value['isPreventSelection']);
                    break;
                case 'updateActiveObject':
                    this.updateActiveObject(args.value['actPoint'], args.value['obj'], args.value['isMouseMove'], args.value['x'], args.value['y']);
                    break;
                case 'clearOuterCanvas':
                    this.clearOuterCanvas(args.value['context']);
                    break;
                case 'setDestPoints':
                    this.setDestPoints();
                    break;
                case 'updateCurrTransState':
                    this.updateCurrTransState(args.value['type'], args.value['isPreventDestination'], args.value['isRotatePan']);
                    break;
                case 'currTransState':
                    this.currTransState(args.value['type'], args.value['isPreventDestination'], args.value['context'], args.value['isPreventCircleCrop']);
                    break;
                case 'setTransform':
                    this.setTransform(args.value['context'], args.value['value'], args.value['isReverse']);
                    break;
                case 'render-image':
                    this.renderImage(args.value['isMouseWheel'], args.value['isPreventClearRect'], args.value['isFrame'], args.value['isStraighten']);
                    break;
                case 'draw-image-to-canvas':
                    this.drawImgToCanvas(args.value['dimension']);
                    break;
                case 'update-canvas':
                    this.updateCanvas();
                    break;
                case 'performCancel':
                    this.performCancel(args.value['isContextualToolbar'], args.value['isUndoRedo'], args.value['isFinalCancel']);
                    break;
                case 'updateFlipPan':
                    this.updateFlipPan(args.value['tempSelectionObj']);
                    break;
                case 'select':
                    this.select(args.value['type'], args.value['startX'], args.value['startY'], args.value['width'], args.value['height']);
                    break;
                case 'callUpdateCurrTransState':
                    this.callUpdateCurrTransState();
                    break;
                case 'resetPanPoints':
                    this.resetPanPoints();
                    break;
                case 'setClientTransDim':
                    this.setClientTransDim(args.value['isPreventDimension']);
                    break;
                case 'redrawImgWithObj':
                    this.redrawImgWithObj();
                    break;
                case 'setCurrentObj':
                    this.setCurrentObj(args.value['obj'], args.value['isUndoRedo'], args.value['isCircleCrop']);
                    break;
                case 'performPointZoom':
                    this.performPointZoom(args.value['x'], args.value['y'], args.value['type'], args.value['isResize']);
                    break;
                case 'open':
                    this.open(args.value['data']);
                    break;
                case 'isInitialLoading':
                    this.isInitialLoading = args.value['isInitialLoading'];
                    break;
                case 'isInitialLoaded':
                    this.getInitialLoaded(args.value['object']);
                    break;
                case 'fileSelect':
                    this.fileSelect(args.value['inputElement'], args.value['args']);
                    break;
                case 'getFileName':
                    args.value['obj']['fileName'] = this.fileName;
                    args.value['obj']['fileType'] = this.fileType;
                    break;
                case 'getErrorImage':
                    args.value['obj']['isErrorImage'] = this.isErrorImage;
                    break;
                case 'getInitialZoomValue':
                    args.value['obj']['initialZoomValue'] = this.initZoomValue;
                    break;
                case 'setShapeTextInsert':
                    this.isShapeTextInserted = args.value['bool'];
                    break;
                case 'resetCurrentSelectionPoint':
                    this.currSelPoint = null;
                    break;
                case 'setRotateZoom':
                    this.isRotateZoom = args.value['isRotateZoom'];
                    break;
                case 'setTempStrokeSettings':
                    this.tempStrokeSettings = args.value['tempStrokeSettings'];
                    break;
                case 'setTempTextSettings':
                    this.tempTextSettings = args.value['tempTextSettings'];
                    break;
                case 'setTempAdjustmentValue':
                    this.tempAdjValue = args.value['tempAdjustmentValue'];
                    break;
                case 'getTempAdjustmentValue':
                    args.value['obj']['value'] = this.tempAdjValue;
                    break;
                case 'setTempFilter':
                    this.tempFilter = args.value['tempFilter'];
                    break;
                case 'setTempUndoRedoStep':
                    this.tempUndoRedoStep = args.value['tempUndoRedoStep'];
                    break;
                case 'setTempFreehandCounter':
                    this.tempFreehandCounter = args.value['tempFreehandCounter'];
                    break;
                case 'setTempCurrentFreehandDrawIndex':
                    this.tempCurrFhdIndex = args.value['tempCurrentFreehandDrawIndex'];
                    break;
                case 'setTempZoomFactor':
                    this.tempZoomFactor = args.value['tempZoomFactor'];
                    break;
                case 'setCancelAction':
                    this.isCancelAction = args.value['bool'];
                    break;
                case 'getRotatedFlipCropSelection':
                    args.value['bool']['isSelected'] = this.rotatedFlipCropSel;
                    break;
                case 'getPrevActObj':
                    args.value['obj']['prevActObj'] = this.prevActObj;
                    break;
                case 'setPrevActObj':
                    this.prevActObj = args.value['prevActObj'];
                    break;
                case 'setZoomCropWidth':
                    this.zoomCrop.width = args.value['width'];
                    this.zoomCrop.height = args.value['height'];
                    break;
                case 'setImageEdited':
                    this.isImageEdited = true;
                    break;
                case 'reset':
                    this.reset();
                    break;
                case 'setNewPath':
                    this.isNewPath = args.value['bool'];
                    break;
                case 'getNewPath':
                    args.value['obj']['isNewPath'] = this.isNewPath;
                    break;
                case 'getArrowDimension':
                    args.value['obj']['arrowDimension'] = ej2_base_1.extend({}, this.arrowDimension, {}, true);
                    break;
                case 'setArrowDimension':
                    this.arrowDimension = args.value['arrowDimension'];
                    break;
                case 'moveToSelectionRange':
                    this.moveToSelectionRange(args.value['type'], args.value['activeObj']);
                    break;
                case 'setResizeSelect':
                    this.isResizeSelect = args.value['bool'];
                    break;
                case 'applyFrame':
                    this.applyFrame(args.value['ctx'], args.value['frame'], args.value['preventImg']);
                    break;
                case 'drawImage':
                    this.drawImage();
                    break;
                case 'downScaleImgCanvas':
                    this.downScaleImgCanvas(args.value['ctx'], args.value['isImgAnnotation'], args.value['isHFlip'], args.value['isVFlip']);
                    break;
                case 'downScale':
                    this.downScale(args.value['canvas'], args.value['width'], args.value['height']);
                    break;
                case 'resetFrameZoom':
                    this.resetFrameZoom(args.value['isOk']);
                    break;
                case 'triggerFrameChange':
                    args.value['obj']['frameChangeEventArgs'] = this.triggerFrameChange(args.value['prevFrameSettings']);
                    break;
                case 'setImageApply':
                    this.isImageApply = args.value['bool'];
                    break;
                case 'zoomToSel':
                    this.zoomToSel(args.value['activeObj'], args.value['isToolbar']);
                    break;
                case 'getStraightenActObj':
                    args.value['obj']['activeObj'] = this.straightenActObj;
                    break;
                case 'setStraightenActObj':
                    this.straightenActObj = args.value['activeObj'];
                    break;
                case 'updateImgCanvasPoints':
                    this.updateImgCanvasPoints();
                    break;
                case 'isLinesIntersect':
                    args.value['obj']['isIntersect'] = this.isLinesIntersect(args.value['obj']);
                    break;
                case 'getImageCanvasPoints':
                    args.value['obj']['points'] = this.imgCanvasPoints;
                    break;
                case 'setDestForStraighten':
                    this.setDestForStraighten();
                    break;
                case 'setTempDestForStraighten':
                    this.tempStraightenDestPoints = ej2_base_1.extend({}, this.straightenDestPoints, {}, true);
                    break;
                case 'getStraightenInitZoom':
                    args.value['obj']['zoomFactor'] = this.straightenInitZoom;
                    break;
                case 'setStraightenInitZoom':
                    this.straightenInitZoom = args.value['zoomFactor'];
                    break;
                case 'isPointsInsideImg':
                    args.value['obj']['bool'] = this.checkPointPosition(args.value['x'], args.value['y'], this.imgCanvasPoints[0].x, this.imgCanvasPoints[0].y, this.imgCanvasPoints[1].x, this.imgCanvasPoints[1].y, this.imgCanvasPoints[2].x, this.imgCanvasPoints[2].y, this.imgCanvasPoints[3].x, this.imgCanvasPoints[3].y) !== 'inside';
                    break;
                case 'setIsCropSelect':
                    this.isCropSelect = args.value['bool'];
                    break;
                case 'updateCropSelection':
                    this.updateCropSelection();
                    break;
                case 'updateCropSelObj':
                    this.updateCropSelObj();
                    break;
                case 'redrawDownScale':
                    this.redrawDownScale();
                    break;
                case 'updateFinetune':
                    this.updateFinetune();
                    break;
                case 'isSelOutsideImg':
                    args.value['obj']['bool'] = this.isSelOutsideImg();
                    break;
                case 'resetStraightenDestPoints':
                    this.straightenDestPoints = null;
                    break;
                case 'checkPointPosition':
                    args.value['obj']['position'] = this.checkPointPosition(args.value['obj']['x'], args.value['obj']['y'], args.value['obj']['x1'], args.value['obj']['y1'], args.value['obj']['x2'], args.value['obj']['y2'], args.value['obj']['x3'], args.value['obj']['y3'], args.value['obj']['x4'], args.value['obj']['y4']);
                    break;
                case 'updateTempObjColl':
                    this.tempObjColl = ej2_base_1.extend([], this.parent.objColl, [], true);
                    break;
                case 'resetTempObjColl':
                    this.tempObjColl = null;
                    break;
                case 'updateTempPointColl':
                    this.tempPointColl = ej2_base_1.extend({}, this.parent.pointColl, {}, true);
                    break;
                case 'resetTempPointColl':
                    this.tempPointColl = {};
                    break;
                case 'showDialogPopup':
                    this.showDialogPopup();
                    break;
                case 'imageBackgroundColor':
                    this.imageBackgroundColor = args.value['color'];
                    break;
                case 'getImageBackgroundColor':
                    args.value['obj']['color'] = this.imageBackgroundColor;
                    break;
                case 'setTempStrokeWidth':
                    this.tempStrokeWidth = args.value['strokeWidth'];
                    break;
                case 'setNullExtension':
                    this.isNullExtension = args.value['extension'];
                    break;
                case 'setRedactStraighten':
                    this.isRedactStraighten = args.value['bool'];
                    break;
            }
        };
        Draw.prototype.getModuleName = function () {
            return 'draw';
        };
        Draw.prototype.updatePrivateVariables = function () {
            var parent = this.parent;
            if (parent.lowerCanvas) {
                this.lowerContext = parent.lowerCanvas.getContext('2d');
            }
            if (parent.upperCanvas) {
                this.upperContext = parent.upperCanvas.getContext('2d');
            }
            if (ej2_base_1.isNullOrUndefined(this.tempZoomFactor)) {
                this.tempZoomFactor = parent.transform.zoomFactor;
            }
            if (this.tempTextSettings.fontFamily === '') {
                this.tempTextSettings.fontFamily = parent.fontFamily.default;
            }
        };
        Draw.prototype.reset = function () {
            this.isInitialLoading = this.isErrorImage = this.isNewPath = this.isResizeSelect = false;
            this.isShapeTextInserted = false;
            this.isImageApply = false;
            this.isNullExtension = true;
            this.initZoomValue = null;
            this.tempFilter = '';
            this.origDim = { width: 0, height: 0 };
            this.currSelPoint = null;
            this.isRotateZoom = false;
            this.tempAdjValue = '';
            this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
            this.tempTextSettings =
                { text: 'Enter Text', fontFamily: this.parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false, italic: false, underline: false, strikethrough: false };
            this.tempUndoRedoStep = this.tempFreehandCounter = this.tempCurrFhdIndex = 0;
            this.tempZoomFactor = null;
            this.isCancelAction = false;
            this.rotatedFlipCropSel = false;
            this.prevActObj = null;
            this.tempStraightenDestPoints = null;
            this.arrowDimension = { bar: { width: 10, height: 32, ratioX: null, ratioY: null },
                arrow: { width: 24, height: 24, ratioX: null, ratioY: null }, arrowSolid: { width: 32, height: 32, ratioX: null, ratioY: null },
                circle: { width: 10, height: 10, ratioX: null, ratioY: null }, square: { width: 20, height: 20, ratioX: null, ratioY: null } };
            this.straightenActObj = null;
            this.imgCanvasPoints = [];
            this.straightenInitZoom = null;
            this.allowRedactStraighten = true;
            this.tempObjColl = [];
            this.tempPointColl = {};
            this.imageBackgroundColor = '';
            this.tempStrokeWidth = null;
            this.straightenDestPoints = null;
            this.isCropSelect = this.isDownScale = this.preventStraightening = false;
            this.isRedactStraighten = false;
        };
        Draw.prototype.redrawDownScale = function () {
            var parent = this.parent;
            if (parent.transform.zoomFactor && parent.transform.zoomFactor < 0) {
                var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.isDownScale = true;
                this.renderImage();
                this.isDownScale = false;
                if (activeObj.shape) {
                    this.drawObject('duplicate', activeObj);
                }
            }
        };
        Draw.prototype.updateFinetune = function () {
            var parent = this.parent;
            if (parent.transform.zoomFactor && parent.transform.zoomFactor < 0) {
                var filter = this.lowerContext.filter;
                this.lowerContext.filter = 'none';
                parent.notify('draw', { prop: 'redrawDownScale' });
                var inMemoryContext = parent.inMemoryCanvas.getContext('2d');
                var ctx = this.lowerContext;
                var imageData = ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height);
                parent.inMemoryCanvas.width = imageData.width;
                parent.inMemoryCanvas.height = imageData.height;
                inMemoryContext.putImageData(imageData, 0, 0);
                this.lowerContext.filter = filter;
                parent.notify('draw', { prop: 'redrawDownScale' });
            }
        };
        Draw.prototype.drawImage = function () {
            this.applyFrame(this.lowerContext, this.parent.frameObj.type);
        };
        Draw.prototype.drawObject = function (canvas, obj, isCropRatio, points, isPreventDrag, saveContext, isPreventSelection) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var actPoint = parent.activeObj.activePoint;
            this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            var canvasDraw;
            canvas = canvas.toLowerCase();
            if (canvas === 'original') {
                canvasDraw = this.lowerContext;
            }
            else if (canvas === 'duplicate') {
                canvasDraw = this.upperContext;
            }
            else Eif (saveContext) {
                canvasDraw = saveContext;
            }
            if (!isPreventDrag && actObj.shape) {
                this.setDragLimit();
            }
            if (parent.currObjType.shape) {
                var splitWords = parent.currObjType.shape.split('-');
                if (splitWords[0].toLowerCase() === 'crop' && isCropRatio) {
                    this.drawCropRatio();
                }
            }
            actObj = parent.activeObj;
            actPoint = parent.activeObj.activePoint;
            if (ej2_base_1.isNullOrUndefined(actObj.strokeSettings)) {
                var obj_1 = { strokeSettings: {} };
                parent.notify('shape', { prop: 'getStrokeSettings', onPropertyChange: false, value: { obj: obj_1 } });
                actObj.strokeSettings = obj_1['strokeSettings'];
            }
            if (ej2_base_1.isNullOrUndefined(actObj.strokeSettings.strokeWidth)) {
                actObj.strokeSettings.strokeWidth = 2;
            }
            if (obj) {
                parent.activeObj = ej2_base_1.extend({}, obj, {}, true);
            }
            if (points && points.startX && points.startY && points.endX && points.endY && points.width && points.height) {
                actPoint.startX = points.startX;
                actPoint.startY = points.startY;
                actPoint.endX = points.endX;
                actPoint.endY = points.endY;
                actPoint.width = points.width;
                actPoint.height = points.height;
            }
            this.updateActiveObject();
            actObj = parent.activeObj;
            actPoint = parent.activeObj.activePoint;
            if (ej2_base_1.isNullOrUndefined(actPoint.startX) && ej2_base_1.isNullOrUndefined(actPoint.startY)) {
                return;
            }
            if (parent.currObjType.isText) {
                var obj_2 = { keyHistory: '' };
                parent.notify('shape', { prop: 'getKeyHistory', onPropertyChange: false, value: { obj: obj_2 } });
                actObj.keyHistory = obj_2['keyHistory'];
            }
            var isCrop = false;
            if (canvas !== 'original') {
                var splitWords = void 0;
                if (actObj.shape) {
                    splitWords = actObj.shape.split('-');
                    if (splitWords[0] === 'crop') {
                        isCrop = true;
                    }
                }
                if (isCrop) {
                    if (points && points.startX && points.startY && points.endX && points.endY && points.width && points.height) {
                        actPoint.startX = points.startX;
                        actPoint.startY = points.startY;
                        actPoint.endX = points.endX;
                        actPoint.endY = points.endY;
                        actPoint.width = points.width;
                        actPoint.height = points.height;
                    }
                    else {
                        actPoint = actObj.activePoint;
                    }
                    this.upperContext.fillStyle = 'rgb(0, 0, 0, 0.25)';
                    this.upperContext.fillRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
                    this.upperContext.clearRect(actPoint.startX, actPoint.startY, actPoint.width, actPoint.height);
                }
                if (ej2_base_1.isNullOrUndefined(isPreventSelection) && (canvasDraw === this.lowerContext || canvasDraw === this.upperContext)) {
                    this.rotateContext('initial', canvasDraw);
                    this.drawOuterSelection(canvasDraw);
                    this.rotateContext('reverse', canvasDraw);
                }
            }
            parent.currObjType.isActiveObj = true;
            var object = { keyHistory: '' };
            parent.notify('shape', { prop: 'getKeyHistory', onPropertyChange: false, value: { obj: object } });
            if (obj) {
                this.drawShapeObj(canvas, obj.shape, saveContext, isPreventSelection);
            }
            else if (object['keyHistory'] !== '' && parent.currObjType.isText) {
                this.drawShapeObj(canvas, 'text', saveContext, isPreventSelection);
            }
            else Eif (actObj.shape) {
                this.drawShapeObj(canvas, actObj.shape, saveContext, isPreventSelection);
            }
            else {
                this.drawShapeObj(canvas, undefined, saveContext, isPreventSelection);
            }
            if (canvas === 'duplicate' && isCrop && actObj.shape !== 'crop-circle' && parent.frameObj.type !== 'none') {
                this.applyFrame(this.upperContext, parent.frameObj.type);
                this.drawCornerCircles(this.upperContext);
            }
        };
        Draw.prototype.rotateContext = function (type, ctx) {
            var parent = this.parent;
            var _a = parent.activeObj, shape = _a.shape, rotatedAngle = _a.rotatedAngle;
            var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
            var _c = parent.activeObj.activePoint, startX = _c.startX, startY = _c.startY, width = _c.width, height = _c.height;
            if (shape === 'line' || shape === 'arrow') {
                return;
            }
            var rotationAngle = (type === 'initial') ? rotatedAngle : -rotatedAngle;
            var translateX;
            var translateY;
            if (parent.transform.straighten === 0 && !parent.isCropTab) {
                translateX = startX + (width / 2);
                translateY = startY + (height / 2);
            }
            else {
                translateX = destLeft + (destWidth / 2);
                translateY = destTop + (destHeight / 2);
            }
            ctx.translate(translateX, translateY);
            ctx.rotate(rotationAngle);
            ctx.translate(-translateX, -translateY);
        };
        Draw.prototype.setDragLimit = function () {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var _a = parent.activeObj, shape = _a.shape, rotatedAngle = _a.rotatedAngle;
            if (actPoint && shape !== 'image' && shape !== 'line' && rotatedAngle === 0 && parent.activeObj.preventShapeDragOut) {
                var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
                if (actPoint.startX < destLeft) {
                    actPoint.startX = destLeft;
                    actPoint.endX = Math.min(actPoint.startX + actPoint.width, destLeft + destWidth);
                }
                else if (actPoint.endX > destLeft + destWidth) {
                    actPoint.endX = destLeft + destWidth;
                    actPoint.startX = Math.max(actPoint.endX - actPoint.width, destLeft);
                }
                if (actPoint.startY < destTop) {
                    actPoint.startY = destTop;
                }
                else if (actPoint.endY > destTop + destHeight) {
                    actPoint.endY = destTop + destHeight;
                    actPoint.startY = Math.max(actPoint.endY - actPoint.height, destTop);
                }
                parent.activeObj = this.updateWidthHeight(parent.activeObj);
            }
        };
        Draw.prototype.drawCropRatio = function () {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var x;
            var y;
            var width;
            var height;
            var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
            if (parent.transform.zoomFactor > 0 && this.currSelPoint) {
                var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                this.drawCustomSelection('crop-custom', null, null, null, null);
                if (parent.transform.straighten !== 0) {
                    actPoint = parent.activeObj.activePoint;
                }
                if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                    width = actPoint.width < actPoint.height ? actPoint.width : actPoint.height;
                    height = width;
                }
                else {
                    width = actPoint.width;
                    height = actPoint.height;
                }
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                parent.activeObj = activeObj;
                parent.currObjType.shape = activeObj.shape;
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                parent.currObjType.isCustomCrop = false;
            }
            else {
                width = destWidth;
                height = destHeight;
                Iif (destLeft < 0) {
                    width += destLeft;
                }
                Iif (destTop < 0) {
                    height += destTop;
                }
                Iif (destLeft + destWidth > parent.lowerCanvas.width) {
                    width -= (destLeft + destWidth - parent.lowerCanvas.width);
                }
                Iif (destTop + destHeight > parent.lowerCanvas.height) {
                    height -= (destTop + destHeight - parent.lowerCanvas.height);
                }
            }
            switch (parent.currObjType.shape.toLowerCase()) {
                case 'crop-square':
                case 'crop-circle':
                    parent.notify('selection', { prop: 'setDragDirection', onPropertyChange: false, value: { width: width, height: height } });
                    actPoint = parent.activeObj.activePoint;
                    Iif (parent.lowerCanvas.width < (actPoint.endX - actPoint.startX)) {
                        actPoint.startX = 7.5;
                        actPoint.endX = parent.lowerCanvas.width - 7.5;
                    }
                    Iif (parent.lowerCanvas.height < (actPoint.endY - actPoint.startY)) {
                        actPoint.startY = 7.5;
                        actPoint.endY = parent.lowerCanvas.height - 7.5;
                    }
                    if (width === destWidth && height === destHeight) {
                        actPoint.startX += destLeft;
                        actPoint.startY += destTop;
                        actPoint.endX += destLeft;
                        actPoint.endY += destTop;
                    }
                    Eif (parent.lowerCanvas.width > parent.lowerCanvas.height) {
                        actPoint.height = actPoint.endY - actPoint.startY;
                        actPoint.width = actPoint.height;
                        actPoint.endX = actPoint.startX + actPoint.width;
                    }
                    else {
                        actPoint.width = actPoint.endX - actPoint.startX;
                        actPoint.height = actPoint.width;
                        actPoint.endY = actPoint.startY + actPoint.height;
                    }
                    break;
                case 'crop-3:2':
                    x = 3;
                    y = 2;
                    break;
                case 'crop-4:3':
                    x = 4;
                    y = 3;
                    break;
                case 'crop-5:4':
                    x = 5;
                    y = 4;
                    break;
                case 'crop-7:5':
                    x = 7;
                    y = 5;
                    break;
                case 'crop-16:9':
                    x = 16;
                    y = 9;
                    break;
                case 'crop-2:3':
                    x = 2;
                    y = 3;
                    break;
                case 'crop-3:4':
                    x = 3;
                    y = 4;
                    break;
                case 'crop-4:5':
                    x = 4;
                    y = 5;
                    break;
                case 'crop-5:7':
                    x = 5;
                    y = 7;
                    break;
                case 'crop-9:16':
                    x = 9;
                    y = 16;
                    break;
                default:
                    x = parseInt(parent.currObjType.shape.toLowerCase().split('crop-')[1].split(':')[0]);
                    y = parseInt(parent.currObjType.shape.toLowerCase().split('crop-')[1].split(':')[1]);
                    break;
            }
            if (x !== undefined && y !== undefined) {
                parent.notify('selection', { prop: 'calcShapeRatio', onPropertyChange: false,
                    value: { x: x, y: y, imgWidth: width, imgHeight: height } });
                if (width === destWidth && height === destHeight) {
                    this.updatePoints();
                }
                actPoint = parent.activeObj.activePoint;
            }
            if (actPoint.startX < destLeft) {
                var diff = (destLeft - actPoint.startX) + 7.5;
                actPoint.startX += diff;
                actPoint.endX += diff;
            }
            Iif (actPoint.startY < destTop) {
                var diff = (destTop - actPoint.startY) + 7.5;
                actPoint.startY += diff;
                actPoint.endY += diff;
            }
            parent.activeObj = this.updateWidthHeight(parent.activeObj);
            this.adjToCenter();
            this.enlargeToImg();
            if (parent.transform.straighten !== 0) {
                this.adjToStraighten();
                this.updateActiveObject(parent.activeObj.activePoint, parent.activeObj);
            }
            var object = { isIntersect: null, arr: null };
            var count = 0;
            actPoint = parent.activeObj.activePoint;
            if (parent.transform.straighten !== 0) {
                while (this.isLinesIntersect(object) && count < 100) {
                    count++;
                    var diff = (actPoint.width * 1) / 100;
                    actPoint.startX += diff;
                    actPoint.endX -= diff;
                    diff = (actPoint.height * 1) / 100;
                    actPoint.startY += diff;
                    actPoint.endY -= diff;
                    actPoint.width = actPoint.endX - actPoint.startX;
                    actPoint.height = actPoint.endY - actPoint.startY;
                    this.updateActiveObject(actPoint, parent.activeObj);
                }
            }
            this.straightenInitZoom = parent.transform.zoomFactor;
            this.straightenActObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            parent.notify('draw', { prop: 'resetStraightenDestPoints' });
            parent.notify('draw', { prop: 'setDestForStraighten' });
        };
        Draw.prototype.adjToCenter = function () {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
            var diffX = ((parent.lowerCanvas.width) / 2) - (actPoint.endX - actPoint.width / 2);
            var diffY = ((parent.lowerCanvas.height) / 2) - (actPoint.endY - actPoint.height / 2);
            actPoint.startX += diffX;
            actPoint.endX += diffX;
            actPoint.startY += diffY;
            actPoint.endY += diffY;
            if (actPoint.startX < (destLeft >= 7.5 ? destLeft : 7.5)) {
                var diff = ((destLeft >= 7.5 ? destLeft : 0) - actPoint.startX);
                actPoint.startX += diff;
                actPoint.endX += diff;
            }
            else if (actPoint.endX > destLeft + destWidth) {
                var diff = (actPoint.endX - (destLeft + destWidth));
                actPoint.startX -= diff;
                actPoint.endX -= diff;
            }
            Iif (actPoint.startY < (destTop >= 7.5 ? destTop : 7.5)) {
                var diff = ((destTop >= 7.5 ? destTop : 0) - actPoint.startY);
                actPoint.startY += diff;
                actPoint.endY += diff;
            }
            else Iif (actPoint.endY > destTop + destHeight) {
                var diff = (actPoint.endY - (destTop + destHeight));
                actPoint.startY -= diff;
                actPoint.endY -= diff;
            }
        };
        Draw.prototype.enlargeToImg = function () {
            var parent = this.parent;
            if (parent.transform.straighten === 0) {
                return;
            }
            Eif (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                var actPoint = parent.activeObj.activePoint;
                var tempActPoint = ej2_base_1.extend({}, actPoint, {}, true);
                var count = 0;
                while (true) {
                    count++;
                    var diff = (actPoint.width * 5) / 100;
                    actPoint.startX -= diff;
                    actPoint.endX += diff;
                    diff = (actPoint.height * 5) / 100;
                    actPoint.startY -= diff;
                    actPoint.endY += diff;
                    actPoint.width = actPoint.endX - actPoint.startX;
                    actPoint.height = actPoint.endY - actPoint.startY;
                    this.updateActiveObject(actPoint, parent.activeObj);
                    var object = { isIntersect: null, arr: null };
                    this.updateImgCanvasPoints();
                    this.isLinesIntersect(object);
                    Eif (object['arr'][0] || object['arr'][1] || object['arr'][2] || object['arr'][3] ||
                        actPoint.startX < 7.5 || actPoint.startY < 7.5 || count === 100) {
                        actPoint = ej2_base_1.extend({}, tempActPoint, {}, true);
                        diff = (actPoint.width * 1) / 100;
                        actPoint.startX += diff;
                        actPoint.endX -= diff;
                        diff = (actPoint.height * 1) / 100;
                        actPoint.startY += diff;
                        actPoint.endY -= diff;
                        actPoint.width = actPoint.endX - actPoint.startX;
                        actPoint.height = actPoint.endY - actPoint.startY;
                        this.updateActiveObject(actPoint, parent.activeObj);
                        break;
                    }
                    tempActPoint = ej2_base_1.extend({}, actPoint, {}, true);
                }
            }
        };
        Draw.prototype.updateActiveObject = function (actPoint, obj, isMouseMove, x, y) {
            var parent = this.parent;
            actPoint = actPoint ? actPoint : ej2_base_1.extend({}, parent.activeObj.activePoint, {}, true);
            obj = obj ? obj : ej2_base_1.extend({}, parent.activeObj, {}, true);
            actPoint.width = actPoint.endX - actPoint.startX;
            actPoint.height = actPoint.endY - actPoint.startY;
            var startX = actPoint.startX, startY = actPoint.startY, endX = actPoint.endX, endY = actPoint.endY, width = actPoint.width, height = actPoint.height;
            x = x ? x : 0;
            y = y ? y : 0;
            var horCircleWidth = width / 2;
            var verCircleHeight = height / 2;
            var radius = 7.5;
            obj.horTopLine = { startX: startX + x, startY: startY - y,
                endX: endX + x, endY: endY + y };
            obj.horBottomLine = { startX: startX - x, startY: endY - y,
                endX: endX - x, endY: endY + y };
            obj.verLeftLine = { startX: startX + x, startY: startY - y,
                endX: startX - y, endY: endY - y };
            obj.verRightLine = { startX: endX + x, startY: startY + y,
                endX: endX - x, endY: endY + y };
            obj.topLeftCircle = { startX: startX, startY: startY,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            obj.topCenterCircle = { startX: startX + horCircleWidth, startY: startY,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            obj.topRightCircle = { startX: endX, startY: startY,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            obj.centerLeftCircle = { startX: startX, startY: startY + verCircleHeight,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            obj.centerRightCircle = { startX: endX, startY: startY + verCircleHeight,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            obj.bottomLeftCircle = { startX: startX, startY: endY,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            obj.bottomCenterCircle = { startX: startX + horCircleWidth, startY: endY,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            obj.bottomRightCircle = { startX: endX, startY: endY,
                radius: obj.horTopLine.endX ? (radius) : 0 };
            if (obj.rotatedAngle === 0) {
                obj.rotationCirclePoint = { x: obj.bottomCenterCircle.startX,
                    y: obj.bottomCenterCircle.startY + 25 };
                obj.rotationCirclePoint.ratioX = (obj.rotationCirclePoint.x - parent.img.destLeft) / parent.img.destWidth;
                obj.rotationCirclePoint.ratioY = (obj.rotationCirclePoint.y - parent.img.destTop) / parent.img.destHeight;
            }
            obj.activePoint = actPoint;
            Eif (ej2_base_1.isNullOrUndefined(isMouseMove)) {
                parent.activeObj = ej2_base_1.extend({}, obj, {}, true);
            }
        };
        Draw.prototype.drawOuterSelection = function (canvasDraw, isCropCircle) {
            var splitWords;
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var actObj = parent.activeObj;
            canvasDraw.lineWidth = (0.5);
            var tempObj = ej2_base_1.extend({}, actObj, {}, true);
            if (actObj.shape) {
                splitWords = actObj.shape.split('-');
            }
            if (((splitWords && splitWords[0] === 'crop') || actObj.shape === undefined) && !isCropCircle) {
                this.upperContext.fillStyle = 'rgb(0, 0, 0, 0.25)';
                this.upperContext.fillRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
                this.upperContext.clearRect(actPoint.startX, actPoint.startY, actPoint.width, actPoint.height);
            }
            canvasDraw.strokeStyle = parent.themeColl[parent.theme]['primaryColor'];
            canvasDraw.fillStyle = parent.themeColl[parent.theme]['secondaryColor'];
            var degree;
            if (tempObj.shapeDegree === 0) {
                degree = parent.transform.degree;
            }
            else {
                degree = parent.transform.degree - tempObj.shapeDegree;
            }
            Iif (degree < 0) {
                degree = 360 + degree;
            }
            if (actObj.shape === 'arrow' || actObj.shape === 'line') {
                canvasDraw.beginPath();
                canvasDraw.moveTo(actPoint.startX, actPoint.startY);
                canvasDraw.lineTo(actPoint.endX, actPoint.endY);
                canvasDraw.stroke();
            }
            else if (actObj.shape === 'path') {
                canvasDraw.beginPath();
                var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                Eif (activeObj.pointColl[0]) {
                    canvasDraw.moveTo(activeObj.pointColl[0].x, activeObj.pointColl[0].y);
                    Eif (activeObj.pointColl.length > 1) {
                        for (var i = 1, len = activeObj.pointColl.length; i < len; i++) {
                            actPoint.endX = activeObj.pointColl[i].x;
                            actPoint.endY = activeObj.pointColl[i].y;
                            canvasDraw.lineTo(actPoint.endX, actPoint.endY);
                        }
                    }
                }
                var obj = { shape: null };
                parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
                Iif (obj['shape'] === 'path') {
                    parent.activeObj = actObj = activeObj;
                }
                canvasDraw.lineTo(actPoint.endX, actPoint.endY);
                canvasDraw.stroke();
            }
            else {
                this.drawCornerCircles(canvasDraw);
            }
            if (parent.selectionSettings.showCircle && (splitWords === undefined || splitWords[0] !== 'crop')) {
                var strokeColor = canvasDraw.strokeStyle;
                var fillColor = canvasDraw.fillStyle;
                canvasDraw.strokeStyle = parent.selectionSettings.strokeColor;
                canvasDraw.fillStyle = parent.selectionSettings.fillColor;
                if (actObj.shape === 'text') {
                    canvasDraw.lineWidth *= 2;
                    canvasDraw.beginPath();
                    this.drawRotationArcLine(canvasDraw);
                    canvasDraw.lineTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
                    canvasDraw.stroke();
                    canvasDraw.fill();
                    canvasDraw.closePath();
                    canvasDraw.beginPath();
                    canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
                    canvasDraw.arc(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
                    canvasDraw.stroke();
                    canvasDraw.fill();
                    canvasDraw.closePath();
                    canvasDraw.lineWidth /= 2;
                }
                else {
                    if (parent.activeObj.shape !== 'redact') {
                        this.drawCenterCircles(canvasDraw);
                    }
                }
                canvasDraw.strokeStyle = strokeColor;
                canvasDraw.fillStyle = fillColor;
            }
            tempObj.rotationCircleLine = actObj.rotationCircleLine;
            parent.activeObj = ej2_base_1.extend({}, tempObj, {}, true);
        };
        Draw.prototype.drawArrowHead = function (canvasDraw, isStartHead) {
            var headType = isStartHead ? this.parent.activeObj.start : this.parent.activeObj.end;
            switch (headType) {
                case 'arrowSolid':
                    isStartHead ? this.arrowSolid(canvasDraw, true) : this.arrowSolid(canvasDraw, false);
                    break;
                case 'arrow':
                    isStartHead ? this.arrow(canvasDraw, true) : this.arrow(canvasDraw, false);
                    break;
                case 'circleSolid':
                    isStartHead ? this.arrowCircleSolid(canvasDraw, true) : this.arrowCircleSolid(canvasDraw, false);
                    break;
                case 'circle':
                    isStartHead ? this.arrowCircle(canvasDraw, true) : this.arrowCircle(canvasDraw, false);
                    break;
                case 'bar':
                    isStartHead ? this.arrowBar(canvasDraw, true) : this.arrowBar(canvasDraw, false);
                    break;
                case 'square':
                case 'squareSolid':
                    isStartHead ? this.arrowSquareStart(canvasDraw) : this.arrowSquareEnd(canvasDraw);
                    break;
            }
        };
        Draw.prototype.drawShapeObj = function (canvas, shape, saveContext, isPreventSelection) {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var actObj = parent.activeObj;
            var _a = actObj.strokeSettings, strokeColor = _a.strokeColor, fillColor = _a.fillColor, strokeWidth = _a.strokeWidth;
            var currentShape = shape !== undefined ? shape : parent.currObjType.shape;
            parent.currObjType.shape = currentShape;
            var canvasDraw;
            if (canvas.toLowerCase() === 'original') {
                canvasDraw = this.lowerContext;
            }
            else if (canvas.toLowerCase() === 'duplicate') {
                canvasDraw = this.upperContext;
            }
            else Eif (saveContext) {
                canvasDraw = saveContext;
            }
            var shapeType = parent.currObjType.shape.toLowerCase();
            var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image', 'redact'];
            if (shapeColl.indexOf(shapeType) !== -1) {
                actObj.shape = parent.currObjType.shape;
            }
            canvasDraw.strokeStyle = strokeColor;
            if (shape === 'text' || shape === 'freehanddraw') {
                canvasDraw.fillStyle = strokeColor;
            }
            else {
                canvasDraw.fillStyle = fillColor;
            }
            var horLineWidth = actPoint.width / 3;
            var verLineHeight = actPoint.height / 3;
            var selectionWidth = actPoint.endX - actPoint.startX;
            var selectionHeight = actPoint.endY - actPoint.startY;
            this.rotateContext('initial', canvasDraw);
            var degree;
            var tempFillStyle = canvasDraw.fillStyle;
            var activeObj;
            switch (parent.currObjType.shape.toLowerCase()) {
                case 'rectangle':
                    this.drawSquareLines(canvasDraw);
                    if (ej2_base_1.isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
                        this.drawOuterSelection(canvasDraw);
                    }
                    break;
                case 'redact':
                    this.drawRedact(canvasDraw, actObj);
                    if (ej2_base_1.isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
                        this.drawOuterSelection(canvasDraw);
                    }
                    parent.currObjType.isRedact = true;
                    break;
                case 'ellipse':
                    selectionWidth = Math.abs(selectionWidth);
                    selectionHeight = Math.abs(selectionHeight);
                    canvasDraw.beginPath();
                    canvasDraw.ellipse(actPoint.startX + (selectionWidth / 2), actPoint.startY + (selectionHeight / 2), selectionWidth / 2, selectionHeight / 2, 0, 0, 2 * Math.PI, false);
                    if (fillColor !== '') {
                        canvasDraw.fillStyle = fillColor;
                        canvasDraw.fill();
                    }
                    canvasDraw.ellipse(actPoint.startX + (selectionWidth / 2), actPoint.startY + (selectionHeight / 2), Math.abs((selectionWidth / 2) - (strokeWidth)), Math.abs((selectionHeight / 2) - (strokeWidth)), 0, 0, 2 * Math.PI, false);
                    canvasDraw.fillStyle = strokeColor;
                    canvasDraw.fill('evenodd');
                    canvasDraw.closePath();
                    if (ej2_base_1.isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
                        this.drawOuterSelection(canvasDraw);
                    }
                    break;
                case 'crop-circle':
                    this.shapeCircle(canvasDraw, selectionWidth, selectionHeight);
                    break;
                case 'line':
                    this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
                    if (ej2_base_1.isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
                        this.drawOuterSelection(canvasDraw);
                    }
                    break;
                case 'arrow':
                    if (actObj.shapeDegree === 0) {
                        degree = parent.transform.degree;
                    }
                    else {
                        degree = parent.transform.degree - actObj.shapeDegree;
                    }
                    Iif (degree < 0) {
                        degree = 360 + degree;
                    }
                    canvasDraw.fillStyle = canvasDraw.strokeStyle;
                    Iif (ej2_base_1.isNullOrUndefined(actObj.triangleDirection)) {
                        actObj.triangleDirection = 'right';
                    }
                    Iif (ej2_base_1.isNullOrUndefined(actObj.start)) {
                        actObj.start = 'none';
                    }
                    Iif (ej2_base_1.isNullOrUndefined(actObj.end)) {
                        actObj.end = 'arrowSolid';
                    }
                    this.drawArrowHead(canvasDraw, true);
                    this.drawArrowHead(canvasDraw, false);
                    if (actObj.end === 'none' && actObj.start !== 'circle' && actObj.start !== 'square') {
                        this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
                    }
                    canvasDraw.fillStyle = tempFillStyle;
                    if (ej2_base_1.isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
                        this.drawOuterSelection(canvasDraw);
                    }
                    break;
                case 'path':
                    activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                    Eif (activeObj.pointColl.length > 1) {
                        var obj = { shape: null };
                        parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
                        Iif (obj['shape'] === 'path' && parent.isShapeDrawing) {
                            var nextPoint = { x: 0, y: 0 };
                            for (var i = 0, len = activeObj.pointColl.length; i < len; i++) {
                                if (ej2_base_1.isNullOrUndefined(activeObj.pointColl[i + 1])) {
                                    nextPoint.x = activeObj.activePoint.endX;
                                    nextPoint.y = activeObj.activePoint.endY;
                                }
                                else {
                                    nextPoint.x = activeObj.pointColl[i + 1].x;
                                    nextPoint.y = activeObj.pointColl[i + 1].y;
                                }
                                actPoint.startX = activeObj.pointColl[i].x;
                                actPoint.startY = activeObj.pointColl[i].y;
                                actPoint.endX = nextPoint.x;
                                actPoint.endY = nextPoint.y;
                                parent.activeObj = this.updateWidthHeight(parent.activeObj);
                                this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
                                if (ej2_base_1.Browser.isDevice) {
                                    activeObj.activePoint.endX = nextPoint.x;
                                    activeObj.activePoint.endY = nextPoint.y;
                                }
                            }
                        }
                        else {
                            for (var i = 1, len = activeObj.pointColl.length; i < len; i++) {
                                actPoint.startX = activeObj.pointColl[i - 1].x;
                                actPoint.startY = activeObj.pointColl[i - 1].y;
                                actPoint.endX = activeObj.pointColl[i].x;
                                actPoint.endY = activeObj.pointColl[i].y;
                                parent.activeObj = this.updateWidthHeight(parent.activeObj);
                                this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
                            }
                        }
                        parent.activeObj = actObj = activeObj;
                    }
                    else {
                        this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
                    }
                    if (canvasDraw === this.upperContext) {
                        this.drawOuterSelection(canvasDraw);
                    }
                    break;
                case 'text':
                    this.shapeText(canvasDraw);
                    break;
                case 'image':
                    this.shapeImage(canvasDraw);
                    if (ej2_base_1.isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
                        this.drawOuterSelection(canvasDraw);
                    }
                    break;
                case 'crop-square':
                case 'crop-3:4':
                case 'crop-4:3':
                case 'crop-6:9':
                case 'crop-9:6':
                case 'crop-9:16':
                case 'crop-16:9':
                    Iif (canvasDraw === this.lowerContext) {
                        canvasDraw = this.upperContext;
                    }
                    this.drawSelection(horLineWidth, verLineHeight);
                    parent.currObjType.shape = '';
                    break;
                default:
                    this.drawSelection(horLineWidth, verLineHeight);
                    break;
            }
            this.rotateContext('reverse', canvasDraw);
        };
        Draw.prototype.updatePoints = function () {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop;
            actPoint.startX += destLeft;
            actPoint.startY += destTop;
            actPoint.endX += destLeft;
            actPoint.endY += destTop;
            parent.activeObj = this.updateWidthHeight(parent.activeObj);
        };
        Draw.prototype.updateWidthHeight = function (obj) {
            var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            obj.activePoint.width = endX - startX;
            obj.activePoint.height = endY - startY;
            return obj;
        };
        Draw.prototype.drawCornerCircles = function (canvasDraw) {
            var parent = this.parent;
            var tempObj = parent.activeObj;
            canvasDraw.beginPath();
            canvasDraw.rect(tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height);
            canvasDraw.stroke();
            canvasDraw.closePath();
            Eif (parent.selectionSettings.showCircle) {
                var strokeColor = canvasDraw.strokeStyle;
                var fillColor = canvasDraw.fillStyle;
                canvasDraw.strokeStyle = parent.selectionSettings.strokeColor;
                canvasDraw.fillStyle = parent.selectionSettings.fillColor;
                canvasDraw.lineWidth *= 2;
                canvasDraw.beginPath();
                canvasDraw.moveTo(tempObj.topLeftCircle.startX, tempObj.topLeftCircle.startY);
                canvasDraw.arc(tempObj.topLeftCircle.startX, tempObj.topLeftCircle.startY, tempObj.topLeftCircle.radius, 0, 2 * Math.PI);
                canvasDraw.moveTo(tempObj.topRightCircle.startX, tempObj.topRightCircle.startY);
                canvasDraw.arc(tempObj.topRightCircle.startX, tempObj.topRightCircle.startY, tempObj.topRightCircle.radius, 0, 2 * Math.PI);
                canvasDraw.moveTo(tempObj.bottomLeftCircle.startX, tempObj.bottomLeftCircle.startY);
                canvasDraw.arc(tempObj.bottomLeftCircle.startX, tempObj.bottomLeftCircle.startY, tempObj.bottomLeftCircle.radius, 0, 2 * Math.PI);
                canvasDraw.moveTo(tempObj.bottomRightCircle.startX, tempObj.bottomRightCircle.startY);
                canvasDraw.arc(tempObj.bottomRightCircle.startX, tempObj.bottomRightCircle.startY, tempObj.bottomRightCircle.radius, 0, 2 * Math.PI);
                canvasDraw.stroke();
                canvasDraw.fill();
                canvasDraw.closePath();
                canvasDraw.lineWidth /= 2;
                canvasDraw.strokeStyle = strokeColor;
                canvasDraw.fillStyle = fillColor;
            }
        };
        Draw.prototype.drawCenterCircles = function (canvasDraw) {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var actObj = parent.activeObj;
            canvasDraw.lineWidth *= 2;
            canvasDraw.beginPath();
            if (actObj.shape === 'arrow' || actObj.shape === 'line') {
                canvasDraw.moveTo(actPoint.startX, actPoint.startY);
                canvasDraw.arc(actPoint.startX, actPoint.startY, actObj.topCenterCircle.radius, 0, 2 * Math.PI);
                canvasDraw.moveTo(actPoint.endX, actPoint.endY);
                canvasDraw.arc(actPoint.endX, actPoint.endY, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
            }
            else if (actObj.shape === 'path') {
                var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                Eif (activeObj.pointColl.length > 1) {
                    for (var i = 1, len = activeObj.pointColl.length; i < len; i++) {
                        actPoint.startX = activeObj.pointColl[i - 1].x;
                        actPoint.startY = activeObj.pointColl[i - 1].y;
                        actPoint.endX = activeObj.pointColl[i].x;
                        actPoint.endY = activeObj.pointColl[i].y;
                        canvasDraw.moveTo(actPoint.startX, actPoint.startY);
                        canvasDraw.arc(actPoint.startX, actPoint.startY, actObj.topCenterCircle.radius, 0, 2 * Math.PI);
                        canvasDraw.moveTo(actPoint.endX, actPoint.endY);
                        canvasDraw.arc(actPoint.endX, actPoint.endY, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
                    }
                }
                var obj = { shape: null };
                parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
                Iif (obj['shape'] === 'path') {
                    parent.activeObj = actObj = activeObj;
                }
                canvasDraw.moveTo(actPoint.startX, actPoint.startY);
                canvasDraw.arc(actPoint.startX, actPoint.startY, actObj.topCenterCircle.radius, 0, 2 * Math.PI);
                canvasDraw.moveTo(actPoint.endX, actPoint.endY);
                canvasDraw.arc(actPoint.endX, actPoint.endY, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
            }
            else {
                this.drawRotationArcLine(canvasDraw);
                canvasDraw.lineTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
            }
            canvasDraw.stroke();
            canvasDraw.fill();
            canvasDraw.closePath();
            if (actObj.shape !== 'arrow' && actObj.shape !== 'line' && actObj.shape !== 'path') {
                canvasDraw.beginPath();
                canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y);
                canvasDraw.arc(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y, actObj.bottomCenterCircle.radius, 0, 2 * Math.PI);
                canvasDraw.stroke();
                canvasDraw.fill();
                canvasDraw.closePath();
            }
            canvasDraw.lineWidth /= 2;
        };
        Draw.prototype.drawRotationArcLine = function (canvasDraw) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            if (ej2_base_1.isNullOrUndefined(actObj.rotationCircleLine)) {
                actObj.rotationCircleLine = 22.5;
            }
            var degree;
            var isHorizontalflip = false;
            var isVerticalflip = false;
            if (actObj.shapeDegree === 0) {
                degree = parent.transform.degree;
            }
            else {
                degree = parent.transform.degree - actObj.shapeDegree;
            }
            Iif (degree < 0) {
                degree = 360 + degree;
            }
            Eif (actObj.flipObjColl) {
                for (var i = 0, len = actObj.flipObjColl.length; i < len; i++) {
                    var flipStr = actObj.flipObjColl[i].toLowerCase();
                    if (flipStr === 'horizontal') {
                        isHorizontalflip = true;
                    }
                    else Eif (flipStr === 'vertical') {
                        isVerticalflip = true;
                    }
                }
            }
            switch (degree) {
                case 0:
                case 360:
                    if (isVerticalflip) {
                        actObj.rotationCirclePoint = { x: actObj.topCenterCircle.startX,
                            y: actObj.topCenterCircle.startY - actObj.rotationCircleLine };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y + actObj.rotationCircleLine);
                    }
                    else {
                        actObj.rotationCirclePoint = { x: actObj.bottomCenterCircle.startX,
                            y: actObj.bottomCenterCircle.startY + actObj.rotationCircleLine };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y - actObj.rotationCircleLine);
                    }
                    break;
                case 90:
                case -270:
                    if (isHorizontalflip) {
                        actObj.rotationCirclePoint = { x: actObj.centerRightCircle.startX +
                                actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x - actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
                    }
                    else {
                        actObj.rotationCirclePoint = { x: actObj.centerLeftCircle.startX -
                                actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x + actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
                    }
                    break;
                case 180:
                case -180:
                    if (isVerticalflip) {
                        actObj.rotationCirclePoint = { x: actObj.bottomCenterCircle.startX,
                            y: actObj.bottomCenterCircle.startY + actObj.rotationCircleLine };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y - actObj.rotationCircleLine);
                    }
                    else {
                        actObj.rotationCirclePoint = { x: actObj.topCenterCircle.startX,
                            y: actObj.topCenterCircle.startY - actObj.rotationCircleLine };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x, actObj.rotationCirclePoint.y + actObj.rotationCircleLine);
                    }
                    break;
                case 270:
                case -90:
                    if (isHorizontalflip) {
                        actObj.rotationCirclePoint = { x: actObj.centerLeftCircle.startX -
                                actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x + actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
                    }
                    else {
                        actObj.rotationCirclePoint = { x: actObj.centerRightCircle.startX +
                                actObj.rotationCircleLine, y: actObj.centerLeftCircle.startY };
                        canvasDraw.moveTo(actObj.rotationCirclePoint.x - actObj.rotationCircleLine, actObj.rotationCirclePoint.y);
                    }
                    break;
            }
        };
        Draw.prototype.drawSquareLines = function (canvasDraw) {
            var splitWords;
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
            var _b = actObj.strokeSettings, fillColor = _b.fillColor, strokeColor = _b.strokeColor, strokeWidth = _b.strokeWidth, radius = _b.radius;
            Eif (actObj.shape) {
                splitWords = actObj.shape.split('-');
            }
            Iif (splitWords[0] === 'crop') {
                canvasDraw.strokeStyle = '#fff';
            }
            else {
                canvasDraw.strokeStyle = strokeColor;
            }
            canvasDraw.beginPath();
            var obj = { width: 0, height: 0 };
            var ratio = { width: 1, height: 1 };
            parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
                value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
            ratio = obj;
            var isTempCanvas = canvasDraw.canvas.id === parent.element.id + '_tempCanvas';
            var zoomFactor = parent.transform.zoomFactor;
            var baseRadius = isTempCanvas ? radius * 10 * ((ratio.width + ratio.height) / 2) : radius * 10;
            var adjustedRadius = baseRadius + (baseRadius * zoomFactor);
            if (radius !== null) {
                Iif (parent.isSafari) {
                    this.drawRoundedRect(canvasDraw, startX, startY, width, height, adjustedRadius);
                }
                else {
                    canvasDraw.roundRect(startX, startY, width, height, adjustedRadius);
                }
            }
            else {
                canvasDraw.rect(startX, startY, width, height);
            }
            if (fillColor !== '') {
                canvasDraw.fillStyle = fillColor;
                canvasDraw.fill();
            }
            if (radius !== null) {
                Iif (parent.isSafari) {
                    this.drawRoundedRect(canvasDraw, startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth), adjustedRadius);
                }
                else {
                    canvasDraw.roundRect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth), adjustedRadius);
                }
            }
            else {
                canvasDraw.rect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth));
            }
            canvasDraw.fillStyle = strokeColor;
            canvasDraw.fill('evenodd');
            canvasDraw.closePath();
        };
        Draw.prototype.drawRoundedRect = function (canvasDraw, startX, startY, width, height, radius) {
            var rectRadius = Math.max(0, Math.min(radius, width / 2, height / 2));
            canvasDraw.moveTo(startX + rectRadius, startY);
            canvasDraw.arcTo(startX + width, startY, startX + width, startY + height, rectRadius);
            canvasDraw.arcTo(startX + width, startY + height, startY, startY + height, rectRadius);
            canvasDraw.arcTo(startX, startY + height, startX, startY, rectRadius);
            canvasDraw.arcTo(startX, startY, startX + width, startY, rectRadius);
            canvasDraw.closePath();
        };
        Draw.prototype.drawSelection = function (horLineWidth, verLineHeight) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            this.upperContext.strokeStyle = parent.themeColl[parent.theme]['primaryColor'];
            this.upperContext.beginPath();
            actObj.horTopInnerLine = { startX: startX, startY: startY +
                    verLineHeight, endX: endX, endY: endY + verLineHeight };
            actObj.horBottomInnerLine = { startX: startX, startY: startY + (2 * verLineHeight), endX: endX, endY: endY + (2 * verLineHeight) };
            actObj.verLeftInnerLine = { startX: startX + horLineWidth,
                startY: startY, endX: startX + horLineWidth, endY: endY };
            actObj.verRightInnerLine = { startX: startX + (2 * horLineWidth),
                startY: startY, endX: startX + (2 * horLineWidth), endY: endY };
            this.upperContext.moveTo(actObj.horTopInnerLine.startX, actObj.horTopInnerLine.startY);
            this.upperContext.lineTo(actObj.horTopInnerLine.endX, actObj.horTopInnerLine.startY);
            this.upperContext.moveTo(actObj.horBottomInnerLine.startX, actObj.horBottomInnerLine.startY);
            this.upperContext.lineTo(actObj.horBottomInnerLine.endX, actObj.horBottomInnerLine.startY);
            this.upperContext.moveTo(actObj.verLeftInnerLine.startX, actObj.verLeftInnerLine.startY);
            this.upperContext.lineTo(actObj.verLeftInnerLine.endX, actObj.verLeftInnerLine.endY);
            this.upperContext.moveTo(actObj.verRightInnerLine.startX, actObj.verRightInnerLine.startY);
            this.upperContext.lineTo(actObj.verRightInnerLine.endX, actObj.verRightInnerLine.endY);
            this.upperContext.stroke();
            this.upperContext.closePath();
        };
        Draw.prototype.shapeCircle = function (canvasDraw, selectionWidth, selectionHeight) {
            var parent = this.parent;
            var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width;
            canvasDraw.strokeStyle = parent.themeColl[parent.theme]['primaryColor'];
            canvasDraw.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            canvasDraw.fillStyle = 'rgb(0, 0, 0, 0.25)';
            canvasDraw.fillRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            var tempWidth = canvasDraw.lineWidth;
            canvasDraw.lineWidth = (2);
            canvasDraw.beginPath();
            canvasDraw.ellipse(parent.activeObj.horTopLine.startX + (selectionWidth / 2), parent.activeObj.horTopLine.startY
                + (selectionHeight / 2), selectionWidth / 2, selectionHeight / 2, 0, 0, 2 * Math.PI, false);
            canvasDraw.stroke();
            canvasDraw.closePath();
            canvasDraw.save();
            canvasDraw.beginPath();
            canvasDraw.arc(((endX - startX) / 2) + startX, ((endY - startY) / 2) + startY, (width / 2), 0, Math.PI * 2);
            canvasDraw.closePath();
            canvasDraw.clip();
            canvasDraw.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            canvasDraw.restore();
            canvasDraw.lineWidth = tempWidth;
            this.drawOuterSelection(canvasDraw, true);
            parent.currObjType.shape = '';
        };
        Draw.prototype.shapeLine = function (canvasDraw, x1, y1, x2, y2) {
            var tempLineWidth = canvasDraw.lineWidth;
            canvasDraw.lineWidth = (this.parent.activeObj.strokeSettings.strokeWidth);
            canvasDraw.beginPath();
            canvasDraw.moveTo(x1, y1);
            canvasDraw.lineTo(x2, y2);
            canvasDraw.stroke();
            canvasDraw.lineWidth = tempLineWidth;
        };
        Draw.prototype.manipulateSaveCtx = function (canvasDraw, x, y) {
            if (canvasDraw !== this.lowerContext && canvasDraw !== this.upperContext) {
                var obj = { width: 0, height: 0 };
                this.parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
                    value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
                var ratio = obj;
                Eif (x) {
                    x *= (ratio.width);
                }
                Eif (y) {
                    y *= (ratio.height);
                }
            }
            return { x: x, y: y };
        };
        Draw.prototype.arrow = function (canvasDraw, start) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var strWidth = actObj.strokeSettings.strokeWidth;
            canvasDraw.lineWidth = strWidth;
            var x = this.arrowDimension['arrow']['width'];
            var y = this.arrowDimension['arrow']['height'];
            var point = this.manipulateSaveCtx(canvasDraw, x, y);
            x = point.x + strWidth;
            y = point.y + strWidth;
            this.dx = endX - startX;
            this.dy = endY - startY;
            canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
            var angle = Math.atan2(this.dy, this.dx);
            var isStartArrow = actObj.start === 'arrow';
            var isEndArrow = actObj.end === 'arrow';
            var isEndCircleOrSquare = actObj.end === 'circle' || actObj.end === 'square';
            var isStartCircleOrSquare = actObj.start === 'circle' || actObj.start === 'square';
            Eif ((start && actObj.triangleDirection === 'left' || actObj.triangleDirection === 'right') &&
                ((isStartArrow && actObj.end === 'none') || (isStartArrow && !isEndCircleOrSquare && !isStartCircleOrSquare)) ||
                (!start && (isEndArrow && actObj.start === 'none' || !isStartArrow && !isEndCircleOrSquare && !isStartCircleOrSquare))) {
                this.shapeLine(canvasDraw, startX, startY, endX, endY);
            }
            if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
                canvasDraw.translate(endX, endY);
                canvasDraw.rotate(angle);
                this.shapeLine(canvasDraw, 0, 0, -x, y / 2);
                this.shapeLine(canvasDraw, 0, 0, -x, -y / 2);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-endX, -endY);
            }
            else Eif ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
                canvasDraw.translate(startX, startY);
                canvasDraw.rotate(angle);
                this.shapeLine(canvasDraw, 0, 0, x, y / 2);
                this.shapeLine(canvasDraw, 0, 0, x, -y / 2);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-startX, -startY);
            }
        };
        Draw.prototype.arrowSolid = function (canvasDraw, start) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var strWidth = actObj.strokeSettings.strokeWidth;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var x = this.arrowDimension['arrowSolid']['width'];
            var y = this.arrowDimension['arrowSolid']['height'];
            var point = this.manipulateSaveCtx(canvasDraw, x, y);
            x = point.x + strWidth;
            y = point.y + strWidth;
            this.dx = endX - startX;
            this.dy = endY - startY;
            var angle = Math.atan2(this.dy, this.dx);
            var isStartArrowSolid = actObj.start === 'arrowSolid';
            var isEndArrowSolid = actObj.end === 'arrowSolid';
            var isEndCircleOrSquare = actObj.end === 'circle' || actObj.end === 'square';
            var isStartCircleOrSquare = actObj.start === 'circle' || actObj.start === 'square';
            if ((start && (isStartArrowSolid && actObj.end === 'none') || (isStartArrowSolid && !isEndCircleOrSquare && !isStartCircleOrSquare)) ||
                (!start && (isEndArrowSolid && actObj.start === 'none' || !isStartArrowSolid && !isEndCircleOrSquare && !isStartCircleOrSquare))) {
                this.shapeLine(canvasDraw, startX, startY, endX, endY);
            }
            if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
                canvasDraw.translate(endX, endY);
                canvasDraw.rotate(angle);
                canvasDraw.beginPath();
                canvasDraw.moveTo(strWidth, 0);
                canvasDraw.lineTo(-x + y / 2, y / 2);
                canvasDraw.lineTo(-x + y / 2, -y / 2);
                canvasDraw.closePath();
                canvasDraw.fill();
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-endX, -endY);
                actObj.rotatedAngle = angle;
            }
            else Eif ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
                canvasDraw.translate(startX, startY);
                canvasDraw.rotate(angle);
                canvasDraw.beginPath();
                canvasDraw.moveTo(0 - strWidth, 0);
                canvasDraw.lineTo(x - y / 2, y / 2);
                canvasDraw.lineTo(x - y / 2, -y / 2);
                canvasDraw.closePath();
                canvasDraw.fill();
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-startX, -startY);
                actObj.rotatedAngle = angle;
            }
        };
        Draw.prototype.arrowSquareStart = function (canvasDraw) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var strWidth = actObj.strokeSettings.strokeWidth;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var isStartSquare = actObj.start === 'square';
            var isEndCircle = actObj.end === 'circle';
            var isStartSquareSolid = actObj.start === 'squareSolid';
            var isEndCircleSolid = actObj.end === 'circleSolid';
            if ((isStartSquare && actObj.end === 'none') || (isStartSquare && !isEndCircle && actObj.start !== 'square') ||
                (isStartSquareSolid && isEndCircleSolid)) {
                this.shapeLine(canvasDraw, startX, startY, endX, endY);
            }
            canvasDraw.lineWidth = (strWidth);
            canvasDraw.beginPath();
            canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
            var x = this.arrowDimension['square']['width'];
            var y = this.arrowDimension['square']['height'];
            var point = this.manipulateSaveCtx(canvasDraw, x, y);
            x = point.x + strWidth;
            y = point.y + strWidth;
            this.dx = endX - startX;
            this.dy = endY - startY;
            var angle = Math.atan2(this.dy, this.dx);
            if (actObj.triangleDirection === 'left') {
                canvasDraw.translate(endX, endY);
                canvasDraw.rotate(angle);
                Iif (actObj.start === 'squareSolid') {
                    canvasDraw.fillRect(-x + y / 2, -y / 2, x, y);
                }
                canvasDraw.strokeRect(-x + y / 2, -y / 2, x, y);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-endX, -endY);
                this.squareStartIntersectX1 = endX - (y / 2) * Math.cos(angle);
                this.squareStartIntersectY1 = endY - (y / 2) * Math.sin(angle);
                Iif (actObj.start === 'square' && actObj.end !== 'square' && actObj.end !== 'circle') {
                    this.shapeLine(canvasDraw, startX, startY, this.squareStartIntersectX1, this.squareStartIntersectY1);
                }
                else Iif (actObj.start === 'square' && actObj.end === 'circle') {
                    this.shapeLine(canvasDraw, this.endCircleIntersectX1, this.endCircleIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
                }
                else Iif (actObj.start === 'squareSolid' && actObj.end === 'squareSolid') {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
            }
            else Eif (actObj.triangleDirection === 'right') {
                canvasDraw.lineWidth = (strWidth);
                canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                if (actObj.start === 'squareSolid' && actObj.end === 'squareSolid') {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
                canvasDraw.translate(startX, startY);
                canvasDraw.rotate(angle);
                if (actObj.start === 'squareSolid') {
                    canvasDraw.fillRect(y / 2 - x, -y / 2, x, y);
                }
                canvasDraw.strokeRect(y / 2 - x, -y / 2, x, y);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-startX, -startY);
                actObj.rotatedAngle = angle;
                this.squareStartIntersectX1 = startX + (y / 2) * Math.cos(angle);
                this.squareStartIntersectY1 = startY + (y / 2) * Math.sin(angle);
                if (actObj.start === 'square' && actObj.end !== 'square' && actObj.end !== 'circle') {
                    this.shapeLine(canvasDraw, endX, endY, this.squareStartIntersectX1, this.squareStartIntersectY1);
                }
                Iif (actObj.start === 'square' && actObj.end === 'circle') {
                    this.shapeLine(canvasDraw, this.endCircleIntersectX1, this.endCircleIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
                }
            }
        };
        Draw.prototype.arrowSquareEnd = function (canvasDraw) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var strWidth = actObj.strokeSettings.strokeWidth;
            var x = this.arrowDimension['square']['width'];
            var y = this.arrowDimension['square']['height'];
            var point = this.manipulateSaveCtx(canvasDraw, x, y);
            x = point.x + strWidth;
            y = point.y + strWidth;
            this.dx = endX - startX;
            this.dy = endY - startY;
            var angle = Math.atan2(this.dy, this.dx);
            canvasDraw.lineWidth = (strWidth);
            if (actObj.triangleDirection === 'right') {
                canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                Iif (actObj.end === 'squareSolid' && actObj.start === 'none') {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
                canvasDraw.translate(endX, endY);
                canvasDraw.rotate(angle);
                if (actObj.end === 'squareSolid') {
                    canvasDraw.fillRect(-x + y / 2, -y / 2, x, y);
                }
                canvasDraw.strokeRect(-x + y / 2, -y / 2, x, y);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-endX, -endY);
                actObj.rotatedAngle = angle;
                this.squareEndIntersectX1 = endX - (y / 2) * Math.cos(angle);
                this.squareEndIntersectY1 = endY - (y / 2) * Math.sin(angle);
                if (actObj.end === 'square' && actObj.start !== 'square' && actObj.start !== 'circle') {
                    this.shapeLine(canvasDraw, startX, startY, this.squareEndIntersectX1, this.squareEndIntersectY1);
                }
                else Iif (actObj.start === 'circle' && actObj.end === 'square') {
                    this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.startCircleIntersectX1, this.startCircleIntersectY1);
                }
                else if (actObj.start === 'square' && actObj.end === 'square') {
                    this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
                }
            }
            else Eif (actObj.triangleDirection === 'left') {
                canvasDraw.translate(startX, startY);
                canvasDraw.rotate(angle);
                Iif (actObj.end === 'squareSolid') {
                    canvasDraw.fillRect(y / 2 - x, -y / 2, x, y);
                }
                canvasDraw.strokeRect(y / 2 - x, -y / 2, x, y);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-startX, -startY);
                actObj.rotatedAngle = angle;
                this.squareEndIntersectX1 = startX + (y / 2) * Math.cos(angle);
                this.squareEndIntersectY1 = startY + (y / 2) * Math.sin(angle);
                Iif (actObj.end === 'square' && actObj.start !== 'square' && actObj.start !== 'circle') {
                    this.shapeLine(canvasDraw, endX, endY, this.squareEndIntersectX1, this.squareEndIntersectY1);
                }
                else Iif (actObj.start === 'circle' && actObj.end === 'square') {
                    this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.startCircleIntersectX1, this.startCircleIntersectY1);
                }
                else Eif (actObj.start === 'square' && actObj.end === 'square') {
                    this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
                }
                else if (actObj.end === 'squareSolid' && actObj.start === 'none') {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
            }
        };
        Draw.prototype.arrowCircle = function (canvasDraw, start) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var strWidth = actObj.strokeSettings.strokeWidth;
            if ((start && actObj.triangleDirection === 'left') ||
                (!start && actObj.triangleDirection === 'right')) {
                canvasDraw.lineWidth = strWidth;
                var circleRadius = this.arrowDimension['circle']['width'];
                var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
                circleRadius = point.x + strWidth;
                canvasDraw.beginPath();
                canvasDraw.arc(endX, endY, circleRadius, 0, 2 * Math.PI);
                canvasDraw.stroke();
                canvasDraw.closePath();
                this.dx = endX - startX;
                this.dy = endY - startY;
                var a = this.dx * this.dx + this.dy * this.dy;
                var b = 2 * (this.dx * (startX - endX) + this.dy * (startY - endY));
                var c = (startX - endX) * (startX - endX) + (startY - endY) *
                    (startY - endY) - circleRadius * circleRadius;
                var intersect = b * b - 4 * a * c;
                Eif (intersect >= 0) {
                    canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                    var t2 = (-b - Math.sqrt(intersect)) / (2 * a);
                    var intersectionX1 = startX + this.dx * t2;
                    var intersectionY1 = startY + this.dy * t2;
                    Iif (start) {
                        this.startCircleIntersectX1 = intersectionX1;
                        this.startCircleIntersectY1 = intersectionY1;
                        this.endCircleIntersectX1 = endX - this.dx * t2;
                        this.endCircleIntersectY1 = endY - this.dy * t2;
                        canvasDraw.beginPath();
                        canvasDraw.fill();
                        canvasDraw.beginPath();
                        if (actObj.start === 'circle' && actObj.end === 'circle') {
                            this.shapeLine(canvasDraw, this.startCircleIntersectX1, this.startCircleIntersectY1, this.endCircleIntersectX1, this.endCircleIntersectY1);
                        }
                        else if (actObj.start === 'circle' && actObj.end !== 'circle' && actObj.end !== 'square') {
                            this.shapeLine(canvasDraw, startX, startY, this.startCircleIntersectX1, this.startCircleIntersectY1);
                        }
                        canvasDraw.stroke();
                        canvasDraw.closePath();
                    }
                    else {
                        this.endCircleIntersectX1 = intersectionX1;
                        this.endCircleIntersectY1 = intersectionY1;
                        Eif (actObj.end === 'circle' && (actObj.start !== 'circle' && actObj.start !== 'square')) {
                            this.shapeLine(canvasDraw, startX, startY, this.endCircleIntersectX1, this.endCircleIntersectY1);
                        }
                    }
                }
                var angle = Math.atan2(this.dy, this.dx);
                parent.activeObj.rotatedAngle = angle;
            }
            else Eif ((start && actObj.triangleDirection === 'right') ||
                (!start && actObj.triangleDirection === 'left')) {
                canvasDraw.lineWidth = strWidth;
                var circleRadius = this.arrowDimension['circle']['width'];
                var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
                circleRadius = point.x + strWidth;
                canvasDraw.beginPath();
                canvasDraw.arc(startX, startY, circleRadius, 0, 2 * Math.PI);
                canvasDraw.stroke();
                canvasDraw.closePath();
                this.dx = startX - endX;
                this.dy = startY - endY;
                var a = this.dx * this.dx + this.dy * this.dy;
                var b = 2 * (this.dx * (endX - startX) + this.dy * (endY - startY));
                var c = (endX - startX) * (endX - startX) + (endY - startY) *
                    (endY - startY) - circleRadius * circleRadius;
                var intersect = b * b - 4 * a * c;
                Eif (intersect >= 0) {
                    canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                    var t2 = (-b - Math.sqrt(intersect)) / (2 * a);
                    var intersectionX1 = endX + this.dx * t2;
                    var intersectionY1 = endY + this.dy * t2;
                    Eif (start) {
                        this.startCircleIntersectX1 = intersectionX1;
                        this.startCircleIntersectY1 = intersectionY1;
                        this.endCircleIntersectX1 = startX - this.dx * t2;
                        this.endCircleIntersectY1 = startY - this.dy * t2;
                        Iif (actObj.start === 'circle' && actObj.end === 'circle') {
                            this.shapeLine(canvasDraw, this.endCircleIntersectX1, this.endCircleIntersectY1, this.startCircleIntersectX1, this.startCircleIntersectY1);
                        }
                        else Eif (actObj.start === 'circle' && actObj.end !== 'circle' && actObj.end !== 'square') {
                            this.shapeLine(canvasDraw, endX, endY, this.startCircleIntersectX1, this.startCircleIntersectY1);
                        }
                    }
                    else {
                        this.endCircleIntersectX1 = intersectionX1;
                        this.endCircleIntersectY1 = intersectionY1;
                        canvasDraw.beginPath();
                        canvasDraw.fill();
                        canvasDraw.beginPath();
                        if (actObj.end === 'circle' && (actObj.start !== 'circle' && actObj.start !== 'square')) {
                            this.shapeLine(canvasDraw, endX, endY, this.endCircleIntersectX1, this.endCircleIntersectY1);
                        }
                    }
                }
                var angle = Math.atan2(this.dy, this.dx);
                parent.activeObj.rotatedAngle = angle;
            }
        };
        Draw.prototype.arrowCircleSolid = function (canvasDraw, start) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var isStartCircleSolid = actObj.start === 'circleSolid';
            var strWidth = actObj.strokeSettings.strokeWidth;
            if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
                canvasDraw.lineWidth = strWidth;
                canvasDraw.beginPath();
                canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                Iif ((start && (isStartCircleSolid && actObj.end === 'none') ||
                    (isStartCircleSolid && actObj.end !== 'circle' && actObj.end !== 'square')) ||
                    (!start && (actObj.end === 'circleSolid' && actObj.start === 'none'))) {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
                var circleRadius = this.arrowDimension['circle']['width'];
                var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
                circleRadius = point.x + strWidth;
                this.dx = endX - startX;
                this.dy = endY - startY;
                canvasDraw.save();
                canvasDraw.beginPath();
                canvasDraw.arc(endX, endY, circleRadius, 0, 2 * Math.PI);
                canvasDraw.stroke();
                canvasDraw.fill();
                canvasDraw.closePath();
                actObj.rotatedAngle = Math.atan2(this.dy, this.dx);
            }
            else Eif ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
                canvasDraw.lineWidth = strWidth;
                canvasDraw.beginPath();
                canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                Eif ((start && (isStartCircleSolid && actObj.end === 'none') ||
                    (isStartCircleSolid && actObj.end !== 'circle' && actObj.end !== 'square')) ||
                    !start && (actObj.end === 'circleSolid' && actObj.start === 'none')) {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
                var circleRadius = this.arrowDimension['circle']['width'];
                var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
                circleRadius = point.x + strWidth;
                this.dx = endX - startX;
                this.dy = endY - startY;
                canvasDraw.save();
                canvasDraw.beginPath();
                canvasDraw.arc(startX, startY, circleRadius, 0, 2 * Math.PI);
                canvasDraw.stroke();
                canvasDraw.fill();
                canvasDraw.closePath();
                actObj.rotatedAngle = Math.atan2(this.dy, this.dx);
            }
        };
        Draw.prototype.arrowBar = function (canvasDraw, start) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var strWidth = actObj.strokeSettings.strokeWidth;
            if ((start && actObj.triangleDirection === 'left') || (!start && actObj.triangleDirection === 'right')) {
                canvasDraw.lineWidth = strWidth;
                canvasDraw.beginPath();
                canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                Eif ((start && (actObj.start === 'bar' && actObj.end === 'none') ||
                    (actObj.start === 'bar' && (actObj.end !== 'circle' && actObj.end !== 'square'))) ||
                    (!start && ((actObj.end === 'bar' && actObj.start === 'none') ||
                        (actObj.end === 'bar' && (actObj.start !== 'circle' && actObj.start !== 'square'))))) {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
                var x = this.arrowDimension['bar']['width'];
                var y = this.arrowDimension['bar']['height'];
                var point = this.manipulateSaveCtx(canvasDraw, x, y);
                x = point.x + strWidth;
                y = point.y + strWidth;
                this.dx = endX - startX;
                this.dy = endY - startY;
                var angle = Math.atan2(this.dy, this.dx);
                canvasDraw.translate(endX, endY);
                canvasDraw.rotate(angle);
                canvasDraw.fillRect(-x + y / 4, -y / 2, x, y);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-endX, -endY);
                actObj.rotatedAngle = angle;
            }
            else Eif ((start && actObj.triangleDirection === 'right') || (!start && actObj.triangleDirection === 'left')) {
                canvasDraw.lineWidth = strWidth;
                canvasDraw.beginPath();
                canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                Eif ((start && (actObj.start === 'bar' && actObj.end === 'none')
                    || (actObj.start === 'bar' && (actObj.end !== 'circle' && actObj.end !== 'square'))) ||
                    (!start && (actObj.end === 'bar' && actObj.start === 'none'))) {
                    this.shapeLine(canvasDraw, startX, startY, endX, endY);
                }
                var x = this.arrowDimension['bar']['width'];
                var y = this.arrowDimension['bar']['height'];
                var point = this.manipulateSaveCtx(canvasDraw, x, y);
                x = point.x + strWidth;
                y = point.y + strWidth;
                this.dx = endX - startX;
                this.dy = endY - startY;
                var angle = Math.atan2(this.dy, this.dx);
                canvasDraw.translate(startX, startY);
                canvasDraw.rotate(angle);
                canvasDraw.fillRect(y / 4 - x, -y / 2, x, y);
                canvasDraw.rotate(-angle);
                canvasDraw.translate(-startX, -startY);
                parent.activeObj.rotatedAngle = angle;
            }
        };
        Draw.prototype.shapeImage = function (canvasDraw) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
            var ctx = actObj.imageCanvas.getContext('2d');
            if (canvasDraw === this.lowerContext && this.isImageApply) {
                var dimObj = { width: 0, height: 0 };
                parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false, value: { width: actObj
                            .imageElement.width, height: actObj.imageElement.height, obj: dimObj, isImgShape: null } });
                Iif (width < (dimObj['width'] / 5) || height < (dimObj['height'] / 5)) {
                    ctx.clearRect(0, 0, actObj.imageCanvas.width, actObj.imageCanvas.height);
                    parent.notify('selection', { prop: 'applyTransformToImg', onPropertyChange: false, value: { ctx: ctx } });
                    parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
                    this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                    parent.notify('selection', { prop: 'setImageClarity', onPropertyChange: false, value: { bool: false } });
                    this.isImageApply = false;
                }
            }
            var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
            imgPoint.width = width;
            imgPoint.height = height;
            Iif (actObj.flipObjColl.length === 4) {
                actObj.flipObjColl = [];
                actObj.shapeFlip = '';
            }
            imgPoint.startX = ((width - imgPoint.width) / 2) + startX;
            imgPoint.startY = ((height - imgPoint.height) / 2) + startY;
            var temp = canvasDraw.globalAlpha;
            canvasDraw.globalAlpha = actObj.opacity;
            if (actObj.rotateFlipColl && actObj.rotateFlipColl.length > 0) {
                this.rotateImage(canvasDraw);
            }
            else {
                canvasDraw.drawImage(actObj.imageCanvas, imgPoint.startX, imgPoint.startY, imgPoint.width, imgPoint.height);
            }
            canvasDraw.globalAlpha = temp;
            parent.currObjType.isText = false;
        };
        Draw.prototype.shapeText = function (canvasDraw) {
            var parent = this.parent;
            var filter = canvasDraw.filter;
            var actObj = parent.activeObj;
            var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
            var rows = actObj.keyHistory.split('\n');
            var _b = actObj.textSettings, fontFamily = _b.fontFamily, bold = _b.bold, italic = _b.italic, underline = _b.underline, strikethrough = _b.strikethrough;
            var fontSize = actObj.textSettings.fontSize;
            var lHeight = fontSize + fontSize * 0.25;
            var lineHeight = ((lHeight * rows.length) - (fontSize * rows.length)) / rows.length;
            canvasDraw.filter = 'none';
            var tempFill = canvasDraw.fillStyle;
            if (actObj.strokeSettings.fillColor !== '') {
                canvasDraw.fillStyle = actObj.strokeSettings.fillColor;
                canvasDraw.fillRect(actObj.activePoint.startX, actObj.activePoint.startY, actObj.activePoint.width, actObj.activePoint.height);
            }
            canvasDraw.fillStyle = tempFill;
            for (var i = 0; i < rows.length; i++) {
                var text = rows[i];
                var yPoint = ((i + 1) * fontSize * 0.9) + (i * lineHeight);
                Iif (parent.transform.degree === -360) {
                    parent.transform.degree = 0;
                }
                if (parent.transform.degree === 0 || parent.transform.degree === 180) {
                    if (fontSize > height) {
                        fontSize = actObj.textSettings.fontSize = height / 1.18;
                    }
                }
                else {
                    Iif (fontSize > width) {
                        fontSize = actObj.textSettings.fontSize = width / 1.18;
                    }
                }
                canvasDraw.strokeStyle = actObj.strokeSettings.outlineColor;
                canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
                var tempWidth = canvasDraw.lineWidth;
                var obj = { width: 0, height: 0 };
                var ratio = { width: 1, height: 1 };
                parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
                    value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
                ratio = obj;
                var isTempCanvas = canvasDraw.canvas.id === parent.element.id + '_tempCanvas';
                var baseWidth = Math.max(1, actObj.strokeSettings.outlineWidth / 2);
                if (/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$|^[a-zA-Z]+$/.test(actObj.strokeSettings.outlineColor)) {
                    canvasDraw.lineWidth = baseWidth * ((isTempCanvas ? Math.floor((fontSize - 1) / 60) :
                        Math.floor((fontSize - 1) / 16)) * 0.5 + 0.5);
                    Iif (isTempCanvas) {
                        canvasDraw.lineWidth *= ((ratio.width + ratio.height) / 2);
                        if (parent.transform.degree !== 0) {
                            canvasDraw.lineWidth /= 1.8;
                        }
                    }
                }
                else {
                    canvasDraw.lineWidth = 1;
                }
                var textStyle = '';
                if (bold) {
                    textStyle = 'bold ';
                }
                if (italic) {
                    textStyle = 'italic ';
                }
                if (bold && italic) {
                    textStyle = 'italic bold ';
                }
                canvasDraw.font = textStyle + fontSize + 'px' + ' ' + fontFamily;
                if (actObj.flipObjColl.length === 4) {
                    actObj.flipObjColl = [];
                    actObj.shapeFlip = '';
                }
                if (actObj.rotateFlipColl && actObj.rotateFlipColl.length > 0) {
                    this.rotateText(canvasDraw);
                }
                else {
                    canvasDraw.strokeText(text, startX + fontSize * 0.1, startY + yPoint);
                    canvasDraw.fillText(text, startX + fontSize * 0.1, startY + yPoint);
                    if (underline) {
                        var yOffset = yPoint + fontSize * 0.1;
                        this.drawTextDecoration(canvasDraw, text, startX, startY, yOffset, fontSize, 0.1);
                    }
                    if (strikethrough) {
                        var yOffset = yPoint - lineHeight - fontSize * 0.025;
                        this.drawTextDecoration(canvasDraw, text, startX, startY, yOffset, fontSize, 0.1);
                    }
                }
                canvasDraw.lineWidth = tempWidth;
            }
            canvasDraw.filter = filter;
            parent.currObjType.isText = false;
            if (this.upperContext === canvasDraw) {
                this.drawOuterSelection(canvasDraw);
            }
        };
        Draw.prototype.drawTextDecoration = function (canvasDraw, text, startX, startY, yOffset, fontSize, horizontalPadding) {
            Iif (horizontalPadding === void 0) { horizontalPadding = 0.1; }
            var tempWidth = canvasDraw.lineWidth;
            var textWidth = canvasDraw.measureText(text).width;
            canvasDraw.lineWidth = fontSize * 0.1;
            canvasDraw.beginPath();
            canvasDraw.moveTo(startX + fontSize * horizontalPadding, startY + yOffset);
            canvasDraw.lineTo(startX + textWidth + fontSize * horizontalPadding, startY + yOffset);
            canvasDraw.strokeStyle = canvasDraw.fillStyle;
            canvasDraw.stroke();
            canvasDraw.lineWidth = tempWidth;
            canvasDraw.strokeStyle = this.parent.activeObj.strokeSettings.outlineColor;
        };
        Draw.prototype.updateActPoint = function (degree, canvasDraw) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var actPoint = actObj.activePoint;
            if (degree.toLowerCase() === 'horizontal') {
                if (actPoint.startX <= canvasDraw.canvas.width / 2) {
                    actPoint.startX = canvasDraw.canvas.width / 2 + ((canvasDraw.canvas.width / 2) - actPoint.endX);
                    actPoint.endX = actPoint.startX + actPoint.width;
                    this.updateActiveObject(actPoint, actObj);
                    parent.activeObj = actObj;
                }
                else Eif (actPoint.startX >= canvasDraw.canvas.width / 2) {
                    actPoint.startX = canvasDraw.canvas.width - actPoint.endX;
                    actPoint.endX = actPoint.startX + actPoint.width;
                    this.updateActiveObject(actPoint, actObj);
                    parent.activeObj = actObj;
                }
            }
            else Eif (degree.toLowerCase() === 'vertical') {
                if (actPoint.startY <= canvasDraw.canvas.height / 2) {
                    actPoint.startY = canvasDraw.canvas.height / 2 + ((canvasDraw.canvas.height / 2) - actPoint.endY);
                    actPoint.endY = actPoint.startY + actPoint.height;
                    this.updateActiveObject(actPoint, actObj);
                    parent.activeObj = actObj;
                }
                else Eif (actPoint.startY >= canvasDraw.canvas.height / 2) {
                    actPoint.startY = canvasDraw.canvas.height - actPoint.endY;
                    actPoint.endY = actPoint.startY + actPoint.height;
                    this.updateActiveObject(actPoint, actObj);
                    parent.activeObj = actObj;
                }
            }
            return actPoint;
        };
        Draw.prototype.rotateImage = function (canvasDraw) {
            var parent = this.parent;
            var degree;
            var actObj = parent.activeObj;
            var tempActiveObj = ej2_base_1.extend({}, parent.activeObj, null, true);
            Eif (actObj.shapeDegree === 0) {
                degree = parent.transform.degree;
            }
            else {
                degree = parent.transform.degree - actObj.shapeDegree;
            }
            Iif (degree === -450) {
                degree = -90;
            }
            Iif (degree < 0) {
                degree = 360 + degree;
            }
            var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
            imgPoint.width = degree % 90 === 0 && degree % 180 !== 0 ? actObj.activePoint.height : actObj.activePoint.width;
            imgPoint.height = degree % 90 === 0 && degree % 180 !== 0 ? actObj.activePoint.width :
                actObj.activePoint.height;
            imgPoint.startX = actObj.activePoint.startX;
            imgPoint.startY = actObj.activePoint.startY;
            var startX = imgPoint.startX;
            var startY = imgPoint.startY;
            var tempDegree;
            var tempColl = [];
            canvasDraw.save();
            for (var i = 0, len = actObj.rotateFlipColl.length; i < len; i++) {
                var coll = actObj.rotateFlipColl[i];
                tempColl.push(coll);
                if (typeof (coll) === 'number') {
                    tempDegree = coll;
                    Iif (tempDegree === -450) {
                        tempDegree = -90;
                    }
                    Iif (tempDegree < 0) {
                        tempDegree = 360 + tempDegree;
                    }
                    imgPoint.width = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ? actObj.activePoint.height : actObj.activePoint.width;
                    imgPoint.height = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ? actObj.activePoint.width :
                        actObj.activePoint.height;
                    canvasDraw.translate(canvasDraw.canvas.width / 2, canvasDraw.canvas.height / 2);
                    canvasDraw.rotate(Math.PI / 180 * coll);
                    canvasDraw.translate(-canvasDraw.canvas.height / 2, -canvasDraw.canvas.width / 2);
                    Eif ((tempDegree % 90 === 0 && tempDegree % 270 !== 0) || tempDegree === 0) {
                        startY = canvasDraw.canvas.width - (actObj.activePoint.startX + actObj.activePoint.width);
                        startY += ((actObj.activePoint.width - imgPoint.height) / 2);
                        startX = imgPoint.startY;
                    }
                    else if (tempDegree % 270 === 0) {
                        startX = canvasDraw.canvas.height - (actObj.activePoint.startY + actObj.activePoint.height);
                        startX += ((actObj.activePoint.height - imgPoint.width) / 2);
                        startY = imgPoint.startX;
                    }
                    imgPoint.startX = startX;
                    imgPoint.startY = startY;
                    actObj.activePoint.startX = startX;
                    actObj.activePoint.startY = startY;
                    actObj.activePoint.endX = actObj.activePoint.startX + imgPoint.width;
                    actObj.activePoint.endY = actObj.activePoint.startY + imgPoint.height;
                    actObj = this.updateWidthHeight(actObj);
                }
                else {
                    if (coll === 'horizontal' && degree % 90 === 0 && degree % 180 !== 0) {
                        coll = 'vertical';
                    }
                    else if (coll === 'vertical' && degree % 90 === 0 && degree % 180 !== 0) {
                        coll = 'horizontal';
                    }
                    if (coll === 'horizontal') {
                        canvasDraw.translate(canvasDraw.canvas.width, 0);
                        canvasDraw.scale(-1, 1);
                        actObj.activePoint = this.updateActPoint('horizontal', canvasDraw);
                    }
                    else Eif (coll === 'vertical') {
                        canvasDraw.translate(0, canvasDraw.canvas.height);
                        canvasDraw.scale(1, -1);
                        actObj.activePoint = this.updateActPoint('vertical', canvasDraw);
                    }
                    imgPoint.startX = actObj.activePoint.startX;
                    imgPoint.startY = actObj.activePoint.startY;
                }
                imgPoint.startX = actObj.activePoint.startX;
                imgPoint.startY = actObj.activePoint.startY;
                startX = imgPoint.startX;
                startY = imgPoint.startY;
            }
            Eif (actObj.rotatedAngle !== 0) {
                parent.notify('shape', { prop: 'setPointCollForShapeRotation', onPropertyChange: false, value: { obj: actObj } });
            }
            canvasDraw.drawImage(actObj.imageCanvas, imgPoint.startX, imgPoint.startY, imgPoint.width, imgPoint.height);
            canvasDraw.restore();
            parent.activeObj = tempActiveObj;
            Iif (parent.transform.degree === 360 || parent.transform.degree === -360) {
                parent.transform.degree = 0;
            }
        };
        Draw.prototype.rotateText = function (canvasDraw) {
            var parent = this.parent;
            var degree;
            var actObj = parent.activeObj;
            var tempActiveObj = ej2_base_1.extend({}, parent.activeObj, null, true);
            var actPoint = parent.activeObj.activePoint;
            if (actObj.shapeDegree === 0) {
                degree = parent.transform.degree;
            }
            else {
                degree = parent.transform.degree - actObj.shapeDegree;
            }
            Iif (degree === -450) {
                degree = -90;
            }
            if (degree < 0) {
                degree = 360 + degree;
            }
            var imgPoint = { startX: 0, startY: 0, width: 0, height: 0 };
            imgPoint.width = degree % 90 === 0 && degree % 180 !== 0 ? actPoint.height : actPoint.width;
            imgPoint.height = degree % 90 === 0 && degree % 180 !== 0 ? actPoint.width : actPoint.height;
            imgPoint.startX = actPoint.startX;
            imgPoint.startY = actPoint.startY;
            var startX = imgPoint.startX;
            var startY = imgPoint.startY;
            var tempDegree;
            var tempColl = [];
            canvasDraw.save();
            for (var i = 0, len = actObj.rotateFlipColl.length; i < len; i++) {
                var coll = actObj.rotateFlipColl[i];
                tempColl.push(coll);
                if (typeof (coll) === 'number') {
                    tempDegree = coll;
                    Iif (tempDegree === -450) {
                        tempDegree = -90;
                    }
                    if (tempDegree < 0) {
                        tempDegree = 360 + tempDegree;
                    }
                    imgPoint.width = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ? actPoint.height : actPoint.width;
                    imgPoint.height = tempDegree % 90 === 0 && tempDegree % 180 !== 0 ? actPoint.width : actPoint.height;
                    canvasDraw.translate(canvasDraw.canvas.width / 2, canvasDraw.canvas.height / 2);
                    canvasDraw.rotate(Math.PI / 180 * coll);
                    canvasDraw.translate(-canvasDraw.canvas.height / 2, -canvasDraw.canvas.width / 2);
                    if ((tempDegree % 90 === 0 && tempDegree % 270 !== 0) || tempDegree === 0) {
                        startY = (canvasDraw.canvas.width - actPoint.endX);
                        startX = actPoint.startY;
                    }
                    else Eif (tempDegree % 270 === 0) {
                        startX = canvasDraw.canvas.height - actPoint.endY;
                        startY = actPoint.startX;
                    }
                    imgPoint.startX = startX;
                    imgPoint.startY = startY;
                    actPoint.startX = startX;
                    actPoint.startY = startY;
                    actPoint.endX = actPoint.startX + imgPoint.width;
                    actPoint.endY = actPoint.startY + imgPoint.height;
                    actObj = this.updateWidthHeight(actObj);
                }
                else {
                    if (coll === 'horizontal' && degree % 90 === 0 && degree % 180 !== 0) {
                        coll = 'vertical';
                    }
                    else if (coll === 'vertical' && degree % 90 === 0 && degree % 180 !== 0) {
                        coll = 'horizontal';
                    }
                    if (coll === 'horizontal') {
                        canvasDraw.translate(canvasDraw.canvas.width, 0);
                        canvasDraw.scale(-1, 1);
                    }
                    else Eif (coll === 'vertical') {
                        canvasDraw.translate(0, canvasDraw.canvas.height);
                        canvasDraw.scale(1, -1);
                    }
                    actObj.activePoint = actPoint = this.updateActPoint(coll, canvasDraw);
                    imgPoint.startX = actPoint.startX;
                    imgPoint.startY = actPoint.startY;
                }
                imgPoint.startX = actPoint.startX;
                imgPoint.startY = actPoint.startY;
                startX = imgPoint.startX;
                startY = imgPoint.startY;
            }
            Iif (actObj.rotatedAngle !== 0) {
                parent.notify('shape', { prop: 'setPointCollForShapeRotation', onPropertyChange: false, value: { obj: actObj } });
            }
            startY += actObj.textSettings.fontSize * 0.4;
            this.textFlipDegree(canvasDraw, startX, startY);
            canvasDraw.restore();
            parent.activeObj = tempActiveObj;
            Iif (parent.transform.degree === 360 || parent.transform.degree === -360) {
                parent.transform.degree = 0;
            }
        };
        Draw.prototype.textFlipDegree = function (canvasDraw, startX, startY) {
            var parent = this.parent;
            var actObj = parent.activeObj;
            var rows = actObj.keyHistory.split('\n');
            var fontSize = actObj.textSettings.fontSize;
            var lineHeight = ((fontSize * rows.length) - (fontSize * rows.length)) / rows.length;
            var yPoint = (fontSize * 0.85) + lineHeight;
            for (var i = 0, len = rows.length; i < len; i++) {
                var text = rows[i];
                Iif (i > 0) {
                    if (i === 1) {
                        yPoint -= (fontSize * 0.85);
                    }
                    yPoint += fontSize + fontSize * 0.15;
                }
                canvasDraw.strokeText(text, startX + fontSize * 0.15, startY +
                    yPoint + (i > 0 ? fontSize * 0.25 : -fontSize * 0.35));
                canvasDraw.fillText(text, startX + fontSize * 0.15, startY +
                    yPoint + (i > 0 ? fontSize * 0.25 : -fontSize * 0.35));
                Iif (actObj.textSettings.underline) {
                    var yOffset = yPoint + (i > 0 ? fontSize * 0.35 : -fontSize * 0.25);
                    this.drawTextDecoration(canvasDraw, text, startX, startY, yOffset, fontSize, 0.15);
                }
                Iif (actObj.textSettings.strikethrough) {
                    var yOffset = yPoint - lineHeight + (i > 0 ? -fontSize * 0.04 : -fontSize * 0.64);
                    this.drawTextDecoration(canvasDraw, text, startX, startY, yOffset, fontSize, 0.1);
                }
            }
        };
        Draw.prototype.clearOuterCanvas = function (context) {
            var parent = this.parent;
            var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
            var left = destLeft > 0 ? destLeft : 0;
            var top = destTop > 0 ? destTop : 0;
            context.clearRect(0, 0, left, parent.lowerCanvas.height);
            context.clearRect(destLeft + destWidth, 0, parent.lowerCanvas.width - (destLeft + destWidth), parent.lowerCanvas.height);
            context.clearRect(0, 0, parent.lowerCanvas.width, top);
            context.clearRect(0, destTop + destHeight, parent.lowerCanvas.width, parent.lowerCanvas.height - (destTop + destHeight));
            if (parent.transform.currFlipState !== '') {
                parent.img.destLeft = destLeft;
                parent.img.destTop = destTop;
            }
        };
        Draw.prototype.setDestPoints = function () {
            var maxDimension;
            var parent = this.parent;
            var _a = parent.transform, degree = _a.degree, zoomFactor = _a.zoomFactor;
            if (degree % 90 === 0 && degree % 180 !== 0) {
                var obj = { width: 0, height: 0 };
                parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                    value: { width: parent.img.srcHeight, height: parent.img.srcWidth, obj: obj, isImgShape: null } });
                maxDimension = obj;
                if (this.isRotateZoom) {
                    maxDimension.width += (maxDimension.width * zoomFactor);
                    maxDimension.height += (maxDimension.height * zoomFactor);
                    parent.img.destWidth = maxDimension.height;
                    parent.img.destHeight = maxDimension.width;
                }
                parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.height) / 2;
                parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.width) / 2;
                parent.img.destWidth = maxDimension.height;
                parent.img.destHeight = maxDimension.width;
            }
            else {
                var obj = { width: 0, height: 0 };
                parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                    value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
                maxDimension = obj;
                if (this.isRotateZoom) {
                    maxDimension.width += (maxDimension.width * zoomFactor);
                    maxDimension.height += (maxDimension.height * zoomFactor);
                    parent.img.destWidth = maxDimension.width;
                    parent.img.destHeight = maxDimension.height;
                }
                parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
                if (degree === 0) {
                    parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
                }
                else {
                    parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
                }
                parent.img.destWidth = maxDimension.width;
                parent.img.destHeight = maxDimension.height;
            }
        };
        Draw.prototype.updateCurrTransState = function (type, isPreventDestination, isRotatePan, isStraighten) {
            var parent = this.parent;
            var destLeft = parent.img.destLeft;
            var destTop = parent.img.destTop;
            if (type === 'initial') {
                this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
                Eif (ej2_base_1.isNullOrUndefined(isPreventDestination)) {
                    this.setDestPoints();
                }
            }
            if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
                this.currTransState(type, true, null, isRotatePan);
                if (parent.transform.degree === 0 && parent.transform.currFlipState === '' && parent.transform.straighten === 0 &&
                    ej2_base_1.isNullOrUndefined(isStraighten)) {
                    parent.img.destLeft = destLeft;
                    parent.img.destTop = destTop;
                }
                if (isRotatePan) {
                    parent.img.destLeft += parent.panPoint.totalPannedClientPoint.x;
                    parent.img.destTop +=
                        parent.panPoint.totalPannedClientPoint.y;
                }
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
                if (isRotatePan) {
                    parent.img.destLeft -= parent.panPoint.totalPannedClientPoint.x;
                    parent.img.destTop -=
                        parent.panPoint.totalPannedClientPoint.y;
                }
            }
            else {
                this.currTransState(type, null, null, isRotatePan);
                if (parent.transform.degree === 0 && parent.transform.currFlipState === '' && parent.transform.straighten === 0 &&
                    ej2_base_1.isNullOrUndefined(isStraighten)) {
                    parent.img.destLeft = destLeft;
                    parent.img.destTop = destTop;
                }
            }
        };
        Draw.prototype.currTransState = function (type, isPreventDimension, context, isPreventCircleCrop) {
            var parent = this.parent;
            context = context ? context : this.lowerContext;
            if (type === 'initial') {
                this.setTransformColl(context, type);
            }
            else Eif (type === 'reverse') {
                this.setTransformColl(context, type);
                this.setClientTransDim(isPreventDimension);
                if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle'
                    && ej2_base_1.isNullOrUndefined(isPreventCircleCrop))) {
                    if (isPreventCircleCrop) {
                        parent.img.destLeft += parent.panPoint.totalPannedClientPoint.x;
                        parent.img.destTop += parent.panPoint.totalPannedClientPoint.y;
                    }
                    parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                        value: { context: this.lowerContext, isSave: null, isFlip: null } });
                    if (isPreventCircleCrop) {
                        parent.img.destLeft -= parent.panPoint.totalPannedClientPoint.x;
                        parent.img.destTop -= parent.panPoint.totalPannedClientPoint.y;
                    }
                }
            }
        };
        Draw.prototype.setTransformColl = function (context, type) {
            var parent = this.parent;
            if (type === 'initial') {
                for (var i = 0, len = parent.rotateFlipColl.length; i < len; i++) {
                    this.setTransform(context, parent.rotateFlipColl[i]);
                }
            }
            else Eif (type === 'reverse') {
                for (var i = parent.rotateFlipColl.length - 1; i >= 0; i--) {
                    this.setTransform(context, parent.rotateFlipColl[i], true);
                }
            }
        };
        Draw.prototype.setTransform = function (context, value, isReverse) {
            var parent = this.parent;
            if (isReverse && value === 90) {
                value = -90;
            }
            else if (isReverse && value === -90) {
                value = 90;
            }
            if (value === 'horizontal' && parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                value = 'vertical';
            }
            else if (value === 'vertical' && parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                value = 'horizontal';
            }
            parent.notify('transform', { prop: 'setReverseRotate', onPropertyChange: false, value: { bool: true } });
            parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: true } });
            if (ej2_base_1.isNullOrUndefined(isReverse)) {
                context.clearRect(0, 0, context.canvas.width, context.canvas.height);
            }
            switch (value) {
                case 90:
                case -90:
                    context.translate(context.canvas.width / 2, context.canvas.height / 2);
                    context.rotate(Math.PI / 180 * value);
                    context.translate(-context.canvas.width / 2, -context.canvas.height / 2);
                    break;
                case 'horizontal':
                    context.translate(context.canvas.width, 0);
                    context.scale(-1, 1);
                    break;
                case 'vertical':
                    context.translate(0, context.canvas.height);
                    context.scale(1, -1);
                    break;
            }
            parent.notify('transform', { prop: 'setReverseRotate', onPropertyChange: false, value: { bool: false } });
            parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: false } });
        };
        Draw.prototype.drawImgToCanvas = function (maxDimension) {
            var parent = this.parent;
            this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            parent.img.destWidth = maxDimension.width;
            parent.img.destHeight = maxDimension.height;
            if (this.isInitialLoading) {
                parent.notify('filter', { prop: 'initFilter', onPropertyChange: false });
                this.isInitialLoading = false;
            }
            var temp = this.lowerContext.filter;
            this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            this.drawImage();
            Iif ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
            }
            this.lowerContext.filter = temp;
        };
        Draw.prototype.renderImage = function (isMouseWheel, isPreventClearRect, isFrame, isStraighten) {
            var parent = this.parent;
            parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
            Eif (ej2_base_1.isNullOrUndefined(isPreventClearRect)) {
                this.upperContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
                this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            }
            if (isMouseWheel) {
                this.setTransformColl(this.lowerContext, 'initial');
            }
            else {
                if (parent.transform.zoomFactor !== 0) {
                    this.isRotateZoom = true;
                }
                this.updateCurrTransState('initial', null, null, isStraighten);
            }
            parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
            this.drawImage();
            parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
            if (isMouseWheel) {
                this.setTransformColl(this.lowerContext, 'reverse');
            }
            else {
                this.updateCurrTransState('reverse', null, null, isStraighten);
                this.isRotateZoom = false;
            }
            if (isFrame) {
                parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
            }
            else {
                parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
            }
            this.clearOuterCanvas(this.lowerContext);
            if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
            }
        };
        Draw.prototype.imageOnLoad = function (src) {
            var _this = this;
            var parent = this.parent;
            var proxy = this;
            parent.imageLoaded = false;
            parent.baseImg.src = src;
            parent.baseImg.onload = function () {
                parent.imgSrc = src;
                if (!parent.isUndoRedo) {
                    parent.notify('filter', { prop: 'update-finetunes', onPropertyChange: false });
                }
                proxy.lowerContext.imageSmoothingQuality = parent.imageSmoothingEnabled ? 'high' : 'low';
                proxy.lowerContext.drawImage(parent.baseImg, 0, 0, proxy.parent.lowerCanvas.width, proxy.parent.lowerCanvas.height);
                var isCropped = false;
                var isSameDimension = false;
                Iif (parent.isImageUpdated) {
                    var _a = parent.img, srcWidth = _a.srcWidth, srcHeight = _a.srcHeight;
                    var _b = parent.baseImgCanvas, width = _b.width, height = _b.height;
                    isCropped = srcWidth !== width || srcHeight !== height;
                    isSameDimension = parent.baseImg.width === width && parent.baseImg.height === height;
                }
                ej2_popups_1.hideSpinner(parent.element);
                parent.element.style.opacity = '1';
                proxy.updateBaseImgCanvas();
                var fileOpened = { fileName: _this.fileName, fileType: _this.fileType, isValidImage: true };
                proxy.updateCanvas(isCropped, isSameDimension);
                Iif (parent.currObjType.isUndoZoom) {
                    parent.currObjType.isUndoZoom = false;
                    proxy.parent.lowerCanvas.style.display = 'block';
                }
                parent.isUndoRedo = _this.isErrorImage = false;
                Iif (ej2_base_1.Browser.isDevice) {
                    parent.notify('toolbar', { prop: 'destroy-top-toolbar', onPropertyChange: false });
                    parent.notify('toolbar', { prop: 'destroy-bottom-toolbar', onPropertyChange: false });
                    var eventargs = { isApplyBtn: false, isDevice: ej2_base_1.Browser.isDevice, isOkBtn: null,
                        isResize: null, isFrame: null, isMainToolbar: true };
                    parent.notify('toolbar', { prop: 'init-main-toolbar', onPropertyChange: false, value: eventargs });
                    parent.notify('toolbar', { prop: 'create-bottom-toolbar', onPropertyChange: false });
                }
                else {
                    parent.notify('toolbar', { prop: 'destroy-top-toolbar', onPropertyChange: false });
                    var eventargs = { isApplyBtn: false, isDevice: false, isOkBtn: null };
                    parent.notify('toolbar', { prop: 'init-main-toolbar', onPropertyChange: false, value: eventargs });
                }
                if (parent.isImageLoaded && parent.element.style.opacity !== '0.5') {
                    parent.trigger('fileOpened', fileOpened);
                    var action = { action: 'file-open', actionEventArgs: fileOpened };
                    parent.triggerEditCompleteEvent(action);
                }
                Iif (_this.fileType === 'Bmp') {
                    _this.fileType = index_1.FileType.Png;
                }
                parent.imageLoaded = true;
            };
            parent.baseImg.onerror = function () {
                ej2_popups_1.hideSpinner(parent.element);
                proxy.isErrorImage = true;
                proxy.errorLoading();
            };
        };
        Draw.prototype.errorLoading = function () {
            var parent = this.parent;
            var fileOpened = { fileName: null, fileType: null, isValidImage: false };
            parent.trigger('fileOpened', fileOpened);
        };
        Draw.prototype.updateBaseImgCanvas = function () {
            var parent = this.parent;
            if (!parent.aspectRatioBaseDimension && parent.imageSettings.width && parent.imageSettings.height) {
                var widthRatio = parent.baseImg.width / parent.imageSettings.width;
                var heightRatio = parent.baseImg.height / parent.imageSettings.height;
                var ratio = (widthRatio + heightRatio) / 2;
                ratio = ratio < 1 ? 1 : ratio;
                parent.baseImgCanvas.width = parent.imageSettings.width * ratio;
                parent.baseImgCanvas.height = parent.imageSettings.height * ratio;
                parent.baseImgCanvas.getContext('2d').drawImage(parent.baseImg, 0, 0, parent.baseImgCanvas.width, parent.baseImgCanvas.height);
            }
            else {
                parent.baseImgCanvas.width = parent.baseImg.width;
                parent.baseImgCanvas.height = parent.baseImg.height;
                parent.baseImgCanvas.getContext('2d').drawImage(parent.baseImg, 0, 0);
            }
        };
        Draw.prototype.updateCanvas = function (isCropped, isSameDimension) {
            var parent = this.parent;
            Eif (!parent.isImageUpdated || !isCropped) {
                parent.img.srcWidth = parent.baseImgCanvas.width;
                parent.img.srcHeight = parent.baseImgCanvas.height;
            }
            else if (!isSameDimension && isCropped) {
                parent.img.srcLeft = 0;
                parent.img.srcTop = 0;
                parent.img.srcWidth = parent.baseImgCanvas.width;
                parent.img.srcHeight = parent.baseImgCanvas.height;
                parent.currSelectionPoint = null;
                parent.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
                    totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
                    degree: 0, currFlipState: '', straighten: 0, destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
                    srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
                    zoomFactor: 0, previousZoomValue: 0, aspectWidth: null, aspectHeight: null, frame: 'none', straightenZoom: 0,
                    adjustmentLevel: { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
                        exposure: 0, transparency: 100, sharpen: false, bw: false }, currentFilter: '' };
            }
            var obj = { width: 0, height: 0 };
            parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
            var maxDimension = obj;
            parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
            parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
            this.drawImgToCanvas(maxDimension);
            this.origDim.width = parent.img.destWidth;
            this.origDim.height = parent.img.destHeight;
            this.zoomCrop.width = parent.img.destWidth;
            this.zoomCrop.height = parent.img.destHeight;
            parent.notify('transform', { prop: 'setCropDimension', onPropertyChange: false,
                value: { width: parent.img.destWidth, height: parent.img.destHeight } });
            var point = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
                height: parent.img.destHeight };
            parent.notify('crop', { prop: 'setCropDestPoints', onPropertyChange: false, value: { point: point } });
            var temp = this.lowerContext.filter;
            this.lowerContext.filter = 'none';
            parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                value: { ctx: this.lowerContext, shape: 'iterate', pen: 'zoom', isPreventApply: null } });
            this.lowerContext.filter = temp;
            if (parent.img.destWidth > 0 && parent.img.destHeight > 0) {
                parent.isImageLoaded = true;
            }
            if (parent.isUndoRedo) {
                Iif (parent.transform.currFlipState !== '') {
                    parent.notify('transform', { prop: 'flipImage', onPropertyChange: false,
                        value: { direction: parent.toPascalCase(parent.transform.currFlipState) } });
                }
            }
            Iif (parent.disabled) {
                parent.element.setAttribute('class', 'e-disabled');
            }
            if (parent.zoomSettings.zoomFactor !== 1 || parent.zoomSettings.zoomPoint) {
                parent.zoom(parent.zoomSettings.zoomFactor, parent.zoomSettings.zoomPoint);
            }
            if (ej2_base_1.isNullOrUndefined(this.initZoomValue)) {
                this.initZoomValue = parent.zoomSettings.zoomFactor;
            }
            this.isImageEdited = false;
        };
        Draw.prototype.resetFrameZoom = function (isOk) {
            var parent = this.parent;
            if (!ej2_base_1.isNullOrUndefined(parent.tempFrameZoomLevel)) {
                var temp = parent.tempFrameZoomLevel;
                parent.tempFrameZoomLevel = null;
                parent.notify('transform', { prop: 'resetZoom', onPropertyChange: false });
                parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                    value: { zoomFactor: temp, zoomPoint: null, isResize: true } });
                var obj = parent.cancelCropSelection;
                if (isOk && obj) {
                    obj.previousObj.frameObj = ej2_base_1.extend({}, parent.frameObj, null, true);
                    obj.currentObj.frameObj = ej2_base_1.extend({}, parent.frameObj, null, true);
                    obj.previousObj.frame = obj.currentObj.frame = parent.frameObj.type;
                }
                this.updateCropSelObj();
                parent.cancelCropSelection = null;
            }
        };
        Draw.prototype.performCancel = function (isContextualToolbar, isUndoRedo, isFinalCancel) {
            var parent = this.parent;
            if (isFinalCancel) {
                parent.noPushUndo = false;
            }
            var straightenObj = { bool: parent.isStraightening };
            isContextualToolbar = isContextualToolbar ? isContextualToolbar : false;
            var obj = { bool: false };
            parent.allowDownScale = true;
            parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
            if (ej2_base_1.isNullOrUndefined(isUndoRedo) && JSON.stringify(parent.frameObj) !== JSON.stringify(parent.tempFrameObj)) {
                ej2_base_1.extend(parent.frameObj, parent.tempFrameObj);
                this.renderImage(null, null, true);
            }
            this.resetFrameZoom(false);
            var editCompleteArgs = { action: '' };
            if (obj['bool']) {
                editCompleteArgs['action'] = 'freehand-draw';
                parent.notify('freehand-draw', { prop: 'cancelFhd', onPropertyChange: false });
                parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
                parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
            }
            else if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
                editCompleteArgs['action'] = 'text-editing';
                parent.textArea.style.display = 'none';
                parent.textArea.value = '';
                parent.textArea.style.transform = '';
                Iif (this.prevActObj) {
                    parent.activeObj = this.prevActObj;
                    this.prevActObj = null;
                }
                else {
                    parent.activeObj.strokeSettings = this.tempStrokeSettings;
                    parent.activeObj.textSettings = this.tempTextSettings;
                }
                parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
                Iif (this.isShapeTextInserted) {
                    parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                }
                parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: true } });
                parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
                parent.notify('selection', { prop: 'setTempActObj', onPropertyChange: false, value: { obj: parent.activeObj } });
                Iif (parent.drawingShape) {
                    parent.enableShapeDrawing(parent.toPascalCase(parent.drawingShape), true);
                }
            }
            else if ((!parent.activeObj.shape || parent.activeObj.shape !== 'redact') && (((!ej2_base_1.Browser.isDevice || (ej2_base_1.Browser.isDevice && !straightenObj['bool'])) &&
                parent.element.querySelector('#' + parent.element.id + '_sliderWrapper')) || parent.currObjType.isFiltered)) {
                editCompleteArgs['action'] = parent.isFinetuneBtnClick ? 'fine-tune' : 'filter';
                this.lowerContext.filter = this.tempAdjValue;
                parent.canvasFilter = this.tempAdjValue;
                parent.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.tempAdjValue } });
                parent.initialAdjustmentValue = this.tempAdjValue;
                if (this.lowerContext.filter.split(' ').length > 1 &&
                    this.lowerContext.filter.split(' ')[0].split('(')[1].split(')')[0] === '1') {
                    parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: false } });
                }
                parent.currentFilter = this.tempFilter;
                parent.notify('filter', { prop: 'setBevelFilter', onPropertyChange: false, value: { bevelFilter: this.lowerContext.filter } });
                this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
                this.redrawImgWithObj();
                parent.currObjType.isFiltered = false;
                var obj_3 = { tempAdjustmentLevel: null };
                parent.notify('filter', { prop: 'getTempAdjustmentLevel', onPropertyChange: false, value: { obj: obj_3 } });
                parent.notify('filter', { prop: 'setAdjustmentLevel', onPropertyChange: false,
                    value: { adjustmentLevel: ej2_base_1.extend({}, obj_3['tempAdjustmentLevel'], {}, true) } });
                parent.notify('undo-redo', { prop: 'setUndoRedoStep', onPropertyChange: false, value: { step: this.tempUndoRedoStep } });
                parent.upperCanvas.style.cursor = parent.cursor = 'default';
                parent.currObjType.isCustomCrop = false;
                this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
                this.clearOuterCanvas(this.lowerContext);
                Iif ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
                    parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                        value: { context: this.lowerContext, isSave: null, isFlip: null } });
                }
                var eventargs = { type: 'main', isApplyBtn: null, isCropping: null, isZooming: null };
                parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
                parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
                Iif (parent.activeObj.shape && parent.activeObj.shape === 'image') {
                    parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
                }
                parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                if (parent.drawingShape) {
                    parent.drawingShape = null;
                    parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
                }
            }
            else {
                Iif ((!parent.activeObj.shape || parent.activeObj.shape !== 'redact') && isContextualToolbar && (!ej2_base_1.Browser.isDevice || (ej2_base_1.Browser.isDevice && !straightenObj['bool']))) {
                    var eventargs = { type: 'main', isApplyBtn: null, isCropping: null, isZooming: null };
                    parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
                }
                else {
                    this.cancelItems(editCompleteArgs);
                    if (parent.transform.zoomFactor > 0) {
                        parent.togglePan = true;
                        parent.notify('selection', { prop: 'setDragCanvas', value: { bool: true } });
                    }
                    else {
                        parent.togglePan = false;
                        parent.notify('selection', { prop: 'setDragCanvas', value: { bool: false } });
                    }
                }
            }
            this.isShapeTextInserted = false;
            this.isNewPath = false;
            parent.notify('toolbar', { prop: 'refresh-dropdown-btn', value: { isDisabled: false } });
            parent.notify('toolbar', { prop: 'setCurrentToolbar', value: { type: 'main' } });
            if (isFinalCancel) {
                parent.noPushUndo = false;
            }
            parent.drawingShape = null;
            parent.notify('draw', { prop: 'resetTempObjColl' });
            parent.notify('draw', { prop: 'resetTempPointColl' });
            parent.isMaskImage = parent.isFinetuneBtnClick = false;
            var actionArgs = { action: 'cancel', actionEventArgs: editCompleteArgs };
            parent.triggerEditCompleteEvent(actionArgs);
        };
        Draw.prototype.cancelItems = function (editCompleteArgs) {
            var parent = this.parent;
            var isCropSelection = false;
            var id = parent.element.id;
            var ascpectIcon = parent.element.querySelector('#' + id + '_aspectratio');
            var nonAspectIcon = parent.element.querySelector('#' + id + '_nonaspectratio');
            var splitWords;
            var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image', 'redact'];
            if (parent.activeObj.shape !== undefined) {
                splitWords = parent.activeObj.shape.split('-');
            }
            Iif (splitWords === undefined && parent.currObjType.isCustomCrop) {
                isCropSelection = true;
            }
            else if (splitWords !== undefined && splitWords[0] === 'crop') {
                isCropSelection = true;
            }
            if (isCropSelection && parent.isCropTab) {
                parent.isCropTab = false;
                parent.transform.zoomFactor = parent.transform.defaultZoomFactor;
            }
            if (parent.isResize) {
                Eif (ascpectIcon || nonAspectIcon || parent.currentToolbar === 'resize-toolbar') {
                    editCompleteArgs['action'] = 'resize';
                    var obj = { width: null, height: null };
                    parent.notify('selection', { prop: 'getNumTextValue', onPropertyChange: false, value: { obj: obj } });
                    var point = { x: obj['width'], y: obj['height'] };
                    var aspectRatioElement = parent.element.querySelector('#' + parent.element.id + '_aspectratio');
                    var blrAspRatElem = parent.element.querySelector('.e-ie-toolbar-aspect-ratio-btn');
                    if (point && point.x && point.y && !ej2_base_1.isNullOrUndefined(parent.aspectWidth)) {
                        Iif (aspectRatioElement || (blrAspRatElem && !blrAspRatElem.classList.contains('e-hidden'))) {
                            parent.notify('transform', { prop: 'resizeImage', value: { width: parent.aspectWidth, height: parent.aspectHeight } });
                        }
                        else {
                            var bool = parent.currObjType.isUndoAction;
                            parent.currObjType.isUndoAction = false;
                            parent.notify('transform', { prop: 'resizeCrop', value: { width: parent.aspectWidth, height: parent.aspectHeight } });
                            parent.currObjType.isUndoAction = bool;
                        }
                    }
                    var obj1 = { prevCropObj: parent.prevCropObj };
                    var obj2 = { prevObj: parent.prevObj };
                    parent.notify('toolbar', { prop: 'getPrevCropObj', onPropertyChange: false, value: { obj: obj1 } });
                    parent.notify('toolbar', { prop: 'getPrevObj', onPropertyChange: false, value: { obj: obj2 } });
                    Eif (obj1['prevCropObj'] && obj2['prevObj']) {
                        parent.objColl = [];
                        parent.pointColl = [];
                        parent.freehandCounter = 0;
                        parent.cropObj = ej2_base_1.extend({}, obj1['prevCropObj'], {}, true);
                        this.setCurrentObj(obj2['prevObj']);
                        parent.objColl = obj2['prevObj']['objColl'];
                        parent.pointColl = obj2['prevObj']['pointColl'];
                        parent.freehandCounter = parent.pointColl.length;
                        parent.transform.straighten = 0;
                        parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                            value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
                        var currObj = parent.currSelectionPoint ?
                            ej2_base_1.extend({}, parent.currSelectionPoint, {}, true) : null;
                        parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                            value: { zoomFactor: -parent.transform.zoomFactor, zoomPoint: null, isResize: true } });
                        parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                            value: { zoomFactor: obj2['prevObj']['defaultZoom'], zoomPoint: null, isResize: true } });
                        parent.currSelectionPoint = currObj;
                        Eif (obj2['prevObj'].zoomFactor) {
                            parent.setProperties({ zoomSettings: { zoomFactor: obj2['prevObj'].zoomFactor } }, true);
                        }
                        parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
                            value: { previousZoomValue: parent.zoomSettings.zoomFactor } });
                    }
                    parent.isResize = false;
                    parent.notify('transform', { prop: 'setResizedImgAngle', onPropertyChange: false, value: { angle: null } });
                    var temp = parent.isCropTab;
                    parent.isCropTab = false;
                    this.updateCropSelObj();
                    parent.cancelCropSelection = null;
                    parent.isCropTab = temp;
                }
            }
            switch (true) {
                case parent.togglePen:
                    editCompleteArgs['action'] = 'freehand-draw';
                    this.cancelPen();
                    break;
                case parent.activeObj.shape === 'text':
                    editCompleteArgs['action'] = 'text';
                    this.cancelText();
                    break;
                case shapes.indexOf(parent.activeObj.shape) !== -1:
                    editCompleteArgs['action'] = parent.activeObj.shape;
                    this.cancelShape();
                    parent.currObjType.isRedact = false;
                    break;
                case isCropSelection:
                    editCompleteArgs['action'] = 'crop-selection';
                    this.cancelSelection();
                    break;
                default:
                    parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                    this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                    parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
                    break;
            }
            parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
            parent.upperCanvas.style.cursor = parent.cursor = 'default';
            parent.currObjType.isCustomCrop = false;
            this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
            var eventargs = { type: 'main', isApplyBtn: null, isCropping: false, isZooming: null };
            parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
        };
        Draw.prototype.cancelPen = function () {
            var parent = this.parent;
            this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            parent.togglePen = false;
            parent.upperCanvas.style.cursor = parent.cursor = 'default';
            var tempPointsColl = ej2_base_1.extend([], parent.pointColl, [], true);
            parent.pointColl = {};
            for (var i = 0; i < this.tempFreehandCounter; i++) {
                parent.pointColl[i] = tempPointsColl[i];
            }
            parent.freehandCounter = this.tempFreehandCounter;
            parent.notify('freehand-draw', { prop: 'setCurrentFreehandDrawIndex', value: { value: this.tempCurrFhdIndex } });
            parent.activeObj.strokeSettings = this.tempStrokeSettings;
            parent.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: parent.activeObj.strokeSettings, strokeColor: null,
                    fillColor: null, strokeWidth: null, radius: null } });
            parent.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: this.tempStrokeWidth } });
            parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
            parent.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: false } });
            parent.objColl = ej2_base_1.extend([], this.tempObjColl, [], true);
            parent.pointColl = ej2_base_1.extend([], this.tempPointColl, [], true);
            parent.freehandCounter = parent.pointColl.length;
            this.tempPointColl = {};
            this.renderImage();
            parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok', isCancel: true } });
        };
        Draw.prototype.cancelText = function () {
            var parent = this.parent;
            parent.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
                value: { textSettings: this.tempTextSettings, fontFamily: null, fontSize: null } });
            parent.notify('shape', { prop: 'setStrokeSettings',
                value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null, radius: null } });
            Iif (ej2_base_1.isNullOrUndefined(parent.activeObj.currIndex)) {
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            }
            else {
                var object = { appliedUndoRedoColl: [] };
                parent.notify('undo-redo', { prop: 'getAppliedUndoRedoColl', value: { obj: object } });
                var len = object['appliedUndoRedoColl'].length;
                var appliedColl = object['appliedUndoRedoColl'][len - 1];
                Iif (this.prevActObj && appliedColl && appliedColl.currentObjColl.length &&
                    appliedColl.currentObjColl[appliedColl.currentObjColl.length - 1].currIndex === this.prevActObj.currIndex) {
                    parent.activeObj = this.prevActObj;
                    this.prevActObj = null;
                }
                else {
                    parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                    this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                }
            }
            parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
            this.tempTextSettings = { text: 'Enter Text', fontFamily: parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false,
                italic: false, underline: false, strikethrough: false };
            parent.objColl = ej2_base_1.extend([], this.tempObjColl, [], true);
            parent.pointColl = ej2_base_1.extend([], this.tempPointColl, [], true);
            this.renderImage();
            this.tempObjColl = [];
            parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok', isCancel: true } });
        };
        Draw.prototype.cancelShape = function () {
            var parent = this.parent;
            parent.notify('shape', { prop: 'setStrokeSettings',
                value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null, radius: null } });
            Iif (ej2_base_1.isNullOrUndefined(parent.activeObj.currIndex)) {
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            }
            else Iif (this.isNewPath) {
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                this.renderImage();
            }
            else {
                var object = { appliedUndoRedoColl: [] };
                parent.notify('undo-redo', { prop: 'getAppliedUndoRedoColl', value: { obj: object } });
                var obj = void 0;
                for (var i = 0, iLen = object['appliedUndoRedoColl'].length; i < iLen; i++) {
                    var currObjColl = object['appliedUndoRedoColl'][i].currentObjColl;
                    for (var j = 0, jLen = currObjColl.length; j < jLen; j++) {
                        Iif (this.prevActObj && this.prevActObj.currIndex &&
                            currObjColl[j].currIndex === this.prevActObj.currIndex) {
                            obj = currObjColl[0];
                            break;
                        }
                    }
                }
                Iif (this.prevActObj && obj) {
                    parent.activeObj = this.prevActObj;
                    this.prevActObj = null;
                    parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false, value: { obj: parent.activeObj } });
                    parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
                    parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: true } });
                }
                else {
                    parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                    this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                }
                var undoRedoObj = { undoRedoStep: null };
                parent.notify('undo-redo', { prop: 'getUndoRedoStep', value: { obj: undoRedoObj } });
                if (object['appliedUndoRedoColl'][(undoRedoObj['undoRedoStep'] - 1)]) {
                    parent.objColl =
                        ej2_base_1.extend([], object['appliedUndoRedoColl'][(undoRedoObj['undoRedoStep'] - 1)].currentObjColl, [], true);
                }
                else {
                    parent.objColl = [];
                }
                this.renderImage();
            }
            parent.currObjType.isDragging = false;
            parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
            parent.objColl = ej2_base_1.extend([], this.tempObjColl, [], true);
            parent.pointColl = ej2_base_1.extend([], this.tempPointColl, [], true);
            this.renderImage();
            this.tempObjColl = [];
            parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok', isCancel: true } });
        };
        Draw.prototype.cancelSelection = function () {
            var parent = this.parent;
            Eif (parent.cancelCropSelection) {
                var obj = { value: parent.tempStraighten };
                parent.transform.straighten = obj['value'];
                parent.straightenBaseImageCanvas();
                parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
                parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
                parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: parent.activeObj } });
                parent.notify('crop', { prop: 'resizeWrapper' });
                this.updateCropSelObj();
                if (this.tempStraightenDestPoints && JSON.stringify(this.tempStraightenDestPoints) !== JSON.stringify(this.straightenDestPoints)) {
                    this.straightenDestPoints = ej2_base_1.extend({}, this.tempStraightenDestPoints, {}, true);
                }
            }
        };
        Draw.prototype.updateCropSelObj = function () {
            var parent = this.parent;
            Eif (parent.cancelCropSelection) {
                parent.cropObj = ej2_base_1.extend({}, parent.cancelCropSelection.previousCropObj, {}, true);
                parent.afterCropActions = parent.cancelCropSelection.previousObj.afterCropActions;
                parent.notify('undo-redo', { prop: 'undoDefault', onPropertyChange: false, value: { obj: parent.cancelCropSelection } });
                parent.currSelectionPoint = ej2_base_1.extend({}, parent.cancelCropSelection.previousCropObj.activeObj, true);
                if (parent.currSelectionPoint && ej2_base_1.isNullOrUndefined(parent.currSelectionPoint.shape)) {
                    parent.currSelectionPoint = null;
                }
                this.clearOuterCanvas(this.lowerContext);
                if (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
                    parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                        value: { context: this.lowerContext, isSave: null, isFlip: null } });
                }
            }
        };
        Draw.prototype.updateCropSelection = function () {
            var parent = this.parent;
            var object = { currObj: {} };
            parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var currentObj = object['currObj'];
            currentObj.objColl = ej2_base_1.extend([], parent.objColl, [], true);
            currentObj.pointColl = ej2_base_1.extend([], parent.pointColl, [], true);
            currentObj.afterCropActions = ej2_base_1.extend([], parent.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            currentObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            parent.cancelCropSelection = { operation: 'cropTransform', previousObj: currentObj, currentObj: currentObj,
                previousObjColl: currentObj.objColl, currentObjColl: currentObj.objColl,
                previousPointColl: currentObj.pointColl, currentPointColl: currentObj.pointColl,
                previousSelPointColl: currentObj.selPointColl, currentSelPointColl: currentObj.selPointColl,
                previousCropObj: ej2_base_1.extend({}, parent.cropObj, {}, true),
                currentCropObj: ej2_base_1.extend({}, parent.cropObj, {}, true),
                previousText: null, currentText: null, filter: null, isCircleCrop: parent.isCircleCrop };
        };
        Draw.prototype.updateFlipPan = function (tempSelectionObj) {
            var parent = this.parent;
            Eif (parent.transform.currFlipState !== '') {
                var temp = this.lowerContext.filter;
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                parent.notify('transform', { prop: 'rotatedFlip', onPropertyChange: false });
                this.lowerContext.filter = 'none';
                parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
                    value: { context: this.lowerContext, points: null } });
                this.lowerContext.filter = temp;
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                Iif (tempSelectionObj) {
                    this.drawObject('duplicate', tempSelectionObj);
                }
            }
        };
        Draw.prototype.select = function (type, startX, startY, width, height) {
            var parent = this.parent;
            type = type.toLowerCase();
            if (!parent.disabled && parent.isImageLoaded) {
                parent.allowDownScale = false;
                var object = { currObj: {} };
                parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                var previousObj = object['currObj'];
                previousObj.objColl = ej2_base_1.extend([], parent.objColl, [], true);
                previousObj.pointColl = ej2_base_1.extend([], parent.pointColl, [], true);
                previousObj.afterCropActions = parent.afterCropActions;
                var selPointCollObj = { selPointColl: null };
                parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                previousObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                parent.notify('crop', { prop: 'setPreviousCropCurrentObj', onPropertyChange: false, value: { obj: previousObj } });
                if (parent.transform.zoomFactor > 0 && parent.activeObj.shape &&
                    parent.activeObj.shape.split('-')[0] === 'crop' && ej2_base_1.isNullOrUndefined(this.currSelPoint)) {
                    this.currSelPoint = ej2_base_1.extend({}, parent.activeObj, {}, true);
                }
                var isPrevent = false;
                var splitWords = void 0;
                if (parent.activeObj.shape !== undefined) {
                    splitWords = parent.activeObj.shape.split('-');
                }
                if (splitWords === undefined && parent.currObjType.isCustomCrop) {
                    isPrevent = true;
                }
                else if (splitWords !== undefined && splitWords[0] === 'crop') {
                    isPrevent = true;
                }
                var obj = { currObj: {} };
                parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: obj } });
                var prevObj = obj['currObj'];
                prevObj.objColl = ej2_base_1.extend([], parent.objColl, [], true);
                prevObj.pointColl = ej2_base_1.extend([], parent.pointColl, [], true);
                prevObj.afterCropActions = ej2_base_1.extend([], parent.afterCropActions, [], true);
                parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
                    value: { x: null, y: null, isMouseDown: null } });
                parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                parent.notify('shape', { prop: 'setKeyHistory', onPropertyChange: false, value: { keyHistory: '' } });
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                parent.upperCanvas.style.display = 'block';
                if (parent.currSelectionPoint || parent.transform.defaultZoomFactor !== 0 ||
                    (parent.transform.degree !== 0 && parent.panPoint.totalPannedInternalPoint.x !== 0 &&
                        parent.panPoint.totalPannedInternalPoint.y !== 0 && !isPrevent)) {
                    parent.isCircleCrop = false;
                    if (parent.transform.defaultZoomFactor !== 0 && !this.isResizeSelect) {
                        var isCropTab = parent.isCropTab;
                        parent.isCropTab = false;
                        parent.notify('transform', { prop: 'resetZoom', onPropertyChange: false });
                        parent.isCropTab = isCropTab;
                        this.resetPanPoints();
                    }
                    parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
                    parent.isCropTab = true;
                    parent.isCircleCrop = false;
                    Eif (!this.isResizeSelect) {
                        parent.notify('crop', { prop: 'setCurrSelPoints', onPropertyChange: false, value: { isSetDimension: true } });
                    }
                    parent.transform.zoomFactor = parent.transform.cropZoomFactor;
                    if (ej2_base_1.isNullOrUndefined(parent.cropObj.activeObj.shape)) {
                        parent.currObjType.shape = 'crop-' + type;
                        this.drawNewSelection(type, startX, startY, width, height);
                    }
                }
                else {
                    if (!this.isCropSelect) {
                        parent.notify('crop', { prop: 'adjustStraightenForShapes', onPropertyChange: false,
                            value: { type: 'reverse', isInitialRotated: true } });
                        parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
                        this.renderImage();
                    }
                    else {
                        this.isCropSelect = false;
                    }
                    if (type === 'custom') {
                        parent.currObjType.shape = '';
                    }
                    this.drawNewSelection(type, startX, startY, width, height);
                }
            }
        };
        Draw.prototype.drawNewSelection = function (type, startX, startY, width, height) {
            var parent = this.parent;
            var points;
            var cropShape = 'crop-' + type.toLowerCase();
            if (cropShape === 'crop-custom') {
                Eif (parent.currObjType.shape === '' || parent.currObjType.shape === 'crop-custom') {
                    this.drawCustomSelection('crop-custom', startX, startY, width, height);
                    this.adjToStraighten();
                    this.updateSelectionInsert();
                    if (parent.isStraightening) {
                        this.straightenActObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                        this.straightenInitZoom = parent.transform.zoomFactor;
                    }
                }
            }
            else if (cropShape === 'crop-canvas') {
                parent.upperCanvas.style.display = 'block';
                parent.notify('selection', { prop: 'setDragCanvas', value: { bool: true } });
            }
            else {
                parent.currObjType.isCustomCrop = false;
                parent.currObjType.shape = cropShape;
                if (width && height) {
                    points = { startX: startX, startY: startY, endX: startX + width, endY: startY + height,
                        width: width, height: height };
                }
                else if (width && cropShape === 'crop-circle') {
                    points = { startX: startX, startY: startY, endX: startX + width, endY: startY + width,
                        width: width, height: width };
                }
                parent.activeObj.shape = cropShape;
                this.updateSelectionInsert(points);
            }
        };
        Draw.prototype.updateSelectionInsert = function (points) {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var obj = { shapeSettingsObj: {} };
            parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
            var selectionSettings = { type: parent.getSelectionType(obj['shapeSettingsObj']['type']), startX: obj['shapeSettingsObj']['startX'],
                startY: obj['shapeSettingsObj']['startY'], width: obj['shapeSettingsObj']['width'], height: obj['shapeSettingsObj']['height'] };
            var selectionChangingArgs = { action: 'insert', previousSelectionSettings: selectionSettings,
                currentSelectionSettings: selectionSettings };
            parent.trigger('selectionChanging', selectionChangingArgs);
            parent.editCompleteArgs = selectionChangingArgs;
            parent.notify('shape', { prop: 'updSelChangeEventArgs', onPropertyChange: false,
                value: { selectionSettings: selectionChangingArgs.currentSelectionSettings } });
            if (selectionChangingArgs.currentSelectionSettings.type === 'Custom') {
                this.drawObject('duplicate', parent.activeObj, null, null, true);
            }
            else {
                Iif (actPoint.startX !== 0 || actPoint.startY !== 0 ||
                    actPoint.width !== 0 || actPoint.height !== 0) {
                    points = { startX: actPoint.startX, startY: actPoint.startY,
                        endX: actPoint.endX, endY: actPoint.endY,
                        width: actPoint.width, height: actPoint.height };
                }
                this.drawObject('duplicate', null, true, points);
            }
        };
        Draw.prototype.drawCustomSelection = function (cropShape, startX, startY, width, height) {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            parent.currObjType.isCustomCrop = true;
            this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            parent.currObjType.shape = parent.activeObj.shape = cropShape.toLowerCase();
            if (!ej2_base_1.isNullOrUndefined(startX) && !ej2_base_1.isNullOrUndefined(startY) && !ej2_base_1.isNullOrUndefined(width) && !ej2_base_1.isNullOrUndefined(height)) {
                actPoint.startX = startX;
                actPoint.startY = startY;
                actPoint.endX = startX + width;
                actPoint.endY = startY + height;
                actPoint.width = width;
                actPoint.height = height;
            }
            else if (width && height) {
                var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
                actPoint.width = width;
                actPoint.height = height;
                actPoint.startX = destLeft + ((destWidth / 2) - (width / 2));
                actPoint.startY = destTop + ((destHeight / 2) - (height / 2));
            }
            else {
                if (ej2_base_1.isNullOrUndefined(parent.transform.zoomFactor) || parent.transform.zoomFactor === 0) {
                    var _b = parent.img, destLeft_1 = _b.destLeft, destTop_1 = _b.destTop, destWidth_1 = _b.destWidth, destHeight_1 = _b.destHeight;
                    var lowerCanvasWidth_1 = parent.lowerCanvas.width;
                    var lowerCanvasHeight_1 = parent.lowerCanvas.height;
                    var activePoint_1 = actPoint;
                    Eif (destLeft_1 >= 0 && destTop_1 >= 0) {
                        activePoint_1.startX = destLeft_1;
                        activePoint_1.startY = destTop_1;
                        activePoint_1.endX = destLeft_1 + destWidth_1;
                        activePoint_1.endY = destTop_1 + destHeight_1;
                    }
                    else if (destLeft_1 >= 0) {
                        activePoint_1.startX = destLeft_1;
                        activePoint_1.startY = 7.5;
                        activePoint_1.endX = destLeft_1 + destWidth_1;
                        activePoint_1.endY = lowerCanvasHeight_1 - 15;
                    }
                    else if (destTop_1 >= 0) {
                        activePoint_1.startX = 7.5;
                        activePoint_1.startY = destTop_1;
                        activePoint_1.endX = lowerCanvasWidth_1 - 15;
                        activePoint_1.endY = destTop_1 + destHeight_1;
                    }
                    else {
                        activePoint_1.startX = 7.5;
                        activePoint_1.startY = 7.5;
                        activePoint_1.endX = lowerCanvasWidth_1 - 15;
                        activePoint_1.endY = lowerCanvasHeight_1 - 15;
                    }
                }
                else {
                    var _c = parent.img, destLeft_2 = _c.destLeft, destTop_2 = _c.destTop, destWidth_2 = _c.destWidth, destHeight_2 = _c.destHeight;
                    var lowerCanvasWidth_2 = parent.lowerCanvas.width;
                    var lowerCanvasHeight_2 = parent.lowerCanvas.height;
                    var activePoint_2 = actPoint;
                    activePoint_2.startX = Math.max(destLeft_2 > 0 ? destLeft_2 : 7.5, destLeft_2);
                    activePoint_2.startY = Math.max(destTop_2 > 0 ? destTop_2 : 7.5, destTop_2);
                    activePoint_2.endX = Math.min(destLeft_2 + destWidth_2 + 15 < lowerCanvasWidth_2 ? destLeft_2 + destWidth_2 - 15 :
                        lowerCanvasWidth_2 - 15, destLeft_2 + destWidth_2);
                    activePoint_2.endY = Math.min(destTop_2 + destHeight_2 + 15 < lowerCanvasHeight_2 ? destTop_2 + destHeight_2 - 15 :
                        lowerCanvasHeight_2 - 15, destTop_2 + destHeight_2);
                }
                var _d = parent.img, destLeft = _d.destLeft, destTop = _d.destTop, destWidth = _d.destWidth, destHeight = _d.destHeight;
                var lowerCanvasWidth = parent.lowerCanvas.clientWidth;
                var lowerCanvasHeight = parent.lowerCanvas.clientHeight;
                var activePoint = actPoint;
                activePoint.startX = Math.max(activePoint.startX, destLeft);
                activePoint.startY = Math.max(activePoint.startY, destTop);
                activePoint.endX = Math.min(activePoint.endX, destLeft + destWidth);
                activePoint.endY = Math.min(activePoint.endY, destTop + destHeight);
                if (parent.transform.straighten > 0) {
                    Eif (this.imgCanvasPoints[0].x > activePoint.startX) {
                        activePoint.startX = this.imgCanvasPoints[0].x;
                    }
                    Iif (this.imgCanvasPoints[0].y > activePoint.startY) {
                        activePoint.startY = this.imgCanvasPoints[0].y;
                    }
                    Eif (this.imgCanvasPoints[2].x < activePoint.endX) {
                        activePoint.endX = this.imgCanvasPoints[2].x;
                    }
                    Iif (this.imgCanvasPoints[2].y < activePoint.endY) {
                        activePoint.endY = this.imgCanvasPoints[2].x;
                    }
                }
                else if (parent.transform.straighten < 0) {
                    Eif (this.imgCanvasPoints[3].x > activePoint.startX) {
                        activePoint.startX = this.imgCanvasPoints[3].x;
                    }
                    Iif (this.imgCanvasPoints[3].y < activePoint.startY) {
                        activePoint.startY = this.imgCanvasPoints[3].y;
                    }
                    Eif (this.imgCanvasPoints[1].x < activePoint.endX) {
                        activePoint.endX = this.imgCanvasPoints[1].x;
                    }
                    Iif (this.imgCanvasPoints[1].y > activePoint.endY) {
                        activePoint.endY = this.imgCanvasPoints[1].x;
                    }
                }
                Iif (activePoint.startX === destLeft && destLeft + destWidth > lowerCanvasWidth) {
                    activePoint.endX = lowerCanvasWidth - 15;
                }
                Iif (activePoint.startY === destTop && destTop + destHeight > lowerCanvasHeight) {
                    activePoint.endY = lowerCanvasHeight - 15;
                }
                Iif (parent.activeObj.activePoint.startX > parent.activeObj.activePoint.endX) {
                    var temp = parent.activeObj.activePoint.startX;
                    parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX;
                    parent.activeObj.activePoint.endX = temp;
                }
                Iif (parent.activeObj.activePoint.startY > parent.activeObj.activePoint.endY) {
                    var temp = parent.activeObj.activePoint.startY;
                    parent.activeObj.activePoint.startY = parent.activeObj.activePoint.endY;
                    parent.activeObj.activePoint.endY = temp;
                }
                parent.activeObj = this.updateWidthHeight(parent.activeObj);
                this.updateActiveObject(actPoint, parent.activeObj);
                this.adjActObj();
            }
            this.updateSelectionInsert();
        };
        Draw.prototype.adjToStraighten = function () {
            var parent = this.parent;
            if (parent.transform.straighten !== 0 && parent.isStraightening) {
                var actPoint = parent.activeObj.activePoint;
                actPoint.startX += 7.5;
                actPoint.startY += 7.5;
                actPoint.endX -= 7.5;
                actPoint.endY -= 7.5;
                parent.activeObj = this.updateWidthHeight(parent.activeObj);
            }
        };
        Draw.prototype.adjActObj = function () {
            var parent = this.parent;
            if (parent.transform.straighten === 0) {
                return;
            }
            var actPoint = parent.activeObj.activePoint;
            var tempActPoint = ej2_base_1.extend({}, actPoint, {}, true);
            var count = 0;
            while (true) {
                count++;
                var object = { isIntersect: null, arr: null };
                parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
                parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: object } });
                if (object['arr'][0] || object['arr'][1] || object['arr'][2] || object['arr'][3] || count === 100) {
                    actPoint = ej2_base_1.extend({}, tempActPoint, {}, true);
                    break;
                }
                tempActPoint = ej2_base_1.extend({}, actPoint, {}, true);
                actPoint.startX -= 5;
                actPoint.endX += 5;
                actPoint.width = actPoint.endX - actPoint.startX;
                this.updateActiveObject(actPoint, parent.activeObj);
            }
        };
        Draw.prototype.callUpdateCurrTransState = function () {
            var parent = this.parent;
            var tempObjColl = ej2_base_1.extend([], parent.objColl, [], true);
            var tempActiveObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            parent.objColl = [];
            parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            this.isRotateZoom = true;
            this.updateCurrTransState('initial');
            this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
            if (parent.transform.degree === 0 && parent.rotateFlipColl.length > 0) {
                parent.img.destLeft += parent.panPoint.totalPannedPoint.x;
                parent.img.destTop += parent.panPoint.totalPannedPoint.y;
            }
            parent.img.destLeft += parent.panPoint.totalPannedInternalPoint.x;
            parent.img.destTop += parent.panPoint.totalPannedInternalPoint.y;
            var temp = this.lowerContext.filter;
            if (parent.transform.degree === 0) {
                parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
            }
            this.drawImage();
            this.updateCurrTransState('reverse');
            if (parent.transform.degree === 0 && parent.rotateFlipColl.length > 0) {
                parent.img.destLeft += parent.panPoint.totalPannedPoint.x;
                parent.img.destTop += parent.panPoint.totalPannedPoint.y;
            }
            this.isRotateZoom = false;
            parent.objColl = tempObjColl;
            var tempTogglePen = parent.togglePen;
            parent.togglePen = false;
            this.lowerContext.filter = 'none';
            var widthObj = { penStrokeWidth: null };
            parent.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj: widthObj } });
            parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                value: { ctx: this.lowerContext, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
            parent.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: widthObj['penStrokeWidth'] } });
            parent.img.destLeft += parent.panPoint.totalPannedInternalPoint.x;
            parent.img.destTop += parent.panPoint.totalPannedInternalPoint.y;
            parent.img.destLeft -= parent.panPoint.totalPannedInternalPoint.x;
            parent.img.destTop -= parent.panPoint.totalPannedInternalPoint.y;
            parent.togglePen = tempTogglePen;
            this.lowerContext.filter = temp;
            parent.activeObj = tempActiveObj;
        };
        Draw.prototype.resetPanPoints = function () {
            this.parent.panPoint.totalPannedPoint = { x: 0, y: 0 };
            this.parent.panPoint.totalPannedClientPoint = { x: 0, y: 0 };
            this.parent.panPoint.totalPannedInternalPoint = { x: 0, y: 0 };
        };
        Draw.prototype.setClientTransDim = function (isPreventDimension) {
            var parent = this.parent;
            if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                parent.img.destLeft = (parent.lowerCanvas.clientWidth - parent.img.destHeight) / 2;
                parent.img.destTop = (parent.lowerCanvas.clientHeight - parent.img.destWidth) / 2;
                var temp = parent.img.destWidth;
                parent.img.destWidth = parent.img.destHeight;
                parent.img.destHeight = temp;
            }
            else {
                if (ej2_base_1.isNullOrUndefined(isPreventDimension)) {
                    parent.img.destLeft = (parent.lowerCanvas.clientWidth - parent.img.destWidth) / 2;
                    parent.img.destTop = (parent.lowerCanvas.clientHeight - parent.img.destHeight) / 2;
                }
            }
        };
        Draw.prototype.redrawImgWithObj = function () {
            var parent = this.parent;
            var obj = { canvasFilter: parent.canvasFilter };
            this.lowerContext.filter = obj['canvasFilter'];
            if (parent.rotateFlipColl.length !== 0) {
                var totalPannedInternalPoint = ej2_base_1.extend({}, parent.panPoint.totalPannedInternalPoint, {}, true);
                var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
                    height: parent.img.destHeight };
                this.callUpdateCurrTransState();
                parent.panPoint.totalPannedInternalPoint = totalPannedInternalPoint;
                parent.img.destLeft = destPoints.startX;
                parent.img.destTop = destPoints.startY;
                parent.img.destWidth = destPoints.width;
                parent.img.destHeight = destPoints.height;
            }
            else {
                this.callUpdateCurrTransState();
            }
            if (parent.isCircleCrop) {
                parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                    value: { context: this.lowerContext, isSave: null, isFlip: null } });
            }
        };
        Draw.prototype.setCurrentObj = function (obj, isUndoRedo, isCircleCropped) {
            var parent = this.parent;
            var isObj = obj ? true : false;
            if (!isObj) {
                parent.cropObj.aspectWidth = parent.aspectWidth;
                parent.cropObj.aspectHeight = parent.aspectHeight;
                parent.cropObj.frame = parent.frameObj.type;
            }
            obj = obj ? obj : parent.cropObj;
            parent.transform.cropZoomFactor = obj.cropZoom;
            parent.transform.defaultZoomFactor = obj.defaultZoom;
            this.straightenInitZoom = obj.straightenZoom;
            if (!isObj) {
                parent.transform.zoomFactor = obj.cropZoom;
            }
            else {
                if (obj.activeObj.shape && obj.activeObj.shape.split('-')[0] === 'crop') {
                    parent.transform.zoomFactor = obj.cropZoom;
                }
                else {
                    parent.transform.zoomFactor = obj.defaultZoom;
                }
            }
            parent.setProperties({ zoomSettings: { zoomFactor: obj.zoomFactor } }, true);
            parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false, value: { previousZoomValue: obj.previousZoomValue } });
            parent.panPoint.totalPannedPoint = ej2_base_1.extend({}, obj.totalPannedPoint, {}, true);
            parent.panPoint.totalPannedClientPoint = ej2_base_1.extend({}, obj.totalPannedClientPoint, {}, true);
            parent.panPoint.totalPannedInternalPoint = ej2_base_1.extend({}, obj.totalPannedInternalPoint, {}, true);
            var point = ej2_base_1.extend({}, obj.tempFlipPanPoint, {}, true);
            parent.notify('crop', { prop: 'setTempFlipPanPoint', onPropertyChange: false, value: { point: point } });
            parent.rotateFlipColl = ej2_base_1.extend([], obj.rotateFlipColl, [], true);
            parent.transform.degree = obj.degree;
            parent.frameObj.type = obj.frame;
            parent.transform.currFlipState = obj.currFlipState;
            parent.notify('filter', { prop: 'setAdjustmentLevel', onPropertyChange: false, value: { adjustmentLevel: obj.adjustmentLevel } });
            parent.notify('filter', { prop: 'setTempAdjVal' });
            parent.currentFilter = obj.currentFilter;
            parent.notify('filter', { prop: 'setTempFilVal' });
            if (parent.transform.straighten !== obj.straighten || isUndoRedo) {
                parent.transform.straighten = obj.straighten;
                parent.straightenBaseImageCanvas();
            }
            parent.img = { destLeft: obj.destPoints.startX, destTop: obj.destPoints.startY, destWidth: obj.destPoints.width,
                destHeight: obj.destPoints.height, srcLeft: obj.srcPoints.startX, srcTop: obj.srcPoints.startY,
                srcWidth: obj.srcPoints.width, srcHeight: obj.srcPoints.height };
            parent.aspectWidth = obj.aspectWidth;
            parent.aspectHeight = obj.aspectHeight;
            if (obj.afterCropActions) {
                parent.afterCropActions = obj.afterCropActions;
            }
            this.lowerContext.filter = obj.filter;
            parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: obj.isBrightAdjust } });
            parent.notify('draw', { prop: 'imageBackgroundColor', onPropertyChange: false, value: { color: obj.bgColor } });
            var isCircleCrop = parent.isCircleCrop;
            var currSelectionPoint;
            if (ej2_base_1.isNullOrUndefined(parent.currSelectionPoint)) {
                currSelectionPoint = null;
            }
            else {
                currSelectionPoint = ej2_base_1.extend({}, parent.currSelectionPoint, {}, true);
                parent.currSelectionPoint = null;
            }
            parent.isCircleCrop = false;
            if (isCircleCropped) {
                parent.frameObj.type = 'none';
            }
            this.drawCropSelectionImage(obj, false);
            if (parent.transform.degree !== 0) {
                if (parent.transform.currFlipState === '') {
                    parent.notify('transform', { prop: 'rotatePan', onPropertyChange: false,
                        value: { isCropSelection: null, isDefaultZoom: null } });
                }
                else {
                    parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: 0, yDiff: 0 } });
                }
                parent.img.destLeft = obj.destPoints.startX;
                parent.img.destTop = obj.destPoints.startY;
                parent.panPoint.totalPannedClientPoint = ej2_base_1.extend({}, obj.totalPannedClientPoint, {}, true);
                parent.panPoint.totalPannedInternalPoint = ej2_base_1.extend({}, obj.totalPannedInternalPoint, {}, true);
            }
            parent.activeObj = ej2_base_1.extend({}, obj.activeObj, {}, true);
            this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
            if (parent.activeObj.activePoint.width !== 0 && parent.activeObj.activePoint.height !== 0) {
                this.drawObject('duplicate', null, null, null, true);
            }
            var activeObj = ej2_base_1.extend({}, obj.activeObj, {}, true);
            var isAfterCropAction = false;
            if (parent.afterCropActions.length > 0) {
                var object = { collection: parent.afterCropActions };
                parent.notify('shape', { prop: 'alignRotateFlipColl', onPropertyChange: false,
                    value: { collection: parent.afterCropActions, isRotateFlipCollection: null, obj: object } });
                parent.afterCropActions = object['collection'];
            }
            var afterCropActions = ej2_base_1.extend([], parent.afterCropActions, [], true);
            if (!isObj && afterCropActions.length > 0) {
                isAfterCropAction = true;
                for (var i = 0, len = afterCropActions.length; i < len; i++) {
                    if (afterCropActions[i] === 'horizontalflip' || afterCropActions[i] === 'verticalflip') {
                        parent.activeObj = ej2_base_1.extend({}, currSelectionPoint, {}, true);
                        this.rotatedFlipCropSel = true;
                    }
                    parent.notify('transform', { prop: 'updateTransform', onPropertyChange: false, value: { text: afterCropActions[i] } });
                }
                activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                this.resetPanPoints();
                parent.activeObj = activeObj;
                this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
                if (parent.activeObj.activePoint.width !== 0 && parent.activeObj.activePoint.height !== 0) {
                    this.drawObject('duplicate', null, null, null, true);
                }
                if (obj.degree !== parent.transform.degree) {
                    parent.transform.cropZoomFactor = null;
                    parent.transform.zoomFactor = 0;
                }
                parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
                if (this.rotatedFlipCropSel) {
                    this.rotatedFlipCropSel = false;
                }
            }
            parent.afterCropActions = afterCropActions;
            if (!this.isCancelAction && !isAfterCropAction) {
                parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
                parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
                parent.img.destLeft = obj.destPoints.startX;
                parent.img.destTop = obj.destPoints.startY;
            }
            parent.activeObj = activeObj;
            parent.isCircleCrop = isCircleCrop;
            if (ej2_base_1.isNullOrUndefined(currSelectionPoint)) {
                parent.currSelectionPoint = null;
            }
            else {
                parent.currSelectionPoint = ej2_base_1.extend({}, currSelectionPoint, {}, true);
                Iif (parent.currSelectionPoint && ej2_base_1.isNullOrUndefined(parent.currSelectionPoint.shape)) {
                    parent.currSelectionPoint = null;
                }
            }
        };
        Draw.prototype.drawCropSelectionImage = function (obj, isObj) {
            var parent = this.parent;
            var temp = this.lowerContext.filter;
            parent.clearContext(this.lowerContext);
            parent.clearContext(this.upperContext);
            this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
            Iif (isObj) {
                this.updateCurrTransState('initial');
            }
            else {
                this.setTransformColl(this.lowerContext, 'initial');
            }
            parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
            this.drawImage();
            Iif (isObj) {
                this.updateCurrTransState('reverse');
            }
            else {
                this.setTransformColl(this.lowerContext, 'reverse');
            }
            parent.img.destLeft = parent.cropObj.destPoints.startX;
            parent.img.destTop = parent.cropObj.destPoints.startY;
            var activeObj = ej2_base_1.extend({}, obj.activeObj, {}, true);
            this.lowerContext.filter = 'none';
            parent.img = { destLeft: obj.destPoints.startX, destTop: obj.destPoints.startY, destWidth: obj.destPoints.width,
                destHeight: obj.destPoints.height, srcLeft: obj.srcPoints.startX, srcTop: obj.srcPoints.startY,
                srcWidth: obj.srcPoints.width, srcHeight: obj.srcPoints.height };
            if (obj.activeObj.activePoint.width !== 0 && obj.activeObj.activePoint.height !== 0) {
                var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
                    height: parent.img.destHeight };
                parent.img.destLeft = obj.activeObj.activePoint.startX;
                parent.img.destTop = obj.activeObj.activePoint.startY;
                parent.img.destWidth = obj.activeObj.activePoint.width;
                parent.img.destHeight = obj.activeObj.activePoint.height;
                parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
                parent.img.destLeft = destPoints.startX;
                parent.img.destTop = destPoints.startY;
                parent.img.destWidth = destPoints.width;
                parent.img.destHeight = destPoints.height;
            }
            parent.activeObj = activeObj;
            this.lowerContext.filter = temp;
        };
        Draw.prototype.performPointZoom = function (x, y, type, isResize, value) {
            var parent = this.parent;
            var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
            var isCropSelection = false;
            if (parent.activeObj.shape && parent.activeObj.shape.indexOf('crop-') > -1) {
                isCropSelection = true;
            }
            if (parent.element.querySelector('.e-contextual-toolbar-wrapper') && !isCropSelection) {
                Iif (!parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
                    parent.okBtn();
                    parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
                }
            }
            var ratioX = (x - destLeft) / destWidth;
            var ratioY = (y - destTop) / destHeight;
            var isUndoRedo = parent.isUndoRedo;
            parent.isUndoRedo = true;
            parent.setProperties({ zoomSettings: { zoomPoint: { x: x, y: y } } }, true);
            var zoomValue = value ? value : (type === 'zoomIn') ? .1 : -.1;
            parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                value: { zoomFactor: zoomValue, zoomPoint: null, isResize: isResize } });
            parent.isUndoRedo = isUndoRedo;
            this.panToPoint(x, y, ratioX, ratioY);
        };
        Draw.prototype.panToPoint = function (x, y, ratioX, ratioY) {
            var parent = this.parent;
            if (parent.transform.zoomFactor > 0) {
                var destLeft = parent.img.destLeft;
                var destTop = parent.img.destTop;
                var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
                if (parent.transform.degree === 0) {
                    parent.img.destLeft = x - (ratioX * parent.img.destWidth);
                    parent.img.destTop = y - (ratioY * parent.img.destHeight);
                    this.drawZoomPanImage(parent.img.destLeft - destLeft, parent.img.destTop - destTop);
                }
                else {
                    var isCropTab = parent.isCropTab;
                    parent.isCropTab = true;
                    var objColl = ej2_base_1.extend([], parent.objColl, [], true);
                    var pointColl = ej2_base_1.extend([], parent.pointColl, [], true);
                    var straightenObj = { straightenPoint: null };
                    parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false,
                        value: { obj: straightenObj } });
                    parent.objColl = [];
                    parent.pointColl = [];
                    parent.freehandCounter = 0;
                    parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false,
                        value: { x: null, y: null, ratioX: null, ratioY: null } });
                    var object = { selPointColl: null };
                    parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                        value: { obj: object } });
                    var cropSelPointColl = object['selPointColl'];
                    parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
                        value: { obj: { selPointColl: [] } } });
                    parent.panPoint.currentPannedPoint = { x: (x - (ratioX * parent.img.destWidth)) - destLeft,
                        y: (y - (ratioY * parent.img.destHeight)) - destTop };
                    parent.notify('transform', { prop: 'rotatePan', onPropertyChange: false,
                        value: { isCropSelection: null, isDefaultZoom: null } });
                    parent.isCropTab = isCropTab;
                    parent.objColl = objColl;
                    parent.pointColl = pointColl;
                    parent.freehandCounter = parent.pointColl.length;
                    if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
                        parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false,
                            value: { x: straightenObj['straightenPoint']['x'], y: straightenObj['straightenPoint']['y'],
                                ratioX: straightenObj['straightenPoint']['ratioX'], ratioY: straightenObj['straightenPoint']['ratioY'] } });
                    }
                    parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
                        value: { obj: { selPointColl: cropSelPointColl } } });
                    parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                        value: { ctx: this.lowerContext, shape: 'pan', pen: 'pan', x: parent.panPoint.currentPannedPoint.x,
                            y: parent.panPoint.currentPannedPoint.y, panRegion: '' } });
                }
                this.adjustPanning(activeObj);
                var isActObj = false;
                for (var i = 0; i < parent.objColl.length; i++) {
                    Iif (JSON.stringify(activeObj.activePoint) === JSON.stringify(parent.objColl[i].activePoint)) {
                        isActObj = true;
                        break;
                    }
                }
                Eif (!isActObj) {
                    parent.activeObj = activeObj;
                }
                if (parent.activeObj.activePoint.width !== 0 && parent.activeObj.activePoint.height !== 0) {
                    this.drawObject('duplicate', null, null, null, true);
                }
            }
        };
        Draw.prototype.adjustPanning = function (activeObj) {
            var parent = this.parent;
            var _a = activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
            if (width !== 0 && height !== 0) {
                var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
                var point = { x: 0, y: 0 };
                if (destLeft > startX) {
                    point.x = destLeft - startX;
                }
                else Iif (destLeft + destWidth < startX + width) {
                    point.x = (destLeft + destWidth) - (startX + width);
                }
                Iif (destTop > startY) {
                    point.y = destTop - startY;
                }
                else Iif (destTop + destHeight < startY + height) {
                    point.y = (destTop + destHeight) - (startY + height);
                }
                if (parent.transform.degree === 0) {
                    parent.img.destLeft -= point.x;
                    parent.img.destTop -= point.y;
                    this.drawZoomPanImage(parent.img.destLeft - destLeft, parent.img.destTop - destTop);
                }
                else {
                    var isCropTab = parent.isCropTab;
                    parent.isCropTab = true;
                    var objColl = ej2_base_1.extend([], parent.objColl, [], true);
                    var pointColl = ej2_base_1.extend([], parent.pointColl, [], true);
                    parent.objColl = [];
                    parent.pointColl = [];
                    parent.freehandCounter = 0;
                    var object = { selPointColl: null };
                    parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                        value: { obj: object } });
                    var cropSelPointColl = object['selPointColl'];
                    parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
                        value: { obj: { selPointColl: [] } } });
                    parent.img.destLeft -= point.x;
                    parent.img.destTop -= point.y;
                    parent.panPoint.currentPannedPoint = { x: parent.img.destLeft - destLeft, y: parent.img.destTop - destTop };
                    parent.notify('transform', { prop: 'rotatePan', onPropertyChange: false,
                        value: { isCropSelection: null, isDefaultZoom: null } });
                    parent.isCropTab = isCropTab;
                    parent.objColl = objColl;
                    parent.pointColl = pointColl;
                    parent.freehandCounter = parent.pointColl.length;
                    parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
                        value: { obj: { selPointColl: cropSelPointColl } } });
                    parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                        value: { ctx: this.lowerContext, shape: 'pan', pen: 'pan', x: parent.panPoint.currentPannedPoint.x,
                            y: parent.panPoint.currentPannedPoint.y, panRegion: '' } });
                }
            }
        };
        Draw.prototype.panToSel = function () {
            var parent = this.parent;
            var activeObj = ej2_base_1.extend({}, parent.activeObj, {}, true);
            var _a = activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
            this.allowRedactStraighten = true;
            var straightenObj = { straightenPoint: null };
            parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false,
                value: { obj: straightenObj } });
            if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
                var panX = (startX + (width / 2)) - straightenObj['straightenPoint']['x'];
                var panY = (startY + (height / 2)) - straightenObj['straightenPoint']['y'];
                if (parent.transform.degree === 0) {
                    parent.img.destLeft += panX;
                    parent.img.destTop += panY;
                    parent.notify('transform', { prop: 'drawPannImage', value: { point: { x: panX, y: panY } } });
                }
                else {
                    parent.panPoint.currentPannedPoint = { x: panX, y: panY };
                    parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panX, yDiff: panY } });
                    parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
                    parent.notify('transform', { prop: 'setTempPanMove', value: { point: null } });
                }
                parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
                var _b = parent.img, destLeft_3 = _b.destLeft, destTop_3 = _b.destTop, destWidth_3 = _b.destWidth, destHeight_3 = _b.destHeight;
                var points = this.imgCanvasPoints;
                points.forEach(function (point) {
                    point.x = (point.ratioX * destWidth_3) + destLeft_3;
                    point.y = (point.ratioY * destHeight_3) + destTop_3;
                });
                this.imgCanvasPoints = points;
                var count = 0;
                if (parent.transform.straighten === 3 && !this.preventStraightening) {
                    this.preventStraightening = true;
                    var temp = parent.prevStraightenedDegree;
                    parent.prevStraightenedDegree = parent.transform.straighten;
                    parent.setStraighten(0);
                    parent.setStraighten(3);
                    parent.prevStraightenedDegree = temp;
                    this.preventStraightening = false;
                }
                while (this.isLinesIntersect() && parent.transform.straighten !== 0 && parent.transform.straighten !== 360 && count < 100) {
                    count++;
                    this.performPointZoom(parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2), parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2), 'zoomIn', false, 0.025);
                    this.updateImgCanvasPoints();
                }
            }
        };
        Draw.prototype.drawZoomPanImage = function (x, y) {
            var parent = this.parent;
            parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                value: { ctx: this.lowerContext, shape: 'pan', pen: 'pan', x: x, y: y, panRegion: '' } });
            this.renderImage(true);
            var obj = { width: 0, height: 0 };
            parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
            var maxDimension = obj;
            maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
            maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
            parent.panPoint.totalPannedPoint.x += x;
            parent.panPoint.totalPannedPoint.y += y;
            parent.notify('crop', { prop: 'setTempFlipPanPoint', onPropertyChange: false, value: { point: { x: 0, y: 0 } } });
        };
        Draw.prototype.openNewImage = function () {
            var _this = this;
            var parent = this.parent;
            var id = parent.element.id;
            var inMemoryContext = parent.inMemoryCanvas.getContext('2d');
            ej2_popups_1.showSpinner(parent.element);
            parent.element.style.opacity = '0.5';
            var toolbar = parent.element.querySelector('#' + id + '_currPos');
            Iif (toolbar) {
                toolbar.style.display = 'none';
            }
            var obj = { defToolbarItems: null };
            parent.notify('toolbar', { prop: 'getDefToolbarItems', value: { obj: obj } });
            if (obj['defToolbarItems'] && obj['defToolbarItems'].length === 0 &&
                (ej2_base_1.isNullOrUndefined(parent.element.querySelector('#' + id + '_toolbar'))) &&
                parent.element.querySelector('#' + id + '_toolbarArea')) {
                var height = parent.element.querySelector('#' + id + '_toolbarArea').clientHeight;
                parent.notify('toolbar', { prop: 'setToolbarHeight', value: { height: height } });
            }
            parent.reset();
            parent.update();
            parent.transform.degree = 0;
            parent.transform.zoomFactor = 0;
            parent.isImageLoaded = false;
            parent.currSelectionPoint = null;
            var type = typeof (this.openURL);
            if (type === 'string') {
                var fileName = this.openURL.split('.');
                if (fileName.length > 1) {
                    fileName = fileName[fileName.length - 2].split('/');
                    this.fileName = fileName[fileName.length - 1];
                }
                else {
                    this.fileName = 'ImageEditor';
                }
                this.fileType = this.getFileExtensionFromURL(this.openURL);
                if (this.fileType) {
                    this.fileType = parent.toPascalCase(this.fileType);
                    var fileType = this.fileType.toLowerCase();
                    if (fileType === 'jpg' || fileType === 'jpeg') {
                        this.fileType = 'Jpeg';
                        fileType = 'jpeg';
                    }
                    if (fileType !== 'jpeg' && fileType !== 'png' && fileType !== 'svg' && fileType !== 'webp' && fileType !== 'bmp') {
                        this.fileType = null;
                    }
                }
                this.imageOnLoad(this.openURL);
                if (typeof (this.openURL) !== 'string' || this.openURL.indexOf('localhost') === -1) {
                    this.getImageSizeFromURL(this.openURL.toString(), function (imageSizeMB) {
                        Eif (imageSizeMB !== null) {
                            _this.parent.notify('toolbar', { prop: 'setInitialSize', value: { value: +imageSizeMB } });
                        }
                    });
                }
            }
            else {
                this.fileName = 'ImageEditor';
                this.fileType = null;
                parent.lowerCanvas = parent.element.querySelector('#' + id + '_lowerCanvas');
                parent.upperCanvas = parent.element.querySelector('#' + id + '_upperCanvas');
                this.lowerContext = parent.lowerCanvas.getContext('2d');
                this.upperContext = parent.upperCanvas.getContext('2d');
                parent.clearContext(this.lowerContext);
                parent.clearContext(this.upperContext);
                parent.clearContext(inMemoryContext);
                parent.inMemoryCanvas.width = this.openURL.width;
                parent.inMemoryCanvas.height = this.openURL.height;
                inMemoryContext.putImageData(this.openURL, 0, 0);
                parent.baseImg.src = parent.inMemoryCanvas.toDataURL();
            }
        };
        Draw.prototype.getImageSizeFromURL = function (imageUrl, callback) {
            return __awaiter(this, void 0, void 0, function () {
                var response, isBlob, imageSizeMB, _a, ex_1;
                return __generator(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            _b.trys.push([0, 5, , 6]);
                            isBlob = imageUrl.indexOf('blob:') === 0;
                            return [4, fetch(imageUrl, { method: isBlob ? 'GET' : 'HEAD' })];
                        case 1:
                            response = _b.sent();
                            Eif (!isBlob) return [3, 3];
                            return [4, response.blob()];
                        case 2:
                            _a = (_b.sent()).size;
                            return [3, 4];
                        case 3:
                            _a = parseInt(response.headers.get('content-length') || '0', 10);
                            _b.label = 4;
                        case 4:
                            imageSizeMB = _a;
                            callback(imageSizeMB);
                            return [3, 6];
                        case 5:
                            ex_1 = _b.sent();
                            console.log(ex_1.message);
                            return [3, 6];
                        case 6: return [2];
                    }
                });
            });
        };
        Draw.prototype.dlgBtnClick = function () {
            this.parent.export();
            this.applyDialogOption();
        };
        Draw.prototype.dlgCloseBtnClick = function () {
            this.applyDialogOption();
        };
        Draw.prototype.applyDialogOption = function () {
            var parent = this.parent;
            if (this.isFileChanged) {
                parent.isImageLoaded = this.isFileChanged = false;
                parent.reset();
                this.checkToolbarTemplate(this.inputElem, this.openURL);
            }
            else {
                this.reset();
                this.openNewImage();
            }
            ej2_base_1.getComponent(document.getElementById(parent.element.id + '_dialog'), 'dialog').destroy();
            this.isImageEdited = false;
        };
        Draw.prototype.showDialogPopup = function () {
            var parent = this.parent;
            var headerObj = { key: 'ConfirmDialogHeader' };
            parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: headerObj } });
            var contentObj = { key: 'ConfirmDialogContent' };
            parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
            var yesObj = { key: 'Yes' };
            parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: yesObj } });
            var noObj = { key: 'No' };
            parent.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: noObj } });
            parent.element.querySelector('#' + parent.element.id + '_dialog').style.display = 'block';
            var dialog = new ej2_popups_1.Dialog({
                header: headerObj['value'],
                closeOnEscape: true,
                content: '<span>' + contentObj['value'] + '</span>',
                target: document.getElementById('target'),
                width: '285px',
                isModal: true,
                animationSettings: { effect: 'Zoom' },
                close: this.dlgCloseBtnClick.bind(this),
                buttons: [
                    { click: this.dlgCloseBtnClick.bind(this),
                        buttonModel: { content: noObj['value'], iconCss: 'e-icons e-close' }
                    },
                    { click: this.dlgBtnClick.bind(this),
                        buttonModel: { content: yesObj['value'], isPrimary: true, iconCss: 'e-icons e-check' } }
                ]
            });
            dialog.appendTo('#' + parent.element.id + '_dialog');
        };
        Draw.prototype.restoreOldImage = function () {
            var _this = this;
            var parent = this.parent;
            var dropArea = parent.element.querySelector('#' + parent.element.id + '_dropArea');
            var extension = parent.getExtensionArray();
            var openURLType = typeof this.openURL;
            if (openURLType !== 'string') {
                this.openImageData(dropArea);
                return;
            }
            var fileType = this.getFileExtensionFromURL(this.openURL);
            if (fileType) {
                fileType = fileType.toLowerCase();
                fileType = (fileType === 'jpg' || fileType === 'jpeg') ? 'jpeg' : fileType;
            }
            var isAllowedFileType = (fileType ? (extension.indexOf(fileType) > -1 ||
                (fileType === 'jpeg' && (parent.uploadSettings.allowedExtensions.indexOf('jpg') > -1 ||
                    parent.uploadSettings.allowedExtensions.indexOf('jpeg') > -1))) : false) || this.isNullExtension;
            if ((this.openURL.indexOf('data:image/') > -1 && this.openURL.indexOf('base64') > -1) ||
                this.openURL.indexOf('blob') > -1) {
                this.openImageData(dropArea, true);
            }
            else if (parent.uploadSettings.minFileSize || parent.uploadSettings.maxFileSize) {
                this.getImageSizeFromURL(this.openURL.toString(), function (imageSizeMB) {
                    var isInvalidSize = (parent.uploadSettings.minFileSize && imageSizeMB < parent.uploadSettings.minFileSize) ||
                        (parent.uploadSettings.maxFileSize && imageSizeMB > parent.uploadSettings.maxFileSize);
                    _this.handleFileSize(!isAllowedFileType || isInvalidSize, dropArea, !isAllowedFileType);
                });
            }
            else {
                this.handleFileSize(!isAllowedFileType, dropArea, !isAllowedFileType);
            }
        };
        Draw.prototype.handleFileSize = function (isError, dropArea, fileTypeError) {
            var parent = this.parent;
            if (isError) {
                this.errorLoading();
                parent.showDialogPopup('unsupported', fileTypeError);
                Eif (dropArea && !parent.isImageLoaded) {
                    dropArea.style.display = 'flex';
                }
            }
            else {
                Eif (dropArea) {
                    dropArea.style.display = 'none';
                }
                if (this.parent.isImageLoaded) {
                    this.reset();
                }
                this.openNewImage();
            }
        };
        Draw.prototype.openImageData = function (dropArea, isBase64) {
            var parent = this.parent;
            var proxy = this;
            var canvas = parent.createElement('canvas');
            var ctx = canvas.getContext('2d');
            if (!parent.uploadSettings.minFileSize && !parent.uploadSettings.maxFileSize) {
                this.handleFileSize(false, dropArea, false);
                return;
            }
            if (isBase64) {
                var img_1 = new Image();
                img_1.src = this.openURL;
                img_1.onload = function () {
                    ctx.canvas.width = img_1.width;
                    ctx.canvas.height = img_1.height;
                    ctx.drawImage(img_1, 0, 0);
                    proxy.getImageSize(canvas, dropArea);
                };
            }
            else {
                canvas.width = this.openURL.width;
                canvas.height = this.openURL.height;
                ctx.putImageData(this.openURL, 0, 0);
                this.getImageSize(canvas, dropArea);
            }
        };
        Draw.prototype.getImageSize = function (canvas, dropArea) {
            var parent = this.parent;
            canvas.toBlob((function (blob) {
                Iif ((parent.uploadSettings.minFileSize && blob.size < parent.uploadSettings.minFileSize) ||
                    (parent.uploadSettings.maxFileSize && blob.size > parent.uploadSettings.maxFileSize)) {
                    this.handleFileSize(true, dropArea, false);
                }
                else {
                    this.handleFileSize(false, dropArea, false);
                }
            }).bind(this), 'image/jpeg', 1);
        };
        Draw.prototype.open = function (data) {
            Eif (!this.parent.disabled) {
                this.openURL = data;
                this.restoreOldImage();
            }
        };
        Draw.prototype.getInitialLoaded = function (object) {
            object['isInitialLoaded'] = this.isInitialLoading;
        };
        Draw.prototype.getFileExtensionFromURL = function (url) {
            var lastDotIndex = url.lastIndexOf('.');
            if (lastDotIndex !== -1) {
                return url.slice(lastDotIndex + 1).toLowerCase();
            }
            else if (url.indexOf('base64') !== -1) {
                return url.slice(url.indexOf('/') + 1, url.indexOf(';')).toLowerCase();
            }
            return null;
        };
        Draw.prototype.fileSelect = function (inputElement, args) {
            var parent = this.parent;
            var dropArea = parent.element.querySelector('#' + parent.element.id + '_dropArea');
            if (dropArea) {
                dropArea.style.display = 'none';
            }
            if (!parent.disabled) {
                var filesData = void 0;
                var fileData = void 0;
                if (args.target) {
                    filesData = args.target.files[0];
                    fileData = filesData;
                }
                else {
                    filesData = fileData = args.filesData[0].rawFile;
                }
                var fileExtension = void 0;
                if (fileData.name) {
                    var fileExtensionArray = fileData.name.split('.');
                    fileExtension = fileExtensionArray[fileExtensionArray.length - 1].toLowerCase();
                }
                var extension = parent.getExtensionArray();
                var isJPG = ((fileExtension === 'jpg' || fileExtension === 'jpeg') && (parent.uploadSettings.allowedExtensions.indexOf('jpg') > -1 || parent.uploadSettings.allowedExtensions.indexOf('jpeg') > -1));
                if ((fileExtension && (extension.indexOf(fileExtension) === -1 && !isJPG)) ||
                    ((parent.uploadSettings.minFileSize && fileData.size < parent.uploadSettings.minFileSize) ||
                        (parent.uploadSettings.maxFileSize && fileData.size > parent.uploadSettings.maxFileSize))) {
                    this.errorLoading();
                    return;
                }
                parent.imageSettings = { width: null, height: null };
                parent.aspectRatioBaseDimension = null;
                ej2_popups_1.showSpinner(parent.element);
                parent.element.style.opacity = '0.5';
                this.inputElem = inputElement;
                fileExtension = fileData.name && fileData.name.split('.')[1];
                if (fileExtension) {
                    var fileType = parent.toPascalCase(fileExtension);
                    if (fileType === 'JPG' || fileType === 'Jpg') {
                        this.fileType = 'Jpeg';
                    }
                    else {
                        this.fileType = fileType;
                    }
                }
                else {
                    this.fileType = null;
                }
                var URL_1 = window.URL;
                var url = URL_1.createObjectURL(filesData);
                this.openURL = url;
                if (parent.isImageLoaded && !parent.isChangesSaved && (this.isImageEdited || parent.pointColl.length > 0 || parent.objColl.length > 0)) {
                    this.isFileChanged = true;
                    this.showDialogPopup();
                }
                else {
                    this.checkToolbarTemplate(inputElement, url);
                }
            }
        };
        Draw.prototype.checkToolbarTemplate = function (inputElement, url) {
            var parent = this.parent;
            if (ej2_base_1.isNullOrUndefined(parent.toolbarTemplate)) {
                parent.reset();
                parent.update();
            }
            this.fileName = inputElement.value.split('\\')[inputElement.value.split('\\').length - 1];
            this.fileName = this.fileName.split('.')[0];
            this.imageOnLoad(url.toString());
            inputElement.value = '';
        };
        Draw.prototype.moveToSelectionRange = function (type, activeObj) {
            var parent = this.parent;
            Eif (parent.activeObj.shape) {
                var isRotated = false;
                for (var i = 0, len = parent.rotateFlipColl.length; i < len; i++) {
                    var degree = parent.rotateFlipColl[i];
                    if (degree === 90 || degree === -90) {
                        isRotated = true;
                        break;
                    }
                }
                if (isRotated) {
                    Iif (parent.transform.degree === 0) {
                        return;
                    }
                    var zoomFactor = parent.transform.zoomFactor;
                    parent.objColl.push(parent.activeObj);
                    parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                    var currObj = parent.objColl[parent.objColl.length - 1];
                    if (type === 'rotateleft' || type === 'rotateright') {
                        if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                            Eif (currObj.activePoint.width < activeObj.activePoint.height) {
                                for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
                                    Eif (currObj.activePoint.width >= activeObj.activePoint.height ||
                                        this.isSelectionBiggerThanCanvas(currObj) ||
                                        this.isSelectionOutsideCanvas(currObj)) {
                                        Iif (!ej2_base_1.isNullOrUndefined(zoomFactor)) {
                                            parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                                value: { zoomFactor: -0.1, zoomPoint: null }, isResize: null });
                                        }
                                        break;
                                    }
                                    zoomFactor += 0.1;
                                    parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                        value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
                                }
                            }
                            else {
                                for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
                                    if (currObj.activePoint.width >= activeObj.activePoint.height ||
                                        this.isSelectionBiggerThanCanvas(currObj) ||
                                        this.isSelectionOutsideCanvas(currObj)) {
                                        if (!ej2_base_1.isNullOrUndefined(zoomFactor)) {
                                            parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                                value: { zoomFactor: 0.1, zoomPoint: null, isResize: null } });
                                        }
                                        break;
                                    }
                                    zoomFactor -= .1;
                                    parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                        value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
                                }
                            }
                        }
                        else {
                            Iif (currObj.activePoint.height < activeObj.activePoint.width) {
                                for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
                                    if (currObj.activePoint.height >= activeObj.activePoint.width ||
                                        this.isSelectionBiggerThanCanvas(currObj) ||
                                        this.isSelectionOutsideCanvas(currObj)) {
                                        if (!ej2_base_1.isNullOrUndefined(zoomFactor)) {
                                            parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                                value: { zoomFactor: -0.1, zoomPoint: null }, isResize: null });
                                        }
                                        break;
                                    }
                                    zoomFactor += 0.1;
                                    parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                        value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
                                }
                            }
                            else {
                                for (var i = 2; i < parent.zoomSettings.maxZoomFactor; i++) {
                                    Eif (currObj.activePoint.height >= activeObj.activePoint.width ||
                                        this.isSelectionBiggerThanCanvas(currObj) ||
                                        this.isSelectionOutsideCanvas(currObj)) {
                                        Iif (!ej2_base_1.isNullOrUndefined(zoomFactor)) {
                                            parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                                value: { zoomFactor: 0.1, zoomPoint: null }, isResize: null });
                                        }
                                        break;
                                    }
                                    zoomFactor -= .1;
                                    parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                        value: { zoomFactor: zoomFactor, zoomPoint: null }, isResize: null });
                                }
                            }
                        }
                    }
                    var panX = (parent.lowerCanvas.clientWidth / 2) - (currObj.activePoint.startX +
                        (currObj.activePoint.width / 2));
                    var panY = ((parent.lowerCanvas.clientHeight) / 2) - (currObj.activePoint.startY +
                        (currObj.activePoint.height / 2));
                    Eif (ej2_base_1.isNullOrUndefined(parent.activeObj.shape)) {
                        parent.activeObj = ej2_base_1.extend({}, activeObj, {}, true);
                    }
                    Iif (parent.transform.degree === 0) {
                        parent.img.destLeft += panX;
                        parent.img.destTop += panY;
                        parent.notify('transform', { prop: 'drawPannImage', value: { point: { x: panX, y: panY } } });
                    }
                    else {
                        parent.panPoint.currentPannedPoint = { x: panX, y: panY };
                        parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panX, yDiff: panY } });
                        parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
                    }
                    parent.notify('transform', { prop: 'setTempPanMove', onPropertyChange: false,
                        value: { point: null } });
                    parent.activeObj = ej2_base_1.extend({}, parent.objColl[parent.objColl.length - 1]);
                    parent.objColl.pop();
                    parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
                }
            }
        };
        Draw.prototype.isSelectionBiggerThanCanvas = function (obj) {
            var isBigger = false;
            var parent = this.parent;
            var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
            if (startX <= destLeft || startY <= destTop || endX >= destLeft + destWidth || endY >= destTop + destHeight) {
                isBigger = true;
            }
            return isBigger;
        };
        Draw.prototype.isSelectionOutsideCanvas = function (obj) {
            var isOutside = false;
            var parent = this.parent;
            Eif ((obj.activePoint.height < parent.lowerCanvas.height - parent.toolbarHeight) ||
                (obj.activePoint.width < parent.lowerCanvas.width)) {
                isOutside = true;
            }
            return isOutside;
        };
        Draw.prototype.downScaleImgCanvas = function (ctx, isImgAnnotation, isHFlip, isVFlip) {
            var parent = this.parent;
            var canvas = isImgAnnotation ? parent.activeObj.imageCanvas : parent.baseImgCanvas;
            var img = isImgAnnotation ? parent.activeObj.imageElement : parent.baseImg;
            var width = isImgAnnotation ? parent.activeObj.activePoint.width : parent.img.destWidth;
            var height = isImgAnnotation ? parent.activeObj.activePoint.height : parent.img.destHeight;
            var obj = { width: 0, height: 0 };
            if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
                parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                    value: { width: img.height, height: img.width, obj: obj, isImgShape: isImgAnnotation } });
            }
            else {
                parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                    value: { width: img.width, height: img.height, obj: obj, isImgShape: isImgAnnotation } });
            }
            if (isImgAnnotation || (parent.allowDownScale && !parent.isCropTab && !parent.isCropToolbar && img.width !== 0 && img.height !== 0
                && obj['width'] * 0.75 > width && obj['height'] * 0.75 > height)) {
                var tempCanvas = parent.createElement('canvas', {
                    id: parent.element.id + '_downScaleCanvas', attrs: { name: 'canvasImage' }
                });
                tempCanvas.width = isImgAnnotation ? img.width : parent.img.srcWidth;
                tempCanvas.height = isImgAnnotation ? img.height : parent.img.srcHeight;
                if (isImgAnnotation) {
                    tempCanvas.getContext('2d').drawImage(img, 0, 0, tempCanvas.width, tempCanvas.height);
                }
                else {
                    Iif (this.imageBackgroundColor !== '') {
                        ctx.fillStyle = this.imageBackgroundColor;
                        ctx.fillRect(parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
                    }
                    tempCanvas.getContext('2d').drawImage(canvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, tempCanvas.width, tempCanvas.height);
                }
                if (isImgAnnotation || this.isDownScale) {
                    this.downScale(tempCanvas, width, height, isImgAnnotation);
                }
                if (isImgAnnotation) {
                    ctx.canvas.width = tempCanvas.width;
                    ctx.canvas.height = tempCanvas.height;
                    Iif (isHFlip && isVFlip) {
                        ctx.translate(parent.activeObj.imageCanvas.width, 0);
                        ctx.scale(-1, 1);
                        ctx.translate(0, parent.activeObj.imageCanvas.height);
                        ctx.scale(1, -1);
                    }
                    else {
                        if (isHFlip) {
                            if (ej2_base_1.isNullOrUndefined(parent.activeObj.isHorImageFlip) || !parent.activeObj.isHorImageFlip) {
                                parent.activeObj.isHorImageFlip = true;
                                ctx.translate(parent.activeObj.imageCanvas.width, 0);
                                ctx.scale(-1, 1);
                            }
                            else Eif (parent.activeObj.isHorImageFlip) {
                                parent.activeObj.isHorImageFlip = false;
                            }
                            Iif (parent.activeObj.isVerImageFlip) {
                                ctx.translate(0, parent.activeObj.imageCanvas.height);
                                ctx.scale(1, -1);
                            }
                        }
                        else if (isVFlip) {
                            if (ej2_base_1.isNullOrUndefined(parent.activeObj.isVerImageFlip) || !parent.activeObj.isVerImageFlip) {
                                parent.activeObj.isVerImageFlip = true;
                                ctx.translate(0, parent.activeObj.imageCanvas.height);
                                ctx.scale(1, -1);
                            }
                            else Eif (parent.activeObj.isVerImageFlip) {
                                parent.activeObj.isVerImageFlip = false;
                            }
                            Eif (parent.activeObj.isHorImageFlip) {
                                ctx.translate(parent.activeObj.imageCanvas.width, 0);
                                ctx.scale(-1, 1);
                            }
                        }
                    }
                    ctx.drawImage(tempCanvas, 0, 0);
                    ctx.setTransform(1, 0, 0, 1, 0, 0);
                }
                else Iif (parent.isFinetuning) {
                    ctx.save();
                    ctx.setTransform(1, 0, 0, 1, 0, 0);
                    ctx.drawImage(parent.inMemoryCanvas, 0, 0);
                    ctx.restore();
                }
                else {
                    ctx.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, parent.img.destLeft, parent.img.destTop, tempCanvas.width, tempCanvas.height);
                }
            }
            else {
                Eif ((ej2_base_1.isNullOrUndefined(isImgAnnotation) || !isImgAnnotation) && parent.baseImgCanvas.width !== 0 &&
                    parent.baseImgCanvas.height !== 0) {
                    if (this.imageBackgroundColor !== '') {
                        ctx.fillStyle = this.imageBackgroundColor;
                        ctx.fillRect(parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
                    }
                    ctx.drawImage(parent.baseImgCanvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
                }
            }
            if (parent.isSafari) {
                parent.notify('filter', { prop: 'apply-filter', onPropertyChange: false, value: { context: ctx } });
            }
        };
        Draw.prototype.downScale = function (canvas, width, height, isImgAnnotation) {
            var parent = this.parent;
            Iif (isImgAnnotation && parent.isStraightening) {
                return;
            }
            var widthSource = canvas.width;
            var heightSource = canvas.height;
            width = Math.round(width);
            height = Math.round(height);
            var widthRatio = widthSource / width;
            var heightRatio = heightSource / height;
            var halfWidthRatio = Math.ceil(widthRatio / 2);
            var halfHeightRatio = Math.ceil(heightRatio / 2);
            var ctx = canvas.getContext('2d');
            var img = ctx.getImageData(0, 0, widthSource, heightSource);
            var img2 = ctx.createImageData(width, height);
            var data = img.data;
            var data2 = img2.data;
            for (var j = 0; j < height; j++) {
                for (var i = 0; i < width; i++) {
                    var x2 = (i + j * width) * 4;
                    var weight = 0;
                    var weights = 0;
                    var alphaWeights = 0;
                    var r = 0;
                    var g = 0;
                    var b = 0;
                    var a = 0;
                    var centerY = (j + 0.5) * heightRatio;
                    var startY = Math.floor(j * heightRatio);
                    var stopY = Math.ceil((j + 1) * heightRatio);
                    for (var y = startY; y < stopY; y++) {
                        var dy = Math.abs(centerY - (y + 0.5)) / halfHeightRatio;
                        var centerX = (i + 0.5) * widthRatio;
                        var w0 = dy * dy;
                        var startX = Math.floor(i * widthRatio);
                        var stopX = Math.ceil((i + 1) * widthRatio);
                        for (var x = startX; x < stopX; x++) {
                            var dx = Math.abs(centerX - (x + 0.5)) / halfWidthRatio;
                            var w = Math.sqrt(w0 + dx * dx);
                            if (w >= 1) {
                                continue;
                            }
                            weight = 2 * w * w * w - 3 * w * w + 1;
                            var xPos = 4 * (x + y * widthSource);
                            a += weight * data[xPos + 3];
                            alphaWeights += weight;
                            weight = weight * data[xPos + 3] / 250;
                            r += weight * data[xPos];
                            g += weight * data[xPos + 1];
                            b += weight * data[xPos + 2];
                            weights += weight;
                        }
                    }
                    data2[x2] = r / weights;
                    data2[x2 + 1] = g / weights;
                    data2[x2 + 2] = b / weights;
                    data2[x2 + 3] = a / alphaWeights;
                }
            }
            canvas.width = isImgAnnotation ? parent.activeObj.activePoint.width : parent.lowerCanvas.width;
            canvas.height = isImgAnnotation ? parent.activeObj.activePoint.height : parent.lowerCanvas.height;
            ctx.putImageData(img2, 0, 0);
        };
        Draw.prototype.drawImgToCtx = function (ctx, preventImg) {
            var parent = this.parent;
            if (ctx.canvas.id !== parent.element.id + '_tempCanvas' && ctx !== this.upperContext && ej2_base_1.isNullOrUndefined(preventImg)) {
                this.downScaleImgCanvas(ctx, null, null, null);
            }
        };
        Draw.prototype.getFrameColor = function (frameObj, ctx, points) {
            var parent = this.parent;
            var color = parent.frameObj.color;
            if (frameObj.gradientColor) {
                var gradient = ctx.createLinearGradient(points.startX, points.startY, points.startX + points.width, points.startY + points.height);
                gradient.addColorStop(0, frameObj.color);
                gradient.addColorStop(1, frameObj.gradientColor);
                color = gradient;
            }
            else {
                color = frameObj.color;
            }
            return color;
        };
        Draw.prototype.applyFrame = function (ctx, frame, preventImg) {
            var parent = this.parent;
            parent.frameObj.type = frame;
            var tempLineWidth;
            var ratio = { width: 1, height: 1 };
            var points = { startX: parent.img.destLeft - ctx.lineWidth, startY: parent.img.destTop - ctx.lineWidth,
                width: parent.img.destWidth + (2 * ctx.lineWidth), height: parent.img.destHeight + (2 * ctx.lineWidth) };
            var frameObj = { type: parent.frameObj.type, color: parent.frameObj.color, size: parent.frameObj.size,
                inset: parent.frameObj.inset, offset: parent.frameObj.offset / 2, radius: parent.frameObj.radius,
                amount: parent.frameObj.amount, border: parent.frameObj.border, gradientColor: parent.frameObj.gradientColor };
            var zoomFactor = parent.transform.zoomFactor;
            if (ctx.canvas.id === parent.element.id + '_tempCanvas') {
                var newWidth = ctx.canvas.width;
                var newHeight = ctx.canvas.height;
                var obj = { width: 0, height: 0 };
                parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
                    value: { obj: obj, dimension: { width: newWidth, height: newHeight } } });
                ratio = obj;
                frameObj.size *= ((ratio.width + ratio.height) / 2);
                frameObj.inset *= ((ratio.width + ratio.height) / 2);
                frameObj.offset *= ((ratio.width + ratio.height) / 2);
                frameObj.radius *= ((ratio.width + ratio.height) / 2);
                points = { startX: 0, startY: 0, width: ctx.canvas.width, height: ctx.canvas.height };
                parent.notify('export', { prop: 'updateSaveContext', onPropertyChange: false, value: { context: ctx } });
            }
            else if (ctx === this.upperContext && parent.activeObj.shape) {
                points = { startX: parent.activeObj.activePoint.startX - ctx.lineWidth, startY: parent.activeObj.activePoint.startY
                        - ctx.lineWidth, width: parent.activeObj.activePoint.width + (2 * ctx.lineWidth), height: parent.activeObj.activePoint.height + (2 * ctx.lineWidth) };
            }
            else if (ej2_base_1.isNullOrUndefined(preventImg)) {
                ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
            }
            var valueForty = (40 * ((ratio.width + ratio.height) / 2));
            var valueFifty = (50 * ((ratio.width + ratio.height) / 2));
            if (ctx !== this.upperContext) {
                frameObj.size += (frameObj.size * zoomFactor);
                frameObj.inset += (frameObj.inset * zoomFactor);
                frameObj.offset += (frameObj.offset * zoomFactor);
                frameObj.radius += (frameObj.radius * zoomFactor);
                valueForty += (valueForty * zoomFactor);
                valueFifty += (valueFifty * zoomFactor);
            }
            if (ctx === this.upperContext && parent.activeObj.shape) {
                Iif ((frame === 'mat' && ((points.width - (2 * frameObj.size) < 0) || (points.height - (2 * frameObj.size) < 0))) ||
                    (frame === 'bevel' && (points.width - (2 * frameObj.size) < 40 || points.height - (2 * frameObj.size) < 40)) ||
                    ((frame === 'inset') && (points.startX + points.width - frameObj.offset - (points.startX + frameObj.offset) < 0 ||
                        points.startY + points.height - frameObj.offset - (points.startY + frameObj.offset) < 0)) ||
                    (frame === 'hook' && (points.width - (2 * frameObj.size) < 50 || points.height - (2 * frameObj.size) < 50))) {
                    return;
                }
            }
            var bevelObj = { bevelFilter: ctx.filter };
            var filter = ctx.filter;
            if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop ||
                (ctx === this.lowerContext && parent.isCropTab)) {
                this.drawImgToCtx(ctx, preventImg);
            }
            else {
                switch (frame) {
                    case 'none':
                        this.drawImgToCtx(ctx, preventImg);
                        break;
                    case 'mat':
                        this.drawImgToCtx(ctx, preventImg);
                        while (((points.width - (2 * frameObj.size) < 0) ||
                            (points.height - (2 * frameObj.size) < 0)) && frameObj.size > 0) {
                            frameObj.size -= 20;
                        }
                        ctx.filter = 'none';
                        ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
                        ctx.beginPath();
                        ctx.rect(points.startX, points.startY, points.width, points.height);
                        ctx.rect(points.startX + frameObj.size, points.startY + frameObj.size, points.width -
                            (2 * frameObj.size), points.height - (2 * frameObj.size));
                        ctx.fill('evenodd');
                        ctx.closePath();
                        break;
                    case 'bevel':
                        ctx.filter = 'none';
                        ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
                        ctx.beginPath();
                        ctx.fillRect(points.startX, points.startY, points.width, points.height);
                        ctx.closePath();
                        points.startX += frameObj.size;
                        points.startY += frameObj.size;
                        points.width -= (2 * frameObj.size);
                        points.height -= (2 * frameObj.size);
                        while ((points.width - (2 * frameObj.size) < 40 ||
                            points.height - (2 * frameObj.size) < 40) && frameObj.size > 0) {
                            points.startX -= frameObj.size;
                            points.startY -= frameObj.size;
                            points.width += (2 * frameObj.size);
                            points.height += (2 * frameObj.size);
                            frameObj.size -= 20;
                            points.startX += frameObj.size;
                            points.startY += frameObj.size;
                            points.width -= (2 * frameObj.size);
                            points.height -= (2 * frameObj.size);
                        }
                        ctx.fillStyle = this.getFrameColor(frameObj, ctx, points);
                        ctx.save();
                        ctx.beginPath();
                        ctx.moveTo(points.startX + valueForty, points.startY);
                        ctx.lineTo(points.startX + points.width - valueForty, points.startY);
                        ctx.quadraticCurveTo(points.startX + points.width, points.startY, points.startX + points.width, points.startY + valueForty);
                        ctx.lineTo(points.startX + points.width, points.startY + points.height - valueForty);
                        ctx.quadraticCurveTo(points.startX + points.width, points.startY + points.height, points.startX + points.width - valueForty, points.startY + points.height);
                        ctx.lineTo(points.startX + valueForty, points.startY + points.height);
                        ctx.quadraticCurveTo(points.startX, points.startY + points.height, points.startX, points.startY + points.height
                            - valueForty);
                        ctx.lineTo(points.startX, points.startY + valueForty);
                        ctx.quadraticCurveTo(points.startX, points.startY, points.startX + valueForty, points.startY);
                        ctx.closePath();
                        ctx.clip();
                        ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
                        Iif (ctx.canvas.id === parent.element.id + '_tempCanvas') {
                            preventImg = null;
                            ctx.filter = 'none';
                            ctx.drawImage(parent.inMemoryCanvas, 0, 0);
                            ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
                        }
                        else {
                            ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
                            if (preventImg) {
                                preventImg = null;
                                Eif (parent.transform.zoomFactor !== 0) {
                                    this.isRotateZoom = true;
                                }
                                parent.notify('filter', { prop: 'getBevelFilter', onPropertyChange: false, value: { obj: bevelObj } });
                                ctx.filter = bevelObj['bevelFilter'];
                                this.updateCurrTransState('initial');
                                this.drawImgToCtx(ctx, preventImg);
                                this.updateCurrTransState('reverse');
                                this.isRotateZoom = false;
                                parent.frameObj.type = 'none';
                                ctx.filter = 'none';
                                parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                                    value: { ctx: ctx, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
                                parent.frameObj.type = 'bevel';
                                ctx.filter = filter === 'none' ? parent.canvasFilter : filter;
                            }
                            else {
                                parent.notify('filter', { prop: 'getBevelFilter', onPropertyChange: false, value: { obj: bevelObj } });
                                ctx.filter = bevelObj['bevelFilter'];
                                this.drawImgToCtx(ctx, preventImg);
                            }
                        }
                        ctx.restore();
                        break;
                    case 'line':
                        this.drawImgToCtx(ctx, preventImg);
                        tempLineWidth = ctx.lineWidth;
                        ctx.lineWidth = frameObj.size / 10;
                        for (var i = 0; i < parent.frameObj.amount; i++) {
                            if (i > 0) {
                                points.startX += frameObj.offset;
                                points.startY += frameObj.offset;
                                points.width -= (2 * frameObj.offset);
                                points.height -= (2 * frameObj.offset);
                            }
                            var arcY2 = points.startY + points.height - frameObj.inset - frameObj.radius;
                            var lineY = points.startY + frameObj.inset + frameObj.radius;
                            var arcX2 = points.startX + points.width - frameObj.inset - frameObj.radius;
                            var lineX = points.startX + frameObj.inset + frameObj.radius;
                            var arcX1 = points.startX + frameObj.inset + frameObj.radius;
                            var lineX2 = points.startX + points.width - frameObj.inset - frameObj.radius;
                            var arcY1 = points.startY + frameObj.inset + frameObj.radius;
                            var lineY2 = points.startY + points.height - frameObj.inset - frameObj.radius;
                            Eif (arcY2 >= lineY && arcX2 >= lineX && arcX1 <= lineX2 && arcY1 <= lineY2) {
                                ctx.filter = 'none';
                                ctx.strokeStyle = this.getFrameColor(frameObj, ctx, points);
                                if (frameObj.border === 'dashed') {
                                    ctx.setLineDash([ctx.lineWidth * 2.5, ctx.lineWidth * 1.5]);
                                }
                                else Iif (frameObj.border === 'dotted') {
                                    ctx.setLineDash([ctx.lineWidth, ctx.lineWidth]);
                                }
                                ctx.beginPath();
                                ctx.moveTo(points.startX + frameObj.inset + frameObj.radius, points.startY + frameObj.inset);
                                ctx.lineTo(points.startX + points.width - frameObj.inset - frameObj.radius, points.startY + frameObj.inset);
                                ctx.arcTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.inset, points.startX + points.width - frameObj.inset, points.startY + frameObj.inset + frameObj.radius, frameObj.radius);
                                ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset -
                                    frameObj.radius);
                                ctx.arcTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset, points.startX + points.width - frameObj.inset - frameObj.radius, points.startY + points.height
                                    - frameObj.inset, frameObj.radius);
                                ctx.lineTo(points.startX + frameObj.inset + frameObj.radius, points.startY + points.height - frameObj.inset);
                                ctx.arcTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.inset, points.startX + frameObj.inset, points.startY + points.height - frameObj.inset - frameObj.radius, frameObj.radius);
                                ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.inset + frameObj.radius);
                                ctx.arcTo(points.startX + frameObj.inset, points.startY + frameObj.inset, points.startX + frameObj.inset + frameObj.radius, points.startY + frameObj.inset, frameObj.radius);
                                ctx.closePath();
                                ctx.stroke();
                                ctx.setLineDash([]);
                            }
                        }
                        ctx.lineWidth = tempLineWidth;
                        break;
                    case 'inset':
                        this.drawImgToCtx(ctx, preventImg);
                        ctx.filter = 'none';
                        ctx.strokeStyle = this.getFrameColor(frameObj, ctx, points);
                        tempLineWidth = ctx.lineWidth;
                        ctx.lineWidth = frameObj.size / 10;
                        ctx.beginPath();
                        ctx.moveTo(points.startX + frameObj.offset, points.startY + frameObj.inset);
                        ctx.lineTo(points.startX + points.width - frameObj.offset, points.startY + frameObj.inset);
                        ctx.moveTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.offset);
                        ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.offset);
                        ctx.moveTo(points.startX + points.width - frameObj.offset, points.startY + points.height - frameObj.inset);
                        ctx.lineTo(points.startX + frameObj.offset, points.startY + points.height - frameObj.inset);
                        ctx.moveTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.offset);
                        ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.offset);
                        ctx.stroke();
                        ctx.closePath();
                        ctx.lineWidth = tempLineWidth;
                        break;
                    case 'hook':
                        this.drawImgToCtx(ctx, preventImg);
                        ctx.filter = 'none';
                        ctx.strokeStyle = this.getFrameColor(frameObj, ctx, points);
                        tempLineWidth = ctx.lineWidth;
                        ctx.lineWidth = frameObj.size / 10;
                        ctx.beginPath();
                        ctx.moveTo(points.startX + frameObj.inset + valueFifty, points.startY + frameObj.inset);
                        ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.inset);
                        ctx.lineTo(points.startX + frameObj.inset, points.startY + frameObj.inset + valueFifty);
                        ctx.moveTo(points.startX + points.width - frameObj.inset - valueFifty, points.startY + frameObj.inset);
                        ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.inset);
                        ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + frameObj.inset + valueFifty);
                        ctx.moveTo(points.startX + points.width - frameObj.inset - valueFifty, points.startY + points.height - frameObj.inset);
                        ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset);
                        ctx.lineTo(points.startX + points.width - frameObj.inset, points.startY + points.height - frameObj.inset - valueFifty);
                        ctx.moveTo(points.startX + frameObj.inset + valueFifty, points.startY + points.height - frameObj.inset);
                        ctx.lineTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.inset);
                        ctx.lineTo(points.startX + frameObj.inset, points.startY + points.height - frameObj.inset - valueFifty);
                        ctx.stroke();
                        ctx.lineWidth = tempLineWidth;
                        break;
                }
                Iif (parent.isCircleCrop || (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle')) {
                    parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
                        value: { context: ctx, isSave: ctx.canvas.id === parent.element.id + '_tempCanvas' ? true : null, isFlip: null } });
                }
                ctx.filter = filter;
            }
        };
        Draw.prototype.triggerFrameChange = function (prevFrameSettings) {
            var parent = this.parent;
            var currFrameSettings = { type: parent.toPascalCase(parent.frameObj.type),
                color: parent.frameObj.color, gradientColor: parent.frameObj.gradientColor, size: parent.frameObj.size,
                inset: parent.frameObj.inset, offset: parent.frameObj.offset, borderRadius: parent.frameObj.radius,
                frameLineStyle: parent.toPascalCase(parent.frameObj.border), lineCount: parent.frameObj.amount };
            var frameChange = { cancel: false, previousFrameSetting: prevFrameSettings,
                currentFrameSetting: currFrameSettings };
            parent.trigger('frameChange', frameChange);
            parent.editCompleteArgs = frameChange;
            Eif (!frameChange.cancel) {
                this.setFrameObj(frameChange.currentFrameSetting);
            }
            return frameChange;
        };
        Draw.prototype.setFrameObj = function (currFrameSettings) {
            var parent = this.parent;
            parent.frameObj.type = currFrameSettings.type.toLowerCase();
            parent.frameObj.color = currFrameSettings.color;
            parent.frameObj.gradientColor = currFrameSettings.gradientColor;
            parent.frameObj.size = currFrameSettings.size;
            parent.frameObj.inset = currFrameSettings.inset;
            parent.frameObj.offset = currFrameSettings.offset;
            parent.frameObj.radius = currFrameSettings.borderRadius;
            parent.frameObj.border = currFrameSettings.frameLineStyle.toLowerCase();
            parent.frameObj.amount = currFrameSettings.lineCount;
        };
        Draw.prototype.zoomToSel = function (activeObj, isToolbar) {
            var parent = this.parent;
            if (this.straightenActObj && JSON.stringify(this.straightenActObj.activePoint) === JSON.stringify(activeObj.activePoint)) {
                parent.activeObj = ej2_base_1.extend({}, this.straightenActObj, null, true);
                this.allowRedactStraighten = false;
                if (parent.transform.straighten === 0) {
                    var destWidth = parent.img.destWidth;
                    var destHeight = parent.img.destHeight;
                    parent.transform.straighten = 360;
                    while (true) {
                        if (!ej2_base_1.isNullOrUndefined(this.straightenInitZoom) &&
                            (Math.round(parent.transform.zoomFactor * Math.pow(10, 3)) / Math.pow(10, 3)) >
                                (Math.round(this.straightenInitZoom * Math.pow(10, 3)) / Math.pow(10, 3))) {
                            this.setZoomPan('out');
                            Iif (destWidth === parent.img.destWidth && destHeight === parent.img.destHeight) {
                                this.performDummyZoom();
                                break;
                            }
                            Eif (parent.transform.degree === 0) {
                                parent.transform.zoomFactor -= 0.025;
                                parent.transform.cropZoomFactor -= 0.025;
                            }
                        }
                        else {
                            this.performDummyZoom();
                            break;
                        }
                    }
                    parent.transform.straighten = 0;
                    parent.img = { destLeft: parent.img.destLeft, destTop: parent.img.destTop, destWidth: parent.img.destWidth,
                        destHeight: parent.img.destHeight, srcLeft: parent.img.srcLeft, srcTop: parent.img.srcTop,
                        srcWidth: parent.img.srcWidth, srcHeight: parent.img.srcHeight };
                }
                else {
                    Iif (ej2_base_1.isNullOrUndefined(this.straightenInitZoom)) {
                        this.straightenInitZoom = parent.transform.zoomFactor;
                    }
                    Iif (this.straightenInitZoom - parent.transform.zoomFactor > 0) {
                        parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                            value: { zoomFactor: -(this.straightenInitZoom - parent.transform.zoomFactor), zoomPoint: null, isResize: true } });
                    }
                    else if (this.straightenInitZoom - parent.transform.zoomFactor < 0) {
                        parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                            value: { zoomFactor: (this.straightenInitZoom - parent.transform.zoomFactor), zoomPoint: null, isResize: true } });
                    }
                    parent.activeObj = ej2_base_1.extend({}, activeObj, null, true);
                    parent.transform.zoomFactor += 0.001;
                    this.calcStraightenedPoints(isToolbar);
                }
            }
            else {
                this.straightenActObj = ej2_base_1.extend({}, activeObj, null, true);
                parent.activeObj = ej2_base_1.extend({}, this.straightenActObj, null, true);
                this.straightenInitZoom = parent.transform.zoomFactor;
                this.calcStraightenedPoints(isToolbar);
            }
        };
        Draw.prototype.isDestPointSmall = function () {
            var parent = this.parent;
            var img = parent.img;
            var destPoints = { startX: img.destLeft, startY: img.destTop,
                width: img.destWidth, height: img.destHeight };
            parent.notify('shape', { prop: 'straightenShapes', onPropertyChange: false });
            var isSmall = false;
            if (this.straightenDestPoints.destWidth && this.straightenDestPoints.destHeight &&
                (img.destWidth < this.straightenDestPoints.destWidth || img.destHeight < this.straightenDestPoints.destHeight)) {
                isSmall = true;
            }
            img.destLeft = destPoints.startX;
            img.destTop = destPoints.startY;
            img.destWidth = destPoints.width;
            img.destHeight = destPoints.height;
            parent.img = img;
            return isSmall;
        };
        Draw.prototype.calcStraightenedPoints = function (isToolbar) {
            var parent = this.parent;
            var destWidth = parent.img.destWidth;
            var destHeight = parent.img.destHeight;
            if (ej2_base_1.isNullOrUndefined(parent.transform.zoomFactor)) {
                parent.transform.zoomFactor += 0.025;
            }
            this.updateImgCanvasPoints();
            var _loop_1 = function () {
                if (this_1.isLinesIntersect() || this_1.isSelOutsideImg() || (isToolbar && this_1.isDestPointSmall())) {
                    parent.activeObj = ej2_base_1.extend({}, this_1.straightenActObj, null, true);
                    this_1.setZoomPan('in');
                    if (destWidth === parent.img.destWidth && destHeight === parent.img.destHeight) {
                        this_1.performDummyZoom();
                        return "break";
                    }
                    if (parent.transform.degree === 0) {
                        parent.transform.zoomFactor += 0.025;
                        parent.transform.cropZoomFactor += 0.025;
                    }
                    var points = this_1.imgCanvasPoints;
                    var left_1 = parent.img.destLeft;
                    var top_1 = parent.img.destTop;
                    var width_1 = parent.img.destWidth;
                    var height_1 = parent.img.destHeight;
                    points.forEach(function (point) {
                        point.x = (point.ratioX * width_1) + left_1;
                        point.y = (point.ratioY * height_1) + top_1;
                    });
                    this_1.imgCanvasPoints = points;
                }
                else {
                    this_1.performDummyZoom();
                    return "break";
                }
            };
            var this_1 = this;
            while (true) {
                var state_1 = _loop_1();
                if (state_1 === "break")
                    break;
            }
        };
        Draw.prototype.performDummyZoom = function () {
            var parent = this.parent;
            parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                value: { zoomFactor: 0.025, zoomPoint: null, isResize: true } });
            parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                value: { zoomFactor: -0.025, zoomPoint: null, isResize: true } });
            var zoom = parent.transform.zoomFactor * 10;
            if (zoom < 1) {
                zoom = 1 + (zoom / 10);
            }
            parent.setProperties({ zoomSettings: { zoomFactor: zoom } }, true);
            parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
                value: { previousZoomValue: zoom } });
            this.panToSel();
        };
        Draw.prototype.setZoomPan = function (type) {
            var parent = this.parent;
            var obj = { maxDimension: null };
            if (parent.transform.degree === 0) {
                parent.notify('transform', { prop: 'cropZoom', onPropertyChange: false,
                    value: { value: type === 'in' ? 0.025 : -0.025, selectionObj: parent.activeObj, obj: obj } });
                parent.img.destWidth = obj['maxDimension']['width'];
                parent.img.destHeight = obj['maxDimension']['height'];
            }
            else {
                parent.transform.zoomFactor += (type === 'in' ? 0.025 : -0.025);
                parent.transform.cropZoomFactor += (type === 'in' ? 0.025 : -0.025);
                this.updateCurrTransState('initial');
                this.isRotateZoom = true;
                this.setDestPoints();
                this.isRotateZoom = false;
                this.updateCurrTransState('reverse');
            }
        };
        Draw.prototype.updateImgCanvasPoints = function () {
            var parent = this.parent;
            var points = this.getImagePoints();
            var obj = { width: 0, height: 0 };
            var width = parent.baseImgCanvas.width;
            var height = parent.baseImgCanvas.height;
            parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
                value: { obj: obj, dimension: { width: width, height: height } } });
            var ratio = obj;
            width = parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0 ?
                ratio.height : ratio.width;
            height = parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0 ?
                ratio.width : ratio.height;
            var p1;
            var p2;
            var p3;
            var p4;
            var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
            if (parent.transform.straighten > 0) {
                p1 = { x: destLeft + (points[0].x / width), y: destTop };
                p2 = { x: destLeft + destWidth, y: destTop + (points[1].y / height) };
                p3 = { x: destLeft + destWidth - (points[0].x / width), y: destTop + destHeight };
                p4 = { x: destLeft, y: destTop + destHeight - (points[1].y / height) };
            }
            else if (parent.transform.straighten < 0) {
                p1 = { x: destLeft, y: destTop + (points[0].y / height) };
                p2 = { x: destLeft + (points[1].x / width), y: destTop };
                p3 = { x: destLeft + destWidth, y: destTop + destHeight - (points[0].y / height) };
                p4 = { x: destLeft + destWidth - (points[1].x / width), y: destTop + destHeight };
            }
            else Eif (parent.transform.straighten === 0) {
                p1 = { x: destLeft, y: destTop };
                p2 = { x: destLeft + destWidth, y: destTop };
                p3 = { x: destLeft + destWidth, y: destTop + destHeight };
                p4 = { x: destLeft, y: destTop + destHeight };
            }
            p1.ratioX = (p1.x - destLeft) / destWidth;
            p1.ratioY = (p1.y - destTop) / destHeight;
            p2.ratioX = (p2.x - destLeft) / destWidth;
            p2.ratioY = (p2.y - destTop) / destHeight;
            p3.ratioX = (p3.x - destLeft) / destWidth;
            p3.ratioY = (p3.y - destTop) / destHeight;
            p4.ratioX = (p4.x - destLeft) / destWidth;
            p4.ratioY = (p4.y - destTop) / destHeight;
            this.imgCanvasPoints = [p1, p2, p3, p4];
        };
        Draw.prototype.isLinesIntersect = function (obj) {
            var parent = this.parent;
            var point = parent.activeObj.activePoint;
            if (parent.activeObj.rotatedAngle !== 0) {
                var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
                var center = { x: startX + (width / 2), y: startY +
                        (height / 2) };
                var cosAngle = Math.cos(parent.activeObj.rotatedAngle);
                var sinAngle = Math.sin(parent.activeObj.rotatedAngle);
                var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
                    y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
                var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
                    y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
                var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
                    y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
                var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
                    y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
                var imgPoints_1 = this.imgCanvasPoints;
                var isTopIntersect_1 = this.doIntersect(p1, p2, imgPoints_1[0], imgPoints_1[1]);
                var isRightIntersect_1 = this.doIntersect(p2, p4, imgPoints_1[1], imgPoints_1[2]);
                var isBottomIntersect_1 = this.doIntersect(p3, p4, imgPoints_1[2], imgPoints_1[3]);
                var isLeftIntersect_1 = this.doIntersect(p1, p3, imgPoints_1[3], imgPoints_1[0]);
                Eif (obj) {
                    obj['arr'] = [isTopIntersect_1, isRightIntersect_1, isBottomIntersect_1, isLeftIntersect_1];
                }
                return isTopIntersect_1 || isRightIntersect_1 || isBottomIntersect_1 || isLeftIntersect_1;
            }
            var imgPoints = this.imgCanvasPoints;
            var isTopIntersect = this.doIntersect({ x: point.startX, y: point.startY }, { x: point.endX, y: point.startY }, imgPoints[0], imgPoints[1]);
            var isRightIntersect = this.doIntersect({ x: point.endX, y: point.startY }, { x: point.endX, y: point.endY }, imgPoints[1], imgPoints[2]);
            var isBottomIntersect = this.doIntersect({ x: point.startX, y: point.endY }, { x: point.endX, y: point.endY }, imgPoints[2], imgPoints[3]);
            var isLeftIntersect = this.doIntersect({ x: point.startX, y: point.startY }, { x: point.startX, y: point.endY }, imgPoints[3], imgPoints[0]);
            var isTopLeftInsideRect = this.isInsideRect(imgPoints[0]);
            var isTopRightInsideRect = this.isInsideRect(imgPoints[1]);
            var isBottomRightInsideRect = this.isInsideRect(imgPoints[2]);
            var isBottomLeftInsideRect = this.isInsideRect(imgPoints[3]);
            if (obj) {
                obj['arr'] = [isTopIntersect, isRightIntersect, isBottomIntersect, isLeftIntersect];
            }
            return isTopIntersect || isRightIntersect || isBottomIntersect || isLeftIntersect ||
                isTopLeftInsideRect || isTopRightInsideRect || isBottomRightInsideRect || isBottomLeftInsideRect ||
                (imgPoints[0].x > point.startX && imgPoints[1].x < point.endX &&
                    imgPoints[2].x < point.endX && imgPoints[3].x > point.startX &&
                    imgPoints[0].y < point.startY && imgPoints[1].y < point.startY &&
                    imgPoints[2].y > point.endY && imgPoints[3].y > point.endY) ||
                (imgPoints[0].x < point.startX && imgPoints[1].x > point.endX &&
                    imgPoints[2].x > point.endX && imgPoints[3].x < point.startX &&
                    imgPoints[0].y > point.startY && imgPoints[1].y > point.startY &&
                    imgPoints[2].y < point.endY && imgPoints[3].y < point.endY);
        };
        Draw.prototype.isSelOutsideImg = function () {
            var parent = this.parent;
            var points = this.imgCanvasPoints;
            var actPoint = parent.activeObj.activePoint;
            return (this.checkPointPosition(actPoint.startX, actPoint.startY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside' ||
                this.checkPointPosition(actPoint.endX, actPoint.startY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside' ||
                this.checkPointPosition(actPoint.startX, actPoint.endY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside' ||
                this.checkPointPosition(actPoint.endX, actPoint.endY, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y) !== 'inside');
        };
        Draw.prototype.calcTriangleArea = function (x1, y1, x2, y2, x3, y3) {
            return Math.abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2);
        };
        Draw.prototype.checkPointPosition = function (x, y, x1, y1, x2, y2, x3, y3, x4, y4) {
            var area1 = this.calcTriangleArea(x, y, x1, y1, x4, y4);
            var area2 = this.calcTriangleArea(x, y, x4, y4, x3, y3);
            var area3 = this.calcTriangleArea(x, y, x3, y3, x2, y2);
            var area4 = this.calcTriangleArea(x, y, x2, y2, x1, y1);
            var areaRectangle = this.calcTriangleArea(x1, y1, x2, y2, x3, y3) + this.calcTriangleArea(x3, y3, x4, y4, x1, y1);
            if (area1 + area2 + area3 + area4 > areaRectangle) {
                return 'outside';
            }
            else if (area1 + area2 + area3 + area4 === areaRectangle && (area1 === 0 || area2 === 0 || area3 === 0 || area4 === 0)) {
                return 'on';
            }
            else {
                return 'inside';
            }
        };
        Draw.prototype.getImagePoints = function () {
            var point = [];
            var parent = this.parent;
            var degree = parent.transform.degree;
            var width;
            var height;
            Iif (!parent.aspectRatioBaseDimension && parent.imageSettings.width && parent.imageSettings.height) {
                var widthRatio = parent.baseImg.width / parent.imageSettings.width;
                var heightRatio = parent.baseImg.height / parent.imageSettings.height;
                var ratio = (widthRatio + heightRatio) / 2;
                ratio = ratio < 1 ? 1 : ratio;
                width = parent.imageSettings.width * ratio;
                height = parent.imageSettings.height * ratio;
            }
            else {
                width = parent.baseImg.width;
                height = parent.baseImg.height;
            }
            var obj = { dim: null, width: height, height: width, angle: parent.transform.straighten };
            obj['dim'] = parent.getRotatedCanvasDim(obj['width'], obj['height'], obj['angle']);
            var baseImgCanvasWidth = degree % 90 === 0 && degree % 180 !== 0 ? obj['dim']['width'] : parent.baseImgCanvas.width;
            var baseImgCanvasHeight = degree % 90 === 0 && degree % 180 !== 0 ? obj['dim']['height'] : parent.baseImgCanvas.height;
            var baseImgWidth = degree % 90 === 0 && degree % 180 !== 0 ? height : width;
            var baseImgHeight = degree % 90 === 0 && degree % 180 !== 0 ? width : height;
            var centerX = baseImgCanvasWidth / 2;
            var centerY = baseImgCanvasHeight / 2;
            var startX = centerX - (baseImgWidth / 2);
            var startY = centerY - (baseImgHeight / 2);
            var endX = centerX + (baseImgWidth / 2);
            var endY = centerY + (baseImgHeight / 2);
            var center = { x: centerX, y: centerY };
            var radians = parent.transform.straighten * (Math.PI / 180);
            var p1 = { x: Math.cos(radians) * (startX - center.x) - Math.sin(radians) * (startY - center.y) + center.x,
                y: Math.sin(radians) * (startX - center.x) + Math.cos(radians) * (startY - center.y) + center.y };
            var p2 = { x: Math.cos(radians) * (endX - center.x) - Math.sin(radians) * (startY - center.y) + center.x,
                y: Math.sin(radians) * (endX - center.x) + Math.cos(radians) * (startY - center.y) + center.y };
            var p3 = { x: Math.cos(radians) * (endX - center.x) - Math.sin(radians) * (endY - center.y) + center.x,
                y: Math.sin(radians) * (endX - center.x) + Math.cos(radians) * (endY - center.y) + center.y };
            var p4 = { x: Math.cos(radians) * (startX - center.x) - Math.sin(radians) * (endY - center.y) + center.x,
                y: Math.sin(radians) * (startX - center.x) + Math.cos(radians) * (endY - center.y) + center.y };
            point.push(p1);
            point.push(p2);
            point.push(p3);
            point.push(p4);
            return point;
        };
        Draw.prototype.doIntersect = function (a, b, c, d) {
            var point1 = this.initiation(a, b, c);
            var point2 = this.initiation(a, b, d);
            var point3 = this.initiation(c, d, a);
            var point4 = this.initiation(c, d, b);
            if (point1 !== point2 && point3 !== point4) {
                return true;
            }
            if (point1 === 0 && this.onSegment(a, c, b)) {
                return true;
            }
            if (point2 === 0 && this.onSegment(a, d, b)) {
                return true;
            }
            if (point3 === 0 && this.onSegment(c, a, d)) {
                return true;
            }
            Iif (point4 === 0 && this.onSegment(c, b, d)) {
                return true;
            }
            return false;
        };
        Draw.prototype.initiation = function (a, b, c) {
            var value = (b.y - a.y) * (c.x - b.x) - (b.x - a.x) * (c.y - b.y);
            if (value === 0) {
                return 0;
            }
            return (value > 0) ? 1 : 2;
        };
        Draw.prototype.onSegment = function (a, b, c) {
            if (b.x <= Math.max(a.x, c.x) && b.x >= Math.min(a.x, c.x) &&
                b.y <= Math.max(a.y, c.y) && b.y >= Math.min(a.y, c.y)) {
                return true;
            }
            return false;
        };
        Draw.prototype.isInsideRect = function (point) {
            var parent = this.parent;
            var actPoint = parent.activeObj.activePoint;
            var isInside = false;
            if (point.x >= actPoint.startX && point.x <= actPoint.endX &&
                point.y >= actPoint.startY && point.y <= actPoint.endY) {
                isInside = true;
            }
            return isInside;
        };
        Draw.prototype.setDestForStraighten = function () {
            var parent = this.parent;
            if (ej2_base_1.isNullOrUndefined(this.straightenDestPoints)) {
                var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
                parent.notify('shape', { prop: 'straightenShapes', onPropertyChange: false });
                this.straightenDestPoints = ej2_base_1.extend({}, parent.img, {}, true);
                parent.img.destLeft = destLeft;
                parent.img.destTop = destTop;
                parent.img.destWidth = destWidth;
                parent.img.destHeight = destHeight;
            }
        };
        Draw.prototype.drawRedact = function (canvasDraw, obj) {
            var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
            var _b = obj.activePoint, width = _b.width, height = _b.height;
            var isSaveCtx = false;
            var canvas = canvasDraw.canvas;
            Iif (canvas.id.indexOf('_tempCanvas') !== -1) {
                isSaveCtx = true;
            }
            var img = this.parent.img;
            Iif (width <= 0 || height <= 0) {
                return;
            }
            else if (this.parent.isCropTab) {
                canvasDraw.drawImage(obj.redactImage, 0, 0, obj.redactImage.width, obj.redactImage.height, startX, startY, width, height);
            }
            else {
                var offscreenCanvas = document.createElement('canvas');
                var offscreenCtx = offscreenCanvas.getContext('2d');
                var imageWidth = canvas.width;
                var imageHeight = canvas.height;
                var tempRatio = Math.min(imageWidth, imageHeight) / 1000;
                var straighten = Math.round(this.parent.activeObj.rotatedAngle * (180 / Math.PI));
                if (this.allowRedactStraighten && straighten !== 0) {
                    var tempCanvas = document.createElement('canvas');
                    var tempCtx = tempCanvas.getContext('2d');
                    Iif (isSaveCtx) {
                        tempCanvas.width = canvas.width;
                        tempCanvas.height = canvas.height;
                        tempCtx.drawImage(canvas, 0, 0);
                    }
                    else {
                        tempCanvas.width = img.destWidth > canvas.width ? canvas.width : img.destWidth;
                        tempCanvas.height = img.destHeight > canvas.height ? canvas.height : img.destHeight;
                        tempCtx.drawImage(this.lowerContext.canvas, img.destLeft > 0 ? img.destLeft : 0, img.destTop > 0 ? img.destTop : 0, tempCanvas.width, tempCanvas.height, 0, 0, tempCanvas.width, tempCanvas.height);
                    }
                    var radians = -straighten * Math.PI / 180;
                    var straightenCanvas = document.createElement('canvas');
                    var straightenCtx = straightenCanvas.getContext('2d');
                    straightenCanvas.width = tempCanvas.width;
                    straightenCanvas.height = tempCanvas.height;
                    Iif (img.destWidth > canvas.width && !isSaveCtx) {
                        straightenCanvas.width = canvas.width;
                    }
                    Iif (img.destHeight > canvas.height && !isSaveCtx) {
                        straightenCanvas.height = canvas.height;
                    }
                    straightenCtx.save();
                    straightenCtx.translate(tempCanvas.width / 2, tempCanvas.height / 2);
                    straightenCtx.rotate(radians);
                    straightenCtx.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2);
                    straightenCtx.restore();
                    Eif (img.destLeft > 0 && !isSaveCtx) {
                        startX -= img.destLeft;
                        endX -= img.destLeft;
                    }
                    Eif (img.destTop > 0 && !isSaveCtx) {
                        startY -= img.destTop;
                        endY -= img.destTop;
                    }
                    var center = { x: startX + (width / 2), y: startY + (height / 2) };
                    var cosAngle = Math.cos(straighten * Math.PI / 180);
                    var sinAngle = Math.sin(straighten * Math.PI / 180);
                    var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
                        y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
                    var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
                        y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
                    var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
                        y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
                    Eif (!isSaveCtx) {
                        center = { x: img.destWidth / 2, y: img.destHeight / 2 };
                        Iif (img.destWidth > canvas.width) {
                            center.x = canvas.width / 2;
                        }
                        Iif (img.destHeight > canvas.height) {
                            center.y = canvas.height / 2;
                        }
                    }
                    else {
                        center = { x: canvas.width / 2, y: canvas.height / 2 };
                    }
                    cosAngle = Math.cos(radians);
                    sinAngle = Math.sin(radians);
                    var newP1 = { x: cosAngle * (p1.x - center.x) - sinAngle * (p1.y - center.y) + center.x,
                        y: sinAngle * (p1.x - center.x) + cosAngle * (p1.y - center.y) + center.y };
                    var newP2 = { x: cosAngle * (p2.x - center.x) - sinAngle * (p2.y - center.y) + center.x,
                        y: sinAngle * (p2.x - center.x) + cosAngle * (p2.y - center.y) + center.y };
                    var newP3 = { x: cosAngle * (p3.x - center.x) - sinAngle * (p3.y - center.y) + center.x,
                        y: sinAngle * (p3.x - center.x) + cosAngle * (p3.y - center.y) + center.y };
                    var tempWidth = isSaveCtx ? canvasDraw.canvas.width :
                        (img.destWidth > canvas.width ? canvas.width : img.destWidth);
                    var tempHeight = isSaveCtx ? canvasDraw.canvas.height :
                        (img.destHeight > canvas.height ? canvas.height : img.destHeight);
                    var rotatedWidth = Math.abs(tempWidth * Math.cos(radians)) + Math.abs(tempHeight * Math.sin(radians));
                    var rotatedHeight = Math.abs(tempWidth * Math.sin(radians)) + Math.abs(tempHeight * Math.cos(radians));
                    var prevWidth = straightenCanvas.width;
                    var prevHeight = straightenCanvas.height;
                    straightenCanvas.width = rotatedWidth;
                    straightenCanvas.height = rotatedHeight;
                    straightenCtx.save();
                    straightenCtx.translate(rotatedWidth / 2, rotatedHeight / 2);
                    straightenCtx.rotate(radians);
                    straightenCtx.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2);
                    straightenCtx.restore();
                    if (this.parent.activeObj.redactType === 'blur') {
                        offscreenCanvas.width = width;
                        offscreenCanvas.height = height;
                        var x = newP1.x + ((rotatedWidth - prevWidth) / 2);
                        var y = newP1.y + ((rotatedHeight - prevHeight) / 2);
                        Iif (this.isRedactStraighten) {
                            x = startX + ((rotatedWidth - prevWidth) / 2);
                            y = startY + ((rotatedHeight - prevHeight) / 2);
                        }
                        offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
                    }
                    else {
                        var pixelSize = (obj.redactPixelate / 100) * 20;
                        Iif (isSaveCtx) {
                            pixelSize = tempRatio * (obj.redactPixelate / 100) * 35;
                        }
                        offscreenCanvas.width = Math.ceil(width / pixelSize);
                        offscreenCanvas.height = Math.ceil(height / pixelSize);
                        var x = newP1.x + ((rotatedWidth - prevWidth) / 2);
                        var y = newP1.y + ((rotatedHeight - prevHeight) / 2);
                        Iif (this.isRedactStraighten) {
                            x = startX + ((rotatedWidth - prevWidth) / 2);
                            y = startY + ((rotatedHeight - prevHeight) / 2);
                        }
                        offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
                    }
                }
                if (this.parent.activeObj.redactType === 'blur') {
                    if (straighten === 0) {
                        offscreenCanvas.width = width;
                        offscreenCanvas.height = height;
                        offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, width, height);
                    }
                    Iif (isSaveCtx) {
                        var blur_1 = tempRatio * ((obj.redactBlur / 100) * 34);
                        offscreenCtx.filter = "blur(" + blur_1 + "px)";
                    }
                    else {
                        offscreenCtx.filter = "blur(" + (obj.redactBlur / 100) * 17 + "px)";
                    }
                    offscreenCtx.drawImage(offscreenCanvas, 0, 0);
                    if (straighten === 0) {
                        offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, width, height);
                    }
                    else {
                        Eif (img.destLeft > 0 && !isSaveCtx) {
                            startX += img.destLeft;
                            endX += img.destLeft;
                        }
                        Eif (img.destTop > 0 && !isSaveCtx) {
                            startY += img.destTop;
                            endY += img.destTop;
                        }
                    }
                    Iif (this.parent.isSafari) {
                        this.parent.notify('filter', { prop: 'apply-filter', onPropertyChange: false, value: { context: offscreenCtx } });
                    }
                    canvasDraw.drawImage(offscreenCanvas, 0, 0, width, height, startX, startY, width, height);
                }
                else {
                    var pixelSize = (obj.redactPixelate / 100) * 20;
                    Iif (isSaveCtx) {
                        pixelSize = tempRatio * (obj.redactPixelate / 100) * 35;
                    }
                    if (straighten === 0) {
                        offscreenCanvas.width = Math.ceil(width / pixelSize);
                        offscreenCanvas.height = Math.ceil(height / pixelSize);
                        offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
                    }
                    else {
                        Eif (img.destLeft > 0 && !isSaveCtx) {
                            startX += img.destLeft;
                            endX += img.destLeft;
                        }
                        Eif (img.destTop > 0 && !isSaveCtx) {
                            startY += img.destTop;
                            endY += img.destTop;
                        }
                    }
                    canvasDraw.imageSmoothingEnabled = false;
                    canvasDraw.drawImage(offscreenCanvas, 0, 0, offscreenCanvas.width, offscreenCanvas.height, startX, startY, width, height);
                    Iif (this.parent.imageSmoothingEnabled) {
                        canvasDraw.imageSmoothingEnabled = true;
                    }
                }
                obj.redactImage = this.parent.createElement('canvas');
                obj.redactImage.width = offscreenCanvas.width;
                obj.redactImage.height = offscreenCanvas.height;
                obj.redactImage.getContext('2d').drawImage(offscreenCanvas, 0, 0);
                canvasDraw.beginPath();
                canvasDraw.rect(startX, startY, width, height);
                canvasDraw.rect(startX, startY, width, height);
                canvasDraw.fill('evenodd');
                canvasDraw.closePath();
            }
        };
        return Draw;
    }());
    exports.Draw = Draw;
});