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AI,UAAU,EAAG,EAAG,KAAK,MAAO,KAAK,QA1dV,KA8dxB,GAAQ,EAAK,WAChB,EAAI,UAAU,EAAK,QAAS,EAAK,QAAS,EAAK,MAAO,EAAK,QA9dlC,KA+df,GAAQ,EAAK,YACvB,EAAI,aAAa,EAAK,UAAW,EAAK,QAAS,EAAK,SA/d/B,IAmenB,EAAM,SACR,EAAI,UAAU,EAAM,QAAS,EAAM,QAAS,EAAM,MAAO,EAAM,QAI1D,EAAI,UAAU,EAAM,MAAO,EAAM,QAAS,EAAM,QACzD,CAEA,OAAA,CAAQ,GACN,IAAI,EAAc,EAClB,MAAM,UAAE,EAAS,OAAE,EAAM,SAAE,GAAa,KAAK,UAEvC,EAAU,KACd,MAAM,EAAI,IAAgB,EACpB,EAAQ,EAAO,GACrB,KAAK,YAAY,EAAK,GAElB,EAAY,GAAK,EAAc,EAAY,IAC7C,KAAK,UAAU,SAAW,WAAW,EAAS,EAAM,OACtD,EAGF,GACF,CAEA,aAAA,GACE,OAAO,aAAa,KAAK,WAAa,KAAK,UAAU,SACvD,CAEA,MAAA,CAAO,GAGD,EAAO,MACT,EAAO,KAAK,gBAGd,EAAO,KAAO,KACd,EAAO,MAAQ,KAAK,MACpB,EAAO,OAAS,KAAK,OACrB,MAAM,EAAM,EAAO,WAAW,MAE9B,GAAI,KAAK,UAEP,OADA,KAAK,aAAa,GACX,KAAK,QAAQ,GACf,CACL,MAAM,EAAO,EAAI,gBAAgB,KAAK,MAAO,KAAK,QAElD,OADA,KAAK,gBAAgB,EAAM,KAAK,gBACzB,EAAI,aAAa,EAAM,EAAG,EACnC,CACF,EAEF,OAAO,CACR,CA3hBY","file":"/npm/png-js@1.0.0/png.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/png-js@1.0.0/png.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * MIT LICENSE\n * Copyright (c) 2011 Devon Govett\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this\n * software and associated documentation files (the \"Software\"), to deal in the Software\n * without restriction, including without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n * to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or\n * substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING\n * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nwindow.PNG = (function() {\n  let APNG_DISPOSE_OP_NONE = 0;\n  let APNG_DISPOSE_OP_BACKGROUND = 1;\n  let APNG_DISPOSE_OP_PREVIOUS = 2;\n  let APNG_BLEND_OP_SOURCE = 0;\n  let APNG_BLEND_OP_OVER = 1;\n  let scratchCanvas = document.createElement('canvas');\n  let scratchCtx = scratchCanvas.getContext('2d');\n  let makeImage = function(imageData) {\n    scratchCtx.width = imageData.width;\n    scratchCtx.height = imageData.height;\n    scratchCtx.clearRect(0, 0, imageData.width, imageData.height);\n    scratchCtx.putImageData(imageData, 0, 0);\n\n    const img = new Image();\n    img.src = scratchCanvas.toDataURL();\n    return img;\n  };\n\n  class PNG {\n    static load(url, canvas, callback) {\n      if (typeof canvas === 'function') {\n        callback = canvas;\n      }\n\n      const xhr = new XMLHttpRequest();\n      xhr.open('GET', url, true);\n      xhr.responseType = 'arraybuffer';\n      xhr.onload = () => {\n        const data = new Uint8Array(xhr.response || xhr.mozResponseArrayBuffer);\n        const png = new PNG(data);\n        if (typeof (canvas && canvas.getContext) === 'function') {\n          png.render(canvas);\n        }\n        return typeof callback === 'function' ? callback(png) : undefined;\n      };\n\n      return xhr.send(null);\n    }\n\n    constructor(data1) {\n      let i;\n      this.data = data1;\n      this.pos = 8; // Skip the default header\n\n      this.palette = [];\n      this.imgData = [];\n      this.transparency = {};\n      this.animation = null;\n      this.text = {};\n      let frame = null;\n\n      while (true) {\n        var data;\n        let chunkSize = this.readUInt32();\n        let section = '';\n        for (i = 0; i < 4; i++) {\n          section += String.fromCharCode(this.data[this.pos++]);\n        }\n\n        switch (section) {\n          case 'IHDR':\n            // we can grab  interesting values from here (like width, height, etc)\n            this.width = this.readUInt32();\n            this.height = this.readUInt32();\n            this.bits = this.data[this.pos++];\n            this.colorType = this.data[this.pos++];\n            this.compressionMethod = this.data[this.pos++];\n            this.filterMethod = this.data[this.pos++];\n            this.interlaceMethod = this.data[this.pos++];\n            break;\n\n          case 'acTL':\n            // we have an animated PNG\n            this.animation = {\n              numFrames: this.readUInt32(),\n              numPlays: this.readUInt32() || Infinity,\n              frames: []\n            };\n            break;\n\n          case 'PLTE':\n            this.palette = this.read(chunkSize);\n            break;\n\n          case 'fcTL':\n            if (frame) {\n              this.animation.frames.push(frame);\n            }\n\n            this.pos += 4; // skip sequence number\n            frame = {\n              width: this.readUInt32(),\n              height: this.readUInt32(),\n              xOffset: this.readUInt32(),\n              yOffset: this.readUInt32()\n            };\n\n            var delayNum = this.readUInt16();\n            var delayDen = this.readUInt16() || 100;\n            frame.delay = (1000 * delayNum) / delayDen;\n\n            frame.disposeOp = this.data[this.pos++];\n            frame.blendOp = this.data[this.pos++];\n            frame.data = [];\n            break;\n\n          case 'IDAT':\n          case 'fdAT':\n            if (section === 'fdAT') {\n              this.pos += 4; // skip sequence number\n              chunkSize -= 4;\n            }\n\n            data = (frame && frame.data) || this.imgData;\n            for (i = 0; i < chunkSize; i++) {\n              data.push(this.data[this.pos++]);\n            }\n            break;\n\n          case 'tRNS':\n            // This chunk can only occur once and it must occur after the\n            // PLTE chunk and before the IDAT chunk.\n            this.transparency = {};\n            switch (this.colorType) {\n              case 3:\n                // Indexed color, RGB. Each byte in this chunk is an alpha for\n                // the palette index in the PLTE (\"palette\") chunk up until the\n                // last non-opaque entry. Set up an array, stretching over all\n                // palette entries which will be 0 (opaque) or 1 (transparent).\n                this.transparency.indexed = this.read(chunkSize);\n                var short = 255 - this.transparency.indexed.length;\n                if (short > 0) {\n                  for (i = 0; i < short; i++) {\n                    this.transparency.indexed.push(255);\n                  }\n                }\n                break;\n              case 0:\n                // Greyscale. Corresponding to entries in the PLTE chunk.\n                // Grey is two bytes, range 0 .. (2 ^ bit-depth) - 1\n                this.transparency.grayscale = this.read(chunkSize)[0];\n                break;\n              case 2:\n                // True color with proper alpha channel.\n                this.transparency.rgb = this.read(chunkSize);\n                break;\n            }\n            break;\n\n          case 'tEXt':\n            var text = this.read(chunkSize);\n            var index = text.indexOf(0);\n            var key = String.fromCharCode.apply(String, text.slice(0, index));\n            this.text[key] = String.fromCharCode.apply(\n              String,\n              text.slice(index + 1)\n            );\n            break;\n\n          case 'IEND':\n            if (frame) {\n              this.animation.frames.push(frame);\n            }\n\n            // we've got everything we need!\n            switch (this.colorType) {\n              case 0:\n              case 3:\n              case 4:\n                this.colors = 1;\n                break;\n              case 2:\n              case 6:\n                this.colors = 3;\n                break;\n            }\n\n            this.hasAlphaChannel = [4, 6].includes(this.colorType);\n            var colors = this.colors + (this.hasAlphaChannel ? 1 : 0);\n            this.pixelBitlength = this.bits * colors;\n\n            switch (this.colors) {\n              case 1:\n                this.colorSpace = 'DeviceGray';\n                break;\n              case 3:\n                this.colorSpace = 'DeviceRGB';\n                break;\n            }\n\n            this.imgData = new Uint8Array(this.imgData);\n            return;\n            break;\n\n          default:\n            // unknown (or unimportant) section, skip it\n            this.pos += chunkSize;\n        }\n\n        this.pos += 4; // Skip the CRC\n\n        if (this.pos > this.data.length) {\n          throw new Error('Incomplete or corrupt PNG file');\n        }\n      }\n    }\n\n    read(bytes) {\n      const result = new Array(bytes);\n      for (let i = 0; i < bytes; i++) {\n        result[i] = this.data[this.pos++];\n      }\n      return result;\n    }\n\n    readUInt32() {\n      const b1 = this.data[this.pos++] << 24;\n      const b2 = this.data[this.pos++] << 16;\n      const b3 = this.data[this.pos++] << 8;\n      const b4 = this.data[this.pos++];\n      return b1 | b2 | b3 | b4;\n    }\n\n    readUInt16() {\n      const b1 = this.data[this.pos++] << 8;\n      const b2 = this.data[this.pos++];\n      return b1 | b2;\n    }\n\n    decodePixels(data) {\n      if (data == null) {\n        data = this.imgData;\n      }\n      if (data.length === 0) {\n        return new Uint8Array(0);\n      }\n\n      data = new FlateStream(data);\n      data = data.getBytes();\n\n      const { width, height } = this;\n      const pixelBytes = this.pixelBitlength / 8;\n\n      const pixels = new Uint8Array(width * height * pixelBytes);\n      const { length } = data;\n      let pos = 0;\n\n      function pass(x0, y0, dx, dy, singlePass = false) {\n        const w = Math.ceil((width - x0) / dx);\n        const h = Math.ceil((height - y0) / dy);\n        const scanlineLength = pixelBytes * w;\n        const buffer = singlePass ? pixels : new Uint8Array(scanlineLength * h);\n        let row = 0;\n        let c = 0;\n        while (row < h && pos < length) {\n          var byte, col, i, left, upper;\n          switch (data[pos++]) {\n            case 0: // None\n              for (i = 0; i < scanlineLength; i++) {\n                buffer[c++] = data[pos++];\n              }\n              break;\n\n            case 1: // Sub\n              for (i = 0; i < scanlineLength; i++) {\n                byte = data[pos++];\n                left = i < pixelBytes ? 0 : buffer[c - pixelBytes];\n                buffer[c++] = (byte + left) % 256;\n              }\n              break;\n\n            case 2: // Up\n              for (i = 0; i < scanlineLength; i++) {\n                byte = data[pos++];\n                col = (i - (i % pixelBytes)) / pixelBytes;\n                upper =\n                  row &&\n                  buffer[\n                    (row - 1) * scanlineLength +\n                      col * pixelBytes +\n                      (i % pixelBytes)\n                  ];\n                buffer[c++] = (upper + byte) % 256;\n              }\n              break;\n\n            case 3: // Average\n              for (i = 0; i < scanlineLength; i++) {\n                byte = data[pos++];\n                col = (i - (i % pixelBytes)) / pixelBytes;\n                left = i < pixelBytes ? 0 : buffer[c - pixelBytes];\n                upper =\n                  row &&\n                  buffer[\n                    (row - 1) * scanlineLength +\n                      col * pixelBytes +\n                      (i % pixelBytes)\n                  ];\n                buffer[c++] = (byte + Math.floor((left + upper) / 2)) % 256;\n              }\n              break;\n\n            case 4: // Paeth\n              for (i = 0; i < scanlineLength; i++) {\n                var paeth, upperLeft;\n                byte = data[pos++];\n                col = (i - (i % pixelBytes)) / pixelBytes;\n                left = i < pixelBytes ? 0 : buffer[c - pixelBytes];\n\n                if (row === 0) {\n                  upper = upperLeft = 0;\n                } else {\n                  upper =\n                    buffer[\n                      (row - 1) * scanlineLength +\n                        col * pixelBytes +\n                        (i % pixelBytes)\n                    ];\n                  upperLeft =\n                    col &&\n                    buffer[\n                      (row - 1) * scanlineLength +\n                        (col - 1) * pixelBytes +\n                        (i % pixelBytes)\n                    ];\n                }\n\n                const p = left + upper - upperLeft;\n                const pa = Math.abs(p - left);\n                const pb = Math.abs(p - upper);\n                const pc = Math.abs(p - upperLeft);\n\n                if (pa <= pb && pa <= pc) {\n                  paeth = left;\n                } else if (pb <= pc) {\n                  paeth = upper;\n                } else {\n                  paeth = upperLeft;\n                }\n\n                buffer[c++] = (byte + paeth) % 256;\n              }\n              break;\n\n            default:\n              throw new Error(`Invalid filter algorithm: ${data[pos - 1]}`);\n          }\n\n          if (!singlePass) {\n            let pixelsPos = ((y0 + row * dy) * width + x0) * pixelBytes;\n            let bufferPos = row * scanlineLength;\n            for (i = 0; i < w; i++) {\n              for (let j = 0; j < pixelBytes; j++)\n                pixels[pixelsPos++] = buffer[bufferPos++];\n              pixelsPos += (dx - 1) * pixelBytes;\n            }\n          }\n\n          row++;\n        }\n      }\n\n      if (this.interlaceMethod === 1) {\n        /*\n          1 6 4 6 2 6 4 6\n          7 7 7 7 7 7 7 7\n          5 6 5 6 5 6 5 6\n          7 7 7 7 7 7 7 7\n          3 6 4 6 3 6 4 6\n          7 7 7 7 7 7 7 7\n          5 6 5 6 5 6 5 6\n          7 7 7 7 7 7 7 7\n        */\n        pass(0, 0, 8, 8); // 1\n        pass(4, 0, 8, 8); // 2\n        pass(0, 4, 4, 8); // 3\n        pass(2, 0, 4, 4); // 4\n        pass(0, 2, 2, 4); // 5\n        pass(1, 0, 2, 2); // 6\n        pass(0, 1, 1, 2); // 7\n      } else {\n        pass(0, 0, 1, 1, true);\n      }\n\n      return pixels;\n    }\n\n    decodePalette() {\n      const { palette } = this;\n      const { length } = palette;\n      const transparency = this.transparency.indexed || [];\n      const ret = new Uint8Array((transparency.length || 0) + length);\n      let pos = 0;\n      let c = 0;\n\n      for (let i = 0; i < length; i += 3) {\n        var left;\n        ret[pos++] = palette[i];\n        ret[pos++] = palette[i + 1];\n        ret[pos++] = palette[i + 2];\n        ret[pos++] = (left = transparency[c++]) != null ? left : 255;\n      }\n\n      return ret;\n    }\n\n    copyToImageData(imageData, pixels) {\n      let j, k;\n      let { colors } = this;\n      let palette = null;\n      let alpha = this.hasAlphaChannel;\n\n      if (this.palette.length) {\n        palette =\n          this._decodedPalette || (this._decodedPalette = this.decodePalette());\n        colors = 4;\n        alpha = true;\n      }\n\n      const data = imageData.data || imageData;\n      const { length } = data;\n      const input = palette || pixels;\n      let i = (j = 0);\n\n      if (colors === 1) {\n        while (i < length) {\n          k = palette ? pixels[i / 4] * 4 : j;\n          const v = input[k++];\n          data[i++] = v;\n          data[i++] = v;\n          data[i++] = v;\n          data[i++] = alpha ? input[k++] : 255;\n          j = k;\n        }\n      } else {\n        while (i < length) {\n          k = palette ? pixels[i / 4] * 4 : j;\n          data[i++] = input[k++];\n          data[i++] = input[k++];\n          data[i++] = input[k++];\n          data[i++] = alpha ? input[k++] : 255;\n          j = k;\n        }\n      }\n    }\n\n    decode() {\n      const ret = new Uint8Array(this.width * this.height * 4);\n      this.copyToImageData(ret, this.decodePixels());\n      return ret;\n    }\n\n    decodeFrames(ctx) {\n      if (!this.animation) {\n        return;\n      }\n\n      for (let i = 0; i < this.animation.frames.length; i++) {\n        const frame = this.animation.frames[i];\n        const imageData = ctx.createImageData(frame.width, frame.height);\n        const pixels = this.decodePixels(new Uint8Array(frame.data));\n\n        this.copyToImageData(imageData, pixels);\n        frame.imageData = imageData;\n        frame.image = makeImage(imageData);\n      }\n    }\n\n    renderFrame(ctx, number) {\n      const { frames } = this.animation;\n      const frame = frames[number];\n      const prev = frames[number - 1];\n\n      // if we're on the first frame, clear the canvas\n      if (number === 0) {\n        ctx.clearRect(0, 0, this.width, this.height);\n      }\n\n      // check the previous frame's dispose operation\n      if ((prev && prev.disposeOp) === APNG_DISPOSE_OP_BACKGROUND) {\n        ctx.clearRect(prev.xOffset, prev.yOffset, prev.width, prev.height);\n      } else if ((prev && prev.disposeOp) === APNG_DISPOSE_OP_PREVIOUS) {\n        ctx.putImageData(prev.imageData, prev.xOffset, prev.yOffset);\n      }\n\n      // APNG_BLEND_OP_SOURCE overwrites the previous data\n      if (frame.blendOp === APNG_BLEND_OP_SOURCE) {\n        ctx.clearRect(frame.xOffset, frame.yOffset, frame.width, frame.height);\n      }\n\n      // draw the current frame\n      return ctx.drawImage(frame.image, frame.xOffset, frame.yOffset);\n    }\n\n    animate(ctx) {\n      let frameNumber = 0;\n      const { numFrames, frames, numPlays } = this.animation;\n\n      const doFrame = () => {\n        const f = frameNumber++ % numFrames;\n        const frame = frames[f];\n        this.renderFrame(ctx, f);\n\n        if (numFrames > 1 && frameNumber / numFrames < numPlays) {\n          this.animation._timeout = setTimeout(doFrame, frame.delay);\n        }\n      };\n\n      doFrame();\n    }\n\n    stopAnimation() {\n      return clearTimeout(this.animation && this.animation._timeout);\n    }\n\n    render(canvas) {\n      // if this canvas was displaying another image before,\n      // stop the animation on it\n      if (canvas._png) {\n        canvas._png.stopAnimation();\n      }\n\n      canvas._png = this;\n      canvas.width = this.width;\n      canvas.height = this.height;\n      const ctx = canvas.getContext('2d');\n\n      if (this.animation) {\n        this.decodeFrames(ctx);\n        return this.animate(ctx);\n      } else {\n        const data = ctx.createImageData(this.width, this.height);\n        this.copyToImageData(data, this.decodePixels());\n        return ctx.putImageData(data, 0, 0);\n      }\n    }\n  }\n  return PNG;\n})();\n"]}