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AK,QAAQ,KAAK,CAAE,GAAI,mBAEjB,IACX,EAQA,YAAY,UAAU,UAAY,SAAU,GAMxC,OALA,KAAK,QAAQ,KAAK,CACd,GAAI,qBACJ,QAAS,IAGN,IACX,EAQA,YAAY,UAAU,SAAW,SAAU,GAMvC,OALA,KAAK,QAAQ,KAAK,CACd,GAAI,oBACJ,QAAS,IAGN,IACX,EAOA,YAAY,UAAU,MAAQ,WAC1B,IAAI,EAAW,KAAK,SACpB,OAAO,KAAK,QAAQ,QAAO,SAAU,EAAS,GAC1C,OAAO,EAAQ,KAAK,SAAU,GAC1B,IAAI,EAAS,CAAC,GAQd,OANI,EAAO,SACP,EAAO,KAAK,EAAO,SAGvB,EAAO,KAAK,GAEL,EAAO,GAAG,MAAM,KAAM,EACjC,EAAE,KAAK,MACX,GAAG,QAAQ,QAAQ,KAAK,OAAO,MAAK,SAAU,GAE1C,OADA,KAAK,KAAO,EACL,CACX,GACJ,EAQA,YAAY,UAAU,OAAS,SAAU,GACrC,MAAM,EAAS,MAAM,WAAW,GAEhC,OAAO,KAAK,QAAQ,MAAK,SAAS,GAC9B,MAAM,EAAQ,SAAS,cAAc,OACrC,EAAM,aAAa,MAAO,gBAAgB,4BAA4B,IACtE,EAAO,YAAY,EACvB,GACJ,EAQA,YAAY,UAAU,OAAS,SAAU,GACrC,MAAM,EAAS,MAAM,WAAW,GAEhC,OAAO,KAAK,QAAQ,MAAK,SAAU,GAC/B,EAAO,aAAa,MAAO,gBAAgB,4BAA4B,GAC3E,GACJ,EAOA,YAAY,UAAU,WAAa,WAE/B,OADA,QAAQ,IAAI,KAAK,MACV,gBAAgB,4BAA4B,KAAK,KAC5D,EAEA,OAAO,QAAU","file":"/npm/image-filters@1.0.1/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/image-filters@1.0.1/src/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","const imageFilterContrast = require('image-filter-contrast');\nconst imageFilterBrightness = require('image-filter-brightness');\nconst imageFilterGrayscale = require('image-filter-grayscale');\nconst imageFilterThreshold = require('image-filter-threshold');\nconst imageFilterSepia = require('image-filter-sepia');\nconst imageFilterColorize = require('image-filter-colorize');\nconst imageFilterCore = require('image-filter-core');\nconst utils = require('./utils');\n\n/**\n * @method imageFilter\n * @param {Object} options\n * @param {String} [options.url] - image url\n * @param {String} [options.imageData] - data of a image extracted from a canvas\n * @param {String} [options.from] - dom selector of the original image\n * @param {Number} nWorkers - number of workers to split the work\n */\nfunction ImageFilter(options, nWorkers) {\n    var element;\n    var canvas;\n    var context;\n\n    if (!options || (!options.url && !options.imageData && !options.from)) {\n        throw new Error('image-filters:: invalid options object');\n    }\n\n    this.filters = [];\n    this.nWorkers = nWorkers;\n    this.url = options.url;\n    this.from = options.from;\n\n    if (this.url) {\n        element = document.createElement('img');\n        element.setAttribute('src', options.url);\n\n        canvas = imageFilterCore.getCanvas(element.width, element.height);\n        context = canvas.getContext('2d');\n\n        this.data = utils.getPixelsFromImage(canvas, context, element);\n    }  else if (options.from) {\n        element = utils.getElement(options.from);\n        canvas = imageFilterCore.getCanvas(element.width, element.height);\n        context = canvas.getContext('2d');\n\n        this.data = utils.getPixelsFromImage(canvas, context, element);\n    } else {\n        this.data = options.imageData;\n    }\n\n    if (!this.data) {\n        throw new Error('image-filters:: no data found');\n    }\n}\n\n/**\n * Push contrast filter\n * @method  contrast\n * @param   {Object} options\n * @returns {ImageFilter}\n */\nImageFilter.prototype.contrast = function (options) {\n    this.filters.push({\n        fn: imageFilterContrast,\n        options: options\n    });\n\n    return this;\n};\n\n/**\n * Push grayscale filter\n * @method  grayscale\n * @param   {Object} options\n * @returns {ImageFilter}\n */\nImageFilter.prototype.grayscale = function () {\n    this.filters.push({ fn: imageFilterGrayscale });\n    return this;\n};\n\n/**\n * Push brightness filter\n * @method  brightness\n * @param   {Object} options\n * @returns {ImageFilter}\n */\nImageFilter.prototype.brightness = function (options) {\n    this.filters.push({\n        fn: imageFilterBrightness,\n        options: options\n    });\n\n    return this;\n};\n\n/**\n * Push sepia filter\n * @method  sepia\n * @param   {Object} options\n * @returns {ImageFilter}\n */\nImageFilter.prototype.sepia = function () {\n    this.filters.push({ fn: imageFilterSepia });\n\n    return this;\n};\n\n/**\n * Push threshold filter\n * @method  threshold\n * @param   {Object} options\n * @returns {ImageFilter}\n */\nImageFilter.prototype.threshold = function (options) {\n    this.filters.push({\n        fn: imageFilterThreshold,\n        options: options\n    });\n\n    return this;\n};\n\n/**\n * Push colorize filter\n * @method  colorize\n * @param   {Object} options\n * @returns {ImageFilter}\n */\nImageFilter.prototype.colorize = function (options) {\n    this.filters.push({\n        fn: imageFilterColorize,\n        options: options\n    });\n\n    return this;\n};\n\n/**\n * Iterates all filters and applies filters\n * @method  apply\n * @returns {Promise}\n */\nImageFilter.prototype.apply = function () {\n    var nWorkers = this.nWorkers;\n    return this.filters.reduce(function (promise, filter) {\n        return promise.then(function (data) {\n            var params = [data];\n\n            if (filter.options) {\n                params.push(filter.options);\n            }\n\n            params.push(nWorkers);\n\n            return filter.fn.apply(null, params);\n        }.bind(this));\n    }, Promise.resolve(this.data)).then(function (data) {\n        this.data = data;\n        return data;\n    });\n};\n\n/**\n * Applies the filters and appends it to the given selector node\n * @method  append\n * @param   {String} selector\n * @returns {Promise}\n */\nImageFilter.prototype.append = function (selector) {\n    const target = utils.getElement(selector);\n\n    return this.apply().then(function(data) {\n        const image = document.createElement('img');\n        image.setAttribute('src', imageFilterCore.convertImageDataToCanvasURL(data));\n        target.appendChild(image);\n    });\n};\n\n/**\n * Re-apply filters and updates targer\n * @method  update\n * @param   {String} selector\n * @returns {Promise}\n */\nImageFilter.prototype.update = function (selector) {\n    const target = utils.getElement(selector);\n\n    return this.apply().then(function (data) {\n        target.setAttribute('src', imageFilterCore.convertImageDataToCanvasURL(data));\n    });\n};\n\n/**\n * Returns the dataURL from the current data\n * @method  getDataURL\n * @returns {String}\n */\nImageFilter.prototype.getDataURL = function () {\n    console.log(this.data);\n    return imageFilterCore.convertImageDataToCanvasURL(this.data);\n};\n\nmodule.exports = ImageFilter;\n"]}