all files / common/ utility.js

97.09% Statements 800/824
90.67% Branches 418/461
100% Functions 80/80
97.07% Lines 794/818
13 statements, 2 functions, 12 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                     30× 30×   30×   24×   20× 20× 42× 43×   20× 30× 30× 30× 30×   30× 20×                             89× 89× 89× 89× 89× 89×                     121× 121× 121× 121× 116×   121×                 1949× 1949× 1949× 2341×   1949×                   89× 89× 89× 172×   89×                       2159× 2159× 2159× 3341× 591×   591×   3341× 3341× 2159×     2159×                 1479× 1479× 1479× 1479× 74× 74×   1479×                                     100× 100× 100× 100× 100×   97× 97× 97× 86×     11×   97× 97× 97× 97× 59× 93× 93×       97× 97× 97× 97× 97× 142× 142× 142×   97×       97×                 151×                   1503×   1503× 1503× 223× 223×                     139× 139× 77×   62× 39×     23×                       798× 7986×   798× 798× 699× 699×   798×                     433× 433× 146×   433× 140× 41× 41×     99× 99× 99× 99× 99×   99× 99× 99×   140×   293× 11×   282×     277×   293× 293× 293× 186× 186× 186×     107× 105×     98×                             32× 32× 32×   32× 32×   32× 32×                     179× 179× 179× 60×   119× 49×   70×   66×           179×                   78× 78×     78×                   125×                 864×                 40×     38×                   60×     59× 59×                   18010× 18010× 11103×   6907× 6907× 6907× 6907×   6907× 6907× 6907× 4540×   6907× 6907× 5033×   1874× 38×   1836× 12×   1824× 1258×     566×   6907×                     168× 168× 16×       16× 16×   152× 152× 152× 152× 152× 12× 12×   140× 133×       152× 152×       152× 152×                       142× 142× 142× 121×     21×                     7220× 7220× 7220× 206× 206×   7220×                   5087× 130×   4957× 4957× 4944×     13×   4957× 4957×                     92× 380× 92×                     60× 60× 60× 60× 60× 37×   60× 42× 42× 42× 42× 42× 24×     18×   42× 42× 42×   60× 60×   56×       56× 21× 21×     35× 35×     60× 60× 60×                 3959×                   2106× 2106× 7084×                       2490× 12191× 12191× 12191× 26×   12191× 12191×                     73859× 73859×                   6384× 6384× 6384×                   15× 15× 15×       15×       15× 15×           15×   15×                   15× 15× 15× 15×   15×                           15×                   69× 69× 69× 69× 69× 69× 69× 69× 69× 69× 69× 69× 69× 69×         69× 69×                     23× 23× 23× 23× 23× 23× 23× 18×       18× 18×                         88× 88× 87× 87× 20×   87× 87× 84× 82× 82×                                               118× 118× 170× 96× 96× 11×               11× 11× 11×       74× 74× 74× 74× 13×   74× 74×   74×                     118×                 31× 31× 31× 31× 31× 31× 21× 21× 21×                     24× 24× 24×     24×                   47× 47× 47× 47× 43×                               92× 62× 38× 38× 38×     24×     92× 78×   92× 92× 122× 122× 25×     92× 92× 92× 17×     75×   92× 92×   90× 90×                                                           16× 16× 16× 32× 16× 16×     16×                 42× 42×   42× 30× 30× 30× 42× 42×   30×     42×     42×       42×     42× 42× 42×     42× 42×         42× 42×                   41× 41× 41× 15× 15×   41× 41× 41× 41× 41× 41× 41×   41× 41× 41× 41× 41× 41× 31×   41×                       42× 42× 42× 42× 42× 42×       42×       40×   42× 42×       42× 42× 42× 54× 54×   42× 42×     41×                                         179× 179×                   358× 358× 118×                         138× 138× 138× 138×       138× 138× 138×                     138× 138× 138× 138× 138× 138× 36× 36×   138× 138× 138× 138× 51× 51× 51×   51× 51× 51×   87× 48× 48× 30×   18× 11×   48× 48× 48×   39× 39× 39× 26×   39× 39× 39×       138× 138× 138× 138×                   15× 15× 15× 90× 90×     15×                   7828× 1153×   6675×                   118× 118× 118× 118×                 24×     22×                     14× 14× 10× 10× 10×                           12×                                                         97× 97×     97×             97×                 1703×                 2127× 2127×                 19574× 19574×                 81× 81×                 143× 143×                 19× 19×                 75× 75×     67×                   19× 19× 14×                                               58× 58× 68× 68× 66×   68× 29×         39× 39×       68×                       58×      
define(["require", "exports", "../base/classes", "../base/constant", "../common/operations", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-data", "../pop-up/dialog"], function (require, exports, CLS, events, operations_1, ej2_base_1, ej2_base_2, ej2_data_1, dialog_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    /**
     * Utility function to compare two strings in a way similar to Windows Explorer.
     * Files and folders are sorted separately, with folders coming before files.
     *
     * @param {string} reference - The first string to compare. This could be a file or folder name.
     * @param {string} comparer - The second string to compare. This could be a file or folder name.
     * @returns {number} - A negative number if `reference` should come before `comparer`, a positive number if `comparer` should come before `reference`, and 0 if they are considered equal.
     */
    function sortComparer(reference, comparer) {
        // Check if reference and comparer are files or folders
        var referenceIsFile = /\.\S+/.test(reference);
        var comparerIsFile = /\.\S+/.test(comparer);
        // If one is a file and the other is a folder, the folder should come first
        if (referenceIsFile && !comparerIsFile) {
            return 1;
        }
        if (!referenceIsFile && comparerIsFile) {
            return -1;
        }
        var referenceParts = [];
        var comparerParts = [];
        (reference + '').replace(/(\d+)|(\D+)/g, function (_, $1, $2) { referenceParts.push([$1 || Infinity, $2 || '']); return ''; });
        (comparer + '').replace(/(\d+)|(\D+)/g, function (_, $1, $2) { comparerParts.push([$1 || Infinity, $2 || '']); return ''; });
        // Compare each part of reference and comparer
        while (referenceParts.length && comparerParts.length) {
            var referencePart = referenceParts.shift();
            var comparerPart = comparerParts.shift();
            Eif (referencePart && comparerPart) {
                var comparisonResult = referencePart[0] - comparerPart[0] ||
                    referencePart[1].localeCompare(comparerPart[1]);
                if (comparisonResult) {
                    return comparisonResult;
                }
            }
        }
        return referenceParts.length - comparerParts.length;
    }
    exports.sortComparer = sortComparer;
    /**
     * Utility file for common actions
     *
     * @param {HTMLLIElement} node - specifies the node.
     * @param {Object} data - specifies the data.
     * @param {IFileManager} instance - specifies the control instance.
     * @returns {void}
     * @private
     */
    function updatePath(node, data, instance) {
        var text = ej2_base_1.getValue('name', data);
        var id = node.getAttribute('data-id');
        var newText = ej2_base_1.isNullOrUndefined(id) ? text : id;
        instance.setProperties({ path: getPath(node, newText, instance.hasId) }, true);
        instance.pathId = getPathId(node);
        instance.pathNames = getPathNames(node, text);
    }
    exports.updatePath = updatePath;
    /**
     * Functions for get path in FileManager
     *
     * @param {Element | Node} element - specifies the element.
     * @param {string} text - specifies the text.
     * @param {boolean} hasId - specifies the id.
     * @returns {string} returns the path.
     * @private
     */
    function getPath(element, text, hasId) {
        var matched = getParents(element, text, false, hasId);
        var path = '/';
        var len = matched.length - (2);
        for (var i = len; i >= 0; i--) {
            path += matched[i] + '/';
        }
        return path;
    }
    exports.getPath = getPath;
    /**
     * Functions for get path id in FileManager
     *
     * @param {Element} node - specifies the node element.
     * @returns {string[]} returns the path ids.
     * @private
     */
    function getPathId(node) {
        var matched = getParents(node, node.getAttribute('data-uid'), true);
        var ids = [];
        for (var i = matched.length - 1; i >= 0; i--) {
            ids.push(matched[i]);
        }
        return ids;
    }
    exports.getPathId = getPathId;
    /**
     * Functions for get path names in FileManager
     *
     * @param {Element} element - specifies the node element.
     * @param {string} text - specifies the text.
     * @returns {string[]} returns the path names.
     * @private
     */
    function getPathNames(element, text) {
        var matched = getParents(element, text, false);
        var names = [];
        for (var i = matched.length - 1; i >= 0; i--) {
            names.push(matched[i]);
        }
        return names;
    }
    exports.getPathNames = getPathNames;
    /**
     * Functions for get path id in FileManager
     *
     * @param {Element} element - specifies the node element.
     * @param {string} text - specifies the text.
     * @param {boolean} isId - specifies the id.
     * @param {boolean} hasId - checks the id exists.
     * @returns {string[]} returns parent element.
     * @private
     */
    function getParents(element, text, isId, hasId) {
        var matched = [text];
        var el = element.parentNode;
        while (!ej2_base_1.isNullOrUndefined(el)) {
            if (ej2_base_1.matches(el, '.' + CLS.LIST_ITEM)) {
                var parentText = isId ? el.getAttribute('data-uid') : (hasId ? el.getAttribute('data-id') :
                    ej2_base_1.select('.' + CLS.LIST_TEXT, el).textContent);
                matched.push(parentText);
            }
            el = el.parentNode;
            if (el.classList.contains(CLS.TREE_VIEW)) {
                break;
            }
        }
        return matched;
    }
    exports.getParents = getParents;
    /**
     * Functions for generate path
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function generatePath(parent) {
        var key = parent.hasId ? 'id' : 'name';
        var newPath = '/';
        var i = 1;
        for (i; i < parent.pathId.length; i++) {
            var data = ej2_base_1.getValue(parent.pathId[parseInt(i.toString(), 10)], parent.feParent);
            newPath += ej2_base_1.getValue(key, data) + '/';
        }
        parent.setProperties({ path: newPath }, true);
    }
    exports.generatePath = generatePath;
    /**
     * Functions for remove active element
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function removeActive(parent) {
        if (parent.isCut) {
            removeBlur(parent);
            parent.selectedNodes = [];
            parent.actionRecords = [];
            parent.enablePaste = false;
            parent.notify(events.hidePaste, {});
        }
    }
    exports.removeActive = removeActive;
    /**
     * Selects active element in File Manager
     *
     * @param {string} action - specifies the action.
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {boolean} - returns active element.
     * @private
     */
    function activeElement(action, parent) {
        parent.isSearchCut = false;
        parent.actionRecords = [];
        parent.activeElements = [];
        parent.notify(events.cutCopyInit, {});
        if (parent.activeElements.length === 0) {
            return false;
        }
        removeBlur(parent);
        var blurEle = parent.activeElements;
        if (parent.activeModule !== 'navigationpane') {
            parent.targetPath = parent.path;
        }
        else {
            parent.targetPath = getParentPath(parent.path);
        }
        var i = 0;
        Eif (blurEle) {
            getModule(parent, blurEle[0]);
            if (action === 'cut') {
                while (i < blurEle.length) {
                    addBlur(blurEle[i]);
                    i++;
                }
            }
        }
        i = 0;
        parent.selectedNodes = [];
        parent.enablePaste = true;
        parent.notify(events.showPaste, {});
        while (i < parent.activeRecords.length) {
            parent.actionRecords.push(parent.activeRecords[i]);
            parent.selectedNodes.push(ej2_base_1.getValue('name', parent.activeRecords[i]));
            i++;
        }
        if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) &&
            parent.activeModule !== 'navigationpane') {
            parent.selectedNodes = [];
            parent.isSearchCut = true;
            var i_1 = 0;
            while (i_1 < parent.selectedItems.length) {
                parent.selectedNodes.push(parent.selectedItems[i_1]);
                i_1++;
            }
        }
        return true;
    }
    exports.activeElement = activeElement;
    /**
     * Adds blur to the elements
     *
     * @param {Element} nodes - specifies the nodes.
     * @returns {void}
     * @private
     */
    function addBlur(nodes) {
        nodes.classList.add(CLS.BLUR);
    }
    exports.addBlur = addBlur;
    /**
     * Removes blur from elements
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string} hover - specifies the hover string.
     * @returns {void}
     * @private
     */
    function removeBlur(parent, hover) {
        var blurEle = (!hover) ? parent.element.querySelectorAll('.' + CLS.BLUR) :
            parent.element.querySelectorAll('.' + CLS.HOVER);
        var i = 0;
        while (i < blurEle.length) {
            blurEle[i].classList.remove((!hover) ? CLS.BLUR : CLS.HOVER);
            i++;
        }
    }
    exports.removeBlur = removeBlur;
    /**
     * Gets module name
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {Element} element - specifies the element.
     * @returns {void}
     * @private
     */
    function getModule(parent, element) {
        Eif (element) {
            if (element.classList.contains(CLS.ROW)) {
                parent.activeModule = 'detailsview';
            }
            else if (ej2_base_2.closest(element, '.' + CLS.LARGE_ICON)) {
                parent.activeModule = 'largeiconsview';
            }
            else {
                parent.activeModule = 'navigationpane';
            }
        }
    }
    exports.getModule = getModule;
    /**
     * Get all child items
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string | number} parentId - specifies the parent ID.
     * @returns {Object[]} An array of child items
     * @private
     */
    function getAllChildItems(parent, parentId) {
        var children = parent.fileSystemData.filter(function (item) {
            return String(item.parentId) === String(parentId);
        });
        var allChildren = children.slice();
        children.forEach(function (child) {
            var childId = child.id;
            allChildren = allChildren.concat(getAllChildItems(parent, childId));
        });
        return allChildren;
    }
    exports.getAllChildItems = getAllChildItems;
    /**
     * Gets module name
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string} value - specifies the value.
     * @param {boolean} isLayoutChange - specifies the layout change.
     * @returns {void}
     * @private
     */
    function searchWordHandler(parent, value, isLayoutChange) {
        var searchWord;
        if (value.length === 0 && !parent.isFiltered) {
            parent.notify(events.pathColumn, { args: parent });
        }
        if (operations_1.isFileSystemData(parent)) {
            if (value === '') {
                parent.itemData = parent.fileSystemData;
                operations_1.read(parent, events.layoutChange, parent.path);
            }
            else {
                parent.searchSettings.filterType = ej2_base_1.isNullOrUndefined(parent.searchSettings.filterType) ? 'contains' : parent.searchSettings.filterType;
                var currData = ej2_base_1.getValue(parent.pathId[parent.pathId.length - 1], parent.feParent);
                var parentId = ej2_base_1.getValue('id', currData);
                var filteredData = getAllChildItems(parent, parentId);
                var data = new ej2_data_1.DataManager(filteredData).
                    executeLocal(new ej2_data_1.Query().where('name', parent.searchSettings.filterType, value, parent.searchSettings.ignoreCase));
                var searchValue = parent.searchSettings.ignoreCase ? value.toLowerCase() : value;
                parent.itemData = data;
                operations_1.Search(parent, isLayoutChange ? events.layoutChange : events.search, parent.path, searchValue, parent.showHiddenItems, !parent.searchSettings.ignoreCase);
            }
            return;
        }
        if (parent.searchSettings.filterType === 'startsWith') {
            searchWord = value + '*';
        }
        else if (parent.searchSettings.filterType === 'endsWith') {
            searchWord = '*' + value;
        }
        else {
            searchWord = '*' + value + '*';
        }
        parent.searchWord = searchWord;
        parent.itemData = [getPathObject(parent)];
        if (value.length > 0) {
            var caseSensitive = parent.searchSettings.ignoreCase;
            var hiddenItems = parent.showHiddenItems;
            operations_1.Search(parent, isLayoutChange ? events.layoutChange : events.search, parent.path, searchWord, hiddenItems, !caseSensitive);
        }
        else {
            if (!parent.isFiltered) {
                if (parent.isSortByClicked) {
                    parent.notify(events.layoutChange, { files: (parent.oldView === 'Details') ? parent.detailsviewModule.gridObj.dataSource : parent.largeiconsviewModule.allItems });
                    parent.isSortByClicked = false;
                }
                else {
                    operations_1.read(parent, isLayoutChange ? events.layoutChange : events.search, parent.path);
                }
            }
            else {
                operations_1.filter(parent, events.layoutChange);
            }
        }
    }
    exports.searchWordHandler = searchWordHandler;
    /**
     * Gets updated layout
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string} view - specifies the view.
     * @returns {void}
     * @private
     */
    function updateLayout(parent, view) {
        parent.oldView = parent.view;
        parent.setProperties({ view: view }, true);
        if (parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) {
            parent.layoutSelectedItems = parent.selectedItems;
        }
        var searchWord = '';
        if (parent.breadcrumbbarModule.searchObj.element.value) {
            searchWord = parent.breadcrumbbarModule.searchObj.element.value;
        }
        parent.isLayoutChange = true;
        searchWordHandler(parent, searchWord, true);
    }
    exports.updateLayout = updateLayout;
    /* istanbul ignore next */
    /**
     * Gets updated layout
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {Element} element - specifies the element.
     * @returns {void}
     * @private
     */
    function getTargetModule(parent, element) {
        var tartgetModule = '';
        Eif (element) {
            if (ej2_base_2.closest(element, '.' + CLS.ROOT + '.' + CLS.CONTROL + ' .' + CLS.GRID_CONTENT)) {
                tartgetModule = 'detailsview';
            }
            else if (ej2_base_2.closest(element, '.' + CLS.LARGE_ICONS)) {
                tartgetModule = 'largeiconsview';
            }
            else if (element.classList.contains('e-fullrow') ||
                element.classList.contains('e-icon-expandable')) {
                tartgetModule = 'navigationpane';
            }
            else Iif (ej2_base_2.closest(element, '.e-address-list-item')) {
                tartgetModule = 'breadcrumbbar';
            }
            else {
                tartgetModule = '';
            }
        }
        parent.targetModule = tartgetModule;
    }
    exports.getTargetModule = getTargetModule;
    /* istanbul ignore next */
    /**
     * refresh the layout
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function refresh(parent) {
        parent.itemData = [getPathObject(parent)];
        Iif (!hasReadAccess(parent.itemData[0])) {
            createDeniedDialog(parent, parent.itemData[0], events.permissionRead);
        }
        else {
            operations_1.read(parent, events.refreshEnd, parent.path);
        }
    }
    exports.refresh = refresh;
    /**
     * open action in the layout
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function openAction(parent) {
        operations_1.read(parent, events.openEnd, parent.path);
    }
    exports.openAction = openAction;
    /**
     * open action in the layout
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {Object} - returns the path data.
     * @private
     */
    function getPathObject(parent) {
        return ej2_base_1.getValue(parent.pathId[parent.pathId.length - 1], parent.feParent);
    }
    exports.getPathObject = getPathObject;
    /**
     * Copy files
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function copyFiles(parent) {
        if (!activeElement('copy', parent)) {
            return;
        }
        else {
            parent.fileAction = 'copy';
        }
    }
    exports.copyFiles = copyFiles;
    /**
     * Cut files
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function cutFiles(parent) {
        if (!activeElement('cut', parent)) {
            return;
        }
        else {
            parent.isCut = true;
            parent.fileAction = 'move';
        }
    }
    exports.cutFiles = cutFiles;
    /**
     * To add class for fileType
     *
     * @param {Object} file - specifies the file.
     * @returns {string} - returns the file type.
     * @private
     */
    function fileType(file) {
        var isFile = ej2_base_1.getValue('isFile', file);
        if (!isFile) {
            return CLS.FOLDER;
        }
        var imageFormat = ['bmp', 'dib', 'jpg', 'jpeg', 'jpe', 'jfif', 'gif', 'tif', 'tiff', 'png', 'ico'];
        var audioFormat = ['mp3', 'wav', 'aac', 'ogg', 'wma', 'aif', 'fla', 'm4a'];
        var videoFormat = ['webm', 'mkv', 'flv', 'vob', 'ogv', 'ogg', 'avi', 'wmv', 'mp4', '3gp'];
        var knownFormat = ['css', 'exe', 'html', 'js', 'msi', 'pdf', 'pptx', 'ppt', 'rar', 'zip', 'txt', 'docx', 'doc',
            'xlsx', 'xls', 'xml', 'rtf', 'php'];
        var filetype = ej2_base_1.getValue('type', file);
        filetype = filetype.toLowerCase();
        if (filetype.indexOf('.') !== -1) {
            filetype = filetype.split('.').join('');
        }
        var iconType;
        if (imageFormat.indexOf(filetype) !== -1) {
            iconType = CLS.ICON_IMAGE;
        }
        else if (audioFormat.indexOf(filetype) !== -1) {
            iconType = CLS.ICON_MUSIC;
        }
        else if (videoFormat.indexOf(filetype) !== -1) {
            iconType = CLS.ICON_VIDEO;
        }
        else if (knownFormat.indexOf(filetype) !== -1) {
            iconType = 'e-fe-' + filetype;
        }
        else {
            iconType = 'e-fe-unknown e-fe-' + filetype;
        }
        return iconType;
    }
    exports.fileType = fileType;
    /* istanbul ignore next */
    /**
     * To get the image URL
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {Object} item - specifies the item.
     * @returns {string} - returns the image url.
     * @private
     */
    function getImageUrl(parent, item) {
        var imgUrl = operations_1.isFileSystemData(parent) ? ej2_base_1.getValue('imageUrl', item) : '';
        if (operations_1.isFileSystemData(parent)) {
            var eventArgs_1 = {
                fileDetails: [item],
                imageUrl: imgUrl
            };
            parent.trigger('beforeImageLoad', eventArgs_1);
            return eventArgs_1.imageUrl;
        }
        var baseUrl = parent.ajaxSettings.getImageUrl ? parent.ajaxSettings.getImageUrl : parent.ajaxSettings.url;
        var pathUrl = (baseUrl.indexOf('?') !== -1) ? '&path=' : '?path=';
        var fileName = encodeURIComponent(ej2_base_1.getValue('name', item));
        var fPath = ej2_base_1.getValue('filterPath', item);
        if (parent.hasId) {
            var imgId = ej2_base_1.getValue('id', item);
            imgUrl = baseUrl + pathUrl + parent.path + '&id=' + imgId;
        }
        else if (!ej2_base_1.isNullOrUndefined(fPath)) {
            imgUrl = baseUrl + pathUrl + encodeURIComponent(fPath.replace(/\\/g, '/')) + fileName;
        }
        else {
            imgUrl = baseUrl + pathUrl + parent.path + fileName;
        }
        imgUrl = imgUrl + '&time=' + (new Date().getTime()).toString();
        var eventArgs = {
            fileDetails: [item],
            imageUrl: imgUrl
        };
        parent.trigger('beforeImageLoad', eventArgs);
        return eventArgs.imageUrl;
    }
    exports.getImageUrl = getImageUrl;
    /* istanbul ignore next */
    /**
     * Gets the full path
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {Object} data - specifies the data.
     * @param {string} path - specifies the path.
     * @returns {string} - returns the image url.
     * @private
     */
    function getFullPath(parent, data, path) {
        var filePath = ej2_base_1.getValue(parent.hasId ? 'id' : 'name', data) + '/';
        var fPath = ej2_base_1.getValue(parent.hasId ? 'filterId' : 'filterPath', data);
        if (!ej2_base_1.isNullOrUndefined(fPath)) {
            return fPath.replace(/\\/g, '/') + filePath;
        }
        else {
            return path + filePath;
        }
    }
    exports.getFullPath = getFullPath;
    /**
     * Gets the name
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {Object} data - specifies the data.
     * @returns {string} - returns the name.
     * @private
     */
    function getName(parent, data) {
        var name = ej2_base_1.getValue('name', data);
        var fPath = ej2_base_1.getValue('filterPath', data);
        if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) && !ej2_base_1.isNullOrUndefined(fPath)) {
            fPath = fPath.replace(/\\/g, '/');
            name = fPath.replace(parent.path, '') + name;
        }
        return name;
    }
    exports.getName = getName;
    /**
     * Gets the name
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {Object[]} items - specifies the item elements.
     * @returns {Object[]} - returns the sorted data.
     * @private
     */
    function getSortedData(parent, items) {
        if (items.length === 0) {
            return items;
        }
        var query;
        if (parent.sortOrder !== 'None' && !ej2_base_1.isNullOrUndefined(parent.sortOrder)) {
            query = new ej2_data_1.Query().sortBy(parent.sortBy, parent.sortOrder.toLowerCase(), true).group('isFile');
        }
        else {
            query = new ej2_data_1.Query().group('isFile');
        }
        var lists = new ej2_data_1.DataManager(items).executeLocal(query);
        return ej2_base_1.getValue('records', lists);
    }
    exports.getSortedData = getSortedData;
    /**
     * Gets the data object
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string} key - specifies the key.
     * @param {string} value - specifies the value.
     * @returns {Object} - returns the sorted data.
     * @private
     */
    function getObject(parent, key, value) {
        var currFiles = ej2_base_1.getValue(parent.pathId[parent.pathId.length - 1], parent.feFiles);
        var result = currFiles.filter(function (data) { return data[key].toString() === value; });
        return result.length > 0 ? result[0] : null;
    }
    exports.getObject = getObject;
    /**
     * Creates empty element
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {HTMLElement} element - specifies the element.
     * @param {ReadArgs | SearchArgs} args - specifies the args.
     * @returns {void}
     * @private
     */
    function createEmptyElement(parent, element, args) {
        var top;
        var layoutElement = ej2_base_1.select('#' + parent.element.id + CLS.LAYOUT_ID, parent.element);
        var addressBarHeight = ej2_base_1.select('#' + parent.element.id + CLS.BREADCRUMBBAR_ID, layoutElement).offsetHeight;
        top = layoutElement.offsetHeight - addressBarHeight;
        if (parent.view === 'Details') {
            top = top - ej2_base_1.select('.' + CLS.GRID_HEADER, layoutElement).offsetHeight;
        }
        if (ej2_base_1.isNullOrUndefined(element.querySelector('.' + CLS.EMPTY))) {
            var emptyDiv = ej2_base_1.createElement('div', { className: CLS.EMPTY });
            var emptyFolder = ej2_base_1.createElement('div', { className: CLS.LARGE_EMPTY_FOLDER });
            var emptyEle = ej2_base_1.createElement('div', { className: CLS.EMPTY_CONTENT });
            var dragFile = ej2_base_1.createElement('div', { className: CLS.EMPTY_INNER_CONTENT });
            if (parent.view === 'Details') {
                element.querySelector('.' + CLS.GRID_VIEW).appendChild(emptyDiv);
            }
            else {
                element.appendChild(emptyDiv);
            }
            emptyDiv.appendChild(emptyFolder);
            emptyDiv.appendChild(emptyEle);
            emptyDiv.appendChild(dragFile);
        }
        Eif (element.querySelector('.' + CLS.EMPTY)) {
            if (!ej2_base_1.isNullOrUndefined(args.error)) {
                element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Access-Denied');
                element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Access-Details');
            }
            else Iif (parent.isFiltered) {
                element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Empty');
                element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Key');
            }
            else if (parent.breadcrumbbarModule.searchObj.element.value !== '') {
                element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Search-Empty');
                element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Search-Key');
            }
            else {
                element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Folder-Empty');
                element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'File-Upload');
            }
        }
        var eDiv = ej2_base_1.select('.' + CLS.EMPTY, element);
        top = (top - eDiv.offsetHeight) / 2;
        eDiv.style.marginTop = top + 'px';
    }
    exports.createEmptyElement = createEmptyElement;
    /**
     * Gets the directories
     *
     * @param {Object[]} files - specifies the file object.
     * @returns {Object[]} - returns the sorted data.
     * @private
     */
    function getDirectories(files) {
        return new ej2_data_1.DataManager(files).executeLocal(new ej2_data_1.Query().where(events.isFile, 'equal', false, false));
    }
    exports.getDirectories = getDirectories;
    /**
     * set the Node ID
     *
     * @param {ReadArgs} result - specifies the result.
     * @param {string} rootId - specifies the rootId.
     * @returns {void}
     * @private
     */
    function setNodeId(result, rootId) {
        var dirs = getDirectories(result.files);
        for (var i = 0, len = dirs.length; i < len; i++) {
            ej2_base_1.setValue('_fm_id', rootId + '_' + i, dirs[i]);
        }
    }
    exports.setNodeId = setNodeId;
    /**
     * set the date object
     *
     * @param {Object[]} args - specifies the file object.
     * @param {Internationalization} localeString - The internationalization object for formatting dates.
     * @param {string} dateFormat - The date format string.
     * @returns {void}
     * @private
     */
    function setDateObject(args, localeString, dateFormat) {
        for (var i = 0; i < args.length; i++) {
            var createdDate = new Date(ej2_base_1.getValue('dateCreated', args[i]));
            var modifiedDate = new Date(ej2_base_1.getValue('dateModified', args[i]));
            if (ej2_base_1.isNullOrUndefined(dateFormat)) {
                dateFormat = 'MM/dd/yyyy';
            }
            ej2_base_1.setValue('_fm_created', localeString.formatDate(createdDate, { format: dateFormat }), args[i]);
            ej2_base_1.setValue('_fm_modified', localeString.formatDate(modifiedDate, { format: dateFormat }), args[i]);
        }
    }
    exports.setDateObject = setDateObject;
    /**
     * get the locale text
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string} text - specifies the text.
     * @returns {string} - returns the locale text.
     * @private
     */
    function getLocaleText(parent, text) {
        var locale = parent.localeObj.getConstant(text);
        return (locale === '') ? text : locale;
    }
    exports.getLocaleText = getLocaleText;
    /**
     * get the CSS class
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string} css - specifies the css.
     * @returns {string} - returns the css classes.
     * @private
     */
    function getCssClass(parent, css) {
        var cssClass = parent.cssClass;
        cssClass = (ej2_base_1.isNullOrUndefined(cssClass) || cssClass === '') ? css : (cssClass + ' ' + css);
        return cssClass;
    }
    exports.getCssClass = getCssClass;
    /**
     * sort on click
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {MenuEventArgs} args - specifies the menu event arguements.
     * @returns {void}
     * @private
     */
    function sortbyClickHandler(parent, args) {
        var tick;
        parent.isSortByClicked = true;
        if (args.item.id.indexOf('ascending') !== -1 || args.item.id.indexOf('descending') !== -1 || args.item.id.indexOf('none') !== -1) {
            tick = true;
        }
        else {
            tick = false;
        }
        if (!tick) {
            parent.sortBy = getSortField(args.item.id, parent);
        }
        else {
            parent.sortOrder = getSortField(args.item.id);
        }
        parent.itemData = [getPathObject(parent)];
        if (parent.view === 'Details') {
            Iif (parent.isMobile) {
                updateLayout(parent, 'Details');
            }
            else {
                parent.notify(events.sortColumn, { module: 'detailsview' });
                parent.isSortByClicked = false;
            }
        }
        if (parent.view === 'LargeIcons') {
            updateLayout(parent, 'LargeIcons');
        }
        parent.notify(events.sortByChange, {});
    }
    exports.sortbyClickHandler = sortbyClickHandler;
    /**
     * Gets the sorted fields
     *
     * @param {string} id - specifies the id.
     * @param {IFileManager} [parent] - optional parameter representing the parent IFileManager.
     * @returns {string} - returns the sorted fields
     * @private
     */
    function getSortField(id, parent) {
        var text = id.substring(id.lastIndexOf('_') + 1);
        var field = text;
        var column;
        if (parent) {
            column = parent.detailsViewSettings.columns;
        }
        switch (text) {
            case 'date':
                for (var i = 0, len = column.length; i < len; i++) {
                    Iif (column[i].field === 'dateModified' || column[i].field === 'dateCreated') {
                        field = column[i].field;
                        break;
                    }
                    else {
                        field = '_fm_modified';
                    }
                }
                break;
            case 'ascending':
                field = 'Ascending';
                break;
            case 'descending':
                field = 'Descending';
                break;
            case 'none':
                field = 'None';
                break;
        }
        return field;
    }
    exports.getSortField = getSortField;
    /**
     * Sets the next path
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {string} path - specifies the path.
     * @returns {void}
     * @private
     */
    function setNextPath(parent, path) {
        var currfolders = path.split('/');
        var folders = parent.originalPath.split('/');
        var root = ej2_base_1.getValue(parent.pathId[0], parent.feParent);
        var key = ej2_base_1.isNullOrUndefined(ej2_base_1.getValue('id', root)) ? 'name' : 'id';
        for (var i = currfolders.length - 1, len = folders.length - 1; i < len; i++) {
            var eventName = (folders[i + 1] === '') ? events.finalizeEnd : events.initialEnd;
            var newPath = (folders[i] === '') ? '/' : (parent.path + folders[i] + '/');
            var data = getObject(parent, key, folders[parseInt(i.toString(), 10)]);
            Eif (!ej2_base_1.isNullOrUndefined(data)) {
                var id = ej2_base_1.getValue('_fm_id', data);
                parent.setProperties({ path: newPath }, true);
                parent.pathId.push(id);
                parent.itemData = [data];
                parent.pathNames.push(ej2_base_1.getValue('name', data));
            }
            else {
                parent.originalPath = newPath;
            }
            operations_1.read(parent, eventName, parent.path);
            break;
        }
    }
    exports.setNextPath = setNextPath;
    /**
     * Opens the searched folder
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {Object} data - specifies the data
     * @returns {void}
     * @private
     */
    function openSearchFolder(parent, data) {
        parent.originalPath = getFullPath(parent, data, parent.path);
        var root = ej2_base_1.getValue(parent.pathId[0], parent.feParent);
        var navData = parent.feParent[ej2_base_1.getValue('_fm_id', parent.itemData[0])];
        var isRoot = ej2_base_1.isNullOrUndefined(navData) || ej2_base_1.getValue('_fm_id', navData) === 'fe_tree';
        var key = ej2_base_1.isNullOrUndefined(ej2_base_1.getValue('id', root)) ? 'name' : 'id';
        var searchData = getObject(parent, key, operations_1.isFileSystemData(parent) ? ej2_base_1.getValue('id', data) : ej2_base_1.getValue('name', data));
        if (ej2_base_1.isNullOrUndefined(searchData)) {
            Iif (!isRoot) {
                parent.notify(events.clearPathInit, { selectedNode: parent.pathId[parent.pathId.length - 1] });
            }
            else {
                setNextPath(parent, parent.path);
                return;
            }
        }
        else {
            var id = ej2_base_1.getValue('_fm_id', searchData);
            parent.setProperties({ path: parent.originalPath }, true);
            parent.pathId.push(id);
            parent.itemData = [searchData];
            parent.pathNames.push(ej2_base_1.getValue('name', searchData));
        }
        operations_1.read(parent, (parent.path !== parent.originalPath) ? events.initialEnd : events.finalizeEnd, parent.path);
    }
    exports.openSearchFolder = openSearchFolder;
    /**
     * Paste handling function
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function pasteHandler(parent) {
        parent.isDragDrop = false;
        if (parent.selectedNodes.length !== 0 && parent.enablePaste) {
            var path = (parent.folderPath === '') ? parent.path : parent.folderPath;
            if (parent.activeModule === 'navigationpane' && !parent.selectedNodes[0].includes('/')) {
                parent.targetPath = ej2_base_1.getValue('filterPath', parent.actionRecords[0]).replace(/\\/g, '/');
            }
            var subFolder = validateSubFolder(parent, parent.actionRecords, path, parent.path);
            if (!subFolder) {
                if ((parent.fileAction === 'move' && parent.targetPath !== path) || parent.fileAction === 'copy') {
                    parent.notify(events.pasteInit, {});
                    operations_1.paste(parent, parent.targetPath, parent.selectedNodes, path, parent.fileAction, [], parent.actionRecords);
                }
                else {
                    parent.enablePaste = false;
                    parent.notify(events.hidePaste, {});
                    removeBlur(parent);
                    var result = {
                        files: null,
                        error: {
                            code: '402',
                            message: getLocaleText(parent, 'Same-Folder-Error'),
                            fileExists: null
                        }
                    };
                    dialog_1.createDialog(parent, 'Error', result);
                }
            }
        }
    }
    exports.pasteHandler = pasteHandler;
    /**
     * Validates the sub folders
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @param {'{ [key: string]: Object; }[]'} data - specifies the data.
     * @param {string} dropPath - specifies the drop path.
     * @param {string} dragPath - specifies the drag path.
     * @returns {boolean} - returns the validated sub folder.
     * @private
     */
    function validateSubFolder(parent, data, dropPath, dragPath) {
        var subFolder = false;
        for (var i = 0; i < data.length; i++) {
            if (!ej2_base_1.getValue('isFile', data[i])) {
                var tempTarget = getFullPath(parent, data[i], dragPath);
                if (dropPath.indexOf(tempTarget) === 0) {
                    var result = {
                        files: null,
                        error: {
                            code: '402',
                            message: getLocaleText(parent, 'Sub-Folder-Error'),
                            fileExists: null
                        }
                    };
                    dialog_1.createDialog(parent, 'Error', result);
                    subFolder = true;
                    break;
                }
            }
            else {
                var name_1 = parent.dragData[i] ? parent.dragData[i].name : null;
                var srcData = operations_1.isFileSystemData(parent) ? name_1 : parent.dragNodes[i];
                var len = 0;
                if (srcData) {
                    len = srcData.lastIndexOf('/');
                }
                var path = '';
                if (len > 0) {
                    path = dragPath + srcData.substring(0, len + 1);
                }
                if (path === dropPath) {
                    var result = {
                        files: null,
                        error: {
                            code: '402',
                            message: getLocaleText(parent, 'Same-Folder-Error'),
                            fileExists: null
                        }
                    };
                    dialog_1.createDialog(parent, 'Error', result);
                    subFolder = true;
                    break;
                }
            }
        }
        return subFolder;
    }
    exports.validateSubFolder = validateSubFolder;
    /**
     * Validates the drop handler
     *
     * @param {IFileManager} parent - specifies the parent element.
     * @returns {void}
     * @private
     */
    function dropHandler(parent) {
        parent.isDragDrop = true;
        Eif (parent.dragData.length !== 0) {
            parent.dragPath = parent.dragPath.replace(/\\/g, '/');
            parent.dropPath = parent.dropPath.replace(/\\/g, '/');
            var subFolder = validateSubFolder(parent, parent.dragData, parent.dropPath, parent.dragPath);
            if (!subFolder && (parent.dragPath !== parent.dropPath)) {
                parent.itemData = [parent.dropData];
                operations_1.paste(parent, parent.dragPath, parent.dragNodes, parent.dropPath, 'move', [], parent.dragData);
                parent.notify(events.pasteInit, {});
            }
        }
    }
    exports.dropHandler = dropHandler;
    /**
     * Gets the parent path
     *
     * @param {string} oldPath - specifies the old path.
     * @returns {string} - returns the parent path.
     * @private
     */
    function getParentPath(oldPath) {
        var path = oldPath.split('/');
        var newPath = path[0] + '/';
        for (var i = 1; i < path.length - 2; i++) {
            newPath += path[i] + '/';
        }
        return newPath;
    }
    exports.getParentPath = getParentPath;
    /**
     * Gets the directory path
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {ReadArgs} args - returns the read arguements.
     * @returns {string} - returns the directory path
     * @private
     */
    function getDirectoryPath(parent, args) {
        var filePath = ej2_base_1.getValue(parent.hasId ? 'id' : 'name', args.cwd) + '/';
        var fPath = ej2_base_1.getValue(parent.hasId && !ej2_base_1.isNullOrUndefined(parent.ajaxSettings.url) ? 'filterId' : 'filterPath', args.cwd);
        Eif (!ej2_base_1.isNullOrUndefined(fPath)) {
            if (fPath === '') {
                return parent.hasId && !ej2_base_1.isNullOrUndefined(parent.ajaxSettings.url) ? filePath : '/';
            }
            return fPath.replace(/\\/g, '/') + filePath;
        }
        else {
            return operations_1.isFileSystemData(parent) ? filePath : parent.path + filePath;
        }
    }
    exports.getDirectoryPath = getDirectoryPath;
    /**
     * Gets the do paste path
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {string} operation - specifies the operations.
     * @param {ReadArgs} result - returns the result.
     * @returns {void}
     * @private
     */
    function doPasteUpdate(parent, operation, result) {
        if (operation === 'move') {
            if (!parent.isDragDrop) {
                parent.enablePaste = false;
                parent.notify(events.hidePaste, {});
                parent.notify(events.cutEnd, result);
            }
            else {
                parent.notify(events.dragEnd, result);
            }
        }
        if (parent.duplicateItems.length === 0) {
            parent.pasteNodes = [];
        }
        var flag = false;
        for (var count = 0; (count < result.files.length) && !flag; count++) {
            parent.pasteNodes.push(result.files[count][parent.hasId ? 'id' : 'name']);
            if (parent.isDragDrop) {
                parent.droppedObjects.push(result.files[count]);
            }
        }
        parent.duplicateItems = [];
        parent.duplicateRecords = [];
        if (parent.isDragDrop && !parent.isPasteError) {
            parent.isDropEnd = true;
        }
        else {
            parent.isDropEnd = false;
        }
        parent.trigger('success', { action: operation, result: result });
        if (!parent.isDragDrop || (parent.path === parent.dragPath) || (parent.path === parent.dropPath)
            || parent.isSearchDrag) {
            parent.isPathDrag = false;
            operations_1.read(parent, events.pasteEnd, parent.path);
        }
        else {
            readDropPath(parent);
        }
    }
    exports.doPasteUpdate = doPasteUpdate;
    /**
     * Reads the drop path
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function readDropPath(parent) {
        var pathId = ej2_base_1.getValue('_fm_id', parent.dropData);
        parent.expandedId = pathId;
        parent.itemData = [parent.dropData];
        Iif (parent.isPathDrag) {
            parent.notify(events.pathDrag, parent.itemData);
        }
        else {
            Eif (parent.navigationpaneModule) {
                var node = ej2_base_1.select('[data-uid="' + pathId + '"]', parent.navigationpaneModule.treeObj.element);
                Iif (!node) {
                    var liElement = document.querySelector('[data-id = "' + ej2_base_1.getValue('id', parent.dropData) + '"]');
                    pathId = liElement.getAttribute('data-uid');
                    node = ej2_base_1.select('[data-uid="' + pathId + '"]', parent.navigationpaneModule.treeObj.element);
                }
                updatePath(node, parent.dropData, parent);
            }
            operations_1.read(parent, events.dropPath, parent.dropPath);
        }
    }
    exports.readDropPath = readDropPath;
    /**
     * Gets the duplicated path
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {string} name - specifies the name.
     * @returns {object} - returns the duplicated path.
     * @private
     */
    function getDuplicateData(parent, name) {
        var data = null;
        var records = parent.isDragDrop ? parent.dragData : parent.actionRecords;
        for (var i = 0; i < records.length; i++) {
            if (ej2_base_1.getValue('name', records[i]) === name) {
                data = records[i];
                break;
            }
        }
        return data;
    }
    exports.getDuplicateData = getDuplicateData;
    /**
     * Gets the create the virtual drag element
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function createVirtualDragElement(parent) {
        parent.isSearchDrag = false;
        if (parent.breadcrumbbarModule.searchObj.element.value !== '') {
            parent.isSearchDrag = true;
        }
        if (parent.activeModule !== 'navigationpane') {
            parent.dragNodes = [];
            var i = 0;
            while (i < parent.selectedItems.length) {
                parent.dragNodes.push(parent.selectedItems[i]);
                i++;
            }
            if (parent.selectedItems.length === 0 && parent.dragData && parent.dragData.length === 1) {
                parent.dragNodes.push(getItemName(parent, parent.dragData[0]));
            }
        }
        var cloneIcon = parent.createElement('div', {
            className: 'e-fe-icon ' + fileType(parent.dragData[0])
        });
        var cloneName = parent.createElement('div', {
            className: 'e-fe-name',
            innerHTML: parent.dragData[0].name
        });
        var virtualEle = parent.createElement('div', {
            className: 'e-fe-content'
        });
        virtualEle.appendChild(cloneIcon);
        virtualEle.appendChild(cloneName);
        var ele = parent.createElement('div', {
            className: CLS.CLONE
        });
        ele.appendChild(virtualEle);
        if (parent.dragNodes.length > 1) {
            var badge = parent.createElement('span', {
                className: 'e-fe-count',
                innerHTML: (parent.dragNodes.length).toString(10)
            });
            ele.appendChild(badge);
        }
        parent.virtualDragElement = ele;
        parent.element.appendChild(parent.virtualDragElement);
    }
    exports.createVirtualDragElement = createVirtualDragElement;
    /**
     * Drops the stop handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {DragEventArgs} args - specifies the drag event arguements.
     * @returns {void}
     * @private
     */
    function dragStopHandler(parent, args) {
        var dragArgs = args;
        dragArgs.cancel = false;
        if (parent.treeExpandTimer != null) {
            window.clearTimeout(parent.treeExpandTimer);
            parent.treeExpandTimer = null;
        }
        removeDropTarget(parent);
        parent.element.classList.remove('e-fe-drop', 'e-no-drop');
        removeBlur(parent);
        parent.uploadObj.dropArea = ej2_base_1.select('#' + parent.element.id + CLS.CONTENT_ID, parent.element);
        var virtualEle = ej2_base_1.select('.' + CLS.CLONE, parent.element);
        Eif (virtualEle) {
            ej2_base_2.detach(virtualEle);
        }
        getTargetModule(parent, args.target);
        parent.notify(events.dropInit, args);
        removeBlur(parent, 'hover');
        dragArgs.fileDetails = parent.dragData;
        parent.trigger('fileDragStop', dragArgs, function (dragArgs) {
            if (!dragArgs.cancel && !ej2_base_1.isNullOrUndefined(parent.targetModule) && parent.targetModule !== '' && parent.dragCount > 2) {
                dropHandler(parent);
            }
            parent.dragCount = 0;
        });
    }
    exports.dragStopHandler = dragStopHandler;
    /**
     * Drag the start handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {'DragEventArgs'} args - specifies the drag event arguements.
     * @param {Draggable} dragObj - specifies the drag event arguements.
     * @returns {void}
     * @private
     */
    function dragStartHandler(parent, args, dragObj) {
        var dragArgs = args;
        dragArgs.cancel = false;
        dragArgs.fileDetails = parent.dragData;
        parent.dragCount = 0;
        parent.droppedObjects = [];
        Iif (!parent.allowDragAndDrop || ((parent.activeModule === 'navigationpane') &&
            (ej2_base_2.closest(args.element, 'li').getAttribute('data-uid') === parent.pathId[0]))) {
            dragArgs.cancel = true;
        }
        if ((parent.activeModule === 'navigationpane') &&
            (parent.pathId.indexOf(ej2_base_2.closest(args.element, 'li').getAttribute('data-uid')) !== -1)) {
            parent.isPathDrag = true;
        }
        else {
            parent.isPathDrag = false;
        }
        removeBlur(parent);
        Iif (dragArgs.cancel) {
            dragObj.intDestroy(args.event);
            dragCancel(parent);
        }
        else Eif (!dragArgs.cancel) {
            var i = 0;
            while (i < parent.activeElements.length) {
                addBlur(parent.activeElements[i]);
                i++;
            }
            parent.trigger('fileDragStart', dragArgs, function (dragArgs) {
                if (dragArgs.cancel) {
                    dragObj.intDestroy(args.event);
                    dragCancel(parent);
                }
                else {
                    parent.uploadObj.dropArea = null;
                }
            });
        }
    }
    exports.dragStartHandler = dragStartHandler;
    /**
     * Drag the cancel handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function dragCancel(parent) {
        removeBlur(parent);
        var virtualEle = ej2_base_1.select('.' + CLS.CLONE, parent.element);
        Eif (virtualEle) {
            ej2_base_2.detach(virtualEle);
        }
    }
    exports.dragCancel = dragCancel;
    /**
     * Remove drop target handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function removeDropTarget(parent) {
        removeItemClass(parent, CLS.DROP_FOLDER);
        removeItemClass(parent, CLS.DROP_FILE);
    }
    exports.removeDropTarget = removeDropTarget;
    /**
     * Remove item class handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {string} value - specifies the value.
     * @returns {void}
     * @private
     */
    function removeItemClass(parent, value) {
        var ele = parent.element.querySelectorAll('.' + value);
        for (var i = 0; i < ele.length; i++) {
            ele[i].classList.remove(value);
        }
    }
    exports.removeItemClass = removeItemClass;
    /**
     * Remove item class handler
     *
     * @param {Element} scrollParent - specifies the scrolling target.
     * @param {IFileManager} parent - specifies the parent.
     * @param {string} nodeClass - specifies the node class.
     * @param {number} clientY - specifies the vertical (Y) coordinate of the mouse cursor position relative to the target element.
     * @returns {void}
     * @private
     */
    function scrollHandler(scrollParent, parent, nodeClass, clientY) {
        var position;
        var elementData = scrollParent.getBoundingClientRect();
        var node = ej2_base_1.select('.' + nodeClass, scrollParent);
        Iif ((clientY >= (elementData.top + scrollParent.clientHeight - 30)) && !ej2_base_1.isNullOrUndefined(node)) {
            position = (parent.targetModule === 'navigationpane' || parent.targetModule === 'detailsview') ? node.offsetHeight / 2.5 : node.offsetHeight / 4.5;
            scrollParent.scrollBy(0, position);
        }
        Eif (!ej2_base_1.isNullOrUndefined(node) && (clientY <= (elementData.top + 30))) {
            position = (parent.targetModule === 'navigationpane' || parent.targetModule === 'detailsview') ? node.offsetHeight / 2.5 : node.offsetHeight / 4.5;
            scrollParent.scrollBy(0, -position);
        }
    }
    exports.scrollHandler = scrollHandler;
    /**
     * Dragging handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {DragEventArgs} args - specifies the arguements.
     * @returns {void}
     * @private
     */
    function draggingHandler(parent, args) {
        var dragArgs = args;
        dragArgs.fileDetails = parent.dragData;
        var canDrop = false;
        getTargetModule(parent, args.target);
        removeDropTarget(parent);
        if (parent.treeExpandTimer != null) {
            window.clearTimeout(parent.treeExpandTimer);
            parent.treeExpandTimer = null;
        }
        removeBlur(parent, 'hover');
        var node = null;
        var scrollParent;
        if (parent.targetModule === 'navigationpane') {
            node = ej2_base_2.closest(args.target, 'li');
            node.classList.add(CLS.HOVER, CLS.DROP_FOLDER);
            canDrop = true;
            /* istanbul ignore next */
            parent.treeExpandTimer = window.setTimeout(function () { parent.notify(events.dragging, args); }, 800);
            scrollParent = parent.navigationpaneModule.treeObj.element.parentElement;
            scrollHandler(scrollParent, parent, 'e-level-2', args.event.y);
        }
        else if (parent.targetModule === 'detailsview') {
            node = ej2_base_2.closest(args.target, 'tr');
            if (node && node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
                node.classList.add(CLS.DROP_FOLDER);
            }
            else if (node && !node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
                node.classList.add(CLS.DROP_FILE);
            }
            canDrop = true;
            scrollParent = parent.detailsviewModule.gridObj.element.querySelector('.e-content');
            scrollHandler(scrollParent, parent, 'e-row', args.event.y);
        }
        else Eif (parent.targetModule === 'largeiconsview') {
            node = ej2_base_2.closest(args.target, 'li');
            if (node && node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
                node.classList.add(CLS.HOVER, CLS.DROP_FOLDER);
            }
            canDrop = true;
            scrollParent = parent.largeiconsviewModule.element.firstElementChild;
            scrollHandler(scrollParent, parent, 'e-large-icon', args.event.y);
            /* istanbul ignore next */
        }
        else if (parent.targetModule === 'breadcrumbbar') {
            canDrop = true;
        }
        parent.element.classList.remove('e-fe-drop', 'e-no-drop');
        parent.element.classList.add(canDrop ? 'e-fe-drop' : 'e-no-drop');
        parent.dragCount = parent.dragCount + 1;
        parent.trigger('fileDragging', dragArgs);
    }
    exports.draggingHandler = draggingHandler;
    /**
     * Object to string handler
     *
     * @param {Object} data - specifies the data.
     * @returns {string} returns string converted from Object.
     * @private
     */
    // Ignored the message key value in permission object
    function objectToString(data) {
        var str = '';
        var keys = Object.keys(data);
        for (var i = 0; i < keys.length; i++) {
            Eif (keys[i] !== 'message') {
                str += (i === 0 ? '' : ', ') + keys[i] + ': ' + ej2_base_1.getValue(keys[i], data);
            }
        }
        return str;
    }
    exports.objectToString = objectToString;
    /**
     * Get item name handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {Object} data - specifies the data.
     * @returns {string} returns the item name.
     * @private
     */
    function getItemName(parent, data) {
        if (parent.hasId) {
            return ej2_base_1.getValue('id', data);
        }
        return getName(parent, data);
    }
    exports.getItemName = getItemName;
    /**
     * Get item name handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {Object} data - specifies the data.
     * @returns {void}
     * @private
     */
    function updateRenamingData(parent, data) {
        parent.itemData = [data];
        parent.currentItemText = ej2_base_1.getValue('name', data);
        parent.isFile = ej2_base_1.getValue('isFile', data);
        parent.filterPath = ej2_base_1.getValue('filterPath', data);
    }
    exports.updateRenamingData = updateRenamingData;
    /**
     * Get item name handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function doRename(parent) {
        if (!hasEditAccess(parent.itemData[0])) {
            createDeniedDialog(parent, parent.itemData[0], events.permissionEdit);
        }
        else {
            dialog_1.createDialog(parent, 'Rename');
        }
    }
    exports.doRename = doRename;
    /* istanbul ignore next */
    /**
     * Download handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function doDownload(parent) {
        var items = parent.itemData;
        for (var i = 0; i < items.length; i++) {
            Eif (!hasDownloadAccess(items[i])) {
                createDeniedDialog(parent, items[i], events.permissionDownload);
                return;
            }
        }
        Iif (parent.selectedItems.length > 0) {
            operations_1.Download(parent, parent.path, parent.selectedItems);
        }
    }
    exports.doDownload = doDownload;
    /**
     * Delete Files handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {Object[]} data - specifies the data.
     * @param {string[]} newIds - specifies the new Ids.
     * @returns {void}
     * @private
     */
    function doDeleteFiles(parent, data, newIds) {
        for (var i = 0; i < data.length; i++) {
            Iif (!hasEditAccess(data[i])) {
                createDeniedDialog(parent, data[i], events.permissionEdit);
                return;
            }
        }
        parent.itemData = data;
        operations_1.Delete(parent, newIds, parent.path, 'delete');
    }
    exports.doDeleteFiles = doDeleteFiles;
    /* istanbul ignore next */
    /**
     * Download files handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {Object[]} data - specifies the data.
     * @param {string[]} newIds - specifies the new Ids.
     * @returns {void}
     * @private
     */
    function doDownloadFiles(parent, data, newIds) {
        for (var i = 0; i < data.length; i++) {
            if (!hasDownloadAccess(data[i])) {
                createDeniedDialog(parent, data[i], events.permissionDownload);
                return;
            }
        }
        parent.itemData = data;
        if (newIds.length > 0) {
            operations_1.Download(parent, parent.path, newIds);
        }
    }
    exports.doDownloadFiles = doDownloadFiles;
    /**
     * Download files handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {Object} data - specifies the data.
     * @param {string} action - specifies the actions.
     * @returns {void}
     * @private
     */
    function createDeniedDialog(parent, data, action) {
        var message = ej2_base_1.getValue('message', ej2_base_1.getValue('permission', data));
        Iif (message === '') {
            message = getLocaleText(parent, 'Access-Message').replace('{0}', ej2_base_1.getValue('name', data)).replace('{1}', action);
        }
        var response = {
            error: {
                code: '401',
                fileExists: null,
                message: message
            }
        };
        dialog_1.createDialog(parent, 'Error', response);
    }
    exports.createDeniedDialog = createDeniedDialog;
    /**
     * Get Access Classes
     *
     * @param {Object} data - specifies the data.
     * @returns {string} - returns accesses classes.
     * @private
     */
    function getAccessClass(data) {
        return !hasReadAccess(data) ? 'e-fe-locked e-fe-hidden' : 'e-fe-locked';
    }
    exports.getAccessClass = getAccessClass;
    /**
     * Check read access handler
     *
     * @param {Object} data - specifies the data.
     * @returns {boolean} - returns read access.
     * @private
     */
    function hasReadAccess(data) {
        var permission = ej2_base_1.getValue('permission', data);
        return (permission && !ej2_base_1.getValue('read', permission)) ? false : true;
    }
    exports.hasReadAccess = hasReadAccess;
    /**
     * Check edit access handler
     *
     * @param {Object} data - specifies the data.
     * @returns {boolean} - returns edit access.
     * @private
     */
    function hasEditAccess(data) {
        var permission = ej2_base_1.getValue('permission', data);
        return permission ? ((ej2_base_1.getValue('read', permission) && ej2_base_1.getValue('write', permission))) : true;
    }
    exports.hasEditAccess = hasEditAccess;
    /**
     * Check content access handler
     *
     * @param {Object} data - specifies the data.
     * @returns {boolean} - returns content access.
     * @private
     */
    function hasContentAccess(data) {
        var permission = ej2_base_1.getValue('permission', data);
        return permission ? ((ej2_base_1.getValue('read', permission) && ej2_base_1.getValue('writeContents', permission))) : true;
    }
    exports.hasContentAccess = hasContentAccess;
    /**
     * Check upload access handler
     *
     * @param {Object} data - specifies the data.
     * @returns {boolean} - returns upload access.
     * @private
     */
    function hasUploadAccess(data) {
        var permission = ej2_base_1.getValue('permission', data);
        return permission ? ((ej2_base_1.getValue('read', permission) && ej2_base_1.getValue('upload', permission))) : true;
    }
    exports.hasUploadAccess = hasUploadAccess;
    /**
     * Check download access handler
     *
     * @param {Object} data - specifies the data.
     * @returns {boolean} - returns download access.
     * @private
     */
    function hasDownloadAccess(data) {
        var permission = ej2_base_1.getValue('permission', data);
        return permission ? ((ej2_base_1.getValue('read', permission) && ej2_base_1.getValue('download', permission))) : true;
    }
    exports.hasDownloadAccess = hasDownloadAccess;
    /**
     * Create new folder handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function createNewFolder(parent) {
        var details = parent.itemData[0];
        if (!hasContentAccess(details)) {
            createDeniedDialog(parent, details, events.permissionEditContents);
        }
        else {
            dialog_1.createDialog(parent, 'NewFolder');
        }
    }
    exports.createNewFolder = createNewFolder;
    /**
     * Upload item handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function uploadItem(parent) {
        var details = parent.itemData[0];
        if (!hasUploadAccess(details)) {
            createDeniedDialog(parent, details, events.permissionUpload);
        }
        else {
            var eleId = '#' + parent.element.id + CLS.UPLOAD_ID;
            var uploadEle = document.querySelector(eleId);
            uploadEle.click();
        }
    }
    exports.uploadItem = uploadItem;
    /**
     * Close dialog popup handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @returns {void}
     * @private
     */
    function closePopup(parent) {
        Eif (!ej2_base_1.isNullOrUndefined(parent.dialogObj)) {
            parent.dialogObj.hide();
        }
    }
    exports.closePopup = closePopup;
    /**
     * Access control handler
     *
     * @param {IFileManager} parent - specifies the parent.
     * @param {Object[]} itemData - specifies the item elements.
     * @param {string} action - specifies the action.
     * @param {boolean} isPathPermision - specifies the path permission.
     * @returns {string} returns the path.
     * @private
     */
    function getAccessDetails(parent, itemData, action, isPathPermision) {
        var accessMessage = '';
        for (var i = 0; i < itemData.length; i++) {
            var permission = ej2_base_1.getValue('permission', itemData[i]);
            if (permission == null) {
                permission = undefined;
            }
            if (isPathPermision) {
                if (permission && (!ej2_base_1.getValue('read', permission) || !ej2_base_1.getValue('writeContents', permission))) {
                    accessMessage = ej2_base_1.getValue('message', ej2_base_1.getValue('permission', itemData[i]));
                    Eif (accessMessage === '') {
                        accessMessage = getLocaleText(parent, 'Access-Message').replace('{0}', ej2_base_1.getValue('name', itemData[i])).replace('{1}', 'writeContents');
                    }
                }
            }
            else {
                var copyOrMovePermission = action === 'copy' ? ej2_base_1.getValue('copy', permission) : ej2_base_1.getValue('write', permission);
                if (permission && (!ej2_base_1.getValue('read', permission) || !copyOrMovePermission)) {
                    accessMessage = ej2_base_1.getValue('message', ej2_base_1.getValue('permission', itemData[i]));
                    Eif (accessMessage === '') {
                        accessMessage = getLocaleText(parent, 'Access-Message').replace('{0}', ej2_base_1.getValue('name', itemData[i])).replace('{1}', action);
                    }
                }
            }
            if (accessMessage !== '') {
                parent.responseData = {
                    cwd: null,
                    details: null,
                    error: {
                        code: '401',
                        message: accessMessage,
                        fileExists: null
                    },
                    files: null
                };
                break;
            }
        }
        return accessMessage;
    }
    exports.getAccessDetails = getAccessDetails;
});