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B,EACjB,gBAAgB,EAChB,OAAQ,aACR,YAAY,GACb,YAAY,QAAQ,OAOvB,OALA,EAAI,MAAM,EAAO,EAAG,CAChB,MACA,YAAa,KAGV,CAAG,IAGR,YAAe,GACb,KACO,CACH,IAAK,UACL,SAAU,UACV,UAAW,YAGZ,SAGJ,MAAM,aAAe,YAE5B,SAAS,QAAQ,GACb,MAAM,SACF,EAAQ,UACR,EAAS,IACT,GACA,YAAY,GAEhB,OAAO,MAAM;qBACI,MAAM;sBACL,OAAO;eACd,IAAI;gBACH,WAAW;;;KAI3B,QAEO,MAAM,UAAa,GAAM,GAAK,EAAI,IAAM,GAE/C,SAAS,WACL,MAAM,EAAO,KAAK,MAAM,OAAO,MAAQ,SAAW,KAC5C,EAAU,KAAK,MAAM,EAAO,IAC5B,EAAU,EAAO,GAEvB,MAAO,GAAG,UAAU,KAAW,KAAW,UAAU,KAAW,GACnE","file":"/npm/@putout/formatter-memory@5.0.1/lib/memory.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@putout/formatter-memory@5.0.1/lib/memory.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import {Writable} from 'node:stream';\nimport process, {hrtime} from 'node:process';\nimport dump from '@putout/formatter-dump';\nimport cliProgress from 'cli-progress';\nimport chalk from 'chalk';\nimport once from 'once';\nimport format from 'format-io';\nimport montag from 'montag';\n\nconst start = once(() => hrtime.bigint());\nconst end = once(() => hrtime.bigint());\n\nconst OK = '👌';\n\nconst {\n    green,\n    yellow,\n    red,\n    blueBright,\n} = chalk;\n\nconst formatErrorsCount = (a) => a ? red(a) : OK;\n\nconst {stderr} = process;\n\nconst {\n    PUTOUT_PROGRESS_BAR = '1',\n    TEST = 0,\n} = process.env;\n\nexport default ({name, options, places, index, count, filesCount, errorsCount}) => {\n    start();\n    \n    const {color = '#ea4336', minCount = 0} = options;\n    \n    const memory = process.memoryUsage();\n    \n    const rss = format.size(memory.rss);\n    const heapUsed = format.size(memory.heapUsed);\n    const heapTotal = format.size(memory.heapTotal);\n    \n    const naturalIndex = index + 1;\n    \n    const result = dump({\n        name,\n        places,\n        index,\n        count,\n        filesCount,\n        errorsCount,\n    });\n    \n    if (count <= minCount)\n        return result;\n    \n    const bar = createProgress({\n        count,\n        color,\n        rss,\n    });\n    \n    bar.increment({\n        errorsCount: formatErrorsCount(errorsCount),\n        rss,\n    });\n    \n    if (naturalIndex === count) {\n        bar.stop();\n        return `\\r${result}\\n${getInfo({\n            rss,\n            heapUsed,\n            heapTotal,\n        })}`;\n    }\n    \n    return '';\n};\n\nconst getColorFn = (color) => {\n    if (color.startsWith('#'))\n        return chalk.hex(color);\n    \n    return chalk[color];\n};\n\nexport const _getStream = () => PUTOUT_PROGRESS_BAR !== '1' ? new Writable() : stderr;\n\nconst createProgress = once(({count, color, rss}) => {\n    const colorFn = getColorFn(color);\n    \n    const bar = new cliProgress.SingleBar({\n        format: `${colorFn('{bar}')} {percentage}% | {errorsCount} | {value}/{total} | {rss}`,\n        barCompleteChar: '\\u2588',\n        barIncompleteChar: '\\u2591',\n        clearOnComplete: true,\n        stopOnComplete: true,\n        stream: _getStream(),\n        hideCursor: true,\n    }, cliProgress.Presets.react);\n    \n    bar.start(count, 0, {\n        rss,\n        errorsCount: OK,\n    });\n    \n    return bar;\n});\n\nconst parseMemory = (memory) => {\n    if (TEST)\n        return {\n            rss: '65.29mb',\n            heapUsed: '65.29mb',\n            heapTotal: '224.57mb',\n        };\n    \n    return memory;\n};\n\nexport const _parseMemory = parseMemory;\n\nfunction getInfo(memory) {\n    const {\n        heapUsed,\n        heapTotal,\n        rss,\n    } = parseMemory(memory);\n    \n    return montag`\n        heap used: ${green(heapUsed)}\n        heap total: ${yellow(heapTotal)}\n        rss: ${red(rss)}\n        time: ${blueBright(calcTime())}\n    \n    \n    `;\n}\n\nexport const maybeZero = (a) => a <= 9 ? '0' : '';\n\nfunction calcTime() {\n    const time = Math.round(Number(end() - start()) / 1e9);\n    const minutes = Math.floor(time / 60);\n    const seconds = time % 60;\n    \n    return `${maybeZero(minutes)}${minutes}:${maybeZero(seconds)}${seconds}`;\n}\n"]}