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AK,KAAK,OAAQ,EAAM,IAEzB,GAAG,OAAO,KACT,KAAK,gBAAkB,KAClB,KAAK,WACJ,KAAK,iBACP,KAAK,KAAK,OAEV,KAAK,OACH,IAAI,MACF,gEAIN,KAAK,UAAW,EAClB,IAGA,KAAK,UACP,KAAK,gBAAgB,OAAO,QAG9B,KAAK,eAAe,SAAQ,SAAU,GACtB,OAAV,EACF,KAAK,gBAAgB,MAAM,MAE3B,KAAK,gBAAgB,MAAM,MAAM,EAErC,GAAG,MACH,KAAK,eAAiB,IAhEtB,CAgE0B,KAG9B,KAAK,eAAe,KAAK,IAE7B,EAEA,SAAS,UAAU,QAAU,WACvB,KAAK,kBACP,KAAK,gBAAgB,OACrB,KAAK,gBAAkB,MAEzB,KAAK,eAAiB,IACxB,EAEA,SAAS,UAAU,QAAU,WACtB,KAAK,WACR,KAAK,UAAW,EAChB,KAAK,UACL,KAAK,eAAiB,KAE1B,EAEA,SAAS,UAAU,IAAM,SAAU,GAC7B,GACF,KAAK,MAAM,GAET,KAAK,gBACP,KAAK,gBAAgB,MAAM,MAEvB,KAAK,eACP,KAAK,eAAe,KAAK,MAGzB,KAAK,MAAM,OAAO,MAAM,GAG9B,EAEA,SAAS,UAAU,MAAQ,WACrB,KAAK,iBACP,KAAK,gBAAgB,OAAO,QAE9B,KAAK,UAAW,CAClB,EAEA,SAAS,UAAU,OAAS,WACtB,KAAK,iBACP,KAAK,gBAAgB,OAAO,SAE9B,KAAK,UAAW,CAClB,EAEA,OAAO,QAAU","file":"/npm/jpegtran@2.0.0/lib/JpegTran.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/jpegtran@2.0.0/lib/JpegTran.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const childProcess = require('child_process');\nconst Stream = require('stream').Stream;\nconst util = require('util');\nconst which = require('which');\nconst memoizeAsync = require('memoizeasync');\n\nfunction JpegTran(jpegTranArgs) {\n  Stream.call(this);\n\n  this.jpegTranArgs = jpegTranArgs;\n  this.writable = this.readable = true;\n  this.hasEnded = false;\n}\n\nutil.inherits(JpegTran, Stream);\n\nJpegTran.getBinaryPath = memoizeAsync((cb) => {\n  which('jpegtran', (err, jpegTranBinaryPath) => {\n    if (err) {\n      jpegTranBinaryPath = require('jpegtran-bin');\n    }\n    if (jpegTranBinaryPath) {\n      cb(null, jpegTranBinaryPath);\n    } else {\n      cb(\n        new Error(\n          'No jpegtran binary in PATH and jpegtran-bin does not provide a pre-built binary for your architecture'\n        )\n      );\n    }\n  });\n});\n\nJpegTran.prototype._error = function (err) {\n  if (!this.hasEnded) {\n    this.hasEnded = true;\n    this.cleanUp();\n    this.emit('error', err);\n  }\n};\n\nJpegTran.prototype.write = function (chunk) {\n  if (this.hasEnded) {\n    return;\n  }\n  if (this.jpegTranProcess) {\n    this.jpegTranProcess.stdin.write(chunk);\n  } else {\n    if (!this.bufferedChunks) {\n      this.bufferedChunks = [];\n      JpegTran.getBinaryPath((err, jpegTranBinaryPath) => {\n        if (this.hasEnded) {\n          return;\n        }\n        if (err) {\n          return this._error(err);\n        }\n        this.commandLine =\n          jpegTranBinaryPath +\n          (this.jpegTranArgs ? ` ${this.jpegTranArgs.join(' ')}` : ''); // For debugging\n        this.jpegTranProcess = childProcess.spawn(\n          jpegTranBinaryPath,\n          this.jpegTranArgs,\n          { windowsHide: true }\n        );\n\n        this.seenDataOnStdout = false;\n\n        this.jpegTranProcess.on('error', this._error.bind(this));\n\n        // The child process might close its STDIN prematurely and emit EPIPE when the next chunk is written.\n        // That's not necessarily an error, so prevent it from causing an exception:\n        this.jpegTranProcess.stdin.on('error', () => {});\n\n        this.jpegTranProcess.on('exit', (exitCode) => {\n          if (exitCode > 0 && !this.hasEnded) {\n            this._error(\n              new Error(\n                `The jpegtran process exited with a non-zero exit code: ${exitCode}`\n              )\n            );\n            this.hasEnded = true;\n          }\n        });\n\n        this.jpegTranProcess.stdout\n          .on('data', (chunk) => {\n            this.seenDataOnStdout = true;\n            this.emit('data', chunk);\n          })\n          .on('end', () => {\n            this.jpegTranProcess = null;\n            if (!this.hasEnded) {\n              if (this.seenDataOnStdout) {\n                this.emit('end');\n              } else {\n                this._error(\n                  new Error(\n                    'JpegTran: The stdout stream ended without emitting any data'\n                  )\n                );\n              }\n              this.hasEnded = true;\n            }\n          });\n\n        if (this.isPaused) {\n          this.jpegTranProcess.stdout.pause();\n        }\n\n        this.bufferedChunks.forEach(function (chunk) {\n          if (chunk === null) {\n            this.jpegTranProcess.stdin.end();\n          } else {\n            this.jpegTranProcess.stdin.write(chunk);\n          }\n        }, this);\n        this.bufferedChunks = null;\n      });\n    }\n    this.bufferedChunks.push(chunk);\n  }\n};\n\nJpegTran.prototype.cleanUp = function () {\n  if (this.jpegTranProcess) {\n    this.jpegTranProcess.kill();\n    this.jpegTranProcess = null;\n  }\n  this.bufferedChunks = null;\n};\n\nJpegTran.prototype.destroy = function () {\n  if (!this.hasEnded) {\n    this.hasEnded = true;\n    this.cleanUp();\n    this.bufferedChunks = null;\n  }\n};\n\nJpegTran.prototype.end = function (chunk) {\n  if (chunk) {\n    this.write(chunk);\n  }\n  if (this.jpegTranProcess) {\n    this.jpegTranProcess.stdin.end();\n  } else {\n    if (this.bufferedChunks) {\n      this.bufferedChunks.push(null);\n    } else {\n      // .end called without an argument and with no preceeding .write calls. Make sure that we do create a process in that case:\n      this.write(Buffer.alloc(0));\n    }\n  }\n};\n\nJpegTran.prototype.pause = function () {\n  if (this.jpegTranProcess) {\n    this.jpegTranProcess.stdout.pause();\n  }\n  this.isPaused = true;\n};\n\nJpegTran.prototype.resume = function () {\n  if (this.jpegTranProcess) {\n    this.jpegTranProcess.stdout.resume();\n  }\n  this.isPaused = false;\n};\n\nmodule.exports = JpegTran;\n"]}