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oB,KAAK,aAC/C,KAAK,aAAe,IAAI,SAAS,QAAQ,CACrC,SAAU,YACV,KAAM,KAAK,WACX,OAAO,EACP,KAAM,CACF,SAAU,KAAK,eACf,SAAU,KAAK,eACf,IAAK,KAAK,KAEd,SAAU,QACV,UAAW,CACP,SAAU,IACV,MAAO,IACP,IAAK,MAET,uBAAwB,QAAQ,wBAE9B,KAAK,aAAa,cAClB,KAAK,kBAAkB,CACzB,KAAM,KAAK,eACX,SAAU,KAAK,eACf,SAAU,KAAK,uBAEb,KAAK,qBACC,KAAK,wBACb,MAAM,IAAI,MAAM,+CAEpB,KAAK,QAAS,CAClB,CACA,MAAO,GAGH,MAFA,KAAK,OAAO,IAAI,QAAS,EAAG,SAC5B,KAAK,OAAO,IAAI,QAAS,GACnB,CACV,CACA,QACI,KAAK,WAAW,SACpB,CACJ,CAQA,UAAM,GACF,IAAI,EAAI,QACF,KAAK,UAAU,UACrB,UACU,KAAK,sBACgB,KAAK,mBACkB,QAA5B,EAAK,KAAK,oBAAiC,IAAP,OAAgB,EAAS,EAAG,uBAC9C,QAA5B,EAAK,KAAK,oBAAiC,IAAP,OAAgB,EAAS,EAAG,MAAK,IAEjF,KAAK,aAAe,KACpB,KAAK,cAAgB,KACrB,KAAK,QAAS,CAClB,CACA,MAAO,GAGH,MAFA,KAAK,OAAO,IAAI,QAAS,EAAG,QAC5B,KAAK,OAAO,IAAI,QAAS,GACnB,CACV,CACA,QACI,KAAK,UAAU,SACnB,CACJ,EAEJ,QAAQ,aAAe,aACvB,aAAa,QAAQ,WAAY,SACjC,QAAQ,QAAU","file":"/npm/@filen/network-drive@0.9.44/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@filen/network-drive@0.9.44/dist/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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    var desc = Object.getOwnPropertyDescriptor(m, k);\n    if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n      desc = { enumerable: true, get: function() { return m[k]; } };\n    }\n    Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n    for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.NetworkDrive = exports.excludePatterns = exports.BINARY_HASHES = exports.WINFSP_URL = exports.FUSE_T_URL = exports.RCLONE_URL = exports.WINFSP_BINARY_NAME = exports.FUSE_T_BINARY_NAME = exports.RCLONE_BINARY_NAME = exports.WINFSP_VERSION = exports.FUSE_T_VERSION_NUMBER = exports.FUSE_T_VERSION = exports.RCLONE_VERSION = void 0;\nconst sdk_1 = __importDefault(require(\"@filen/sdk\"));\nconst semaphore_1 = require(\"./semaphore\");\nconst webdav_1 = __importDefault(require(\"@filen/webdav\"));\nconst child_process_1 = require(\"child_process\");\nconst utils_1 = require(\"./utils\");\nconst path_1 = __importDefault(require(\"path\"));\nconst fs_extra_1 = __importDefault(require(\"fs-extra\"));\nconst ports_1 = require(\"./ports\");\nconst write_file_atomic_1 = __importDefault(require(\"write-file-atomic\"));\nconst axios_1 = __importDefault(require(\"axios\"));\nconst monitor_1 = require(\"./monitor\");\nconst logger_1 = __importDefault(require(\"./logger\"));\nconst sudo_prompt_1 = __importDefault(require(\"@vscode/sudo-prompt\"));\nconst os_1 = __importDefault(require(\"os\"));\nexports.RCLONE_VERSION = \"1680\";\nexports.FUSE_T_VERSION = \"1044\";\nexports.FUSE_T_VERSION_NUMBER = 1000044;\nexports.WINFSP_VERSION = \"2124255\";\nexports.RCLONE_BINARY_NAME = `filen_rclone_${process.platform}_${process.arch}_${exports.RCLONE_VERSION}${process.platform === \"win32\" ? \".exe\" : \"\"}`;\nexports.FUSE_T_BINARY_NAME = `fuse_t_${exports.FUSE_T_VERSION}.pkg`;\nexports.WINFSP_BINARY_NAME = `winfsp_${exports.WINFSP_VERSION}.msi`;\nexports.RCLONE_URL = `https://cdn.filen.io/@filen/desktop/bin/rclone/${exports.RCLONE_BINARY_NAME}`;\nexports.FUSE_T_URL = `https://cdn.filen.io/@filen/desktop/bin/fuse-t/${exports.FUSE_T_BINARY_NAME}`;\nexports.WINFSP_URL = `https://cdn.filen.io/@filen/desktop/bin/winfsp/${exports.WINFSP_BINARY_NAME}`;\nexports.BINARY_HASHES = {\n    filen_rclone_darwin_arm64_1680: \"9a92a9ce8addf55cd5a25c7a6ec2d1ac05d24cb1c68afa49f926db837a251944be03920e2c124d35da31e9abe93c690cc4019d716f732aa3396ab16ab9194cf4\",\n    filen_rclone_darwin_x64_1680: \"ace3ec98ea8625e87f8097a246ce937732acf22766174a53515066138e5c0d55e25e85a99bc8b2b622648f58650ee918b4606724111082c258f093e77d905c35\",\n    filen_rclone_linux_arm64_1680: \"527dd1d983f3f3d6530eb3d820a36bdcb1908c67c37be73a33669a5a6481fb0bd64155816ab437420c26dbb147ac9a0688e3704c3550f5ef80704483bd382e4d\",\n    filen_rclone_linux_ia32_1680: \"b017e5cf3c7fc5ab06936c4e923dd281fbb2332f856c07e2e5ebc0e4fb1ad7c94f62a0baf6824c09cba30f90c678b1374681177b6d49b7ae2ffd9b80d7198991\",\n    filen_rclone_linux_x64_1680: \"5d20f5562609695b565d696980bbee91ec0503ed946410eb2e6024a8b6850ebd5b587d5c71488f471012ea39e6bf440d843840165e8ac75cd0ec737defa2a749\",\n    \"filen_rclone_win32_arm64_1680.exe\": \"40e33bd06be605727e24bcfcb5beb95463b1962e61f9b37518f5407fa7f3c576f492a8737d1f6c15b41715194a0cc4c4f904146b524af2c1d4d42c19278f2057\",\n    \"filen_rclone_win32_ia32_1680.exe\": \"2338009b0244a7f6573f4cc9cc01b49a3073cae566c2e26a82688fac6aaf36f67a27ee7524e8e3e65f28954c8ae927ff1710f77c07b2c356f0d6c49e72adabe6\",\n    \"filen_rclone_win32_x64_1680.exe\": \"55ece9582bbbc4339494d3d0611b30187bd5e49f7b593c7baa46a156256055273c5c7751124b90c9e66b990effeaf9ac0a6155ecd777dd9791b848a4f7c3c287\",\n    \"fuse_t_1044.pkg\": \"8304c63661b5bd1c35cd2dc506429defab2608799a5da146443f18c8a6462f8f5e741f44334fe8abc6ff0ec92018b3ef8dbaab579fbd1e074b38db2fb4cb7b98\",\n    \"winfsp_2124255.msi\": \"1ca6facd9d1702e52795bbb7933ee0070be800a2cff1261976714cf901edc4845858b98ae9be934da0125fc20b5c1a57a17d6fd50330e168688f32d8ad6304fb\"\n};\nexports.excludePatterns = [\n    // macOS\n    \".DS_Store\",\n    \"._.DS_Store\",\n    \"*.DS_Store*\",\n    \"*.nfs.*\",\n    \"._*\",\n    \"*._*\",\n    \".Trashes/**\",\n    \".Spotlight-V100/**\",\n    \".TemporaryItems/**\",\n    // Windows\n    \"*.tmp\",\n    \"~*\",\n    \"Thumbs.db\",\n    \"desktop.ini\",\n    // Linux\n    \".Trash*\",\n    \"*.swp\",\n    \"*.temp\",\n    \".*.swx\"\n];\n/**\n * Description placeholder\n *\n * @export\n * @class NetworkDrive\n * @typedef {NetworkDrive}\n */\nclass NetworkDrive {\n    /**\n     * Creates an instance of NetworkDrive.\n     *\n     * @constructor\n     * @public\n     * @param {{\n     * \t\tsdk?: FilenSDK\n     * \t\tsdkConfig?: FilenSDKConfig\n     * \t\tmountPoint: string\n     * \t\tlogFilePath?: string\n     * \t\treadOnly?: boolean\n     * \t\tdisableLogging?: boolean,\n     * \t\ttryToInstallDependenciesOnStart?: boolean\n     * \t}} param0\n     * @param {FilenSDK} param0.sdk\n     * @param {FilenSDKConfig} param0.sdkConfig\n     * @param {string} param0.mountPoint\n     * @param {string} param0.logFilePath\n     * @param {boolean} [param0.readOnly=false]\n     * @param {boolean} [param0.disableLogging=false]\n     * @param {boolean} [param0.tryToInstallDependenciesOnStart=false]\n     */\n    constructor({ sdk, sdkConfig, mountPoint, logFilePath, readOnly = false, disableLogging = false, tryToInstallDependenciesOnStart = false, cachePath }) {\n        this.webdavServer = null;\n        this.rcloneProcess = null;\n        this.monitorProcess = null;\n        this.webdavUsername = \"admin\";\n        this.webdavPassword = \"admin\";\n        this.webdavPort = 1905;\n        this.webdavEndpoint = \"http://127.0.0.1:1905\";\n        this.active = false;\n        this.rcloneBinaryPath = null;\n        this.rcloneConfigPath = null;\n        this.configPath = null;\n        this.startMutex = new semaphore_1.Semaphore(1);\n        this.stopMutex = new semaphore_1.Semaphore(1);\n        this.getRCloneBinaryMutex = new semaphore_1.Semaphore(1);\n        this.rclonePort = 1906;\n        this.monitorScriptPath = null;\n        if (!sdk && !sdkConfig) {\n            throw new Error(\"Either pass a configured SDK instance OR a SDKConfig object to the constructor.\");\n        }\n        this.sdk = sdk\n            ? sdk\n            : new sdk_1.default(Object.assign(Object.assign({}, sdkConfig), { connectToSocket: true, metadataCache: true }));\n        this.mountPoint = mountPoint;\n        this.logFilePath = logFilePath;\n        this.readOnly = readOnly;\n        this.cachePath = cachePath;\n        this.tryToInstallDependenciesOnStart = tryToInstallDependenciesOnStart;\n        this.logger = new logger_1.default(disableLogging, false);\n        // Start downloading the binary in the background\n        this.getRCloneBinaryPath().catch(() => { });\n        // Start montioring the mount in the background\n        this.monitor().catch(() => { });\n    }\n    /**\n     * Monitor the network drive in the background.\n     * If the underlying WebDAV server or the drive itself becomes unavailable, cleanup.\n     *\n     * @private\n     * @async\n     * @returns {Promise<void>}\n     */\n    async monitor() {\n        try {\n            if (!this.active) {\n                return;\n            }\n            if (!(await this.isMountActuallyActive())) {\n                await this.stop();\n            }\n        }\n        catch (e) {\n            this.logger.log(\"error\", e, \"monitor\");\n            this.logger.log(\"error\", e);\n        }\n        finally {\n            await new Promise(resolve => setTimeout(resolve, 15000));\n            this.monitor();\n        }\n    }\n    /**\n     * Get the platform config path.\n     *\n     * @private\n     * @async\n     * @returns {Promise<string>}\n     */\n    async getConfigPath() {\n        if (!this.configPath) {\n            this.configPath = await (0, utils_1.platformConfigPath)();\n        }\n        return this.configPath;\n    }\n    /**\n     * Get the monitor script path.\n     *\n     * @private\n     * @async\n     * @returns {Promise<string>}\n     */\n    async getMonitorScriptPath() {\n        if (!this.monitorScriptPath) {\n            this.monitorScriptPath = await (0, monitor_1.writeMonitorScriptAndReturnPath)();\n        }\n        return this.monitorScriptPath;\n    }\n    /**\n     * Get the VFS cache path.\n     *\n     * @private\n     * @async\n     * @returns {Promise<string>}\n     */\n    async getCachePath() {\n        if (!this.cachePath) {\n            this.cachePath = path_1.default.join(await this.getConfigPath(), \"cache\");\n        }\n        return this.cachePath;\n    }\n    /**\n     * Get the RClone config path.\n     *\n     * @private\n     * @async\n     * @returns {Promise<string>}\n     */\n    async getRCloneConfigPath() {\n        if (!this.rcloneConfigPath) {\n            this.rcloneConfigPath = path_1.default.join(await this.getConfigPath(), \"rclone.conf\");\n        }\n        return this.rcloneConfigPath;\n    }\n    /**\n     * Install WinFSP if it's not installed yet.\n     *\n     * @private\n     * @async\n     * @returns {Promise<void>}\n     */\n    async installWinFSPWindows() {\n        if (!this.tryToInstallDependenciesOnStart || process.platform !== \"win32\" || (await (0, utils_1.isWinFSPInstalled)())) {\n            return;\n        }\n        if (!exports.BINARY_HASHES[exports.WINFSP_BINARY_NAME]) {\n            throw new Error(\"WinFSP binary hash not found.\");\n        }\n        const tempPath = path_1.default.join(os_1.default.tmpdir(), exports.WINFSP_BINARY_NAME);\n        await (0, utils_1.downloadBinaryAndVerifySHA512)(exports.WINFSP_URL, tempPath, exports.BINARY_HASHES[exports.WINFSP_BINARY_NAME]);\n        try {\n            await new Promise((resolve, reject) => {\n                (0, child_process_1.exec)(`powershell -Command \"Start-Process msiexec -ArgumentList '/i ${tempPath} /qn' -Verb runAs -Wait\"`, err => {\n                    if (err) {\n                        reject(err);\n                        return;\n                    }\n                    resolve();\n                });\n            });\n        }\n        finally {\n            await fs_extra_1.default.rm(tempPath, {\n                force: true,\n                maxRetries: 60 * 10,\n                recursive: true,\n                retryDelay: 100\n            });\n        }\n    }\n    /**\n     * Download FUSE-T if it's not installed yet.\n     *\n     * @private\n     * @async\n     * @returns {Promise<void>}\n     */\n    async installFuseTMacOS() {\n        if (!this.tryToInstallDependenciesOnStart || process.platform !== \"darwin\" || (await (0, utils_1.isFUSETInstalledOnMacOS)())) {\n            return;\n        }\n        if (!exports.BINARY_HASHES[exports.FUSE_T_BINARY_NAME]) {\n            throw new Error(\"FUSE-T binary hash not found.\");\n        }\n        const tempPath = path_1.default.join(os_1.default.tmpdir(), exports.FUSE_T_BINARY_NAME);\n        await (0, utils_1.downloadBinaryAndVerifySHA512)(exports.FUSE_T_URL, tempPath, exports.BINARY_HASHES[exports.FUSE_T_BINARY_NAME]);\n        try {\n            await new Promise((resolve, reject) => {\n                sudo_prompt_1.default.exec(`osascript -e 'do shell script \"/usr/sbin/installer -pkg ${tempPath} -target /\" with administrator privileges'`, {\n                    name: \"Filen\"\n                }, (err, stdout, stderr) => {\n                    if (err) {\n                        reject(err);\n                        return;\n                    }\n                    if ((stderr instanceof Buffer && stderr.toString(\"utf-8\").toLowerCase().includes(\"the install was successful\")) ||\n                        (stdout instanceof Buffer && stdout.toString(\"utf-8\").toLowerCase().includes(\"the install was successful\")) ||\n                        (stderr instanceof Buffer && stderr.toString(\"utf-8\").toLowerCase().includes(\"the upgrade was successful\")) ||\n                        (stdout instanceof Buffer && stdout.toString(\"utf-8\").toLowerCase().includes(\"the upgrade was successful\")) ||\n                        (typeof stderr === \"string\" && stderr.toLowerCase().includes(\"the install was successful\")) ||\n                        (typeof stdout === \"string\" && stdout.toLowerCase().includes(\"the install was successful\")) ||\n                        (typeof stderr === \"string\" && stderr.toLowerCase().includes(\"the upgrade was successful\")) ||\n                        (typeof stdout === \"string\" && stdout.toLowerCase().includes(\"the upgrade was successful\"))) {\n                        resolve();\n                        return;\n                    }\n                    reject(new Error(\"Could not install fuse-t.\"));\n                });\n            });\n        }\n        finally {\n            await fs_extra_1.default.rm(tempPath, {\n                force: true,\n                maxRetries: 60 * 10,\n                recursive: true,\n                retryDelay: 100\n            });\n        }\n    }\n    /**\n     * Add Filen as a host entry for localhost. Used for macOS fuse-t.\n     *\n     * @private\n     * @async\n     * @returns {Promise<void>}\n     */\n    async addHostsEntry() {\n        if (process.platform !== \"darwin\") {\n            return;\n        }\n        try {\n            if (process.platform === \"darwin\") {\n                const hosts = await fs_extra_1.default.readFile(\"/etc/hosts\", \"utf-8\");\n                const hostLines = hosts.split(\"\\n\");\n                const foundHostEntry = hostLines.some(line => {\n                    line = line.trim().split(\" \").join(\"\");\n                    return line.includes(\"127.0.0.1\") && line.includes(\"Filen\") && !line.includes(\"#\");\n                });\n                if (!foundHostEntry) {\n                    await new Promise((resolve, reject) => {\n                        sudo_prompt_1.default.exec(\n                        // eslint-disable-next-line quotes\n                        `sh -c 'echo \"127.0.0.1 Filen\" >> /etc/hosts'`, {\n                            name: \"Filen\"\n                        }, err => {\n                            if (err) {\n                                reject(err);\n                                return;\n                            }\n                            resolve();\n                        });\n                    });\n                }\n            }\n        }\n        catch (_a) {\n            // Noop\n        }\n    }\n    /**\n     * Get the RClone binary path.\n     * Downloads the binary from our CDN if it does not exist.\n     *\n     * @private\n     * @async\n     * @returns {Promise<string>}\n     */\n    async getRCloneBinaryPath() {\n        if (!this.rcloneBinaryPath) {\n            await this.getRCloneBinaryMutex.acquire();\n            try {\n                const configPath = await this.getConfigPath();\n                const binaryPath = path_1.default.join(configPath, exports.RCLONE_BINARY_NAME);\n                if (!(await fs_extra_1.default.exists(binaryPath))) {\n                    if (!exports.BINARY_HASHES[exports.RCLONE_BINARY_NAME]) {\n                        throw new Error(`Hash for binary name ${exports.RCLONE_BINARY_NAME} not found in hardcoded record.`);\n                    }\n                    await (0, utils_1.downloadBinaryAndVerifySHA512)(exports.RCLONE_URL, binaryPath, exports.BINARY_HASHES[exports.RCLONE_BINARY_NAME]);\n                    if (process.platform !== \"win32\") {\n                        await (0, utils_1.execCommand)(`chmod +x ${(0, utils_1.normalizePathForCmd)(binaryPath)}`);\n                    }\n                }\n                this.rcloneBinaryPath = binaryPath;\n            }\n            catch (e) {\n                this.logger.log(\"error\", e, \"getRCloneBinaryPath\");\n                this.logger.log(\"error\", e);\n                throw e;\n            }\n            finally {\n                this.getRCloneBinaryMutex.release();\n            }\n        }\n        return this.rcloneBinaryPath;\n    }\n    /**\n     * Check if the underyling WebDAV server is online.\n     *\n     * @private\n     * @async\n     * @returns {Promise<boolean>}\n     */\n    async isWebDAVOnline() {\n        return await (0, utils_1.httpHealthCheck)({\n            url: `http://127.0.0.1:${this.webdavPort}`,\n            method: \"GET\",\n            expectedStatusCode: 401\n        });\n    }\n    /**\n     * List all active VFSes from rclone.\n     *\n     * @public\n     * @async\n     * @returns {Promise<string[]>}\n     */\n    async vfsList() {\n        try {\n            const response = await axios_1.default.post(`http://127.0.0.1:${this.rclonePort}/vfs/list`, {}, {\n                responseType: \"json\",\n                timeout: 5000\n            });\n            const vfsList = response.data;\n            return vfsList.vfses;\n        }\n        catch (_a) {\n            return [];\n        }\n    }\n    /**\n     * Get RClone stats.\n     *\n     * @public\n     * @async\n     * @returns {Promise<GetStats>}\n     */\n    async getStats() {\n        if (!this.active) {\n            return {\n                uploadsInProgress: 0,\n                uploadsQueued: 0,\n                erroredFiles: 0,\n                transfers: []\n            };\n        }\n        try {\n            const [coreResponse, vfsResponse] = await Promise.all([\n                axios_1.default.post(`http://127.0.0.1:${this.rclonePort}/core/stats`, {}, {\n                    responseType: \"json\",\n                    timeout: 5000\n                }),\n                axios_1.default.post(`http://127.0.0.1:${this.rclonePort}/vfs/stats`, {}, {\n                    responseType: \"json\",\n                    timeout: 5000\n                })\n            ]);\n            const coreData = coreResponse.data;\n            const vfsData = vfsResponse.data;\n            if (!vfsData.diskCache ||\n                typeof vfsData.diskCache.erroredFiles !== \"number\" ||\n                typeof vfsData.diskCache.uploadsInProgress !== \"number\" ||\n                typeof vfsData.diskCache.uploadsQueued !== \"number\") {\n                return {\n                    uploadsInProgress: 0,\n                    uploadsQueued: 0,\n                    erroredFiles: 0,\n                    transfers: !coreData.transferring || !Array.isArray(coreData.transferring) ? [] : coreData.transferring\n                };\n            }\n            return {\n                uploadsInProgress: vfsData.diskCache.uploadsInProgress,\n                uploadsQueued: vfsData.diskCache.uploadsQueued,\n                erroredFiles: vfsData.diskCache.erroredFiles,\n                transfers: !coreData.transferring || !Array.isArray(coreData.transferring)\n                    ? []\n                    : coreData.transferring.map(transfer => ({\n                        name: typeof transfer.name === \"string\" ? transfer.name : \"\",\n                        size: typeof transfer.size === \"number\" ? transfer.size : 0,\n                        speed: typeof transfer.speed === \"number\" ? transfer.speed : 0\n                    }))\n            };\n        }\n        catch (_a) {\n            return {\n                uploadsInProgress: 0,\n                uploadsQueued: 0,\n                erroredFiles: 0,\n                transfers: []\n            };\n        }\n    }\n    /**\n     * Check if the mount and the underyling WebDAV server is actually online and accessible.\n     *\n     * @private\n     * @async\n     * @returns {Promise<boolean>}\n     */\n    async isMountActuallyActive() {\n        if (!this.rcloneProcess) {\n            return false;\n        }\n        try {\n            const [mountExists, vfsList, webdavOnline] = await Promise.all([\n                (0, utils_1.checkIfMountExists)(this.mountPoint),\n                this.vfsList(),\n                this.isWebDAVOnline()\n            ]);\n            if (!mountExists || !webdavOnline) {\n                return false;\n            }\n            return vfsList.includes(\"Filen:\");\n        }\n        catch (e) {\n            this.logger.log(\"error\", e, \"isMountActuallyActive\");\n            this.logger.log(\"error\", e);\n            return false;\n        }\n    }\n    /**\n     * Obscure the random WebDAV passwort to the RClone format.\n     *\n     * @private\n     * @async\n     * @param {string} password\n     * @returns {Promise<string>}\n     */\n    async obscureRClonePassword(password) {\n        const binaryPath = await this.getRCloneBinaryPath();\n        return await (0, utils_1.execCommand)(`${(0, utils_1.normalizePathForCmd)(binaryPath)} obscure ${password}`);\n    }\n    /**\n     * Write the RClone config locally.\n     *\n     * @private\n     * @async\n     * @param {{ endpoint: string; user: string; password: string }} param0\n     * @param {string} param0.endpoint\n     * @param {string} param0.user\n     * @param {string} param0.password\n     * @returns {Promise<void>}\n     */\n    async writeRCloneConfig({ endpoint, user, password }) {\n        const [obscuredPassword, configPath] = await Promise.all([this.obscureRClonePassword(password), this.getRCloneConfigPath()]);\n        const content = `[Filen]\\ntype = webdav\\nurl = ${endpoint}\\nvendor = other\\nuser = ${user}\\npass = ${obscuredPassword}`;\n        await (0, write_file_atomic_1.default)(configPath, content, \"utf-8\");\n    }\n    /**\n     * Generate the \"rclone mount\" arguments.\n     *\n     * @private\n     * @async\n     * @param {{\n     * \t\tcachePath: string\n     * \t\tconfigPath: string\n     * \t}} param0\n     * @param {string} param0.cachePath\n     * @param {string} param0.configPath\n     * @returns {Promise<string[]>}\n     */\n    async rcloneArgs({ cachePath, configPath }) {\n        const [availableCacheSize, macFUSEInstalled] = await Promise.all([(0, utils_1.getAvailableCacheSize)(cachePath), (0, utils_1.isMacFUSEInstalled)()]);\n        const osDiskBufferGib = 5;\n        const availableCacheSizeGib = Math.floor(availableCacheSize / (1024 * 1024 * 1024)) - osDiskBufferGib;\n        const cacheSize = availableCacheSizeGib > 0 ? availableCacheSizeGib : osDiskBufferGib;\n        return [\n            `mount Filen: \"${this.mountPoint}\"`,\n            `--config \"${configPath}\"`,\n            \"--vfs-cache-mode full\",\n            ...(this.readOnly ? [\"--read-only\"] : []),\n            `--cache-dir \"${cachePath}\"`,\n            `--vfs-cache-max-size \"${cacheSize}Gi\"`,\n            \"--vfs-cache-min-free-space 5Gi\",\n            \"--vfs-cache-max-age 720h\",\n            \"--vfs-cache-poll-interval 1m\",\n            \"--dir-cache-time 3s\",\n            \"--cache-info-age 5s\",\n            //\"--noappledouble\",\n            //\"--noapplexattr\",\n            \"--no-gzip-encoding\",\n            \"--use-mmap\",\n            //\"--allow-other\",\n            \"--disable-http2\",\n            \"--file-perms 0666\",\n            \"--dir-perms 0777\",\n            \"--use-server-modtime\",\n            \"--vfs-read-chunk-size 128Mi\",\n            \"--buffer-size 0\",\n            \"--vfs-read-ahead 1024Mi\",\n            \"--vfs-read-chunk-size-limit 0\",\n            \"--no-checksum\",\n            \"--transfers 16\",\n            \"--vfs-fast-fingerprint\",\n            \"--rc\",\n            `--rc-addr \"127.0.0.1:${this.rclonePort}\"`,\n            ...(this.logFilePath ? [`--log-file \"${this.logFilePath}\"`] : []),\n            \"--devname Filen\",\n            ...(process.platform === \"win32\" ? [\"--volname \\\\\\\\Filen\\\\Filen\"] : [\"--volname Filen\"]),\n            ...(process.platform === \"win32\"\n                ? // eslint-disable-next-line quotes\n                    ['-o FileSecurity=\"D:P(A;;FA;;;WD)\"', \"--network-mode\"]\n                : []),\n            // Only for FUSE-T\n            ...(process.platform === \"darwin\"\n                ? macFUSEInstalled\n                    ? [\"-o jail_symlinks\"]\n                    : [\"-o nomtime\", \"-o backend=nfs\", \"-o location=Filen\", \"-o nonamedattr\"]\n                : [])\n        ];\n    }\n    /**\n     * Spawn the RClone process.\n     *\n     * @private\n     * @async\n     * @returns {Promise<void>}\n     */\n    async spawnRClone() {\n        const [binaryPath, configPath, cachePath, monitorScriptPath] = await Promise.all([\n            this.getRCloneBinaryPath(),\n            this.getRCloneConfigPath(),\n            this.getCachePath(),\n            this.getMonitorScriptPath()\n        ]);\n        if (!(await fs_extra_1.default.exists(binaryPath))) {\n            throw new Error(`Network drive binary not found at ${binaryPath}.`);\n        }\n        if (!(await fs_extra_1.default.exists(configPath))) {\n            throw new Error(`Network drive config not found at ${configPath}.`);\n        }\n        await fs_extra_1.default.rm(cachePath, {\n            force: true,\n            maxRetries: 60 * 10,\n            recursive: true,\n            retryDelay: 100\n        });\n        await fs_extra_1.default.ensureDir(cachePath);\n        if (this.logFilePath) {\n            if (await fs_extra_1.default.exists(this.logFilePath)) {\n                const logStats = await fs_extra_1.default.stat(this.logFilePath);\n                if (logStats.size > 1024 * 1024 * 10) {\n                    await fs_extra_1.default.unlink(this.logFilePath);\n                }\n            }\n        }\n        // The monitor process is a pretty dirty workaround to a specific problem.\n        // When spawning a child process in an Electron environment the child process does not get killed when the parent process (Electron) exits (nobody knows why).\n        // This means the spawned rclone process keeps chugging along while the actual desktop client is already closed -> bad.\n        // This is why we start a secondary \"monitor\" process. This monitor process continuously checks if the parent PID (electron) is still alive.\n        // If not, it tries to kill the rclone process, unmount the mountpoints and then exits itself.\n        // This makes sure we clean up all of our processes, even if the parent electron process dies and cannot properly clean up on its own.\n        await new Promise((resolve, reject) => {\n            if (this.monitorProcess) {\n                resolve();\n                return;\n            }\n            let errored = false;\n            this.monitorProcess = (0, child_process_1.spawn)(process.platform === \"win32\" ? (0, utils_1.normalizePathForCmd)(monitorScriptPath) : \"sh\", process.platform === \"win32\"\n                ? [process.pid.toString(), exports.RCLONE_BINARY_NAME]\n                : [(0, utils_1.normalizePathForCmd)(monitorScriptPath), process.pid.toString(), exports.RCLONE_BINARY_NAME, `\"${this.mountPoint}\"`], {\n                detached: false,\n                shell: process.platform === \"win32\" ? \"cmd.exe\" : \"/bin/sh\",\n                stdio: \"ignore\"\n            });\n            this.monitorProcess.unref();\n            this.monitorProcess.on(\"error\", err => {\n                errored = true;\n                this.monitorProcess = null;\n                reject(err);\n            });\n            this.monitorProcess.on(\"exit\", () => {\n                errored = true;\n                this.monitorProcess = null;\n                reject(new Error(\"Could not spawn monitor process (exit).\"));\n            });\n            this.monitorProcess.on(\"spawn\", () => {\n                setTimeout(() => {\n                    if (errored) {\n                        reject(new Error(\"Could not spawn monitor process (spawn).\"));\n                        return;\n                    }\n                    resolve();\n                }, 1000);\n            });\n        });\n        const rcPort = await (0, ports_1.findFreePort)();\n        if (!rcPort) {\n            throw new Error(\"Could not find a free port for RC.\");\n        }\n        this.rclonePort = rcPort;\n        const args = await this.rcloneArgs({\n            cachePath,\n            configPath\n        });\n        const binaryPathNormalized = (0, utils_1.normalizePathForCmd)(binaryPath);\n        this.logger.log(\"info\", `Rclone args: '${binaryPathNormalized} ${args.join(\" \")}'`);\n        await new Promise((resolve, reject) => {\n            let checkInterval = undefined;\n            let checkTimeout = undefined;\n            checkInterval = setInterval(async () => {\n                try {\n                    if (await this.isMountActuallyActive()) {\n                        clearInterval(checkInterval);\n                        clearTimeout(checkTimeout);\n                        resolve();\n                    }\n                }\n                catch (_a) {\n                    // Noop\n                }\n            }, 1000);\n            checkTimeout = setTimeout(async () => {\n                clearInterval(checkInterval);\n                clearTimeout(checkTimeout);\n                try {\n                    if (await this.isMountActuallyActive()) {\n                        resolve();\n                        return;\n                    }\n                    await this.stop();\n                    reject(new Error(\"Could not start network drive (timeout).\"));\n                }\n                catch (e) {\n                    reject(e);\n                }\n            }, 30000);\n            this.rcloneProcess = (0, child_process_1.spawn)(binaryPathNormalized, args, {\n                stdio: \"ignore\",\n                shell: process.platform === \"win32\" ? \"cmd.exe\" : \"/bin/sh\",\n                detached: false\n            });\n            this.rcloneProcess.on(\"error\", err => {\n                this.rcloneProcess = null;\n                clearInterval(checkInterval);\n                clearTimeout(checkTimeout);\n                reject(err);\n            });\n            this.rcloneProcess.on(\"exit\", () => {\n                this.rcloneProcess = null;\n                clearInterval(checkInterval);\n                clearTimeout(checkTimeout);\n                reject(new Error(\"Could not start network drive (exit).\"));\n            });\n        });\n    }\n    /**\n     * Cleanup the RClone process.\n     *\n     * @private\n     * @async\n     * @returns {Promise<void>}\n     */\n    async cleanupRClone() {\n        var _a;\n        if (this.rcloneProcess) {\n            this.rcloneProcess.removeAllListeners();\n            if (this.rcloneProcess.stdin) {\n                try {\n                    this.rcloneProcess.stdin.removeAllListeners();\n                    this.rcloneProcess.stdin.destroy();\n                }\n                catch (_b) {\n                    // Noop\n                }\n            }\n            if (this.rcloneProcess.stdout) {\n                try {\n                    this.rcloneProcess.stdout.removeAllListeners();\n                    this.rcloneProcess.stdout.destroy();\n                }\n                catch (_c) {\n                    // Noop\n                }\n            }\n            if (this.rcloneProcess.stderr) {\n                try {\n                    this.rcloneProcess.stderr.removeAllListeners();\n                    this.rcloneProcess.stderr.destroy();\n                }\n                catch (_d) {\n                    // Noop\n                }\n            }\n            (_a = this.rcloneProcess) === null || _a === void 0 ? void 0 : _a.kill(\"SIGTERM\");\n            await new Promise(resolve => setTimeout(resolve, 1000));\n            if (this.rcloneProcess.pid) {\n                await (0, utils_1.killProcessByPid)(this.rcloneProcess.pid).catch(() => { });\n            }\n        }\n        await (0, utils_1.killProcessByName)(exports.RCLONE_BINARY_NAME).catch(() => { });\n        if (process.platform === \"linux\" || process.platform === \"darwin\") {\n            await (0, utils_1.execCommand)(process.platform === \"darwin\" ? `umount -f \"${this.mountPoint}\"` : `fusermount -uzq \"${this.mountPoint}\"`).catch(() => { });\n        }\n    }\n    /**\n     * Start the network drive.\n     *\n     * @public\n     * @async\n     * @returns {Promise<void>}\n     */\n    async start() {\n        await this.startMutex.acquire();\n        try {\n            await this.stop();\n            if (this.tryToInstallDependenciesOnStart) {\n                if (process.platform === \"darwin\" && !(await (0, utils_1.isMacFUSEInstalled)())) {\n                    await this.installFuseTMacOS();\n                    await this.addHostsEntry();\n                }\n                if (process.platform === \"win32\") {\n                    await this.installWinFSPWindows();\n                }\n            }\n            if (process.platform === \"win32\" && !(await (0, utils_1.isWinFSPInstalled)())) {\n                throw new Error(\"WinFSP not installed.\");\n            }\n            if (process.platform === \"linux\" && !(await (0, utils_1.isFUSE3InstalledOnLinux)())) {\n                throw new Error(\"FUSE3 not installed.\");\n            }\n            if (process.platform === \"darwin\" && !(await (0, utils_1.isFUSETInstalledOnMacOS)())) {\n                throw new Error(\"FUSE-T not installed.\");\n            }\n            if (process.platform === \"win32\") {\n                const availableDriveLetters = await (0, utils_1.getAvailableDriveLetters)();\n                if (!availableDriveLetters.includes(this.mountPoint)) {\n                    throw new Error(`Cannot mount network drive at ${this.mountPoint}: Drive letter exists.`);\n                }\n            }\n            else {\n                if ((process.platform === \"linux\" || process.platform === \"darwin\") && this.mountPoint.includes(\"$\")) {\n                    throw new Error(\"Only absolute paths for mount points are supported.\");\n                }\n                if (process.platform === \"linux\" && !this.mountPoint.startsWith(os_1.default.homedir() + \"/\")) {\n                    throw new Error(\"Cannot mount to a directory outside of your home directory.\");\n                }\n                if (process.platform === \"darwin\" && !this.mountPoint.startsWith(os_1.default.homedir() + \"/\")) {\n                    throw new Error(\"Cannot mount to a directory outside of your user directory.\");\n                }\n                if (!(await (0, utils_1.isUnixMountPointValid)(this.mountPoint))) {\n                    throw new Error(`Cannot mount network drive at ${this.mountPoint}: Mount point does not exist.`);\n                }\n                if (!(await (0, utils_1.isUnixMountPointEmpty)(this.mountPoint))) {\n                    throw new Error(`Cannot mount network drive at ${this.mountPoint}: Mount point not empty.`);\n                }\n            }\n            const webdavPort = await (0, ports_1.findFreePort)();\n            if (!webdavPort) {\n                throw new Error(\"Could not find a free port.\");\n            }\n            this.webdavPort = webdavPort;\n            this.webdavUsername = (0, utils_1.generateRandomString)(32);\n            this.webdavPassword = (0, utils_1.generateRandomString)(32);\n            this.webdavEndpoint = `http://127.0.0.1:${this.webdavPort}`;\n            this.webdavServer = new webdav_1.default({\n                hostname: \"127.0.0.1\",\n                port: this.webdavPort,\n                https: false,\n                user: {\n                    username: this.webdavUsername,\n                    password: this.webdavPassword,\n                    sdk: this.sdk\n                },\n                authMode: \"basic\",\n                rateLimit: {\n                    windowMs: 1000,\n                    limit: 10000,\n                    key: \"ip\"\n                },\n                tempFilesToStoreOnDisk: exports.excludePatterns\n            });\n            await this.webdavServer.start();\n            await this.writeRCloneConfig({\n                user: this.webdavUsername,\n                password: this.webdavPassword,\n                endpoint: this.webdavEndpoint\n            });\n            await this.spawnRClone();\n            if (!(await this.isMountActuallyActive())) {\n                throw new Error(\"Could not start network drive (not active).\");\n            }\n            this.active = true;\n        }\n        catch (e) {\n            this.logger.log(\"error\", e, \"start\");\n            this.logger.log(\"error\", e);\n            throw e;\n        }\n        finally {\n            this.startMutex.release();\n        }\n    }\n    /**\n     * Stop the network drive.\n     *\n     * @public\n     * @async\n     * @returns {Promise<void>}\n     */\n    async stop() {\n        var _a, _b;\n        await this.stopMutex.acquire();\n        try {\n            await this.cleanupRClone();\n            const webdavOnline = await this.isWebDAVOnline();\n            if (webdavOnline && ((_a = this.webdavServer) === null || _a === void 0 ? void 0 : _a.serverInstance)) {\n                await ((_b = this.webdavServer) === null || _b === void 0 ? void 0 : _b.stop(true));\n            }\n            this.webdavServer = null;\n            this.rcloneProcess = null;\n            this.active = false;\n        }\n        catch (e) {\n            this.logger.log(\"error\", e, \"stop\");\n            this.logger.log(\"error\", e);\n            throw e;\n        }\n        finally {\n            this.stopMutex.release();\n        }\n    }\n}\nexports.NetworkDrive = NetworkDrive;\n__exportStar(require(\"./utils\"), exports);\nexports.default = NetworkDrive;\n"]}