{
  "version": 3,
  "sources": ["../../../../../src/packages/default-reporter/reporterForClient/reportBigTarballsProgress.ts"],
  "sourcesContent": ["import type { FetchingProgressLog } from '../../core-loggers/index.ts';\nimport type * as Rx from 'rxjs';\nimport { filter, map, startWith } from 'rxjs/operators';\nimport prettyBytes from 'pretty-bytes';\nimport { hlPkgId, hlValue } from './outputConstants.ts';\n\nconst BIG_TARBALL_SIZE = 1024 * 1024 * 5; // 5 MB\nconst PRETTY_OPTS = {\n  minimumFractionDigits: 2,\n  maximumFractionDigits: 2,\n};\n\nexport function reportBigTarballProgress(log$: {\n  fetchingProgress: Rx.Observable<FetchingProgressLog>;\n}): Rx.Observable<Rx.Observable<{ fixed: boolean; msg: string }>> {\n  return log$.fetchingProgress.pipe(\n    filter(\n      (log: FetchingProgressLog) =>\n        log.status === 'started' &&\n        typeof log.size === 'number' &&\n        log.size >= BIG_TARBALL_SIZE &&\n        // When retrying the download, keep the existing progress line.\n        // Fixing issue: https://github.com/pnpm/pnpm/issues/1013\n        log.attempt === 1\n    ),\n    map((startedLog: FetchingProgressLog) => {\n      const size = prettyBytes(startedLog.size ?? 0, PRETTY_OPTS);\n      return log$.fetchingProgress.pipe(\n        filter(\n          (log: FetchingProgressLog) =>\n            log.status === 'in_progress' &&\n            log.packageId === startedLog['packageId']\n        ),\n        map((log: FetchingProgressLog) => log.downloaded ?? 0),\n        startWith(0),\n        map((downloadedRaw: number) => {\n          const done = startedLog.size === downloadedRaw;\n          const downloaded = prettyBytes(downloadedRaw, PRETTY_OPTS);\n          return {\n            fixed: !done,\n            msg: `Downloading ${hlPkgId(startedLog['packageId'])}: ${hlValue(downloaded)}/${hlValue(size)}${done ? ', done' : ''}`,\n          };\n        })\n      );\n    })\n  );\n}\n"],
  "mappings": "AAEA,SAAS,QAAQ,KAAK,iBAAiB;AACvC,OAAO,iBAAiB;AACxB,SAAS,SAAS,eAAe;AAEjC,MAAM,mBAAmB,OAAO,OAAO;AACvC,MAAM,cAAc;AAAA,EAClB,uBAAuB;AAAA,EACvB,uBAAuB;AACzB;AAEO,SAAS,yBAAyB,MAEyB;AAChE,SAAO,KAAK,iBAAiB;AAAA,IAC3B;AAAA,MACE,CAAC,QACC,IAAI,WAAW,aACf,OAAO,IAAI,SAAS,YACpB,IAAI,QAAQ;AAAA;AAAA,MAGZ,IAAI,YAAY;AAAA,IACpB;AAAA,IACA,IAAI,CAAC,eAAoC;AACvC,YAAM,OAAO,YAAY,WAAW,QAAQ,GAAG,WAAW;AAC1D,aAAO,KAAK,iBAAiB;AAAA,QAC3B;AAAA,UACE,CAAC,QACC,IAAI,WAAW,iBACf,IAAI,cAAc,WAAW,WAAW;AAAA,QAC5C;AAAA,QACA,IAAI,CAAC,QAA6B,IAAI,cAAc,CAAC;AAAA,QACrD,UAAU,CAAC;AAAA,QACX,IAAI,CAAC,kBAA0B;AAC7B,gBAAM,OAAO,WAAW,SAAS;AACjC,gBAAM,aAAa,YAAY,eAAe,WAAW;AACzD,iBAAO;AAAA,YACL,OAAO,CAAC;AAAA,YACR,KAAK,eAAe,QAAQ,WAAW,WAAW,CAAC,CAAC,KAAK,QAAQ,UAAU,CAAC,IAAI,QAAQ,IAAI,CAAC,GAAG,OAAO,WAAW,EAAE;AAAA,UACtH;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
  "names": []
}
