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K,KAAK,EAAO,GAC7B,EAAa,KAAK,KAAK,EAAQ,GAC/B,EAAS,EAAS,GACtB,GAAsB,mBAAX,EAIP,MAAM,IAAI,MAAM,oCAAsC,EAAa,2BAA6B,EAAa,sBAAwB,EAAS,yFAH9I,EAAO,EAAW,EAAY,EAKtC,CACA,SAAS,aAAa,GAClB,MAAO,CACH,EAAM,cAAgB,QAAU,SAChC,EAAM,aACN,EAER,CACA,SAAS,gBAAgB,GACrB,MAAO,CACH,EAAM,cAAgB,QAAU,SAChC,EAAM,aACN,EAER,CACA,SAAS,gBAAgB,GACrB,MAAO,CACH,SACA,EAAM,aACN,EAER,CAEA,OAAO,QAAU","file":"/npm/fs-tree-diff@2.0.1/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/fs-tree-diff@2.0.1/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __assign = (this && this.__assign) || function () {\n    __assign = Object.assign || function(t) {\n        for (var s, i = 1, n = arguments.length; i < n; i++) {\n            s = arguments[i];\n            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n                t[p] = s[p];\n        }\n        return t;\n    };\n    return __assign.apply(this, arguments);\n};\nvar fs = require(\"fs\");\nvar path = require(\"path-posix\");\nvar symlinkOrCopy = require(\"symlink-or-copy\");\nvar Logger = require(\"heimdalljs-logger\");\nvar entry_1 = require(\"./entry\");\nvar util_1 = require(\"./util\");\nvar logger = Logger('fs-tree-diff:');\nvar ARBITRARY_START_OF_TIME = 0;\nvar DEFAULT_DELEGATE = {\n    unlink: function (inputPath, outputPath, relativePath) {\n        try {\n            fs.unlinkSync(outputPath);\n        }\n        catch (e) {\n            if (typeof e === 'object' && e !== null && e.code === 'ENOENT') {\n                return;\n            }\n            throw e;\n        }\n    },\n    rmdir: function (inputPath, outputPath, relativePath) {\n        fs.rmdirSync(outputPath);\n    },\n    mkdir: function (inputPath, outputPath, relativePath) {\n        fs.mkdirSync(outputPath);\n    },\n    change: function (inputPath, outputPath, relativePath) {\n        // We no-op if the platform can symlink, because we assume the output path\n        // is already linked via a prior create operation.\n        if (symlinkOrCopy.canSymlink) {\n            return;\n        }\n        fs.unlinkSync(outputPath);\n        symlinkOrCopy.sync(inputPath, outputPath);\n    },\n    create: function (inputPath, outputPath, relativePath) {\n        symlinkOrCopy.sync(inputPath, outputPath);\n    }\n};\nvar FSTree = /** @class */ (function () {\n    function FSTree(options) {\n        if (options === void 0) { options = {}; }\n        var entries = options.entries || [];\n        if (options.sortAndExpand) {\n            util_1.sortAndExpand(entries);\n        }\n        else {\n            util_1.validateSortedUnique(entries);\n        }\n        this.entries = entries;\n    }\n    FSTree.fromPaths = function (paths, options) {\n        if (options === void 0) { options = {}; }\n        var entries = paths.map(function (path) {\n            return new entry_1.default(path, 0, ARBITRARY_START_OF_TIME);\n        });\n        return new this({\n            entries: entries,\n            sortAndExpand: options.sortAndExpand,\n        });\n    };\n    FSTree.fromEntries = function (entries, options) {\n        if (options === void 0) { options = {}; }\n        return new this({\n            entries: entries,\n            sortAndExpand: options.sortAndExpand,\n        });\n    };\n    Object.defineProperty(FSTree.prototype, \"size\", {\n        get: function () {\n            return this.entries.length;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    FSTree.prototype.addEntries = function (entries, options) {\n        if (!Array.isArray(entries)) {\n            throw new TypeError('entries must be an array');\n        }\n        if (options !== null && typeof options === 'object' && options.sortAndExpand) {\n            util_1.sortAndExpand(entries);\n        }\n        else {\n            util_1.validateSortedUnique(entries);\n        }\n        var fromIndex = 0;\n        var toIndex = 0;\n        while (fromIndex < entries.length) {\n            while (toIndex < this.entries.length &&\n                this.entries[toIndex].relativePath < entries[fromIndex].relativePath) {\n                toIndex++;\n            }\n            if (toIndex < this.entries.length &&\n                this.entries[toIndex].relativePath === entries[fromIndex].relativePath) {\n                this.entries.splice(toIndex, 1, entries[fromIndex++]);\n            }\n            else {\n                this.entries.splice(toIndex++, 0, entries[fromIndex++]);\n            }\n        }\n    };\n    FSTree.prototype.addPaths = function (paths, options) {\n        var entries = paths.map(function (path) {\n            // TODO:\n            // addPths + a custom isEqual comparator + custom Entry types are actually incompatible\n            // As a addPaths will not abide by the custom Entry type\n            // and will make this.entries be contain a mixture of types.\n            // isEqual's arguments will then be typed incorrectly\n            //\n            // We should likely just deprecate `addPaths` in-favor of addEntries,\n            // which correctly externalizes the creation of entry\n            return new entry_1.default(path, 0, ARBITRARY_START_OF_TIME);\n        });\n        this.addEntries(entries, options);\n    };\n    FSTree.prototype.forEach = function (fn, context) {\n        this.entries.forEach(fn, context);\n    };\n    FSTree.prototype.calculatePatch = function (theirFSTree, isEqual) {\n        if (arguments.length > 1 && typeof isEqual !== 'function') {\n            throw new TypeError('calculatePatch\\'s second argument must be a function');\n        }\n        // TODO: the TS here is strange\n        if (typeof isEqual !== 'function') {\n            isEqual = this.constructor.defaultIsEqual;\n        }\n        var ours = this.entries;\n        var theirs = theirFSTree.entries;\n        var additions = [];\n        var removals = [];\n        var i = 0;\n        var j = 0;\n        var command;\n        while (i < ours.length && j < theirs.length) {\n            var x = ours[i];\n            var y = theirs[j];\n            if (x.relativePath < y.relativePath) {\n                // ours\n                i++;\n                removals.push(removeOperation(x));\n                // remove additions\n            }\n            else if (x.relativePath > y.relativePath) {\n                // theirs\n                j++;\n                additions.push(addOperation(y));\n            }\n            else {\n                if (!isEqual(x, y)) {\n                    command = updateOperation(y);\n                    if (x.isDirectory()) {\n                        removals.push(command);\n                    }\n                    else {\n                        additions.push(command);\n                    }\n                }\n                // both are the same\n                i++;\n                j++;\n            }\n        }\n        // cleanup ours\n        for (; i < ours.length; i++) {\n            removals.push(removeOperation(ours[i]));\n        }\n        // cleanup theirs\n        for (; j < theirs.length; j++) {\n            additions.push(addOperation(theirs[j]));\n        }\n        return removals.reverse().concat(additions);\n    };\n    FSTree.prototype.calculateAndApplyPatch = function (otherFSTree, input, output, delegate) {\n        this.constructor.applyPatch(input, output, this.calculatePatch(otherFSTree), delegate);\n    };\n    FSTree.defaultIsEqual = function (entryA, entryB) {\n        if (entryA.isDirectory() && entryB.isDirectory()) {\n            // ignore directory changes by default\n            return true;\n        }\n        var equal;\n        if (entryA.size === entryB.size && entryA.mode === entryB.mode) {\n            if (entryA.mtime === entryB.mtime) {\n                equal = true;\n            }\n            else if (entryA.mtime === undefined || entryB.mtime === undefined) {\n                equal = false;\n            }\n            else if (+entryA.mtime === +entryB.mtime) {\n                equal = true;\n            }\n            else {\n                equal = false;\n            }\n        }\n        else {\n            equal = false;\n        }\n        if (equal === false) {\n            logger.info('invalidation reason: \\nbefore %o\\n entryB %o', entryA, entryB);\n        }\n        return equal;\n    };\n    FSTree.applyPatch = function (input, output, patch, _delegate) {\n        var delegate = __assign({}, DEFAULT_DELEGATE, _delegate);\n        for (var i = 0; i < patch.length; i++) {\n            applyOperation(input, output, patch[i], delegate);\n        }\n    };\n    return FSTree;\n}());\nfunction applyOperation(input, output, operation, delegate) {\n    var methodName = operation[0];\n    var relativePath = operation[1];\n    var inputPath = path.join(input, relativePath);\n    var outputPath = path.join(output, relativePath);\n    var method = delegate[methodName];\n    if (typeof method === 'function') {\n        method(inputPath, outputPath, relativePath);\n    }\n    else {\n        throw new Error('Unable to apply patch operation: ' + methodName + '. The value of delegate.' + methodName + ' is of type ' + typeof method + ', and not a function. Check the `delegate` argument to `FSTree.prototype.applyPatch`.');\n    }\n}\nfunction addOperation(entry) {\n    return [\n        entry.isDirectory() ? 'mkdir' : 'create',\n        entry.relativePath,\n        entry\n    ];\n}\nfunction removeOperation(entry) {\n    return [\n        entry.isDirectory() ? 'rmdir' : 'unlink',\n        entry.relativePath,\n        entry\n    ];\n}\nfunction updateOperation(entry) {\n    return [\n        'change',\n        entry.relativePath,\n        entry\n    ];\n}\n;\nmodule.exports = FSTree;\n"]}