diff --git a/app/code/Magento/AwsS3/Test/Mftf/Helper/MockTestLogger.php b/app/code/Magento/AwsS3/Test/Mftf/Helper/MockTestLogger.php index 45b7d53fee0d..5ea7d05458e8 100644 --- a/app/code/Magento/AwsS3/Test/Mftf/Helper/MockTestLogger.php +++ b/app/code/Magento/AwsS3/Test/Mftf/Helper/MockTestLogger.php @@ -14,49 +14,107 @@ * * Ignores most log messages but throws errors on error/critical/emergency logs so tests will fail */ -class MockTestLogger implements LoggerInterface { - - public function emergency($message, array $context = array()) +class MockTestLogger implements LoggerInterface +{ + /** + * @param $message + * @param array $context + * @return void + * @throws \Exception + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function emergency($message, array $context = []): void { throw new \Exception($message); } - public function alert($message, array $context = array()) + /** + * @param $message + * @param array $context + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function alert($message, array $context = []): void { // noop } - public function critical($message, array $context = array()) + /** + * @param $message + * @param array $context + * @return void + * @throws \Exception + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function critical($message, array $context = []): void { throw new \Exception($message); } - public function error($message, array $context = array()) + /** + * @param $message + * @param array $context + * @return void + * @throws \Exception + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function error($message, array $context = []): void { throw new \Exception($message); } - public function warning($message, array $context = array()) + /** + * @param $message + * @param array $context + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function warning($message, array $context = []): void { // noop } - public function notice($message, array $context = array()) + /** + * @param $message + * @param array $context + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function notice($message, array $context = []): void { // noop } - public function info($message, array $context = array()) + /** + * @param $message + * @param array $context + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function info($message, array $context = []): void { // noop } - public function debug($message, array $context = array()) + /** + * @param $message + * @param array $context + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function debug($message, array $context = []): void { // noop } - public function log($level, $message, array $context = array()) + /** + * @param $level + * @param $message + * @param array $context + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function log($level, $message, array $context = []): void { // noop } diff --git a/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml b/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml index bfc1e6a522b7..a9470eacf7fc 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml @@ -6,6 +6,7 @@ // phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound /** @var $block \Magento\Backend\Block\Media\Uploader */ +/** @var \Magento\Framework\Escaper $escaper */ ?>
- escapeHtml(__('Browse Files...')) ?> - + escapeHtml(__('Browse Files...')) ?> +
-``` - -The widget can then be initialized on a file upload form the following way: - -```js -$('#fileupload').fileupload(); -``` - -For further information, please refer to the following guides: - -- [Main documentation page](https://github.com/blueimp/jQuery-File-Upload/wiki) -- [List of all available Options](https://github.com/blueimp/jQuery-File-Upload/wiki/Options) -- [The plugin API](https://github.com/blueimp/jQuery-File-Upload/wiki/API) -- [How to setup the plugin on your website](https://github.com/blueimp/jQuery-File-Upload/wiki/Setup) -- [How to use only the basic plugin.](https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin) - -## Requirements - -### Mandatory requirements - -- [jQuery](https://jquery.com/) v1.7+ -- [jQuery UI widget factory](https://api.jqueryui.com/jQuery.widget/) v1.9+ - (included): Required for the basic File Upload plugin, but very lightweight - without any other dependencies from the jQuery UI suite. -- [jQuery Iframe Transport plugin](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.iframe-transport.js) - (included): Required for - [browsers without XHR file upload support](https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support). - -### Optional requirements - -- [JavaScript Templates engine](https://github.com/blueimp/JavaScript-Templates) - v3+: Used to render the selected and uploaded files for the Basic Plus UI and - jQuery UI versions. -- [JavaScript Load Image library](https://github.com/blueimp/JavaScript-Load-Image) - v2+: Required for the image previews and resizing functionality. -- [JavaScript Canvas to Blob polyfill](https://github.com/blueimp/JavaScript-Canvas-to-Blob) - v3+:Required for the image previews and resizing functionality. -- [blueimp Gallery](https://github.com/blueimp/Gallery) v2+: Used to display the - uploaded images in a lightbox. -- [Bootstrap](https://getbootstrap.com/) v3+: Used for the demo design. -- [Glyphicons](https://glyphicons.com/) Icon set used by Bootstrap. - -### Cross-domain requirements - -[Cross-domain File Uploads](https://github.com/blueimp/jQuery-File-Upload/wiki/Cross-domain-uploads) -using the -[Iframe Transport plugin](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.iframe-transport.js) -require a redirect back to the origin server to retrieve the upload results. The -[example implementation](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/main.js) -makes use of -[result.html](https://github.com/blueimp/jQuery-File-Upload/blob/master/cors/result.html) -as a static redirect page for the origin server. - -The repository also includes the -[jQuery XDomainRequest Transport plugin](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/cors/jquery.xdr-transport.js), -which enables limited cross-domain AJAX requests in Microsoft Internet Explorer -8 and 9 (IE 10 supports cross-domain XHR requests). -The XDomainRequest object allows GET and POST requests only and doesn't support -file uploads. It is used on the -[Demo](https://blueimp.github.io/jQuery-File-Upload/) to delete uploaded files -from the cross-domain demo file upload service. - -## Browsers - -### Desktop browsers - -The File Upload plugin is regularly tested with the latest browser versions and -supports the following minimal versions: - -- Google Chrome -- Apple Safari 4.0+ -- Mozilla Firefox 3.0+ -- Opera 11.0+ -- Microsoft Internet Explorer 6.0+ - -### Mobile browsers - -The File Upload plugin has been tested with and supports the following mobile -browsers: - -- Apple Safari on iOS 6.0+ -- Google Chrome on iOS 6.0+ -- Google Chrome on Android 4.0+ -- Default Browser on Android 2.3+ -- Opera Mobile 12.0+ - -### Extended browser support information - -For a detailed overview of the features supported by each browser version and -known operating system / browser bugs, please have a look at the -[Extended browser support information](https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support). - -## Testing - -The project comes with three sets of tests: - -1. Code linting using [ESLint](https://eslint.org/). -2. Unit tests using [Mocha](https://mochajs.org/). -3. End-to-end tests using [blueimp/wdio](https://github.com/blueimp/wdio). - -To run the tests, follow these steps: - -1. Start [Docker](https://docs.docker.com/). -2. Install development dependencies: - - ```sh - npm install - ``` - -3. Run the tests: - - ```sh - npm test - ``` - -## Support - -This project is actively maintained, but there is no official support channel. -If you have a question that another developer might help you with, please post -to -[Stack Overflow](https://stackoverflow.com/questions/tagged/blueimp+jquery+file-upload) -and tag your question with `blueimp jquery file upload`. - -## License - -Released under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/lib/web/jquery/fileUploader/SECURITY.md b/lib/web/jquery/fileUploader/SECURITY.md deleted file mode 100644 index 433a6853cdb3..000000000000 --- a/lib/web/jquery/fileUploader/SECURITY.md +++ /dev/null @@ -1,227 +0,0 @@ -# File Upload Security - -## Contents - -- [Introduction](#introduction) -- [Purpose of this project](#purpose-of-this-project) -- [Mitigations against file upload risks](#mitigations-against-file-upload-risks) - - [Prevent code execution on the server](#prevent-code-execution-on-the-server) - - [Prevent code execution in the browser](#prevent-code-execution-in-the-browser) - - [Prevent distribution of malware](#prevent-distribution-of-malware) -- [Secure file upload serving configurations](#secure-file-upload-serving-configurations) - - [Apache config](#apache-config) - - [NGINX config](#nginx-config) -- [Secure image processing configurations](#secure-image-processing-configurations) -- [ImageMagick config](#imagemagick-config) - -## Introduction - -For an in-depth understanding of the potential security risks of providing file -uploads and possible mitigations, please refer to the -[OWASP - Unrestricted File Upload](https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload) -documentation. - -To securely setup the project to serve uploaded files, please refer to the -sample -[Secure file upload serving configurations](#secure-file-upload-serving-configurations). - -To mitigate potential vulnerabilities in image processing libraries, please -refer to the -[Secure image processing configurations](#secure-image-processing-configurations). - -By default, all sample upload handlers allow only upload of image files, which -mitigates some attack vectors, but should not be relied on as the only -protection. - -Please also have a look at the -[list of fixed vulnerabilities](VULNERABILITIES.md) in jQuery File Upload, which -relates mostly to the sample server-side upload handlers and how they have been -configured. - -## Purpose of this project - -Please note that this project is not a complete file management product, but -foremost a client-side file upload library for [jQuery](https://jquery.com/). -The server-side sample upload handlers are just examples to demonstrate the -client-side file upload functionality. - -To make this very clear, there is **no user authentication** by default: - -- **everyone can upload files** -- **everyone can delete uploaded files** - -In some cases this can be acceptable, but for most projects you will want to -extend the sample upload handlers to integrate user authentication, or implement -your own. - -It is also up to you to configure your web server to securely serve the uploaded -files, e.g. using the -[sample server configurations](#secure-file-upload-serving-configurations). - -## Mitigations against file upload risks - -### Prevent code execution on the server - -To prevent execution of scripts or binaries on server-side, the upload directory -must be configured to not execute files in the upload directory (e.g. -`server/php/files` as the default for the PHP upload handler) and only treat -uploaded files as static content. - -The recommended way to do this is to configure the upload directory path to -point outside of the web application root. -Then the web server can be configured to serve files from the upload directory -with their default static files handler only. - -Limiting file uploads to a whitelist of safe file types (e.g. image files) also -mitigates this issue, but should not be the only protection. - -### Prevent code execution in the browser - -To prevent execution of scripts on client-side, the following headers must be -sent when delivering generic uploaded files to the client: - -``` -Content-Type: application/octet-stream -X-Content-Type-Options: nosniff -``` - -The `Content-Type: application/octet-stream` header instructs browsers to -display a download dialog instead of parsing it and possibly executing script -content e.g. in HTML files. - -The `X-Content-Type-Options: nosniff` header prevents browsers to try to detect -the file mime type despite the given content-type header. - -For known safe files, the content-type header can be adjusted using a -**whitelist**, e.g. sending `Content-Type: image/png` for PNG files. - -### Prevent distribution of malware - -To prevent attackers from uploading and distributing malware (e.g. computer -viruses), it is recommended to limit file uploads only to a whitelist of safe -file types. - -Please note that the detection of file types in the sample file upload handlers -is based on the file extension and not the actual file content. This makes it -still possible for attackers to upload malware by giving their files an image -file extension, but should prevent automatic execution on client computers when -opening those files. - -It does not protect at all from exploiting vulnerabilities in image display -programs, nor from users renaming file extensions to inadvertently execute the -contained malicious code. - -## Secure file upload serving configurations - -The following configurations serve uploaded files as static files with the -proper headers as -[mitigation against file upload risks](#mitigations-against-file-upload-risks). -Please do not simply copy&paste these configurations, but make sure you -understand what they are doing and that you have implemented them correctly. - -> Always test your own setup and make sure that it is secure! - -e.g. try uploading PHP scripts (as "example.php", "example.php.png" and -"example.png") to see if they get executed by your web server, e.g. the content -of the following sample: - -```php -GIF89ad - # Some of the directives require the Apache Headers module. If it is not - # already enabled, please execute the following command and reload Apache: - # sudo a2enmod headers - # - # Please note that the order of directives across configuration files matters, - # see also: - # https://httpd.apache.org/docs/current/sections.html#merging - - # The following directive matches all files and forces them to be handled as - # static content, which prevents the server from parsing and executing files - # that are associated with a dynamic runtime, e.g. PHP files. - # It also forces their Content-Type header to "application/octet-stream" and - # adds a "Content-Disposition: attachment" header to force a download dialog, - # which prevents browsers from interpreting files in the context of the - # web server, e.g. HTML files containing JavaScript. - # Lastly it also prevents browsers from MIME-sniffing the Content-Type, - # preventing them from interpreting a file as a different Content-Type than - # the one sent by the webserver. - - SetHandler default-handler - ForceType application/octet-stream - Header set Content-Disposition attachment - Header set X-Content-Type-Options nosniff - - - # The following directive matches known image files and unsets the forced - # Content-Type so they can be served with their original mime type. - # It also unsets the Content-Disposition header to allow displaying them - # inline in the browser. - - ForceType none - Header unset Content-Disposition - - -``` - -### NGINX config - -Add the following directive to the NGINX config, replacing the directory path -with the absolute path to the upload directory: - -```Nginx -location ^~ /path/to/project/server/php/files { - root html; - default_type application/octet-stream; - types { - image/gif gif; - image/jpeg jpg; - image/png png; - } - add_header X-Content-Type-Options 'nosniff'; - if ($request_filename ~ /(((?!\.(jpg)|(png)|(gif)$)[^/])+$)) { - add_header Content-Disposition 'attachment; filename="$1"'; - # Add X-Content-Type-Options again, as using add_header in a new context - # dismisses all previous add_header calls: - add_header X-Content-Type-Options 'nosniff'; - } -} -``` - -## Secure image processing configurations - -The following configuration mitigates -[potential image processing vulnerabilities with ImageMagick](VULNERABILITIES.md#potential-vulnerabilities-with-php-imagemagick) -by limiting the attack vectors to a small subset of image types -(`GIF/JPEG/PNG`). - -Please also consider using alternative, safer image processing libraries like -[libvips](https://github.com/libvips/libvips) or -[imageflow](https://github.com/imazen/imageflow). - -## ImageMagick config - -It is recommended to disable all non-required ImageMagick coders via -[policy.xml](https://wiki.debian.org/imagemagick/security). -To do so, locate the ImageMagick `policy.xml` configuration file and add the -following policies: - -```xml - - - - - - - - -``` diff --git a/lib/web/jquery/fileUploader/cors/jquery.postmessage-transport.js b/lib/web/jquery/fileUploader/cors/jquery.postmessage-transport.js deleted file mode 100644 index 5d5cc2f8d27c..000000000000 --- a/lib/web/jquery/fileUploader/cors/jquery.postmessage-transport.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * jQuery postMessage Transport Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory(require('jquery')); - } else { - // Browser globals: - factory(window.jQuery); - } -})(function ($) { - 'use strict'; - - var counter = 0, - names = [ - 'accepts', - 'cache', - 'contents', - 'contentType', - 'crossDomain', - 'data', - 'dataType', - 'headers', - 'ifModified', - 'mimeType', - 'password', - 'processData', - 'timeout', - 'traditional', - 'type', - 'url', - 'username' - ], - convert = function (p) { - return p; - }; - - $.ajaxSetup({ - converters: { - 'postmessage text': convert, - 'postmessage json': convert, - 'postmessage html': convert - } - }); - - $.ajaxTransport('postmessage', function (options) { - if (options.postMessage && window.postMessage) { - var iframe, - loc = $('').prop('href', options.postMessage)[0], - target = loc.protocol + '//' + loc.host, - xhrUpload = options.xhr().upload; - // IE always includes the port for the host property of a link - // element, but not in the location.host or origin property for the - // default http port 80 and https port 443, so we strip it: - if (/^(http:\/\/.+:80)|(https:\/\/.+:443)$/.test(target)) { - target = target.replace(/:(80|443)$/, ''); - } - return { - send: function (_, completeCallback) { - counter += 1; - var message = { - id: 'postmessage-transport-' + counter - }, - eventName = 'message.' + message.id; - iframe = $( - '' - ) - .on('load', function () { - $.each(names, function (i, name) { - message[name] = options[name]; - }); - message.dataType = message.dataType.replace('postmessage ', ''); - $(window).on(eventName, function (event) { - var e = event.originalEvent; - var data = e.data; - var ev; - if (e.origin === target && data.id === message.id) { - if (data.type === 'progress') { - ev = document.createEvent('Event'); - ev.initEvent(data.type, false, true); - $.extend(ev, data); - xhrUpload.dispatchEvent(ev); - } else { - completeCallback( - data.status, - data.statusText, - { postmessage: data.result }, - data.headers - ); - iframe.remove(); - $(window).off(eventName); - } - } - }); - iframe[0].contentWindow.postMessage(message, target); - }) - .appendTo(document.body); - }, - abort: function () { - if (iframe) { - iframe.remove(); - } - } - }; - } - }); -}); diff --git a/lib/web/jquery/fileUploader/cors/jquery.xdr-transport.js b/lib/web/jquery/fileUploader/cors/jquery.xdr-transport.js deleted file mode 100644 index 9e81860b943f..000000000000 --- a/lib/web/jquery/fileUploader/cors/jquery.xdr-transport.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * jQuery XDomainRequest Transport Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - * - * Based on Julian Aubourg's ajaxHooks xdr.js: - * https://github.com/jaubourg/ajaxHooks/ - */ - -/* global define, require, XDomainRequest */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory(require('jquery')); - } else { - // Browser globals: - factory(window.jQuery); - } -})(function ($) { - 'use strict'; - if (window.XDomainRequest && !$.support.cors) { - $.ajaxTransport(function (s) { - if (s.crossDomain && s.async) { - if (s.timeout) { - s.xdrTimeout = s.timeout; - delete s.timeout; - } - var xdr; - return { - send: function (headers, completeCallback) { - var addParamChar = /\?/.test(s.url) ? '&' : '?'; - /** - * Callback wrapper function - * - * @param {number} status HTTP status code - * @param {string} statusText HTTP status text - * @param {object} [responses] Content-type specific responses - * @param {string} [responseHeaders] Response headers string - */ - function callback(status, statusText, responses, responseHeaders) { - xdr.onload = xdr.onerror = xdr.ontimeout = $.noop; - xdr = null; - completeCallback(status, statusText, responses, responseHeaders); - } - xdr = new XDomainRequest(); - // XDomainRequest only supports GET and POST: - if (s.type === 'DELETE') { - s.url = s.url + addParamChar + '_method=DELETE'; - s.type = 'POST'; - } else if (s.type === 'PUT') { - s.url = s.url + addParamChar + '_method=PUT'; - s.type = 'POST'; - } else if (s.type === 'PATCH') { - s.url = s.url + addParamChar + '_method=PATCH'; - s.type = 'POST'; - } - xdr.open(s.type, s.url); - xdr.onload = function () { - callback( - 200, - 'OK', - { text: xdr.responseText }, - 'Content-Type: ' + xdr.contentType - ); - }; - xdr.onerror = function () { - callback(404, 'Not Found'); - }; - if (s.xdrTimeout) { - xdr.ontimeout = function () { - callback(0, 'timeout'); - }; - xdr.timeout = s.xdrTimeout; - } - xdr.send((s.hasContent && s.data) || null); - }, - abort: function () { - if (xdr) { - xdr.onerror = $.noop(); - xdr.abort(); - } - } - }; - } - }); - } -}); diff --git a/lib/web/jquery/fileUploader/css/jquery.fileupload-noscript.css b/lib/web/jquery/fileUploader/css/jquery.fileupload-noscript.css deleted file mode 100644 index 2409bfb0a694..000000000000 --- a/lib/web/jquery/fileUploader/css/jquery.fileupload-noscript.css +++ /dev/null @@ -1,22 +0,0 @@ -@charset "UTF-8"; -/* - * jQuery File Upload Plugin NoScript CSS - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -.fileinput-button input { - position: static; - opacity: 1; - filter: none; - font-size: inherit !important; - direction: inherit; -} -.fileinput-button span { - display: none; -} diff --git a/lib/web/jquery/fileUploader/css/jquery.fileupload-ui-noscript.css b/lib/web/jquery/fileUploader/css/jquery.fileupload-ui-noscript.css deleted file mode 100644 index 30651acf026c..000000000000 --- a/lib/web/jquery/fileUploader/css/jquery.fileupload-ui-noscript.css +++ /dev/null @@ -1,17 +0,0 @@ -@charset "UTF-8"; -/* - * jQuery File Upload UI Plugin NoScript CSS - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2012, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -.fileinput-button i, -.fileupload-buttonbar .delete, -.fileupload-buttonbar .toggle { - display: none; -} diff --git a/lib/web/jquery/fileUploader/css/jquery.fileupload.css b/lib/web/jquery/fileUploader/css/jquery.fileupload.css deleted file mode 100644 index 5716f3e8a8ae..000000000000 --- a/lib/web/jquery/fileUploader/css/jquery.fileupload.css +++ /dev/null @@ -1,36 +0,0 @@ -@charset "UTF-8"; -/* - * jQuery File Upload Plugin CSS - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -.fileinput-button { - position: relative; - overflow: hidden; - display: inline-block; -} -.fileinput-button input { - position: absolute; - top: 0; - right: 0; - margin: 0; - height: 100%; - opacity: 0; - filter: alpha(opacity=0); - font-size: 200px !important; - direction: ltr; - cursor: pointer; -} - -/* Fixes for IE < 8 */ -@media screen\9 { - .fileinput-button input { - font-size: 150% !important; - } -} diff --git a/lib/web/jquery/fileUploader/img/loading.gif b/lib/web/jquery/fileUploader/img/loading.gif deleted file mode 100644 index f5ef9dad4f77..000000000000 Binary files a/lib/web/jquery/fileUploader/img/loading.gif and /dev/null differ diff --git a/lib/web/jquery/fileUploader/img/progressbar.gif b/lib/web/jquery/fileUploader/img/progressbar.gif deleted file mode 100644 index fbcce6bc9abf..000000000000 Binary files a/lib/web/jquery/fileUploader/img/progressbar.gif and /dev/null differ diff --git a/lib/web/jquery/fileUploader/jquery.fileupload-audio.js b/lib/web/jquery/fileUploader/jquery.fileupload-audio.js deleted file mode 100644 index 1435ef20af2f..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileupload-audio.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * jQuery File Upload Audio Preview Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/jquery.fileupload-process'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory( - require('jquery'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), - require('jquery/fileUploader/jquery.fileupload-process') - ); - } else { - // Browser globals: - factory(window.jQuery, window.loadImage); - } -})(function ($, loadImage) { - 'use strict'; - - // Prepend to the default processQueue: - $.blueimp.fileupload.prototype.options.processQueue.unshift( - { - action: 'loadAudio', - // Use the action as prefix for the "@" options: - prefix: true, - fileTypes: '@', - maxFileSize: '@', - disabled: '@disableAudioPreview' - }, - { - action: 'setAudio', - name: '@audioPreviewName', - disabled: '@disableAudioPreview' - } - ); - - // The File Upload Audio Preview plugin extends the fileupload widget - // with audio preview functionality: - $.widget('blueimp.fileupload', $.blueimp.fileupload, { - options: { - // The regular expression for the types of audio files to load, - // matched against the file type: - loadAudioFileTypes: /^audio\/.*$/ - }, - - _audioElement: document.createElement('audio'), - - processActions: { - // Loads the audio file given via data.files and data.index - // as audio element if the browser supports playing it. - // Accepts the options fileTypes (regular expression) - // and maxFileSize (integer) to limit the files to load: - loadAudio: function (data, options) { - if (options.disabled) { - return data; - } - var file = data.files[data.index], - url, - audio; - if ( - this._audioElement.canPlayType && - this._audioElement.canPlayType(file.type) && - ($.type(options.maxFileSize) !== 'number' || - file.size <= options.maxFileSize) && - (!options.fileTypes || options.fileTypes.test(file.type)) - ) { - url = loadImage.createObjectURL(file); - if (url) { - audio = this._audioElement.cloneNode(false); - audio.src = url; - audio.controls = true; - data.audio = audio; - return data; - } - } - return data; - }, - - // Sets the audio element as a property of the file object: - setAudio: function (data, options) { - if (data.audio && !options.disabled) { - data.files[data.index][options.name || 'preview'] = data.audio; - } - return data; - } - } - }); -}); diff --git a/lib/web/jquery/fileUploader/jquery.fileupload-image.js b/lib/web/jquery/fileUploader/jquery.fileupload-image.js deleted file mode 100644 index 11c63c236247..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileupload-image.js +++ /dev/null @@ -1,346 +0,0 @@ -/* - * jQuery File Upload Image Preview & Resize Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define([ - 'jquery', - 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image', - 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta', - 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale', - 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif', - 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-orientation', - 'jquery/fileUploader/vendor/blueimp-canvas-to-blob/js/canvas-to-blob', - 'jquery/fileUploader/jquery.fileupload-process' - ], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory( - require('jquery'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-orientation'), - require('jquery/fileUploader/vendor/blueimp-canvas-to-blob/js/canvas-to-blob'), - require('jquery/fileUploader/jquery.fileupload-process') - ); - } else { - // Browser globals: - factory(window.jQuery, window.loadImage); - } -})(function ($, loadImage) { - 'use strict'; - - // Prepend to the default processQueue: - $.blueimp.fileupload.prototype.options.processQueue.unshift( - { - action: 'loadImageMetaData', - maxMetaDataSize: '@', - disableImageHead: '@', - disableMetaDataParsers: '@', - disableExif: '@', - disableExifOffsets: '@', - includeExifTags: '@', - excludeExifTags: '@', - disableIptc: '@', - disableIptcOffsets: '@', - includeIptcTags: '@', - excludeIptcTags: '@', - disabled: '@disableImageMetaDataLoad' - }, - { - action: 'loadImage', - // Use the action as prefix for the "@" options: - prefix: true, - fileTypes: '@', - maxFileSize: '@', - noRevoke: '@', - disabled: '@disableImageLoad' - }, - { - action: 'resizeImage', - // Use "image" as prefix for the "@" options: - prefix: 'image', - maxWidth: '@', - maxHeight: '@', - minWidth: '@', - minHeight: '@', - crop: '@', - orientation: '@', - forceResize: '@', - disabled: '@disableImageResize' - }, - { - action: 'saveImage', - quality: '@imageQuality', - type: '@imageType', - disabled: '@disableImageResize' - }, - { - action: 'saveImageMetaData', - disabled: '@disableImageMetaDataSave' - }, - { - action: 'resizeImage', - // Use "preview" as prefix for the "@" options: - prefix: 'preview', - maxWidth: '@', - maxHeight: '@', - minWidth: '@', - minHeight: '@', - crop: '@', - orientation: '@', - thumbnail: '@', - canvas: '@', - disabled: '@disableImagePreview' - }, - { - action: 'setImage', - name: '@imagePreviewName', - disabled: '@disableImagePreview' - }, - { - action: 'deleteImageReferences', - disabled: '@disableImageReferencesDeletion' - } - ); - - // The File Upload Resize plugin extends the fileupload widget - // with image resize functionality: - $.widget('blueimp.fileupload', $.blueimp.fileupload, { - options: { - // The regular expression for the types of images to load: - // matched against the file type: - loadImageFileTypes: /^image\/(gif|jpeg|png|svg\+xml)$/, - // The maximum file size of images to load: - loadImageMaxFileSize: 10000000, // 10MB - // The maximum width of resized images: - imageMaxWidth: 1920, - // The maximum height of resized images: - imageMaxHeight: 1080, - // Defines the image orientation (1-8) or takes the orientation - // value from Exif data if set to true: - imageOrientation: true, - // Define if resized images should be cropped or only scaled: - imageCrop: false, - // Disable the resize image functionality by default: - disableImageResize: true, - // The maximum width of the preview images: - previewMaxWidth: 80, - // The maximum height of the preview images: - previewMaxHeight: 80, - // Defines the preview orientation (1-8) or takes the orientation - // value from Exif data if set to true: - previewOrientation: true, - // Create the preview using the Exif data thumbnail: - previewThumbnail: true, - // Define if preview images should be cropped or only scaled: - previewCrop: false, - // Define if preview images should be resized as canvas elements: - previewCanvas: true - }, - - processActions: { - // Loads the image given via data.files and data.index - // as img element, if the browser supports the File API. - // Accepts the options fileTypes (regular expression) - // and maxFileSize (integer) to limit the files to load: - loadImage: function (data, options) { - if (options.disabled) { - return data; - } - var that = this, - file = data.files[data.index], - // eslint-disable-next-line new-cap - dfd = $.Deferred(); - if ( - ($.type(options.maxFileSize) === 'number' && - file.size > options.maxFileSize) || - (options.fileTypes && !options.fileTypes.test(file.type)) || - !loadImage( - file, - function (img) { - if (img.src) { - data.img = img; - } - dfd.resolveWith(that, [data]); - }, - options - ) - ) { - return data; - } - return dfd.promise(); - }, - - // Resizes the image given as data.canvas or data.img - // and updates data.canvas or data.img with the resized image. - // Also stores the resized image as preview property. - // Accepts the options maxWidth, maxHeight, minWidth, - // minHeight, canvas and crop: - resizeImage: function (data, options) { - if (options.disabled || !(data.canvas || data.img)) { - return data; - } - // eslint-disable-next-line no-param-reassign - options = $.extend({ canvas: true }, options); - var that = this, - // eslint-disable-next-line new-cap - dfd = $.Deferred(), - img = (options.canvas && data.canvas) || data.img, - resolve = function (newImg) { - if ( - newImg && - (newImg.width !== img.width || - newImg.height !== img.height || - options.forceResize) - ) { - data[newImg.getContext ? 'canvas' : 'img'] = newImg; - } - data.preview = newImg; - dfd.resolveWith(that, [data]); - }, - thumbnail, - thumbnailBlob; - if (data.exif && options.thumbnail) { - thumbnail = data.exif.get('Thumbnail'); - thumbnailBlob = thumbnail && thumbnail.get('Blob'); - if (thumbnailBlob) { - options.orientation = data.exif.get('Orientation'); - loadImage(thumbnailBlob, resolve, options); - return dfd.promise(); - } - } - if (data.orientation) { - // Prevent orienting the same image twice: - delete options.orientation; - } else { - data.orientation = options.orientation || loadImage.orientation; - } - if (img) { - resolve(loadImage.scale(img, options, data)); - return dfd.promise(); - } - return data; - }, - - // Saves the processed image given as data.canvas - // inplace at data.index of data.files: - saveImage: function (data, options) { - if (!data.canvas || options.disabled) { - return data; - } - var that = this, - file = data.files[data.index], - // eslint-disable-next-line new-cap - dfd = $.Deferred(); - if (data.canvas.toBlob) { - data.canvas.toBlob( - function (blob) { - if (!blob.name) { - if (file.type === blob.type) { - blob.name = file.name; - } else if (file.name) { - blob.name = file.name.replace( - /\.\w+$/, - '.' + blob.type.substr(6) - ); - } - } - // Don't restore invalid meta data: - if (file.type !== blob.type) { - delete data.imageHead; - } - // Store the created blob at the position - // of the original file in the files list: - data.files[data.index] = blob; - dfd.resolveWith(that, [data]); - }, - options.type || file.type, - options.quality - ); - } else { - return data; - } - return dfd.promise(); - }, - - loadImageMetaData: function (data, options) { - if (options.disabled) { - return data; - } - var that = this, - // eslint-disable-next-line new-cap - dfd = $.Deferred(); - loadImage.parseMetaData( - data.files[data.index], - function (result) { - $.extend(data, result); - dfd.resolveWith(that, [data]); - }, - options - ); - return dfd.promise(); - }, - - saveImageMetaData: function (data, options) { - if ( - !( - data.imageHead && - data.canvas && - data.canvas.toBlob && - !options.disabled - ) - ) { - return data; - } - var that = this, - file = data.files[data.index], - // eslint-disable-next-line new-cap - dfd = $.Deferred(); - if (data.orientation === true && data.exifOffsets) { - // Reset Exif Orientation data: - loadImage.writeExifData(data.imageHead, data, 'Orientation', 1); - } - loadImage.replaceHead(file, data.imageHead, function (blob) { - blob.name = file.name; - data.files[data.index] = blob; - dfd.resolveWith(that, [data]); - }); - return dfd.promise(); - }, - - // Sets the resized version of the image as a property of the - // file object, must be called after "saveImage": - setImage: function (data, options) { - if (data.preview && !options.disabled) { - data.files[data.index][options.name || 'preview'] = data.preview; - } - return data; - }, - - deleteImageReferences: function (data, options) { - if (!options.disabled) { - delete data.img; - delete data.canvas; - delete data.preview; - delete data.imageHead; - } - return data; - } - } - }); -}); diff --git a/lib/web/jquery/fileUploader/jquery.fileupload-process.js b/lib/web/jquery/fileUploader/jquery.fileupload-process.js deleted file mode 100644 index a65ee9140016..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileupload-process.js +++ /dev/null @@ -1,170 +0,0 @@ -/* - * jQuery File Upload Processing Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2012, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery', 'jquery/fileUploader/jquery.fileupload'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory(require('jquery'), require('jquery/fileUploader/jquery.fileupload')); - } else { - // Browser globals: - factory(window.jQuery); - } -})(function ($) { - 'use strict'; - - var originalAdd = $.blueimp.fileupload.prototype.options.add; - - // The File Upload Processing plugin extends the fileupload widget - // with file processing functionality: - $.widget('blueimp.fileupload', $.blueimp.fileupload, { - options: { - // The list of processing actions: - processQueue: [ - /* - { - action: 'log', - type: 'debug' - } - */ - ], - add: function (e, data) { - var $this = $(this); - data.process(function () { - return $this.fileupload('process', data); - }); - originalAdd.call(this, e, data); - } - }, - - processActions: { - /* - log: function (data, options) { - console[options.type]( - 'Processing "' + data.files[data.index].name + '"' - ); - } - */ - }, - - _processFile: function (data, originalData) { - var that = this, - // eslint-disable-next-line new-cap - dfd = $.Deferred().resolveWith(that, [data]), - chain = dfd.promise(); - this._trigger('process', null, data); - $.each(data.processQueue, function (i, settings) { - var func = function (data) { - if (originalData.errorThrown) { - // eslint-disable-next-line new-cap - return $.Deferred().rejectWith(that, [originalData]).promise(); - } - return that.processActions[settings.action].call( - that, - data, - settings - ); - }; - chain = chain[that._promisePipe](func, settings.always && func); - }); - chain - .done(function () { - that._trigger('processdone', null, data); - that._trigger('processalways', null, data); - }) - .fail(function () { - that._trigger('processfail', null, data); - that._trigger('processalways', null, data); - }); - return chain; - }, - - // Replaces the settings of each processQueue item that - // are strings starting with an "@", using the remaining - // substring as key for the option map, - // e.g. "@autoUpload" is replaced with options.autoUpload: - _transformProcessQueue: function (options) { - var processQueue = []; - $.each(options.processQueue, function () { - var settings = {}, - action = this.action, - prefix = this.prefix === true ? action : this.prefix; - $.each(this, function (key, value) { - if ($.type(value) === 'string' && value.charAt(0) === '@') { - settings[key] = - options[ - value.slice(1) || - (prefix - ? prefix + key.charAt(0).toUpperCase() + key.slice(1) - : key) - ]; - } else { - settings[key] = value; - } - }); - processQueue.push(settings); - }); - options.processQueue = processQueue; - }, - - // Returns the number of files currently in the processing queue: - processing: function () { - return this._processing; - }, - - // Processes the files given as files property of the data parameter, - // returns a Promise object that allows to bind callbacks: - process: function (data) { - var that = this, - options = $.extend({}, this.options, data); - if (options.processQueue && options.processQueue.length) { - this._transformProcessQueue(options); - if (this._processing === 0) { - this._trigger('processstart'); - } - $.each(data.files, function (index) { - var opts = index ? $.extend({}, options) : options, - func = function () { - if (data.errorThrown) { - // eslint-disable-next-line new-cap - return $.Deferred().rejectWith(that, [data]).promise(); - } - return that._processFile(opts, data); - }; - opts.index = index; - that._processing += 1; - that._processingQueue = that._processingQueue[that._promisePipe]( - func, - func - ).always(function () { - that._processing -= 1; - if (that._processing === 0) { - that._trigger('processstop'); - } - }); - }); - } - return this._processingQueue; - }, - - _create: function () { - this._super(); - this._processing = 0; - // eslint-disable-next-line new-cap - this._processingQueue = $.Deferred().resolveWith(this).promise(); - } - }); -}); diff --git a/lib/web/jquery/fileUploader/jquery.fileupload-ui.js b/lib/web/jquery/fileUploader/jquery.fileupload-ui.js deleted file mode 100644 index a4665f8392fe..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileupload-ui.js +++ /dev/null @@ -1,759 +0,0 @@ -/* - * jQuery File Upload User Interface Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2010, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define([ - 'jquery', - 'jquery/fileUploader/vendor/blueimp-tmpl/js/tmpl', - 'jquery/fileUploader/jquery.fileupload-image', - 'jquery/fileUploader/jquery.fileupload-audio', - 'jquery/fileUploader/jquery.fileupload-video', - 'jquery/fileUploader/jquery.fileupload-validate' - ], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory( - require('jquery'), - require('jquery/fileUploader/vendor/blueimp-tmpl/js/tmpl'), - require('jquery/fileUploader/jquery.fileupload-image'), - require('jquery/fileUploader/jquery.fileupload-audio'), - require('jquery/fileUploader/jquery.fileupload-video'), - require('jquery/fileUploader/jquery.fileupload-validate') - ); - } else { - // Browser globals: - factory(window.jQuery, window.tmpl); - } -})(function ($, tmpl) { - 'use strict'; - - $.blueimp.fileupload.prototype._specialOptions.push( - 'filesContainer', - 'uploadTemplateId', - 'downloadTemplateId' - ); - - // The UI version extends the file upload widget - // and adds complete user interface interaction: - $.widget('blueimp.fileupload', $.blueimp.fileupload, { - options: { - // By default, files added to the widget are uploaded as soon - // as the user clicks on the start buttons. To enable automatic - // uploads, set the following option to true: - autoUpload: false, - // The class to show/hide UI elements: - showElementClass: 'in', - // The ID of the upload template: - uploadTemplateId: 'template-upload', - // The ID of the download template: - downloadTemplateId: 'template-download', - // The container for the list of files. If undefined, it is set to - // an element with class "files" inside of the widget element: - filesContainer: undefined, - // By default, files are appended to the files container. - // Set the following option to true, to prepend files instead: - prependFiles: false, - // The expected data type of the upload response, sets the dataType - // option of the $.ajax upload requests: - dataType: 'json', - - // Error and info messages: - messages: { - unknownError: 'Unknown error' - }, - - // Function returning the current number of files, - // used by the maxNumberOfFiles validation: - getNumberOfFiles: function () { - return this.filesContainer.children().not('.processing').length; - }, - - // Callback to retrieve the list of files from the server response: - getFilesFromResponse: function (data) { - if (data.result && $.isArray(data.result.files)) { - return data.result.files; - } - return []; - }, - - // The add callback is invoked as soon as files are added to the fileupload - // widget (via file input selection, drag & drop or add API call). - // See the basic file upload widget for more information: - add: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var $this = $(this), - that = $this.data('blueimp-fileupload') || $this.data('fileupload'), - options = that.options; - data.context = that - ._renderUpload(data.files) - .data('data', data) - .addClass('processing'); - options.filesContainer[options.prependFiles ? 'prepend' : 'append']( - data.context - ); - that._forceReflow(data.context); - that._transition(data.context); - data - .process(function () { - return $this.fileupload('process', data); - }) - .always(function () { - data.context - .each(function (index) { - $(this) - .find('.size') - .text(that._formatFileSize(data.files[index].size)); - }) - .removeClass('processing'); - that._renderPreviews(data); - }) - .done(function () { - data.context.find('.edit,.start').prop('disabled', false); - if ( - that._trigger('added', e, data) !== false && - (options.autoUpload || data.autoUpload) && - data.autoUpload !== false - ) { - data.submit(); - } - }) - .fail(function () { - if (data.files.error) { - data.context.each(function (index) { - var error = data.files[index].error; - if (error) { - $(this).find('.error').text(error); - } - }); - } - }); - }, - // Callback for the start of each file upload request: - send: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var that = - $(this).data('blueimp-fileupload') || $(this).data('fileupload'); - if ( - data.context && - data.dataType && - data.dataType.substr(0, 6) === 'iframe' - ) { - // Iframe Transport does not support progress events. - // In lack of an indeterminate progress bar, we set - // the progress to 100%, showing the full animated bar: - data.context - .find('.progress') - .addClass(!$.support.transition && 'progress-animated') - .attr('aria-valuenow', 100) - .children() - .first() - .css('width', '100%'); - } - return that._trigger('sent', e, data); - }, - // Callback for successful uploads: - done: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var that = - $(this).data('blueimp-fileupload') || $(this).data('fileupload'), - getFilesFromResponse = - data.getFilesFromResponse || that.options.getFilesFromResponse, - files = getFilesFromResponse(data), - template, - deferred; - if (data.context) { - data.context.each(function (index) { - var file = files[index] || { error: 'Empty file upload result' }; - deferred = that._addFinishedDeferreds(); - that._transition($(this)).done(function () { - var node = $(this); - template = that._renderDownload([file]).replaceAll(node); - that._forceReflow(template); - that._transition(template).done(function () { - data.context = $(this); - that._trigger('completed', e, data); - that._trigger('finished', e, data); - deferred.resolve(); - }); - }); - }); - } else { - template = that - ._renderDownload(files) - [that.options.prependFiles ? 'prependTo' : 'appendTo']( - that.options.filesContainer - ); - that._forceReflow(template); - deferred = that._addFinishedDeferreds(); - that._transition(template).done(function () { - data.context = $(this); - that._trigger('completed', e, data); - that._trigger('finished', e, data); - deferred.resolve(); - }); - } - }, - // Callback for failed (abort or error) uploads: - fail: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var that = - $(this).data('blueimp-fileupload') || $(this).data('fileupload'), - template, - deferred; - if (data.context) { - data.context.each(function (index) { - if (data.errorThrown !== 'abort') { - var file = data.files[index]; - file.error = - file.error || data.errorThrown || data.i18n('unknownError'); - deferred = that._addFinishedDeferreds(); - that._transition($(this)).done(function () { - var node = $(this); - template = that._renderDownload([file]).replaceAll(node); - that._forceReflow(template); - that._transition(template).done(function () { - data.context = $(this); - that._trigger('failed', e, data); - that._trigger('finished', e, data); - deferred.resolve(); - }); - }); - } else { - deferred = that._addFinishedDeferreds(); - that._transition($(this)).done(function () { - $(this).remove(); - that._trigger('failed', e, data); - that._trigger('finished', e, data); - deferred.resolve(); - }); - } - }); - } else if (data.errorThrown !== 'abort') { - data.context = that - ._renderUpload(data.files) - [that.options.prependFiles ? 'prependTo' : 'appendTo']( - that.options.filesContainer - ) - .data('data', data); - that._forceReflow(data.context); - deferred = that._addFinishedDeferreds(); - that._transition(data.context).done(function () { - data.context = $(this); - that._trigger('failed', e, data); - that._trigger('finished', e, data); - deferred.resolve(); - }); - } else { - that._trigger('failed', e, data); - that._trigger('finished', e, data); - that._addFinishedDeferreds().resolve(); - } - }, - // Callback for upload progress events: - progress: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var progress = Math.floor((data.loaded / data.total) * 100); - if (data.context) { - data.context.each(function () { - $(this) - .find('.progress') - .attr('aria-valuenow', progress) - .children() - .first() - .css('width', progress + '%'); - }); - } - }, - // Callback for global upload progress events: - progressall: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var $this = $(this), - progress = Math.floor((data.loaded / data.total) * 100), - globalProgressNode = $this.find('.fileupload-progress'), - extendedProgressNode = globalProgressNode.find('.progress-extended'); - if (extendedProgressNode.length) { - extendedProgressNode.html( - ( - $this.data('blueimp-fileupload') || $this.data('fileupload') - )._renderExtendedProgress(data) - ); - } - globalProgressNode - .find('.progress') - .attr('aria-valuenow', progress) - .children() - .first() - .css('width', progress + '%'); - }, - // Callback for uploads start, equivalent to the global ajaxStart event: - start: function (e) { - if (e.isDefaultPrevented()) { - return false; - } - var that = - $(this).data('blueimp-fileupload') || $(this).data('fileupload'); - that._resetFinishedDeferreds(); - that - ._transition($(this).find('.fileupload-progress')) - .done(function () { - that._trigger('started', e); - }); - }, - // Callback for uploads stop, equivalent to the global ajaxStop event: - stop: function (e) { - if (e.isDefaultPrevented()) { - return false; - } - var that = - $(this).data('blueimp-fileupload') || $(this).data('fileupload'), - deferred = that._addFinishedDeferreds(); - $.when.apply($, that._getFinishedDeferreds()).done(function () { - that._trigger('stopped', e); - }); - that - ._transition($(this).find('.fileupload-progress')) - .done(function () { - $(this) - .find('.progress') - .attr('aria-valuenow', '0') - .children() - .first() - .css('width', '0%'); - $(this).find('.progress-extended').html(' '); - deferred.resolve(); - }); - }, - processstart: function (e) { - if (e.isDefaultPrevented()) { - return false; - } - $(this).addClass('fileupload-processing'); - }, - processstop: function (e) { - if (e.isDefaultPrevented()) { - return false; - } - $(this).removeClass('fileupload-processing'); - }, - // Callback for file deletion: - destroy: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var that = - $(this).data('blueimp-fileupload') || $(this).data('fileupload'), - removeNode = function () { - that._transition(data.context).done(function () { - $(this).remove(); - that._trigger('destroyed', e, data); - }); - }; - if (data.url) { - data.dataType = data.dataType || that.options.dataType; - $.ajax(data) - .done(removeNode) - .fail(function () { - that._trigger('destroyfailed', e, data); - }); - } else { - removeNode(); - } - } - }, - - _resetFinishedDeferreds: function () { - this._finishedUploads = []; - }, - - _addFinishedDeferreds: function (deferred) { - // eslint-disable-next-line new-cap - var promise = deferred || $.Deferred(); - this._finishedUploads.push(promise); - return promise; - }, - - _getFinishedDeferreds: function () { - return this._finishedUploads; - }, - - // Link handler, that allows to download files - // by drag & drop of the links to the desktop: - _enableDragToDesktop: function () { - var link = $(this), - url = link.prop('href'), - name = link.prop('download'), - type = 'application/octet-stream'; - link.on('dragstart', function (e) { - try { - e.originalEvent.dataTransfer.setData( - 'DownloadURL', - [type, name, url].join(':') - ); - } catch (ignore) { - // Ignore exceptions - } - }); - }, - - _formatFileSize: function (bytes) { - if (typeof bytes !== 'number') { - return ''; - } - if (bytes >= 1000000000) { - return (bytes / 1000000000).toFixed(2) + ' GB'; - } - if (bytes >= 1000000) { - return (bytes / 1000000).toFixed(2) + ' MB'; - } - return (bytes / 1000).toFixed(2) + ' KB'; - }, - - _formatBitrate: function (bits) { - if (typeof bits !== 'number') { - return ''; - } - if (bits >= 1000000000) { - return (bits / 1000000000).toFixed(2) + ' Gbit/s'; - } - if (bits >= 1000000) { - return (bits / 1000000).toFixed(2) + ' Mbit/s'; - } - if (bits >= 1000) { - return (bits / 1000).toFixed(2) + ' kbit/s'; - } - return bits.toFixed(2) + ' bit/s'; - }, - - _formatTime: function (seconds) { - var date = new Date(seconds * 1000), - days = Math.floor(seconds / 86400); - days = days ? days + 'd ' : ''; - return ( - days + - ('0' + date.getUTCHours()).slice(-2) + - ':' + - ('0' + date.getUTCMinutes()).slice(-2) + - ':' + - ('0' + date.getUTCSeconds()).slice(-2) - ); - }, - - _formatPercentage: function (floatValue) { - return (floatValue * 100).toFixed(2) + ' %'; - }, - - _renderExtendedProgress: function (data) { - return ( - this._formatBitrate(data.bitrate) + - ' | ' + - this._formatTime(((data.total - data.loaded) * 8) / data.bitrate) + - ' | ' + - this._formatPercentage(data.loaded / data.total) + - ' | ' + - this._formatFileSize(data.loaded) + - ' / ' + - this._formatFileSize(data.total) - ); - }, - - _renderTemplate: function (func, files) { - if (!func) { - return $(); - } - var result = func({ - files: files, - formatFileSize: this._formatFileSize, - options: this.options - }); - if (result instanceof $) { - return result; - } - return $(this.options.templatesContainer).html(result).children(); - }, - - _renderPreviews: function (data) { - data.context.find('.preview').each(function (index, elm) { - $(elm).empty().append(data.files[index].preview); - }); - }, - - _renderUpload: function (files) { - return this._renderTemplate(this.options.uploadTemplate, files); - }, - - _renderDownload: function (files) { - return this._renderTemplate(this.options.downloadTemplate, files) - .find('a[download]') - .each(this._enableDragToDesktop) - .end(); - }, - - _editHandler: function (e) { - e.preventDefault(); - if (!this.options.edit) return; - var that = this, - button = $(e.currentTarget), - template = button.closest('.template-upload'), - data = template.data('data'), - index = button.data().index; - this.options.edit(data.files[index]).then(function (file) { - if (!file) return; - data.files[index] = file; - data.context.addClass('processing'); - template.find('.edit,.start').prop('disabled', true); - $(that.element) - .fileupload('process', data) - .always(function () { - template - .find('.size') - .text(that._formatFileSize(data.files[index].size)); - data.context.removeClass('processing'); - that._renderPreviews(data); - }) - .done(function () { - template.find('.edit,.start').prop('disabled', false); - }) - .fail(function () { - template.find('.edit').prop('disabled', false); - var error = data.files[index].error; - if (error) { - template.find('.error').text(error); - } - }); - }); - }, - - _startHandler: function (e) { - e.preventDefault(); - var button = $(e.currentTarget), - template = button.closest('.template-upload'), - data = template.data('data'); - button.prop('disabled', true); - if (data && data.submit) { - data.submit(); - } - }, - - _cancelHandler: function (e) { - e.preventDefault(); - var template = $(e.currentTarget).closest( - '.template-upload,.template-download' - ), - data = template.data('data') || {}; - data.context = data.context || template; - if (data.abort) { - data.abort(); - } else { - data.errorThrown = 'abort'; - this._trigger('fail', e, data); - } - }, - - _deleteHandler: function (e) { - e.preventDefault(); - var button = $(e.currentTarget); - this._trigger( - 'destroy', - e, - $.extend( - { - context: button.closest('.template-download'), - type: 'DELETE' - }, - button.data() - ) - ); - }, - - _forceReflow: function (node) { - return $.support.transition && node.length && node[0].offsetWidth; - }, - - _transition: function (node) { - // eslint-disable-next-line new-cap - var dfd = $.Deferred(); - if ( - $.support.transition && - node.hasClass('fade') && - node.is(':visible') - ) { - var transitionEndHandler = function (e) { - // Make sure we don't respond to other transition events - // in the container element, e.g. from button elements: - if (e.target === node[0]) { - node.off($.support.transition.end, transitionEndHandler); - dfd.resolveWith(node); - } - }; - node - .on($.support.transition.end, transitionEndHandler) - .toggleClass(this.options.showElementClass); - } else { - node.toggleClass(this.options.showElementClass); - dfd.resolveWith(node); - } - return dfd; - }, - - _initButtonBarEventHandlers: function () { - var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'), - filesList = this.options.filesContainer; - this._on(fileUploadButtonBar.find('.start'), { - click: function (e) { - e.preventDefault(); - filesList.find('.start').trigger('click'); - } - }); - this._on(fileUploadButtonBar.find('.cancel'), { - click: function (e) { - e.preventDefault(); - filesList.find('.cancel').trigger('click'); - } - }); - this._on(fileUploadButtonBar.find('.delete'), { - click: function (e) { - e.preventDefault(); - filesList - .find('.toggle:checked') - .closest('.template-download') - .find('.delete') - .trigger('click'); - fileUploadButtonBar.find('.toggle').prop('checked', false); - } - }); - this._on(fileUploadButtonBar.find('.toggle'), { - change: function (e) { - filesList - .find('.toggle') - .prop('checked', $(e.currentTarget).is(':checked')); - } - }); - }, - - _destroyButtonBarEventHandlers: function () { - this._off( - this.element - .find('.fileupload-buttonbar') - .find('.start, .cancel, .delete'), - 'click' - ); - this._off(this.element.find('.fileupload-buttonbar .toggle'), 'change.'); - }, - - _initEventHandlers: function () { - this._super(); - this._on(this.options.filesContainer, { - 'click .edit': this._editHandler, - 'click .start': this._startHandler, - 'click .cancel': this._cancelHandler, - 'click .delete': this._deleteHandler - }); - this._initButtonBarEventHandlers(); - }, - - _destroyEventHandlers: function () { - this._destroyButtonBarEventHandlers(); - this._off(this.options.filesContainer, 'click'); - this._super(); - }, - - _enableFileInputButton: function () { - this.element - .find('.fileinput-button input') - .prop('disabled', false) - .parent() - .removeClass('disabled'); - }, - - _disableFileInputButton: function () { - this.element - .find('.fileinput-button input') - .prop('disabled', true) - .parent() - .addClass('disabled'); - }, - - _initTemplates: function () { - var options = this.options; - options.templatesContainer = this.document[0].createElement( - options.filesContainer.prop('nodeName') - ); - if (tmpl) { - if (options.uploadTemplateId) { - options.uploadTemplate = tmpl(options.uploadTemplateId); - } - if (options.downloadTemplateId) { - options.downloadTemplate = tmpl(options.downloadTemplateId); - } - } - }, - - _initFilesContainer: function () { - var options = this.options; - if (options.filesContainer === undefined) { - options.filesContainer = this.element.find('.files'); - } else if (!(options.filesContainer instanceof $)) { - options.filesContainer = $(options.filesContainer); - } - }, - - _initSpecialOptions: function () { - this._super(); - this._initFilesContainer(); - // this._initTemplates(); - }, - - _create: function () { - this._super(); - this._resetFinishedDeferreds(); - if (!$.support.fileInput) { - this._disableFileInputButton(); - } - }, - - enable: function () { - var wasDisabled = false; - if (this.options.disabled) { - wasDisabled = true; - } - this._super(); - if (wasDisabled) { - this.element.find('input, button').prop('disabled', false); - this._enableFileInputButton(); - } - }, - - disable: function () { - if (!this.options.disabled) { - this.element.find('input, button').prop('disabled', true); - this._disableFileInputButton(); - } - this._super(); - } - }); -}); diff --git a/lib/web/jquery/fileUploader/jquery.fileupload-validate.js b/lib/web/jquery/fileUploader/jquery.fileupload-validate.js deleted file mode 100644 index d23e0f4a24ef..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileupload-validate.js +++ /dev/null @@ -1,119 +0,0 @@ -/* - * jQuery File Upload Validation Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery', 'jquery/fileUploader/jquery.fileupload-process'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory(require('jquery'), require('jquery/fileUploader/jquery.fileupload-process')); - } else { - // Browser globals: - factory(window.jQuery); - } -})(function ($) { - 'use strict'; - - // Append to the default processQueue: - $.blueimp.fileupload.prototype.options.processQueue.push({ - action: 'validate', - // Always trigger this action, - // even if the previous action was rejected: - always: true, - // Options taken from the global options map: - acceptFileTypes: '@', - maxFileSize: '@', - minFileSize: '@', - maxNumberOfFiles: '@', - disabled: '@disableValidation' - }); - - // The File Upload Validation plugin extends the fileupload widget - // with file validation functionality: - $.widget('blueimp.fileupload', $.blueimp.fileupload, { - options: { - /* - // The regular expression for allowed file types, matches - // against either file type or file name: - acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, - // The maximum allowed file size in bytes: - maxFileSize: 10000000, // 10 MB - // The minimum allowed file size in bytes: - minFileSize: undefined, // No minimal file size - // The limit of files to be uploaded: - maxNumberOfFiles: 10, - */ - - // Function returning the current number of files, - // has to be overridden for maxNumberOfFiles validation: - getNumberOfFiles: $.noop, - - // Error and info messages: - messages: { - maxNumberOfFiles: 'Maximum number of files exceeded', - acceptFileTypes: 'File type not allowed', - maxFileSize: 'File is too large', - minFileSize: 'File is too small' - } - }, - - processActions: { - validate: function (data, options) { - if (options.disabled) { - return data; - } - // eslint-disable-next-line new-cap - var dfd = $.Deferred(), - settings = this.options, - file = data.files[data.index], - fileSize; - if (options.minFileSize || options.maxFileSize) { - fileSize = file.size; - } - if ( - $.type(options.maxNumberOfFiles) === 'number' && - (settings.getNumberOfFiles() || 0) + data.files.length > - options.maxNumberOfFiles - ) { - file.error = settings.i18n('maxNumberOfFiles'); - } else if ( - options.acceptFileTypes && - !( - options.acceptFileTypes.test(file.type) || - options.acceptFileTypes.test(file.name) - ) - ) { - file.error = settings.i18n('acceptFileTypes'); - } else if (fileSize > options.maxFileSize) { - file.error = settings.i18n('maxFileSize'); - } else if ( - $.type(fileSize) === 'number' && - fileSize < options.minFileSize - ) { - file.error = settings.i18n('minFileSize'); - } else { - delete file.error; - } - if (file.error || data.files.error) { - data.files.error = true; - dfd.rejectWith(this, [data]); - } else { - dfd.resolveWith(this, [data]); - } - return dfd.promise(); - } - } - }); -}); diff --git a/lib/web/jquery/fileUploader/jquery.fileupload-video.js b/lib/web/jquery/fileUploader/jquery.fileupload-video.js deleted file mode 100644 index bf247f38280a..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileupload-video.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * jQuery File Upload Video Preview Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/jquery.fileupload-process'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory( - require('jquery'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), - require('jquery/fileUploader/jquery.fileupload-process') - ); - } else { - // Browser globals: - factory(window.jQuery, window.loadImage); - } -})(function ($, loadImage) { - 'use strict'; - - // Prepend to the default processQueue: - $.blueimp.fileupload.prototype.options.processQueue.unshift( - { - action: 'loadVideo', - // Use the action as prefix for the "@" options: - prefix: true, - fileTypes: '@', - maxFileSize: '@', - disabled: '@disableVideoPreview' - }, - { - action: 'setVideo', - name: '@videoPreviewName', - disabled: '@disableVideoPreview' - } - ); - - // The File Upload Video Preview plugin extends the fileupload widget - // with video preview functionality: - $.widget('blueimp.fileupload', $.blueimp.fileupload, { - options: { - // The regular expression for the types of video files to load, - // matched against the file type: - loadVideoFileTypes: /^video\/.*$/ - }, - - _videoElement: document.createElement('video'), - - processActions: { - // Loads the video file given via data.files and data.index - // as video element if the browser supports playing it. - // Accepts the options fileTypes (regular expression) - // and maxFileSize (integer) to limit the files to load: - loadVideo: function (data, options) { - if (options.disabled) { - return data; - } - var file = data.files[data.index], - url, - video; - if ( - this._videoElement.canPlayType && - this._videoElement.canPlayType(file.type) && - ($.type(options.maxFileSize) !== 'number' || - file.size <= options.maxFileSize) && - (!options.fileTypes || options.fileTypes.test(file.type)) - ) { - url = loadImage.createObjectURL(file); - if (url) { - video = this._videoElement.cloneNode(false); - video.src = url; - video.controls = true; - data.video = video; - return data; - } - } - return data; - }, - - // Sets the video element as a property of the file object: - setVideo: function (data, options) { - if (data.video && !options.disabled) { - data.files[data.index][options.name || 'preview'] = data.video; - } - return data; - } - } - }); -}); diff --git a/lib/web/jquery/fileUploader/jquery.fileupload.js b/lib/web/jquery/fileUploader/jquery.fileupload.js deleted file mode 100644 index 48e836e91c12..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileupload.js +++ /dev/null @@ -1,1604 +0,0 @@ -/* - * jQuery File Upload Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2010, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ -/* eslint-disable new-cap */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery', 'jquery/fileUploader/vendor/jquery.ui.widget'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory(require('jquery'), require('jquery/fileUploader/vendor/jquery.ui.widget')); - } else { - // Browser globals: - factory(window.jQuery); - } -})(function ($) { - 'use strict'; - - // Detect file input support, based on - // https://viljamis.com/2012/file-upload-support-on-mobile/ - $.support.fileInput = !( - new RegExp( - // Handle devices which give false positives for the feature detection: - '(Android (1\\.[0156]|2\\.[01]))' + - '|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' + - '|(w(eb)?OSBrowser)|(webOS)' + - '|(Kindle/(1\\.0|2\\.[05]|3\\.0))' - ).test(window.navigator.userAgent) || - // Feature detection for all other devices: - $('').prop('disabled') - ); - - // The FileReader API is not actually used, but works as feature detection, - // as some Safari versions (5?) support XHR file uploads via the FormData API, - // but not non-multipart XHR file uploads. - // window.XMLHttpRequestUpload is not available on IE10, so we check for - // window.ProgressEvent instead to detect XHR2 file upload capability: - $.support.xhrFileUpload = !!(window.ProgressEvent && window.FileReader); - $.support.xhrFormDataFileUpload = !!window.FormData; - - // Detect support for Blob slicing (required for chunked uploads): - $.support.blobSlice = - window.Blob && - (Blob.prototype.slice || - Blob.prototype.webkitSlice || - Blob.prototype.mozSlice); - - /** - * Helper function to create drag handlers for dragover/dragenter/dragleave - * - * @param {string} type Event type - * @returns {Function} Drag handler - */ - function getDragHandler(type) { - var isDragOver = type === 'dragover'; - return function (e) { - e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; - var dataTransfer = e.dataTransfer; - if ( - dataTransfer && - $.inArray('Files', dataTransfer.types) !== -1 && - this._trigger(type, $.Event(type, { delegatedEvent: e })) !== false - ) { - e.preventDefault(); - if (isDragOver) { - dataTransfer.dropEffect = 'copy'; - } - } - }; - } - - // The fileupload widget listens for change events on file input fields defined - // via fileInput setting and paste or drop events of the given dropZone. - // In addition to the default jQuery Widget methods, the fileupload widget - // exposes the "add" and "send" methods, to add or directly send files using - // the fileupload API. - // By default, files added via file input selection, paste, drag & drop or - // "add" method are uploaded immediately, but it is possible to override - // the "add" callback option to queue file uploads. - $.widget('blueimp.fileupload', { - options: { - // The drop target element(s), by the default the complete document. - // Set to null to disable drag & drop support: - dropZone: $(document), - // The paste target element(s), by the default undefined. - // Set to a DOM node or jQuery object to enable file pasting: - pasteZone: undefined, - // The file input field(s), that are listened to for change events. - // If undefined, it is set to the file input fields inside - // of the widget element on plugin initialization. - // Set to null to disable the change listener. - fileInput: undefined, - // By default, the file input field is replaced with a clone after - // each input field change event. This is required for iframe transport - // queues and allows change events to be fired for the same file - // selection, but can be disabled by setting the following option to false: - replaceFileInput: true, - // The parameter name for the file form data (the request argument name). - // If undefined or empty, the name property of the file input field is - // used, or "files[]" if the file input name property is also empty, - // can be a string or an array of strings: - paramName: undefined, - // By default, each file of a selection is uploaded using an individual - // request for XHR type uploads. Set to false to upload file - // selections in one request each: - singleFileUploads: true, - // To limit the number of files uploaded with one XHR request, - // set the following option to an integer greater than 0: - limitMultiFileUploads: undefined, - // The following option limits the number of files uploaded with one - // XHR request to keep the request size under or equal to the defined - // limit in bytes: - limitMultiFileUploadSize: undefined, - // Multipart file uploads add a number of bytes to each uploaded file, - // therefore the following option adds an overhead for each file used - // in the limitMultiFileUploadSize configuration: - limitMultiFileUploadSizeOverhead: 512, - // Set the following option to true to issue all file upload requests - // in a sequential order: - sequentialUploads: false, - // To limit the number of concurrent uploads, - // set the following option to an integer greater than 0: - limitConcurrentUploads: undefined, - // Set the following option to true to force iframe transport uploads: - forceIframeTransport: false, - // Set the following option to the location of a redirect url on the - // origin server, for cross-domain iframe transport uploads: - redirect: undefined, - // The parameter name for the redirect url, sent as part of the form - // data and set to 'redirect' if this option is empty: - redirectParamName: undefined, - // Set the following option to the location of a postMessage window, - // to enable postMessage transport uploads: - postMessage: undefined, - // By default, XHR file uploads are sent as multipart/form-data. - // The iframe transport is always using multipart/form-data. - // Set to false to enable non-multipart XHR uploads: - multipart: true, - // To upload large files in smaller chunks, set the following option - // to a preferred maximum chunk size. If set to 0, null or undefined, - // or the browser does not support the required Blob API, files will - // be uploaded as a whole. - maxChunkSize: undefined, - // When a non-multipart upload or a chunked multipart upload has been - // aborted, this option can be used to resume the upload by setting - // it to the size of the already uploaded bytes. This option is most - // useful when modifying the options object inside of the "add" or - // "send" callbacks, as the options are cloned for each file upload. - uploadedBytes: undefined, - // By default, failed (abort or error) file uploads are removed from the - // global progress calculation. Set the following option to false to - // prevent recalculating the global progress data: - recalculateProgress: true, - // Interval in milliseconds to calculate and trigger progress events: - progressInterval: 100, - // Interval in milliseconds to calculate progress bitrate: - bitrateInterval: 500, - // By default, uploads are started automatically when adding files: - autoUpload: true, - // By default, duplicate file names are expected to be handled on - // the server-side. If this is not possible (e.g. when uploading - // files directly to Amazon S3), the following option can be set to - // an empty object or an object mapping existing filenames, e.g.: - // { "image.jpg": true, "image (1).jpg": true } - // If it is set, all files will be uploaded with unique filenames, - // adding increasing number suffixes if necessary, e.g.: - // "image (2).jpg" - uniqueFilenames: undefined, - - // Error and info messages: - messages: { - uploadedBytes: 'Uploaded bytes exceed file size' - }, - - // Translation function, gets the message key to be translated - // and an object with context specific data as arguments: - i18n: function (message, context) { - // eslint-disable-next-line no-param-reassign - message = this.messages[message] || message.toString(); - if (context) { - $.each(context, function (key, value) { - // eslint-disable-next-line no-param-reassign - message = message.replace('{' + key + '}', value); - }); - } - return message; - }, - - // Additional form data to be sent along with the file uploads can be set - // using this option, which accepts an array of objects with name and - // value properties, a function returning such an array, a FormData - // object (for XHR file uploads), or a simple object. - // The form of the first fileInput is given as parameter to the function: - formData: function (form) { - return form.serializeArray(); - }, - - // The add callback is invoked as soon as files are added to the fileupload - // widget (via file input selection, drag & drop, paste or add API call). - // If the singleFileUploads option is enabled, this callback will be - // called once for each file in the selection for XHR file uploads, else - // once for each file selection. - // - // The upload starts when the submit method is invoked on the data parameter. - // The data object contains a files property holding the added files - // and allows you to override plugin options as well as define ajax settings. - // - // Listeners for this callback can also be bound the following way: - // .on('fileuploadadd', func); - // - // data.submit() returns a Promise object and allows to attach additional - // handlers using jQuery's Deferred callbacks: - // data.submit().done(func).fail(func).always(func); - add: function (e, data) { - if (e.isDefaultPrevented()) { - return false; - } - if ( - data.autoUpload || - (data.autoUpload !== false && - $(this).fileupload('option', 'autoUpload')) - ) { - data.process().done(function () { - data.submit(); - }); - } - }, - - // Other callbacks: - - // Callback for the submit event of each file upload: - // submit: function (e, data) {}, // .on('fileuploadsubmit', func); - - // Callback for the start of each file upload request: - // send: function (e, data) {}, // .on('fileuploadsend', func); - - // Callback for successful uploads: - // done: function (e, data) {}, // .on('fileuploaddone', func); - - // Callback for failed (abort or error) uploads: - // fail: function (e, data) {}, // .on('fileuploadfail', func); - - // Callback for completed (success, abort or error) requests: - // always: function (e, data) {}, // .on('fileuploadalways', func); - - // Callback for upload progress events: - // progress: function (e, data) {}, // .on('fileuploadprogress', func); - - // Callback for global upload progress events: - // progressall: function (e, data) {}, // .on('fileuploadprogressall', func); - - // Callback for uploads start, equivalent to the global ajaxStart event: - // start: function (e) {}, // .on('fileuploadstart', func); - - // Callback for uploads stop, equivalent to the global ajaxStop event: - // stop: function (e) {}, // .on('fileuploadstop', func); - - // Callback for change events of the fileInput(s): - // change: function (e, data) {}, // .on('fileuploadchange', func); - - // Callback for paste events to the pasteZone(s): - // paste: function (e, data) {}, // .on('fileuploadpaste', func); - - // Callback for drop events of the dropZone(s): - // drop: function (e, data) {}, // .on('fileuploaddrop', func); - - // Callback for dragover events of the dropZone(s): - // dragover: function (e) {}, // .on('fileuploaddragover', func); - - // Callback before the start of each chunk upload request (before form data initialization): - // chunkbeforesend: function (e, data) {}, // .on('fileuploadchunkbeforesend', func); - - // Callback for the start of each chunk upload request: - // chunksend: function (e, data) {}, // .on('fileuploadchunksend', func); - - // Callback for successful chunk uploads: - // chunkdone: function (e, data) {}, // .on('fileuploadchunkdone', func); - - // Callback for failed (abort or error) chunk uploads: - // chunkfail: function (e, data) {}, // .on('fileuploadchunkfail', func); - - // Callback for completed (success, abort or error) chunk upload requests: - // chunkalways: function (e, data) {}, // .on('fileuploadchunkalways', func); - - // The plugin options are used as settings object for the ajax calls. - // The following are jQuery ajax settings required for the file uploads: - processData: false, - contentType: false, - cache: false, - timeout: 0 - }, - - // jQuery versions before 1.8 require promise.pipe if the return value is - // used, as promise.then in older versions has a different behavior, see: - // https://blog.jquery.com/2012/08/09/jquery-1-8-released/ - // https://bugs.jquery.com/ticket/11010 - // https://github.com/blueimp/jQuery-File-Upload/pull/3435 - _promisePipe: (function () { - var parts = $.fn.jquery.split('.'); - return Number(parts[0]) > 1 || Number(parts[1]) > 7 ? 'then' : 'pipe'; - })(), - - // A list of options that require reinitializing event listeners and/or - // special initialization code: - _specialOptions: [ - 'fileInput', - 'dropZone', - 'pasteZone', - 'multipart', - 'forceIframeTransport' - ], - - _blobSlice: - $.support.blobSlice && - function () { - var slice = this.slice || this.webkitSlice || this.mozSlice; - return slice.apply(this, arguments); - }, - - _BitrateTimer: function () { - this.timestamp = Date.now ? Date.now() : new Date().getTime(); - this.loaded = 0; - this.bitrate = 0; - this.getBitrate = function (now, loaded, interval) { - var timeDiff = now - this.timestamp; - if (!this.bitrate || !interval || timeDiff > interval) { - this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8; - this.loaded = loaded; - this.timestamp = now; - } - return this.bitrate; - }; - }, - - _isXHRUpload: function (options) { - return ( - !options.forceIframeTransport && - ((!options.multipart && $.support.xhrFileUpload) || - $.support.xhrFormDataFileUpload) - ); - }, - - _getFormData: function (options) { - var formData; - if ($.type(options.formData) === 'function') { - return options.formData(options.form); - } - if ($.isArray(options.formData)) { - return options.formData; - } - if ($.type(options.formData) === 'object') { - formData = []; - $.each(options.formData, function (name, value) { - formData.push({ name: name, value: value }); - }); - return formData; - } - return []; - }, - - _getTotal: function (files) { - var total = 0; - $.each(files, function (index, file) { - total += file.size || 1; - }); - return total; - }, - - _initProgressObject: function (obj) { - var progress = { - loaded: 0, - total: 0, - bitrate: 0 - }; - if (obj._progress) { - $.extend(obj._progress, progress); - } else { - obj._progress = progress; - } - }, - - _initResponseObject: function (obj) { - var prop; - if (obj._response) { - for (prop in obj._response) { - if (Object.prototype.hasOwnProperty.call(obj._response, prop)) { - delete obj._response[prop]; - } - } - } else { - obj._response = {}; - } - }, - - _onProgress: function (e, data) { - if (e.lengthComputable) { - var now = Date.now ? Date.now() : new Date().getTime(), - loaded; - if ( - data._time && - data.progressInterval && - now - data._time < data.progressInterval && - e.loaded !== e.total - ) { - return; - } - data._time = now; - loaded = - Math.floor( - (e.loaded / e.total) * (data.chunkSize || data._progress.total) - ) + (data.uploadedBytes || 0); - // Add the difference from the previously loaded state - // to the global loaded counter: - this._progress.loaded += loaded - data._progress.loaded; - this._progress.bitrate = this._bitrateTimer.getBitrate( - now, - this._progress.loaded, - data.bitrateInterval - ); - data._progress.loaded = data.loaded = loaded; - data._progress.bitrate = data.bitrate = data._bitrateTimer.getBitrate( - now, - loaded, - data.bitrateInterval - ); - // Trigger a custom progress event with a total data property set - // to the file size(s) of the current upload and a loaded data - // property calculated accordingly: - this._trigger( - 'progress', - $.Event('progress', { delegatedEvent: e }), - data - ); - // Trigger a global progress event for all current file uploads, - // including ajax calls queued for sequential file uploads: - this._trigger( - 'progressall', - $.Event('progressall', { delegatedEvent: e }), - this._progress - ); - } - }, - - _initProgressListener: function (options) { - var that = this, - xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); - // Access to the native XHR object is required to add event listeners - // for the upload progress event: - if (xhr.upload) { - $(xhr.upload).on('progress', function (e) { - var oe = e.originalEvent; - // Make sure the progress event properties get copied over: - e.lengthComputable = oe.lengthComputable; - e.loaded = oe.loaded; - e.total = oe.total; - that._onProgress(e, options); - }); - options.xhr = function () { - return xhr; - }; - } - }, - - _deinitProgressListener: function (options) { - var xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); - if (xhr.upload) { - $(xhr.upload).off('progress'); - } - }, - - _isInstanceOf: function (type, obj) { - // Cross-frame instanceof check - return Object.prototype.toString.call(obj) === '[object ' + type + ']'; - }, - - _getUniqueFilename: function (name, map) { - // eslint-disable-next-line no-param-reassign - name = String(name); - if (map[name]) { - // eslint-disable-next-line no-param-reassign - name = name.replace( - /(?: \(([\d]+)\))?(\.[^.]+)?$/, - function (_, p1, p2) { - var index = p1 ? Number(p1) + 1 : 1; - var ext = p2 || ''; - return ' (' + index + ')' + ext; - } - ); - return this._getUniqueFilename(name, map); - } - map[name] = true; - return name; - }, - - _initXHRData: function (options) { - var that = this, - formData, - file = options.files[0], - // Ignore non-multipart setting if not supported: - multipart = options.multipart || !$.support.xhrFileUpload, - paramName = - $.type(options.paramName) === 'array' - ? options.paramName[0] - : options.paramName; - options.headers = $.extend({}, options.headers); - if (options.contentRange) { - options.headers['Content-Range'] = options.contentRange; - } - if (!multipart || options.blob || !this._isInstanceOf('File', file)) { - options.headers['Content-Disposition'] = - 'attachment; filename="' + - encodeURI(file.uploadName || file.name) + - '"'; - } - if (!multipart) { - options.contentType = file.type || 'application/octet-stream'; - options.data = options.blob || file; - } else if ($.support.xhrFormDataFileUpload) { - if (options.postMessage) { - // window.postMessage does not allow sending FormData - // objects, so we just add the File/Blob objects to - // the formData array and let the postMessage window - // create the FormData object out of this array: - formData = this._getFormData(options); - if (options.blob) { - formData.push({ - name: paramName, - value: options.blob - }); - } else { - $.each(options.files, function (index, file) { - formData.push({ - name: - ($.type(options.paramName) === 'array' && - options.paramName[index]) || - paramName, - value: file - }); - }); - } - } else { - if (that._isInstanceOf('FormData', options.formData)) { - formData = options.formData; - } else { - formData = new FormData(); - $.each(this._getFormData(options), function (index, field) { - formData.append(field.name, field.value); - }); - } - if (options.blob) { - formData.append( - paramName, - options.blob, - file.uploadName || file.name - ); - } else { - $.each(options.files, function (index, file) { - // This check allows the tests to run with - // dummy objects: - if ( - that._isInstanceOf('File', file) || - that._isInstanceOf('Blob', file) - ) { - var fileName = file.uploadName || file.name; - if (options.uniqueFilenames) { - fileName = that._getUniqueFilename( - fileName, - options.uniqueFilenames - ); - } - formData.append( - ($.type(options.paramName) === 'array' && - options.paramName[index]) || - paramName, - file, - fileName - ); - } - }); - } - } - options.data = formData; - } - // Blob reference is not needed anymore, free memory: - options.blob = null; - }, - - _initIframeSettings: function (options) { - var targetHost = $('').prop('href', options.url).prop('host'); - // Setting the dataType to iframe enables the iframe transport: - options.dataType = 'iframe ' + (options.dataType || ''); - // The iframe transport accepts a serialized array as form data: - options.formData = this._getFormData(options); - // Add redirect url to form data on cross-domain uploads: - if (options.redirect && targetHost && targetHost !== location.host) { - options.formData.push({ - name: options.redirectParamName || 'redirect', - value: options.redirect - }); - } - }, - - _initDataSettings: function (options) { - if (this._isXHRUpload(options)) { - if (!this._chunkedUpload(options, true)) { - if (!options.data) { - this._initXHRData(options); - } - this._initProgressListener(options); - } - if (options.postMessage) { - // Setting the dataType to postmessage enables the - // postMessage transport: - options.dataType = 'postmessage ' + (options.dataType || ''); - } - } else { - this._initIframeSettings(options); - } - }, - - _getParamName: function (options) { - var fileInput = $(options.fileInput), - paramName = options.paramName; - if (!paramName) { - paramName = []; - fileInput.each(function () { - var input = $(this), - name = input.prop('name') || 'files[]', - i = (input.prop('files') || [1]).length; - while (i) { - paramName.push(name); - i -= 1; - } - }); - if (!paramName.length) { - paramName = [fileInput.prop('name') || 'files[]']; - } - } else if (!$.isArray(paramName)) { - paramName = [paramName]; - } - return paramName; - }, - - _initFormSettings: function (options) { - // Retrieve missing options from the input field and the - // associated form, if available: - if (!options.form || !options.form.length) { - options.form = $(options.fileInput.prop('form')); - // If the given file input doesn't have an associated form, - // use the default widget file input's form: - if (!options.form.length) { - options.form = $(this.options.fileInput.prop('form')); - } - } - options.paramName = this._getParamName(options); - if (!options.url) { - options.url = options.form.prop('action') || location.href; - } - // The HTTP request method must be "POST" or "PUT": - options.type = ( - options.type || - ($.type(options.form.prop('method')) === 'string' && - options.form.prop('method')) || - '' - ).toUpperCase(); - if ( - options.type !== 'POST' && - options.type !== 'PUT' && - options.type !== 'PATCH' - ) { - options.type = 'POST'; - } - if (!options.formAcceptCharset) { - options.formAcceptCharset = options.form.attr('accept-charset'); - } - }, - - _getAJAXSettings: function (data) { - var options = $.extend({}, this.options, data); - this._initFormSettings(options); - this._initDataSettings(options); - return options; - }, - - // jQuery 1.6 doesn't provide .state(), - // while jQuery 1.8+ removed .isRejected() and .isResolved(): - _getDeferredState: function (deferred) { - if (deferred.state) { - return deferred.state(); - } - if (deferred.isResolved()) { - return 'resolved'; - } - if (deferred.isRejected()) { - return 'rejected'; - } - return 'pending'; - }, - - // Maps jqXHR callbacks to the equivalent - // methods of the given Promise object: - _enhancePromise: function (promise) { - promise.success = promise.done; - promise.error = promise.fail; - promise.complete = promise.always; - return promise; - }, - - // Creates and returns a Promise object enhanced with - // the jqXHR methods abort, success, error and complete: - _getXHRPromise: function (resolveOrReject, context, args) { - var dfd = $.Deferred(), - promise = dfd.promise(); - // eslint-disable-next-line no-param-reassign - context = context || this.options.context || promise; - if (resolveOrReject === true) { - dfd.resolveWith(context, args); - } else if (resolveOrReject === false) { - dfd.rejectWith(context, args); - } - promise.abort = dfd.promise; - return this._enhancePromise(promise); - }, - - // Adds convenience methods to the data callback argument: - _addConvenienceMethods: function (e, data) { - var that = this, - getPromise = function (args) { - return $.Deferred().resolveWith(that, args).promise(); - }; - data.process = function (resolveFunc, rejectFunc) { - if (resolveFunc || rejectFunc) { - data._processQueue = this._processQueue = (this._processQueue || - getPromise([this])) - [that._promisePipe](function () { - if (data.errorThrown) { - return $.Deferred().rejectWith(that, [data]).promise(); - } - return getPromise(arguments); - }) - [that._promisePipe](resolveFunc, rejectFunc); - } - return this._processQueue || getPromise([this]); - }; - data.submit = function () { - if (this.state() !== 'pending') { - data.jqXHR = this.jqXHR = - that._trigger( - 'submit', - $.Event('submit', { delegatedEvent: e }), - this - ) !== false && that._onSend(e, this); - } - return this.jqXHR || that._getXHRPromise(); - }; - data.abort = function () { - if (this.jqXHR) { - return this.jqXHR.abort(); - } - this.errorThrown = 'abort'; - that._trigger('fail', null, this); - return that._getXHRPromise(false); - }; - data.state = function () { - if (this.jqXHR) { - return that._getDeferredState(this.jqXHR); - } - if (this._processQueue) { - return that._getDeferredState(this._processQueue); - } - }; - data.processing = function () { - return ( - !this.jqXHR && - this._processQueue && - that._getDeferredState(this._processQueue) === 'pending' - ); - }; - data.progress = function () { - return this._progress; - }; - data.response = function () { - return this._response; - }; - }, - - // Parses the Range header from the server response - // and returns the uploaded bytes: - _getUploadedBytes: function (jqXHR) { - var range = jqXHR.getResponseHeader('Range'), - parts = range && range.split('-'), - upperBytesPos = parts && parts.length > 1 && parseInt(parts[1], 10); - return upperBytesPos && upperBytesPos + 1; - }, - - // Uploads a file in multiple, sequential requests - // by splitting the file up in multiple blob chunks. - // If the second parameter is true, only tests if the file - // should be uploaded in chunks, but does not invoke any - // upload requests: - _chunkedUpload: function (options, testOnly) { - options.uploadedBytes = options.uploadedBytes || 0; - var that = this, - file = options.files[0], - fs = file.size, - ub = options.uploadedBytes, - mcs = options.maxChunkSize || fs, - slice = this._blobSlice, - dfd = $.Deferred(), - promise = dfd.promise(), - jqXHR, - upload; - if ( - !( - this._isXHRUpload(options) && - slice && - (ub || ($.type(mcs) === 'function' ? mcs(options) : mcs) < fs) - ) || - options.data - ) { - return false; - } - if (testOnly) { - return true; - } - if (ub >= fs) { - file.error = options.i18n('uploadedBytes'); - return this._getXHRPromise(false, options.context, [ - null, - 'error', - file.error - ]); - } - // The chunk upload method: - upload = function () { - // Clone the options object for each chunk upload: - var o = $.extend({}, options), - currentLoaded = o._progress.loaded; - o.blob = slice.call( - file, - ub, - ub + ($.type(mcs) === 'function' ? mcs(o) : mcs), - file.type - ); - // Store the current chunk size, as the blob itself - // will be dereferenced after data processing: - o.chunkSize = o.blob.size; - // Expose the chunk bytes position range: - o.contentRange = - 'bytes ' + ub + '-' + (ub + o.chunkSize - 1) + '/' + fs; - // Trigger chunkbeforesend to allow form data to be updated for this chunk - that._trigger('chunkbeforesend', null, o); - // Process the upload data (the blob and potential form data): - that._initXHRData(o); - // Add progress listeners for this chunk upload: - that._initProgressListener(o); - jqXHR = ( - (that._trigger('chunksend', null, o) !== false && $.ajax(o)) || - that._getXHRPromise(false, o.context) - ) - .done(function (result, textStatus, jqXHR) { - ub = that._getUploadedBytes(jqXHR) || ub + o.chunkSize; - // Create a progress event if no final progress event - // with loaded equaling total has been triggered - // for this chunk: - if (currentLoaded + o.chunkSize - o._progress.loaded) { - that._onProgress( - $.Event('progress', { - lengthComputable: true, - loaded: ub - o.uploadedBytes, - total: ub - o.uploadedBytes - }), - o - ); - } - options.uploadedBytes = o.uploadedBytes = ub; - o.result = result; - o.textStatus = textStatus; - o.jqXHR = jqXHR; - that._trigger('chunkdone', null, o); - that._trigger('chunkalways', null, o); - if (ub < fs) { - // File upload not yet complete, - // continue with the next chunk: - upload(); - } else { - dfd.resolveWith(o.context, [result, textStatus, jqXHR]); - } - }) - .fail(function (jqXHR, textStatus, errorThrown) { - o.jqXHR = jqXHR; - o.textStatus = textStatus; - o.errorThrown = errorThrown; - that._trigger('chunkfail', null, o); - that._trigger('chunkalways', null, o); - dfd.rejectWith(o.context, [jqXHR, textStatus, errorThrown]); - }) - .always(function () { - that._deinitProgressListener(o); - }); - }; - this._enhancePromise(promise); - promise.abort = function () { - return jqXHR.abort(); - }; - upload(); - return promise; - }, - - _beforeSend: function (e, data) { - if (this._active === 0) { - // the start callback is triggered when an upload starts - // and no other uploads are currently running, - // equivalent to the global ajaxStart event: - this._trigger('start'); - // Set timer for global bitrate progress calculation: - this._bitrateTimer = new this._BitrateTimer(); - // Reset the global progress values: - this._progress.loaded = this._progress.total = 0; - this._progress.bitrate = 0; - } - // Make sure the container objects for the .response() and - // .progress() methods on the data object are available - // and reset to their initial state: - this._initResponseObject(data); - this._initProgressObject(data); - data._progress.loaded = data.loaded = data.uploadedBytes || 0; - data._progress.total = data.total = this._getTotal(data.files) || 1; - data._progress.bitrate = data.bitrate = 0; - this._active += 1; - // Initialize the global progress values: - this._progress.loaded += data.loaded; - this._progress.total += data.total; - }, - - _onDone: function (result, textStatus, jqXHR, options) { - var total = options._progress.total, - response = options._response; - if (options._progress.loaded < total) { - // Create a progress event if no final progress event - // with loaded equaling total has been triggered: - this._onProgress( - $.Event('progress', { - lengthComputable: true, - loaded: total, - total: total - }), - options - ); - } - response.result = options.result = result; - response.textStatus = options.textStatus = textStatus; - response.jqXHR = options.jqXHR = jqXHR; - this._trigger('done', null, options); - }, - - _onFail: function (jqXHR, textStatus, errorThrown, options) { - var response = options._response; - if (options.recalculateProgress) { - // Remove the failed (error or abort) file upload from - // the global progress calculation: - this._progress.loaded -= options._progress.loaded; - this._progress.total -= options._progress.total; - } - response.jqXHR = options.jqXHR = jqXHR; - response.textStatus = options.textStatus = textStatus; - response.errorThrown = options.errorThrown = errorThrown; - this._trigger('fail', null, options); - }, - - _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) { - // jqXHRorResult, textStatus and jqXHRorError are added to the - // options object via done and fail callbacks - this._trigger('always', null, options); - }, - - _onSend: function (e, data) { - if (!data.submit) { - this._addConvenienceMethods(e, data); - } - var that = this, - jqXHR, - aborted, - slot, - pipe, - options = that._getAJAXSettings(data), - send = function () { - that._sending += 1; - // Set timer for bitrate progress calculation: - options._bitrateTimer = new that._BitrateTimer(); - jqXHR = - jqXHR || - ( - ((aborted || - that._trigger( - 'send', - $.Event('send', { delegatedEvent: e }), - options - ) === false) && - that._getXHRPromise(false, options.context, aborted)) || - that._chunkedUpload(options) || - $.ajax(options) - ) - .done(function (result, textStatus, jqXHR) { - that._onDone(result, textStatus, jqXHR, options); - }) - .fail(function (jqXHR, textStatus, errorThrown) { - that._onFail(jqXHR, textStatus, errorThrown, options); - }) - .always(function (jqXHRorResult, textStatus, jqXHRorError) { - that._deinitProgressListener(options); - that._onAlways( - jqXHRorResult, - textStatus, - jqXHRorError, - options - ); - that._sending -= 1; - that._active -= 1; - if ( - options.limitConcurrentUploads && - options.limitConcurrentUploads > that._sending - ) { - // Start the next queued upload, - // that has not been aborted: - var nextSlot = that._slots.shift(); - while (nextSlot) { - if (that._getDeferredState(nextSlot) === 'pending') { - nextSlot.resolve(); - break; - } - nextSlot = that._slots.shift(); - } - } - if (that._active === 0) { - // The stop callback is triggered when all uploads have - // been completed, equivalent to the global ajaxStop event: - that._trigger('stop'); - } - }); - return jqXHR; - }; - this._beforeSend(e, options); - if ( - this.options.sequentialUploads || - (this.options.limitConcurrentUploads && - this.options.limitConcurrentUploads <= this._sending) - ) { - if (this.options.limitConcurrentUploads > 1) { - slot = $.Deferred(); - this._slots.push(slot); - pipe = slot[that._promisePipe](send); - } else { - this._sequence = this._sequence[that._promisePipe](send, send); - pipe = this._sequence; - } - // Return the piped Promise object, enhanced with an abort method, - // which is delegated to the jqXHR object of the current upload, - // and jqXHR callbacks mapped to the equivalent Promise methods: - pipe.abort = function () { - aborted = [undefined, 'abort', 'abort']; - if (!jqXHR) { - if (slot) { - slot.rejectWith(options.context, aborted); - } - return send(); - } - return jqXHR.abort(); - }; - return this._enhancePromise(pipe); - } - return send(); - }, - - _onAdd: function (e, data) { - var that = this, - result = true, - options = $.extend({}, this.options, data), - files = data.files, - filesLength = files.length, - limit = options.limitMultiFileUploads, - limitSize = options.limitMultiFileUploadSize, - overhead = options.limitMultiFileUploadSizeOverhead, - batchSize = 0, - paramName = this._getParamName(options), - paramNameSet, - paramNameSlice, - fileSet, - i, - j = 0; - if (!filesLength) { - return false; - } - if (limitSize && files[0].size === undefined) { - limitSize = undefined; - } - if ( - !(options.singleFileUploads || limit || limitSize) || - !this._isXHRUpload(options) - ) { - fileSet = [files]; - paramNameSet = [paramName]; - } else if (!(options.singleFileUploads || limitSize) && limit) { - fileSet = []; - paramNameSet = []; - for (i = 0; i < filesLength; i += limit) { - fileSet.push(files.slice(i, i + limit)); - paramNameSlice = paramName.slice(i, i + limit); - if (!paramNameSlice.length) { - paramNameSlice = paramName; - } - paramNameSet.push(paramNameSlice); - } - } else if (!options.singleFileUploads && limitSize) { - fileSet = []; - paramNameSet = []; - for (i = 0; i < filesLength; i = i + 1) { - batchSize += files[i].size + overhead; - if ( - i + 1 === filesLength || - batchSize + files[i + 1].size + overhead > limitSize || - (limit && i + 1 - j >= limit) - ) { - fileSet.push(files.slice(j, i + 1)); - paramNameSlice = paramName.slice(j, i + 1); - if (!paramNameSlice.length) { - paramNameSlice = paramName; - } - paramNameSet.push(paramNameSlice); - j = i + 1; - batchSize = 0; - } - } - } else { - paramNameSet = paramName; - } - data.originalFiles = files; - $.each(fileSet || files, function (index, element) { - var newData = $.extend({}, data); - newData.files = fileSet ? element : [element]; - newData.paramName = paramNameSet[index]; - that._initResponseObject(newData); - that._initProgressObject(newData); - that._addConvenienceMethods(e, newData); - result = that._trigger( - 'add', - $.Event('add', { delegatedEvent: e }), - newData - ); - return result; - }); - return result; - }, - - _replaceFileInput: function (data) { - var input = data.fileInput, - inputClone = input.clone(true), - restoreFocus = input.is(document.activeElement); - // Add a reference for the new cloned file input to the data argument: - data.fileInputClone = inputClone; - $('
').append(inputClone)[0].reset(); - // Detaching allows to insert the fileInput on another form - // without losing the file input value: - input.after(inputClone).detach(); - // If the fileInput had focus before it was detached, - // restore focus to the inputClone. - if (restoreFocus) { - inputClone.trigger('focus'); - } - // Avoid memory leaks with the detached file input: - $.cleanData(input.off('remove')); - // Replace the original file input element in the fileInput - // elements set with the clone, which has been copied including - // event handlers: - this.options.fileInput = this.options.fileInput.map(function (i, el) { - if (el === input[0]) { - return inputClone[0]; - } - return el; - }); - // If the widget has been initialized on the file input itself, - // override this.element with the file input clone: - if (input[0] === this.element[0]) { - this.element = inputClone; - } - }, - - _handleFileTreeEntry: function (entry, path) { - var that = this, - dfd = $.Deferred(), - entries = [], - dirReader, - errorHandler = function (e) { - if (e && !e.entry) { - e.entry = entry; - } - // Since $.when returns immediately if one - // Deferred is rejected, we use resolve instead. - // This allows valid files and invalid items - // to be returned together in one set: - dfd.resolve([e]); - }, - successHandler = function (entries) { - that - ._handleFileTreeEntries(entries, path + entry.name + '/') - .done(function (files) { - dfd.resolve(files); - }) - .fail(errorHandler); - }, - readEntries = function () { - dirReader.readEntries(function (results) { - if (!results.length) { - successHandler(entries); - } else { - entries = entries.concat(results); - readEntries(); - } - }, errorHandler); - }; - // eslint-disable-next-line no-param-reassign - path = path || ''; - if (entry.isFile) { - if (entry._file) { - // Workaround for Chrome bug #149735 - entry._file.relativePath = path; - dfd.resolve(entry._file); - } else { - entry.file(function (file) { - file.relativePath = path; - dfd.resolve(file); - }, errorHandler); - } - } else if (entry.isDirectory) { - dirReader = entry.createReader(); - readEntries(); - } else { - // Return an empty list for file system items - // other than files or directories: - dfd.resolve([]); - } - return dfd.promise(); - }, - - _handleFileTreeEntries: function (entries, path) { - var that = this; - return $.when - .apply( - $, - $.map(entries, function (entry) { - return that._handleFileTreeEntry(entry, path); - }) - ) - [this._promisePipe](function () { - return Array.prototype.concat.apply([], arguments); - }); - }, - - _getDroppedFiles: function (dataTransfer) { - // eslint-disable-next-line no-param-reassign - dataTransfer = dataTransfer || {}; - var items = dataTransfer.items; - if ( - items && - items.length && - (items[0].webkitGetAsEntry || items[0].getAsEntry) - ) { - return this._handleFileTreeEntries( - $.map(items, function (item) { - var entry; - if (item.webkitGetAsEntry) { - entry = item.webkitGetAsEntry(); - if (entry) { - // Workaround for Chrome bug #149735: - entry._file = item.getAsFile(); - } - return entry; - } - return item.getAsEntry(); - }) - ); - } - return $.Deferred().resolve($.makeArray(dataTransfer.files)).promise(); - }, - - _getSingleFileInputFiles: function (fileInput) { - // eslint-disable-next-line no-param-reassign - fileInput = $(fileInput); - var entries = fileInput.prop('entries'), - files, - value; - if (entries && entries.length) { - return this._handleFileTreeEntries(entries); - } - files = $.makeArray(fileInput.prop('files')); - if (!files.length) { - value = fileInput.prop('value'); - if (!value) { - return $.Deferred().resolve([]).promise(); - } - // If the files property is not available, the browser does not - // support the File API and we add a pseudo File object with - // the input value as name with path information removed: - files = [{ name: value.replace(/^.*\\/, '') }]; - } else if (files[0].name === undefined && files[0].fileName) { - // File normalization for Safari 4 and Firefox 3: - $.each(files, function (index, file) { - file.name = file.fileName; - file.size = file.fileSize; - }); - } - return $.Deferred().resolve(files).promise(); - }, - - _getFileInputFiles: function (fileInput) { - if (!(fileInput instanceof $) || fileInput.length === 1) { - return this._getSingleFileInputFiles(fileInput); - } - return $.when - .apply($, $.map(fileInput, this._getSingleFileInputFiles)) - [this._promisePipe](function () { - return Array.prototype.concat.apply([], arguments); - }); - }, - - _onChange: function (e) { - var that = this, - data = { - fileInput: $(e.target), - form: $(e.target.form) - }; - this._getFileInputFiles(data.fileInput).always(function (files) { - data.files = files; - if (that.options.replaceFileInput) { - that._replaceFileInput(data); - } - if ( - that._trigger( - 'change', - $.Event('change', { delegatedEvent: e }), - data - ) !== false - ) { - that._onAdd(e, data); - } - }); - }, - - _onPaste: function (e) { - var items = - e.originalEvent && - e.originalEvent.clipboardData && - e.originalEvent.clipboardData.items, - data = { files: [] }; - if (items && items.length) { - $.each(items, function (index, item) { - var file = item.getAsFile && item.getAsFile(); - if (file) { - data.files.push(file); - } - }); - if ( - this._trigger( - 'paste', - $.Event('paste', { delegatedEvent: e }), - data - ) !== false - ) { - this._onAdd(e, data); - } - } - }, - - _onDrop: function (e) { - e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; - var that = this, - dataTransfer = e.dataTransfer, - data = {}; - if (dataTransfer && dataTransfer.files && dataTransfer.files.length) { - e.preventDefault(); - this._getDroppedFiles(dataTransfer).always(function (files) { - data.files = files; - if ( - that._trigger( - 'drop', - $.Event('drop', { delegatedEvent: e }), - data - ) !== false - ) { - that._onAdd(e, data); - } - }); - } - }, - - _onDragOver: getDragHandler('dragover'), - - _onDragEnter: getDragHandler('dragenter'), - - _onDragLeave: getDragHandler('dragleave'), - - _initEventHandlers: function () { - if (this._isXHRUpload(this.options)) { - this._on(this.options.dropZone, { - dragover: this._onDragOver, - drop: this._onDrop, - // event.preventDefault() on dragenter is required for IE10+: - dragenter: this._onDragEnter, - // dragleave is not required, but added for completeness: - dragleave: this._onDragLeave - }); - this._on(this.options.pasteZone, { - paste: this._onPaste - }); - } - if ($.support.fileInput) { - this._on(this.options.fileInput, { - change: this._onChange - }); - } - }, - - _destroyEventHandlers: function () { - this._off(this.options.dropZone, 'dragenter dragleave dragover drop'); - this._off(this.options.pasteZone, 'paste'); - this._off(this.options.fileInput, 'change'); - }, - - _destroy: function () { - this._destroyEventHandlers(); - }, - - _setOption: function (key, value) { - var reinit = $.inArray(key, this._specialOptions) !== -1; - if (reinit) { - this._destroyEventHandlers(); - } - this._super(key, value); - if (reinit) { - this._initSpecialOptions(); - this._initEventHandlers(); - } - }, - - _initSpecialOptions: function () { - var options = this.options; - if (options.fileInput === undefined) { - options.fileInput = this.element.is('input[type="file"]') - ? this.element - : this.element.find('input[type="file"]'); - } else if (!(options.fileInput instanceof $)) { - options.fileInput = $(options.fileInput); - } - if (!(options.dropZone instanceof $)) { - options.dropZone = $(options.dropZone); - } - if (!(options.pasteZone instanceof $)) { - options.pasteZone = $(options.pasteZone); - } - }, - - _getRegExp: function (str) { - var parts = str.split('/'), - modifiers = parts.pop(); - parts.shift(); - return new RegExp(parts.join('/'), modifiers); - }, - - _isRegExpOption: function (key, value) { - return ( - key !== 'url' && - $.type(value) === 'string' && - /^\/.*\/[igm]{0,3}$/.test(value) - ); - }, - - _initDataAttributes: function () { - var that = this, - options = this.options, - data = this.element.data(); - // Initialize options set via HTML5 data-attributes: - $.each(this.element[0].attributes, function (index, attr) { - var key = attr.name.toLowerCase(), - value; - if (/^data-/.test(key)) { - // Convert hyphen-ated key to camelCase: - key = key.slice(5).replace(/-[a-z]/g, function (str) { - return str.charAt(1).toUpperCase(); - }); - value = data[key]; - if (that._isRegExpOption(key, value)) { - value = that._getRegExp(value); - } - options[key] = value; - } - }); - }, - - _create: function () { - this._initDataAttributes(); - this._initSpecialOptions(); - this._slots = []; - this._sequence = this._getXHRPromise(true); - this._sending = this._active = 0; - this._initProgressObject(this); - this._initEventHandlers(); - }, - - // This method is exposed to the widget API and allows to query - // the number of active uploads: - active: function () { - return this._active; - }, - - // This method is exposed to the widget API and allows to query - // the widget upload progress. - // It returns an object with loaded, total and bitrate properties - // for the running uploads: - progress: function () { - return this._progress; - }, - - // This method is exposed to the widget API and allows adding files - // using the fileupload API. The data parameter accepts an object which - // must have a files property and can contain additional options: - // .fileupload('add', {files: filesList}); - add: function (data) { - var that = this; - if (!data || this.options.disabled) { - return; - } - if (data.fileInput && !data.files) { - this._getFileInputFiles(data.fileInput).always(function (files) { - data.files = files; - that._onAdd(null, data); - }); - } else { - data.files = $.makeArray(data.files); - this._onAdd(null, data); - } - }, - - // This method is exposed to the widget API and allows sending files - // using the fileupload API. The data parameter accepts an object which - // must have a files or fileInput property and can contain additional options: - // .fileupload('send', {files: filesList}); - // The method returns a Promise object for the file upload call. - send: function (data) { - if (data && !this.options.disabled) { - if (data.fileInput && !data.files) { - var that = this, - dfd = $.Deferred(), - promise = dfd.promise(), - jqXHR, - aborted; - promise.abort = function () { - aborted = true; - if (jqXHR) { - return jqXHR.abort(); - } - dfd.reject(null, 'abort', 'abort'); - return promise; - }; - this._getFileInputFiles(data.fileInput).always(function (files) { - if (aborted) { - return; - } - if (!files.length) { - dfd.reject(); - return; - } - data.files = files; - jqXHR = that._onSend(null, data); - jqXHR.then( - function (result, textStatus, jqXHR) { - dfd.resolve(result, textStatus, jqXHR); - }, - function (jqXHR, textStatus, errorThrown) { - dfd.reject(jqXHR, textStatus, errorThrown); - } - ); - }); - return this._enhancePromise(promise); - } - data.files = $.makeArray(data.files); - if (data.files.length) { - return this._onSend(null, data); - } - } - return this._getXHRPromise(false, data && data.context); - } - }); -}); diff --git a/lib/web/jquery/fileUploader/jquery.fileuploader.js b/lib/web/jquery/fileUploader/jquery.fileuploader.js deleted file mode 100644 index 4ec869ab4f47..000000000000 --- a/lib/web/jquery/fileUploader/jquery.fileuploader.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Custom Uploader - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define([ - 'jquery', - 'jquery/fileUploader/jquery.fileupload-image', - 'jquery/fileUploader/jquery.fileupload-audio', - 'jquery/fileUploader/jquery.fileupload-video', - 'jquery/fileUploader/jquery.iframe-transport', - ], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory( - require('jquery'), - require('jquery/fileUploader/jquery.fileupload-image'), - require('jquery/fileUploader/jquery.fileupload-audio'), - require('jquery/fileUploader/jquery.fileupload-video'), - require('jquery/fileUploader/jquery.iframe-transport') - ); - } else { - // Browser globals: - factory(window.jQuery); - } -})(); diff --git a/lib/web/jquery/fileUploader/jquery.iframe-transport.js b/lib/web/jquery/fileUploader/jquery.iframe-transport.js deleted file mode 100644 index 3e3b9a93b05d..000000000000 --- a/lib/web/jquery/fileUploader/jquery.iframe-transport.js +++ /dev/null @@ -1,227 +0,0 @@ -/* - * jQuery Iframe Transport Plugin - * https://github.com/blueimp/jQuery-File-Upload - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, require */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS: - factory(require('jquery')); - } else { - // Browser globals: - factory(window.jQuery); - } -})(function ($) { - 'use strict'; - - // Helper variable to create unique names for the transport iframes: - var counter = 0, - jsonAPI = $, - jsonParse = 'parseJSON'; - - if ('JSON' in window && 'parse' in JSON) { - jsonAPI = JSON; - jsonParse = 'parse'; - } - - // The iframe transport accepts four additional options: - // options.fileInput: a jQuery collection of file input fields - // options.paramName: the parameter name for the file form data, - // overrides the name property of the file input field(s), - // can be a string or an array of strings. - // options.formData: an array of objects with name and value properties, - // equivalent to the return data of .serializeArray(), e.g.: - // [{name: 'a', value: 1}, {name: 'b', value: 2}] - // options.initialIframeSrc: the URL of the initial iframe src, - // by default set to "javascript:false;" - $.ajaxTransport('iframe', function (options) { - if (options.async) { - // javascript:false as initial iframe src - // prevents warning popups on HTTPS in IE6: - // eslint-disable-next-line no-script-url - var initialIframeSrc = options.initialIframeSrc || 'javascript:false;', - form, - iframe, - addParamChar; - return { - send: function (_, completeCallback) { - form = $('
'); - form.attr('accept-charset', options.formAcceptCharset); - addParamChar = /\?/.test(options.url) ? '&' : '?'; - // XDomainRequest only supports GET and POST: - if (options.type === 'DELETE') { - options.url = options.url + addParamChar + '_method=DELETE'; - options.type = 'POST'; - } else if (options.type === 'PUT') { - options.url = options.url + addParamChar + '_method=PUT'; - options.type = 'POST'; - } else if (options.type === 'PATCH') { - options.url = options.url + addParamChar + '_method=PATCH'; - options.type = 'POST'; - } - // IE versions below IE8 cannot set the name property of - // elements that have already been added to the DOM, - // so we set the name along with the iframe HTML markup: - counter += 1; - iframe = $( - '' - ).on('load', function () { - var fileInputClones, - paramNames = $.isArray(options.paramName) - ? options.paramName - : [options.paramName]; - iframe.off('load').on('load', function () { - var response; - // Wrap in a try/catch block to catch exceptions thrown - // when trying to access cross-domain iframe contents: - try { - response = iframe.contents(); - // Google Chrome and Firefox do not throw an - // exception when calling iframe.contents() on - // cross-domain requests, so we unify the response: - if (!response.length || !response[0].firstChild) { - throw new Error(); - } - } catch (e) { - response = undefined; - } - // The complete callback returns the - // iframe content document as response object: - completeCallback(200, 'success', { iframe: response }); - // Fix for IE endless progress bar activity bug - // (happens on form submits to iframe targets): - $('').appendTo( - form - ); - window.setTimeout(function () { - // Removing the form in a setTimeout call - // allows Chrome's developer tools to display - // the response result - form.remove(); - }, 0); - }); - form - .prop('target', iframe.prop('name')) - .prop('action', options.url) - .prop('method', options.type); - if (options.formData) { - $.each(options.formData, function (index, field) { - $('') - .prop('name', field.name) - .val(field.value) - .appendTo(form); - }); - } - if ( - options.fileInput && - options.fileInput.length && - options.type === 'POST' - ) { - fileInputClones = options.fileInput.clone(); - // Insert a clone for each file input field: - options.fileInput.after(function (index) { - return fileInputClones[index]; - }); - if (options.paramName) { - options.fileInput.each(function (index) { - $(this).prop('name', paramNames[index] || options.paramName); - }); - } - // Appending the file input fields to the hidden form - // removes them from their original location: - form - .append(options.fileInput) - .prop('enctype', 'multipart/form-data') - // enctype must be set as encoding for IE: - .prop('encoding', 'multipart/form-data'); - // Remove the HTML5 form attribute from the input(s): - options.fileInput.removeAttr('form'); - } - window.setTimeout(function () { - // Submitting the form in a setTimeout call fixes an issue with - // Safari 13 not triggering the iframe load event after resetting - // the load event handler, see also: - // https://github.com/blueimp/jQuery-File-Upload/issues/3633 - form.submit(); - // Insert the file input fields at their original location - // by replacing the clones with the originals: - if (fileInputClones && fileInputClones.length) { - options.fileInput.each(function (index, input) { - var clone = $(fileInputClones[index]); - // Restore the original name and form properties: - $(input) - .prop('name', clone.prop('name')) - .attr('form', clone.attr('form')); - clone.replaceWith(input); - }); - } - }, 0); - }); - form.append(iframe).appendTo(document.body); - }, - abort: function () { - if (iframe) { - // javascript:false as iframe src aborts the request - // and prevents warning popups on HTTPS in IE6. - iframe.off('load').prop('src', initialIframeSrc); - } - if (form) { - form.remove(); - } - } - }; - } - }); - - // The iframe transport returns the iframe content document as response. - // The following adds converters from iframe to text, json, html, xml - // and script. - // Please note that the Content-Type for JSON responses has to be text/plain - // or text/html, if the browser doesn't include application/json in the - // Accept header, else IE will show a download dialog. - // The Content-Type for XML responses on the other hand has to be always - // application/xml or text/xml, so IE properly parses the XML response. - // See also - // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation - $.ajaxSetup({ - converters: { - 'iframe text': function (iframe) { - return iframe && $(iframe[0].body).text(); - }, - 'iframe json': function (iframe) { - return iframe && jsonAPI[jsonParse]($(iframe[0].body).text()); - }, - 'iframe html': function (iframe) { - return iframe && $(iframe[0].body).html(); - }, - 'iframe xml': function (iframe) { - var xmlDoc = iframe && iframe[0]; - return xmlDoc && $.isXMLDoc(xmlDoc) - ? xmlDoc - : $.parseXML( - (xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) || - $(xmlDoc.body).html() - ); - }, - 'iframe script': function (iframe) { - return iframe && $.globalEval($(iframe[0].body).text()); - } - } - }); -}); diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/LICENSE.txt b/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/LICENSE.txt deleted file mode 100644 index e1ad73662d4a..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -MIT License - -Copyright © 2012 Sebastian Tschan, https://blueimp.net - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/README.md b/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/README.md deleted file mode 100644 index 92e16c63ce7c..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/README.md +++ /dev/null @@ -1,135 +0,0 @@ -# JavaScript Canvas to Blob - -## Contents - -- [Description](#description) -- [Setup](#setup) -- [Usage](#usage) -- [Requirements](#requirements) -- [Browsers](#browsers) -- [API](#api) -- [Test](#test) -- [License](#license) - -## Description - -Canvas to Blob is a -[polyfill](https://developer.mozilla.org/en-US/docs/Glossary/Polyfill) for -Browsers that don't support the standard JavaScript -[HTMLCanvasElement.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) -method. - -It can be used to create -[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects from an -HTML [canvas](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) -element. - -## Setup - -Install via [NPM](https://www.npmjs.com/package/blueimp-canvas-to-blob): - -```sh -npm install blueimp-canvas-to-blob -``` - -This will install the JavaScript files inside -`./node_modules/blueimp-canvas-to-blob/js/` relative to your current directory, -from where you can copy them into a folder that is served by your web server. - -Next include the minified JavaScript Canvas to Blob script in your HTML markup: - -```html - -``` - -Or alternatively, include the non-minified version: - -```html - -``` - -## Usage - -You can use the `canvas.toBlob()` method in the same way as the native -implementation: - -```js -var canvas = document.createElement('canvas') -// Edit the canvas ... -if (canvas.toBlob) { - canvas.toBlob(function (blob) { - // Do something with the blob object, - // e.g. create multipart form data for file uploads: - var formData = new FormData() - formData.append('file', blob, 'image.jpg') - // ... - }, 'image/jpeg') -} -``` - -## Requirements - -The JavaScript Canvas to Blob function has zero dependencies. - -However, it is a very suitable complement to the -[JavaScript Load Image](https://github.com/blueimp/JavaScript-Load-Image) -function. - -## Browsers - -The following browsers have native support for -[HTMLCanvasElement.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob): - -- Chrome 50+ -- Firefox 19+ -- Safari 11+ -- Mobile Chrome 50+ (Android) -- Mobile Firefox 4+ (Android) -- Mobile Safari 11+ (iOS) -- Edge 79+ - -Browsers which implement the following APIs support `canvas.toBlob()` via -polyfill: - -- [HTMLCanvasElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) -- [HTMLCanvasElement.toDataURL](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL) -- [Blob() constructor](https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob) -- [atob](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob) -- [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) -- [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) - -This includes the following browsers: - -- Chrome 20+ -- Firefox 13+ -- Safari 8+ -- Mobile Chrome 25+ (Android) -- Mobile Firefox 14+ (Android) -- Mobile Safari 8+ (iOS) -- Edge 74+ -- Edge Legacy 12+ -- Internet Explorer 10+ - -## API - -In addition to the `canvas.toBlob()` polyfill, the JavaScript Canvas to Blob -script exposes its helper function `dataURLtoBlob(url)`: - -```js -// Uncomment the following line when using a module loader like webpack: -// var dataURLtoBlob = require('blueimp-canvas-to-blob') - -// black+white 3x2 GIF, base64 data: -var b64 = 'R0lGODdhAwACAPEAAAAAAP///yZFySZFySH5BAEAAAIALAAAAAADAAIAAAIDRAJZADs=' -var url = 'data:image/gif;base64,' + b64 -var blob = dataURLtoBlob(url) -``` - -## Test - -[Unit tests](https://blueimp.github.io/JavaScript-Canvas-to-Blob/test/) - -## License - -The JavaScript Canvas to Blob script is released under the -[MIT license](https://opensource.org/licenses/MIT). diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/js/canvas-to-blob.js b/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/js/canvas-to-blob.js deleted file mode 100644 index 8cd717bc1205..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-canvas-to-blob/js/canvas-to-blob.js +++ /dev/null @@ -1,143 +0,0 @@ -/* - * JavaScript Canvas to Blob - * https://github.com/blueimp/JavaScript-Canvas-to-Blob - * - * Copyright 2012, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - * - * Based on stackoverflow user Stoive's code snippet: - * http://stackoverflow.com/q/4998908 - */ - -/* global define, Uint8Array, ArrayBuffer, module */ - -;(function (window) { - 'use strict' - - var CanvasPrototype = - window.HTMLCanvasElement && window.HTMLCanvasElement.prototype - var hasBlobConstructor = - window.Blob && - (function () { - try { - return Boolean(new Blob()) - } catch (e) { - return false - } - })() - var hasArrayBufferViewSupport = - hasBlobConstructor && - window.Uint8Array && - (function () { - try { - return new Blob([new Uint8Array(100)]).size === 100 - } catch (e) { - return false - } - })() - var BlobBuilder = - window.BlobBuilder || - window.WebKitBlobBuilder || - window.MozBlobBuilder || - window.MSBlobBuilder - var dataURIPattern = /^data:((.*?)(;charset=.*?)?)(;base64)?,/ - var dataURLtoBlob = - (hasBlobConstructor || BlobBuilder) && - window.atob && - window.ArrayBuffer && - window.Uint8Array && - function (dataURI) { - var matches, - mediaType, - isBase64, - dataString, - byteString, - arrayBuffer, - intArray, - i, - bb - // Parse the dataURI components as per RFC 2397 - matches = dataURI.match(dataURIPattern) - if (!matches) { - throw new Error('invalid data URI') - } - // Default to text/plain;charset=US-ASCII - mediaType = matches[2] - ? matches[1] - : 'text/plain' + (matches[3] || ';charset=US-ASCII') - isBase64 = !!matches[4] - dataString = dataURI.slice(matches[0].length) - if (isBase64) { - // Convert base64 to raw binary data held in a string: - byteString = atob(dataString) - } else { - // Convert base64/URLEncoded data component to raw binary: - byteString = decodeURIComponent(dataString) - } - // Write the bytes of the string to an ArrayBuffer: - arrayBuffer = new ArrayBuffer(byteString.length) - intArray = new Uint8Array(arrayBuffer) - for (i = 0; i < byteString.length; i += 1) { - intArray[i] = byteString.charCodeAt(i) - } - // Write the ArrayBuffer (or ArrayBufferView) to a blob: - if (hasBlobConstructor) { - return new Blob([hasArrayBufferViewSupport ? intArray : arrayBuffer], { - type: mediaType - }) - } - bb = new BlobBuilder() - bb.append(arrayBuffer) - return bb.getBlob(mediaType) - } - if (window.HTMLCanvasElement && !CanvasPrototype.toBlob) { - if (CanvasPrototype.mozGetAsFile) { - CanvasPrototype.toBlob = function (callback, type, quality) { - var self = this - setTimeout(function () { - if (quality && CanvasPrototype.toDataURL && dataURLtoBlob) { - callback(dataURLtoBlob(self.toDataURL(type, quality))) - } else { - callback(self.mozGetAsFile('blob', type)) - } - }) - } - } else if (CanvasPrototype.toDataURL && dataURLtoBlob) { - if (CanvasPrototype.msToBlob) { - CanvasPrototype.toBlob = function (callback, type, quality) { - var self = this - setTimeout(function () { - if ( - ((type && type !== 'image/png') || quality) && - CanvasPrototype.toDataURL && - dataURLtoBlob - ) { - callback(dataURLtoBlob(self.toDataURL(type, quality))) - } else { - callback(self.msToBlob(type)) - } - }) - } - } else { - CanvasPrototype.toBlob = function (callback, type, quality) { - var self = this - setTimeout(function () { - callback(dataURLtoBlob(self.toDataURL(type, quality))) - }) - } - } - } - } - if (typeof define === 'function' && define.amd) { - define(function () { - return dataURLtoBlob - }) - } else if (typeof module === 'object' && module.exports) { - module.exports = dataURLtoBlob - } else { - window.dataURLtoBlob = dataURLtoBlob - } -})(window) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/LICENSE.txt b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/LICENSE.txt deleted file mode 100644 index d6a9d74758be..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -MIT License - -Copyright © 2011 Sebastian Tschan, https://blueimp.net - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/README.md b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/README.md deleted file mode 100644 index 77b6b1195e3d..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/README.md +++ /dev/null @@ -1,1070 +0,0 @@ -# JavaScript Load Image - -> A JavaScript library to load and transform image files. - -## Contents - -- [Demo](https://blueimp.github.io/JavaScript-Load-Image/) -- [Description](#description) -- [Setup](#setup) -- [Usage](#usage) - - [Image loading](#image-loading) - - [Image scaling](#image-scaling) -- [Requirements](#requirements) -- [Browser support](#browser-support) -- [API](#api) - - [Callback](#callback) - - [Function signature](#function-signature) - - [Cancel image loading](#cancel-image-loading) - - [Callback arguments](#callback-arguments) - - [Error handling](#error-handling) - - [Promise](#promise) -- [Options](#options) - - [maxWidth](#maxwidth) - - [maxHeight](#maxheight) - - [minWidth](#minwidth) - - [minHeight](#minheight) - - [sourceWidth](#sourcewidth) - - [sourceHeight](#sourceheight) - - [top](#top) - - [right](#right) - - [bottom](#bottom) - - [left](#left) - - [contain](#contain) - - [cover](#cover) - - [aspectRatio](#aspectratio) - - [pixelRatio](#pixelratio) - - [downsamplingRatio](#downsamplingratio) - - [imageSmoothingEnabled](#imagesmoothingenabled) - - [imageSmoothingQuality](#imagesmoothingquality) - - [crop](#crop) - - [orientation](#orientation) - - [meta](#meta) - - [canvas](#canvas) - - [crossOrigin](#crossorigin) - - [noRevoke](#norevoke) -- [Metadata parsing](#metadata-parsing) - - [Image head](#image-head) - - [Exif parser](#exif-parser) - - [Exif Thumbnail](#exif-thumbnail) - - [Exif IFD](#exif-ifd) - - [GPSInfo IFD](#gpsinfo-ifd) - - [Interoperability IFD](#interoperability-ifd) - - [Exif parser options](#exif-parser-options) - - [Exif writer](#exif-writer) - - [IPTC parser](#iptc-parser) - - [IPTC parser options](#iptc-parser-options) -- [License](#license) -- [Credits](#credits) - -## Description - -JavaScript Load Image is a library to load images provided as `File` or `Blob` -objects or via `URL`. It returns an optionally **scaled**, **cropped** or -**rotated** HTML `img` or `canvas` element. - -It also provides methods to parse image metadata to extract -[IPTC](https://iptc.org/standards/photo-metadata/) and -[Exif](https://en.wikipedia.org/wiki/Exif) tags as well as embedded thumbnail -images, to overwrite the Exif Orientation value and to restore the complete -image header after resizing. - -## Setup - -Install via [NPM](https://www.npmjs.com/package/blueimp-load-image): - -```sh -npm install blueimp-load-image -``` - -This will install the JavaScript files inside -`./node_modules/blueimp-load-image/js/` relative to your current directory, from -where you can copy them into a folder that is served by your web server. - -Next include the combined and minified JavaScript Load Image script in your HTML -markup: - -```html - -``` - -Or alternatively, choose which components you want to include: - -```html - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - -## Usage - -### Image loading - -In your application code, use the `loadImage()` function with -[callback](#callback) style: - -```js -document.getElementById('file-input').onchange = function () { - loadImage( - this.files[0], - function (img) { - document.body.appendChild(img) - }, - { maxWidth: 600 } // Options - ) -} -``` - -Or use the [Promise](#promise) based API like this ([requires](#requirements) a -polyfill for older browsers): - -```js -document.getElementById('file-input').onchange = function () { - loadImage(this.files[0], { maxWidth: 600 }).then(function (data) { - document.body.appendChild(data.image) - }) -} -``` - -With -[async/await](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await) -(requires a modern browser or a code transpiler like -[Babel](https://babeljs.io/) or [TypeScript](https://www.typescriptlang.org/)): - -```js -document.getElementById('file-input').onchange = async function () { - let data = await loadImage(this.files[0], { maxWidth: 600 }) - document.body.appendChild(data.image) -} -``` - -### Image scaling - -It is also possible to use the image scaling functionality directly with an -existing image: - -```js -var scaledImage = loadImage.scale( - img, // img or canvas element - { maxWidth: 600 } -) -``` - -## Requirements - -The JavaScript Load Image library has zero dependencies, but benefits from the -following two -[polyfills](https://developer.mozilla.org/en-US/docs/Glossary/Polyfill): - -- [blueimp-canvas-to-blob](https://github.com/blueimp/JavaScript-Canvas-to-Blob) - for browsers without native - [HTMLCanvasElement.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) - support, to create `Blob` objects out of `canvas` elements. -- [promise-polyfill](https://github.com/taylorhakes/promise-polyfill) to be able - to use the - [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) - based `loadImage` API in Browsers without native `Promise` support. - -## Browser support - -Browsers which implement the following APIs support all options: - -- Loading images from File and Blob objects: - - [URL.createObjectURL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) - or - [FileReader.readAsDataURL](https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL) -- Parsing meta data: - - [FileReader.readAsArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsArrayBuffer) - - [Blob.slice](https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice) - - [DataView](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) - (no [BigInt](https://developer.mozilla.org/en-US/docs/Glossary/BigInt) - support required) -- Parsing meta data from images loaded via URL: - - [fetch Response.blob](https://developer.mozilla.org/en-US/docs/Web/API/Body/blob) - or - [XMLHttpRequest.responseType blob](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType#blob) -- Promise based API: - - [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) - -This includes (but is not limited to) the following browsers: - -- Chrome 32+ -- Firefox 29+ -- Safari 8+ -- Mobile Chrome 42+ (Android) -- Mobile Firefox 50+ (Android) -- Mobile Safari 8+ (iOS) -- Edge 74+ -- Edge Legacy 12+ -- Internet Explorer 10+ `*` - -`*` Internet Explorer [requires](#requirements) a polyfill for the `Promise` -based API. - -Loading an image from a URL and applying transformations (scaling, cropping and -rotating - except `orientation:true`, which requires reading meta data) is -supported by all browsers which implement the -[HTMLCanvasElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) -interface. - -Loading an image from a URL and scaling it in size is supported by all browsers -which implement the -[img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) element and -has been tested successfully with browser engines as old as Internet Explorer 5 -(via -[IE11's emulation mode]()). - -The `loadImage()` function applies options using -[progressive enhancement](https://en.wikipedia.org/wiki/Progressive_enhancement) -and falls back to a configuration that is supported by the browser, e.g. if the -`canvas` element is not supported, an equivalent `img` element is returned. - -## API - -### Callback - -#### Function signature - -The `loadImage()` function accepts a -[File](https://developer.mozilla.org/en-US/docs/Web/API/File) or -[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object or an image -URL as first argument. - -If a [File](https://developer.mozilla.org/en-US/docs/Web/API/File) or -[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) is passed as -parameter, it returns an HTML `img` element if the browser supports the -[URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) API, alternatively a -[FileReader](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) object -if the `FileReader` API is supported, or `false`. - -It always returns an HTML -[img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img) element -when passing an image URL: - -```js -var loadingImage = loadImage( - 'https://example.org/image.png', - function (img) { - document.body.appendChild(img) - }, - { maxWidth: 600 } -) -``` - -#### Cancel image loading - -Some browsers (e.g. Chrome) will cancel the image loading process if the `src` -property of an `img` element is changed. -To avoid unnecessary requests, we can use the -[data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) -of a 1x1 pixel transparent GIF image as `src` target to cancel the original -image download. - -To disable callback handling, we can also unset the image event handlers and for -maximum browser compatibility, cancel the file reading process if the returned -object is a -[FileReader](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) -instance: - -```js -var loadingImage = loadImage( - 'https://example.org/image.png', - function (img) { - document.body.appendChild(img) - }, - { maxWidth: 600 } -) - -if (loadingImage) { - // Unset event handling for the loading image: - loadingImage.onload = loadingImage.onerror = null - - // Cancel image loading process: - if (loadingImage.abort) { - // FileReader instance, stop the file reading process: - loadingImage.abort() - } else { - // HTMLImageElement element, cancel the original image request by changing - // the target source to the data URL of a 1x1 pixel transparent image GIF: - loadingImage.src = - 'data:image/gif;base64,' + - 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' - } -} -``` - -**Please note:** -The `img` element (or `FileReader` instance) for the loading image is only -returned when using the callback style API and not available with the -[Promise](#promise) based API. - -#### Callback arguments - -For the callback style API, the second argument to `loadImage()` must be a -`callback` function, which is called when the image has been loaded or an error -occurred while loading the image. - -The callback function is passed two arguments: - -1. An HTML [img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) - element or - [canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) - element, or an - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) object of - type `error`. -2. An object with the original image dimensions as properties and potentially - additional [metadata](#metadata-parsing). - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - document.body.appendChild(img) - console.log('Original image width: ', data.originalWidth) - console.log('Original image height: ', data.originalHeight) - }, - { maxWidth: 600, meta: true } -) -``` - -**Please note:** -The original image dimensions reflect the natural width and height of the loaded -image before applying any transformation. -For consistent values across browsers, [metadata](#metadata-parsing) parsing has -to be enabled via `meta:true`, so `loadImage` can detect automatic image -orientation and normalize the dimensions. - -#### Error handling - -Example code implementing error handling: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - if (img.type === 'error') { - console.error('Error loading image file') - } else { - document.body.appendChild(img) - } - }, - { maxWidth: 600 } -) -``` - -### Promise - -If the `loadImage()` function is called without a `callback` function as second -argument and the -[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) -API is available, it returns a `Promise` object: - -```js -loadImage(fileOrBlobOrUrl, { maxWidth: 600, meta: true }) - .then(function (data) { - document.body.appendChild(data.image) - console.log('Original image width: ', data.originalWidth) - console.log('Original image height: ', data.originalHeight) - }) - .catch(function (err) { - // Handling image loading errors - console.log(err) - }) -``` - -The `Promise` resolves with an object with the following properties: - -- `image`: An HTML - [img](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) or - [canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) element. -- `originalWidth`: The original width of the image. -- `originalHeight`: The original height of the image. - -Please also read the note about original image dimensions normalization in the -[callback arguments](#callback-arguments) section. - -If [metadata](#metadata-parsing) has been parsed, additional properties might be -present on the object. - -If image loading fails, the `Promise` rejects with an -[Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) object of type -`error`. - -## Options - -The optional options argument to `loadImage()` allows to configure the image -loading. - -It can be used the following way with the callback style: - -```js -loadImage( - fileOrBlobOrUrl, - function (img) { - document.body.appendChild(img) - }, - { - maxWidth: 600, - maxHeight: 300, - minWidth: 100, - minHeight: 50, - canvas: true - } -) -``` - -Or the following way with the `Promise` based API: - -```js -loadImage(fileOrBlobOrUrl, { - maxWidth: 600, - maxHeight: 300, - minWidth: 100, - minHeight: 50, - canvas: true -}).then(function (data) { - document.body.appendChild(data.image) -}) -``` - -All settings are optional. By default, the image is returned as HTML `img` -element without any image size restrictions. - -### maxWidth - -Defines the maximum width of the `img`/`canvas` element. - -### maxHeight - -Defines the maximum height of the `img`/`canvas` element. - -### minWidth - -Defines the minimum width of the `img`/`canvas` element. - -### minHeight - -Defines the minimum height of the `img`/`canvas` element. - -### sourceWidth - -The width of the sub-rectangle of the source image to draw into the destination -canvas. -Defaults to the source image width and requires `canvas: true`. - -### sourceHeight - -The height of the sub-rectangle of the source image to draw into the destination -canvas. -Defaults to the source image height and requires `canvas: true`. - -### top - -The top margin of the sub-rectangle of the source image. -Defaults to `0` and requires `canvas: true`. - -### right - -The right margin of the sub-rectangle of the source image. -Defaults to `0` and requires `canvas: true`. - -### bottom - -The bottom margin of the sub-rectangle of the source image. -Defaults to `0` and requires `canvas: true`. - -### left - -The left margin of the sub-rectangle of the source image. -Defaults to `0` and requires `canvas: true`. - -### contain - -Scales the image up/down to contain it in the max dimensions if set to `true`. -This emulates the CSS feature -[background-image: contain](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Backgrounds_and_Borders/Resizing_background_images#contain). - -### cover - -Scales the image up/down to cover the max dimensions with the image dimensions -if set to `true`. -This emulates the CSS feature -[background-image: cover](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Backgrounds_and_Borders/Resizing_background_images#cover). - -### aspectRatio - -Crops the image to the given aspect ratio (e.g. `16/9`). -Setting the `aspectRatio` also enables the `crop` option. - -### pixelRatio - -Defines the ratio of the canvas pixels to the physical image pixels on the -screen. -Should be set to -[window.devicePixelRatio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio) -unless the scaled image is not rendered on screen. -Defaults to `1` and requires `canvas: true`. - -### downsamplingRatio - -Defines the ratio in which the image is downsampled (scaled down in steps). -By default, images are downsampled in one step. -With a ratio of `0.5`, each step scales the image to half the size, before -reaching the target dimensions. -Requires `canvas: true`. - -### imageSmoothingEnabled - -If set to `false`, -[disables image smoothing](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled). -Defaults to `true` and requires `canvas: true`. - -### imageSmoothingQuality - -Sets the -[quality of image smoothing](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality). -Possible values: `'low'`, `'medium'`, `'high'` -Defaults to `'low'` and requires `canvas: true`. - -### crop - -Crops the image to the `maxWidth`/`maxHeight` constraints if set to `true`. -Enabling the `crop` option also enables the `canvas` option. - -### orientation - -Transform the canvas according to the specified Exif orientation, which can be -an `integer` in the range of `1` to `8` or the boolean value `true`. - -When set to `true`, it will set the orientation value based on the Exif data of -the image, which will be parsed automatically if the Exif extension is -available. - -Exif orientation values to correctly display the letter F: - -```diagram - 1 2 - ██████ ██████ - ██ ██ - ████ ████ - ██ ██ - ██ ██ - - 3 4 - ██ ██ - ██ ██ - ████ ████ - ██ ██ - ██████ ██████ - - 5 6 -██████████ ██ -██ ██ ██ ██ -██ ██████████ - - 7 8 - ██ ██████████ - ██ ██ ██ ██ -██████████ ██ -``` - -Setting `orientation` to `true` enables the `canvas` and `meta` options, unless -the browser supports automatic image orientation (see -[browser support for image-orientation](https://caniuse.com/#feat=css-image-orientation)). - -Setting `orientation` to `1` enables the `canvas` and `meta` options if the -browser does support automatic image orientation (to allow reset of the -orientation). - -Setting `orientation` to an integer in the range of `2` to `8` always enables -the `canvas` option and also enables the `meta` option if the browser supports -automatic image orientation (again to allow reset). - -### meta - -Automatically parses the image metadata if set to `true`. - -If metadata has been found, the data object passed as second argument to the -callback function has additional properties (see -[metadata parsing](#metadata-parsing)). - -If the file is given as URL and the browser supports the -[fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) or the -XHR -[responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType) -`blob`, fetches the file as `Blob` to be able to parse the metadata. - -### canvas - -Returns the image as -[canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) element if -set to `true`. - -### crossOrigin - -Sets the `crossOrigin` property on the `img` element for loading -[CORS enabled images](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image). - -### noRevoke - -By default, the -[created object URL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) -is revoked after the image has been loaded, except when this option is set to -`true`. - -## Metadata parsing - -If the Load Image Meta extension is included, it is possible to parse image meta -data automatically with the `meta` option: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - console.log('Original image head: ', data.imageHead) - console.log('Exif data: ', data.exif) // requires exif extension - console.log('IPTC data: ', data.iptc) // requires iptc extension - }, - { meta: true } -) -``` - -Or alternatively via `loadImage.parseMetaData`, which can be used with an -available `File` or `Blob` object as first argument: - -```js -loadImage.parseMetaData( - fileOrBlob, - function (data) { - console.log('Original image head: ', data.imageHead) - console.log('Exif data: ', data.exif) // requires exif extension - console.log('IPTC data: ', data.iptc) // requires iptc extension - }, - { - maxMetaDataSize: 262144 - } -) -``` - -Or using the -[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) -based API: - -```js -loadImage - .parseMetaData(fileOrBlob, { - maxMetaDataSize: 262144 - }) - .then(function (data) { - console.log('Original image head: ', data.imageHead) - console.log('Exif data: ', data.exif) // requires exif extension - console.log('IPTC data: ', data.iptc) // requires iptc extension - }) -``` - -The Metadata extension adds additional options used for the `parseMetaData` -method: - -- `maxMetaDataSize`: Maximum number of bytes of metadata to parse. -- `disableImageHead`: Disable parsing the original image head. -- `disableMetaDataParsers`: Disable parsing metadata (image head only) - -### Image head - -Resized JPEG images can be combined with their original image head via -`loadImage.replaceHead`, which requires the resized image as `Blob` object as -first argument and an `ArrayBuffer` image head as second argument. - -With callback style, the third argument must be a `callback` function, which is -called with the new `Blob` object: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - if (data.imageHead) { - img.toBlob(function (blob) { - loadImage.replaceHead(blob, data.imageHead, function (newBlob) { - // do something with the new Blob object - }) - }, 'image/jpeg') - } - }, - { meta: true, canvas: true, maxWidth: 800 } -) -``` - -Or using the -[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) -based API like this: - -```js -loadImage(fileOrBlobOrUrl, { meta: true, canvas: true, maxWidth: 800 }) - .then(function (data) { - if (!data.imageHead) throw new Error('Could not parse image metadata') - return new Promise(function (resolve) { - data.image.toBlob(function (blob) { - data.blob = blob - resolve(data) - }, 'image/jpeg') - }) - }) - .then(function (data) { - return loadImage.replaceHead(data.blob, data.imageHead) - }) - .then(function (blob) { - // do something with the new Blob object - }) - .catch(function (err) { - console.error(err) - }) -``` - -**Please note:** -`Blob` objects of resized images can be created via -[HTMLCanvasElement.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob). -[blueimp-canvas-to-blob](https://github.com/blueimp/JavaScript-Canvas-to-Blob) -provides a polyfill for browsers without native `canvas.toBlob()` support. - -### Exif parser - -If you include the Load Image Exif Parser extension, the argument passed to the -callback for `parseMetaData` will contain the following additional properties if -Exif data could be found in the given image: - -- `exif`: The parsed Exif tags -- `exifOffsets`: The parsed Exif tag offsets -- `exifTiffOffset`: TIFF header offset (used for offset pointers) -- `exifLittleEndian`: little endian order if true, big endian if false - -The `exif` object stores the parsed Exif tags: - -```js -var orientation = data.exif[0x0112] // Orientation -``` - -The `exif` and `exifOffsets` objects also provide a `get()` method to retrieve -the tag value/offset via the tag's mapped name: - -```js -var orientation = data.exif.get('Orientation') -var orientationOffset = data.exifOffsets.get('Orientation') -``` - -By default, only the following names are mapped: - -- `Orientation` -- `Thumbnail` (see [Exif Thumbnail](#exif-thumbnail)) -- `Exif` (see [Exif IFD](#exif-ifd)) -- `GPSInfo` (see [GPSInfo IFD](#gpsinfo-ifd)) -- `Interoperability` (see [Interoperability IFD](#interoperability-ifd)) - -If you also include the Load Image Exif Map library, additional tag mappings -become available, as well as three additional methods: - -- `exif.getText()` -- `exif.getName()` -- `exif.getAll()` - -```js -var orientationText = data.exif.getText('Orientation') // e.g. "Rotate 90° CW" - -var name = data.exif.getName(0x0112) // "Orientation" - -// A map of all parsed tags with their mapped names/text as keys/values: -var allTags = data.exif.getAll() -``` - -#### Exif Thumbnail - -Example code displaying a thumbnail image embedded into the Exif metadata: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - var exif = data.exif - var thumbnail = exif && exif.get('Thumbnail') - var blob = thumbnail && thumbnail.get('Blob') - if (blob) { - loadImage( - blob, - function (thumbImage) { - document.body.appendChild(thumbImage) - }, - { orientation: exif.get('Orientation') } - ) - } - }, - { meta: true } -) -``` - -#### Exif IFD - -Example code displaying data from the Exif IFD (Image File Directory) that -contains Exif specified TIFF tags: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - var exifIFD = data.exif && data.exif.get('Exif') - if (exifIFD) { - // Map of all Exif IFD tags with their mapped names/text as keys/values: - console.log(exifIFD.getAll()) - // A specific Exif IFD tag value: - console.log(exifIFD.get('UserComment')) - } - }, - { meta: true } -) -``` - -#### GPSInfo IFD - -Example code displaying data from the Exif IFD (Image File Directory) that -contains [GPS](https://en.wikipedia.org/wiki/Global_Positioning_System) info: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - var gpsInfo = data.exif && data.exif.get('GPSInfo') - if (gpsInfo) { - // Map of all GPSInfo tags with their mapped names/text as keys/values: - console.log(gpsInfo.getAll()) - // A specific GPSInfo tag value: - console.log(gpsInfo.get('GPSLatitude')) - } - }, - { meta: true } -) -``` - -#### Interoperability IFD - -Example code displaying data from the Exif IFD (Image File Directory) that -contains Interoperability data: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - var interoperabilityData = data.exif && data.exif.get('Interoperability') - if (interoperabilityData) { - // The InteroperabilityIndex tag value: - console.log(interoperabilityData.get('InteroperabilityIndex')) - } - }, - { meta: true } -) -``` - -#### Exif parser options - -The Exif parser adds additional options: - -- `disableExif`: Disables Exif parsing when `true`. -- `disableExifOffsets`: Disables storing Exif tag offsets when `true`. -- `includeExifTags`: A map of Exif tags to include for parsing (includes all but - the excluded tags by default). -- `excludeExifTags`: A map of Exif tags to exclude from parsing (defaults to - exclude `Exif` `MakerNote`). - -An example parsing only Orientation, Thumbnail and ExifVersion tags: - -```js -loadImage.parseMetaData( - fileOrBlob, - function (data) { - console.log('Exif data: ', data.exif) - }, - { - includeExifTags: { - 0x0112: true, // Orientation - ifd1: { - 0x0201: true, // JPEGInterchangeFormat (Thumbnail data offset) - 0x0202: true // JPEGInterchangeFormatLength (Thumbnail data length) - }, - 0x8769: { - // ExifIFDPointer - 0x9000: true // ExifVersion - } - } - } -) -``` - -An example excluding `Exif` `MakerNote` and `GPSInfo`: - -```js -loadImage.parseMetaData( - fileOrBlob, - function (data) { - console.log('Exif data: ', data.exif) - }, - { - excludeExifTags: { - 0x8769: { - // ExifIFDPointer - 0x927c: true // MakerNote - }, - 0x8825: true // GPSInfoIFDPointer - } - } -) -``` - -### Exif writer - -The Exif parser extension also includes a minimal writer that allows to override -the Exif `Orientation` value in the parsed `imageHead` `ArrayBuffer`: - -```js -loadImage( - fileOrBlobOrUrl, - function (img, data) { - if (data.imageHead && data.exif) { - // Reset Exif Orientation data: - loadImage.writeExifData(data.imageHead, data, 'Orientation', 1) - img.toBlob(function (blob) { - loadImage.replaceHead(blob, data.imageHead, function (newBlob) { - // do something with newBlob - }) - }, 'image/jpeg') - } - }, - { meta: true, orientation: true, canvas: true, maxWidth: 800 } -) -``` - -**Please note:** -The Exif writer relies on the Exif tag offsets being available as -`data.exifOffsets` property, which requires that Exif data has been parsed from -the image. -The Exif writer can only change existing values, not add new tags, e.g. it -cannot add an Exif `Orientation` tag for an image that does not have one. - -### IPTC parser - -If you include the Load Image IPTC Parser extension, the argument passed to the -callback for `parseMetaData` will contain the following additional properties if -IPTC data could be found in the given image: - -- `iptc`: The parsed IPTC tags -- `iptcOffsets`: The parsed IPTC tag offsets - -The `iptc` object stores the parsed IPTC tags: - -```js -var objectname = data.iptc[5] -``` - -The `iptc` and `iptcOffsets` objects also provide a `get()` method to retrieve -the tag value/offset via the tag's mapped name: - -```js -var objectname = data.iptc.get('ObjectName') -``` - -By default, only the following names are mapped: - -- `ObjectName` - -If you also include the Load Image IPTC Map library, additional tag mappings -become available, as well as three additional methods: - -- `iptc.getText()` -- `iptc.getName()` -- `iptc.getAll()` - -```js -var keywords = data.iptc.getText('Keywords') // e.g.: ['Weather','Sky'] - -var name = data.iptc.getName(5) // ObjectName - -// A map of all parsed tags with their mapped names/text as keys/values: -var allTags = data.iptc.getAll() -``` - -#### IPTC parser options - -The IPTC parser adds additional options: - -- `disableIptc`: Disables IPTC parsing when true. -- `disableIptcOffsets`: Disables storing IPTC tag offsets when `true`. -- `includeIptcTags`: A map of IPTC tags to include for parsing (includes all but - the excluded tags by default). -- `excludeIptcTags`: A map of IPTC tags to exclude from parsing (defaults to - exclude `ObjectPreviewData`). - -An example parsing only the `ObjectName` tag: - -```js -loadImage.parseMetaData( - fileOrBlob, - function (data) { - console.log('IPTC data: ', data.iptc) - }, - { - includeIptcTags: { - 5: true // ObjectName - } - } -) -``` - -An example excluding `ApplicationRecordVersion` and `ObjectPreviewData`: - -```js -loadImage.parseMetaData( - fileOrBlob, - function (data) { - console.log('IPTC data: ', data.iptc) - }, - { - excludeIptcTags: { - 0: true, // ApplicationRecordVersion - 202: true // ObjectPreviewData - } - } -) -``` - -## License - -The JavaScript Load Image library is released under the -[MIT license](https://opensource.org/licenses/MIT). - -## Credits - -- Original image metadata handling implemented with the help and contribution of - Achim Stöhr. -- Original Exif tags mapping based on Jacob Seidelin's - [exif-js](https://github.com/exif-js/exif-js) library. -- Original IPTC parser implementation by - [Dave Bevan](https://github.com/bevand10). diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/index.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/index.js deleted file mode 100644 index 20875a2d0853..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/* global module, require */ - -module.exports = require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image') - -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale') -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta') -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-fetch') -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif') -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif-map') -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc') -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc-map') -require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-orientation') diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif-map.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif-map.js deleted file mode 100644 index 29f11aff226f..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif-map.js +++ /dev/null @@ -1,420 +0,0 @@ -/* - * JavaScript Load Image Exif Map - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Exif tags mapping based on - * https://github.com/jseidelin/exif-js - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, require */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif'], factory) - } else if (typeof module === 'object' && module.exports) { - factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif')) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - var ExifMapProto = loadImage.ExifMap.prototype - - ExifMapProto.tags = { - // ================= - // TIFF tags (IFD0): - // ================= - 0x0100: 'ImageWidth', - 0x0101: 'ImageHeight', - 0x0102: 'BitsPerSample', - 0x0103: 'Compression', - 0x0106: 'PhotometricInterpretation', - 0x0112: 'Orientation', - 0x0115: 'SamplesPerPixel', - 0x011c: 'PlanarConfiguration', - 0x0212: 'YCbCrSubSampling', - 0x0213: 'YCbCrPositioning', - 0x011a: 'XResolution', - 0x011b: 'YResolution', - 0x0128: 'ResolutionUnit', - 0x0111: 'StripOffsets', - 0x0116: 'RowsPerStrip', - 0x0117: 'StripByteCounts', - 0x0201: 'JPEGInterchangeFormat', - 0x0202: 'JPEGInterchangeFormatLength', - 0x012d: 'TransferFunction', - 0x013e: 'WhitePoint', - 0x013f: 'PrimaryChromaticities', - 0x0211: 'YCbCrCoefficients', - 0x0214: 'ReferenceBlackWhite', - 0x0132: 'DateTime', - 0x010e: 'ImageDescription', - 0x010f: 'Make', - 0x0110: 'Model', - 0x0131: 'Software', - 0x013b: 'Artist', - 0x8298: 'Copyright', - 0x8769: { - // ExifIFDPointer - 0x9000: 'ExifVersion', // EXIF version - 0xa000: 'FlashpixVersion', // Flashpix format version - 0xa001: 'ColorSpace', // Color space information tag - 0xa002: 'PixelXDimension', // Valid width of meaningful image - 0xa003: 'PixelYDimension', // Valid height of meaningful image - 0xa500: 'Gamma', - 0x9101: 'ComponentsConfiguration', // Information about channels - 0x9102: 'CompressedBitsPerPixel', // Compressed bits per pixel - 0x927c: 'MakerNote', // Any desired information written by the manufacturer - 0x9286: 'UserComment', // Comments by user - 0xa004: 'RelatedSoundFile', // Name of related sound file - 0x9003: 'DateTimeOriginal', // Date and time when the original image was generated - 0x9004: 'DateTimeDigitized', // Date and time when the image was stored digitally - 0x9010: 'OffsetTime', // Time zone when the image file was last changed - 0x9011: 'OffsetTimeOriginal', // Time zone when the image was stored digitally - 0x9012: 'OffsetTimeDigitized', // Time zone when the image was stored digitally - 0x9290: 'SubSecTime', // Fractions of seconds for DateTime - 0x9291: 'SubSecTimeOriginal', // Fractions of seconds for DateTimeOriginal - 0x9292: 'SubSecTimeDigitized', // Fractions of seconds for DateTimeDigitized - 0x829a: 'ExposureTime', // Exposure time (in seconds) - 0x829d: 'FNumber', - 0x8822: 'ExposureProgram', // Exposure program - 0x8824: 'SpectralSensitivity', // Spectral sensitivity - 0x8827: 'PhotographicSensitivity', // EXIF 2.3, ISOSpeedRatings in EXIF 2.2 - 0x8828: 'OECF', // Optoelectric conversion factor - 0x8830: 'SensitivityType', - 0x8831: 'StandardOutputSensitivity', - 0x8832: 'RecommendedExposureIndex', - 0x8833: 'ISOSpeed', - 0x8834: 'ISOSpeedLatitudeyyy', - 0x8835: 'ISOSpeedLatitudezzz', - 0x9201: 'ShutterSpeedValue', // Shutter speed - 0x9202: 'ApertureValue', // Lens aperture - 0x9203: 'BrightnessValue', // Value of brightness - 0x9204: 'ExposureBias', // Exposure bias - 0x9205: 'MaxApertureValue', // Smallest F number of lens - 0x9206: 'SubjectDistance', // Distance to subject in meters - 0x9207: 'MeteringMode', // Metering mode - 0x9208: 'LightSource', // Kind of light source - 0x9209: 'Flash', // Flash status - 0x9214: 'SubjectArea', // Location and area of main subject - 0x920a: 'FocalLength', // Focal length of the lens in mm - 0xa20b: 'FlashEnergy', // Strobe energy in BCPS - 0xa20c: 'SpatialFrequencyResponse', - 0xa20e: 'FocalPlaneXResolution', // Number of pixels in width direction per FPRUnit - 0xa20f: 'FocalPlaneYResolution', // Number of pixels in height direction per FPRUnit - 0xa210: 'FocalPlaneResolutionUnit', // Unit for measuring the focal plane resolution - 0xa214: 'SubjectLocation', // Location of subject in image - 0xa215: 'ExposureIndex', // Exposure index selected on camera - 0xa217: 'SensingMethod', // Image sensor type - 0xa300: 'FileSource', // Image source (3 == DSC) - 0xa301: 'SceneType', // Scene type (1 == directly photographed) - 0xa302: 'CFAPattern', // Color filter array geometric pattern - 0xa401: 'CustomRendered', // Special processing - 0xa402: 'ExposureMode', // Exposure mode - 0xa403: 'WhiteBalance', // 1 = auto white balance, 2 = manual - 0xa404: 'DigitalZoomRatio', // Digital zoom ratio - 0xa405: 'FocalLengthIn35mmFilm', - 0xa406: 'SceneCaptureType', // Type of scene - 0xa407: 'GainControl', // Degree of overall image gain adjustment - 0xa408: 'Contrast', // Direction of contrast processing applied by camera - 0xa409: 'Saturation', // Direction of saturation processing applied by camera - 0xa40a: 'Sharpness', // Direction of sharpness processing applied by camera - 0xa40b: 'DeviceSettingDescription', - 0xa40c: 'SubjectDistanceRange', // Distance to subject - 0xa420: 'ImageUniqueID', // Identifier assigned uniquely to each image - 0xa430: 'CameraOwnerName', - 0xa431: 'BodySerialNumber', - 0xa432: 'LensSpecification', - 0xa433: 'LensMake', - 0xa434: 'LensModel', - 0xa435: 'LensSerialNumber' - }, - 0x8825: { - // GPSInfoIFDPointer - 0x0000: 'GPSVersionID', - 0x0001: 'GPSLatitudeRef', - 0x0002: 'GPSLatitude', - 0x0003: 'GPSLongitudeRef', - 0x0004: 'GPSLongitude', - 0x0005: 'GPSAltitudeRef', - 0x0006: 'GPSAltitude', - 0x0007: 'GPSTimeStamp', - 0x0008: 'GPSSatellites', - 0x0009: 'GPSStatus', - 0x000a: 'GPSMeasureMode', - 0x000b: 'GPSDOP', - 0x000c: 'GPSSpeedRef', - 0x000d: 'GPSSpeed', - 0x000e: 'GPSTrackRef', - 0x000f: 'GPSTrack', - 0x0010: 'GPSImgDirectionRef', - 0x0011: 'GPSImgDirection', - 0x0012: 'GPSMapDatum', - 0x0013: 'GPSDestLatitudeRef', - 0x0014: 'GPSDestLatitude', - 0x0015: 'GPSDestLongitudeRef', - 0x0016: 'GPSDestLongitude', - 0x0017: 'GPSDestBearingRef', - 0x0018: 'GPSDestBearing', - 0x0019: 'GPSDestDistanceRef', - 0x001a: 'GPSDestDistance', - 0x001b: 'GPSProcessingMethod', - 0x001c: 'GPSAreaInformation', - 0x001d: 'GPSDateStamp', - 0x001e: 'GPSDifferential', - 0x001f: 'GPSHPositioningError' - }, - 0xa005: { - // InteroperabilityIFDPointer - 0x0001: 'InteroperabilityIndex' - } - } - - // IFD1 directory can contain any IFD0 tags: - ExifMapProto.tags.ifd1 = ExifMapProto.tags - - ExifMapProto.stringValues = { - ExposureProgram: { - 0: 'Undefined', - 1: 'Manual', - 2: 'Normal program', - 3: 'Aperture priority', - 4: 'Shutter priority', - 5: 'Creative program', - 6: 'Action program', - 7: 'Portrait mode', - 8: 'Landscape mode' - }, - MeteringMode: { - 0: 'Unknown', - 1: 'Average', - 2: 'CenterWeightedAverage', - 3: 'Spot', - 4: 'MultiSpot', - 5: 'Pattern', - 6: 'Partial', - 255: 'Other' - }, - LightSource: { - 0: 'Unknown', - 1: 'Daylight', - 2: 'Fluorescent', - 3: 'Tungsten (incandescent light)', - 4: 'Flash', - 9: 'Fine weather', - 10: 'Cloudy weather', - 11: 'Shade', - 12: 'Daylight fluorescent (D 5700 - 7100K)', - 13: 'Day white fluorescent (N 4600 - 5400K)', - 14: 'Cool white fluorescent (W 3900 - 4500K)', - 15: 'White fluorescent (WW 3200 - 3700K)', - 17: 'Standard light A', - 18: 'Standard light B', - 19: 'Standard light C', - 20: 'D55', - 21: 'D65', - 22: 'D75', - 23: 'D50', - 24: 'ISO studio tungsten', - 255: 'Other' - }, - Flash: { - 0x0000: 'Flash did not fire', - 0x0001: 'Flash fired', - 0x0005: 'Strobe return light not detected', - 0x0007: 'Strobe return light detected', - 0x0009: 'Flash fired, compulsory flash mode', - 0x000d: 'Flash fired, compulsory flash mode, return light not detected', - 0x000f: 'Flash fired, compulsory flash mode, return light detected', - 0x0010: 'Flash did not fire, compulsory flash mode', - 0x0018: 'Flash did not fire, auto mode', - 0x0019: 'Flash fired, auto mode', - 0x001d: 'Flash fired, auto mode, return light not detected', - 0x001f: 'Flash fired, auto mode, return light detected', - 0x0020: 'No flash function', - 0x0041: 'Flash fired, red-eye reduction mode', - 0x0045: 'Flash fired, red-eye reduction mode, return light not detected', - 0x0047: 'Flash fired, red-eye reduction mode, return light detected', - 0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode', - 0x004d: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected', - 0x004f: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected', - 0x0059: 'Flash fired, auto mode, red-eye reduction mode', - 0x005d: 'Flash fired, auto mode, return light not detected, red-eye reduction mode', - 0x005f: 'Flash fired, auto mode, return light detected, red-eye reduction mode' - }, - SensingMethod: { - 1: 'Undefined', - 2: 'One-chip color area sensor', - 3: 'Two-chip color area sensor', - 4: 'Three-chip color area sensor', - 5: 'Color sequential area sensor', - 7: 'Trilinear sensor', - 8: 'Color sequential linear sensor' - }, - SceneCaptureType: { - 0: 'Standard', - 1: 'Landscape', - 2: 'Portrait', - 3: 'Night scene' - }, - SceneType: { - 1: 'Directly photographed' - }, - CustomRendered: { - 0: 'Normal process', - 1: 'Custom process' - }, - WhiteBalance: { - 0: 'Auto white balance', - 1: 'Manual white balance' - }, - GainControl: { - 0: 'None', - 1: 'Low gain up', - 2: 'High gain up', - 3: 'Low gain down', - 4: 'High gain down' - }, - Contrast: { - 0: 'Normal', - 1: 'Soft', - 2: 'Hard' - }, - Saturation: { - 0: 'Normal', - 1: 'Low saturation', - 2: 'High saturation' - }, - Sharpness: { - 0: 'Normal', - 1: 'Soft', - 2: 'Hard' - }, - SubjectDistanceRange: { - 0: 'Unknown', - 1: 'Macro', - 2: 'Close view', - 3: 'Distant view' - }, - FileSource: { - 3: 'DSC' - }, - ComponentsConfiguration: { - 0: '', - 1: 'Y', - 2: 'Cb', - 3: 'Cr', - 4: 'R', - 5: 'G', - 6: 'B' - }, - Orientation: { - 1: 'Original', - 2: 'Horizontal flip', - 3: 'Rotate 180° CCW', - 4: 'Vertical flip', - 5: 'Vertical flip + Rotate 90° CW', - 6: 'Rotate 90° CW', - 7: 'Horizontal flip + Rotate 90° CW', - 8: 'Rotate 90° CCW' - } - } - - ExifMapProto.getText = function (name) { - var value = this.get(name) - switch (name) { - case 'LightSource': - case 'Flash': - case 'MeteringMode': - case 'ExposureProgram': - case 'SensingMethod': - case 'SceneCaptureType': - case 'SceneType': - case 'CustomRendered': - case 'WhiteBalance': - case 'GainControl': - case 'Contrast': - case 'Saturation': - case 'Sharpness': - case 'SubjectDistanceRange': - case 'FileSource': - case 'Orientation': - return this.stringValues[name][value] - case 'ExifVersion': - case 'FlashpixVersion': - if (!value) return - return String.fromCharCode(value[0], value[1], value[2], value[3]) - case 'ComponentsConfiguration': - if (!value) return - return ( - this.stringValues[name][value[0]] + - this.stringValues[name][value[1]] + - this.stringValues[name][value[2]] + - this.stringValues[name][value[3]] - ) - case 'GPSVersionID': - if (!value) return - return value[0] + '.' + value[1] + '.' + value[2] + '.' + value[3] - } - return String(value) - } - - ExifMapProto.getAll = function () { - var map = {} - var prop - var obj - var name - for (prop in this) { - if (Object.prototype.hasOwnProperty.call(this, prop)) { - obj = this[prop] - if (obj && obj.getAll) { - map[this.ifds[prop].name] = obj.getAll() - } else { - name = this.tags[prop] - if (name) map[name] = this.getText(name) - } - } - } - return map - } - - ExifMapProto.getName = function (tagCode) { - var name = this.tags[tagCode] - if (typeof name === 'object') return this.ifds[tagCode].name - return name - } - - // Extend the map of tag names to tag codes: - ;(function () { - var tags = ExifMapProto.tags - var prop - var ifd - var subTags - // Map the tag names to tags: - for (prop in tags) { - if (Object.prototype.hasOwnProperty.call(tags, prop)) { - ifd = ExifMapProto.ifds[prop] - if (ifd) { - subTags = tags[prop] - for (prop in subTags) { - if (Object.prototype.hasOwnProperty.call(subTags, prop)) { - ifd.map[subTags[prop]] = Number(prop) - } - } - } else { - ExifMapProto.map[tags[prop]] = Number(prop) - } - } - } - })() -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif.js deleted file mode 100644 index 3c0937b8b590..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-exif.js +++ /dev/null @@ -1,460 +0,0 @@ -/* - * JavaScript Load Image Exif Parser - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, require, DataView */ - -/* eslint-disable no-console */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta'], factory) - } else if (typeof module === 'object' && module.exports) { - factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta')) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - /** - * Exif tag map - * - * @name ExifMap - * @class - * @param {number|string} tagCode IFD tag code - */ - function ExifMap(tagCode) { - if (tagCode) { - Object.defineProperty(this, 'map', { - value: this.ifds[tagCode].map - }) - Object.defineProperty(this, 'tags', { - value: (this.tags && this.tags[tagCode]) || {} - }) - } - } - - ExifMap.prototype.map = { - Orientation: 0x0112, - Thumbnail: 'ifd1', - Blob: 0x0201, // Alias for JPEGInterchangeFormat - Exif: 0x8769, - GPSInfo: 0x8825, - Interoperability: 0xa005 - } - - ExifMap.prototype.ifds = { - ifd1: { name: 'Thumbnail', map: ExifMap.prototype.map }, - 0x8769: { name: 'Exif', map: {} }, - 0x8825: { name: 'GPSInfo', map: {} }, - 0xa005: { name: 'Interoperability', map: {} } - } - - /** - * Retrieves exif tag value - * - * @param {number|string} id Exif tag code or name - * @returns {object} Exif tag value - */ - ExifMap.prototype.get = function (id) { - return this[id] || this[this.map[id]] - } - - /** - * Returns the Exif Thumbnail data as Blob. - * - * @param {DataView} dataView Data view interface - * @param {number} offset Thumbnail data offset - * @param {number} length Thumbnail data length - * @returns {undefined|Blob} Returns the Thumbnail Blob or undefined - */ - function getExifThumbnail(dataView, offset, length) { - if (!length) return - if (offset + length > dataView.byteLength) { - console.log('Invalid Exif data: Invalid thumbnail data.') - return - } - return new Blob( - [loadImage.bufferSlice.call(dataView.buffer, offset, offset + length)], - { - type: 'image/jpeg' - } - ) - } - - var ExifTagTypes = { - // byte, 8-bit unsigned int: - 1: { - getValue: function (dataView, dataOffset) { - return dataView.getUint8(dataOffset) - }, - size: 1 - }, - // ascii, 8-bit byte: - 2: { - getValue: function (dataView, dataOffset) { - return String.fromCharCode(dataView.getUint8(dataOffset)) - }, - size: 1, - ascii: true - }, - // short, 16 bit int: - 3: { - getValue: function (dataView, dataOffset, littleEndian) { - return dataView.getUint16(dataOffset, littleEndian) - }, - size: 2 - }, - // long, 32 bit int: - 4: { - getValue: function (dataView, dataOffset, littleEndian) { - return dataView.getUint32(dataOffset, littleEndian) - }, - size: 4 - }, - // rational = two long values, first is numerator, second is denominator: - 5: { - getValue: function (dataView, dataOffset, littleEndian) { - return ( - dataView.getUint32(dataOffset, littleEndian) / - dataView.getUint32(dataOffset + 4, littleEndian) - ) - }, - size: 8 - }, - // slong, 32 bit signed int: - 9: { - getValue: function (dataView, dataOffset, littleEndian) { - return dataView.getInt32(dataOffset, littleEndian) - }, - size: 4 - }, - // srational, two slongs, first is numerator, second is denominator: - 10: { - getValue: function (dataView, dataOffset, littleEndian) { - return ( - dataView.getInt32(dataOffset, littleEndian) / - dataView.getInt32(dataOffset + 4, littleEndian) - ) - }, - size: 8 - } - } - // undefined, 8-bit byte, value depending on field: - ExifTagTypes[7] = ExifTagTypes[1] - - /** - * Returns Exif tag value. - * - * @param {DataView} dataView Data view interface - * @param {number} tiffOffset TIFF offset - * @param {number} offset Tag offset - * @param {number} type Tag type - * @param {number} length Tag length - * @param {boolean} littleEndian Little endian encoding - * @returns {object} Tag value - */ - function getExifValue( - dataView, - tiffOffset, - offset, - type, - length, - littleEndian - ) { - var tagType = ExifTagTypes[type] - var tagSize - var dataOffset - var values - var i - var str - var c - if (!tagType) { - console.log('Invalid Exif data: Invalid tag type.') - return - } - tagSize = tagType.size * length - // Determine if the value is contained in the dataOffset bytes, - // or if the value at the dataOffset is a pointer to the actual data: - dataOffset = - tagSize > 4 - ? tiffOffset + dataView.getUint32(offset + 8, littleEndian) - : offset + 8 - if (dataOffset + tagSize > dataView.byteLength) { - console.log('Invalid Exif data: Invalid data offset.') - return - } - if (length === 1) { - return tagType.getValue(dataView, dataOffset, littleEndian) - } - values = [] - for (i = 0; i < length; i += 1) { - values[i] = tagType.getValue( - dataView, - dataOffset + i * tagType.size, - littleEndian - ) - } - if (tagType.ascii) { - str = '' - // Concatenate the chars: - for (i = 0; i < values.length; i += 1) { - c = values[i] - // Ignore the terminating NULL byte(s): - if (c === '\u0000') { - break - } - str += c - } - return str - } - return values - } - - /** - * Determines if the given tag should be included. - * - * @param {object} includeTags Map of tags to include - * @param {object} excludeTags Map of tags to exclude - * @param {number|string} tagCode Tag code to check - * @returns {boolean} True if the tag should be included - */ - function shouldIncludeTag(includeTags, excludeTags, tagCode) { - return ( - (!includeTags || includeTags[tagCode]) && - (!excludeTags || excludeTags[tagCode] !== true) - ) - } - - /** - * Parses Exif tags. - * - * @param {DataView} dataView Data view interface - * @param {number} tiffOffset TIFF offset - * @param {number} dirOffset Directory offset - * @param {boolean} littleEndian Little endian encoding - * @param {ExifMap} tags Map to store parsed exif tags - * @param {ExifMap} tagOffsets Map to store parsed exif tag offsets - * @param {object} includeTags Map of tags to include - * @param {object} excludeTags Map of tags to exclude - * @returns {number} Next directory offset - */ - function parseExifTags( - dataView, - tiffOffset, - dirOffset, - littleEndian, - tags, - tagOffsets, - includeTags, - excludeTags - ) { - var tagsNumber, dirEndOffset, i, tagOffset, tagNumber, tagValue - if (dirOffset + 6 > dataView.byteLength) { - console.log('Invalid Exif data: Invalid directory offset.') - return - } - tagsNumber = dataView.getUint16(dirOffset, littleEndian) - dirEndOffset = dirOffset + 2 + 12 * tagsNumber - if (dirEndOffset + 4 > dataView.byteLength) { - console.log('Invalid Exif data: Invalid directory size.') - return - } - for (i = 0; i < tagsNumber; i += 1) { - tagOffset = dirOffset + 2 + 12 * i - tagNumber = dataView.getUint16(tagOffset, littleEndian) - if (!shouldIncludeTag(includeTags, excludeTags, tagNumber)) continue - tagValue = getExifValue( - dataView, - tiffOffset, - tagOffset, - dataView.getUint16(tagOffset + 2, littleEndian), // tag type - dataView.getUint32(tagOffset + 4, littleEndian), // tag length - littleEndian - ) - tags[tagNumber] = tagValue - if (tagOffsets) { - tagOffsets[tagNumber] = tagOffset - } - } - // Return the offset to the next directory: - return dataView.getUint32(dirEndOffset, littleEndian) - } - - /** - * Parses tags in a given IFD (Image File Directory). - * - * @param {object} data Data object to store exif tags and offsets - * @param {number|string} tagCode IFD tag code - * @param {DataView} dataView Data view interface - * @param {number} tiffOffset TIFF offset - * @param {boolean} littleEndian Little endian encoding - * @param {object} includeTags Map of tags to include - * @param {object} excludeTags Map of tags to exclude - */ - function parseExifIFD( - data, - tagCode, - dataView, - tiffOffset, - littleEndian, - includeTags, - excludeTags - ) { - var dirOffset = data.exif[tagCode] - if (dirOffset) { - data.exif[tagCode] = new ExifMap(tagCode) - if (data.exifOffsets) { - data.exifOffsets[tagCode] = new ExifMap(tagCode) - } - parseExifTags( - dataView, - tiffOffset, - tiffOffset + dirOffset, - littleEndian, - data.exif[tagCode], - data.exifOffsets && data.exifOffsets[tagCode], - includeTags && includeTags[tagCode], - excludeTags && excludeTags[tagCode] - ) - } - } - - loadImage.parseExifData = function (dataView, offset, length, data, options) { - if (options.disableExif) { - return - } - var includeTags = options.includeExifTags - var excludeTags = options.excludeExifTags || { - 0x8769: { - // ExifIFDPointer - 0x927c: true // MakerNote - } - } - var tiffOffset = offset + 10 - var littleEndian - var dirOffset - var thumbnailIFD - // Check for the ASCII code for "Exif" (0x45786966): - if (dataView.getUint32(offset + 4) !== 0x45786966) { - // No Exif data, might be XMP data instead - return - } - if (tiffOffset + 8 > dataView.byteLength) { - console.log('Invalid Exif data: Invalid segment size.') - return - } - // Check for the two null bytes: - if (dataView.getUint16(offset + 8) !== 0x0000) { - console.log('Invalid Exif data: Missing byte alignment offset.') - return - } - // Check the byte alignment: - switch (dataView.getUint16(tiffOffset)) { - case 0x4949: - littleEndian = true - break - case 0x4d4d: - littleEndian = false - break - default: - console.log('Invalid Exif data: Invalid byte alignment marker.') - return - } - // Check for the TIFF tag marker (0x002A): - if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002a) { - console.log('Invalid Exif data: Missing TIFF marker.') - return - } - // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal: - dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian) - // Create the exif object to store the tags: - data.exif = new ExifMap() - if (!options.disableExifOffsets) { - data.exifOffsets = new ExifMap() - data.exifTiffOffset = tiffOffset - data.exifLittleEndian = littleEndian - } - // Parse the tags of the main image directory (IFD0) and retrieve the - // offset to the next directory (IFD1), usually the thumbnail directory: - dirOffset = parseExifTags( - dataView, - tiffOffset, - tiffOffset + dirOffset, - littleEndian, - data.exif, - data.exifOffsets, - includeTags, - excludeTags - ) - if (dirOffset && shouldIncludeTag(includeTags, excludeTags, 'ifd1')) { - data.exif.ifd1 = dirOffset - if (data.exifOffsets) { - data.exifOffsets.ifd1 = tiffOffset + dirOffset - } - } - Object.keys(data.exif.ifds).forEach(function (tagCode) { - parseExifIFD( - data, - tagCode, - dataView, - tiffOffset, - littleEndian, - includeTags, - excludeTags - ) - }) - thumbnailIFD = data.exif.ifd1 - // Check for JPEG Thumbnail offset and data length: - if (thumbnailIFD && thumbnailIFD[0x0201]) { - thumbnailIFD[0x0201] = getExifThumbnail( - dataView, - tiffOffset + thumbnailIFD[0x0201], - thumbnailIFD[0x0202] // Thumbnail data length - ) - } - } - - // Registers the Exif parser for the APP1 JPEG metadata segment: - loadImage.metaDataParsers.jpeg[0xffe1].push(loadImage.parseExifData) - - loadImage.exifWriters = { - // Orientation writer: - 0x0112: function (buffer, data, value) { - var orientationOffset = data.exifOffsets[0x0112] - if (!orientationOffset) return buffer - var view = new DataView(buffer, orientationOffset + 8, 2) - view.setUint16(0, value, data.exifLittleEndian) - return buffer - } - } - - loadImage.writeExifData = function (buffer, data, id, value) { - loadImage.exifWriters[data.exif.map[id]](buffer, data, value) - } - - loadImage.ExifMap = ExifMap - - // Adds the following properties to the parseMetaData callback data: - // - exif: The parsed Exif tags - // - exifOffsets: The parsed Exif tag offsets - // - exifTiffOffset: TIFF header offset (used for offset pointers) - // - exifLittleEndian: little endian order if true, big endian if false - - // Adds the following options to the parseMetaData method: - // - disableExif: Disables Exif parsing when true. - // - disableExifOffsets: Disables storing Exif tag offsets when true. - // - includeExifTags: A map of Exif tags to include for parsing. - // - excludeExifTags: A map of Exif tags to exclude from parsing. -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-fetch.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-fetch.js deleted file mode 100644 index 28a28fb83e6c..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-fetch.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * JavaScript Load Image Fetch - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2017, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, require, Promise */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image'], factory) - } else if (typeof module === 'object' && module.exports) { - factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image')) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - var global = loadImage.global - - if ( - global.fetch && - global.Request && - global.Response && - global.Response.prototype.blob - ) { - loadImage.fetchBlob = function (url, callback, options) { - /** - * Fetch response handler. - * - * @param {Response} response Fetch response - * @returns {Blob} Fetched Blob. - */ - function responseHandler(response) { - return response.blob() - } - if (global.Promise && typeof callback !== 'function') { - return fetch(new Request(url, callback)).then(responseHandler) - } - fetch(new Request(url, options)) - .then(responseHandler) - .then(callback) - [ - // Avoid parsing error in IE<9, where catch is a reserved word. - // eslint-disable-next-line dot-notation - 'catch' - ](function (err) { - callback(null, err) - }) - } - } else if ( - global.XMLHttpRequest && - // https://xhr.spec.whatwg.org/#the-responsetype-attribute - new XMLHttpRequest().responseType === '' - ) { - loadImage.fetchBlob = function (url, callback, options) { - /** - * Promise executor - * - * @param {Function} resolve Resolution function - * @param {Function} reject Rejection function - */ - function executor(resolve, reject) { - options = options || {} // eslint-disable-line no-param-reassign - var req = new XMLHttpRequest() - req.open(options.method || 'GET', url) - if (options.headers) { - Object.keys(options.headers).forEach(function (key) { - req.setRequestHeader(key, options.headers[key]) - }) - } - req.withCredentials = options.credentials === 'include' - req.responseType = 'blob' - req.onload = function () { - resolve(req.response) - } - req.onerror = req.onabort = req.ontimeout = function (err) { - if (resolve === reject) { - // Not using Promises - reject(null, err) - } else { - reject(err) - } - } - req.send(options.body) - } - if (global.Promise && typeof callback !== 'function') { - options = callback // eslint-disable-line no-param-reassign - return new Promise(executor) - } - return executor(callback, callback) - } - } -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc-map.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc-map.js deleted file mode 100644 index cd959a24b354..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc-map.js +++ /dev/null @@ -1,169 +0,0 @@ -/* - * JavaScript Load Image IPTC Map - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2013, Sebastian Tschan - * Copyright 2018, Dave Bevan - * - * IPTC tags mapping based on - * https://iptc.org/standards/photo-metadata - * https://exiftool.org/TagNames/IPTC.html - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, require */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc'], factory) - } else if (typeof module === 'object' && module.exports) { - factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc')) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - var IptcMapProto = loadImage.IptcMap.prototype - - IptcMapProto.tags = { - 0: 'ApplicationRecordVersion', - 3: 'ObjectTypeReference', - 4: 'ObjectAttributeReference', - 5: 'ObjectName', - 7: 'EditStatus', - 8: 'EditorialUpdate', - 10: 'Urgency', - 12: 'SubjectReference', - 15: 'Category', - 20: 'SupplementalCategories', - 22: 'FixtureIdentifier', - 25: 'Keywords', - 26: 'ContentLocationCode', - 27: 'ContentLocationName', - 30: 'ReleaseDate', - 35: 'ReleaseTime', - 37: 'ExpirationDate', - 38: 'ExpirationTime', - 40: 'SpecialInstructions', - 42: 'ActionAdvised', - 45: 'ReferenceService', - 47: 'ReferenceDate', - 50: 'ReferenceNumber', - 55: 'DateCreated', - 60: 'TimeCreated', - 62: 'DigitalCreationDate', - 63: 'DigitalCreationTime', - 65: 'OriginatingProgram', - 70: 'ProgramVersion', - 75: 'ObjectCycle', - 80: 'Byline', - 85: 'BylineTitle', - 90: 'City', - 92: 'Sublocation', - 95: 'State', - 100: 'CountryCode', - 101: 'Country', - 103: 'OriginalTransmissionReference', - 105: 'Headline', - 110: 'Credit', - 115: 'Source', - 116: 'CopyrightNotice', - 118: 'Contact', - 120: 'Caption', - 121: 'LocalCaption', - 122: 'Writer', - 125: 'RasterizedCaption', - 130: 'ImageType', - 131: 'ImageOrientation', - 135: 'LanguageIdentifier', - 150: 'AudioType', - 151: 'AudioSamplingRate', - 152: 'AudioSamplingResolution', - 153: 'AudioDuration', - 154: 'AudioOutcue', - 184: 'JobID', - 185: 'MasterDocumentID', - 186: 'ShortDocumentID', - 187: 'UniqueDocumentID', - 188: 'OwnerID', - 200: 'ObjectPreviewFileFormat', - 201: 'ObjectPreviewFileVersion', - 202: 'ObjectPreviewData', - 221: 'Prefs', - 225: 'ClassifyState', - 228: 'SimilarityIndex', - 230: 'DocumentNotes', - 231: 'DocumentHistory', - 232: 'ExifCameraInfo', - 255: 'CatalogSets' - } - - IptcMapProto.stringValues = { - 10: { - 0: '0 (reserved)', - 1: '1 (most urgent)', - 2: '2', - 3: '3', - 4: '4', - 5: '5 (normal urgency)', - 6: '6', - 7: '7', - 8: '8 (least urgent)', - 9: '9 (user-defined priority)' - }, - 75: { - a: 'Morning', - b: 'Both Morning and Evening', - p: 'Evening' - }, - 131: { - L: 'Landscape', - P: 'Portrait', - S: 'Square' - } - } - - IptcMapProto.getText = function (id) { - var value = this.get(id) - var tagCode = this.map[id] - var stringValue = this.stringValues[tagCode] - if (stringValue) return stringValue[value] - return String(value) - } - - IptcMapProto.getAll = function () { - var map = {} - var prop - var name - for (prop in this) { - if (Object.prototype.hasOwnProperty.call(this, prop)) { - name = this.tags[prop] - if (name) map[name] = this.getText(name) - } - } - return map - } - - IptcMapProto.getName = function (tagCode) { - return this.tags[tagCode] - } - - // Extend the map of tag names to tag codes: - ;(function () { - var tags = IptcMapProto.tags - var map = IptcMapProto.map || {} - var prop - // Map the tag names to tags: - for (prop in tags) { - if (Object.prototype.hasOwnProperty.call(tags, prop)) { - map[tags[prop]] = Number(prop) - } - } - })() -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc.js deleted file mode 100644 index f6b4594f9e13..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-iptc.js +++ /dev/null @@ -1,239 +0,0 @@ -/* - * JavaScript Load Image IPTC Parser - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2013, Sebastian Tschan - * Copyright 2018, Dave Bevan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, require, DataView */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta'], factory) - } else if (typeof module === 'object' && module.exports) { - factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta')) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - /** - * IPTC tag map - * - * @name IptcMap - * @class - */ - function IptcMap() {} - - IptcMap.prototype.map = { - ObjectName: 5 - } - - IptcMap.prototype.types = { - 0: 'Uint16', // ApplicationRecordVersion - 200: 'Uint16', // ObjectPreviewFileFormat - 201: 'Uint16', // ObjectPreviewFileVersion - 202: 'binary' // ObjectPreviewData - } - - /** - * Retrieves IPTC tag value - * - * @param {number|string} id IPTC tag code or name - * @returns {object} IPTC tag value - */ - IptcMap.prototype.get = function (id) { - return this[id] || this[this.map[id]] - } - - /** - * Retrieves string for the given DataView and range - * - * @param {DataView} dataView Data view interface - * @param {number} offset Offset start - * @param {number} length Offset length - * @returns {string} String value - */ - function getStringValue(dataView, offset, length) { - var outstr = '' - var end = offset + length - for (var n = offset; n < end; n += 1) { - outstr += String.fromCharCode(dataView.getUint8(n)) - } - return outstr - } - - /** - * Retrieves tag value for the given DataView and range - * - * @param {number} tagCode tag code - * @param {IptcMap} map IPTC tag map - * @param {DataView} dataView Data view interface - * @param {number} offset Range start - * @param {number} length Range length - * @returns {object} Tag value - */ - function getTagValue(tagCode, map, dataView, offset, length) { - if (map.types[tagCode] === 'binary') { - return new Blob([dataView.buffer.slice(offset, offset + length)]) - } - if (map.types[tagCode] === 'Uint16') { - return dataView.getUint16(offset) - } - return getStringValue(dataView, offset, length) - } - - /** - * Combines IPTC value with existing ones. - * - * @param {object} value Existing IPTC field value - * @param {object} newValue New IPTC field value - * @returns {object} Resulting IPTC field value - */ - function combineTagValues(value, newValue) { - if (value === undefined) return newValue - if (value instanceof Array) { - value.push(newValue) - return value - } - return [value, newValue] - } - - /** - * Parses IPTC tags. - * - * @param {DataView} dataView Data view interface - * @param {number} segmentOffset Segment offset - * @param {number} segmentLength Segment length - * @param {object} data Data export object - * @param {object} includeTags Map of tags to include - * @param {object} excludeTags Map of tags to exclude - */ - function parseIptcTags( - dataView, - segmentOffset, - segmentLength, - data, - includeTags, - excludeTags - ) { - var value, tagSize, tagCode - var segmentEnd = segmentOffset + segmentLength - var offset = segmentOffset - while (offset < segmentEnd) { - if ( - dataView.getUint8(offset) === 0x1c && // tag marker - dataView.getUint8(offset + 1) === 0x02 // record number, only handles v2 - ) { - tagCode = dataView.getUint8(offset + 2) - if ( - (!includeTags || includeTags[tagCode]) && - (!excludeTags || !excludeTags[tagCode]) - ) { - tagSize = dataView.getInt16(offset + 3) - value = getTagValue(tagCode, data.iptc, dataView, offset + 5, tagSize) - data.iptc[tagCode] = combineTagValues(data.iptc[tagCode], value) - if (data.iptcOffsets) { - data.iptcOffsets[tagCode] = offset - } - } - } - offset += 1 - } - } - - /** - * Tests if field segment starts at offset. - * - * @param {DataView} dataView Data view interface - * @param {number} offset Segment offset - * @returns {boolean} True if '8BIM' exists at offset - */ - function isSegmentStart(dataView, offset) { - return ( - dataView.getUint32(offset) === 0x3842494d && // Photoshop segment start - dataView.getUint16(offset + 4) === 0x0404 // IPTC segment start - ) - } - - /** - * Returns header length. - * - * @param {DataView} dataView Data view interface - * @param {number} offset Segment offset - * @returns {number} Header length - */ - function getHeaderLength(dataView, offset) { - var length = dataView.getUint8(offset + 7) - if (length % 2 !== 0) length += 1 - // Check for pre photoshop 6 format - if (length === 0) { - // Always 4 - length = 4 - } - return length - } - - loadImage.parseIptcData = function (dataView, offset, length, data, options) { - if (options.disableIptc) { - return - } - var markerLength = offset + length - while (offset + 8 < markerLength) { - if (isSegmentStart(dataView, offset)) { - var headerLength = getHeaderLength(dataView, offset) - var segmentOffset = offset + 8 + headerLength - if (segmentOffset > markerLength) { - // eslint-disable-next-line no-console - console.log('Invalid IPTC data: Invalid segment offset.') - break - } - var segmentLength = dataView.getUint16(offset + 6 + headerLength) - if (offset + segmentLength > markerLength) { - // eslint-disable-next-line no-console - console.log('Invalid IPTC data: Invalid segment size.') - break - } - // Create the iptc object to store the tags: - data.iptc = new IptcMap() - if (!options.disableIptcOffsets) { - data.iptcOffsets = new IptcMap() - } - parseIptcTags( - dataView, - segmentOffset, - segmentLength, - data, - options.includeIptcTags, - options.excludeIptcTags || { 202: true } // ObjectPreviewData - ) - return - } - // eslint-disable-next-line no-param-reassign - offset += 1 - } - } - - // Registers this IPTC parser for the APP13 JPEG metadata segment: - loadImage.metaDataParsers.jpeg[0xffed].push(loadImage.parseIptcData) - - loadImage.IptcMap = IptcMap - - // Adds the following properties to the parseMetaData callback data: - // - iptc: The iptc tags, parsed by the parseIptcData method - - // Adds the following options to the parseMetaData method: - // - disableIptc: Disables IPTC parsing when true. - // - disableIptcOffsets: Disables storing IPTC tag offsets when true. - // - includeIptcTags: A map of IPTC tags to include for parsing. - // - excludeIptcTags: A map of IPTC tags to exclude from parsing. -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta.js deleted file mode 100644 index 20a06184c640..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta.js +++ /dev/null @@ -1,259 +0,0 @@ -/* - * JavaScript Load Image Meta - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Image metadata handling implementation - * based on the help and contribution of - * Achim Stöhr. - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, require, Promise, DataView, Uint8Array, ArrayBuffer */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image'], factory) - } else if (typeof module === 'object' && module.exports) { - factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image')) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - var global = loadImage.global - var originalTransform = loadImage.transform - - var blobSlice = - global.Blob && - (Blob.prototype.slice || - Blob.prototype.webkitSlice || - Blob.prototype.mozSlice) - - var bufferSlice = - (global.ArrayBuffer && ArrayBuffer.prototype.slice) || - function (begin, end) { - // Polyfill for IE10, which does not support ArrayBuffer.slice - // eslint-disable-next-line no-param-reassign - end = end || this.byteLength - begin - var arr1 = new Uint8Array(this, begin, end) - var arr2 = new Uint8Array(end) - arr2.set(arr1) - return arr2.buffer - } - - var metaDataParsers = { - jpeg: { - 0xffe1: [], // APP1 marker - 0xffed: [] // APP13 marker - } - } - - /** - * Parses image metadata and calls the callback with an object argument - * with the following property: - * - imageHead: The complete image head as ArrayBuffer - * The options argument accepts an object and supports the following - * properties: - * - maxMetaDataSize: Defines the maximum number of bytes to parse. - * - disableImageHead: Disables creating the imageHead property. - * - * @param {Blob} file Blob object - * @param {Function} [callback] Callback function - * @param {object} [options] Parsing options - * @param {object} [data] Result data object - * @returns {Promise|undefined} Returns Promise if no callback given. - */ - function parseMetaData(file, callback, options, data) { - var that = this - /** - * Promise executor - * - * @param {Function} resolve Resolution function - * @param {Function} reject Rejection function - * @returns {undefined} Undefined - */ - function executor(resolve, reject) { - if ( - !( - global.DataView && - blobSlice && - file && - file.size >= 12 && - file.type === 'image/jpeg' - ) - ) { - // Nothing to parse - return resolve(data) - } - // 256 KiB should contain all EXIF/ICC/IPTC segments: - var maxMetaDataSize = options.maxMetaDataSize || 262144 - if ( - !loadImage.readFile( - blobSlice.call(file, 0, maxMetaDataSize), - function (buffer) { - // Note on endianness: - // Since the marker and length bytes in JPEG files are always - // stored in big endian order, we can leave the endian parameter - // of the DataView methods undefined, defaulting to big endian. - var dataView = new DataView(buffer) - // Check for the JPEG marker (0xffd8): - if (dataView.getUint16(0) !== 0xffd8) { - return reject( - new Error('Invalid JPEG file: Missing JPEG marker.') - ) - } - var offset = 2 - var maxOffset = dataView.byteLength - 4 - var headLength = offset - var markerBytes - var markerLength - var parsers - var i - while (offset < maxOffset) { - markerBytes = dataView.getUint16(offset) - // Search for APPn (0xffeN) and COM (0xfffe) markers, - // which contain application-specific metadata like - // Exif, ICC and IPTC data and text comments: - if ( - (markerBytes >= 0xffe0 && markerBytes <= 0xffef) || - markerBytes === 0xfffe - ) { - // The marker bytes (2) are always followed by - // the length bytes (2), indicating the length of the - // marker segment, which includes the length bytes, - // but not the marker bytes, so we add 2: - markerLength = dataView.getUint16(offset + 2) + 2 - if (offset + markerLength > dataView.byteLength) { - // eslint-disable-next-line no-console - console.log('Invalid JPEG metadata: Invalid segment size.') - break - } - parsers = metaDataParsers.jpeg[markerBytes] - if (parsers && !options.disableMetaDataParsers) { - for (i = 0; i < parsers.length; i += 1) { - parsers[i].call( - that, - dataView, - offset, - markerLength, - data, - options - ) - } - } - offset += markerLength - headLength = offset - } else { - // Not an APPn or COM marker, probably safe to - // assume that this is the end of the metadata - break - } - } - // Meta length must be longer than JPEG marker (2) - // plus APPn marker (2), followed by length bytes (2): - if (!options.disableImageHead && headLength > 6) { - data.imageHead = bufferSlice.call(buffer, 0, headLength) - } - resolve(data) - }, - reject, - 'readAsArrayBuffer' - ) - ) { - // No support for the FileReader interface, nothing to parse - resolve(data) - } - } - options = options || {} // eslint-disable-line no-param-reassign - if (global.Promise && typeof callback !== 'function') { - options = callback || {} // eslint-disable-line no-param-reassign - data = options // eslint-disable-line no-param-reassign - return new Promise(executor) - } - data = data || {} // eslint-disable-line no-param-reassign - return executor(callback, callback) - } - - /** - * Replaces the head of a JPEG Blob - * - * @param {Blob} blob Blob object - * @param {ArrayBuffer} oldHead Old JPEG head - * @param {ArrayBuffer} newHead New JPEG head - * @returns {Blob} Combined Blob - */ - function replaceJPEGHead(blob, oldHead, newHead) { - if (!blob || !oldHead || !newHead) return null - return new Blob([newHead, blobSlice.call(blob, oldHead.byteLength)], { - type: 'image/jpeg' - }) - } - - /** - * Replaces the image head of a JPEG blob with the given one. - * Returns a Promise or calls the callback with the new Blob. - * - * @param {Blob} blob Blob object - * @param {ArrayBuffer} head New JPEG head - * @param {Function} [callback] Callback function - * @returns {Promise|undefined} Combined Blob - */ - function replaceHead(blob, head, callback) { - var options = { maxMetaDataSize: 256, disableMetaDataParsers: true } - if (!callback && global.Promise) { - return parseMetaData(blob, options).then(function (data) { - return replaceJPEGHead(blob, data.imageHead, head) - }) - } - parseMetaData( - blob, - function (data) { - callback(replaceJPEGHead(blob, data.imageHead, head)) - }, - options - ) - } - - loadImage.transform = function (img, options, callback, file, data) { - if (loadImage.requiresMetaData(options)) { - data = data || {} // eslint-disable-line no-param-reassign - parseMetaData( - file, - function (result) { - if (result !== data) { - // eslint-disable-next-line no-console - if (global.console) console.log(result) - result = data // eslint-disable-line no-param-reassign - } - originalTransform.call( - loadImage, - img, - options, - callback, - file, - result - ) - }, - options, - data - ) - } else { - originalTransform.apply(loadImage, arguments) - } - } - - loadImage.blobSlice = blobSlice - loadImage.bufferSlice = bufferSlice - loadImage.replaceHead = replaceHead - loadImage.parseMetaData = parseMetaData - loadImage.metaDataParsers = metaDataParsers -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-orientation.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-orientation.js deleted file mode 100644 index 2b32a368e5f5..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-orientation.js +++ /dev/null @@ -1,481 +0,0 @@ -/* - * JavaScript Load Image Orientation - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2013, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* -Exif orientation values to correctly display the letter F: - - 1 2 - ██████ ██████ - ██ ██ - ████ ████ - ██ ██ - ██ ██ - - 3 4 - ██ ██ - ██ ██ - ████ ████ - ██ ██ - ██████ ██████ - - 5 6 -██████████ ██ -██ ██ ██ ██ -██ ██████████ - - 7 8 - ██ ██████████ - ██ ██ ██ ██ -██████████ ██ - -*/ - -/* global define, module, require */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale', 'jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta'], factory) - } else if (typeof module === 'object' && module.exports) { - factory( - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale'), - require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image-meta') - ) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - var originalTransform = loadImage.transform - var originalRequiresCanvas = loadImage.requiresCanvas - var originalRequiresMetaData = loadImage.requiresMetaData - var originalTransformCoordinates = loadImage.transformCoordinates - var originalGetTransformedOptions = loadImage.getTransformedOptions - - ;(function ($) { - // Guard for non-browser environments (e.g. server-side rendering): - if (!$.global.document) return - // black+white 3x2 JPEG, with the following meta information set: - // - EXIF Orientation: 6 (Rotated 90° CCW) - // Image data layout (B=black, F=white): - // BFF - // BBB - var testImageURL = - 'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' + - 'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' + - 'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' + - 'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/x' + - 'ABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAA' + - 'AAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQ' + - 'voP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXw' + - 'H/9k=' - var img = document.createElement('img') - img.onload = function () { - // Check if the browser supports automatic image orientation: - $.orientation = img.width === 2 && img.height === 3 - if ($.orientation) { - var canvas = $.createCanvas(1, 1, true) - var ctx = canvas.getContext('2d') - ctx.drawImage(img, 1, 1, 1, 1, 0, 0, 1, 1) - // Check if the source image coordinates (sX, sY, sWidth, sHeight) are - // correctly applied to the auto-orientated image, which should result - // in a white opaque pixel (e.g. in Safari). - // Browsers that show a transparent pixel (e.g. Chromium) fail to crop - // auto-oriented images correctly and require a workaround, e.g. - // drawing the complete source image to an intermediate canvas first. - // See https://bugs.chromium.org/p/chromium/issues/detail?id=1074354 - $.orientationCropBug = - ctx.getImageData(0, 0, 1, 1).data.toString() !== '255,255,255,255' - } - } - img.src = testImageURL - })(loadImage) - - /** - * Determines if the orientation requires a canvas element. - * - * @param {object} [options] Options object - * @param {boolean} [withMetaData] Is metadata required for orientation - * @returns {boolean} Returns true if orientation requires canvas/meta - */ - function requiresCanvasOrientation(options, withMetaData) { - var orientation = options && options.orientation - return ( - // Exif orientation for browsers without automatic image orientation: - (orientation === true && !loadImage.orientation) || - // Orientation reset for browsers with automatic image orientation: - (orientation === 1 && loadImage.orientation) || - // Orientation to defined value, requires meta for orientation reset only: - ((!withMetaData || loadImage.orientation) && - orientation > 1 && - orientation < 9) - ) - } - - /** - * Determines if the image requires an orientation change. - * - * @param {number} [orientation] Defined orientation value - * @param {number} [autoOrientation] Auto-orientation based on Exif data - * @returns {boolean} Returns true if an orientation change is required - */ - function requiresOrientationChange(orientation, autoOrientation) { - return ( - orientation !== autoOrientation && - ((orientation === 1 && autoOrientation > 1 && autoOrientation < 9) || - (orientation > 1 && orientation < 9)) - ) - } - - /** - * Determines orientation combinations that require a rotation by 180°. - * - * The following is a list of combinations that return true: - * - * 2 (flip) => 5 (rot90,flip), 7 (rot90,flip), 6 (rot90), 8 (rot90) - * 4 (flip) => 5 (rot90,flip), 7 (rot90,flip), 6 (rot90), 8 (rot90) - * - * 5 (rot90,flip) => 2 (flip), 4 (flip), 6 (rot90), 8 (rot90) - * 7 (rot90,flip) => 2 (flip), 4 (flip), 6 (rot90), 8 (rot90) - * - * 6 (rot90) => 2 (flip), 4 (flip), 5 (rot90,flip), 7 (rot90,flip) - * 8 (rot90) => 2 (flip), 4 (flip), 5 (rot90,flip), 7 (rot90,flip) - * - * @param {number} [orientation] Defined orientation value - * @param {number} [autoOrientation] Auto-orientation based on Exif data - * @returns {boolean} Returns true if rotation by 180° is required - */ - function requiresRot180(orientation, autoOrientation) { - if (autoOrientation > 1 && autoOrientation < 9) { - switch (orientation) { - case 2: - case 4: - return autoOrientation > 4 - case 5: - case 7: - return autoOrientation % 2 === 0 - case 6: - case 8: - return ( - autoOrientation === 2 || - autoOrientation === 4 || - autoOrientation === 5 || - autoOrientation === 7 - ) - } - } - return false - } - - // Determines if the target image should be a canvas element: - loadImage.requiresCanvas = function (options) { - return ( - requiresCanvasOrientation(options) || - originalRequiresCanvas.call(loadImage, options) - ) - } - - // Determines if metadata should be loaded automatically: - loadImage.requiresMetaData = function (options) { - return ( - requiresCanvasOrientation(options, true) || - originalRequiresMetaData.call(loadImage, options) - ) - } - - loadImage.transform = function (img, options, callback, file, data) { - originalTransform.call( - loadImage, - img, - options, - function (img, data) { - if (data) { - var autoOrientation = - loadImage.orientation && data.exif && data.exif.get('Orientation') - if (autoOrientation > 4 && autoOrientation < 9) { - // Automatic image orientation switched image dimensions - var originalWidth = data.originalWidth - var originalHeight = data.originalHeight - data.originalWidth = originalHeight - data.originalHeight = originalWidth - } - } - callback(img, data) - }, - file, - data - ) - } - - // Transforms coordinate and dimension options - // based on the given orientation option: - loadImage.getTransformedOptions = function (img, opts, data) { - var options = originalGetTransformedOptions.call(loadImage, img, opts) - var exifOrientation = data.exif && data.exif.get('Orientation') - var orientation = options.orientation - var autoOrientation = loadImage.orientation && exifOrientation - if (orientation === true) orientation = exifOrientation - if (!requiresOrientationChange(orientation, autoOrientation)) { - return options - } - var top = options.top - var right = options.right - var bottom = options.bottom - var left = options.left - var newOptions = {} - for (var i in options) { - if (Object.prototype.hasOwnProperty.call(options, i)) { - newOptions[i] = options[i] - } - } - newOptions.orientation = orientation - if ( - (orientation > 4 && !(autoOrientation > 4)) || - (orientation < 5 && autoOrientation > 4) - ) { - // Image dimensions and target dimensions are switched - newOptions.maxWidth = options.maxHeight - newOptions.maxHeight = options.maxWidth - newOptions.minWidth = options.minHeight - newOptions.minHeight = options.minWidth - newOptions.sourceWidth = options.sourceHeight - newOptions.sourceHeight = options.sourceWidth - } - if (autoOrientation > 1) { - // Browsers which correctly apply source image coordinates to - // auto-oriented images - switch (autoOrientation) { - case 2: - // Horizontal flip - right = options.left - left = options.right - break - case 3: - // 180° Rotate CCW - top = options.bottom - right = options.left - bottom = options.top - left = options.right - break - case 4: - // Vertical flip - top = options.bottom - bottom = options.top - break - case 5: - // Horizontal flip + 90° Rotate CCW - top = options.left - right = options.bottom - bottom = options.right - left = options.top - break - case 6: - // 90° Rotate CCW - top = options.left - right = options.top - bottom = options.right - left = options.bottom - break - case 7: - // Vertical flip + 90° Rotate CCW - top = options.right - right = options.top - bottom = options.left - left = options.bottom - break - case 8: - // 90° Rotate CW - top = options.right - right = options.bottom - bottom = options.left - left = options.top - break - } - // Some orientation combinations require additional rotation by 180°: - if (requiresRot180(orientation, autoOrientation)) { - var tmpTop = top - var tmpRight = right - top = bottom - right = left - bottom = tmpTop - left = tmpRight - } - } - newOptions.top = top - newOptions.right = right - newOptions.bottom = bottom - newOptions.left = left - // Account for defined browser orientation: - switch (orientation) { - case 2: - // Horizontal flip - newOptions.right = left - newOptions.left = right - break - case 3: - // 180° Rotate CCW - newOptions.top = bottom - newOptions.right = left - newOptions.bottom = top - newOptions.left = right - break - case 4: - // Vertical flip - newOptions.top = bottom - newOptions.bottom = top - break - case 5: - // Vertical flip + 90° Rotate CW - newOptions.top = left - newOptions.right = bottom - newOptions.bottom = right - newOptions.left = top - break - case 6: - // 90° Rotate CW - newOptions.top = right - newOptions.right = bottom - newOptions.bottom = left - newOptions.left = top - break - case 7: - // Horizontal flip + 90° Rotate CW - newOptions.top = right - newOptions.right = top - newOptions.bottom = left - newOptions.left = bottom - break - case 8: - // 90° Rotate CCW - newOptions.top = left - newOptions.right = top - newOptions.bottom = right - newOptions.left = bottom - break - } - return newOptions - } - - // Transform image orientation based on the given EXIF orientation option: - loadImage.transformCoordinates = function (canvas, options, data) { - originalTransformCoordinates.call(loadImage, canvas, options, data) - var orientation = options.orientation - var autoOrientation = - loadImage.orientation && data.exif && data.exif.get('Orientation') - if (!requiresOrientationChange(orientation, autoOrientation)) { - return - } - var ctx = canvas.getContext('2d') - var width = canvas.width - var height = canvas.height - var sourceWidth = width - var sourceHeight = height - if ( - (orientation > 4 && !(autoOrientation > 4)) || - (orientation < 5 && autoOrientation > 4) - ) { - // Image dimensions and target dimensions are switched - canvas.width = height - canvas.height = width - } - if (orientation > 4) { - // Destination and source dimensions are switched - sourceWidth = height - sourceHeight = width - } - // Reset automatic browser orientation: - switch (autoOrientation) { - case 2: - // Horizontal flip - ctx.translate(sourceWidth, 0) - ctx.scale(-1, 1) - break - case 3: - // 180° Rotate CCW - ctx.translate(sourceWidth, sourceHeight) - ctx.rotate(Math.PI) - break - case 4: - // Vertical flip - ctx.translate(0, sourceHeight) - ctx.scale(1, -1) - break - case 5: - // Horizontal flip + 90° Rotate CCW - ctx.rotate(-0.5 * Math.PI) - ctx.scale(-1, 1) - break - case 6: - // 90° Rotate CCW - ctx.rotate(-0.5 * Math.PI) - ctx.translate(-sourceWidth, 0) - break - case 7: - // Vertical flip + 90° Rotate CCW - ctx.rotate(-0.5 * Math.PI) - ctx.translate(-sourceWidth, sourceHeight) - ctx.scale(1, -1) - break - case 8: - // 90° Rotate CW - ctx.rotate(0.5 * Math.PI) - ctx.translate(0, -sourceHeight) - break - } - // Some orientation combinations require additional rotation by 180°: - if (requiresRot180(orientation, autoOrientation)) { - ctx.translate(sourceWidth, sourceHeight) - ctx.rotate(Math.PI) - } - switch (orientation) { - case 2: - // Horizontal flip - ctx.translate(width, 0) - ctx.scale(-1, 1) - break - case 3: - // 180° Rotate CCW - ctx.translate(width, height) - ctx.rotate(Math.PI) - break - case 4: - // Vertical flip - ctx.translate(0, height) - ctx.scale(1, -1) - break - case 5: - // Vertical flip + 90° Rotate CW - ctx.rotate(0.5 * Math.PI) - ctx.scale(1, -1) - break - case 6: - // 90° Rotate CW - ctx.rotate(0.5 * Math.PI) - ctx.translate(0, -height) - break - case 7: - // Horizontal flip + 90° Rotate CW - ctx.rotate(0.5 * Math.PI) - ctx.translate(width, -height) - ctx.scale(-1, 1) - break - case 8: - // 90° Rotate CCW - ctx.rotate(-0.5 * Math.PI) - ctx.translate(-width, 0) - break - } - } -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale.js deleted file mode 100644 index 80cc5e544fec..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image-scale.js +++ /dev/null @@ -1,327 +0,0 @@ -/* - * JavaScript Load Image Scaling - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, require */ - -;(function (factory) { - 'use strict' - if (typeof define === 'function' && define.amd) { - // Register as an anonymous AMD module: - define(['jquery/fileUploader/vendor/blueimp-load-image/js/load-image'], factory) - } else if (typeof module === 'object' && module.exports) { - factory(require('jquery/fileUploader/vendor/blueimp-load-image/js/load-image')) - } else { - // Browser globals: - factory(window.loadImage) - } -})(function (loadImage) { - 'use strict' - - var originalTransform = loadImage.transform - - loadImage.createCanvas = function (width, height, offscreen) { - if (offscreen && loadImage.global.OffscreenCanvas) { - return new OffscreenCanvas(width, height) - } - var canvas = document.createElement('canvas') - canvas.width = width - canvas.height = height - return canvas - } - - loadImage.transform = function (img, options, callback, file, data) { - originalTransform.call( - loadImage, - loadImage.scale(img, options, data), - options, - callback, - file, - data - ) - } - - // Transform image coordinates, allows to override e.g. - // the canvas orientation based on the orientation option, - // gets canvas, options and data passed as arguments: - loadImage.transformCoordinates = function () {} - - // Returns transformed options, allows to override e.g. - // maxWidth, maxHeight and crop options based on the aspectRatio. - // gets img, options, data passed as arguments: - loadImage.getTransformedOptions = function (img, options) { - var aspectRatio = options.aspectRatio - var newOptions - var i - var width - var height - if (!aspectRatio) { - return options - } - newOptions = {} - for (i in options) { - if (Object.prototype.hasOwnProperty.call(options, i)) { - newOptions[i] = options[i] - } - } - newOptions.crop = true - width = img.naturalWidth || img.width - height = img.naturalHeight || img.height - if (width / height > aspectRatio) { - newOptions.maxWidth = height * aspectRatio - newOptions.maxHeight = height - } else { - newOptions.maxWidth = width - newOptions.maxHeight = width / aspectRatio - } - return newOptions - } - - // Canvas render method, allows to implement a different rendering algorithm: - loadImage.drawImage = function ( - img, - canvas, - sourceX, - sourceY, - sourceWidth, - sourceHeight, - destWidth, - destHeight, - options - ) { - var ctx = canvas.getContext('2d') - if (options.imageSmoothingEnabled === false) { - ctx.msImageSmoothingEnabled = false - ctx.imageSmoothingEnabled = false - } else if (options.imageSmoothingQuality) { - ctx.imageSmoothingQuality = options.imageSmoothingQuality - } - ctx.drawImage( - img, - sourceX, - sourceY, - sourceWidth, - sourceHeight, - 0, - 0, - destWidth, - destHeight - ) - return ctx - } - - // Determines if the target image should be a canvas element: - loadImage.requiresCanvas = function (options) { - return options.canvas || options.crop || !!options.aspectRatio - } - - // Scales and/or crops the given image (img or canvas HTML element) - // using the given options: - loadImage.scale = function (img, options, data) { - // eslint-disable-next-line no-param-reassign - options = options || {} - // eslint-disable-next-line no-param-reassign - data = data || {} - var useCanvas = - img.getContext || - (loadImage.requiresCanvas(options) && - !!loadImage.global.HTMLCanvasElement) - var width = img.naturalWidth || img.width - var height = img.naturalHeight || img.height - var destWidth = width - var destHeight = height - var maxWidth - var maxHeight - var minWidth - var minHeight - var sourceWidth - var sourceHeight - var sourceX - var sourceY - var pixelRatio - var downsamplingRatio - var tmp - var canvas - /** - * Scales up image dimensions - */ - function scaleUp() { - var scale = Math.max( - (minWidth || destWidth) / destWidth, - (minHeight || destHeight) / destHeight - ) - if (scale > 1) { - destWidth *= scale - destHeight *= scale - } - } - /** - * Scales down image dimensions - */ - function scaleDown() { - var scale = Math.min( - (maxWidth || destWidth) / destWidth, - (maxHeight || destHeight) / destHeight - ) - if (scale < 1) { - destWidth *= scale - destHeight *= scale - } - } - if (useCanvas) { - // eslint-disable-next-line no-param-reassign - options = loadImage.getTransformedOptions(img, options, data) - sourceX = options.left || 0 - sourceY = options.top || 0 - if (options.sourceWidth) { - sourceWidth = options.sourceWidth - if (options.right !== undefined && options.left === undefined) { - sourceX = width - sourceWidth - options.right - } - } else { - sourceWidth = width - sourceX - (options.right || 0) - } - if (options.sourceHeight) { - sourceHeight = options.sourceHeight - if (options.bottom !== undefined && options.top === undefined) { - sourceY = height - sourceHeight - options.bottom - } - } else { - sourceHeight = height - sourceY - (options.bottom || 0) - } - destWidth = sourceWidth - destHeight = sourceHeight - } - maxWidth = options.maxWidth - maxHeight = options.maxHeight - minWidth = options.minWidth - minHeight = options.minHeight - if (useCanvas && maxWidth && maxHeight && options.crop) { - destWidth = maxWidth - destHeight = maxHeight - tmp = sourceWidth / sourceHeight - maxWidth / maxHeight - if (tmp < 0) { - sourceHeight = (maxHeight * sourceWidth) / maxWidth - if (options.top === undefined && options.bottom === undefined) { - sourceY = (height - sourceHeight) / 2 - } - } else if (tmp > 0) { - sourceWidth = (maxWidth * sourceHeight) / maxHeight - if (options.left === undefined && options.right === undefined) { - sourceX = (width - sourceWidth) / 2 - } - } - } else { - if (options.contain || options.cover) { - minWidth = maxWidth = maxWidth || minWidth - minHeight = maxHeight = maxHeight || minHeight - } - if (options.cover) { - scaleDown() - scaleUp() - } else { - scaleUp() - scaleDown() - } - } - if (useCanvas) { - pixelRatio = options.pixelRatio - if ( - pixelRatio > 1 && - // Check if the image has not yet had the device pixel ratio applied: - !( - img.style.width && - Math.floor(parseFloat(img.style.width, 10)) === - Math.floor(width / pixelRatio) - ) - ) { - destWidth *= pixelRatio - destHeight *= pixelRatio - } - // Check if workaround for Chromium orientation crop bug is required: - // https://bugs.chromium.org/p/chromium/issues/detail?id=1074354 - if ( - loadImage.orientationCropBug && - !img.getContext && - (sourceX || sourceY || sourceWidth !== width || sourceHeight !== height) - ) { - // Write the complete source image to an intermediate canvas first: - tmp = img - // eslint-disable-next-line no-param-reassign - img = loadImage.createCanvas(width, height, true) - loadImage.drawImage( - tmp, - img, - 0, - 0, - width, - height, - width, - height, - options - ) - } - downsamplingRatio = options.downsamplingRatio - if ( - downsamplingRatio > 0 && - downsamplingRatio < 1 && - destWidth < sourceWidth && - destHeight < sourceHeight - ) { - while (sourceWidth * downsamplingRatio > destWidth) { - canvas = loadImage.createCanvas( - sourceWidth * downsamplingRatio, - sourceHeight * downsamplingRatio, - true - ) - loadImage.drawImage( - img, - canvas, - sourceX, - sourceY, - sourceWidth, - sourceHeight, - canvas.width, - canvas.height, - options - ) - sourceX = 0 - sourceY = 0 - sourceWidth = canvas.width - sourceHeight = canvas.height - // eslint-disable-next-line no-param-reassign - img = canvas - } - } - canvas = loadImage.createCanvas(destWidth, destHeight) - loadImage.transformCoordinates(canvas, options, data) - if (pixelRatio > 1) { - canvas.style.width = canvas.width / pixelRatio + 'px' - } - loadImage - .drawImage( - img, - canvas, - sourceX, - sourceY, - sourceWidth, - sourceHeight, - destWidth, - destHeight, - options - ) - .setTransform(1, 0, 0, 1, 0, 0) // reset to the identity matrix - return canvas - } - img.width = destWidth - img.height = destHeight - return img - } -}) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image.js b/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image.js deleted file mode 100644 index 27387fbd13d7..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-load-image/js/load-image.js +++ /dev/null @@ -1,229 +0,0 @@ -/* - * JavaScript Load Image - * https://github.com/blueimp/JavaScript-Load-Image - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define, module, Promise */ - -;(function ($) { - 'use strict' - - var urlAPI = $.URL || $.webkitURL - - /** - * Creates an object URL for a given File object. - * - * @param {Blob} blob Blob object - * @returns {string|boolean} Returns object URL if API exists, else false. - */ - function createObjectURL(blob) { - return urlAPI ? urlAPI.createObjectURL(blob) : false - } - - /** - * Revokes a given object URL. - * - * @param {string} url Blob object URL - * @returns {undefined|boolean} Returns undefined if API exists, else false. - */ - function revokeObjectURL(url) { - return urlAPI ? urlAPI.revokeObjectURL(url) : false - } - - /** - * Helper function to revoke an object URL - * - * @param {string} url Blob Object URL - * @param {object} [options] Options object - */ - function revokeHelper(url, options) { - if (url && url.slice(0, 5) === 'blob:' && !(options && options.noRevoke)) { - revokeObjectURL(url) - } - } - - /** - * Loads a given File object via FileReader interface. - * - * @param {Blob} file Blob object - * @param {Function} onload Load event callback - * @param {Function} [onerror] Error/Abort event callback - * @param {string} [method=readAsDataURL] FileReader method - * @returns {FileReader|boolean} Returns FileReader if API exists, else false. - */ - function readFile(file, onload, onerror, method) { - if (!$.FileReader) return false - var reader = new FileReader() - reader.onload = function () { - onload.call(reader, this.result) - } - if (onerror) { - reader.onabort = reader.onerror = function () { - onerror.call(reader, this.error) - } - } - var readerMethod = reader[method || 'readAsDataURL'] - if (readerMethod) { - readerMethod.call(reader, file) - return reader - } - } - - /** - * Cross-frame instanceof check. - * - * @param {string} type Instance type - * @param {object} obj Object instance - * @returns {boolean} Returns true if the object is of the given instance. - */ - function isInstanceOf(type, obj) { - // Cross-frame instanceof check - return Object.prototype.toString.call(obj) === '[object ' + type + ']' - } - - /** - * @typedef { HTMLImageElement|HTMLCanvasElement } Result - */ - - /** - * Loads an image for a given File object. - * - * @param {Blob|string} file Blob object or image URL - * @param {Function|object} [callback] Image load event callback or options - * @param {object} [options] Options object - * @returns {HTMLImageElement|FileReader|Promise} Object - */ - function loadImage(file, callback, options) { - /** - * Promise executor - * - * @param {Function} resolve Resolution function - * @param {Function} reject Rejection function - * @returns {HTMLImageElement|FileReader} Object - */ - function executor(resolve, reject) { - var img = document.createElement('img') - var url - /** - * Callback for the fetchBlob call. - * - * @param {HTMLImageElement|HTMLCanvasElement} img Error object - * @param {object} data Data object - * @returns {undefined} Undefined - */ - function resolveWrapper(img, data) { - if (resolve === reject) { - // Not using Promises - if (resolve) resolve(img, data) - return - } else if (img instanceof Error) { - reject(img) - return - } - data = data || {} // eslint-disable-line no-param-reassign - data.image = img - resolve(data) - } - /** - * Callback for the fetchBlob call. - * - * @param {Blob} blob Blob object - * @param {Error} err Error object - */ - function fetchBlobCallback(blob, err) { - if (err && $.console) console.log(err) // eslint-disable-line no-console - if (blob && isInstanceOf('Blob', blob)) { - file = blob // eslint-disable-line no-param-reassign - url = createObjectURL(file) - } else { - url = file - if (options && options.crossOrigin) { - img.crossOrigin = options.crossOrigin - } - } - img.src = url - } - img.onerror = function (event) { - revokeHelper(url, options) - if (reject) reject.call(img, event) - } - img.onload = function () { - revokeHelper(url, options) - var data = { - originalWidth: img.naturalWidth || img.width, - originalHeight: img.naturalHeight || img.height - } - try { - loadImage.transform(img, options, resolveWrapper, file, data) - } catch (error) { - if (reject) reject(error) - } - } - if (typeof file === 'string') { - if (loadImage.requiresMetaData(options)) { - loadImage.fetchBlob(file, fetchBlobCallback, options) - } else { - fetchBlobCallback() - } - return img - } else if (isInstanceOf('Blob', file) || isInstanceOf('File', file)) { - url = createObjectURL(file) - if (url) { - img.src = url - return img - } - return readFile( - file, - function (url) { - img.src = url - }, - reject - ) - } - } - if ($.Promise && typeof callback !== 'function') { - options = callback // eslint-disable-line no-param-reassign - return new Promise(executor) - } - return executor(callback, callback) - } - - // Determines if metadata should be loaded automatically. - // Requires the load image meta extension to load metadata. - loadImage.requiresMetaData = function (options) { - return options && options.meta - } - - // If the callback given to this function returns a blob, it is used as image - // source instead of the original url and overrides the file argument used in - // the onload and onerror event callbacks: - loadImage.fetchBlob = function (url, callback) { - callback() - } - - loadImage.transform = function (img, options, callback, file, data) { - callback(img, data) - } - - loadImage.global = $ - loadImage.readFile = readFile - loadImage.isInstanceOf = isInstanceOf - loadImage.createObjectURL = createObjectURL - loadImage.revokeObjectURL = revokeObjectURL - - if (typeof define === 'function' && define.amd) { - define(function () { - return loadImage - }) - } else if (typeof module === 'object' && module.exports) { - module.exports = loadImage - } else { - $.loadImage = loadImage - } -})((typeof window !== 'undefined' && window) || this) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/LICENSE.txt b/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/LICENSE.txt deleted file mode 100644 index d6a9d74758be..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -MIT License - -Copyright © 2011 Sebastian Tschan, https://blueimp.net - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/README.md b/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/README.md deleted file mode 100644 index d8281b237ca1..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/README.md +++ /dev/null @@ -1,436 +0,0 @@ -# JavaScript Templates - -## Contents - -- [Demo](https://blueimp.github.io/JavaScript-Templates/) -- [Description](#description) -- [Usage](#usage) - - [Client-side](#client-side) - - [Server-side](#server-side) -- [Requirements](#requirements) -- [API](#api) - - [tmpl() function](#tmpl-function) - - [Templates cache](#templates-cache) - - [Output encoding](#output-encoding) - - [Local helper variables](#local-helper-variables) - - [Template function argument](#template-function-argument) - - [Template parsing](#template-parsing) -- [Templates syntax](#templates-syntax) - - [Interpolation](#interpolation) - - [Evaluation](#evaluation) -- [Compiled templates](#compiled-templates) -- [Tests](#tests) -- [License](#license) - -## Description - -1KB lightweight, fast & powerful JavaScript templating engine with zero -dependencies. -Compatible with server-side environments like [Node.js](https://nodejs.org/), -module loaders like [RequireJS](https://requirejs.org/) or -[webpack](https://webpack.js.org/) and all web browsers. - -## Usage - -### Client-side - -Install the **blueimp-tmpl** package with [NPM](https://www.npmjs.org/): - -```sh -npm install blueimp-tmpl -``` - -Include the (minified) JavaScript Templates script in your HTML markup: - -```html - -``` - -Add a script section with type **"text/x-tmpl"**, a unique **id** property and -your template definition as content: - -```html - -``` - -**"o"** (the lowercase letter) is a reference to the data parameter of the -template function (see the API section on how to modify this identifier). - -In your application code, create a JavaScript object to use as data for the -template: - -```js -var data = { - title: 'JavaScript Templates', - license: { - name: 'MIT license', - url: 'https://opensource.org/licenses/MIT' - }, - features: ['lightweight & fast', 'powerful', 'zero dependencies'] -} -``` - -In a real application, this data could be the result of retrieving a -[JSON](https://json.org/) resource. - -Render the result by calling the **tmpl()** method with the id of the template -and the data object as arguments: - -```js -document.getElementById('result').innerHTML = tmpl('tmpl-demo', data) -``` - -### Server-side - -The following is an example how to use the JavaScript Templates engine on the -server-side with [Node.js](https://nodejs.org/). - -Install the **blueimp-tmpl** package with [NPM](https://www.npmjs.org/): - -```sh -npm install blueimp-tmpl -``` - -Add a file **template.html** with the following content: - -```html - -{%=o.title%} -

{%=o.title%}

-

Features

-
    -{% for (var i=0; i{%=o.features[i]%} -{% } %} -
-``` - -Add a file **server.js** with the following content: - -```js -require('http') - .createServer(function (req, res) { - var fs = require('fs'), - // The tmpl module exports the tmpl() function: - tmpl = require('./tmpl'), - // Use the following version if you installed the package with npm: - // tmpl = require("blueimp-tmpl"), - // Sample data: - data = { - title: 'JavaScript Templates', - url: 'https://github.com/blueimp/JavaScript-Templates', - features: ['lightweight & fast', 'powerful', 'zero dependencies'] - } - // Override the template loading method: - tmpl.load = function (id) { - var filename = id + '.html' - console.log('Loading ' + filename) - return fs.readFileSync(filename, 'utf8') - } - res.writeHead(200, { 'Content-Type': 'text/x-tmpl' }) - // Render the content: - res.end(tmpl('template', data)) - }) - .listen(8080, 'localhost') -console.log('Server running at http://localhost:8080/') -``` - -Run the application with the following command: - -```sh -node server.js -``` - -## Requirements - -The JavaScript Templates script has zero dependencies. - -## API - -### tmpl() function - -The **tmpl()** function is added to the global **window** object and can be -called as global function: - -```js -var result = tmpl('tmpl-demo', data) -``` - -The **tmpl()** function can be called with the id of a template, or with a -template string: - -```js -var result = tmpl('

{%=o.title%}

', data) -``` - -If called without second argument, **tmpl()** returns a reusable template -function: - -```js -var func = tmpl('

{%=o.title%}

') -document.getElementById('result').innerHTML = func(data) -``` - -### Templates cache - -Templates loaded by id are cached in the map **tmpl.cache**: - -```js -var func = tmpl('tmpl-demo'), // Loads and parses the template - cached = typeof tmpl.cache['tmpl-demo'] === 'function', // true - result = tmpl('tmpl-demo', data) // Uses cached template function - -tmpl.cache['tmpl-demo'] = null -result = tmpl('tmpl-demo', data) // Loads and parses the template again -``` - -### Output encoding - -The method **tmpl.encode** is used to escape HTML special characters in the -template output: - -```js -var output = tmpl.encode('<>&"\'\x00') // Renders "<>&"'" -``` - -**tmpl.encode** makes use of the regular expression **tmpl.encReg** and the -encoding map **tmpl.encMap** to match and replace special characters, which can -be modified to change the behavior of the output encoding. -Strings matched by the regular expression, but not found in the encoding map are -removed from the output. This allows for example to automatically trim input -values (removing whitespace from the start and end of the string): - -```js -tmpl.encReg = /(^\s+)|(\s+$)|[<>&"'\x00]/g -var output = tmpl.encode(' Banana! ') // Renders "Banana" (without whitespace) -``` - -### Local helper variables - -The local variables available inside the templates are the following: - -- **o**: The data object given as parameter to the template function (see the - next section on how to modify the parameter name). -- **tmpl**: A reference to the **tmpl** function object. -- **\_s**: The string for the rendered result content. -- **\_e**: A reference to the **tmpl.encode** method. -- **print**: Helper function to add content to the rendered result string. -- **include**: Helper function to include the return value of a different - template in the result. - -To introduce additional local helper variables, the string **tmpl.helper** can -be extended. The following adds a convenience function for _console.log_ and a -streaming function, that streams the template rendering result back to the -callback argument (note the comma at the beginning of each variable -declaration): - -```js -tmpl.helper += - ',log=function(){console.log.apply(console, arguments)}' + - ",st='',stream=function(cb){var l=st.length;st=_s;cb( _s.slice(l));}" -``` - -Those new helper functions could be used to stream the template contents to the -console output: - -```html - -``` - -### Template function argument - -The generated template functions accept one argument, which is the data object -given to the **tmpl(id, data)** function. This argument is available inside the -template definitions as parameter **o** (the lowercase letter). - -The argument name can be modified by overriding **tmpl.arg**: - -```js -tmpl.arg = 'p' - -// Renders "

JavaScript Templates

": -var result = tmpl('

{%=p.title%}

', { title: 'JavaScript Templates' }) -``` - -### Template parsing - -The template contents are matched and replaced using the regular expression -**tmpl.regexp** and the replacement function **tmpl.func**. The replacement -function operates based on the -[parenthesized submatch strings](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter). - -To use different tags for the template syntax, override **tmpl.regexp** with a -modified regular expression, by exchanging all occurrences of "{%" and "%}", -e.g. with "[%" and "%]": - -```js -tmpl.regexp = /([\s'\\])(?!(?:[^[]|\[(?!%))*%\])|(?:\[%(=|#)([\s\S]+?)%\])|(\[%)|(%\])/g -``` - -By default, the plugin preserves whitespace (newlines, carriage returns, tabs -and spaces). To strip unnecessary whitespace, you can override the **tmpl.func** -function, e.g. with the following code: - -```js -var originalFunc = tmpl.func -tmpl.func = function (s, p1, p2, p3, p4, p5, offset, str) { - if (p1 && /\s/.test(p1)) { - if ( - !offset || - /\s/.test(str.charAt(offset - 1)) || - /^\s+$/g.test(str.slice(offset)) - ) { - return '' - } - return ' ' - } - return originalFunc.apply(tmpl, arguments) -} -``` - -## Templates syntax - -### Interpolation - -Print variable with HTML special characters escaped: - -```html -

{%=o.title%}

-``` - -Print variable without escaping: - -```html -

{%#o.user_id%}

-``` - -Print output of function calls: - -```html -Website -``` - -Use dot notation to print nested properties: - -```html -{%=o.author.name%} -``` - -### Evaluation - -Use **print(str)** to add escaped content to the output: - -```html -Year: {% var d=new Date(); print(d.getFullYear()); %} -``` - -Use **print(str, true)** to add unescaped content to the output: - -```html -{% print("Fast & powerful", true); %} -``` - -Use **include(str, obj)** to include content from a different template: - -```html -
- {% include('tmpl-link', {name: "Website", url: "https://example.org"}); %} -
-``` - -**If else condition**: - -```html -{% if (o.author.url) { %} -{%=o.author.name%} -{% } else { %} -No author url. -{% } %} -``` - -**For loop**: - -```html -
    -{% for (var i=0; i{%=o.features[i]%} -{% } %} -
-``` - -## Compiled templates - -The JavaScript Templates project comes with a compilation script, that allows -you to compile your templates into JavaScript code and combine them with a -minimal Templates runtime into one combined JavaScript file. - -The compilation script is built for [Node.js](https://nodejs.org/). -To use it, first install the JavaScript Templates project via -[NPM](https://www.npmjs.org/): - -```sh -npm install blueimp-tmpl -``` - -This will put the executable **tmpl.js** into the folder **node_modules/.bin**. -It will also make it available on your PATH if you install the package globally -(by adding the **-g** flag to the install command). - -The **tmpl.js** executable accepts the paths to one or multiple template files -as command line arguments and prints the generated JavaScript code to the -console output. The following command line shows you how to store the generated -code in a new JavaScript file that can be included in your project: - -```sh -tmpl.js index.html > tmpl.js -``` - -The files given as command line arguments to **tmpl.js** can either be pure -template files or HTML documents with embedded template script sections. For the -pure template files, the file names (without extension) serve as template ids. -The generated file can be included in your project as a replacement for the -original **tmpl.js** runtime. It provides you with the same API and provides a -**tmpl(id, data)** function that accepts the id of one of your templates as -first and a data object as optional second parameter. - -## Tests - -The JavaScript Templates project comes with -[Unit Tests](https://en.wikipedia.org/wiki/Unit_testing). -There are two different ways to run the tests: - -- Open test/index.html in your browser or -- run `npm test` in the Terminal in the root path of the repository package. - -The first one tests the browser integration, the second one the -[Node.js](https://nodejs.org/) integration. - -## License - -The JavaScript Templates script is released under the -[MIT license](https://opensource.org/licenses/MIT). diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/compile.js b/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/compile.js deleted file mode 100755 index 122d034eaa8e..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/compile.js +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env node -/* - * JavaScript Templates Compiler - * https://github.com/blueimp/JavaScript-Templates - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* eslint-disable strict */ -/* eslint-disable no-console */ - -;(function () { - 'use strict' - var path = require('path') - var tmpl = require(path.join(__dirname, 'tmpl.js')) - var fs = require('fs') - // Retrieve the content of the minimal runtime: - var runtime = fs.readFileSync(path.join(__dirname, 'runtime.js'), 'utf8') - // A regular expression to parse templates from script tags in a HTML page: - var regexp = /([\s\S]+?)<\/script>/gi - // A regular expression to match the helper function names: - var helperRegexp = new RegExp( - tmpl.helper.match(/\w+(?=\s*=\s*function\s*\()/g).join('\\s*\\(|') + - '\\s*\\(' - ) - // A list to store the function bodies: - var list = [] - var code - // Extend the Templating engine with a print method for the generated functions: - tmpl.print = function (str) { - // Only add helper functions if they are used inside of the template: - var helper = helperRegexp.test(str) ? tmpl.helper : '' - var body = str.replace(tmpl.regexp, tmpl.func) - if (helper || /_e\s*\(/.test(body)) { - helper = '_e=tmpl.encode' + helper + ',' - } - return ( - 'function(' + - tmpl.arg + - ',tmpl){' + - ('var ' + helper + "_s='" + body + "';return _s;") - .split("_s+='';") - .join('') + - '}' - ) - } - // Loop through the command line arguments: - process.argv.forEach(function (file, index) { - var listLength = list.length - var stats - var content - var result - var id - // Skip the first two arguments, which are "node" and the script: - if (index > 1) { - stats = fs.statSync(file) - if (!stats.isFile()) { - console.error(file + ' is not a file.') - return - } - content = fs.readFileSync(file, 'utf8') - // eslint-disable-next-line no-constant-condition - while (true) { - // Find templates in script tags: - result = regexp.exec(content) - if (!result) { - break - } - id = result[2] || result[4] - list.push("'" + id + "':" + tmpl.print(result[5])) - } - if (listLength === list.length) { - // No template script tags found, use the complete content: - id = path.basename(file, path.extname(file)) - list.push("'" + id + "':" + tmpl.print(content)) - } - } - }) - if (!list.length) { - console.error('Missing input file.') - return - } - // Combine the generated functions as cache of the minimal runtime: - code = runtime.replace('{}', '{' + list.join(',') + '}') - // Print the resulting code to the console output: - console.log(code) -})() diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/runtime.js b/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/runtime.js deleted file mode 100644 index 1a3a716c51bc..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/runtime.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * JavaScript Templates Runtime - * https://github.com/blueimp/JavaScript-Templates - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - */ - -/* global define */ - -/* eslint-disable strict */ - -;(function ($) { - 'use strict' - var tmpl = function (id, data) { - var f = tmpl.cache[id] - return data - ? f(data, tmpl) - : function (data) { - return f(data, tmpl) - } - } - tmpl.cache = {} - tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex - tmpl.encMap = { - '<': '<', - '>': '>', - '&': '&', - '"': '"', - "'": ''' - } - tmpl.encode = function (s) { - // eslint-disable-next-line eqeqeq - return (s == null ? '' : '' + s).replace(tmpl.encReg, function (c) { - return tmpl.encMap[c] || '' - }) - } - if (typeof define === 'function' && define.amd) { - define(function () { - return tmpl - }) - } else if (typeof module === 'object' && module.exports) { - module.exports = tmpl - } else { - $.tmpl = tmpl - } -})(this) diff --git a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/tmpl.js b/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/tmpl.js deleted file mode 100644 index 63eb927cb0d4..000000000000 --- a/lib/web/jquery/fileUploader/vendor/blueimp-tmpl/js/tmpl.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * JavaScript Templates - * https://github.com/blueimp/JavaScript-Templates - * - * Copyright 2011, Sebastian Tschan - * https://blueimp.net - * - * Licensed under the MIT license: - * https://opensource.org/licenses/MIT - * - * Inspired by John Resig's JavaScript Micro-Templating: - * http://ejohn.org/blog/javascript-micro-templating/ - */ - -/* global define */ - -/* eslint-disable strict */ - -;(function ($) { - 'use strict' - var tmpl = function (str, data) { - var f = !/[^\w\-.:]/.test(str) - ? (tmpl.cache[str] = tmpl.cache[str] || tmpl(tmpl.load(str))) - : new Function( // eslint-disable-line no-new-func - tmpl.arg + ',tmpl', - 'var _e=tmpl.encode' + - tmpl.helper + - ",_s='" + - str.replace(tmpl.regexp, tmpl.func) + - "';return _s;" - ) - return data - ? f(data, tmpl) - : function (data) { - return f(data, tmpl) - } - } - tmpl.cache = {} - tmpl.load = function (id) { - return document.getElementById(id).innerHTML - } - tmpl.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g - tmpl.func = function (s, p1, p2, p3, p4, p5) { - if (p1) { - // whitespace, quote and backspace in HTML context - return ( - { - '\n': '\\n', - '\r': '\\r', - '\t': '\\t', - ' ': ' ' - }[p1] || '\\' + p1 - ) - } - if (p2) { - // interpolation: {%=prop%}, or unescaped: {%#prop%} - if (p2 === '=') { - return "'+_e(" + p3 + ")+'" - } - return "'+(" + p3 + "==null?'':" + p3 + ")+'" - } - if (p4) { - // evaluation start tag: {% - return "';" - } - if (p5) { - // evaluation end tag: %} - return "_s+='" - } - } - tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex - tmpl.encMap = { - '<': '<', - '>': '>', - '&': '&', - '"': '"', - "'": ''' - } - tmpl.encode = function (s) { - // eslint-disable-next-line eqeqeq - return (s == null ? '' : '' + s).replace(tmpl.encReg, function (c) { - return tmpl.encMap[c] || '' - }) - } - tmpl.arg = 'o' - tmpl.helper = - ",print=function(s,e){_s+=e?(s==null?'':s):_e(s);}" + - ',include=function(s,d){_s+=tmpl(s,d);}' - if (typeof define === 'function' && define.amd) { - define(function () { - return tmpl - }) - } else if (typeof module === 'object' && module.exports) { - module.exports = tmpl - } else { - $.tmpl = tmpl - } -})(this) diff --git a/lib/web/jquery/fileUploader/vendor/jquery.ui.widget.js b/lib/web/jquery/fileUploader/vendor/jquery.ui.widget.js deleted file mode 100644 index 43f0ec6340f3..000000000000 --- a/lib/web/jquery/fileUploader/vendor/jquery.ui.widget.js +++ /dev/null @@ -1,832 +0,0 @@ -/*! jQuery UI - v1.13.2 - * http://jqueryui.com - * Includes: widget.js - * Copyright jQuery Foundation and other contributors; Licensed MIT */ - -/* global define, require */ -/* eslint-disable no-param-reassign, new-cap, jsdoc/require-jsdoc */ - -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['jquery'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS - factory(require('jquery')); - } else { - // Browser globals - factory(window.jQuery); - } -})(function ($) { - ('use strict'); - - $.ui = $.ui || {}; - - $.ui.version = '1.13.2'; - - /*! - * jQuery UI Widget 1.13.2 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - - //>>label: Widget - //>>group: Core - //>>description: Provides a factory for creating stateful widgets with a common API. - //>>docs: http://api.jqueryui.com/jQuery.widget/ - //>>demos: http://jqueryui.com/widget/ - - // Support: jQuery 1.9.x or older - // $.expr[ ":" ] is deprecated. - if (!$.expr.pseudos) { - $.expr.pseudos = $.expr[':']; - } - - // Support: jQuery 1.11.x or older - // $.unique has been renamed to $.uniqueSort - if (!$.uniqueSort) { - $.uniqueSort = $.unique; - } - var widgetUuid = 0; - var widgetHasOwnProperty = Array.prototype.hasOwnProperty; - var widgetSlice = Array.prototype.slice; - - $.cleanData = (function (orig) { - return function (elems) { - var events, elem, i; - for (i = 0; (elem = elems[i]) != null; i++) { - // Only trigger remove when necessary to save time - events = $._data(elem, 'events'); - if (events && events.remove) { - $(elem).triggerHandler('remove'); - } - } - orig(elems); - }; - })($.cleanData); - - $.widget = function (name, base, prototype) { - var existingConstructor, constructor, basePrototype; - - // ProxiedPrototype allows the provided prototype to remain unmodified - // so that it can be used as a mixin for multiple widgets (#8876) - var proxiedPrototype = {}; - - var namespace = name.split('.')[0]; - // eslint-disable-next-line no-param-reassign - name = name.split('.')[1]; - var fullName = namespace + '-' + name; - - if (!prototype) { - prototype = base; - base = $.Widget; - } - - if (Array.isArray(prototype)) { - prototype = $.extend.apply(null, [{}].concat(prototype)); - } - - // Create selector for plugin - $.expr.pseudos[fullName.toLowerCase()] = function (elem) { - return !!$.data(elem, fullName); - }; - - $[namespace] = $[namespace] || {}; - existingConstructor = $[namespace][name]; - constructor = $[namespace][name] = function (options, element) { - // Allow instantiation without "new" keyword - if (!this || !this._createWidget) { - return new constructor(options, element); - } - - // Allow instantiation without initializing for simple inheritance - // must use "new" keyword (the code above always passes args) - if (arguments.length) { - this._createWidget(options, element); - } - }; - - // Extend with the existing constructor to carry over any static properties - $.extend(constructor, existingConstructor, { - version: prototype.version, - - // Copy the object used to create the prototype in case we need to - // redefine the widget later - _proto: $.extend({}, prototype), - - // Track widgets that inherit from this widget in case this widget is - // redefined after a widget inherits from it - _childConstructors: [] - }); - - basePrototype = new base(); - - // We need to make the options hash a property directly on the new instance - // otherwise we'll modify the options hash on the prototype that we're - // inheriting from - basePrototype.options = $.widget.extend({}, basePrototype.options); - $.each(prototype, function (prop, value) { - if (typeof value !== 'function') { - proxiedPrototype[prop] = value; - return; - } - proxiedPrototype[prop] = (function () { - /** - * - */ - function _super() { - return base.prototype[prop].apply(this, arguments); - } - - /** - * @param args - */ - function _superApply(args) { - return base.prototype[prop].apply(this, args); - } - - return function () { - var __super = this._super; - var __superApply = this._superApply; - var returnValue; - - this._super = _super; - this._superApply = _superApply; - - returnValue = value.apply(this, arguments); - - this._super = __super; - this._superApply = __superApply; - - return returnValue; - }; - })(); - }); - constructor.prototype = $.widget.extend( - basePrototype, - { - // TODO: remove support for widgetEventPrefix - // always use the name + a colon as the prefix, e.g., draggable:start - // don't prefix for widgets that aren't DOM-based - widgetEventPrefix: existingConstructor - ? basePrototype.widgetEventPrefix || name - : name - }, - proxiedPrototype, - { - constructor: constructor, - namespace: namespace, - widgetName: name, - widgetFullName: fullName - } - ); - - // If this widget is being redefined then we need to find all widgets that - // are inheriting from it and redefine all of them so that they inherit from - // the new version of this widget. We're essentially trying to replace one - // level in the prototype chain. - if (existingConstructor) { - $.each(existingConstructor._childConstructors, function (i, child) { - var childPrototype = child.prototype; - - // Redefine the child widget using the same prototype that was - // originally used, but inherit from the new version of the base - $.widget( - childPrototype.namespace + '.' + childPrototype.widgetName, - constructor, - child._proto - ); - }); - - // Remove the list of existing child constructors from the old constructor - // so the old child constructors can be garbage collected - delete existingConstructor._childConstructors; - } else { - base._childConstructors.push(constructor); - } - - $.widget.bridge(name, constructor); - - return constructor; - }; - - $.widget.extend = function (target) { - var input = widgetSlice.call(arguments, 1); - var inputIndex = 0; - var inputLength = input.length; - var key; - var value; - - for (; inputIndex < inputLength; inputIndex++) { - for (key in input[inputIndex]) { - value = input[inputIndex][key]; - if ( - widgetHasOwnProperty.call(input[inputIndex], key) && - value !== undefined - ) { - // Clone objects - if ($.isPlainObject(value)) { - target[key] = $.isPlainObject(target[key]) - ? $.widget.extend({}, target[key], value) - : // Don't extend strings, arrays, etc. with objects - $.widget.extend({}, value); - - // Copy everything else by reference - } else { - target[key] = value; - } - } - } - } - return target; - }; - - $.widget.bridge = function (name, object) { - var fullName = object.prototype.widgetFullName || name; - $.fn[name] = function (options) { - var isMethodCall = typeof options === 'string'; - var args = widgetSlice.call(arguments, 1); - var returnValue = this; - - if (isMethodCall) { - // If this is an empty collection, we need to have the instance method - // return undefined instead of the jQuery instance - if (!this.length && options === 'instance') { - returnValue = undefined; - } else { - this.each(function () { - var methodValue; - var instance = $.data(this, fullName); - - if (options === 'instance') { - returnValue = instance; - return false; - } - - if (!instance) { - return $.error( - 'cannot call methods on ' + - name + - ' prior to initialization; ' + - "attempted to call method '" + - options + - "'" - ); - } - - if ( - typeof instance[options] !== 'function' || - options.charAt(0) === '_' - ) { - return $.error( - "no such method '" + - options + - "' for " + - name + - ' widget instance' - ); - } - - methodValue = instance[options].apply(instance, args); - - if (methodValue !== instance && methodValue !== undefined) { - returnValue = - methodValue && methodValue.jquery - ? returnValue.pushStack(methodValue.get()) - : methodValue; - return false; - } - }); - } - } else { - // Allow multiple hashes to be passed on init - if (args.length) { - options = $.widget.extend.apply(null, [options].concat(args)); - } - - this.each(function () { - var instance = $.data(this, fullName); - if (instance) { - instance.option(options || {}); - if (instance._init) { - instance._init(); - } - } else { - $.data(this, fullName, new object(options, this)); - } - }); - } - - return returnValue; - }; - }; - - $.Widget = function (/* options, element */) {}; - $.Widget._childConstructors = []; - - $.Widget.prototype = { - widgetName: 'widget', - widgetEventPrefix: '', - defaultElement: '
', - - options: { - classes: {}, - disabled: false, - - // Callbacks - create: null - }, - - _createWidget: function (options, element) { - element = $(element || this.defaultElement || this)[0]; - this.element = $(element); - this.uuid = widgetUuid++; - this.eventNamespace = '.' + this.widgetName + this.uuid; - - this.bindings = $(); - this.hoverable = $(); - this.focusable = $(); - this.classesElementLookup = {}; - - if (element !== this) { - $.data(element, this.widgetFullName, this); - this._on(true, this.element, { - remove: function (event) { - if (event.target === element) { - this.destroy(); - } - } - }); - this.document = $( - element.style - ? // Element within the document - element.ownerDocument - : // Element is window or document - element.document || element - ); - this.window = $( - this.document[0].defaultView || this.document[0].parentWindow - ); - } - - this.options = $.widget.extend( - {}, - this.options, - this._getCreateOptions(), - options - ); - - this._create(); - - if (this.options.disabled) { - this._setOptionDisabled(this.options.disabled); - } - - this._trigger('create', null, this._getCreateEventData()); - this._init(); - }, - - _getCreateOptions: function () { - return {}; - }, - - _getCreateEventData: $.noop, - - _create: $.noop, - - _init: $.noop, - - destroy: function () { - var that = this; - - this._destroy(); - $.each(this.classesElementLookup, function (key, value) { - that._removeClass(value, key); - }); - - // We can probably remove the unbind calls in 2.0 - // all event bindings should go through this._on() - this.element.off(this.eventNamespace).removeData(this.widgetFullName); - this.widget().off(this.eventNamespace).removeAttr('aria-disabled'); - - // Clean up events and states - this.bindings.off(this.eventNamespace); - }, - - _destroy: $.noop, - - widget: function () { - return this.element; - }, - - option: function (key, value) { - var options = key; - var parts; - var curOption; - var i; - - if (arguments.length === 0) { - // Don't return a reference to the internal hash - return $.widget.extend({}, this.options); - } - - if (typeof key === 'string') { - // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } - options = {}; - parts = key.split('.'); - key = parts.shift(); - if (parts.length) { - curOption = options[key] = $.widget.extend({}, this.options[key]); - for (i = 0; i < parts.length - 1; i++) { - curOption[parts[i]] = curOption[parts[i]] || {}; - curOption = curOption[parts[i]]; - } - key = parts.pop(); - if (arguments.length === 1) { - return curOption[key] === undefined ? null : curOption[key]; - } - curOption[key] = value; - } else { - if (arguments.length === 1) { - return this.options[key] === undefined ? null : this.options[key]; - } - options[key] = value; - } - } - - this._setOptions(options); - - return this; - }, - - _setOptions: function (options) { - var key; - - for (key in options) { - this._setOption(key, options[key]); - } - - return this; - }, - - _setOption: function (key, value) { - if (key === 'classes') { - this._setOptionClasses(value); - } - - this.options[key] = value; - - if (key === 'disabled') { - this._setOptionDisabled(value); - } - - return this; - }, - - _setOptionClasses: function (value) { - var classKey, elements, currentElements; - - for (classKey in value) { - currentElements = this.classesElementLookup[classKey]; - if ( - value[classKey] === this.options.classes[classKey] || - !currentElements || - !currentElements.length - ) { - continue; - } - - // We are doing this to create a new jQuery object because the _removeClass() call - // on the next line is going to destroy the reference to the current elements being - // tracked. We need to save a copy of this collection so that we can add the new classes - // below. - elements = $(currentElements.get()); - this._removeClass(currentElements, classKey); - - // We don't use _addClass() here, because that uses this.options.classes - // for generating the string of classes. We want to use the value passed in from - // _setOption(), this is the new value of the classes option which was passed to - // _setOption(). We pass this value directly to _classes(). - elements.addClass( - this._classes({ - element: elements, - keys: classKey, - classes: value, - add: true - }) - ); - } - }, - - _setOptionDisabled: function (value) { - this._toggleClass( - this.widget(), - this.widgetFullName + '-disabled', - null, - !!value - ); - - // If the widget is becoming disabled, then nothing is interactive - if (value) { - this._removeClass(this.hoverable, null, 'ui-state-hover'); - this._removeClass(this.focusable, null, 'ui-state-focus'); - } - }, - - enable: function () { - return this._setOptions({ disabled: false }); - }, - - disable: function () { - return this._setOptions({ disabled: true }); - }, - - _classes: function (options) { - var full = []; - var that = this; - - options = $.extend( - { - element: this.element, - classes: this.options.classes || {} - }, - options - ); - - /** - * - */ - function bindRemoveEvent() { - var nodesToBind = []; - - options.element.each(function (_, element) { - var isTracked = $.map(that.classesElementLookup, function (elements) { - return elements; - }).some(function (elements) { - return elements.is(element); - }); - - if (!isTracked) { - nodesToBind.push(element); - } - }); - - that._on($(nodesToBind), { - remove: '_untrackClassesElement' - }); - } - - /** - * @param classes - * @param checkOption - */ - function processClassString(classes, checkOption) { - var current, i; - for (i = 0; i < classes.length; i++) { - current = that.classesElementLookup[classes[i]] || $(); - if (options.add) { - bindRemoveEvent(); - current = $( - $.uniqueSort(current.get().concat(options.element.get())) - ); - } else { - current = $(current.not(options.element).get()); - } - that.classesElementLookup[classes[i]] = current; - full.push(classes[i]); - if (checkOption && options.classes[classes[i]]) { - full.push(options.classes[classes[i]]); - } - } - } - - if (options.keys) { - processClassString(options.keys.match(/\S+/g) || [], true); - } - if (options.extra) { - processClassString(options.extra.match(/\S+/g) || []); - } - - return full.join(' '); - }, - - _untrackClassesElement: function (event) { - var that = this; - $.each(that.classesElementLookup, function (key, value) { - if ($.inArray(event.target, value) !== -1) { - that.classesElementLookup[key] = $(value.not(event.target).get()); - } - }); - - this._off($(event.target)); - }, - - _removeClass: function (element, keys, extra) { - return this._toggleClass(element, keys, extra, false); - }, - - _addClass: function (element, keys, extra) { - return this._toggleClass(element, keys, extra, true); - }, - - _toggleClass: function (element, keys, extra, add) { - add = typeof add === 'boolean' ? add : extra; - var shift = typeof element === 'string' || element === null, - options = { - extra: shift ? keys : extra, - keys: shift ? element : keys, - element: shift ? this.element : element, - add: add - }; - options.element.toggleClass(this._classes(options), add); - return this; - }, - - _on: function (suppressDisabledCheck, element, handlers) { - var delegateElement; - var instance = this; - - // No suppressDisabledCheck flag, shuffle arguments - if (typeof suppressDisabledCheck !== 'boolean') { - handlers = element; - element = suppressDisabledCheck; - suppressDisabledCheck = false; - } - - // No element argument, shuffle and use this.element - if (!handlers) { - handlers = element; - element = this.element; - delegateElement = this.widget(); - } else { - element = delegateElement = $(element); - this.bindings = this.bindings.add(element); - } - - $.each(handlers, function (event, handler) { - /** - * - */ - function handlerProxy() { - // Allow widgets to customize the disabled handling - // - disabled as an array instead of boolean - // - disabled class as method for disabling individual parts - if ( - !suppressDisabledCheck && - (instance.options.disabled === true || - $(this).hasClass('ui-state-disabled')) - ) { - return; - } - return ( - typeof handler === 'string' ? instance[handler] : handler - ).apply(instance, arguments); - } - - // Copy the guid so direct unbinding works - if (typeof handler !== 'string') { - handlerProxy.guid = handler.guid = - handler.guid || handlerProxy.guid || $.guid++; - } - - var match = event.match(/^([\w:-]*)\s*(.*)$/); - var eventName = match[1] + instance.eventNamespace; - var selector = match[2]; - - if (selector) { - delegateElement.on(eventName, selector, handlerProxy); - } else { - element.on(eventName, handlerProxy); - } - }); - }, - - _off: function (element, eventName) { - eventName = - (eventName || '').split(' ').join(this.eventNamespace + ' ') + - this.eventNamespace; - element.off(eventName); - - // Clear the stack to avoid memory leaks (#10056) - this.bindings = $(this.bindings.not(element).get()); - this.focusable = $(this.focusable.not(element).get()); - this.hoverable = $(this.hoverable.not(element).get()); - }, - - _delay: function (handler, delay) { - /** - * - */ - function handlerProxy() { - return ( - typeof handler === 'string' ? instance[handler] : handler - ).apply(instance, arguments); - } - var instance = this; - return setTimeout(handlerProxy, delay || 0); - }, - - _hoverable: function (element) { - this.hoverable = this.hoverable.add(element); - this._on(element, { - mouseenter: function (event) { - this._addClass($(event.currentTarget), null, 'ui-state-hover'); - }, - mouseleave: function (event) { - this._removeClass($(event.currentTarget), null, 'ui-state-hover'); - } - }); - }, - - _focusable: function (element) { - this.focusable = this.focusable.add(element); - this._on(element, { - focusin: function (event) { - this._addClass($(event.currentTarget), null, 'ui-state-focus'); - }, - focusout: function (event) { - this._removeClass($(event.currentTarget), null, 'ui-state-focus'); - } - }); - }, - - _trigger: function (type, event, data) { - var prop, orig; - var callback = this.options[type]; - - data = data || {}; - event = $.Event(event); - event.type = ( - type === this.widgetEventPrefix ? type : this.widgetEventPrefix + type - ).toLowerCase(); - - // The original event may come from any element - // so we need to reset the target on the new event - event.target = this.element[0]; - - // Copy original event properties over to the new event - orig = event.originalEvent; - if (orig) { - for (prop in orig) { - if (!(prop in event)) { - event[prop] = orig[prop]; - } - } - } - - this.element.trigger(event, data); - return !( - (typeof callback === 'function' && - callback.apply(this.element[0], [event].concat(data)) === false) || - event.isDefaultPrevented() - ); - } - }; - - $.each({ show: 'fadeIn', hide: 'fadeOut' }, function (method, defaultEffect) { - $.Widget.prototype['_' + method] = function (element, options, callback) { - if (typeof options === 'string') { - options = { effect: options }; - } - - var hasOptions; - var effectName = !options - ? method - : options === true || typeof options === 'number' - ? defaultEffect - : options.effect || defaultEffect; - - options = options || {}; - if (typeof options === 'number') { - options = { duration: options }; - } else if (options === true) { - options = {}; - } - - hasOptions = !$.isEmptyObject(options); - options.complete = callback; - - if (options.delay) { - element.delay(options.delay); - } - - if (hasOptions && $.effects && $.effects.effect[effectName]) { - element[method](options); - } else if (effectName !== method && element[effectName]) { - element[effectName](options.duration, options.easing, callback); - } else { - element.queue(function (next) { - $(this)[method](); - if (callback) { - callback.call(element[0]); - } - next(); - }); - } - }; - }); -}); diff --git a/lib/web/jquery/uppy/dist/uppy-custom.css b/lib/web/jquery/uppy/dist/uppy-custom.css new file mode 100644 index 000000000000..cef247458121 --- /dev/null +++ b/lib/web/jquery/uppy/dist/uppy-custom.css @@ -0,0 +1,22 @@ +/** css related to Uppy **/ +.uppy-Dashboard-progressindicators, +.uppy-Dashboard-close, +.uppy-Dashboard-dropFilesHereHint, +.uppy-Dashboard-inner{ + display:none; +} + +.image.image-placeholder #fileUploader{ + border:500px solid transparent; + bottom:0; + cursor:pointer; + font-size:10em; + height:100%; + left:0; + opacity:0; + position:absolute; + right:0; + top:0; + width:100%; + z-index:3 +} diff --git a/lib/web/jquery/uppy/dist/uppy.min.js b/lib/web/jquery/uppy/dist/uppy.min.js new file mode 100644 index 000000000000..126c6ddd5533 --- /dev/null +++ b/lib/web/jquery/uppy/dist/uppy.min.js @@ -0,0 +1,63 @@ +"use strict";(()=>{var Bb=Object.create;var Cl=Object.defineProperty;var zb=Object.getOwnPropertyDescriptor;var jb=Object.getOwnPropertyNames;var Hb=Object.getPrototypeOf,$b=Object.prototype.hasOwnProperty;var n=(i,e)=>Cl(i,"name",{value:e,configurable:!0});var he=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Tl=(i,e)=>{for(var t in e)Cl(i,t,{get:e[t],enumerable:!0})},qb=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of jb(e))!$b.call(i,s)&&s!==t&&Cl(i,s,{get:()=>e[s],enumerable:!(r=zb(e,s))||r.enumerable});return i};var de=(i,e,t)=>(t=i!=null?Bb(Hb(i)):{},qb(e||!i||!i.__esModule?Cl(t,"default",{value:i,enumerable:!0}):t,i));var yh=he((Zx,of)=>{of.exports=n(function(){var e={},t=e._fns={};e.emit=n(function(a,l,h,p,d,f,y){var b=r(a);b.length&&s(a,b,[l,h,p,d,f,y])},"emit"),e.on=n(function(a,l){t[a]||(t[a]=[]),t[a].push(l)},"on"),e.once=n(function(a,l){function h(){l.apply(this,arguments),e.off(a,h)}n(h,"one"),this.on(a,h)},"once"),e.off=n(function(a,l){var h=[];if(a&&l){var p=this._fns[a],d=0,f=p?p.length:0;for(d;d{function Yb(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}n(Yb,"isObject");nf.exports=Yb});var lf=he((oF,af)=>{var Qb=typeof global=="object"&&global&&global.Object===Object&&global;af.exports=Qb});var vh=he((nF,uf)=>{var Jb=lf(),Zb=typeof self=="object"&&self&&self.Object===Object&&self,e1=Jb||Zb||Function("return this")();uf.exports=e1});var df=he((aF,hf)=>{var t1=vh(),i1=n(function(){return t1.Date.now()},"now");hf.exports=i1});var pf=he((uF,cf)=>{var r1=/\s/;function s1(i){for(var e=i.length;e--&&r1.test(i.charAt(e)););return e}n(s1,"trimmedEndIndex");cf.exports=s1});var mf=he((dF,ff)=>{var o1=pf(),n1=/^\s+/;function a1(i){return i&&i.slice(0,o1(i)+1).replace(n1,"")}n(a1,"baseTrim");ff.exports=a1});var bh=he((pF,gf)=>{var l1=vh(),u1=l1.Symbol;gf.exports=u1});var wf=he((fF,bf)=>{var yf=bh(),vf=Object.prototype,h1=vf.hasOwnProperty,d1=vf.toString,cn=yf?yf.toStringTag:void 0;function c1(i){var e=h1.call(i,cn),t=i[cn];try{i[cn]=void 0;var r=!0}catch{}var s=d1.call(i);return r&&(e?i[cn]=t:delete i[cn]),s}n(c1,"getRawTag");bf.exports=c1});var Pf=he((gF,Sf)=>{var p1=Object.prototype,f1=p1.toString;function m1(i){return f1.call(i)}n(m1,"objectToString");Sf.exports=m1});var Ef=he((vF,Ff)=>{var _f=bh(),g1=wf(),y1=Pf(),v1="[object Null]",b1="[object Undefined]",xf=_f?_f.toStringTag:void 0;function w1(i){return i==null?i===void 0?b1:v1:xf&&xf in Object(i)?g1(i):y1(i)}n(w1,"baseGetTag");Ff.exports=w1});var Cf=he((wF,Of)=>{function S1(i){return i!=null&&typeof i=="object"}n(S1,"isObjectLike");Of.exports=S1});var Af=he((PF,Tf)=>{var P1=Ef(),_1=Cf(),x1="[object Symbol]";function F1(i){return typeof i=="symbol"||_1(i)&&P1(i)==x1}n(F1,"isSymbol");Tf.exports=F1});var Df=he((xF,kf)=>{var E1=mf(),Rf=Al(),O1=Af(),Uf=0/0,C1=/^[-+]0x[0-9a-f]+$/i,T1=/^0b[01]+$/i,A1=/^0o[0-7]+$/i,R1=parseInt;function U1(i){if(typeof i=="number")return i;if(O1(i))return Uf;if(Rf(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=Rf(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=E1(i);var t=T1.test(i);return t||A1.test(i)?R1(i.slice(2),t?2:8):C1.test(i)?Uf:+i}n(U1,"toNumber");kf.exports=U1});var Sh=he((EF,Nf)=>{var k1=Al(),wh=df(),If=Df(),D1="Expected a function",I1=Math.max,N1=Math.min;function M1(i,e,t){var r,s,o,a,l,h,p=0,d=!1,f=!1,y=!0;if(typeof i!="function")throw new TypeError(D1);e=If(e)||0,k1(t)&&(d=!!t.leading,f="maxWait"in t,o=f?I1(If(t.maxWait)||0,e):o,y="trailing"in t?!!t.trailing:y);function b(B){var z=r,K=s;return r=s=void 0,p=B,a=i.apply(K,z),a}n(b,"invokeFunc");function S(B){return p=B,l=setTimeout(F,e),d?b(B):a}n(S,"leadingEdge");function E(B){var z=B-h,K=B-p,oe=e-z;return f?N1(oe,o-K):oe}n(E,"remainingWait");function x(B){var z=B-h,K=B-p;return h===void 0||z>=e||z<0||f&&K>=o}n(x,"shouldInvoke");function F(){var B=wh();if(x(B))return U(B);l=setTimeout(F,E(B))}n(F,"timerExpired");function U(B){return l=void 0,y&&r?b(B):(r=s=void 0,a)}n(U,"trailingEdge");function j(){l!==void 0&&clearTimeout(l),p=0,r=h=s=l=void 0}n(j,"cancel");function G(){return l===void 0?a:U(wh())}n(G,"flush");function J(){var B=wh(),z=x(B);if(r=arguments,s=this,h=B,z){if(l===void 0)return S(h);if(f)return clearTimeout(l),l=setTimeout(F,e),b(h)}return l===void 0&&(l=setTimeout(F,e)),a}return n(J,"debounced"),J.cancel=j,J.flush=G,J}n(M1,"debounce");Nf.exports=M1});var Rl=he((CF,Mf)=>{var L1=Sh(),B1=Al(),z1="Expected a function";function j1(i,e,t){var r=!0,s=!0;if(typeof i!="function")throw new TypeError(z1);return B1(t)&&(r="leading"in t?!!t.leading:r,s="trailing"in t?!!t.trailing:s),L1(i,e,{leading:r,maxWait:e,trailing:s})}n(j1,"throttle");Mf.exports=j1});var Il=he((YF,Hf)=>{Hf.exports=n(function(e){if(typeof e!="number"||isNaN(e))throw new TypeError(`Expected a number, got ${typeof e}`);let t=e<0,r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t&&(e=-e),e<1)return`${(t?"-":"")+e} B`;let s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1);e=Number(e/Math.pow(1024,s));let o=r[s];return e>=10||e%1===0?`${(t?"-":"")+e.toFixed(0)} ${o}`:`${(t?"-":"")+e.toFixed(1)} ${o}`},"prettierBytes")});var Vf=he((JF,qf)=>{"use strict";function $f(i,e){this.text=i=i||"",this.hasWild=~i.indexOf("*"),this.separator=e,this.parts=i.split(e)}n($f,"WildcardMatcher");$f.prototype.match=function(i){var e=!0,t=this.parts,r,s=t.length,o;if(typeof i=="string"||i instanceof String)if(!this.hasWild&&this.text!=i)e=!1;else{for(o=(i||"").split(this.separator),r=0;e&&r{var G1=Vf(),K1=/[\/\+\.]/;Wf.exports=function(i,e){function t(r){var s=G1(r,i,K1);return s&&s.length>=2}return n(t,"test"),e?t(e.split(";")[0]):t}});var bm=he((j3,vm)=>{function pi(i,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(i)),this._timeouts=i,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}n(pi,"RetryOperation");vm.exports=pi;pi.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};pi.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};pi.prototype.retry=function(i){if(this._timeout&&clearTimeout(this._timeout),!i)return!1;var e=new Date().getTime();if(i&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(i),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(i);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t),this._options.unref&&this._timer.unref(),!0};pi.prototype.attempt=function(i,e){this._fn=i,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};pi.prototype.try=function(i){console.log("Using RetryOperation.try() is deprecated"),this.attempt(i)};pi.prototype.start=function(i){console.log("Using RetryOperation.start() is deprecated"),this.attempt(i)};pi.prototype.start=pi.prototype.try;pi.prototype.errors=function(){return this._errors};pi.prototype.attempts=function(){return this._attempts};pi.prototype.mainError=function(){if(this._errors.length===0)return null;for(var i={},e=null,t=0,r=0;r=t&&(e=s,t=a)}return e}});var wm=he(Ss=>{var bw=bm();Ss.operation=function(i){var e=Ss.timeouts(i);return new bw(e,{forever:i&&(i.forever||i.retries===1/0),unref:i&&i.unref,maxRetryTime:i&&i.maxRetryTime})};Ss.timeouts=function(i){if(i instanceof Array)return[].concat(i);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in i)e[t]=i[t];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],s=0;s{Sm.exports=wm()});var Dm=he((UE,zh)=>{"use strict";var $w=Object.prototype.hasOwnProperty,At="~";function In(){}n(In,"Events");Object.create&&(In.prototype=Object.create(null),new In().__proto__||(At=!1));function qw(i,e,t){this.fn=i,this.context=e,this.once=t||!1}n(qw,"EE");function km(i,e,t,r,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var o=new qw(t,r||i,s),a=At?At+e:e;return i._events[a]?i._events[a].fn?i._events[a]=[i._events[a],o]:i._events[a].push(o):(i._events[a]=o,i._eventsCount++),i}n(km,"addListener");function Xl(i,e){--i._eventsCount===0?i._events=new In:delete i._events[e]}n(Xl,"clearEvent");function _t(){this._events=new In,this._eventsCount=0}n(_t,"EventEmitter");_t.prototype.eventNames=n(function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)$w.call(t,r)&&e.push(At?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},"eventNames");_t.prototype.listeners=n(function(e){var t=At?At+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,o=r.length,a=new Array(o);s{(function(){"use strict";var i={}.hasOwnProperty;function e(){for(var t=[],r=0;r{ty.exports=n(function(e,t){if(e===t)return!0;for(var r in e)if(!(r in t))return!1;for(var r in t)if(e[r]!==t[r])return!1;return!0},"isShallowEqual")});var oy=he((VT,sy)=>{sy.exports=n(function(e){if(typeof e!="number"||isNaN(e))throw new TypeError("Expected a number, got "+typeof e);var t=e<0,r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t&&(e=-e),e<1)return(t?"-":"")+e+" B";var s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1);e=Number(e/Math.pow(1024,s));var o=r[s];return e>=10||e%1===0?(t?"-":"")+e.toFixed(0)+" "+o:(t?"-":"")+e.toFixed(1)+" "+o},"prettierBytes")});var Ay=he((Vd,Wd)=>{(function(i,e){typeof Vd=="object"&&typeof Wd<"u"?Wd.exports=e():typeof define=="function"&&define.amd?define(e):(i=i||self,i.Cropper=e())})(Vd,function(){"use strict";function i(v){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?i=n(function(c){return typeof c},"_typeof"):i=n(function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},"_typeof"),i(v)}n(i,"_typeof");function e(v,c){if(!(v instanceof c))throw new TypeError("Cannot call a class as a function")}n(e,"_classCallCheck");function t(v,c){for(var g=0;gv.length)&&(c=v.length);for(var g=0,m=new Array(c);g
',_l=Number.isNaN||S.isNaN;function ie(v){return typeof v=="number"&&!_l(v)}n(ie,"isNumber");var an=n(function(c){return c>0&&c<1/0},"isPositiveNumber");function Po(v){return typeof v>"u"}n(Po,"isUndefined");function Ni(v){return i(v)==="object"&&v!==null}n(Ni,"isObject");var hh=Object.prototype.hasOwnProperty;function Vr(v){if(!Ni(v))return!1;try{var c=v.constructor,g=c.prototype;return c&&g&&hh.call(g,"isPrototypeOf")}catch{return!1}}n(Vr,"isPlainObject");function St(v){return typeof v=="function"}n(St,"isFunction");var dh=Array.prototype.slice;function _o(v){return Array.from?Array.from(v):dh.call(v)}n(_o,"toArray");function Re(v,c){return v&&St(c)&&(Array.isArray(v)||ie(v.length)?_o(v).forEach(function(g,m){c.call(v,g,m,v)}):Ni(v)&&Object.keys(v).forEach(function(g){c.call(v,v[g],g,v)})),v}n(Re,"forEach");var Se=Object.assign||n(function(c){for(var g=arguments.length,m=new Array(g>1?g-1:0),P=1;P0&&m.forEach(function(w){Ni(w)&&Object.keys(w).forEach(function(_){c[_]=w[_]})}),c},"assign"),ln=/\.\d*(?:0|9){12}\d*$/;function Mi(v){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return ln.test(v)?Math.round(v*c)/c:v}n(Mi,"normalizeDecimalNumber");var xl=/^width|height|left|top|marginLeft|marginTop$/;function vi(v,c){var g=v.style;Re(c,function(m,P){xl.test(P)&&ie(m)&&(m="".concat(m,"px")),g[P]=m})}n(vi,"setStyle");function Fl(v,c){return v.classList?v.classList.contains(c):v.className.indexOf(c)>-1}n(Fl,"hasClass");function je(v,c){if(c){if(ie(v.length)){Re(v,function(m){je(m,c)});return}if(v.classList){v.classList.add(c);return}var g=v.className.trim();g?g.indexOf(c)<0&&(v.className="".concat(g," ").concat(c)):v.className=c}}n(je,"addClass");function bi(v,c){if(c){if(ie(v.length)){Re(v,function(g){bi(g,c)});return}if(v.classList){v.classList.remove(c);return}v.className.indexOf(c)>=0&&(v.className=v.className.replace(c,""))}}n(bi,"removeClass");function Wr(v,c,g){if(c){if(ie(v.length)){Re(v,function(m){Wr(m,c,g)});return}g?je(v,c):bi(v,c)}}n(Wr,"toggleClass");var yb=/([a-z\d])([A-Z])/g;function ch(v){return v.replace(yb,"$1-$2").toLowerCase()}n(ch,"toParamCase");function ph(v,c){return Ni(v[c])?v[c]:v.dataset?v.dataset[c]:v.getAttribute("data-".concat(ch(c)))}n(ph,"getData");function un(v,c,g){Ni(g)?v[c]=g:v.dataset?v.dataset[c]=g:v.setAttribute("data-".concat(ch(c)),g)}n(un,"setData");function vb(v,c){if(Ni(v[c]))try{delete v[c]}catch{v[c]=void 0}else if(v.dataset)try{delete v.dataset[c]}catch{v.dataset[c]=void 0}else v.removeAttribute("data-".concat(ch(c)))}n(vb,"removeData");var Vp=/\s\s*/,Wp=function(){var v=!1;if(b){var c=!1,g=n(function(){},"listener"),m=Object.defineProperty({},"once",{get:n(function(){return v=!0,c},"get"),set:n(function(w){c=w},"set")});S.addEventListener("test",g,m),S.removeEventListener("test",g,m)}return v}();function wi(v,c,g){var m=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},P=g;c.trim().split(Vp).forEach(function(w){if(!Wp){var _=v.listeners;_&&_[w]&&_[w][g]&&(P=_[w][g],delete _[w][g],Object.keys(_[w]).length===0&&delete _[w],Object.keys(_).length===0&&delete v.listeners)}v.removeEventListener(w,P,m)})}n(wi,"removeListener");function hi(v,c,g){var m=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},P=g;c.trim().split(Vp).forEach(function(w){if(m.once&&!Wp){var _=v.listeners,O=_===void 0?{}:_;P=n(function(){delete O[w][g],v.removeEventListener(w,P,m);for(var A=arguments.length,T=new Array(A),C=0;C1&&arguments[1]!==void 0?arguments[1]:"contain",w=an(m),_=an(g);if(w&&_){var O=g*c;P==="contain"&&O>m||P==="cover"&&O90?{width:D,height:O}:{width:O,height:D}}n(Pb,"getRotatedSizes");function _b(v,c,g,m){var P=c.aspectRatio,w=c.naturalWidth,_=c.naturalHeight,O=c.rotate,D=O===void 0?0:O,A=c.scaleX,T=A===void 0?1:A,C=c.scaleY,k=C===void 0?1:C,ue=g.aspectRatio,le=g.naturalWidth,Ce=g.naturalHeight,fe=m.fillColor,Ze=fe===void 0?"transparent":fe,lt=m.imageSmoothingEnabled,Ke=lt===void 0?!0:lt,dr=m.imageSmoothingQuality,Wt=dr===void 0?"low":dr,M=m.maxWidth,me=M===void 0?1/0:M,et=m.maxHeight,di=et===void 0?1/0:et,cr=m.minWidth,ps=cr===void 0?0:cr,fs=m.minHeight,Kr=fs===void 0?0:fs,Li=document.createElement("canvas"),jt=Li.getContext("2d"),ms=Gr({aspectRatio:ue,width:me,height:di}),Ol=Gr({aspectRatio:ue,width:ps,height:Kr},"cover"),mh=Math.min(ms.width,Math.max(Ol.width,le)),gh=Math.min(ms.height,Math.max(Ol.height,Ce)),Jp=Gr({aspectRatio:P,width:me,height:di}),Zp=Gr({aspectRatio:P,width:ps,height:Kr},"cover"),ef=Math.min(Jp.width,Math.max(Zp.width,w)),tf=Math.min(Jp.height,Math.max(Zp.height,_)),Mb=[-ef/2,-tf/2,ef,tf];return Li.width=Mi(mh),Li.height=Mi(gh),jt.fillStyle=Ze,jt.fillRect(0,0,mh,gh),jt.save(),jt.translate(mh/2,gh/2),jt.rotate(D*Math.PI/180),jt.scale(T,k),jt.imageSmoothingEnabled=Ke,jt.imageSmoothingQuality=Wt,jt.drawImage.apply(jt,[v].concat(l(Mb.map(function(Lb){return Math.floor(Mi(Lb))})))),jt.restore(),Li}n(_b,"getSourceCanvas");var Yp=String.fromCharCode;function xb(v,c,g){var m="";g+=c;for(var P=c;P0;)g.push(Yp.apply(null,_o(P.subarray(0,m)))),P=P.subarray(m);return"data:".concat(c,";base64,").concat(btoa(g.join("")))}n(Ob,"arrayBufferToDataURL");function Cb(v){var c=new DataView(v),g;try{var m,P,w;if(c.getUint8(0)===255&&c.getUint8(1)===216)for(var _=c.byteLength,O=2;O+1<_;){if(c.getUint8(O)===255&&c.getUint8(O+1)===225){P=O;break}O+=1}if(P){var D=P+4,A=P+10;if(xb(c,D,4)==="Exif"){var T=c.getUint16(A);if(m=T===18761,(m||T===19789)&&c.getUint16(A+2,m)===42){var C=c.getUint32(A+4,m);C>=8&&(w=A+C)}}}if(w){var k=c.getUint16(w,m),ue,le;for(le=0;lec.width?m===3?D=c.height*O:A=c.width/O:m===3?A=c.width/O:D=c.height*O;var T={aspectRatio:O,naturalWidth:w,naturalHeight:_,width:D,height:A};T.left=(c.width-D)/2,T.top=(c.height-A)/2,T.oldLeft=T.left,T.oldTop=T.top,this.canvasData=T,this.limited=m===1||m===2,this.limitCanvas(!0,!0),this.initialImageData=Se({},g),this.initialCanvasData=Se({},T)},"initCanvas"),limitCanvas:n(function(c,g){var m=this.options,P=this.containerData,w=this.canvasData,_=this.cropBoxData,O=m.viewMode,D=w.aspectRatio,A=this.cropped&&_;if(c){var T=Number(m.minCanvasWidth)||0,C=Number(m.minCanvasHeight)||0;O>1?(T=Math.max(T,P.width),C=Math.max(C,P.height),O===3&&(C*D>T?T=C*D:C=T/D)):O>0&&(T?T=Math.max(T,A?_.width:0):C?C=Math.max(C,A?_.height:0):A&&(T=_.width,C=_.height,C*D>T?T=C*D:C=T/D));var k=Gr({aspectRatio:D,width:T,height:C});T=k.width,C=k.height,w.minWidth=T,w.minHeight=C,w.maxWidth=1/0,w.maxHeight=1/0}if(g)if(O>(A?0:1)){var ue=P.width-w.width,le=P.height-w.height;w.minLeft=Math.min(0,ue),w.minTop=Math.min(0,le),w.maxLeft=Math.max(0,ue),w.maxTop=Math.max(0,le),A&&this.limited&&(w.minLeft=Math.min(_.left,_.left+(_.width-w.width)),w.minTop=Math.min(_.top,_.top+(_.height-w.height)),w.maxLeft=_.left,w.maxTop=_.top,O===2&&(w.width>=P.width&&(w.minLeft=Math.min(0,ue),w.maxLeft=Math.max(0,ue)),w.height>=P.height&&(w.minTop=Math.min(0,le),w.maxTop=Math.max(0,le))))}else w.minLeft=-w.width,w.minTop=-w.height,w.maxLeft=P.width,w.maxTop=P.height},"limitCanvas"),renderCanvas:n(function(c,g){var m=this.canvasData,P=this.imageData;if(g){var w=Pb({width:P.naturalWidth*Math.abs(P.scaleX||1),height:P.naturalHeight*Math.abs(P.scaleY||1),degree:P.rotate||0}),_=w.width,O=w.height,D=m.width*(_/m.naturalWidth),A=m.height*(O/m.naturalHeight);m.left-=(D-m.width)/2,m.top-=(A-m.height)/2,m.width=D,m.height=A,m.aspectRatio=_/O,m.naturalWidth=_,m.naturalHeight=O,this.limitCanvas(!0,!1)}(m.width>m.maxWidth||m.widthm.maxHeight||m.heightg.width?w.height=w.width/m:w.width=w.height*m),this.cropBoxData=w,this.limitCropBox(!0,!0),w.width=Math.min(Math.max(w.width,w.minWidth),w.maxWidth),w.height=Math.min(Math.max(w.height,w.minHeight),w.maxHeight),w.width=Math.max(w.minWidth,w.width*P),w.height=Math.max(w.minHeight,w.height*P),w.left=g.left+(g.width-w.width)/2,w.top=g.top+(g.height-w.height)/2,w.oldLeft=w.left,w.oldTop=w.top,this.initialCropBoxData=Se({},w)},"initCropBox"),limitCropBox:n(function(c,g){var m=this.options,P=this.containerData,w=this.canvasData,_=this.cropBoxData,O=this.limited,D=m.aspectRatio;if(c){var A=Number(m.minCropBoxWidth)||0,T=Number(m.minCropBoxHeight)||0,C=O?Math.min(P.width,w.width,w.width+w.left,P.width-w.left):P.width,k=O?Math.min(P.height,w.height,w.height+w.top,P.height-w.top):P.height;A=Math.min(A,P.width),T=Math.min(T,P.height),D&&(A&&T?T*D>A?T=A/D:A=T*D:A?T=A/D:T&&(A=T*D),k*D>C?k=C/D:C=k*D),_.minWidth=Math.min(A,C),_.minHeight=Math.min(T,k),_.maxWidth=C,_.maxHeight=k}g&&(O?(_.minLeft=Math.max(0,w.left),_.minTop=Math.max(0,w.top),_.maxLeft=Math.min(P.width,w.left+w.width)-_.width,_.maxTop=Math.min(P.height,w.top+w.height)-_.height):(_.minLeft=0,_.minTop=0,_.maxLeft=P.width-_.width,_.maxTop=P.height-_.height))},"limitCropBox"),renderCropBox:n(function(){var c=this.options,g=this.containerData,m=this.cropBoxData;(m.width>m.maxWidth||m.widthm.maxHeight||m.height=g.width&&m.height>=g.height?G:U),vi(this.cropBox,Se({width:m.width,height:m.height},hn({translateX:m.left,translateY:m.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},"renderCropBox"),output:n(function(){this.preview(),xo(this.element,ne,this.getData())},"output")},Rb={initPreview:n(function(){var c=this.element,g=this.crossOrigin,m=this.options.preview,P=g?this.crossOriginUrl:this.url,w=c.alt||"The image to preview",_=document.createElement("img");if(g&&(_.crossOrigin=g),_.src=P,_.alt=w,this.viewBox.appendChild(_),this.viewBoxImage=_,!!m){var O=m;typeof m=="string"?O=c.ownerDocument.querySelectorAll(m):m.querySelector&&(O=[m]),this.previews=O,Re(O,function(D){var A=document.createElement("img");un(D,Q,{width:D.offsetWidth,height:D.offsetHeight,html:D.innerHTML}),g&&(A.crossOrigin=g),A.src=P,A.alt=w,A.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',D.innerHTML="",D.appendChild(A)})}},"initPreview"),resetPreview:n(function(){Re(this.previews,function(c){var g=ph(c,Q);vi(c,{width:g.width,height:g.height}),c.innerHTML=g.html,vb(c,Q)})},"resetPreview"),preview:n(function(){var c=this.imageData,g=this.canvasData,m=this.cropBoxData,P=m.width,w=m.height,_=c.width,O=c.height,D=m.left-g.left-c.left,A=m.top-g.top-c.top;!this.cropped||this.disabled||(vi(this.viewBoxImage,Se({width:_,height:O},hn(Se({translateX:-D,translateY:-A},c)))),Re(this.previews,function(T){var C=ph(T,Q),k=C.width,ue=C.height,le=k,Ce=ue,fe=1;P&&(fe=k/P,Ce=w*fe),w&&Ce>ue&&(fe=ue/w,le=P*fe,Ce=ue),vi(T,{width:le,height:Ce}),vi(T.getElementsByTagName("img")[0],Se({width:_*fe,height:O*fe},hn(Se({translateX:-D*fe,translateY:-A*fe},c))))}))},"preview")},Ub={bind:n(function(){var c=this.element,g=this.options,m=this.cropper;St(g.cropstart)&&hi(c,Ee,g.cropstart),St(g.cropmove)&&hi(c,Fe,g.cropmove),St(g.cropend)&&hi(c,re,g.cropend),St(g.crop)&&hi(c,ne,g.crop),St(g.zoom)&&hi(c,ur,g.zoom),hi(m,Ge,this.onCropStart=this.cropStart.bind(this)),g.zoomable&&g.zoomOnWheel&&hi(m,qr,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),g.toggleDragModeOnDblclick&&hi(m,Ft,this.onDblclick=this.dblclick.bind(this)),hi(c.ownerDocument,lr,this.onCropMove=this.cropMove.bind(this)),hi(c.ownerDocument,So,this.onCropEnd=this.cropEnd.bind(this)),g.responsive&&hi(window,$r,this.onResize=this.resize.bind(this))},"bind"),unbind:n(function(){var c=this.element,g=this.options,m=this.cropper;St(g.cropstart)&&wi(c,Ee,g.cropstart),St(g.cropmove)&&wi(c,Fe,g.cropmove),St(g.cropend)&&wi(c,re,g.cropend),St(g.crop)&&wi(c,ne,g.crop),St(g.zoom)&&wi(c,ur,g.zoom),wi(m,Ge,this.onCropStart),g.zoomable&&g.zoomOnWheel&&wi(m,qr,this.onWheel,{passive:!1,capture:!0}),g.toggleDragModeOnDblclick&&wi(m,Ft,this.onDblclick),wi(c.ownerDocument,lr,this.onCropMove),wi(c.ownerDocument,So,this.onCropEnd),g.responsive&&wi(window,$r,this.onResize)},"unbind")},kb={resize:n(function(){if(!this.disabled){var c=this.options,g=this.container,m=this.containerData,P=g.offsetWidth/m.width;if(P!==1||g.offsetHeight!==m.height){var w,_;c.restore&&(w=this.getCanvasData(),_=this.getCropBoxData()),this.render(),c.restore&&(this.setCanvasData(Re(w,function(O,D){w[D]=O*P})),this.setCropBoxData(Re(_,function(O,D){_[D]=O*P})))}}},"resize"),dblclick:n(function(){this.disabled||this.options.dragMode===pe||this.setDragMode(Fl(this.dragBox,_e)?ye:X)},"dblclick"),wheel:n(function(c){var g=this,m=Number(this.options.wheelZoomRatio)||.1,P=1;this.disabled||(c.preventDefault(),!this.wheeling&&(this.wheeling=!0,setTimeout(function(){g.wheeling=!1},50),c.deltaY?P=c.deltaY>0?1:-1:c.wheelDelta?P=-c.wheelDelta/120:c.detail&&(P=c.detail>0?1:-1),this.zoom(-P*m,c)))},"wheel"),cropStart:n(function(c){var g=c.buttons,m=c.button;if(!(this.disabled||(c.type==="mousedown"||c.type==="pointerdown"&&c.pointerType==="mouse")&&(ie(g)&&g!==1||ie(m)&&m!==0||c.ctrlKey))){var P=this.options,w=this.pointers,_;c.changedTouches?Re(c.changedTouches,function(O){w[O.identifier]=El(O)}):w[c.pointerId||0]=El(c),Object.keys(w).length>1&&P.zoomable&&P.zoomOnTouch?_=J:_=ph(c.target,L),nt.test(_)&&xo(this.element,Ee,{originalEvent:c,action:_})!==!1&&(c.preventDefault(),this.action=_,this.cropping=!1,_===j&&(this.cropping=!0,je(this.dragBox,R)))}},"cropStart"),cropMove:n(function(c){var g=this.action;if(!(this.disabled||!g)){var m=this.pointers;c.preventDefault(),xo(this.element,Fe,{originalEvent:c,action:g})!==!1&&(c.changedTouches?Re(c.changedTouches,function(P){Se(m[P.identifier]||{},El(P,!0))}):Se(m[c.pointerId||0]||{},El(c,!0)),this.change(c))}},"cropMove"),cropEnd:n(function(c){if(!this.disabled){var g=this.action,m=this.pointers;c.changedTouches?Re(c.changedTouches,function(P){delete m[P.identifier]}):delete m[c.pointerId||0],g&&(c.preventDefault(),Object.keys(m).length||(this.action=""),this.cropping&&(this.cropping=!1,Wr(this.dragBox,R,this.cropped&&this.options.modal)),xo(this.element,re,{originalEvent:c,action:g}))}},"cropEnd")},Db={change:n(function(c){var g=this.options,m=this.canvasData,P=this.containerData,w=this.cropBoxData,_=this.pointers,O=this.action,D=g.aspectRatio,A=w.left,T=w.top,C=w.width,k=w.height,ue=A+C,le=T+k,Ce=0,fe=0,Ze=P.width,lt=P.height,Ke=!0,dr;!D&&c.shiftKey&&(D=C&&k?C/k:1),this.limited&&(Ce=w.minLeft,fe=w.minTop,Ze=Ce+Math.min(P.width,m.width,m.left+m.width),lt=fe+Math.min(P.height,m.height,m.top+m.height));var Wt=_[Object.keys(_)[0]],M={x:Wt.endX-Wt.startX,y:Wt.endY-Wt.startY},me=n(function(di){switch(di){case B:ue+M.x>Ze&&(M.x=Ze-ue);break;case z:A+M.xlt&&(M.y=lt-le);break}},"check");switch(O){case U:A+=M.x,T+=M.y;break;case B:if(M.x>=0&&(ue>=Ze||D&&(T<=fe||le>=lt))){Ke=!1;break}me(B),C+=M.x,C<0&&(O=z,C=-C,A-=C),D&&(k=C/D,T+=(w.height-k)/2);break;case oe:if(M.y<=0&&(T<=fe||D&&(A<=Ce||ue>=Ze))){Ke=!1;break}me(oe),k-=M.y,T+=M.y,k<0&&(O=K,k=-k,T-=k),D&&(C=k*D,A+=(w.width-C)/2);break;case z:if(M.x<=0&&(A<=Ce||D&&(T<=fe||le>=lt))){Ke=!1;break}me(z),C-=M.x,A+=M.x,C<0&&(O=B,C=-C,A-=C),D&&(k=C/D,T+=(w.height-k)/2);break;case K:if(M.y>=0&&(le>=lt||D&&(A<=Ce||ue>=Ze))){Ke=!1;break}me(K),k+=M.y,k<0&&(O=oe,k=-k,T-=k),D&&(C=k*D,A+=(w.width-C)/2);break;case Be:if(D){if(M.y<=0&&(T<=fe||ue>=Ze)){Ke=!1;break}me(oe),k-=M.y,T+=M.y,C=k*D}else me(oe),me(B),M.x>=0?uefe&&(k-=M.y,T+=M.y):(k-=M.y,T+=M.y);C<0&&k<0?(O=We,k=-k,C=-C,T-=k,A-=C):C<0?(O=Je,C=-C,A-=C):k<0&&(O=wt,k=-k,T-=k);break;case Je:if(D){if(M.y<=0&&(T<=fe||A<=Ce)){Ke=!1;break}me(oe),k-=M.y,T+=M.y,C=k*D,A+=w.width-C}else me(oe),me(z),M.x<=0?A>Ce?(C-=M.x,A+=M.x):M.y<=0&&T<=fe&&(Ke=!1):(C-=M.x,A+=M.x),M.y<=0?T>fe&&(k-=M.y,T+=M.y):(k-=M.y,T+=M.y);C<0&&k<0?(O=wt,k=-k,C=-C,T-=k,A-=C):C<0?(O=Be,C=-C,A-=C):k<0&&(O=We,k=-k,T-=k);break;case We:if(D){if(M.x<=0&&(A<=Ce||le>=lt)){Ke=!1;break}me(z),C-=M.x,A+=M.x,k=C/D}else me(K),me(z),M.x<=0?A>Ce?(C-=M.x,A+=M.x):M.y>=0&&le>=lt&&(Ke=!1):(C-=M.x,A+=M.x),M.y>=0?le=0&&(ue>=Ze||le>=lt)){Ke=!1;break}me(B),C+=M.x,k=C/D}else me(K),me(B),M.x>=0?ue=0&&le>=lt&&(Ke=!1):C+=M.x,M.y>=0?le0?O=M.y>0?wt:Be:M.x<0&&(A-=C,O=M.y>0?We:Je),M.y<0&&(T-=k),this.cropped||(bi(this.cropBox,xe),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0));break}Ke&&(w.width=C,w.height=k,w.left=A,w.top=T,this.action=O,this.renderCropBox()),Re(_,function(et){et.startX=et.endX,et.startY=et.endY})},"change")},Ib={crop:n(function(){return this.ready&&!this.cropped&&!this.disabled&&(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&je(this.dragBox,R),bi(this.cropBox,xe),this.setCropBoxData(this.initialCropBoxData)),this},"crop"),reset:n(function(){return this.ready&&!this.disabled&&(this.imageData=Se({},this.initialImageData),this.canvasData=Se({},this.initialCanvasData),this.cropBoxData=Se({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},"reset"),clear:n(function(){return this.cropped&&!this.disabled&&(Se(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),bi(this.dragBox,R),je(this.cropBox,xe)),this},"clear"),replace:n(function(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return!this.disabled&&c&&(this.isImg&&(this.element.src=c),g?(this.url=c,this.image.src=c,this.ready&&(this.viewBoxImage.src=c,Re(this.previews,function(m){m.getElementsByTagName("img")[0].src=c}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(c))),this},"replace"),enable:n(function(){return this.ready&&this.disabled&&(this.disabled=!1,bi(this.cropper,ze)),this},"enable"),disable:n(function(){return this.ready&&!this.disabled&&(this.disabled=!0,je(this.cropper,ze)),this},"disable"),destroy:n(function(){var c=this.element;return c[F]?(c[F]=void 0,this.isImg&&this.replaced&&(c.src=this.originalUrl),this.uncreate(),this):this},"destroy"),move:n(function(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c,m=this.canvasData,P=m.left,w=m.top;return this.moveTo(Po(c)?c:P+Number(c),Po(g)?g:w+Number(g))},"move"),moveTo:n(function(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c,m=this.canvasData,P=!1;return c=Number(c),g=Number(g),this.ready&&!this.disabled&&this.options.movable&&(ie(c)&&(m.left=c,P=!0),ie(g)&&(m.top=g,P=!0),P&&this.renderCanvas(!0)),this},"moveTo"),zoom:n(function(c,g){var m=this.canvasData;return c=Number(c),c<0?c=1/(1-c):c=1+c,this.zoomTo(m.width*c/m.naturalWidth,null,g)},"zoom"),zoomTo:n(function(c,g,m){var P=this.options,w=this.canvasData,_=w.width,O=w.height,D=w.naturalWidth,A=w.naturalHeight;if(c=Number(c),c>=0&&this.ready&&!this.disabled&&P.zoomable){var T=D*c,C=A*c;if(xo(this.element,ur,{ratio:c,oldRatio:_/D,originalEvent:m})===!1)return this;if(m){var k=this.pointers,ue=Gp(this.cropper),le=k&&Object.keys(k).length?Sb(k):{pageX:m.pageX,pageY:m.pageY};w.left-=(T-_)*((le.pageX-ue.left-w.left)/_),w.top-=(C-O)*((le.pageY-ue.top-w.top)/O)}else Vr(g)&&ie(g.x)&&ie(g.y)?(w.left-=(T-_)*((g.x-w.left)/_),w.top-=(C-O)*((g.y-w.top)/O)):(w.left-=(T-_)/2,w.top-=(C-O)/2);w.width=T,w.height=C,this.renderCanvas(!0)}return this},"zoomTo"),rotate:n(function(c){return this.rotateTo((this.imageData.rotate||0)+Number(c))},"rotate"),rotateTo:n(function(c){return c=Number(c),ie(c)&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=c%360,this.renderCanvas(!0,!0)),this},"rotateTo"),scaleX:n(function(c){var g=this.imageData.scaleY;return this.scale(c,ie(g)?g:1)},"scaleX"),scaleY:n(function(c){var g=this.imageData.scaleX;return this.scale(ie(g)?g:1,c)},"scaleY"),scale:n(function(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c,m=this.imageData,P=!1;return c=Number(c),g=Number(g),this.ready&&!this.disabled&&this.options.scalable&&(ie(c)&&(m.scaleX=c,P=!0),ie(g)&&(m.scaleY=g,P=!0),P&&this.renderCanvas(!0,!0)),this},"scale"),getData:n(function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,g=this.options,m=this.imageData,P=this.canvasData,w=this.cropBoxData,_;if(this.ready&&this.cropped){_={x:w.left-P.left,y:w.top-P.top,width:w.width,height:w.height};var O=m.width/m.naturalWidth;if(Re(_,function(T,C){_[C]=T/O}),c){var D=Math.round(_.y+_.height),A=Math.round(_.x+_.width);_.x=Math.round(_.x),_.y=Math.round(_.y),_.width=A-_.x,_.height=D-_.y}}else _={x:0,y:0,width:0,height:0};return g.rotatable&&(_.rotate=m.rotate||0),g.scalable&&(_.scaleX=m.scaleX||1,_.scaleY=m.scaleY||1),_},"getData"),setData:n(function(c){var g=this.options,m=this.imageData,P=this.canvasData,w={};if(this.ready&&!this.disabled&&Vr(c)){var _=!1;g.rotatable&&ie(c.rotate)&&c.rotate!==m.rotate&&(m.rotate=c.rotate,_=!0),g.scalable&&(ie(c.scaleX)&&c.scaleX!==m.scaleX&&(m.scaleX=c.scaleX,_=!0),ie(c.scaleY)&&c.scaleY!==m.scaleY&&(m.scaleY=c.scaleY,_=!0)),_&&this.renderCanvas(!0,!0);var O=m.width/m.naturalWidth;ie(c.x)&&(w.left=c.x*O+P.left),ie(c.y)&&(w.top=c.y*O+P.top),ie(c.width)&&(w.width=c.width*O),ie(c.height)&&(w.height=c.height*O),this.setCropBoxData(w)}return this},"setData"),getContainerData:n(function(){return this.ready?Se({},this.containerData):{}},"getContainerData"),getImageData:n(function(){return this.sized?Se({},this.imageData):{}},"getImageData"),getCanvasData:n(function(){var c=this.canvasData,g={};return this.ready&&Re(["left","top","width","height","naturalWidth","naturalHeight"],function(m){g[m]=c[m]}),g},"getCanvasData"),setCanvasData:n(function(c){var g=this.canvasData,m=g.aspectRatio;return this.ready&&!this.disabled&&Vr(c)&&(ie(c.left)&&(g.left=c.left),ie(c.top)&&(g.top=c.top),ie(c.width)?(g.width=c.width,g.height=c.width/m):ie(c.height)&&(g.height=c.height,g.width=c.height*m),this.renderCanvas(!0)),this},"setCanvasData"),getCropBoxData:n(function(){var c=this.cropBoxData,g;return this.ready&&this.cropped&&(g={left:c.left,top:c.top,width:c.width,height:c.height}),g||{}},"getCropBoxData"),setCropBoxData:n(function(c){var g=this.cropBoxData,m=this.options.aspectRatio,P,w;return this.ready&&this.cropped&&!this.disabled&&Vr(c)&&(ie(c.left)&&(g.left=c.left),ie(c.top)&&(g.top=c.top),ie(c.width)&&c.width!==g.width&&(P=!0,g.width=c.width),ie(c.height)&&c.height!==g.height&&(w=!0,g.height=c.height),m&&(P?g.height=g.width/m:w&&(g.width=g.height*m)),this.renderCropBox()),this},"setCropBoxData"),getCroppedCanvas:n(function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var g=this.canvasData,m=_b(this.image,this.imageData,g,c);if(!this.cropped)return m;var P=this.getData(),w=P.x,_=P.y,O=P.width,D=P.height,A=m.width/Math.floor(g.naturalWidth);A!==1&&(w*=A,_*=A,O*=A,D*=A);var T=O/D,C=Gr({aspectRatio:T,width:c.maxWidth||1/0,height:c.maxHeight||1/0}),k=Gr({aspectRatio:T,width:c.minWidth||0,height:c.minHeight||0},"cover"),ue=Gr({aspectRatio:T,width:c.width||(A!==1?m.width:O),height:c.height||(A!==1?m.height:D)}),le=ue.width,Ce=ue.height;le=Math.min(C.width,Math.max(k.width,le)),Ce=Math.min(C.height,Math.max(k.height,Ce));var fe=document.createElement("canvas"),Ze=fe.getContext("2d");fe.width=Mi(le),fe.height=Mi(Ce),Ze.fillStyle=c.fillColor||"transparent",Ze.fillRect(0,0,le,Ce);var lt=c.imageSmoothingEnabled,Ke=lt===void 0?!0:lt,dr=c.imageSmoothingQuality;Ze.imageSmoothingEnabled=Ke,dr&&(Ze.imageSmoothingQuality=dr);var Wt=m.width,M=m.height,me=w,et=_,di,cr,ps,fs,Kr,Li;me<=-O||me>Wt?(me=0,di=0,ps=0,Kr=0):me<=0?(ps=-me,me=0,di=Math.min(Wt,O+me),Kr=di):me<=Wt&&(ps=0,di=Math.min(O,Wt-me),Kr=di),di<=0||et<=-D||et>M?(et=0,cr=0,fs=0,Li=0):et<=0?(fs=-et,et=0,cr=Math.min(M,D+et),Li=cr):et<=M&&(fs=0,cr=Math.min(D,M-et),Li=cr);var jt=[me,et,di,cr];if(Kr>0&&Li>0){var ms=le/O;jt.push(ps*ms,fs*ms,Kr*ms,Li*ms)}return Ze.drawImage.apply(Ze,[m].concat(l(jt.map(function(Ol){return Math.floor(Mi(Ol))})))),fe},"getCroppedCanvas"),setAspectRatio:n(function(c){var g=this.options;return!this.disabled&&!Po(c)&&(g.aspectRatio=Math.max(0,c)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},"setAspectRatio"),setDragMode:n(function(c){var g=this.options,m=this.dragBox,P=this.face;if(this.ready&&!this.disabled){var w=c===X,_=g.movable&&c===ye;c=w||_?c:pe,g.dragMode=c,un(m,L,c),Wr(m,_e,w),Wr(m,I,_),g.cropBoxMovable||(un(P,L,c),Wr(P,_e,w),Wr(P,I,_))}return this},"setDragMode")},Nb=S.Cropper,Qp=function(){function v(c){var g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e(this,v),!c||!Sl.test(c.tagName))throw new Error("The first argument is required and must be an or element.");this.element=c,this.options=Se({},nn,Vr(g)&&g),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return n(v,"Cropper"),r(v,[{key:"init",value:n(function(){var g=this.element,m=g.tagName.toLowerCase(),P;if(!g[F]){if(g[F]=this,m==="img"){if(this.isImg=!0,P=g.getAttribute("src")||"",this.originalUrl=P,!P)return;P=g.src}else m==="canvas"&&window.HTMLCanvasElement&&(P=g.toDataURL());this.load(P)}},"init")},{key:"load",value:n(function(g){var m=this;if(g){this.url=g,this.imageData={};var P=this.element,w=this.options;if(!w.rotatable&&!w.scalable&&(w.checkOrientation=!1),!w.checkOrientation||!window.ArrayBuffer){this.clone();return}if(at.test(g)){wl.test(g)?this.read(Eb(g)):this.clone();return}var _=new XMLHttpRequest,O=this.clone.bind(this);this.reloading=!0,this.xhr=_,_.onabort=O,_.onerror=O,_.ontimeout=O,_.onprogress=function(){_.getResponseHeader("content-type")!==hr&&_.abort()},_.onload=function(){m.read(_.response)},_.onloadend=function(){m.reloading=!1,m.xhr=null},w.checkCrossOrigin&&Kp(g)&&P.crossOrigin&&(g=Xp(g)),_.open("GET",g),_.responseType="arraybuffer",_.withCredentials=P.crossOrigin==="use-credentials",_.send()}},"load")},{key:"read",value:n(function(g){var m=this.options,P=this.imageData,w=Cb(g),_=0,O=1,D=1;if(w>1){this.url=Ob(g,hr);var A=Tb(w);_=A.rotate,O=A.scaleX,D=A.scaleY}m.rotatable&&(P.rotate=_),m.scalable&&(P.scaleX=O,P.scaleY=D),this.clone()},"read")},{key:"clone",value:n(function(){var g=this.element,m=this.url,P=g.crossOrigin,w=m;this.options.checkCrossOrigin&&Kp(m)&&(P||(P="anonymous"),w=Xp(m)),this.crossOrigin=P,this.crossOriginUrl=w;var _=document.createElement("img");P&&(_.crossOrigin=P),_.src=w||m,_.alt=g.alt||"The image to crop",this.image=_,_.onload=this.start.bind(this),_.onerror=this.stop.bind(this),je(_,ui),g.parentNode.insertBefore(_,g.nextSibling)},"clone")},{key:"start",value:n(function(){var g=this,m=this.image;m.onload=null,m.onerror=null,this.sizing=!0;var P=S.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(S.navigator.userAgent),w=n(function(A,T){Se(g.imageData,{naturalWidth:A,naturalHeight:T,aspectRatio:A/T}),g.sizing=!1,g.sized=!0,g.build()},"done");if(m.naturalWidth&&!P){w(m.naturalWidth,m.naturalHeight);return}var _=document.createElement("img"),O=document.body||document.documentElement;this.sizingImage=_,_.onload=function(){w(_.width,_.height),P||O.removeChild(_)},_.src=m.src,P||(_.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",O.appendChild(_))},"start")},{key:"stop",value:n(function(){var g=this.image;g.onload=null,g.onerror=null,g.parentNode.removeChild(g),this.image=null},"stop")},{key:"build",value:n(function(){if(!(!this.sized||this.ready)){var g=this.element,m=this.options,P=this.image,w=g.parentNode,_=document.createElement("div");_.innerHTML=Pl;var O=_.querySelector(".".concat(F,"-container")),D=O.querySelector(".".concat(F,"-canvas")),A=O.querySelector(".".concat(F,"-drag-box")),T=O.querySelector(".".concat(F,"-crop-box")),C=T.querySelector(".".concat(F,"-face"));this.container=w,this.cropper=O,this.canvas=D,this.dragBox=A,this.cropBox=T,this.viewBox=O.querySelector(".".concat(F,"-view-box")),this.face=C,D.appendChild(P),je(g,xe),w.insertBefore(O,g.nextSibling),this.isImg||bi(P,ui),this.initPreview(),this.bind(),m.initialAspectRatio=Math.max(0,m.initialAspectRatio)||NaN,m.aspectRatio=Math.max(0,m.aspectRatio)||NaN,m.viewMode=Math.max(0,Math.min(3,Math.round(m.viewMode)))||0,je(T,xe),m.guides||je(T.getElementsByClassName("".concat(F,"-dashed")),xe),m.center||je(T.getElementsByClassName("".concat(F,"-center")),xe),m.background&&je(O,"".concat(F,"-bg")),m.highlight||je(C,V),m.cropBoxMovable&&(je(C,I),un(C,L,U)),m.cropBoxResizable||(je(T.getElementsByClassName("".concat(F,"-line")),xe),je(T.getElementsByClassName("".concat(F,"-point")),xe)),this.render(),this.ready=!0,this.setDragMode(m.dragMode),m.autoCrop&&this.crop(),this.setData(m.data),St(m.ready)&&hi(g,Hr,m.ready,{once:!0}),xo(g,Hr)}},"build")},{key:"unbuild",value:n(function(){this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),this.cropper.parentNode.removeChild(this.cropper),bi(this.element,xe))},"unbuild")},{key:"uncreate",value:n(function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()},"uncreate")}],[{key:"noConflict",value:n(function(){return window.Cropper=Nb,v},"noConflict")},{key:"setDefaults",value:n(function(g){Se(nn,Vr(g)&&g)},"setDefaults")}]),v}();return Se(Qp.prototype,Ab,Rb,Ub,kb,Db,Ib),Qp})});var sv=he((uD,Bu)=>{"use strict";Bu.exports=cc;Bu.exports.isMobile=cc;Bu.exports.default=cc;var wP=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,SP=/CrOS/,PP=/android|ipad|playbook|silk/i;function cc(i){i||(i={});let e=i.ua;if(!e&&typeof navigator<"u"&&(e=navigator.userAgent),e&&e.headers&&typeof e.headers["user-agent"]=="string"&&(e=e.headers["user-agent"]),typeof e!="string")return!1;let t=wP.test(e)&&!SP.test(e)||!!i.tablet&&PP.test(e);return!t&&i.tablet&&i.featureDetect&&navigator&&navigator.maxTouchPoints>1&&e.indexOf("Macintosh")!==-1&&e.indexOf("Safari")!==-1&&(t=!0),t}n(cc,"isMobile")});var Kv=he((c9,Gv)=>{"use strict";Gv.exports=n(function(e,t){if(t=t.split(":")[0],e=+e,!e)return!1;switch(t){case"http":case"ws":return e!==80;case"https":case"wss":return e!==443;case"ftp":return e!==21;case"gopher":return e!==70;case"file":return!1}return e!==0},"required")});var Qv=he(Vc=>{"use strict";var U_=Object.prototype.hasOwnProperty,k_;function Xv(i){try{return decodeURIComponent(i.replace(/\+/g," "))}catch{return null}}n(Xv,"decode");function Yv(i){try{return encodeURIComponent(i)}catch{return null}}n(Yv,"encode");function D_(i){for(var e=/([^=?#&]+)=?([^&]*)/g,t={},r;r=e.exec(i);){var s=Xv(r[1]),o=Xv(r[2]);s===null||o===null||s in t||(t[s]=o)}return t}n(D_,"querystring");function I_(i,e){e=e||"";var t=[],r,s;typeof e!="string"&&(e="?");for(s in i)if(U_.call(i,s)){if(r=i[s],!r&&(r===null||r===k_||isNaN(r))&&(r=""),s=Yv(s),r=Yv(r),s===null||r===null)continue;t.push(s+"="+r)}return t.length?e+t.join("&"):""}n(I_,"querystringify");Vc.stringify=I_;Vc.parse=D_});var o0=he((g9,s0)=>{"use strict";var Zv=Kv(),Yu=Qv(),N_=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,e0=/[\n\r\t]/g,M_=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,t0=/:\d+$/,L_=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,B_=/^[a-zA-Z]:/;function Gc(i){return(i||"").toString().replace(N_,"")}n(Gc,"trimLeft");var Wc=[["#","hash"],["?","query"],n(function(e,t){return rr(t.protocol)?e.replace(/\\/g,"/"):e},"sanitize"),["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],Jv={hash:1,query:1};function i0(i){var e;typeof window<"u"?e=window:typeof global<"u"?e=global:typeof self<"u"?e=self:e={};var t=e.location||{};i=i||t;var r={},s=typeof i,o;if(i.protocol==="blob:")r=new sr(unescape(i.pathname),{});else if(s==="string"){r=new sr(i,{});for(o in Jv)delete r[o]}else if(s==="object"){for(o in i)o in Jv||(r[o]=i[o]);r.slashes===void 0&&(r.slashes=M_.test(i.href))}return r}n(i0,"lolcation");function rr(i){return i==="file:"||i==="ftp:"||i==="http:"||i==="https:"||i==="ws:"||i==="wss:"}n(rr,"isSpecial");function r0(i,e){i=Gc(i),i=i.replace(e0,""),e=e||{};var t=L_.exec(i),r=t[1]?t[1].toLowerCase():"",s=!!t[2],o=!!t[3],a=0,l;return s?o?(l=t[2]+t[3]+t[4],a=t[2].length+t[3].length):(l=t[2]+t[4],a=t[2].length):o?(l=t[3]+t[4],a=t[3].length):l=t[4],r==="file:"?a>=2&&(l=l.slice(2)):rr(r)?l=t[4]:r?s&&(l=l.slice(2)):a>=2&&rr(e.protocol)&&(l=t[4]),{protocol:r,slashes:s||rr(r),slashesCount:a,rest:l}}n(r0,"extractProtocol");function z_(i,e){if(i==="")return e;for(var t=(e||"/").split("/").slice(0,-1).concat(i.split("/")),r=t.length,s=t[r-1],o=!1,a=0;r--;)t[r]==="."?t.splice(r,1):t[r]===".."?(t.splice(r,1),a++):a&&(r===0&&(o=!0),t.splice(r,1),a--);return o&&t.unshift(""),(s==="."||s==="..")&&t.push(""),t.join("/")}n(z_,"resolve");function sr(i,e,t){if(i=Gc(i),i=i.replace(e0,""),!(this instanceof sr))return new sr(i,e,t);var r,s,o,a,l,h,p=Wc.slice(),d=typeof e,f=this,y=0;for(d!=="object"&&d!=="string"&&(t=e,e=null),t&&typeof t!="function"&&(t=Yu.parse),e=i0(e),s=r0(i||"",e),r=!s.protocol&&!s.slashes,f.slashes=s.slashes||r&&e.slashes,f.protocol=s.protocol||e.protocol||"",i=s.rest,(s.protocol==="file:"&&(s.slashesCount!==2||B_.test(i))||!s.slashes&&(s.protocol||s.slashesCount<2||!rr(f.protocol)))&&(p[3]=[/(.*)/,"pathname"]);y{typeof dp<"u"&&(dp.exports=ni);function ni(i){if(i)return j5(i)}n(ni,"Emitter");function j5(i){for(var e in ni.prototype)i[e]=ni.prototype[e];return i}n(j5,"mixin");ni.prototype.on=ni.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};ni.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return n(t,"on"),t.fn=e,this.on(i,t),this};ni.prototype.off=ni.prototype.removeListener=ni.prototype.removeAllListeners=ni.prototype.removeEventListener=function(i,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+i];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var r,s=0;s{(function(i,e){typeof jp=="object"&&typeof Hp<"u"?Hp.exports=e():typeof define=="function"&&define.amd?define(e):(i=typeof globalThis<"u"?globalThis:i||self,i.Compressor=e())})(jp,function(){"use strict";function i(V,R){var I=Object.keys(V);if(Object.getOwnPropertySymbols){var L=Object.getOwnPropertySymbols(V);R&&(L=L.filter(function(Q){return Object.getOwnPropertyDescriptor(V,Q).enumerable})),I.push.apply(I,L)}return I}n(i,"ownKeys");function e(V){for(var R=1;R"u"||function(R){var I=R.HTMLCanvasElement&&R.HTMLCanvasElement.prototype,L=R.Blob&&function(){try{return!!new Blob}catch{return!1}}(),Q=L&&R.Uint8Array&&function(){try{return new Blob([new Uint8Array(100)]).size===100}catch{return!1}}(),X=R.BlobBuilder||R.WebKitBlobBuilder||R.MozBlobBuilder||R.MSBlobBuilder,ye=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,pe=(L||X)&&R.atob&&R.ArrayBuffer&&R.Uint8Array&&function(ne){var re,Fe,Ee,Ft,Et,te,Ot,Ge,lr;if(re=ne.match(ye),!re)throw new Error("invalid data URI");for(Fe=re[2]?re[1]:"text/plain"+(re[3]||";charset=US-ASCII"),Ee=!!re[4],Ft=ne.slice(re[0].length),Ee?Et=atob(Ft):Et=decodeURIComponent(Ft),te=new ArrayBuffer(Et.length),Ot=new Uint8Array(te),Ge=0;Ge"u"?!1:R instanceof Blob||Object.prototype.toString.call(R)==="[object Blob]"},"isBlob"),d={strict:!0,checkOrientation:!0,maxWidth:1/0,maxHeight:1/0,minWidth:0,minHeight:0,width:void 0,height:void 0,resize:"none",quality:.8,mimeType:"auto",convertTypes:["image/png"],convertSize:5e6,beforeDraw:null,drew:null,success:null,error:null},f=typeof window<"u"&&typeof window.document<"u",y=f?window:{},b=n(function(R){return R>0&&R<1/0},"isPositiveNumber"),S=Array.prototype.slice;function E(V){return Array.from?Array.from(V):S.call(V)}n(E,"toArray");var x=/^image\/.+$/;function F(V){return x.test(V)}n(F,"isImageType");function U(V){var R=F(V)?V.substr(6):"";return R==="jpeg"&&(R="jpg"),".".concat(R)}n(U,"imageTypeToExtension");var j=String.fromCharCode;function G(V,R,I){var L="",Q;for(I+=R,Q=R;Q0;)I.push(j.apply(null,E(Q.subarray(0,L)))),Q=Q.subarray(L);return"data:".concat(R,";base64,").concat(J(I.join("")))}n(B,"arrayBufferToDataURL");function z(V){var R=new DataView(V),I;try{var L,Q,X;if(R.getUint8(0)===255&&R.getUint8(1)===216)for(var ye=R.byteLength,pe=2;pe+1=8&&(X=re+Ee)}}}if(X){var Ft=R.getUint16(X,L),Et,te;for(te=0;te1&&arguments[1]!==void 0?arguments[1]:1e11;return oe.test(V)?Math.round(V*R)/R:V}n(Be,"normalizeDecimalNumber");function Je(V){var R=V.aspectRatio,I=V.height,L=V.width,Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"none",X=b(L),ye=b(I);if(X&&ye){var pe=I*R;(Q==="contain"||Q==="none")&&pe>L||Q==="cover"&&pe1||!_e?(Ee.url=B(Fe,X),Ft>1&&a(Ee,K(Ft))):Ee.url=_e.createObjectURL(L)}else Ee.url=Fe;I.load(Ee)},ye.onabort=function(){I.fail(new Error("Aborted to read the image with FileReader."))},ye.onerror=function(){I.fail(new Error("Failed to read the image with FileReader."))},ye.onloadend=function(){I.reader=null},pe?ye.readAsArrayBuffer(L):ye.readAsDataURL(L)}},"init")},{key:"load",value:n(function(I){var L=this,Q=this.file,X=this.image;X.onload=function(){L.draw(e(e({},I),{},{naturalWidth:X.naturalWidth,naturalHeight:X.naturalHeight}))},X.onabort=function(){L.fail(new Error("Aborted to load the image."))},X.onerror=function(){L.fail(new Error("Failed to load the image."))},y.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(y.navigator.userAgent)&&(X.crossOrigin="anonymous"),X.alt=Q.name,X.src=I.url},"load")},{key:"draw",value:n(function(I){var L=this,Q=I.naturalWidth,X=I.naturalHeight,ye=I.rotate,pe=ye===void 0?0:ye,ne=I.scaleX,re=ne===void 0?1:ne,Fe=I.scaleY,Ee=Fe===void 0?1:Fe,Ft=this.file,Et=this.image,te=this.options,Ot=document.createElement("canvas"),Ge=Ot.getContext("2d"),lr=Math.abs(pe)%180===90,So=(te.resize==="contain"||te.resize==="cover")&&b(te.width)&&b(te.height),Hr=Math.max(te.maxWidth,0)||1/0,$r=Math.max(te.maxHeight,0)||1/0,qr=Math.max(te.minWidth,0)||0,ur=Math.max(te.minHeight,0)||0,hr=Q/X,nt=te.width,at=te.height;if(lr){var wl=[$r,Hr];Hr=wl[0],$r=wl[1];var Sl=[ur,qr];qr=Sl[0],ur=Sl[1];var nn=[at,nt];nt=nn[0],at=nn[1]}So&&(hr=nt/at);var Pl=Je({aspectRatio:hr,width:Hr,height:$r},"contain");Hr=Pl.width,$r=Pl.height;var _l=Je({aspectRatio:hr,width:qr,height:ur},"cover");if(qr=_l.width,ur=_l.height,So){var ie=Je({aspectRatio:hr,width:nt,height:at},te.resize);nt=ie.width,at=ie.height}else{var an=Je({aspectRatio:hr,width:nt,height:at}),Po=an.width;nt=Po===void 0?Q:Po;var Ni=an.height;at=Ni===void 0?X:Ni}nt=Math.floor(Be(Math.min(Math.max(nt,qr),Hr))),at=Math.floor(Be(Math.min(Math.max(at,ur),$r)));var hh=-nt/2,Vr=-at/2,St=nt,dh=at,_o=[];if(So){var Re=0,Se=0,ln=Q,Mi=X,xl=Je({aspectRatio:hr,width:Q,height:X},{contain:"cover",cover:"contain"}[te.resize]);ln=xl.width,Mi=xl.height,Re=(Q-ln)/2,Se=(X-Mi)/2,_o.push(Re,Se,ln,Mi)}if(_o.push(hh,Vr,St,dh),lr){var vi=[at,nt];nt=vi[0],at=vi[1]}Ot.width=nt,Ot.height=at,F(te.mimeType)||(te.mimeType=Ft.type);var Fl="transparent";if(Ft.size>te.convertSize&&te.convertTypes.indexOf(te.mimeType)>=0&&(te.mimeType="image/jpeg"),te.mimeType==="image/jpeg"&&(Fl="#fff"),Ge.fillStyle=Fl,Ge.fillRect(0,0,nt,at),te.beforeDraw&&te.beforeDraw.call(this,Ge,Ot),!this.aborted&&(Ge.save(),Ge.translate(nt/2,at/2),Ge.rotate(pe*Math.PI/180),Ge.scale(re,Ee),Ge.drawImage.apply(Ge,[Et].concat(_o)),Ge.restore(),te.drew&&te.drew.call(this,Ge,Ot),!this.aborted)){var je=n(function(Wr){L.aborted||L.done({naturalWidth:Q,naturalHeight:X,result:Wr})},"done");Ot.toBlob?Ot.toBlob(je,te.mimeType,te.quality):je(h(Ot.toDataURL(te.mimeType,te.quality)))}},"draw")},{key:"done",value:n(function(I){var L=I.naturalWidth,Q=I.naturalHeight,X=I.result,ye=this.file,pe=this.image,ne=this.options;if(_e&&!ne.checkOrientation&&_e.revokeObjectURL(pe.src),X)if(ne.strict&&X.size>ye.size&&ne.mimeType===ye.type&&!(ne.width>L||ne.height>Q||ne.minWidth>L||ne.minHeight>Q||ne.maxWidthns,AwsS3:()=>no,AwsS3Multipart:()=>Ri,BasePlugin:()=>ve,Box:()=>Xi,Compressor:()=>on,Core:()=>qx,Dashboard:()=>is,DefaultStore:()=>kl,DragDrop:()=>Gi,DropTarget:()=>Ns,Dropbox:()=>Yi,Facebook:()=>Qi,FileInput:()=>rs,Form:()=>go,GoldenRetriever:()=>bo,GoogleDrive:()=>Ji,ImageEditor:()=>ss,Informer:()=>qi,Instagram:()=>Zi,OneDrive:()=>er,ProgressBar:()=>os,ReduxDevTools:()=>wo,ReduxStore:()=>fg,RemoteSources:()=>zs,ScreenCapture:()=>as,StatusBar:()=>$i,ThumbnailGenerator:()=>Cr,Transloadit:()=>yi,Tus:()=>or,UIPlugin:()=>Z,Unsplash:()=>tr,Uppy:()=>Ah,Url:()=>Ti,Webcam:()=>ls,XHRUpload:()=>mo,Zoom:()=>ir,debugLogger:()=>mn,locales:()=>Wx,server:()=>Bh,views:()=>Vx});function Ct(i,e){return Object.prototype.hasOwnProperty.call(i,e)}n(Ct,"has");function rf(i,e){if(!Object.prototype.hasOwnProperty.call(i,e))throw new TypeError("attempted to use private field on non-instance");return i}n(rf,"_classPrivateFieldLooseBase");var Vb=0;function Wb(i){return"__private_"+Vb+++"_"+i}n(Wb,"_classPrivateFieldLooseKey");function Gb(i,e,t){let r=[];return i.forEach(s=>typeof s!="string"?r.push(s):e[Symbol.split](s).forEach((o,a,l)=>{o!==""&&r.push(o),a{let e="",t=i;for(;t--;)e+=Xb[Math.random()*64|0];return e},"nanoid");var em=de(Rl(),1);function Ul(i,e){if(!Object.prototype.hasOwnProperty.call(i,e))throw new TypeError("attempted to use private field on non-instance");return i}n(Ul,"_classPrivateFieldLooseBase");var H1=0;function Lf(i){return"__private_"+H1+++"_"+i}n(Lf,"_classPrivateFieldLooseKey");var $1={version:"3.1.0"},gs=Lf("callbacks"),Ph=Lf("publish"),pn=class{constructor(){Object.defineProperty(this,Ph,{value:q1}),this.state={},Object.defineProperty(this,gs,{writable:!0,value:new Set})}getState(){return this.state}setState(e){let t={...this.state},r={...this.state,...e};this.state=r,Ul(this,Ph)[Ph](t,r,e)}subscribe(e){return Ul(this,gs)[gs].add(e),()=>{Ul(this,gs)[gs].delete(e)}}};n(pn,"DefaultStore");function q1(){for(var i=arguments.length,e=new Array(i),t=0;t{r(...e)})}n(q1,"_publish2");pn.VERSION=$1.version;var kl=pn;function Bi(i){let e=i.lastIndexOf(".");return e===-1||e===i.length-1?{name:i,extension:void 0}:{name:i.slice(0,e),extension:i.slice(e+1)}}n(Bi,"getFileNameAndExtension");var fn={__proto__:null,md:"text/markdown",markdown:"text/markdown",mp4:"video/mp4",mp3:"audio/mp3",svg:"image/svg+xml",jpg:"image/jpeg",png:"image/png",webp:"image/webp",gif:"image/gif",heic:"image/heic",heif:"image/heif",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",tsv:"text/tab-separated-values",tab:"text/tab-separated-values",avi:"video/x-msvideo",mks:"video/x-matroska",mkv:"video/x-matroska",mov:"video/quicktime",dicom:"application/dicom",doc:"application/msword",docm:"application/vnd.ms-word.document.macroenabled.12",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",dot:"application/msword",dotm:"application/vnd.ms-word.template.macroenabled.12",dotx:"application/vnd.openxmlformats-officedocument.wordprocessingml.template",xla:"application/vnd.ms-excel",xlam:"application/vnd.ms-excel.addin.macroenabled.12",xlc:"application/vnd.ms-excel",xlf:"application/x-xliff+xml",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlsb:"application/vnd.ms-excel.sheet.binary.macroenabled.12",xlsm:"application/vnd.ms-excel.sheet.macroenabled.12",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xlt:"application/vnd.ms-excel",xltm:"application/vnd.ms-excel.template.macroenabled.12",xltx:"application/vnd.openxmlformats-officedocument.spreadsheetml.template",xlw:"application/vnd.ms-excel",txt:"text/plain",text:"text/plain",conf:"text/plain",log:"text/plain",pdf:"application/pdf",zip:"application/zip","7z":"application/x-7z-compressed",rar:"application/x-rar-compressed",tar:"application/x-tar",gz:"application/gzip",dmg:"application/x-apple-diskimage"};function ys(i){var e;if(i.type)return i.type;let t=i.name?(e=Bi(i.name).extension)==null?void 0:e.toLowerCase():null;return t&&t in fn?fn[t]:"application/octet-stream"}n(ys,"getFileType");function V1(i){return i.charCodeAt(0).toString(32)}n(V1,"encodeCharacter");function Bf(i){let e="";return i.replace(/[^A-Z0-9]/gi,t=>(e+=`-${V1(t)}`,"/"))+e}n(Bf,"encodeFilename");function zf(i){let e="uppy";return typeof i.name=="string"&&(e+=`-${Bf(i.name.toLowerCase())}`),i.type!==void 0&&(e+=`-${i.type}`),i.meta&&typeof i.meta.relativePath=="string"&&(e+=`-${Bf(i.meta.relativePath.toLowerCase())}`),i.data.size!==void 0&&(e+=`-${i.data.size}`),i.data.lastModified!==void 0&&(e+=`-${i.data.lastModified}`),e}n(zf,"generateFileID");function W1(i){return!i.isRemote||!i.remote?!1:new Set(["box","dropbox","drive","facebook","unsplash"]).has(i.remote.provider)}n(W1,"hasFileStableId");function Dl(i){if(W1(i))return i.id;let e=ys(i);return zf({...i,type:e})}n(Dl,"getSafeFileId");function _h(i){if(i==null&&typeof navigator<"u"&&(i=navigator.userAgent),!i)return!0;let e=/Edge\/(\d+\.\d+)/.exec(i);if(!e)return!0;let t=e[1],[r,s]=t.split(".");return r=parseInt(r,10),s=parseInt(s,10),r<15||r===15&&s<15063||r>18||r===18&&s>=18218}n(_h,"supportsUploadProgress");function xh(i,e){return e.name?e.name:i.split("/")[0]==="image"?`${i.split("/")[0]}.${i.split("/")[1]}`:"noname"}n(xh,"getFileName");function Fh(i){return i<10?`0${i}`:i.toString()}n(Fh,"pad");function Fo(){let i=new Date,e=Fh(i.getHours()),t=Fh(i.getMinutes()),r=Fh(i.getSeconds());return`${e}:${t}:${r}`}n(Fo,"getTimeStamp");var jf={debug:()=>{},warn:()=>{},error:function(){for(var i=arguments.length,e=new Array(i),t=0;t{let r=e();if(r.restrictions.allowedFileTypes!=null&&!Array.isArray(r.restrictions.allowedFileTypes))throw new TypeError("`restrictions.allowedFileTypes` must be an array");return r}}validateAggregateRestrictions(e,t){let{maxTotalFileSize:r,maxNumberOfFiles:s}=this.getOpts().restrictions;if(s&&e.filter(a=>!a.isGhost).length+t.length>s)throw new Tt(`${this.i18n("youCanOnlyUploadX",{smart_count:s})}`);if(r){let o=e.reduce((a,l)=>a+l.size,0);for(let a of t)if(a.size!=null&&(o+=a.size,o>r))throw new Tt(this.i18n("exceedsSize",{size:(0,Nl.default)(r),file:a.name}))}}validateSingleFile(e){let{maxFileSize:t,minFileSize:r,allowedFileTypes:s}=this.getOpts().restrictions;if(s&&!s.some(a=>a.includes("/")?e.type?(0,Kf.default)(e.type.replace(/;.*?$/,""),a):!1:a[0]==="."&&e.extension?e.extension.toLowerCase()===a.slice(1).toLowerCase():!1)){let a=s.join(", ");throw new Tt(this.i18n("youCanOnlyUploadFileTypes",{types:a}),{file:e})}if(t&&e.size!=null&&e.size>t)throw new Tt(this.i18n("exceedsSize",{size:(0,Nl.default)(t),file:e.name}),{file:e});if(r&&e.size!=null&&e.size{this.validateSingleFile(r)}),this.validateAggregateRestrictions(e,t)}validateMinNumberOfFiles(e){let{minNumberOfFiles:t}=this.getOpts().restrictions;if(Object.keys(e).length({totalProgress:0,allowNewUpload:!0,error:null,recoveredState:null}),"getDefaultUploadState"),ht=Xe("plugins"),Gt=Xe("restricter"),yn=Xe("storeUnsubscribe"),pr=Xe("emitter"),vs=Xe("preProcessors"),bs=Xe("uploaders"),gr=Xe("postProcessors"),Kt=Xe("informAndEmit"),Pn=Xe("checkRequiredMetaFieldsOnFile"),Eh=Xe("checkRequiredMetaFields"),vn=Xe("assertNewUploadAllowed"),Th=Xe("transformFile"),bn=Xe("startIfAutoProceed"),wn=Xe("checkAndUpdateFileState"),Oh=Xe("addListeners"),Si=Xe("updateOnlineStatus"),fr=Xe("createUpload"),Ch=Xe("getUpload"),ws=Xe("removeUpload"),mr=Xe("runUpload");Qf=Symbol.for("uppy test: getPlugins");Jf=Symbol.for("uppy test: createUpload");var Sn=class{constructor(e){Object.defineProperty(this,mr,{value:lw}),Object.defineProperty(this,ws,{value:aw}),Object.defineProperty(this,Ch,{value:nw}),Object.defineProperty(this,fr,{value:ow}),Object.defineProperty(this,Oh,{value:sw}),Object.defineProperty(this,wn,{value:rw}),Object.defineProperty(this,bn,{value:iw}),Object.defineProperty(this,Th,{value:tw}),Object.defineProperty(this,vn,{value:ew}),Object.defineProperty(this,Eh,{value:Z1}),Object.defineProperty(this,Pn,{value:J1}),Object.defineProperty(this,Kt,{value:Q1}),Object.defineProperty(this,ht,{writable:!0,value:Object.create(null)}),Object.defineProperty(this,Gt,{writable:!0,value:void 0}),Object.defineProperty(this,yn,{writable:!0,value:void 0}),Object.defineProperty(this,pr,{writable:!0,value:(0,Zf.default)()}),Object.defineProperty(this,vs,{writable:!0,value:new Set}),Object.defineProperty(this,bs,{writable:!0,value:new Set}),Object.defineProperty(this,gr,{writable:!0,value:new Set}),this.calculateProgress=(0,em.default)((r,s)=>{let o=this.getFile(r?.id);if(r==null||!o){this.log(`Not setting progress for a file that has been removed: ${r?.id}`);return}if(o.progress.percentage===100){this.log(`Not setting progress for a file that has been already uploaded: ${r.id}`);return}let a=Number.isFinite(s.bytesTotal)&&s.bytesTotal>0;this.setFileState(r.id,{progress:{...o.progress,bytesUploaded:s.bytesUploaded,bytesTotal:s.bytesTotal,percentage:a?Math.round(s.bytesUploaded/s.bytesTotal*100):0}}),this.calculateTotalProgress()},500,{leading:!0,trailing:!0}),Object.defineProperty(this,Si,{writable:!0,value:this.updateOnlineStatus.bind(this)}),this.defaultLocale=Yf;let t={id:"uppy",autoProceed:!1,allowMultipleUploadBatches:!0,debug:!1,restrictions:Xf,meta:{},onBeforeFileAdded:(r,s)=>!Object.hasOwn(s,r.id),onBeforeUpload:r=>r,store:new kl,logger:jf,infoTimeout:5e3};this.opts={...t,...e,restrictions:{...t.restrictions,...e&&e.restrictions}},e&&e.logger&&e.debug?this.log("You are using a custom `logger`, but also set `debug: true`, which uses built-in logger to output logs to console. Ignoring `debug: true` and using your custom `logger`.","warning"):e&&e.debug&&(this.opts.logger=mn),this.log(`Using Core v${this.constructor.VERSION}`),this.i18nInit(),this.store=this.opts.store,this.setState({...Ml(),plugins:{},files:{},currentUploads:{},capabilities:{uploadProgress:_h(),individualCancellation:!0,resumableUploads:!1},meta:{...this.opts.meta},info:[]}),q(this,Gt)[Gt]=new gn(()=>this.opts,this.i18n),q(this,yn)[yn]=this.store.subscribe((r,s,o)=>{this.emit("state-update",r,s,o),this.updateAll(s)}),this.opts.debug&&typeof window<"u"&&(window[this.opts.id]=this),q(this,Oh)[Oh]()}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s{t.update(e)})}setState(e){this.store.setState(e)}getState(){return this.store.getState()}patchFilesState(e){let t=this.getState().files;this.setState({files:{...t,...Object.fromEntries(Object.entries(e).map(r=>{let[s,o]=r;return[s,{...t[s],...o}]}))}})}setFileState(e,t){if(!this.getState().files[e])throw new Error(`Can\u2019t set state for ${e} (the file could have been removed)`);this.patchFilesState({[e]:t})}i18nInit(){let e=new Xr([this.defaultLocale,this.opts.locale]);this.i18n=e.translate.bind(e),this.i18nArray=e.translateArray.bind(e),this.locale=e.locale}setOptions(e){this.opts={...this.opts,...e,restrictions:{...this.opts.restrictions,...e&&e.restrictions}},e.meta&&this.setMeta(e.meta),this.i18nInit(),e.locale&&this.iteratePlugins(t=>{t.setOptions(e)}),this.setState()}resetProgress(){let e={percentage:0,bytesUploaded:0,uploadComplete:!1,uploadStarted:null},t={...this.getState().files},r={};Object.keys(t).forEach(s=>{r[s]={...t[s],progress:{...t[s].progress,...e}}}),this.setState({files:r,...Ml()}),this.emit("reset-progress")}clearUploadedFiles(){this.setState({...Ml(),files:{}})}addPreProcessor(e){q(this,vs)[vs].add(e)}removePreProcessor(e){return q(this,vs)[vs].delete(e)}addPostProcessor(e){q(this,gr)[gr].add(e)}removePostProcessor(e){return q(this,gr)[gr].delete(e)}addUploader(e){q(this,bs)[bs].add(e)}removeUploader(e){return q(this,bs)[bs].delete(e)}setMeta(e){let t={...this.getState().meta,...e},r={...this.getState().files};Object.keys(r).forEach(s=>{r[s]={...r[s],meta:{...r[s].meta,...e}}}),this.log("Adding metadata:"),this.log(e),this.setState({meta:t,files:r})}setFileMeta(e,t){let r={...this.getState().files};if(!r[e]){this.log("Was trying to set metadata for a file that has been removed: ",e);return}let s={...r[e].meta,...t};r[e]={...r[e],meta:s},this.setState({files:r})}getFile(e){return this.getState().files[e]}getFiles(){let{files:e}=this.getState();return Object.values(e)}getFilesByIds(e){return e.map(t=>this.getFile(t))}getObjectOfFilesPerState(){let{files:e,totalProgress:t,error:r}=this.getState(),s=Object.values(e),o=s.filter(S=>{let{progress:E}=S;return!E.uploadComplete&&E.uploadStarted}),a=s.filter(S=>!S.progress.uploadStarted),l=s.filter(S=>S.progress.uploadStarted||S.progress.preprocess||S.progress.postprocess),h=s.filter(S=>S.progress.uploadStarted),p=s.filter(S=>S.isPaused),d=s.filter(S=>S.progress.uploadComplete),f=s.filter(S=>S.error),y=o.filter(S=>!S.isPaused),b=s.filter(S=>S.progress.preprocess||S.progress.postprocess);return{newFiles:a,startedFiles:l,uploadStartedFiles:h,pausedFiles:p,completeFiles:d,erroredFiles:f,inProgressFiles:o,inProgressNotPausedFiles:y,processingFiles:b,isUploadStarted:h.length>0,isAllComplete:t===100&&d.length===s.length&&b.length===0,isAllErrored:!!r&&f.length===s.length,isAllPaused:o.length!==0&&p.length===o.length,isUploadInProgress:o.length>0,isSomeGhost:s.some(S=>S.isGhost)}}validateRestrictions(e,t){t===void 0&&(t=this.getFiles());try{q(this,Gt)[Gt].validate(t,[e])}catch(r){return r}return null}checkIfFileAlreadyExists(e){let{files:t}=this.getState();return!!(t[e]&&!t[e].isGhost)}addFile(e){q(this,vn)[vn](e);let{nextFilesState:t,validFilesToAdd:r,errors:s}=q(this,wn)[wn]([e]),o=s.filter(l=>l.isRestriction);if(q(this,Kt)[Kt](o),s.length>0)throw s[0];this.setState({files:t});let[a]=r;return this.emit("file-added",a),this.emit("files-added",r),this.log(`Added file: ${a.name}, ${a.id}, mime type: ${a.type}`),q(this,bn)[bn](),a.id}addFiles(e){q(this,vn)[vn]();let{nextFilesState:t,validFilesToAdd:r,errors:s}=q(this,wn)[wn](e),o=s.filter(l=>l.isRestriction);q(this,Kt)[Kt](o);let a=s.filter(l=>!l.isRestriction);if(a.length>0){let l=`Multiple errors occurred while adding files: +`;if(a.forEach(h=>{l+=` + * ${h.message}`}),this.info({message:this.i18n("addBulkFilesFailed",{smart_count:a.length}),details:l},"error",this.opts.infoTimeout),typeof AggregateError=="function")throw new AggregateError(a,l);{let h=new Error(l);throw h.errors=a,h}}this.setState({files:t}),r.forEach(l=>{this.emit("file-added",l)}),this.emit("files-added",r),r.length>5?this.log(`Added batch of ${r.length} files`):Object.values(r).forEach(l=>{this.log(`Added file: ${l.name} + id: ${l.id} + type: ${l.type}`)}),r.length>0&&q(this,bn)[bn]()}removeFiles(e,t){let{files:r,currentUploads:s}=this.getState(),o={...r},a={...s},l=Object.create(null);e.forEach(f=>{r[f]&&(l[f]=r[f],delete o[f])});function h(f){return l[f]===void 0}n(h,"fileIsNotRemoved"),Object.keys(a).forEach(f=>{let y=s[f].fileIDs.filter(h);if(y.length===0){delete a[f];return}let{capabilities:b}=this.getState();if(y.length!==s[f].fileIDs.length&&!b.individualCancellation)throw new Error("individualCancellation is disabled");a[f]={...s[f],fileIDs:y}});let p={currentUploads:a,files:o};Object.keys(o).length===0&&(p.allowNewUpload=!0,p.error=null,p.recoveredState=null),this.setState(p),this.calculateTotalProgress();let d=Object.keys(l);d.forEach(f=>{this.emit("file-removed",l[f],t)}),d.length>5?this.log(`Removed ${d.length} files`):this.log(`Removed files: ${d.join(", ")}`)}removeFile(e,t){t===void 0&&(t=null),this.removeFiles([e],t)}pauseResume(e){if(!this.getState().capabilities.resumableUploads||this.getFile(e).uploadComplete)return;let r=!(this.getFile(e).isPaused||!1);return this.setFileState(e,{isPaused:r}),this.emit("upload-pause",e,r),r}pauseAll(){let e={...this.getState().files};Object.keys(e).filter(r=>!e[r].progress.uploadComplete&&e[r].progress.uploadStarted).forEach(r=>{let s={...e[r],isPaused:!0};e[r]=s}),this.setState({files:e}),this.emit("pause-all")}resumeAll(){let e={...this.getState().files};Object.keys(e).filter(r=>!e[r].progress.uploadComplete&&e[r].progress.uploadStarted).forEach(r=>{let s={...e[r],isPaused:!1,error:null};e[r]=s}),this.setState({files:e}),this.emit("resume-all")}retryAll(){let e={...this.getState().files},t=Object.keys(e).filter(s=>e[s].error);if(t.forEach(s=>{let o={...e[s],isPaused:!1,error:null};e[s]=o}),this.setState({files:e,error:null}),this.emit("retry-all",t),t.length===0)return Promise.resolve({successful:[],failed:[]});let r=q(this,fr)[fr](t,{forceAllowNewUpload:!0});return q(this,mr)[mr](r)}cancelAll(e){let{reason:t="user"}=e===void 0?{}:e;if(this.emit("cancel-all",{reason:t}),t==="user"){let{files:r}=this.getState(),s=Object.keys(r);s.length&&this.removeFiles(s,"cancel-all"),this.setState(Ml())}}retryUpload(e){this.setFileState(e,{error:null,isPaused:!1}),this.emit("upload-retry",e);let t=q(this,fr)[fr]([e],{forceAllowNewUpload:!0});return q(this,mr)[mr](t)}logout(){this.iteratePlugins(e=>{e.provider&&e.provider.logout&&e.provider.logout()})}calculateTotalProgress(){let t=this.getFiles().filter(p=>p.progress.uploadStarted||p.progress.preprocess||p.progress.postprocess);if(t.length===0){this.emit("progress",0),this.setState({totalProgress:0});return}let r=t.filter(p=>p.progress.bytesTotal!=null),s=t.filter(p=>p.progress.bytesTotal==null);if(r.length===0){let p=t.length*100,d=s.reduce((y,b)=>y+b.progress.percentage,0),f=Math.round(d/p*100);this.setState({totalProgress:f});return}let o=r.reduce((p,d)=>p+d.progress.bytesTotal,0),a=o/r.length;o+=a*s.length;let l=0;r.forEach(p=>{l+=p.progress.bytesUploaded}),s.forEach(p=>{l+=a*(p.progress.percentage||0)/100});let h=o===0?0:Math.round(l/o*100);h>100&&(h=100),this.setState({totalProgress:h}),this.emit("progress",h)}updateOnlineStatus(){(typeof window.navigator.onLine<"u"?window.navigator.onLine:!0)?(this.emit("is-online"),this.wasOffline&&(this.emit("back-online"),this.info(this.i18n("connectedToInternet"),"success",3e3),this.wasOffline=!1)):(this.emit("is-offline"),this.info(this.i18n("noInternetConnection"),"error",0),this.wasOffline=!0)}getID(){return this.opts.id}use(e,t){if(typeof e!="function"){let a=`Expected a plugin class, but got ${e===null?"null":typeof e}. Please verify that the plugin was imported and spelled correctly.`;throw new TypeError(a)}let r=new e(this,t),s=r.id;if(!s)throw new Error("Your plugin must have an id");if(!r.type)throw new Error("Your plugin must have a type");let o=this.getPlugin(s);if(o){let a=`Already found a plugin named '${o.id}'. Tried to use: '${s}'. +Uppy plugins must have unique \`id\` options. See https://uppy.io/docs/plugins/#id.`;throw new Error(a)}return e.VERSION&&this.log(`Using ${s} v${e.VERSION}`),r.type in q(this,ht)[ht]?q(this,ht)[ht][r.type].push(r):q(this,ht)[ht][r.type]=[r],r.install(),this.emit("plugin-added",r),this}getPlugin(e){for(let t of Object.values(q(this,ht)[ht])){let r=t.find(s=>s.id===e);if(r!=null)return r}}[Qf](e){return q(this,ht)[ht][e]}iteratePlugins(e){Object.values(q(this,ht)[ht]).flat(1).forEach(e)}removePlugin(e){this.log(`Removing plugin ${e.id}`),this.emit("plugin-remove",e),e.uninstall&&e.uninstall();let t=q(this,ht)[ht][e.type],r=t.findIndex(a=>a.id===e.id);r!==-1&&t.splice(r,1);let o={plugins:{...this.getState().plugins,[e.id]:void 0}};this.setState(o)}close(e){let{reason:t}=e===void 0?{}:e;this.log(`Closing Uppy instance ${this.opts.id}: removing all files and uninstalling plugins`),this.cancelAll({reason:t}),q(this,yn)[yn](),this.iteratePlugins(r=>{this.removePlugin(r)}),typeof window<"u"&&window.removeEventListener&&(window.removeEventListener("online",q(this,Si)[Si]),window.removeEventListener("offline",q(this,Si)[Si]))}hideInfo(){let{info:e}=this.getState();this.setState({info:e.slice(1)}),this.emit("info-hidden")}info(e,t,r){t===void 0&&(t="info"),r===void 0&&(r=3e3);let s=typeof e=="object";this.setState({info:[...this.getState().info,{type:t,message:s?e.message:e,details:s?e.details:null}]}),setTimeout(()=>this.hideInfo(),r),this.emit("info-visible")}log(e,t){let{logger:r}=this.opts;switch(t){case"error":r.error(e);break;case"warning":r.warn(e);break;default:r.debug(e);break}}restore(e){return this.log(`Core: attempting to restore upload "${e}"`),this.getState().currentUploads[e]?q(this,mr)[mr](e):(q(this,ws)[ws](e),Promise.reject(new Error("Nonexistent upload")))}[Jf](){return q(this,fr)[fr](...arguments)}addResultData(e,t){if(!q(this,Ch)[Ch](e)){this.log(`Not setting result for an upload that has been removed: ${e}`);return}let{currentUploads:r}=this.getState(),s={...r[e],result:{...r[e].result,...t}};this.setState({currentUploads:{...r,[e]:s}})}upload(){var e;(e=q(this,ht)[ht].uploader)!=null&&e.length||this.log("No uploader type plugins are used","warning");let{files:t}=this.getState(),r=this.opts.onBeforeUpload(t);return r===!1?Promise.reject(new Error("Not starting the upload because onBeforeUpload returned false")):(r&&typeof r=="object"&&(t=r,this.setState({files:t})),Promise.resolve().then(()=>q(this,Gt)[Gt].validateMinNumberOfFiles(t)).catch(s=>{throw q(this,Kt)[Kt]([s]),s}).then(()=>{if(!q(this,Eh)[Eh](t))throw new Tt(this.i18n("missingRequiredMetaField"))}).catch(s=>{throw s}).then(()=>{let{currentUploads:s}=this.getState(),o=Object.values(s).flatMap(h=>h.fileIDs),a=[];Object.keys(t).forEach(h=>{let p=this.getFile(h);!p.progress.uploadStarted&&o.indexOf(h)===-1&&a.push(p.id)});let l=q(this,fr)[fr](a);return q(this,mr)[mr](l)}).catch(s=>{throw this.emit("error",s),this.log(s,"error"),s}))}};n(Sn,"Uppy");function Q1(i){for(let o of i){let{file:a,isRestriction:l}=o;l?this.emit("restriction-failed",a,o):this.emit("error",o),this.log(o,"warning")}let e=i.filter(o=>o.isUserFacing),t=4,r=e.slice(0,t),s=e.slice(t);r.forEach(o=>{let{message:a,details:l=""}=o;this.info({message:a,details:l},"error",this.opts.infoTimeout)}),s.length>0&&this.info({message:this.i18n("additionalRestrictionsFailed",{count:s.length})})}n(Q1,"_informAndEmit2");function J1(i){let{missingFields:e,error:t}=q(this,Gt)[Gt].getMissingRequiredMetaFields(i);return e.length>0?(this.setFileState(i.id,{missingRequiredMetaFields:e}),this.log(t.message),this.emit("restriction-failed",i,t),!1):!0}n(J1,"_checkRequiredMetaFieldsOnFile2");function Z1(i){let e=!0;for(let t of Object.values(i))q(this,Pn)[Pn](t)||(e=!1);return e}n(Z1,"_checkRequiredMetaFields2");function ew(i){let{allowNewUpload:e}=this.getState();if(e===!1){let t=new Tt(this.i18n("noMoreFilesAllowed"),{file:i});throw q(this,Kt)[Kt]([t]),t}}n(ew,"_assertNewUploadAllowed2");function tw(i){let e=i instanceof File?{name:i.name,type:i.type,size:i.size,data:i}:i,t=ys(e),r=xh(t,e),s=Bi(r).extension,o=!!e.isRemote,a=Dl(e),l=e.meta||{};l.name=r,l.type=t;let h=Number.isFinite(e.data.size)?e.data.size:null;return{source:e.source||"",id:a,name:r,extension:s||"",meta:{...this.getState().meta,...l},type:t,data:e.data,progress:{percentage:0,bytesUploaded:0,bytesTotal:h,uploadComplete:!1,uploadStarted:null},size:h,isRemote:o,remote:e.remote||"",preview:e.preview}}n(tw,"_transformFile2");function iw(){this.opts.autoProceed&&!this.scheduledAutoProceed&&(this.scheduledAutoProceed=setTimeout(()=>{this.scheduledAutoProceed=null,this.upload().catch(i=>{i.isRestriction||this.log(i.stack||i.message||i)})},4))}n(iw,"_startIfAutoProceed2");function rw(i){let{files:e}=this.getState(),t={...e},r=[],s=[];for(let a of i)try{var o;let l=q(this,Th)[Th](a);if((o=e[l.id])!=null&&o.isGhost){let{isGhost:p,...d}=e[l.id];l={...d,data:a.data},this.log(`Replaced the blob in the restored ghost file: ${l.name}, ${l.id}`)}let h=this.opts.onBeforeFileAdded(l,t);if(!h&&this.checkIfFileAlreadyExists(l.id))throw new Tt(this.i18n("noDuplicates",{fileName:l.name}),{file:a});if(h===!1)throw new Tt("Cannot add the file because onBeforeFileAdded returned false.",{isUserFacing:!1,file:a});typeof h=="object"&&h!==null&&(l=h),q(this,Gt)[Gt].validateSingleFile(l),t[l.id]=l,r.push(l)}catch(l){s.push(l)}try{q(this,Gt)[Gt].validateAggregateRestrictions(Object.values(e),r)}catch(a){return s.push(a),{nextFilesState:e,validFilesToAdd:[],errors:s}}return{nextFilesState:t,validFilesToAdd:r,errors:s}}n(rw,"_checkAndUpdateFileState2");function sw(){let i=n((r,s,o)=>{let a=r.message||"Unknown error";r.details&&(a+=` ${r.details}`),this.setState({error:a}),s!=null&&s.id in this.getState().files&&this.setFileState(s.id,{error:a,response:o})},"errorHandler");this.on("error",i),this.on("upload-error",(r,s,o)=>{if(i(s,r,o),typeof s=="object"&&s.message){this.log(s.message,"error");let a=new Error(this.i18n("failedToUpload",{file:r?.name}));a.isUserFacing=!0,a.details=s.message,s.details&&(a.details+=` ${s.details}`),q(this,Kt)[Kt]([a])}else q(this,Kt)[Kt]([s])});let e;this.on("upload-stalled",(r,s)=>{let{message:o}=r,a=s.map(l=>l.meta.name).join(", ");e||(this.info({message:o,details:a},"warning",this.opts.infoTimeout),e=setTimeout(()=>{e=null},this.opts.infoTimeout)),this.log(`${o} ${a}`.trim(),"warning")}),this.on("upload",()=>{this.setState({error:null})});let t=n(r=>{let s=r.filter(a=>{let l=a!=null&&this.getFile(a.id);return l||this.log(`Not setting progress for a file that has been removed: ${a?.id}`),l}),o=Object.fromEntries(s.map(a=>[a.id,{progress:{uploadStarted:Date.now(),uploadComplete:!1,percentage:0,bytesUploaded:0,bytesTotal:a.size}}]));this.patchFilesState(o)},"onUploadStarted");this.on("upload-start",r=>{r.forEach(s=>{this.emit("upload-started",s)}),t(r)}),this.on("upload-progress",this.calculateProgress),this.on("upload-success",(r,s)=>{if(r==null||!this.getFile(r.id)){this.log(`Not setting progress for a file that has been removed: ${r?.id}`);return}let o=this.getFile(r.id).progress;this.setFileState(r.id,{progress:{...o,postprocess:q(this,gr)[gr].size>0?{mode:"indeterminate"}:null,uploadComplete:!0,percentage:100,bytesUploaded:o.bytesTotal},response:s,uploadURL:s.uploadURL,isPaused:!1}),r.size==null&&this.setFileState(r.id,{size:s.bytesUploaded||o.bytesTotal}),this.calculateTotalProgress()}),this.on("preprocess-progress",(r,s)=>{if(r==null||!this.getFile(r.id)){this.log(`Not setting progress for a file that has been removed: ${r?.id}`);return}this.setFileState(r.id,{progress:{...this.getFile(r.id).progress,preprocess:s}})}),this.on("preprocess-complete",r=>{if(r==null||!this.getFile(r.id)){this.log(`Not setting progress for a file that has been removed: ${r?.id}`);return}let s={...this.getState().files};s[r.id]={...s[r.id],progress:{...s[r.id].progress}},delete s[r.id].progress.preprocess,this.setState({files:s})}),this.on("postprocess-progress",(r,s)=>{if(r==null||!this.getFile(r.id)){this.log(`Not setting progress for a file that has been removed: ${r?.id}`);return}this.setFileState(r.id,{progress:{...this.getState().files[r.id].progress,postprocess:s}})}),this.on("postprocess-complete",r=>{if(r==null||!this.getFile(r.id)){this.log(`Not setting progress for a file that has been removed: ${r?.id}`);return}let s={...this.getState().files};s[r.id]={...s[r.id],progress:{...s[r.id].progress}},delete s[r.id].progress.postprocess,this.setState({files:s})}),this.on("restored",()=>{this.calculateTotalProgress()}),this.on("dashboard:file-edit-complete",r=>{r&&q(this,Pn)[Pn](r)}),typeof window<"u"&&window.addEventListener&&(window.addEventListener("online",q(this,Si)[Si]),window.addEventListener("offline",q(this,Si)[Si]),setTimeout(q(this,Si)[Si],3e3))}n(sw,"_addListeners2");function ow(i,e){e===void 0&&(e={});let{forceAllowNewUpload:t=!1}=e,{allowNewUpload:r,currentUploads:s}=this.getState();if(!r&&!t)throw new Error("Cannot create a new upload: already uploading.");let o=Pt();return this.emit("upload",{id:o,fileIDs:i}),this.setState({allowNewUpload:this.opts.allowMultipleUploadBatches!==!1&&this.opts.allowMultipleUploads!==!1,currentUploads:{...s,[o]:{fileIDs:i,step:0,result:{}}}}),o}n(ow,"_createUpload2");function nw(i){let{currentUploads:e}=this.getState();return e[i]}n(nw,"_getUpload2");function aw(i){let e={...this.getState().currentUploads};delete e[i],this.setState({currentUploads:e})}n(aw,"_removeUpload2");async function lw(i){let e=n(()=>{let{currentUploads:o}=this.getState();return o[i]},"getCurrentUpload"),t=e(),r=[...q(this,vs)[vs],...q(this,bs)[bs],...q(this,gr)[gr]];try{for(let o=t.step||0;o{let p=this.getFile(h);p&&p.progress.postprocess&&this.emit("postprocess-complete",p)});let o=t.fileIDs.map(h=>this.getFile(h)),a=o.filter(h=>!h.error),l=o.filter(h=>h.error);await this.addResultData(i,{successful:a,failed:l,uploadID:i}),t=e()}let s;return t&&(s=t.result,this.emit("complete",s),q(this,ws)[ws](i)),s==null&&this.log(`Not setting result for an upload that has been removed: ${i}`),s}n(lw,"_runUpload2");Sn.VERSION=Y1.version;var Ah=Sn;var Fn,ee,nm,uw,_n,tm,hw,Ll={},am=[],dw=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function yr(i,e){for(var t in e)i[t]=e[t];return i}n(yr,"s");function lm(i){var e=i.parentNode;e&&e.removeChild(i)}n(lm,"a");function u(i,e,t){var r,s,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?s=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?Fn.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(o in i.defaultProps)a[o]===void 0&&(a[o]=i.defaultProps[o]);return xn(i,a,r,s,null)}n(u,"h");function xn(i,e,t,r,s){var o={type:i,props:e,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:s??++nm};return s==null&&ee.vnode!=null&&ee.vnode(o),o}n(xn,"v");function um(){return{current:null}}n(um,"y");function Ht(i){return i.children}n(Ht,"p");function we(i,e){this.props=i,this.context=e}n(we,"d");function Eo(i,e){if(e==null)return i.__?Eo(i.__,i.__.__k.indexOf(i)+1):null;for(var t;e0?xn(b.type,b.props,b.key,null,b.__v):b)!=null){if(b.__=t,b.__b=t.__b+1,(y=F[d])===null||y&&b.key==y.key&&b.type===y.type)F[d]=void 0;else for(f=0;f2&&(a.children=arguments.length>3?Fn.call(arguments,2):t),xn(i.type,a,r||i.key,s||i.ref,null)}n(jl,"q");Fn=am.slice,ee={__e:function(i,e,t,r){for(var s,o,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(i)),a=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(i,r||{}),a=s.__d),a)return s.__E=s}catch(l){i=l}throw i}},nm=0,uw=n(function(i){return i!=null&&i.constructor===void 0},"i"),we.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=yr({},this.state),typeof i=="function"&&(i=i(yr({},t),this.props)),i&&yr(t,i),i!=null&&this.__v&&(e&&this.__h.push(e),im(this))},we.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),im(this))},we.prototype.render=Ht,_n=[],Bl.__r=0,hw=0;function En(i){return typeof i!="object"||i===null||!("nodeType"in i)?!1:i.nodeType===Node.ELEMENT_NODE}n(En,"isDOMElement");function On(i,e){return e===void 0&&(e=document),typeof i=="string"?e.querySelector(i):En(i)?i:null}n(On,"findDOMElement");function mw(i){for(var e;i&&!i.dir;)i=i.parentNode;return(e=i)==null?void 0:e.dir}n(mw,"getTextDirection");var Hl=mw;var ve=class{constructor(e,t){t===void 0&&(t={}),this.uppy=e,this.opts=t}getPluginState(){let{plugins:e}=this.uppy.getState();return e[this.id]||{}}setPluginState(e){let{plugins:t}=this.uppy.getState();this.uppy.setState({plugins:{...t,[this.id]:{...t[this.id],...e}}})}setOptions(e){this.opts={...this.opts,...e},this.setPluginState(),this.i18nInit()}i18nInit(){let e=new Xr([this.defaultLocale,this.uppy.locale,this.opts.locale]);this.i18n=e.translate.bind(e),this.i18nArray=e.translateArray.bind(e),this.setPluginState()}addTarget(){throw new Error("Extend the addTarget method to add your plugin to another plugin's target")}install(){}uninstall(){}render(){throw new Error("Extend the render method to add your plugin to a DOM element")}update(){}afterUpdate(){}};n(ve,"BasePlugin");function ym(i,e){if(!Object.prototype.hasOwnProperty.call(i,e))throw new TypeError("attempted to use private field on non-instance");return i}n(ym,"_classPrivateFieldLooseBase");var gw=0;function yw(i){return"__private_"+gw+++"_"+i}n(yw,"_classPrivateFieldLooseKey");function vw(i){let e=null,t=null;return function(){for(var r=arguments.length,s=new Array(r),o=0;o(e=null,i(...t)))),e}}n(vw,"debounce");var Cn=yw("updateUI"),Oo=class extends ve{constructor(){super(...arguments),Object.defineProperty(this,Cn,{writable:!0,value:void 0})}getTargetPlugin(e){let t;if(typeof e=="object"&&e instanceof Oo)t=e;else if(typeof e=="function"){let r=e;this.uppy.iteratePlugins(s=>{s instanceof r&&(t=s)})}return t}mount(e,t){let r=t.id,s=On(e);if(s){this.isTargetDOMEl=!0;let l=document.createElement("div");return l.classList.add("uppy-Root"),ym(this,Cn)[Cn]=vw(h=>{this.uppy.getPlugin(this.id)&&(Uh(this.render(h),l),this.afterUpdate())}),this.uppy.log(`Installing ${r} to a DOM element '${e}'`),this.opts.replaceTargetContent&&(s.innerHTML=""),Uh(this.render(this.uppy.getState()),l),this.el=l,s.appendChild(l),l.dir=this.opts.direction||Hl(l)||"ltr",this.onMount(),this.el}let o=this.getTargetPlugin(e);if(o)return this.uppy.log(`Installing ${r} to ${o.id}`),this.parent=o,this.el=o.addTarget(t),this.onMount(),this.el;this.uppy.log(`Not installing ${r}`);let a=`Invalid target option given to ${r}.`;throw typeof e=="function"?a+=" The given target is not a Plugin class. Please check that you're not specifying a React Component instead of a plugin. If you are using @uppy/* packages directly, make sure you have only 1 version of @uppy/core installed: run `npm ls @uppy/core` on the command line and verify that all the versions match and are deduped correctly.":a+="If you meant to target an HTML element, please make sure that the element exists. Check that the