diff --git a/cloudinary-jquery-file-upload.js b/cloudinary-jquery-file-upload.js index 36c0034..96c45ff 100644 --- a/cloudinary-jquery-file-upload.js +++ b/cloudinary-jquery-file-upload.js @@ -1,4722 +1,5315 @@ - /** - * Cloudinary's JavaScript library - Version 2.5.0 + * cloudinary-jquery-file-upload.js + * Cloudinary's JavaScript library - Version 2.6.0 * Copyright Cloudinary * see https://github.com/cloudinary/cloudinary_js * */ -var slice = [].slice, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - -(function(root, factory) { - var name, ref, results, value; - if ((typeof define === 'function') && define.amd) { - return define(['jquery'], factory); - } else if (typeof exports === 'object') { - return module.exports = factory(require('jquery')); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["cloudinary"] = factory(); + else + root["cloudinary"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/namespace/cloudinary-jquery-file-upload.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./src/cloudinary.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/configuration.js"); +/* harmony import */ var _tags_htmltag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/tags/htmltag.js"); +/* harmony import */ var _tags_imagetag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/tags/imagetag.js"); +/* harmony import */ var _tags_picturetag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/tags/picturetag.js"); +/* harmony import */ var _tags_sourcetag__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/tags/sourcetag.js"); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/transformation.js"); +/* harmony import */ var _url__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./src/url.js"); +/* harmony import */ var _tags_videotag__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("./src/tags/videotag.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__("./src/constants.js"); +var applyBreakpoints, closestAbove, defaultBreakpoints, findContainerWidth, maxWidth, updateDpr; + + + + + + + + + + + + + + +defaultBreakpoints = function(width, steps = 100) { + return steps * Math.ceil(width / steps); +}; + +closestAbove = function(list, value) { + var i; + i = list.length - 2; + while (i >= 0 && list[i] >= value) { + i--; + } + return list[i + 1]; +}; + +applyBreakpoints = function(tag, width, steps, options) { + var ref, ref1, ref2, responsive_use_breakpoints; + responsive_use_breakpoints = (ref = (ref1 = (ref2 = options['responsive_use_breakpoints']) != null ? ref2 : options['responsive_use_stoppoints']) != null ? ref1 : this.config('responsive_use_breakpoints')) != null ? ref : this.config('responsive_use_stoppoints'); + if ((!responsive_use_breakpoints) || (responsive_use_breakpoints === 'resize' && !options.resizing)) { + return width; } else { - root.cloudinary || (root.cloudinary = {}); - ref = factory(jQuery); - results = []; - for (name in ref) { - value = ref[name]; - results.push(root.cloudinary[name] = value); - } - return results; + return this.calc_breakpoint(tag, width, steps); } -})(this, function(jQuery) { - - /* - * Includes common utility methods and shims - */ - - /** - * Return true if all items in list are strings - * @function Util.allString - * @param {Array} list - an array of items - */ - var ArrayParam, BaseUtil, ClientHintsMetaTag, Cloudinary, CloudinaryJQuery, Condition, Configuration, Expression, ExpressionParam, FetchLayer, HtmlTag, ImageTag, Layer, LayerParam, Param, RangeParam, RawParam, SubtitlesLayer, TextLayer, Transformation, TransformationBase, TransformationParam, Util, VideoTag, addClass, allStrings, base64Encode, base64EncodeURL, camelCase, cloneDeep, cloudinary, compact, contains, convertKeys, crc32, defaults, difference, funcTag, functions, getAttribute, getData, hasClass, identity, isEmpty, isFunction, isNumberLike, isObject, isString, m, merge, objToString, objectProto, parameters, reWords, removeAttribute, setAttribute, setAttributes, setData, smartEscape, snakeCase, utf8_encode, webp, width, withCamelCaseKeys, withSnakeCaseKeys, without; - allStrings = function(list) { - var item, j, len; - for (j = 0, len = list.length; j < len; j++) { - item = list[j]; - if (!Util.isString(item)) { - return false; - } +}; + +findContainerWidth = function(element) { + var containerWidth, style; + containerWidth = 0; + while (((element = element != null ? element.parentNode : void 0) instanceof Element) && !containerWidth) { + style = window.getComputedStyle(element); + if (!/^inline/.test(style.display)) { + containerWidth = Object(_util__WEBPACK_IMPORTED_MODULE_8__["width"])(element); } - return true; - }; + } + return containerWidth; +}; + +updateDpr = function(dataSrc, roundDpr) { + return dataSrc.replace(/\bdpr_(1\.0|auto)\b/g, 'dpr_' + this.device_pixel_ratio(roundDpr)); +}; + +maxWidth = function(requiredWidth, tag) { + var imageWidth; + imageWidth = Object(_util__WEBPACK_IMPORTED_MODULE_8__["getData"])(tag, 'width') || 0; + if (requiredWidth > imageWidth) { + imageWidth = requiredWidth; + Object(_util__WEBPACK_IMPORTED_MODULE_8__["setData"])(tag, 'width', requiredWidth); + } + return imageWidth; +}; +var Cloudinary = class Cloudinary { /** - * Creates a new array without the given item. - * @function Util.without - * @param {Array} array - original array - * @param {*} item - the item to exclude from the new array - * @return {Array} a new array made of the original array's items except for `item` + * Main Cloudinary class + * @class Cloudinary + * @param {Object} options - options to configure Cloudinary + * @see Configuration for more details + * @example + * var cl = new cloudinary.Cloudinary( { cloud_name: "mycloud"}); + * var imgTag = cl.image("myPicID"); */ - without = function(array, item) { - var i, length, newArray; - newArray = []; - i = -1; - length = array.length; - while (++i < length) { - if (array[i] !== item) { - newArray.push(array[i]); - } - } - return newArray; - }; + constructor(options) { + var configuration; + this.devicePixelRatioCache = {}; + this.responsiveConfig = {}; + this.responsiveResizeInitialized = false; + configuration = new _configuration__WEBPACK_IMPORTED_MODULE_0__["default"](options); + // Provided for backward compatibility + this.config = function(newConfig, newValue) { + return configuration.config(newConfig, newValue); + }; + /** + * Use \ tags in the document to configure this Cloudinary instance. + * @return {Cloudinary} this for chaining + */ + this.fromDocument = function() { + configuration.fromDocument(); + return this; + }; + /** + * Use environment variables to configure this Cloudinary instance. + * @return {Cloudinary} this for chaining + */ + this.fromEnvironment = function() { + configuration.fromEnvironment(); + return this; + }; + /** + * Initialize configuration. + * @function Cloudinary#init + * @see Configuration#init + * @return {Cloudinary} this for chaining + */ + this.init = function() { + configuration.init(); + return this; + }; + } /** - * Return true is value is a number or a string representation of a number. - * @function Util.isNumberLike - * @param {*} value - * @returns {boolean} true if value is a number - * @example - * Util.isNumber(0) // true - * Util.isNumber("1.3") // true - * Util.isNumber("") // false - * Util.isNumber(undefined) // false + * Convenience constructor + * @param {Object} options + * @return {Cloudinary} + * @example cl = cloudinary.Cloudinary.new( { cloud_name: "mycloud"}) */ - isNumberLike = function(value) { - return (value != null) && !isNaN(parseFloat(value)); - }; + static new(options) { + return new this(options); + } /** - * Escape all characters matching unsafe in the given string - * @function Util.smartEscape - * @param {string} string - source string to escape - * @param {RegExp} unsafe - characters that must be escaped - * @return {string} escaped string + * Generate an resource URL. + * @function Cloudinary#url + * @param {string} publicId - the public ID of the resource + * @param {Object} [options] - options for the tag and transformations, possible values include all {@link Transformation} parameters + * and {@link Configuration} parameters + * @param {string} [options.type='upload'] - the classification of the resource + * @param {Object} [options.resource_type='image'] - the type of the resource + * @return {string} The resource URL */ - smartEscape = function(string, unsafe) { - if (unsafe == null) { - unsafe = /([^a-zA-Z0-9_.\-\/:]+)/g; - } - return string.replace(unsafe, function(match) { - return match.split("").map(function(c) { - return "%" + c.charCodeAt(0).toString(16).toUpperCase(); - }).join(""); - }); - }; + url(publicId, options = {}) { + return Object(_url__WEBPACK_IMPORTED_MODULE_6__["default"])(publicId, options, this.config()); + } /** - * Assign values from sources if they are not defined in the destination. - * Once a value is set it does not change - * @function Util.defaults - * @param {Object} destination - the object to assign defaults to - * @param {...Object} source - the source object(s) to assign defaults from - * @return {Object} destination after it was modified + * Generate an video resource URL. + * @function Cloudinary#video_url + * @param {string} publicId - the public ID of the resource + * @param {Object} [options] - options for the tag and transformations, possible values include all {@link Transformation} parameters + * and {@link Configuration} parameters + * @param {string} [options.type='upload'] - the classification of the resource + * @return {string} The video URL */ - defaults = function() { - var destination, sources; - destination = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : []; - return sources.reduce(function(dest, source) { - var key, value; - for (key in source) { - value = source[key]; - if (dest[key] === void 0) { - dest[key] = value; - } - } - return dest; - }, destination); - }; - - /*********** lodash functions */ - objectProto = Object.prototype; + video_url(publicId, options) { + options = Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + resource_type: 'video' + }, options); + return this.url(publicId, options); + } /** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. + * Generate an video thumbnail URL. + * @function Cloudinary#video_thumbnail_url + * @param {string} publicId - the public ID of the resource + * @param {Object} [options] - options for the tag and transformations, possible values include all {@link Transformation} parameters + * and {@link Configuration} parameters + * @param {string} [options.type='upload'] - the classification of the resource + * @return {string} The video thumbnail URL */ - objToString = objectProto.toString; + video_thumbnail_url(publicId, options) { + options = Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({}, _constants__WEBPACK_IMPORTED_MODULE_9__["DEFAULT_POSTER_OPTIONS"], options); + return this.url(publicId, options); + } /** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - #isObject({}); - * // => true - * - #isObject([1, 2, 3]); - * // => true - * - #isObject(1); - * // => false + * Generate a string representation of the provided transformation options. + * @function Cloudinary#transformation_string + * @param {Object} options - the transformation options + * @returns {string} The transformation string */ - isObject = function(value) { - var type; - type = typeof value; - return !!value && (type === 'object' || type === 'function'); - }; - funcTag = '[object Function]'; + transformation_string(options) { + return new _transformation__WEBPACK_IMPORTED_MODULE_5__["default"](options).serialize(); + } /** - * Checks if `value` is classified as a `Function` object. - * @function Util.isFunction - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * function Foo(){}; - * isFunction(Foo); - * // => true - * - * isFunction(/abc/); - * // => false + * Generate an image tag. + * @function Cloudinary#image + * @param {string} publicId - the public ID of the image + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} an image tag element */ - isFunction = function(value) { - return isObject(value) && objToString.call(value) === funcTag; - }; - - /*********** lodash functions */ - - /** Used to match words to create compound words. */ - reWords = (function() { - var lower, upper; - upper = '[A-Z]'; - lower = '[a-z]+'; - return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); - })(); + image(publicId, options = {}) { + var client_hints, img, ref, ref1; + img = this.imageTag(publicId, options); + client_hints = (ref = (ref1 = options.client_hints) != null ? ref1 : this.config('client_hints')) != null ? ref : false; + if (!((options.src != null) || client_hints)) { + // src must be removed before creating the DOM element to avoid loading the image + img.setAttr("src", ''); + } + img = img.toDOM(); + if (!client_hints) { + // cache the image src + Object(_util__WEBPACK_IMPORTED_MODULE_8__["setData"])(img, 'src-cache', this.url(publicId, options)); + // set image src taking responsiveness in account + this.cloudinary_update(img, options); + } + return img; + } /** - * Convert string to camelCase - * @function Util.camelCase - * @param {string} string - the string to convert - * @return {string} in camelCase format + * Creates a new ImageTag instance, configured using this own's configuration. + * @function Cloudinary#imageTag + * @param {string} publicId - the public ID of the resource + * @param {Object} options - additional options to pass to the new ImageTag instance + * @return {ImageTag} An ImageTag that is attached (chained) to this Cloudinary instance */ - camelCase = function(source) { - var i, word, words; - words = source.match(reWords); - words = (function() { - var j, len, results; - results = []; - for (i = j = 0, len = words.length; j < len; i = ++j) { - word = words[i]; - word = word.toLocaleLowerCase(); - if (i) { - results.push(word.charAt(0).toLocaleUpperCase() + word.slice(1)); - } else { - results.push(word); - } - } - return results; - })(); - return words.join(''); - }; + imageTag(publicId, options) { + var tag; + tag = new _tags_imagetag__WEBPACK_IMPORTED_MODULE_2__["default"](publicId, this.config()); + tag.transformation().fromOptions(options); + return tag; + } /** - * Convert string to snake_case - * @function Util.snakeCase - * @param {string} string - the string to convert - * @return {string} in snake_case format + * Creates a new PictureTag instance, configured using this own's configuration. + * @function Cloudinary#PictureTag + * @param {string} publicId - the public ID of the resource + * @param {Object} options - additional options to pass to the new ImageTag instance + * @return {PictureTag} An PictureTag that is attached (chained) to this Cloudinary instance */ - snakeCase = function(source) { - var i, word, words; - words = source.match(reWords); - words = (function() { - var j, len, results; - results = []; - for (i = j = 0, len = words.length; j < len; i = ++j) { - word = words[i]; - results.push(word.toLocaleLowerCase()); - } - return results; - })(); - return words.join('_'); - }; - convertKeys = function(source, converter) { - var key, result, value; - if (converter == null) { - converter = Util.identity; - } - result = {}; - for (key in source) { - value = source[key]; - key = converter(key); - if (!Util.isEmpty(key)) { - result[key] = value; - } - } - return result; - }; + pictureTag(publicId, options) { + var tag; + tag = new _tags_picturetag__WEBPACK_IMPORTED_MODULE_3__["default"](publicId, this.config()); + tag.transformation().fromOptions(options); + return tag; + } /** - * Create a copy of the source object with all keys in camelCase - * @function Util.withCamelCaseKeys - * @param {Object} value - the object to copy - * @return {Object} a new object + * Creates a new SourceTag instance, configured using this own's configuration. + * @function Cloudinary#SourceTag + * @param {string} publicId - the public ID of the resource + * @param {Object} options - additional options to pass to the new ImageTag instance + * @return {SourceTag} An PictureTag that is attached (chained) to this Cloudinary instance */ - withCamelCaseKeys = function(source) { - return convertKeys(source, Util.camelCase); - }; + sourceTag(publicId, options) { + var tag; + tag = new _tags_sourcetag__WEBPACK_IMPORTED_MODULE_4__["default"](publicId, this.config()); + tag.transformation().fromOptions(options); + return tag; + } /** - * Create a copy of the source object with all keys in snake_case - * @function Util.withSnakeCaseKeys - * @param {Object} value - the object to copy - * @return {Object} a new object + * Generate an image tag for the video thumbnail. + * @function Cloudinary#video_thumbnail + * @param {string} publicId - the public ID of the video + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} An image tag element */ - withSnakeCaseKeys = function(source) { - return convertKeys(source, Util.snakeCase); - }; - base64Encode = typeof btoa !== 'undefined' && isFunction(btoa) ? btoa : typeof Buffer !== 'undefined' && isFunction(Buffer) ? function(input) { - if (!(input instanceof Buffer)) { - input = new Buffer.from(String(input), 'binary'); - } - return input.toString('base64'); - } : function(input) { - throw new Error("No base64 encoding function found"); - }; + video_thumbnail(publicId, options) { + return this.image(publicId, Object(_util__WEBPACK_IMPORTED_MODULE_8__["merge"])({}, _constants__WEBPACK_IMPORTED_MODULE_9__["DEFAULT_POSTER_OPTIONS"], options)); + } /** - * Returns the Base64-decoded version of url.
- * This method delegates to `btoa` if present. Otherwise it tries `Buffer`. - * @function Util.base64EncodeURL - * @param {string} url - the url to encode. the value is URIdecoded and then re-encoded before converting to base64 representation - * @return {string} the base64 representation of the URL + * @function Cloudinary#facebook_profile_image + * @param {string} publicId - the public ID of the image + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} an image tag element */ - base64EncodeURL = function(input) { - var error1, ignore; - try { - input = decodeURI(input); - } catch (error1) { - ignore = error1; - } - input = encodeURI(input); - return base64Encode(input); - }; - BaseUtil = { - allStrings: allStrings, - camelCase: camelCase, - convertKeys: convertKeys, - defaults: defaults, - snakeCase: snakeCase, - without: without, - isFunction: isFunction, - isNumberLike: isNumberLike, - smartEscape: smartEscape, - withCamelCaseKeys: withCamelCaseKeys, - withSnakeCaseKeys: withSnakeCaseKeys, - base64EncodeURL: base64EncodeURL - }; + facebook_profile_image(publicId, options) { + return this.image(publicId, Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + type: 'facebook' + }, options)); + } /** - * Includes utility methods and lodash / jQuery shims + * @function Cloudinary#twitter_profile_image + * @param {string} publicId - the public ID of the image + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} an image tag element */ + twitter_profile_image(publicId, options) { + return this.image(publicId, Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + type: 'twitter' + }, options)); + } /** - * Get data from the DOM element. - * - * This method will use jQuery's `data()` method if it is available, otherwise it will get the `data-` attribute - * @param {Element} element - the element to get the data from - * @param {string} name - the name of the data item - * @returns the value associated with the `name` - * @function Util.getData + * @function Cloudinary#twitter_name_profile_image + * @param {string} publicId - the public ID of the image + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} an image tag element */ - getData = function(element, name) { - return jQuery(element).data(name); - }; + twitter_name_profile_image(publicId, options) { + return this.image(publicId, Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + type: 'twitter_name' + }, options)); + } /** - * Set data in the DOM element. - * - * This method will use jQuery's `data()` method if it is available, otherwise it will set the `data-` attribute - * @function Util.setData - * @param {Element} element - the element to set the data in - * @param {string} name - the name of the data item - * @param {*} value - the value to be set - * + * @function Cloudinary#gravatar_image + * @param {string} publicId - the public ID of the image + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} an image tag element */ - setData = function(element, name, value) { - return jQuery(element).data(name, value); - }; + gravatar_image(publicId, options) { + return this.image(publicId, Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + type: 'gravatar' + }, options)); + } /** - * Get attribute from the DOM element. - * - * This method will use jQuery's `attr()` method if it is available, otherwise it will get the attribute directly - * @function Util.getAttribute - * @param {Element} element - the element to set the attribute for - * @param {string} name - the name of the attribute - * @returns {*} the value of the attribute - * + * @function Cloudinary#fetch_image + * @param {string} publicId - the public ID of the image + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} an image tag element */ - getAttribute = function(element, name) { - return jQuery(element).attr(name); - }; + fetch_image(publicId, options) { + return this.image(publicId, Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + type: 'fetch' + }, options)); + } /** - * Set attribute in the DOM element. - * - * This method will use jQuery's `attr()` method if it is available, otherwise it will set the attribute directly - * @function Util.setAttribute - * @param {Element} element - the element to set the attribute for - * @param {string} name - the name of the attribute - * @param {*} value - the value to be set + * @function Cloudinary#video + * @param {string} publicId - the public ID of the image + * @param {Object} [options] - options for the tag and transformations + * @return {HTMLImageElement} an image tag element */ - setAttribute = function(element, name, value) { - return jQuery(element).attr(name, value); - }; + video(publicId, options = {}) { + return this.videoTag(publicId, options).toHtml(); + } /** - * Remove an attribute in the DOM element. - * - * @function Util.removeAttribute - * @param {Element} element - the element to set the attribute for - * @param {string} name - the name of the attribute + * Creates a new VideoTag instance, configured using this own's configuration. + * @function Cloudinary#videoTag + * @param {string} publicId - the public ID of the resource + * @param {Object} options - additional options to pass to the new VideoTag instance + * @return {VideoTag} A VideoTag that is attached (chained) to this Cloudinary instance */ - removeAttribute = function(element, name) { - return jQuery(element).removeAttr(name); - }; + videoTag(publicId, options) { + options = Object(_util__WEBPACK_IMPORTED_MODULE_8__["defaults"])({}, options, this.config()); + return new _tags_videotag__WEBPACK_IMPORTED_MODULE_7__["default"](publicId, options); + } /** - * Set a group of attributes to the element - * @function Util.setAttributes - * @param {Element} element - the element to set the attributes for - * @param {Object} attributes - a hash of attribute names and values + * Generate the URL of the sprite image + * @function Cloudinary#sprite_css + * @param {string} publicId - the public ID of the resource + * @param {Object} [options] - options for the tag and transformations + * @see {@link http://cloudinary.com/documentation/sprite_generation Sprite generation} */ - setAttributes = function(element, attributes) { - return jQuery(element).attr(attributes); - }; + sprite_css(publicId, options) { + options = Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + type: 'sprite' + }, options); + if (!publicId.match(/.css$/)) { + options.format = 'css'; + } + return this.url(publicId, options); + } /** - * Checks if element has a css class - * @function Util.hasClass - * @param {Element} element - the element to check - * @param {string} name - the class name - @returns {boolean} true if the element has the class + * Initialize the responsive behaviour.
+ * Calls {@link Cloudinary#cloudinary_update} to modify image tags. + * @function Cloudinary#responsive + * @param {Object} options + * @param {String} [options.responsive_class='cld-responsive'] - provide an alternative class used to locate img tags + * @param {number} [options.responsive_debounce=100] - the debounce interval in milliseconds. + * @param {boolean} [bootstrap=true] if true processes the img tags by calling cloudinary_update. When false the tags will be processed only after a resize event. + * @see {@link Cloudinary#cloudinary_update} for additional configuration parameters */ - hasClass = function(element, name) { - return jQuery(element).hasClass(name); - }; + responsive(options, bootstrap = true) { + var ref, ref1, ref2, responsiveClass, responsiveResize, timeout; + this.responsiveConfig = Object(_util__WEBPACK_IMPORTED_MODULE_8__["merge"])(this.responsiveConfig || {}, options); + responsiveClass = (ref = this.responsiveConfig['responsive_class']) != null ? ref : this.config('responsive_class'); + if (bootstrap) { + this.cloudinary_update(`img.${responsiveClass}, img.cld-hidpi`, this.responsiveConfig); + } + responsiveResize = (ref1 = (ref2 = this.responsiveConfig['responsive_resize']) != null ? ref2 : this.config('responsive_resize')) != null ? ref1 : true; + if (responsiveResize && !this.responsiveResizeInitialized) { + this.responsiveConfig.resizing = this.responsiveResizeInitialized = true; + timeout = null; + return window.addEventListener('resize', () => { + var debounce, ref3, ref4, reset, run, wait, waitFunc; + debounce = (ref3 = (ref4 = this.responsiveConfig['responsive_debounce']) != null ? ref4 : this.config('responsive_debounce')) != null ? ref3 : 100; + reset = function() { + if (timeout) { + clearTimeout(timeout); + return timeout = null; + } + }; + run = () => { + return this.cloudinary_update(`img.${responsiveClass}`, this.responsiveConfig); + }; + waitFunc = function() { + reset(); + return run(); + }; + wait = function() { + reset(); + return timeout = setTimeout(waitFunc, debounce); + }; + if (debounce) { + return wait(); + } else { + return run(); + } + }); + } + } /** - * Add class to the element - * @function Util.addClass - * @param {Element} element - the element - * @param {string} name - the class name to add + * @function Cloudinary#calc_breakpoint + * @private + * @ignore */ - addClass = function(element, name) { - return jQuery(element).addClass(name); - }; - width = function(element) { - return jQuery(element).width(); - }; + calc_breakpoint(element, width, steps) { + let breakpoints = Object(_util__WEBPACK_IMPORTED_MODULE_8__["getData"])(element, 'breakpoints') || Object(_util__WEBPACK_IMPORTED_MODULE_8__["getData"])(element, 'stoppoints') || this.config('breakpoints') || this.config('stoppoints') || defaultBreakpoints; + if (Object(_util__WEBPACK_IMPORTED_MODULE_8__["isFunction"])(breakpoints)) { + return breakpoints(width, steps); + } else { + if (Object(_util__WEBPACK_IMPORTED_MODULE_8__["isString"])(breakpoints)) { + breakpoints = breakpoints.split(',').map(point=>parseInt(point)).sort((a, b) => a - b); + } + return closestAbove(breakpoints, width); + } + } /** - * Returns true if item is empty: - * - * @function Util.isEmpty - * @param item - * @returns {boolean} true if item is empty + * @function Cloudinary#calc_stoppoint + * @deprecated Use {@link calc_breakpoint} instead. + * @private + * @ignore */ - isEmpty = function(item) { - return (item == null) || (jQuery.isArray(item) || Util.isString(item)) && item.length === 0 || (jQuery.isPlainObject(item) && jQuery.isEmptyObject(item)); - }; + calc_stoppoint(element, width, steps) { + return this.calc_breakpoint(element, width, steps); + } /** - * Returns true if item is a string - * @param item - * @returns {boolean} true if item is a string + * @function Cloudinary#device_pixel_ratio + * @private */ - isString = function(item) { - return typeof item === 'string' || (item != null ? item.toString() : void 0) === '[object String]'; - }; + device_pixel_ratio(roundDpr = true) { + var dpr, dprString; + dpr = (typeof window !== "undefined" && window !== null ? window.devicePixelRatio : void 0) || 1; + if (roundDpr) { + dpr = Math.ceil(dpr); + } + if (dpr <= 0 || dpr === (0/0)) { + dpr = 1; + } + dprString = dpr.toString(); + if (dprString.match(/^\d+$/)) { + dprString += '.0'; + } + return dprString; + } /** - * Recursively assign source properties to destination - * @function Util.merge - * @param {Object} destination - the object to assign to - * @param {...Object} [sources] The source objects. + * Finds all `img` tags under each node and sets it up to provide the image through Cloudinary + * @param {Element[]} nodes the parent nodes to search for img under + * @param {Object} [options={}] options and transformations params + * @function Cloudinary#processImageTags */ - merge = function() { - var args, i; - args = (function() { - var j, len, results; + processImageTags(nodes, options = {}) { + var images, imgOptions, node, publicId; + if (Object(_util__WEBPACK_IMPORTED_MODULE_8__["isEmpty"])(nodes)) { + // similar to `$.fn.cloudinary` + return this; + } + options = Object(_util__WEBPACK_IMPORTED_MODULE_8__["defaults"])({}, options, this.config()); + images = (function() { + var j, len, ref, results; results = []; - for (j = 0, len = arguments.length; j < len; j++) { - i = arguments[j]; - results.push(i); + for (j = 0, len = nodes.length; j < len; j++) { + node = nodes[j]; + if (!(((ref = node.tagName) != null ? ref.toUpperCase() : void 0) === 'IMG')) { + continue; + } + imgOptions = Object(_util__WEBPACK_IMPORTED_MODULE_8__["assign"])({ + width: node.getAttribute('width'), + height: node.getAttribute('height'), + src: node.getAttribute('src') + }, options); + publicId = imgOptions['source'] || imgOptions['src']; + delete imgOptions['source']; + delete imgOptions['src']; + url = this.url(publicId, imgOptions); + imgOptions = new _transformation__WEBPACK_IMPORTED_MODULE_5__["default"](imgOptions).toHtmlAttributes(); + Object(_util__WEBPACK_IMPORTED_MODULE_8__["setData"])(node, 'src-cache', url); + node.setAttribute('width', imgOptions.width); + node.setAttribute('height', imgOptions.height); + results.push(node); } return results; - }).apply(this, arguments); - args.unshift(true); - return jQuery.extend.apply(this, args); - }; + }).call(this); + this.cloudinary_update(images, options); + return this; + } /** - * Creates a new array from the parameter with "falsey" values removed - * @function Util.compact - * @param {Array} array - the array to remove values from - * @return {Array} a new array without falsey values + * Update hidpi (dpr_auto) and responsive (w_auto) fields according to the current container size and the device pixel ratio. + * Only images marked with the cld-responsive class have w_auto updated. + * @function Cloudinary#cloudinary_update + * @param {(Array|string|NodeList)} elements - the elements to modify + * @param {Object} options + * @param {boolean|string} [options.responsive_use_breakpoints=true] + * - when `true`, always use breakpoints for width + * - when `"resize"` use exact width on first render and breakpoints on resize + * - when `false` always use exact width + * @param {boolean} [options.responsive] - if `true`, enable responsive on this element. Can be done by adding cld-responsive. + * @param {boolean} [options.responsive_preserve_height] - if set to true, original css height is preserved. + * Should only be used if the transformation supports different aspect ratios. */ - compact = function(arr) { - var item, j, len, results; - results = []; - for (j = 0, len = arr.length; j < len; j++) { - item = arr[j]; - if (item) { - results.push(item); + cloudinary_update(elements, options = {}) { + var containerWidth, dataSrc, j, len, match, ref, ref1, ref2, ref3, ref4, ref5, requiredWidth, responsive, responsiveClass, roundDpr, setUrl, tag; + if (elements === null) { + return this; + } + responsive = (ref = (ref1 = options.responsive) != null ? ref1 : this.config('responsive')) != null ? ref : false; + elements = (function() { + switch (false) { + case !Object(_util__WEBPACK_IMPORTED_MODULE_8__["isArray"])(elements): + return elements; + case elements.constructor.name !== "NodeList": + return elements; + case !Object(_util__WEBPACK_IMPORTED_MODULE_8__["isString"])(elements): + return document.querySelectorAll(elements); + default: + return [elements]; + } + })(); + responsiveClass = (ref2 = (ref3 = this.responsiveConfig['responsive_class']) != null ? ref3 : options['responsive_class']) != null ? ref2 : this.config('responsive_class'); + roundDpr = (ref4 = options['round_dpr']) != null ? ref4 : this.config('round_dpr'); + for (j = 0, len = elements.length; j < len; j++) { + tag = elements[j]; + if (!((ref5 = tag.tagName) != null ? ref5.match(/img/i) : void 0)) { + continue; + } + setUrl = true; + if (responsive) { + Object(_util__WEBPACK_IMPORTED_MODULE_8__["addClass"])(tag, responsiveClass); + } + dataSrc = Object(_util__WEBPACK_IMPORTED_MODULE_8__["getData"])(tag, 'src-cache') || Object(_util__WEBPACK_IMPORTED_MODULE_8__["getData"])(tag, 'src'); + if (!Object(_util__WEBPACK_IMPORTED_MODULE_8__["isEmpty"])(dataSrc)) { + // Update dpr according to the device's devicePixelRatio + dataSrc = updateDpr.call(this, dataSrc, roundDpr); + if (_tags_htmltag__WEBPACK_IMPORTED_MODULE_1__["default"].isResponsive(tag, responsiveClass)) { + containerWidth = findContainerWidth(tag); + if (containerWidth !== 0) { + switch (false) { + case !/w_auto:breakpoints/.test(dataSrc): + requiredWidth = maxWidth(containerWidth, tag); + dataSrc = dataSrc.replace(/w_auto:breakpoints([_0-9]*)(:[0-9]+)?/, `w_auto:breakpoints$1:${requiredWidth}`); + break; + case !(match = /w_auto(:(\d+))?/.exec(dataSrc)): + requiredWidth = applyBreakpoints.call(this, tag, containerWidth, match[2], options); + requiredWidth = maxWidth(requiredWidth, tag); + dataSrc = dataSrc.replace(/w_auto[^,\/]*/g, `w_${requiredWidth}`); + } + Object(_util__WEBPACK_IMPORTED_MODULE_8__["removeAttribute"])(tag, 'width'); + if (!options.responsive_preserve_height) { + Object(_util__WEBPACK_IMPORTED_MODULE_8__["removeAttribute"])(tag, 'height'); + } + } else { + // Container doesn't know the size yet - usually because the image is hidden or outside the DOM. + setUrl = false; + } + } + if (setUrl) { + Object(_util__WEBPACK_IMPORTED_MODULE_8__["setAttribute"])(tag, 'src', dataSrc); + } } } - return results; - }; + return this; + } /** - * Create a new copy of the given object, including all internal objects. - * @function Util.cloneDeep - * @param {Object} value - the object to clone - * @return {Object} a new deep copy of the object + * Provide a transformation object, initialized with own's options, for chaining purposes. + * @function Cloudinary#transformation + * @param {Object} options + * @return {Transformation} */ - cloneDeep = function() { - var args; - args = jQuery.makeArray(arguments); - args.unshift({}); - args.unshift(true); - return jQuery.extend.apply(this, args); - }; + transformation(options) { + return _transformation__WEBPACK_IMPORTED_MODULE_5__["default"].new(this.config()).fromOptions(options).setParent(this); + } - /** - * Check if a given item is included in the given array - * @function Util.contains - * @param {Array} array - the array to search in - * @param {*} item - the item to search for - * @return {boolean} true if the item is included in the array - */ - contains = function(arr, item) { - var i, j, len; - for (j = 0, len = arr.length; j < len; j++) { - i = arr[j]; - if (i === item) { - return true; - } - } - return false; - }; +}; - /** - * Returns values in the given array that are not included in the other array - * @function Util.difference - * @param {Array} arr - the array to select from - * @param {Array} values - values to filter from arr - * @return {Array} the filtered values - */ - difference = function(arr, values) { - var item, j, len, results; - results = []; - for (j = 0, len = arr.length; j < len; j++) { - item = arr[j]; - if (!contains(values, item)) { - results.push(item); - } - } - return results; - }; +/* harmony default export */ __webpack_exports__["default"] = (Cloudinary); - /** - * Returns a list of all the function names in obj - * @function Util.functions - * @param {Object} object - the object to inspect - * @return {Array} a list of functions of object - */ - functions = function(object) { - var i, results; - results = []; - for (i in object) { - if (jQuery.isFunction(object[i])) { - results.push(i); - } - } - return results; - }; - /** - * Returns the provided value. This functions is used as a default predicate function. - * @function Util.identity - * @param {*} value - * @return {*} the provided value - */ - identity = function(value) { - return value; - }; +/***/ }), + +/***/ "./src/cloudinaryjquery.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _cloudinary__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/cloudinary.js"); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/transformation.js"); +/* harmony import */ var _util_firstNotNull__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/util/firstNotNull.js"); +/** + * Cloudinary jQuery plugin + * Depends on 'jquery', 'util', 'transformation', 'cloudinary' + */ +var webp; - /** - * @class Util - */ - Util = jQuery.extend(BaseUtil, { - hasClass: hasClass, - addClass: addClass, - getAttribute: getAttribute, - setAttribute: setAttribute, - removeAttribute: removeAttribute, - setAttributes: setAttributes, - getData: getData, - setData: setData, - width: width, - isString: isString, - isArray: jQuery.isArray, - isEmpty: isEmpty, - /** - * Assign source properties to destination. - * If the property is an object it is assigned as a whole, overriding the destination object. - * @function Util.assign - * @param {Object} destination - the object to assign to - */ - assign: jQuery.extend, - merge: merge, - cloneDeep: cloneDeep, - compact: compact, - contains: contains, - difference: difference, - functions: functions, - identity: identity, - isPlainObject: jQuery.isPlainObject, - /** - * Remove leading or trailing spaces from text - * @function Util.trim - * @param {string} text - * @return {string} the `text` without leading or trailing spaces - */ - trim: jQuery.trim - }); + +const CloudinaryJQuery = class CloudinaryJQuery extends _cloudinary__WEBPACK_IMPORTED_MODULE_0__["default"] { /** - * UTF8 encoder - * + * Cloudinary class with jQuery support + * @constructor CloudinaryJQuery + * @extends Cloudinary */ - utf8_encode = function(argString) { - var c1, enc, end, n, start, string, stringl, utftext; - if (argString === null || typeof argString === 'undefined') { - return ''; - } - string = argString + ''; - utftext = ''; - start = void 0; - end = void 0; - stringl = 0; - start = end = 0; - stringl = string.length; - n = 0; - while (n < stringl) { - c1 = string.charCodeAt(n); - enc = null; - if (c1 < 128) { - end++; - } else if (c1 > 127 && c1 < 2048) { - enc = String.fromCharCode(c1 >> 6 | 192, c1 & 63 | 128); - } else { - enc = String.fromCharCode(c1 >> 12 | 224, c1 >> 6 & 63 | 128, c1 & 63 | 128); - } - if (enc !== null) { - if (end > start) { - utftext += string.slice(start, end); - } - utftext += enc; - start = end = n + 1; - } - n++; - } - if (end > start) { - utftext += string.slice(start, stringl); - } - return utftext; - }; + constructor(options) { + super(options); + } /** - * CRC32 calculator - * Depends on 'utf8_encode' + * @override */ - crc32 = function(str) { - var crc, i, iTop, table, x, y; - str = utf8_encode(str); - table = '00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D'; - crc = 0; - x = 0; - y = 0; - crc = crc ^ -1; - i = 0; - iTop = str.length; - while (i < iTop) { - y = (crc ^ str.charCodeAt(i)) & 0xFF; - x = '0x' + table.substr(y * 9, 8); - crc = crc >>> 8 ^ x; - i++; + image(publicId, options = {}) { + var client_hints, img; + img = this.imageTag(publicId, options); + client_hints = Object(_util_firstNotNull__WEBPACK_IMPORTED_MODULE_2__["default"])(options.client_hints, this.config('client_hints'), false); + if (!((options.src != null) || client_hints)) { + // generate a tag without the image src + img.setAttr("src", ''); } - crc = crc ^ -1; - if (crc < 0) { - crc += 4294967296; + img = jQuery(img.toHtml()); + if (!client_hints) { + // cache the image src + // set image src taking responsiveness in account + img.data('src-cache', this.url(publicId, options)).cloudinary_update(options); } - return crc; - }; - Layer = (function() { + return img; + } - /** - * Layer - * @constructor Layer - * @param {Object} options - layer parameters - */ - function Layer(options) { - this.options = {}; - if (options != null) { - ["resourceType", "type", "publicId", "format"].forEach((function(_this) { - return function(key) { - var ref; - return _this.options[key] = (ref = options[key]) != null ? ref : options[Util.snakeCase(key)]; - }; - })(this)); - } + /** + * @override + */ + responsive(options) { + var responsiveClass, responsiveConfig, responsiveResizeInitialized, responsive_resize, timeout; + responsiveConfig = jQuery.extend(responsiveConfig || {}, options); + responsiveClass = this.responsiveConfig['responsive_class'] || this.config('responsive_class'); + jQuery(`img.${responsiveClass}, img.cld-hidpi`).cloudinary_update(responsiveConfig); + responsive_resize = Object(_util_firstNotNull__WEBPACK_IMPORTED_MODULE_2__["default"])(responsiveConfig['responsive_resize'], this.config('responsive_resize'), true); + if (responsive_resize && !responsiveResizeInitialized) { + responsiveConfig.resizing = responsiveResizeInitialized = true; + timeout = null; + return jQuery(window).on('resize', () => { + const debounce = Object(_util_firstNotNull__WEBPACK_IMPORTED_MODULE_2__["default"])(responsiveConfig.responsive_debounce, this.config('responsive_debounce'), 100); + let reset = function() { + if (timeout) { + clearTimeout(timeout); + return timeout = null; + } + }; + let run = function() { + return jQuery(`img.${responsiveClass}`).cloudinary_update(responsiveConfig); + }; + let wait = function() { + reset(); + return setTimeout((function() { + reset(); + return run(); + }), debounce); + }; + if (debounce) { + return wait(); + } else { + return run(); + } + }); } + } - Layer.prototype.resourceType = function(value) { - this.options.resourceType = value; - return this; - }; +}; - Layer.prototype.type = function(value) { - this.options.type = value; - return this; - }; +/** + * The following methods are provided through the jQuery class + * @class jQuery + */ +/** + * Convert all img tags in the collection to utilize Cloudinary. + * @function jQuery#cloudinary + * @param {Object} [options] - options for the tag and transformations + * @returns {jQuery} + */ +jQuery.fn.cloudinary = function(options) { + this.filter('img').each(function() { + var img_options, public_id, url; + img_options = jQuery.extend({ + width: jQuery(this).attr('width'), + height: jQuery(this).attr('height'), + src: jQuery(this).attr('src') + }, jQuery(this).data(), options); + public_id = img_options.source || img_options.src; + delete img_options.source; + delete img_options.src; + url = jQuery.cloudinary.url(public_id, img_options); + img_options = new _transformation__WEBPACK_IMPORTED_MODULE_1__["default"](img_options).toHtmlAttributes(); + return jQuery(this).data('src-cache', url).attr({ + width: img_options.width, + height: img_options.height + }); + }).cloudinary_update(options); + return this; +}; - Layer.prototype.publicId = function(value) { - this.options.publicId = value; - return this; - }; +/** + * Update hidpi (dpr_auto) and responsive (w_auto) fields according to the current container size and the device pixel ratio. + * Only images marked with the cld-responsive class have w_auto updated. + * options: + * - responsive_use_stoppoints: + * - true - always use stoppoints for width + * - "resize" - use exact width on first render and stoppoints on resize (default) + * - false - always use exact width + * - responsive: + * - true - enable responsive on this element. Can be done by adding cld-responsive. + * Note that jQuery.cloudinary.responsive() should be called once on the page. + * - responsive_preserve_height: if set to true, original css height is perserved. Should only be used if the transformation supports different aspect ratios. + */ +jQuery.fn.cloudinary_update = function(options = {}) { + jQuery.cloudinary.cloudinary_update(this.filter('img').toArray(), options); + return this; +}; +webp = null; - /** - * Get the public ID, formatted for layer parameter - * @function Layer#getPublicId - * @return {String} public ID - */ +/** + * @function jQuery#webpify + */ +jQuery.fn.webpify = function(options = {}, webp_options) { + var that, webp_canary; + that = this; + webp_options = webp_options != null ? webp_options : options; + if (!webp) { + webp = jQuery.Deferred(); + webp_canary = new Image; + webp_canary.onerror = webp.reject; + webp_canary.onload = webp.resolve; + webp_canary.src = 'data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA'; + } + jQuery(function() { + return webp.done(function() { + return jQuery(that).cloudinary(jQuery.extend({}, webp_options, { + format: 'webp' + })); + }).fail(function() { + return jQuery(that).cloudinary(options); + }); + }); + return this; +}; - Layer.prototype.getPublicId = function() { - var ref; - return (ref = this.options.publicId) != null ? ref.replace(/\//g, ":") : void 0; - }; +jQuery.fn.fetchify = function(options) { + return this.cloudinary(jQuery.extend(options, { + 'type': 'fetch' + })); +}; +jQuery.cloudinary = new CloudinaryJQuery(); - /** - * Get the public ID, with format if present - * @function Layer#getFullPublicId - * @return {String} public ID - */ +jQuery.cloudinary.fromDocument(); - Layer.prototype.getFullPublicId = function() { - if (this.options.format != null) { - return this.getPublicId() + "." + this.options.format; - } else { - return this.getPublicId(); - } - }; +/* harmony default export */ __webpack_exports__["default"] = (CloudinaryJQuery); - Layer.prototype.format = function(value) { - this.options.format = value; - return this; - }; +/***/ }), - /** - * generate the string representation of the layer - * @function Layer#toString - */ +/***/ "./src/condition.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - Layer.prototype.toString = function() { - var components; - components = []; - if (this.options.publicId == null) { - throw "Must supply publicId"; - } - if (!(this.options.resourceType === "image")) { - components.push(this.options.resourceType); - } - if (!(this.options.type === "upload")) { - components.push(this.options.type); - } - components.push(this.getFullPublicId()); - return Util.compact(components).join(":"); - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/expression.js"); - return Layer; - })(); - FetchLayer = (function(superClass) { - extend(FetchLayer, superClass); +var Condition = class Condition extends _expression__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * Represents a transformation condition + * @param {string} conditionStr - a condition in string format + * @class Condition + * @example + * // normally this class is not instantiated directly + * var tr = cloudinary.Transformation.new() + * .if().width( ">", 1000).and().aspectRatio("<", "3:4").then() + * .width(1000) + * .crop("scale") + * .else() + * .width(500) + * .crop("scale") + * + * var tr = cloudinary.Transformation.new() + * .if("w > 1000 and aspectRatio < 3:4") + * .width(1000) + * .crop("scale") + * .else() + * .width(500) + * .crop("scale") + * + */ + constructor(conditionStr) { + super(conditionStr); + } + /** + * @function Condition#height + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Condition} this condition + */ + height(operator, value) { + return this.predicate("h", operator, value); + } - /** - * @constructor FetchLayer - * @param {Object|string} options - layer parameters or a url - * @param {string} options.url the url of the image to fetch - */ + /** + * @function Condition#width + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Condition} this condition + */ + width(operator, value) { + return this.predicate("w", operator, value); + } - function FetchLayer(options) { - FetchLayer.__super__.constructor.call(this, options); - if (Util.isString(options)) { - this.options.url = options; - } else if (options != null ? options.url : void 0) { - this.options.url = options.url; - } - } + /** + * @function Condition#aspectRatio + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Condition} this condition + */ + aspectRatio(operator, value) { + return this.predicate("ar", operator, value); + } - FetchLayer.prototype.url = function(url) { - this.options.url = url; - return this; - }; - - - /** - * generate the string representation of the layer - * @function FetchLayer#toString - * @return {String} - */ + /** + * @function Condition#pages + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Condition} this condition + */ + pageCount(operator, value) { + return this.predicate("pc", operator, value); + } - FetchLayer.prototype.toString = function() { - return "fetch:" + (cloudinary.Util.base64EncodeURL(this.options.url)); - }; + /** + * @function Condition#faces + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Condition} this condition + */ + faceCount(operator, value) { + return this.predicate("fc", operator, value); + } - return FetchLayer; +}; - })(Layer); - TextLayer = (function(superClass) { - extend(TextLayer, superClass); +/* harmony default export */ __webpack_exports__["default"] = (Condition); - /** - * @constructor TextLayer - * @param {Object} options - layer parameters - */ +/***/ }), - function TextLayer(options) { - var keys; - TextLayer.__super__.constructor.call(this, options); - keys = ["resourceType", "resourceType", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecoration", "textAlign", "stroke", "letterSpacing", "lineSpacing", "text"]; - if (options != null) { - keys.forEach((function(_this) { - return function(key) { - var ref; - return _this.options[key] = (ref = options[key]) != null ? ref : options[Util.snakeCase(key)]; - }; - })(this)); - } - this.options.resourceType = "text"; - } +/***/ "./src/configuration.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - TextLayer.prototype.resourceType = function(resourceType) { - throw "Cannot modify resourceType for text layers"; - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/util/jquery.js"); +/** + * Cloudinary configuration class + * Depends on 'utils' + */ - TextLayer.prototype.type = function(type) { - throw "Cannot modify type for text layers"; - }; - TextLayer.prototype.format = function(format) { - throw "Cannot modify format for text layers"; - }; - TextLayer.prototype.fontFamily = function(fontFamily) { - this.options.fontFamily = fontFamily; - return this; - }; +/** + * Defaults configuration. + */ +var Configuration = class Configuration { + /** + * Cloudinary configuration class + * @constructor Configuration + * @param {Object} options - configuration parameters + */ + constructor(options = {}) { + this.configuration = Object(_util__WEBPACK_IMPORTED_MODULE_0__["cloneDeep"])(options); + Object(_util__WEBPACK_IMPORTED_MODULE_0__["defaults"])(this.configuration, DEFAULT_CONFIGURATION_PARAMS); + } - TextLayer.prototype.fontSize = function(fontSize) { - this.options.fontSize = fontSize; - return this; - }; + /** + * Initialize the configuration. + * The function first tries to retrieve the configuration form the environment and then from the document. + * @function Configuration#init + * @return {Configuration} returns this for chaining + * @see fromDocument + * @see fromEnvironment + */ + init() { + this.fromEnvironment(); + this.fromDocument(); + return this; + } - TextLayer.prototype.fontWeight = function(fontWeight) { - this.options.fontWeight = fontWeight; - return this; - }; + /** + * Set a new configuration item + * @function Configuration#set + * @param {string} name - the name of the item to set + * @param {*} value - the value to be set + * @return {Configuration} + * + */ + set(name, value) { + this.configuration[name] = value; + return this; + } - TextLayer.prototype.fontStyle = function(fontStyle) { - this.options.fontStyle = fontStyle; - return this; - }; + /** + * Get the value of a configuration item + * @function Configuration#get + * @param {string} name - the name of the item to set + * @return {*} the configuration item + */ + get(name) { + return this.configuration[name]; + } - TextLayer.prototype.textDecoration = function(textDecoration) { - this.options.textDecoration = textDecoration; - return this; - }; + merge(config = {}) { + Object(_util__WEBPACK_IMPORTED_MODULE_0__["assign"])(this.configuration, Object(_util__WEBPACK_IMPORTED_MODULE_0__["cloneDeep"])(config)); + return this; + } - TextLayer.prototype.textAlign = function(textAlign) { - this.options.textAlign = textAlign; - return this; - }; + /** + * Initialize Cloudinary from HTML meta tags. + * @function Configuration#fromDocument + * @return {Configuration} + * @example + * + */ + fromDocument() { + var el, i, len, meta_elements; + meta_elements = typeof document !== "undefined" && document !== null ? document.querySelectorAll('meta[name^="cloudinary_"]') : void 0; + if (meta_elements) { + for (i = 0, len = meta_elements.length; i < len; i++) { + el = meta_elements[i]; + this.configuration[el.getAttribute('name').replace('cloudinary_', '')] = el.getAttribute('content'); + } + } + return this; + } - TextLayer.prototype.stroke = function(stroke) { - this.options.stroke = stroke; - return this; - }; + /** + * Initialize Cloudinary from the `CLOUDINARY_URL` environment variable. + * + * This function will only run under Node.js environment. + * @function Configuration#fromEnvironment + * @requires Node.js + */ + fromEnvironment() { + var cloudinary_url, query, uri, uriRegex; + if(typeof process !== "undefined" && process !== null && process.env && process.env.CLOUDINARY_URL ){ + cloudinary_url = process.env.CLOUDINARY_URL; + uriRegex = /cloudinary:\/\/(?:(\w+)(?:\:([\w-]+))?@)?([\w\.-]+)(?:\/([^?]*))?(?:\?(.+))?/; + uri = uriRegex.exec(cloudinary_url); + if (uri) { + if (uri[3] != null) { + this.configuration['cloud_name'] = uri[3]; + } + if (uri[1] != null) { + this.configuration['api_key'] = uri[1]; + } + if (uri[2] != null) { + this.configuration['api_secret'] = uri[2]; + } + if (uri[4] != null) { + this.configuration['private_cdn'] = uri[4] != null; + } + if (uri[4] != null) { + this.configuration['secure_distribution'] = uri[4]; + } + query = uri[5]; + if (query != null) { + query.split('&').forEach(value=>{ + let [k, v] = value.split('='); + if (v == null) { + v = true; + } + this.configuration[k] = v; + }); + } + } + } + return this; + } - TextLayer.prototype.letterSpacing = function(letterSpacing) { - this.options.letterSpacing = letterSpacing; - return this; - }; + /** + * Create or modify the Cloudinary client configuration + * + * Warning: `config()` returns the actual internal configuration object. modifying it will change the configuration. + * + * This is a backward compatibility method. For new code, use get(), merge() etc. + * @function Configuration#config + * @param {hash|string|boolean} new_config + * @param {string} new_value + * @returns {*} configuration, or value + * + * @see {@link fromEnvironment} for initialization using environment variables + * @see {@link fromDocument} for initialization using HTML meta tags + */ + config(new_config, new_value) { + switch (false) { + case new_value === void 0: + this.set(new_config, new_value); + return this.configuration; + case !Object(_util__WEBPACK_IMPORTED_MODULE_0__["isString"])(new_config): + return this.get(new_config); + case !Object(_util__WEBPACK_IMPORTED_MODULE_0__["isPlainObject"])(new_config): + this.merge(new_config); + return this.configuration; + default: + // Backward compatibility - return the internal object + return this.configuration; + } + } - TextLayer.prototype.lineSpacing = function(lineSpacing) { - this.options.lineSpacing = lineSpacing; - return this; - }; + /** + * Returns a copy of the configuration parameters + * @function Configuration#toOptions + * @returns {Object} a key:value collection of the configuration parameters + */ + toOptions() { + return Object(_util__WEBPACK_IMPORTED_MODULE_0__["cloneDeep"])(this.configuration); + } - TextLayer.prototype.text = function(text) { - this.options.text = text; - return this; - }; +}; + +const DEFAULT_CONFIGURATION_PARAMS = { + responsive_class: 'cld-responsive', + responsive_use_breakpoints: true, + round_dpr: true, + secure: (typeof window !== "undefined" && window !== null ? window.location ? window.location.protocol : void 0 : void 0) === 'https:' +}; + +Configuration.CONFIG_PARAMS = [ + "api_key", + "api_secret", + "callback", + "cdn_subdomain", + "cloud_name", + "cname", + "private_cdn", + "protocol", + "resource_type", + "responsive", + "responsive_class", + "responsive_use_breakpoints", + "responsive_width", + "round_dpr", + "secure", + "secure_cdn_subdomain", + "secure_distribution", + "shorten", + "type", + "upload_preset", + "url_suffix", + "use_root_path", + "version" +]; + +/* harmony default export */ __webpack_exports__["default"] = (Configuration); + + +/***/ }), + +/***/ "./src/constants.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return VERSION; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CF_SHARED_CDN", function() { return CF_SHARED_CDN; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OLD_AKAMAI_SHARED_CDN", function() { return OLD_AKAMAI_SHARED_CDN; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AKAMAI_SHARED_CDN", function() { return AKAMAI_SHARED_CDN; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SHARED_CDN", function() { return SHARED_CDN; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_POSTER_OPTIONS", function() { return DEFAULT_POSTER_OPTIONS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_VIDEO_SOURCE_TYPES", function() { return DEFAULT_VIDEO_SOURCE_TYPES; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEO_TYPES", function() { return SEO_TYPES; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_IMAGE_PARAMS", function() { return DEFAULT_IMAGE_PARAMS; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_VIDEO_PARAMS", function() { return DEFAULT_VIDEO_PARAMS; }); +var VERSION = "2.5.0"; + +var CF_SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net"; + +var OLD_AKAMAI_SHARED_CDN = "cloudinary-a.akamaihd.net"; + +var AKAMAI_SHARED_CDN = "res.cloudinary.com"; + +var SHARED_CDN = AKAMAI_SHARED_CDN; + +var DEFAULT_POSTER_OPTIONS = { + format: 'jpg', + resource_type: 'video' +}; + +var DEFAULT_VIDEO_SOURCE_TYPES = ['webm', 'mp4', 'ogv']; + +var SEO_TYPES = { + "image/upload": "images", + "image/private": "private_images", + "image/authenticated": "authenticated_images", + "raw/upload": "files", + "video/upload": "videos" +}; +/** +* @const {Object} Cloudinary.DEFAULT_IMAGE_PARAMS +* Defaults values for image parameters. +* +* (Previously defined using option_consume() ) + */ +var DEFAULT_IMAGE_PARAMS = { + resource_type: "image", + transformation: [], + type: 'upload' +}; - /** - * generate the string representation of the layer - * @function TextLayer#toString - * @return {String} - */ +/** +* Defaults values for video parameters. +* @const {Object} Cloudinary.DEFAULT_VIDEO_PARAMS +* (Previously defined using option_consume() ) + */ +var DEFAULT_VIDEO_PARAMS = { + fallback_content: '', + resource_type: "video", + source_transformation: {}, + source_types: DEFAULT_VIDEO_SOURCE_TYPES, + transformation: [], + type: 'upload' +}; - TextLayer.prototype.toString = function() { - var components, hasPublicId, hasStyle, publicId, re, res, start, style, text, textSource; - style = this.textStyleIdentifier(); - if (this.options.publicId != null) { - publicId = this.getFullPublicId(); - } - if (this.options.text != null) { - hasPublicId = !Util.isEmpty(publicId); - hasStyle = !Util.isEmpty(style); - if (hasPublicId && hasStyle || !hasPublicId && !hasStyle) { - throw "Must supply either style parameters or a public_id when providing text parameter in a text overlay/underlay, but not both!"; - } - re = /\$\([a-zA-Z]\w*\)/g; - start = 0; - textSource = Util.smartEscape(this.options.text, /[,\/]/g); - text = ""; - while (res = re.exec(textSource)) { - text += Util.smartEscape(textSource.slice(start, res.index)); - text += res[0]; - start = res.index + res[0].length; - } - text += Util.smartEscape(textSource.slice(start)); - } - components = [this.options.resourceType, style, publicId, text]; - return Util.compact(components).join(":"); - }; - TextLayer.prototype.textStyleIdentifier = function() { - var components; - components = []; - if (this.options.fontWeight !== "normal") { - components.push(this.options.fontWeight); - } - if (this.options.fontStyle !== "normal") { - components.push(this.options.fontStyle); - } - if (this.options.textDecoration !== "none") { - components.push(this.options.textDecoration); - } - components.push(this.options.textAlign); - if (this.options.stroke !== "none") { - components.push(this.options.stroke); - } - if (!(Util.isEmpty(this.options.letterSpacing) && !Util.isNumberLike(this.options.letterSpacing))) { - components.push("letter_spacing_" + this.options.letterSpacing); - } - if (!(Util.isEmpty(this.options.lineSpacing) && !Util.isNumberLike(this.options.lineSpacing))) { - components.push("line_spacing_" + this.options.lineSpacing); - } - if (!Util.isEmpty(Util.compact(components))) { - if (Util.isEmpty(this.options.fontFamily)) { - throw "Must supply fontFamily. " + components; - } - if (Util.isEmpty(this.options.fontSize) && !Util.isNumberLike(this.options.fontSize)) { - throw "Must supply fontSize."; - } - } - components.unshift(this.options.fontFamily, this.options.fontSize); - components = Util.compact(components).join("_"); - return components; - }; +/***/ }), - return TextLayer; +/***/ "./src/crc32.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - })(Layer); - SubtitlesLayer = (function(superClass) { - extend(SubtitlesLayer, superClass); +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _utf8_encode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utf8_encode.js"); +/** + * CRC32 calculator + * Depends on 'utf8_encode' + */ +var crc32; + + + +crc32 = function(str) { + var crc, i, iTop, table, x, y; + // http://kevin.vanzonneveld.net + // + original by: Webtoolkit.info (http://www.webtoolkit.info/) + // + improved by: T0bsn + // + improved by: http://stackoverflow.com/questions/2647935/javascript-crc32-function-and-php-crc32-not-matching + // - depends on: utf8_encode + // * example 1: crc32('Kevin van Zonneveld'); + // * returns 1: 1249991249 + str = Object(_utf8_encode__WEBPACK_IMPORTED_MODULE_0__["default"])(str); + table = '00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D'; + crc = 0; + x = 0; + y = 0; + crc = crc ^ -1; + i = 0; + iTop = str.length; + while (i < iTop) { + y = (crc ^ str.charCodeAt(i)) & 0xFF; + x = '0x' + table.substr(y * 9, 8); + crc = crc >>> 8 ^ x; + i++; + } + crc = crc ^ -1; + //convert to unsigned 32-bit int if needed + if (crc < 0) { + crc += 4294967296; + } + return crc; +}; - /** - * Represent a subtitles layer - * @constructor SubtitlesLayer - * @param {Object} options - layer parameters - */ +/* harmony default export */ __webpack_exports__["default"] = (crc32); - function SubtitlesLayer(options) { - SubtitlesLayer.__super__.constructor.call(this, options); - this.options.resourceType = "subtitles"; - } - return SubtitlesLayer; +/***/ }), - })(TextLayer); +/***/ "./src/expression.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +__webpack_require__.r(__webpack_exports__); +const Expression = class Expression { /** - * Transformation parameters - * Depends on 'util', 'transformation' + * Represents a transformation expression + * @param {string} expressionStr - a expression in string format + * @class Expression + * */ - Param = (function() { - + constructor(expressionStr) { /** - * Represents a single parameter - * @class Param - * @param {string} name - The name of the parameter in snake_case - * @param {string} shortName - The name of the serialized form of the parameter. - * If a value is not provided, the parameter will not be serialized. - * @param {function} [process=cloudinary.Util.identity ] - Manipulate origValue when value is called - * @ignore + * @protected + * @inner Expression-expressions */ - function Param(name, shortName, process) { - if (process == null) { - process = cloudinary.Util.identity; - } - - /** - * The name of the parameter in snake_case - * @member {string} Param#name - */ - this.name = name; - - /** - * The name of the serialized form of the parameter - * @member {string} Param#shortName - */ - this.shortName = shortName; - - /** - * Manipulate origValue when value is called - * @member {function} Param#process - */ - this.process = process; + this.expressions = []; + if (expressionStr != null) { + this.expressions.push(Expression.normalize(expressionStr)); } + } + /** + * Convenience constructor method + * @function Expression.new + */ + static new(expressionStr) { + return new this(expressionStr); + } - /** - * Set a (unprocessed) value for this parameter - * @function Param#set - * @param {*} origValue - the value of the parameter - * @return {Param} self for chaining - */ + /** + * Normalize a string expression + * @function Cloudinary#normalize + * @param {string} expression a expression, e.g. "w gt 100", "width_gt_100", "width > 100" + * @return {string} the normalized form of the value expression, e.g. "w_gt_100" + */ + static normalize(expression) { + var operators, pattern, replaceRE; + if (expression == null) { + return expression; + } + expression = String(expression); + operators = "\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*"; + pattern = "((" + operators + ")(?=[ _])|" + Object.keys(Expression.PREDEFINED_VARS).join("|") + ")"; + replaceRE = new RegExp(pattern, "g"); + expression = expression.replace(replaceRE, function (match) { + return Expression.OPERATORS[match] || Expression.PREDEFINED_VARS[match]; + }); + return expression.replace(/[ _]+/g, '_'); + } - Param.prototype.set = function(origValue) { - this.origValue = origValue; - return this; - }; + /** + * Serialize the expression + * @return {string} the expression as a string + */ + serialize() { + return Expression.normalize(this.expressions.join("_")); + } + toString() { + return this.serialize(); + } - /** - * Generate the serialized form of the parameter - * @function Param#serialize - * @return {string} the serialized form of the parameter - */ + /** + * Get the parent transformation of this expression + * @return Transformation + */ + getParent() { + return this.parent; + } - Param.prototype.serialize = function() { - var val, valid; - val = this.value(); - valid = cloudinary.Util.isArray(val) || cloudinary.Util.isPlainObject(val) || cloudinary.Util.isString(val) ? !cloudinary.Util.isEmpty(val) : val != null; - if ((this.shortName != null) && valid) { - return this.shortName + "_" + val; - } else { - return ''; - } - }; + /** + * Set the parent transformation of this expression + * @param {Transformation} the parent transformation + * @return {Expression} this expression + */ + setParent(parent) { + this.parent = parent; + return this; + } + /** + * Add a expression + * @function Expression#predicate + * @internal + */ + predicate(name, operator, value) { + if (Expression.OPERATORS[operator] != null) { + operator = Expression.OPERATORS[operator]; + } + this.expressions.push(`${name}_${operator}_${value}`); + return this; + } - /** - * Return the processed value of the parameter - * @function Param#value - */ + /** + * @function Expression#and + */ + and() { + this.expressions.push("and"); + return this; + } - Param.prototype.value = function() { - return this.process(this.origValue); - }; + /** + * @function Expression#or + */ + or() { + this.expressions.push("or"); + return this; + } - Param.norm_color = function(value) { - return value != null ? value.replace(/^#/, 'rgb:') : void 0; - }; + /** + * Conclude expression + * @function Expression#then + * @return {Transformation} the transformation this expression is defined for + */ + then() { + return this.getParent().if(this.toString()); + } - Param.prototype.build_array = function(arg) { - if (arg == null) { - arg = []; - } - if (cloudinary.Util.isArray(arg)) { - return arg; - } else { - return [arg]; - } - }; + /** + * @function Expression#height + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Expression} this expression + */ + height(operator, value) { + return this.predicate("h", operator, value); + } + /** + * @function Expression#width + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Expression} this expression + */ + width(operator, value) { + return this.predicate("w", operator, value); + } - /** - * Covert value to video codec string. - * - * If the parameter is an object, - * @param {(string|Object)} param - the video codec as either a String or a Hash - * @return {string} the video codec string in the format codec:profile:level - * @example - * vc_[ :profile : [level]] - * or - { codec: 'h264', profile: 'basic', level: '3.1' } - * @ignore - */ + /** + * @function Expression#aspectRatio + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Expression} this expression + */ + aspectRatio(operator, value) { + return this.predicate("ar", operator, value); + } - Param.process_video_params = function(param) { - var video; - switch (param.constructor) { - case Object: - video = ""; - if ('codec' in param) { - video = param['codec']; - if ('profile' in param) { - video += ":" + param['profile']; - if ('level' in param) { - video += ":" + param['level']; - } - } - } - return video; - case String: - return param; - default: - return null; - } - }; + /** + * @function Expression#pages + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Expression} this expression + */ + pageCount(operator, value) { + return this.predicate("pc", operator, value); + } - return Param; + /** + * @function Expression#faces + * @param {string} operator the comparison operator (e.g. "<", "lt") + * @param {string|number} value the right hand side value + * @return {Expression} this expression + */ + faceCount(operator, value) { + return this.predicate("fc", operator, value); + } - })(); - ArrayParam = (function(superClass) { - extend(ArrayParam, superClass); + value(value) { + this.expressions.push(value); + return this; + } + /** + */ + static variable(name, value) { + return new this(name).value(value); + } - /** - * A parameter that represents an array - * @param {string} name - The name of the parameter in snake_case - * @param {string} shortName - The name of the serialized form of the parameter - * If a value is not provided, the parameter will not be serialized. - * @param {string} [sep='.'] - The separator to use when joining the array elements together - * @param {function} [process=cloudinary.Util.identity ] - Manipulate origValue when value is called - * @class ArrayParam - * @extends Param - * @ignore - */ + /** + * @returns Expression a new expression with the predefined variable "width" + * @function Expression.width + */ + static width() { + return new this("width"); + } - function ArrayParam(name, shortName, sep, process) { - if (sep == null) { - sep = '.'; - } - this.sep = sep; - ArrayParam.__super__.constructor.call(this, name, shortName, process); - } + /** + * @returns Expression a new expression with the predefined variable "height" + * @function Expression.height + */ + static height() { + return new this("height"); + } - ArrayParam.prototype.serialize = function() { - var arrayValue, flat, t; - if (this.shortName != null) { - arrayValue = this.value(); - if (cloudinary.Util.isEmpty(arrayValue)) { - return ''; - } else if (cloudinary.Util.isString(arrayValue)) { - return this.shortName + "_" + arrayValue; - } else { - flat = (function() { - var j, len, results; - results = []; - for (j = 0, len = arrayValue.length; j < len; j++) { - t = arrayValue[j]; - if (cloudinary.Util.isFunction(t.serialize)) { - results.push(t.serialize()); - } else { - results.push(t); - } - } - return results; - })(); - return this.shortName + "_" + (flat.join(this.sep)); - } - } else { - return ''; - } - }; + /** + * @returns Expression a new expression with the predefined variable "initialWidth" + * @function Expression.initialWidth + */ + static initialWidth() { + return new this("initialWidth"); + } - ArrayParam.prototype.value = function() { - var j, len, ref, results, v; - if (cloudinary.Util.isArray(this.origValue)) { - ref = this.origValue; - results = []; - for (j = 0, len = ref.length; j < len; j++) { - v = ref[j]; - results.push(this.process(v)); - } - return results; - } else { - return this.process(this.origValue); - } - }; + /** + * @returns Expression a new expression with the predefined variable "initialHeight" + * @function Expression.initialHeight + */ + static initialHeight() { + return new this("initialHeight"); + } - ArrayParam.prototype.set = function(origValue) { - if ((origValue == null) || cloudinary.Util.isArray(origValue)) { - return ArrayParam.__super__.set.call(this, origValue); - } else { - return ArrayParam.__super__.set.call(this, [origValue]); - } - }; + /** + * @returns Expression a new expression with the predefined variable "aspectRatio" + * @function Expression.aspectRatio + */ + static aspectRatio() { + return new this("aspectRatio"); + } - return ArrayParam; + /** + * @returns Expression a new expression with the predefined variable "initialAspectRatio" + * @function Expression.initialAspectRatio + */ + static initialAspectRatio() { + return new this("initialAspectRatio"); + } - })(Param); - TransformationParam = (function(superClass) { - extend(TransformationParam, superClass); + /** + * @returns Expression a new expression with the predefined variable "pageCount" + * @function Expression.pageCount + */ + static pageCount() { + return new this("pageCount"); + } + /** + * @returns Expression new expression with the predefined variable "faceCount" + * @function Expression.faceCount + */ + static faceCount() { + return new this("faceCount"); + } - /** - * A parameter that represents a transformation - * @param {string} name - The name of the parameter in snake_case - * @param {string} [shortName='t'] - The name of the serialized form of the parameter - * @param {string} [sep='.'] - The separator to use when joining the array elements together - * @param {function} [process=cloudinary.Util.identity ] - Manipulate origValue when value is called - * @class TransformationParam - * @extends Param - * @ignore - */ + /** + * @returns Expression a new expression with the predefined variable "currentPage" + * @function Expression.currentPage + */ + static currentPage() { + return new this("currentPage"); + } - function TransformationParam(name, shortName, sep, process) { - if (shortName == null) { - shortName = "t"; - } - if (sep == null) { - sep = '.'; - } - this.sep = sep; - TransformationParam.__super__.constructor.call(this, name, shortName, process); - } + /** + * @returns Expression a new expression with the predefined variable "tags" + * @function Expression.tags + */ + static tags() { + return new this("tags"); + } - TransformationParam.prototype.serialize = function() { - var joined, result, t; - if (cloudinary.Util.isEmpty(this.value())) { - return ''; - } else if (cloudinary.Util.allStrings(this.value())) { - joined = this.value().join(this.sep); - if (!cloudinary.Util.isEmpty(joined)) { - return this.shortName + "_" + joined; - } else { - return ''; - } - } else { - result = (function() { - var j, len, ref, results; - ref = this.value(); - results = []; - for (j = 0, len = ref.length; j < len; j++) { - t = ref[j]; - if (t != null) { - if (cloudinary.Util.isString(t) && !cloudinary.Util.isEmpty(t)) { - results.push(this.shortName + "_" + t); - } else if (cloudinary.Util.isFunction(t.serialize)) { - results.push(t.serialize()); - } else if (cloudinary.Util.isPlainObject(t) && !cloudinary.Util.isEmpty(t)) { - results.push(new Transformation(t).serialize()); - } else { - results.push(void 0); - } - } - } - return results; - }).call(this); - return cloudinary.Util.compact(result); - } - }; + /** + * @returns Expression a new expression with the predefined variable "pageX" + * @function Expression.pageX + */ + static pageX() { + return new this("pageX"); + } - TransformationParam.prototype.set = function(origValue1) { - this.origValue = origValue1; - if (cloudinary.Util.isArray(this.origValue)) { - return TransformationParam.__super__.set.call(this, this.origValue); - } else { - return TransformationParam.__super__.set.call(this, [this.origValue]); - } - }; + /** + * @returns Expression a new expression with the predefined variable "pageY" + * @function Expression.pageY + */ + static pageY() { + return new this("pageY"); + } - return TransformationParam; +}; - })(Param); - RangeParam = (function(superClass) { - extend(RangeParam, superClass); +/** + * @internal + */ +Expression.OPERATORS = { + "=": 'eq', + "!=": 'ne', + "<": 'lt', + ">": 'gt', + "<=": 'lte', + ">=": 'gte', + "&&": 'and', + "||": 'or', + "*": "mul", + "/": "div", + "+": "add", + "-": "sub" +}; +/** + * @internal + */ +Expression.PREDEFINED_VARS = { + "aspect_ratio": "ar", + "aspectRatio": "ar", + "current_page": "cp", + "currentPage": "cp", + "face_count": "fc", + "faceCount": "fc", + "height": "h", + "initial_aspect_ratio": "iar", + "initial_height": "ih", + "initial_width": "iw", + "initialAspectRatio": "iar", + "initialHeight": "ih", + "initialWidth": "iw", + "page_count": "pc", + "page_x": "px", + "page_y": "py", + "pageCount": "pc", + "pageX": "px", + "pageY": "py", + "tags": "tags", + "width": "w" +}; - /** - * A parameter that represents a range - * @param {string} name - The name of the parameter in snake_case - * @param {string} shortName - The name of the serialized form of the parameter - * If a value is not provided, the parameter will not be serialized. - * @param {function} [process=norm_range_value ] - Manipulate origValue when value is called - * @class RangeParam - * @extends Param - * @ignore - */ +/** + * @internal + */ +Expression.BOUNDRY = "[ _]+"; - function RangeParam(name, shortName, process) { - if (process == null) { - process = this.norm_range_value; - } - RangeParam.__super__.constructor.call(this, name, shortName, process); - } +/* harmony default export */ __webpack_exports__["default"] = (Expression); - RangeParam.norm_range_value = function(value) { - var modifier, offset; - offset = String(value).match(new RegExp('^' + offset_any_pattern + '$')); - if (offset) { - modifier = offset[5] != null ? 'p' : ''; - value = (offset[1] || offset[4]) + modifier; - } - return value; - }; - return RangeParam; +/***/ }), - })(Param); - RawParam = (function(superClass) { - extend(RawParam, superClass); +/***/ "./src/jquery-file-upload.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - function RawParam(name, shortName, process) { - if (process == null) { - process = cloudinary.Util.identity; - } - RawParam.__super__.constructor.call(this, name, shortName, process); - } +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _cloudinaryjquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/cloudinaryjquery.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/util/jquery.js"); +/** + * This module extends CloudinaryJquery to support jQuery File Upload + * Depends on 'jquery', 'util', 'cloudinaryjquery', 'jquery.ui.widget', 'jquery.iframe-transport','jquery.fileupload' + */ - RawParam.prototype.serialize = function() { - return this.value(); - }; - return RawParam; - })(Param); - LayerParam = (function(superClass) { - var LAYER_KEYWORD_PARAMS; +/** + * Delete a resource using the upload token + * @function CloudinaryJQuery#delete_by_token + * @param {string} delete_token - the delete token + * @param {Object} [options] + * @param {string} [options.url] - an alternative URL to use for the API + * @param {string} [options.cloud_name] - an alternative cloud_name to use. This parameter is ignored if `options.url` is provided. + */ +_cloudinaryjquery__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.delete_by_token = function(delete_token, options) { + var cloud_name, dataType, url; + options = options || {}; + url = options.url; + if (!url) { + cloud_name = options.cloud_name || jQuery.cloudinary.config().cloud_name; + url = 'https://api.cloudinary.com/v1_1/' + cloud_name + '/delete_by_token'; + } + dataType = jQuery.support.xhrFileUpload ? 'json' : 'iframe json'; + return jQuery.ajax({ + url: url, + method: 'POST', + data: { + token: delete_token + }, + headers: { + 'X-Requested-With': 'XMLHttpRequest' + }, + dataType: dataType + }); +}; - extend(LayerParam, superClass); +/** + * Creates an `input` tag and sets it up to upload files to cloudinary + * @function CloudinaryJQuery#unsigned_upload_tag + * @param {string} + */ +_cloudinaryjquery__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.unsigned_upload_tag = function(upload_preset, upload_params, options) { + return jQuery('').attr({ + type: 'file', + name: 'file' + }).unsigned_cloudinary_upload(upload_preset, upload_params, options); +}; - function LayerParam() { - return LayerParam.__super__.constructor.apply(this, arguments); +/** + * Initialize the jQuery File Upload plugin to upload to Cloudinary + * @function jQuery#cloudinary_fileupload + * @param {Object} options + * @returns {jQuery} + */ +jQuery.fn.cloudinary_fileupload = function(options) { + var cloud_name, initializing, resource_type, type, upload_url; + if (!_util__WEBPACK_IMPORTED_MODULE_1__["isFunction"](jQuery.fn.fileupload)) { + return this; + } + initializing = !this.data('blueimpFileupload'); + if (initializing) { + options = jQuery.extend({ + maxFileSize: 20000000, + dataType: 'json', + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }, options); + } + this.fileupload(options); + if (initializing) { + this.bind('fileuploaddone', function(e, data) { + var add_field, field, multiple, upload_info; + if (data.result.error) { + return; + } + data.result.path = ['v', data.result.version, '/', data.result.public_id, data.result.format ? '.' + data.result.format : ''].join(''); + if (data.cloudinaryField && data.form.length > 0) { + upload_info = [data.result.resource_type, data.result.type, data.result.path].join('/') + '#' + data.result.signature; + multiple = jQuery(e.target).prop('multiple'); + add_field = function() { + return jQuery('').attr({ + type: 'hidden', + name: data.cloudinaryField + }).val(upload_info).appendTo(data.form); + }; + if (multiple) { + add_field(); + } else { + field = jQuery(data.form).find('input[name="' + data.cloudinaryField + '"]'); + if (field.length > 0) { + field.val(upload_info); + } else { + add_field(); + } + } + } + return jQuery(e.target).trigger('cloudinarydone', data); + }); + this.bind('fileuploadsend', function(e, data) { + // add a common unique ID to all chunks of the same uploaded file + data.headers = jQuery.extend({}, data.headers, { + 'X-Unique-Upload-Id': (Math.random() * 10000000000).toString(16) + }); + return true; + }); + this.bind('fileuploadstart', function(e) { + return jQuery(e.target).trigger('cloudinarystart'); + }); + this.bind('fileuploadstop', function(e) { + return jQuery(e.target).trigger('cloudinarystop'); + }); + this.bind('fileuploadprogress', function(e, data) { + return jQuery(e.target).trigger('cloudinaryprogress', data); + }); + this.bind('fileuploadprogressall', function(e, data) { + return jQuery(e.target).trigger('cloudinaryprogressall', data); + }); + this.bind('fileuploadfail', function(e, data) { + return jQuery(e.target).trigger('cloudinaryfail', data); + }); + this.bind('fileuploadalways', function(e, data) { + return jQuery(e.target).trigger('cloudinaryalways', data); + }); + if (!this.fileupload('option').url) { + cloud_name = options.cloud_name || jQuery.cloudinary.config().cloud_name; + resource_type = options.resource_type || 'auto'; + type = options.type || 'upload'; + upload_url = 'https://api.cloudinary.com/v1_1/' + cloud_name + '/' + resource_type + '/' + type; + this.fileupload('option', 'url', upload_url); } + } + return this; +}; - LayerParam.prototype.value = function() { - var layerOptions, result; - layerOptions = this.origValue; - if (cloudinary.Util.isPlainObject(layerOptions)) { - layerOptions = Util.withCamelCaseKeys(layerOptions); - if (layerOptions.resourceType === "text" || (layerOptions.text != null)) { - result = new cloudinary.TextLayer(layerOptions).toString(); - } else if (layerOptions.resourceType === "subtitles") { - result = new cloudinary.SubtitlesLayer(layerOptions).toString(); - } else if (layerOptions.resourceType === "fetch" || (layerOptions.url != null)) { - result = new cloudinary.FetchLayer(layerOptions).toString(); - } else { - result = new cloudinary.Layer(layerOptions).toString(); +/** + * Add a file to upload + * @function jQuery#cloudinary_upload_url + * @param {string} remote_url - the url to add + * @returns {jQuery} + */ +jQuery.fn.cloudinary_upload_url = function(remote_url) { + if (!_util__WEBPACK_IMPORTED_MODULE_1__["isFunction"](jQuery.fn.fileupload)) { + return this; + } + this.fileupload('option', 'formData').file = remote_url; + this.fileupload('add', { + files: [remote_url] + }); + delete this.fileupload('option', 'formData').file; + return this; +}; + +/** + * Initialize the jQuery File Upload plugin to upload to Cloudinary using unsigned upload + * @function jQuery#unsigned_cloudinary_upload + * @param {string} upload_preset - the upload preset to use + * @param {Object} [upload_params] - parameters that should be past to the server + * @param {Object} [options] + * @returns {jQuery} + */ +jQuery.fn.unsigned_cloudinary_upload = function(upload_preset, upload_params = {}, options = {}) { + var attr, attrs_to_move, html_options, i, key, value; + upload_params = _util__WEBPACK_IMPORTED_MODULE_1__["cloneDeep"](upload_params); + options = _util__WEBPACK_IMPORTED_MODULE_1__["cloneDeep"](options); + attrs_to_move = ['cloud_name', 'resource_type', 'type']; + i = 0; + while (i < attrs_to_move.length) { + attr = attrs_to_move[i]; + if (upload_params[attr]) { + options[attr] = upload_params[attr]; + delete upload_params[attr]; + } + i++; + } +// Serialize upload_params + for (key in upload_params) { + value = upload_params[key]; + if (_util__WEBPACK_IMPORTED_MODULE_1__["isPlainObject"](value)) { + upload_params[key] = jQuery.map(value, function(v, k) { + if (_util__WEBPACK_IMPORTED_MODULE_1__["isString"](v)) { + v = v.replace(/[\|=]/g, "\\$&"); } - } else if (/^fetch:.+/.test(layerOptions)) { - result = new FetchLayer(layerOptions.substr(6)).toString(); + return k + '=' + v; + }).join('|'); + } else if (_util__WEBPACK_IMPORTED_MODULE_1__["isArray"](value)) { + if (value.length > 0 && jQuery.isArray(value[0])) { + upload_params[key] = jQuery.map(value, function(array_value) { + return array_value.join(','); + }).join('|'); } else { - result = layerOptions; + upload_params[key] = value.join(','); } - return result; - }; + } + } + if (!upload_params.callback) { + upload_params.callback = '/cloudinary_cors.html'; + } + upload_params.upload_preset = upload_preset; + options.formData = upload_params; + if (options.cloudinary_field) { + options.cloudinaryField = options.cloudinary_field; + delete options.cloudinary_field; + } + html_options = options.html || {}; + html_options.class = _util__WEBPACK_IMPORTED_MODULE_1__["trim"](`cloudinary_fileupload ${html_options.class || ''}`); + if (options.multiple) { + html_options.multiple = true; + } + this.attr(html_options).cloudinary_fileupload(options); + return this; +}; - LAYER_KEYWORD_PARAMS = [["font_weight", "normal"], ["font_style", "normal"], ["text_decoration", "none"], ["text_align", null], ["stroke", "none"], ["letter_spacing", null], ["line_spacing", null]]; +jQuery.cloudinary = new _cloudinaryjquery__WEBPACK_IMPORTED_MODULE_0__["default"](); - LayerParam.prototype.textStyle = function(layer) { - return (new cloudinary.TextLayer(layer)).textStyleIdentifier(); - }; +/* harmony default export */ __webpack_exports__["default"] = (_cloudinaryjquery__WEBPACK_IMPORTED_MODULE_0__["default"]); - return LayerParam; - })(Param); - ExpressionParam = (function(superClass) { - extend(ExpressionParam, superClass); +/***/ }), - function ExpressionParam() { - return ExpressionParam.__super__.constructor.apply(this, arguments); - } +/***/ "./src/layer/fetchlayer.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - ExpressionParam.prototype.serialize = function() { - return Expression.normalize(ExpressionParam.__super__.serialize.call(this)); - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/layer/layer.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/util/jquery.js"); - return ExpressionParam; - })(Param); - parameters = {}; - parameters.Param = Param; - parameters.ArrayParam = ArrayParam; - parameters.RangeParam = RangeParam; - parameters.RawParam = RawParam; - parameters.TransformationParam = TransformationParam; - parameters.LayerParam = LayerParam; - parameters.ExpressionParam = ExpressionParam; - Expression = (function() { - /** - * @internal - */ - var faceCount; - - Expression.OPERATORS = { - "=": 'eq', - "!=": 'ne', - "<": 'lt', - ">": 'gt', - "<=": 'lte', - ">=": 'gte', - "&&": 'and', - "||": 'or', - "*": "mul", - "/": "div", - "+": "add", - "-": "sub" - }; +const FetchLayer = class FetchLayer extends _layer__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * @constructor FetchLayer + * @param {Object|string} options - layer parameters or a url + * @param {string} options.url the url of the image to fetch + */ + constructor(options) { + super(options); + if (Object(_util__WEBPACK_IMPORTED_MODULE_1__["isString"])(options)) { + this.options.url = options; + } else if (options != null ? options.url : void 0) { + this.options.url = options.url; + } + } - /** - * @internal - */ + url(url) { + this.options.url = url; + return this; + } - Expression.PREDEFINED_VARS = { - "aspect_ratio": "ar", - "aspectRatio": "ar", - "current_page": "cp", - "currentPage": "cp", - "face_count": "fc", - "faceCount": "fc", - "height": "h", - "initial_aspect_ratio": "iar", - "initial_height": "ih", - "initial_width": "iw", - "initialAspectRatio": "iar", - "initialHeight": "ih", - "initialWidth": "iw", - "page_count": "pc", - "page_x": "px", - "page_y": "py", - "pageCount": "pc", - "pageX": "px", - "pageY": "py", - "tags": "tags", - "width": "w" - }; + /** + * generate the string representation of the layer + * @function FetchLayer#toString + * @return {String} + */ + toString() { + return `fetch:${Object(_util__WEBPACK_IMPORTED_MODULE_1__["base64EncodeURL"])(this.options.url)}`; + } +}; - /** - * @internal - */ +/* harmony default export */ __webpack_exports__["default"] = (FetchLayer); - Expression.BOUNDRY = "[ _]+"; +/***/ }), - /** - * Represents a transformation expression - * @param {string} expressionStr - a expression in string format - * @class Expression - * - */ +/***/ "./src/layer/layer.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - function Expression(expressionStr) { +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/util/jquery.js"); - /** - * @protected - * @inner Expression-expressions - */ - this.expressions = []; - if (expressionStr != null) { - this.expressions.push(Expression.normalize(expressionStr)); - } + +var Layer = class Layer { + /** + * Layer + * @constructor Layer + * @param {Object} options - layer parameters + */ + constructor(options) { + this.options = {}; + if (options != null) { + ["resourceType", "type", "publicId", "format"].forEach((key) => { + var ref; + return this.options[key] = (ref = options[key]) != null ? ref : options[Object(_util__WEBPACK_IMPORTED_MODULE_0__["snakeCase"])(key)]; + }); } + } + resourceType(value) { + this.options.resourceType = value; + return this; + } - /** - * Convenience constructor method - * @function Expression.new - */ + type(value) { + this.options.type = value; + return this; + } - Expression["new"] = function(expressionStr) { - return new this(expressionStr); - }; + publicId(value) { + this.options.publicId = value; + return this; + } + /** + * Get the public ID, formatted for layer parameter + * @function Layer#getPublicId + * @return {String} public ID + */ + getPublicId() { + var ref; + return (ref = this.options.publicId) != null ? ref.replace(/\//g, ":") : void 0; + } - /** - * Normalize a string expression - * @function Cloudinary#normalize - * @param {string} expression a expression, e.g. "w gt 100", "width_gt_100", "width > 100" - * @return {string} the normalized form of the value expression, e.g. "w_gt_100" - */ + /** + * Get the public ID, with format if present + * @function Layer#getFullPublicId + * @return {String} public ID + */ + getFullPublicId() { + if (this.options.format != null) { + return this.getPublicId() + "." + this.options.format; + } else { + return this.getPublicId(); + } + } - Expression.normalize = function(expression) { - var operators, pattern, replaceRE; - if (expression == null) { - return expression; - } - expression = String(expression); - operators = "\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*"; - pattern = "((" + operators + ")(?=[ _])|" + Object.keys(Expression.PREDEFINED_VARS).join("|") + ")"; - replaceRE = new RegExp(pattern, "g"); - expression = expression.replace(replaceRE, function(match) { - return Expression.OPERATORS[match] || Expression.PREDEFINED_VARS[match]; - }); - return expression.replace(/[ _]+/g, '_'); - }; + format(value) { + this.options.format = value; + return this; + } + /** + * generate the string representation of the layer + * @function Layer#toString + */ + toString() { + var components; + components = []; + if (this.options.publicId == null) { + throw "Must supply publicId"; + } + if (!(this.options.resourceType === "image")) { + components.push(this.options.resourceType); + } + if (!(this.options.type === "upload")) { + components.push(this.options.type); + } + components.push(this.getFullPublicId()); + return Object(_util__WEBPACK_IMPORTED_MODULE_0__["compact"])(components).join(":"); + } - /** - * Serialize the expression - * @return {string} the expression as a string - */ +}; - Expression.prototype.serialize = function() { - return Expression.normalize(this.expressions.join("_")); - }; +/* harmony default export */ __webpack_exports__["default"] = (Layer); - Expression.prototype.toString = function() { - return this.serialize(); - }; +/***/ }), - /** - * Get the parent transformation of this expression - * @return Transformation - */ +/***/ "./src/layer/subtitleslayer.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - Expression.prototype.getParent = function() { - return this.parent; - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _textlayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/layer/textlayer.js"); - /** - * Set the parent transformation of this expression - * @param {Transformation} the parent transformation - * @return {Expression} this expression - */ +const SubtitlesLayer = class SubtitlesLayer extends _textlayer__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * Represent a subtitles layer + * @constructor SubtitlesLayer + * @param {Object} options - layer parameters + */ + constructor(options) { + super(options); + this.options.resourceType = "subtitles"; + } - Expression.prototype.setParent = function(parent) { - this.parent = parent; - return this; - }; +}; +/* harmony default export */ __webpack_exports__["default"] = (SubtitlesLayer); - /** - * Add a expression - * @function Expression#predicate - * @internal - */ +/***/ }), - Expression.prototype.predicate = function(name, operator, value) { - if (Expression.OPERATORS[operator] != null) { - operator = Expression.OPERATORS[operator]; - } - this.expressions.push(name + "_" + operator + "_" + value); - return this; - }; +/***/ "./src/layer/textlayer.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/layer/layer.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/util/jquery.js"); - /** - * @function Expression#and - */ - Expression.prototype.and = function() { - this.expressions.push("and"); - return this; - }; - /** - * @function Expression#or - */ +var TextLayer = class TextLayer extends _layer__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * @constructor TextLayer + * @param {Object} options - layer parameters + */ + constructor(options) { + var keys; + super(options); + keys = ["resourceType", "resourceType", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecoration", "textAlign", "stroke", "letterSpacing", "lineSpacing", "text"]; + if (options != null) { + keys.forEach((key) => { + var ref; + return this.options[key] = (ref = options[key]) != null ? ref : options[Object(_util__WEBPACK_IMPORTED_MODULE_1__["snakeCase"])(key)]; + }); + } + this.options.resourceType = "text"; + } - Expression.prototype.or = function() { - this.expressions.push("or"); - return this; - }; + resourceType(resourceType) { + throw "Cannot modify resourceType for text layers"; + } + type(type) { + throw "Cannot modify type for text layers"; + } - /** - * Conclude expression - * @function Expression#then - * @return {Transformation} the transformation this expression is defined for - */ + format(format) { + throw "Cannot modify format for text layers"; + } - Expression.prototype.then = function() { - return this.getParent()["if"](this.toString()); - }; + fontFamily(fontFamily) { + this.options.fontFamily = fontFamily; + return this; + } + fontSize(fontSize) { + this.options.fontSize = fontSize; + return this; + } - /** - * @function Expression#height - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Expression} this expression - */ + fontWeight(fontWeight) { + this.options.fontWeight = fontWeight; + return this; + } - Expression.prototype.height = function(operator, value) { - return this.predicate("h", operator, value); - }; + fontStyle(fontStyle) { + this.options.fontStyle = fontStyle; + return this; + } + textDecoration(textDecoration) { + this.options.textDecoration = textDecoration; + return this; + } - /** - * @function Expression#width - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Expression} this expression - */ + textAlign(textAlign) { + this.options.textAlign = textAlign; + return this; + } - Expression.prototype.width = function(operator, value) { - return this.predicate("w", operator, value); - }; + stroke(stroke) { + this.options.stroke = stroke; + return this; + } + letterSpacing(letterSpacing) { + this.options.letterSpacing = letterSpacing; + return this; + } - /** - * @function Expression#aspectRatio - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Expression} this expression - */ + lineSpacing(lineSpacing) { + this.options.lineSpacing = lineSpacing; + return this; + } - Expression.prototype.aspectRatio = function(operator, value) { - return this.predicate("ar", operator, value); - }; + text(text) { + this.options.text = text; + return this; + } + /** + * generate the string representation of the layer + * @function TextLayer#toString + * @return {String} + */ + toString() { + var components, hasPublicId, hasStyle, publicId, re, res, start, style, text, textSource; + style = this.textStyleIdentifier(); + if (this.options.publicId != null) { + publicId = this.getFullPublicId(); + } + if (this.options.text != null) { + hasPublicId = !Object(_util__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(publicId); + hasStyle = !Object(_util__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(style); + if (hasPublicId && hasStyle || !hasPublicId && !hasStyle) { + throw "Must supply either style parameters or a public_id when providing text parameter in a text overlay/underlay, but not both!"; + } + re = /\$\([a-zA-Z]\w*\)/g; + start = 0; + // textSource = text.replace(new RegExp("[,/]", 'g'), (c)-> "%#{c.charCodeAt(0).toString(16).toUpperCase()}") + textSource = Object(_util__WEBPACK_IMPORTED_MODULE_1__["smartEscape"])(this.options.text, /[,\/]/g); + text = ""; + while (res = re.exec(textSource)) { + text += Object(_util__WEBPACK_IMPORTED_MODULE_1__["smartEscape"])(textSource.slice(start, res.index)); + text += res[0]; + start = res.index + res[0].length; + } + text += Object(_util__WEBPACK_IMPORTED_MODULE_1__["smartEscape"])(textSource.slice(start)); + } + components = [this.options.resourceType, style, publicId, text]; + return Object(_util__WEBPACK_IMPORTED_MODULE_1__["compact"])(components).join(":"); + } - /** - * @function Expression#pages - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Expression} this expression - */ + textStyleIdentifier() { + var components; + components = []; + if (this.options.fontWeight !== "normal") { + components.push(this.options.fontWeight); + } + if (this.options.fontStyle !== "normal") { + components.push(this.options.fontStyle); + } + if (this.options.textDecoration !== "none") { + components.push(this.options.textDecoration); + } + components.push(this.options.textAlign); + if (this.options.stroke !== "none") { + components.push(this.options.stroke); + } + if (!(Object(_util__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(this.options.letterSpacing) && !Object(_util__WEBPACK_IMPORTED_MODULE_1__["isNumberLike"])(this.options.letterSpacing))) { + components.push("letter_spacing_" + this.options.letterSpacing); + } + if (!(Object(_util__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(this.options.lineSpacing) && !Object(_util__WEBPACK_IMPORTED_MODULE_1__["isNumberLike"])(this.options.lineSpacing))) { + components.push("line_spacing_" + this.options.lineSpacing); + } + if (!Object(_util__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(Object(_util__WEBPACK_IMPORTED_MODULE_1__["compact"])(components))) { + if (Object(_util__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(this.options.fontFamily)) { + throw `Must supply fontFamily. ${components}`; + } + if (Object(_util__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(this.options.fontSize) && !Object(_util__WEBPACK_IMPORTED_MODULE_1__["isNumberLike"])(this.options.fontSize)) { + throw "Must supply fontSize."; + } + } + components.unshift(this.options.fontFamily, this.options.fontSize); + components = Object(_util__WEBPACK_IMPORTED_MODULE_1__["compact"])(components).join("_"); + return components; + } - Expression.prototype.pageCount = function(operator, value) { - return this.predicate("pc", operator, value); - }; +}; +/* harmony default export */ __webpack_exports__["default"] = (TextLayer); - /** - * @function Expression#faces - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Expression} this expression - */ - Expression.prototype.faceCount = function(operator, value) { - return this.predicate("fc", operator, value); - }; +/***/ }), - Expression.prototype.value = function(value) { - this.expressions.push(value); - return this; - }; +/***/ "./src/namespace/cloudinary-jquery-file-upload.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _utf8_encode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utf8_encode.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "utf8_encode", function() { return _utf8_encode__WEBPACK_IMPORTED_MODULE_0__["default"]; }); - /** - */ +/* harmony import */ var _crc32__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/crc32.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "crc32", function() { return _crc32__WEBPACK_IMPORTED_MODULE_1__["default"]; }); - Expression.variable = function(name, value) { - return new this(name).value(value); - }; +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/util/jquery.js"); +/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "Util", function() { return _util__WEBPACK_IMPORTED_MODULE_2__; }); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/transformation.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Transformation", function() { return _transformation__WEBPACK_IMPORTED_MODULE_3__["default"]; }); +/* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/condition.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_4__["default"]; }); - /** - * @returns a new expression with the predefined variable "width" - * @function Expression.width - */ +/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/configuration.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Configuration", function() { return _configuration__WEBPACK_IMPORTED_MODULE_5__["default"]; }); - Expression.width = function() { - return new this("width"); - }; +/* harmony import */ var _tags_htmltag__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./src/tags/htmltag.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlTag", function() { return _tags_htmltag__WEBPACK_IMPORTED_MODULE_6__["default"]; }); +/* harmony import */ var _tags_imagetag__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("./src/tags/imagetag.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageTag", function() { return _tags_imagetag__WEBPACK_IMPORTED_MODULE_7__["default"]; }); - /** - * @returns a new expression with the predefined variable "height" - * @function Expression.height - */ +/* harmony import */ var _tags_picturetag__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__("./src/tags/picturetag.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PictureTag", function() { return _tags_picturetag__WEBPACK_IMPORTED_MODULE_8__["default"]; }); - Expression.height = function() { - return new this("height"); - }; +/* harmony import */ var _tags_videotag__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__("./src/tags/videotag.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTag", function() { return _tags_videotag__WEBPACK_IMPORTED_MODULE_9__["default"]; }); +/* harmony import */ var _tags_clienthintsmetatag__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__("./src/tags/clienthintsmetatag.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClientHintsMetaTag", function() { return _tags_clienthintsmetatag__WEBPACK_IMPORTED_MODULE_10__["default"]; }); - /** - * @returns a new expression with the predefined variable "initialWidth" - * @function Expression.initialWidth - */ +/* harmony import */ var _layer_layer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__("./src/layer/layer.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer_layer__WEBPACK_IMPORTED_MODULE_11__["default"]; }); - Expression.initialWidth = function() { - return new this("initialWidth"); - }; +/* harmony import */ var _layer_fetchlayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__("./src/layer/fetchlayer.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FetchLayer", function() { return _layer_fetchlayer__WEBPACK_IMPORTED_MODULE_12__["default"]; }); +/* harmony import */ var _layer_textlayer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__("./src/layer/textlayer.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextLayer", function() { return _layer_textlayer__WEBPACK_IMPORTED_MODULE_13__["default"]; }); - /** - * @returns a new expression with the predefined variable "initialHeight" - * @function Expression.initialHeight - */ - - Expression.initialHeight = function() { - return new this("initialHeight"); - }; +/* harmony import */ var _layer_subtitleslayer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__("./src/layer/subtitleslayer.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubtitlesLayer", function() { return _layer_subtitleslayer__WEBPACK_IMPORTED_MODULE_14__["default"]; }); +/* harmony import */ var _cloudinary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__("./src/cloudinary.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Cloudinary", function() { return _cloudinary__WEBPACK_IMPORTED_MODULE_15__["default"]; }); - /** - * @returns a new expression with the predefined variable "aspectRatio" - * @function Expression.aspectRatio - */ +/* harmony import */ var _jquery_file_upload__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__("./src/jquery-file-upload.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CloudinaryJQuery", function() { return _jquery_file_upload__WEBPACK_IMPORTED_MODULE_16__["default"]; }); - Expression.aspectRatio = function() { - return new this("aspectRatio"); - }; + /** + * Creates the namespace for Cloudinary + */ - /** - * @returns a new expression with the predefined variable "initialAspectRatio" - * @function Expression.initialAspectRatio - */ - Expression.initialAspectRatio = function() { - return new this("initialAspectRatio"); - }; - /** - * @returns a new expression with the predefined variable "pageCount" - * @function Expression.pageCount - */ - Expression.pageCount = function() { - return new this("pageCount"); - }; - /** - * @returns a new expression with the predefined variable "faceCount" - * @function Expression.faceCount - */ - faceCount = function() { - return new this("faceCount"); - }; - /** - * @returns a new expression with the predefined variable "currentPage" - * @function Expression.currentPage - */ - Expression.currentPage = function() { - return new this("currentPage"); - }; - /** - * @returns a new expression with the predefined variable "tags" - * @function Expression.tags - */ - Expression.tags = function() { - return new this("tags"); - }; - /** - * @returns a new expression with the predefined variable "pageX" - * @function Expression.pageX - */ - Expression.pageX = function() { - return new this("pageX"); - }; - /** - * @returns a new expression with the predefined variable "pageY" - * @function Expression.pageY - */ - Expression.pageY = function() { - return new this("pageY"); - }; - return Expression; - })(); - Condition = (function(superClass) { - extend(Condition, superClass); - /** - * Represents a transformation condition - * @param {string} conditionStr - a condition in string format - * @class Condition - * @example - * // normally this class is not instantiated directly - * var tr = cloudinary.Transformation.new() - * .if().width( ">", 1000).and().aspectRatio("<", "3:4").then() - * .width(1000) - * .crop("scale") - * .else() - * .width(500) - * .crop("scale") - * - * var tr = cloudinary.Transformation.new() - * .if("w > 1000 and aspectRatio < 3:4") - * .width(1000) - * .crop("scale") - * .else() - * .width(500) - * .crop("scale") - * - */ - function Condition(conditionStr) { - Condition.__super__.constructor.call(this, conditionStr); - } - /** - * @function Condition#height - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Condition} this condition - */ - Condition.prototype.height = function(operator, value) { - return this.predicate("h", operator, value); - }; - /** - * @function Condition#width - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Condition} this condition - */ - Condition.prototype.width = function(operator, value) { - return this.predicate("w", operator, value); - }; - /** - * @function Condition#aspectRatio - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Condition} this condition - */ - Condition.prototype.aspectRatio = function(operator, value) { - return this.predicate("ar", operator, value); - }; - /** - * @function Condition#pages - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Condition} this condition - */ +/***/ }), - Condition.prototype.pageCount = function(operator, value) { - return this.predicate("pc", operator, value); - }; +/***/ "./src/parameters.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Param", function() { return Param; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayParam", function() { return ArrayParam; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformationParam", function() { return TransformationParam; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RangeParam", function() { return RangeParam; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawParam", function() { return RawParam; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerParam", function() { return LayerParam; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExpressionParam", function() { return ExpressionParam; }); +/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/expression.js"); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/transformation.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _layer_layer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/layer/layer.js"); +/* harmony import */ var _layer_textlayer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/layer/textlayer.js"); +/* harmony import */ var _layer_subtitleslayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/layer/subtitleslayer.js"); +/* harmony import */ var _layer_fetchlayer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./src/layer/fetchlayer.js"); - /** - * @function Condition#faces - * @param {string} operator the comparison operator (e.g. "<", "lt") - * @param {string|number} value the right hand side value - * @return {Condition} this condition - */ - Condition.prototype.faceCount = function(operator, value) { - return this.predicate("fc", operator, value); - }; - return Condition; - })(Expression); - /** - * Cloudinary configuration class - * Depends on 'utils' - */ - Configuration = (function() { - /** - * Defaults configuration. - */ - var DEFAULT_CONFIGURATION_PARAMS, ref; - DEFAULT_CONFIGURATION_PARAMS = { - responsive_class: 'cld-responsive', - responsive_use_breakpoints: true, - round_dpr: true, - secure: (typeof window !== "undefined" && window !== null ? (ref = window.location) != null ? ref.protocol : void 0 : void 0) === 'https:' - }; - Configuration.CONFIG_PARAMS = ["api_key", "api_secret", "callback", "cdn_subdomain", "cloud_name", "cname", "private_cdn", "protocol", "resource_type", "responsive", "responsive_class", "responsive_use_breakpoints", "responsive_width", "round_dpr", "secure", "secure_cdn_subdomain", "secure_distribution", "shorten", "type", "upload_preset", "url_suffix", "use_root_path", "version"]; - /** - * Cloudinary configuration class - * @constructor Configuration - * @param {Object} options - configuration parameters - */ - function Configuration(options) { - if (options == null) { - options = {}; - } - this.configuration = Util.cloneDeep(options); - Util.defaults(this.configuration, DEFAULT_CONFIGURATION_PARAMS); - } +/** + * Transformation parameters + * Depends on 'util', 'transformation' + */ +var Param = class Param { + /** + * Represents a single parameter + * @class Param + * @param {string} name - The name of the parameter in snake_case + * @param {string} shortName - The name of the serialized form of the parameter. + * If a value is not provided, the parameter will not be serialized. + * @param {function} [process=Util.identity ] - Manipulate origValue when value is called + * @ignore + */ + constructor(name, shortName, process = _util__WEBPACK_IMPORTED_MODULE_2__["identity"]) { /** - * Initialize the configuration. - * The function first tries to retrieve the configuration form the environment and then from the document. - * @function Configuration#init - * @return {Configuration} returns this for chaining - * @see fromDocument - * @see fromEnvironment + * The name of the parameter in snake_case + * @member {string} Param#name */ - - Configuration.prototype.init = function() { - this.fromEnvironment(); - this.fromDocument(); - return this; - }; - - + this.name = name; /** - * Set a new configuration item - * @function Configuration#set - * @param {string} name - the name of the item to set - * @param {*} value - the value to be set - * @return {Configuration} - * + * The name of the serialized form of the parameter + * @member {string} Param#shortName */ - - Configuration.prototype.set = function(name, value) { - this.configuration[name] = value; - return this; - }; - - + this.shortName = shortName; /** - * Get the value of a configuration item - * @function Configuration#get - * @param {string} name - the name of the item to set - * @return {*} the configuration item + * Manipulate origValue when value is called + * @member {function} Param#process */ + this.process = process; + } - Configuration.prototype.get = function(name) { - return this.configuration[name]; - }; - - Configuration.prototype.merge = function(config) { - if (config == null) { - config = {}; - } - Util.assign(this.configuration, Util.cloneDeep(config)); - return this; - }; - + /** + * Set a (unprocessed) value for this parameter + * @function Param#set + * @param {*} origValue - the value of the parameter + * @return {Param} self for chaining + */ + set(origValue) { + this.origValue = origValue; + return this; + } - /** - * Initialize Cloudinary from HTML meta tags. - * @function Configuration#fromDocument - * @return {Configuration} - * @example - * - */ + /** + * Generate the serialized form of the parameter + * @function Param#serialize + * @return {string} the serialized form of the parameter + */ + serialize() { + var val, valid; + val = this.value(); + valid = Object(_util__WEBPACK_IMPORTED_MODULE_2__["isArray"])(val) || Object(_util__WEBPACK_IMPORTED_MODULE_2__["isPlainObject"])(val) || Object(_util__WEBPACK_IMPORTED_MODULE_2__["isString"])(val) ? !Object(_util__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(val) : val != null; + if ((this.shortName != null) && valid) { + return `${this.shortName}_${val}`; + } else { + return ''; + } + } - Configuration.prototype.fromDocument = function() { - var el, j, len, meta_elements; - meta_elements = typeof document !== "undefined" && document !== null ? document.querySelectorAll('meta[name^="cloudinary_"]') : void 0; - if (meta_elements) { - for (j = 0, len = meta_elements.length; j < len; j++) { - el = meta_elements[j]; - this.configuration[el.getAttribute('name').replace('cloudinary_', '')] = el.getAttribute('content'); - } - } - return this; - }; + /** + * Return the processed value of the parameter + * @function Param#value + */ + value() { + return this.process(this.origValue); + } + static norm_color(value) { + return value != null ? value.replace(/^#/, 'rgb:') : void 0; + } - /** - * Initialize Cloudinary from the `CLOUDINARY_URL` environment variable. - * - * This function will only run under Node.js environment. - * @function Configuration#fromEnvironment - * @requires Node.js - */ + build_array(arg = []) { + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isArray"])(arg)) { + return arg; + } else { + return [arg]; + } + } - Configuration.prototype.fromEnvironment = function() { - var cloudinary_url, j, k, len, query, ref1, ref2, ref3, uri, uriRegex, v, value; - cloudinary_url = typeof process !== "undefined" && process !== null ? (ref1 = process.env) != null ? ref1.CLOUDINARY_URL : void 0 : void 0; - if (cloudinary_url != null) { - uriRegex = /cloudinary:\/\/(?:(\w+)(?:\:([\w-]+))?@)?([\w\.-]+)(?:\/([^?]*))?(?:\?(.+))?/; - uri = uriRegex.exec(cloudinary_url); - if (uri) { - if (uri[3] != null) { - this.configuration['cloud_name'] = uri[3]; - } - if (uri[1] != null) { - this.configuration['api_key'] = uri[1]; - } - if (uri[2] != null) { - this.configuration['api_secret'] = uri[2]; - } - if (uri[4] != null) { - this.configuration['private_cdn'] = uri[4] != null; - } - if (uri[4] != null) { - this.configuration['secure_distribution'] = uri[4]; - } - query = uri[5]; - if (query != null) { - ref2 = query.split('&'); - for (j = 0, len = ref2.length; j < len; j++) { - value = ref2[j]; - ref3 = value.split('='), k = ref3[0], v = ref3[1]; - if (v == null) { - v = true; - } - this.configuration[k] = v; + /** + * Covert value to video codec string. + * + * If the parameter is an object, + * @param {(string|Object)} param - the video codec as either a String or a Hash + * @return {string} the video codec string in the format codec:profile:level + * @example + * vc_[ :profile : [level]] + * or + { codec: 'h264', profile: 'basic', level: '3.1' } + * @ignore + */ + static process_video_params(param) { + var video; + switch (param.constructor) { + case Object: + video = ""; + if ('codec' in param) { + video = param['codec']; + if ('profile' in param) { + video += ":" + param['profile']; + if ('level' in param) { + video += ":" + param['level']; } } } - } - return this; - }; + return video; + case String: + return param; + default: + return null; + } + } +}; - /** - * Create or modify the Cloudinary client configuration - * - * Warning: `config()` returns the actual internal configuration object. modifying it will change the configuration. - * - * This is a backward compatibility method. For new code, use get(), merge() etc. - * @function Configuration#config - * @param {hash|string|boolean} new_config - * @param {string} new_value - * @returns {*} configuration, or value - * - * @see {@link fromEnvironment} for initialization using environment variables - * @see {@link fromDocument} for initialization using HTML meta tags - */ +var ArrayParam = class ArrayParam extends Param { + /** + * A parameter that represents an array + * @param {string} name - The name of the parameter in snake_case + * @param {string} shortName - The name of the serialized form of the parameter + * If a value is not provided, the parameter will not be serialized. + * @param {string} [sep='.'] - The separator to use when joining the array elements together + * @param {function} [process=Util.identity ] - Manipulate origValue when value is called + * @class ArrayParam + * @extends Param + * @ignore + */ + constructor(name, shortName, sep = '.', process) { + super(name, shortName, process); + this.sep = sep; + } - Configuration.prototype.config = function(new_config, new_value) { - switch (false) { - case new_value === void 0: - this.set(new_config, new_value); - return this.configuration; - case !Util.isString(new_config): - return this.get(new_config); - case !Util.isPlainObject(new_config): - this.merge(new_config); - return this.configuration; - default: - return this.configuration; + serialize() { + if (this.shortName != null) { + let arrayValue = this.value(); + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(arrayValue)) { + return ''; + } else if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isString"])(arrayValue)) { + return `${this.shortName}_${arrayValue}`; + } else { + let flat = arrayValue.map(t=>Object(_util__WEBPACK_IMPORTED_MODULE_2__["isFunction"])(t.serialize) ? t.serialize() : t).join(this.sep); + return `${this.shortName}_${flat}`; } - }; + } else { + return ''; + } + } + value() { + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isArray"])(this.origValue)) { + return this.origValue.map(v=>this.process(v)); + } else { + return this.process(this.origValue); + } + } - /** - * Returns a copy of the configuration parameters - * @function Configuration#toOptions - * @returns {Object} a key:value collection of the configuration parameters - */ + set(origValue) { + if ((origValue == null) || Object(_util__WEBPACK_IMPORTED_MODULE_2__["isArray"])(origValue)) { + return super.set(origValue); + } else { + return super.set([origValue]); + } + } - Configuration.prototype.toOptions = function() { - return Util.cloneDeep(this.configuration); - }; +}; + +var TransformationParam = class TransformationParam extends Param { + /** + * A parameter that represents a transformation + * @param {string} name - The name of the parameter in snake_case + * @param {string} [shortName='t'] - The name of the serialized form of the parameter + * @param {string} [sep='.'] - The separator to use when joining the array elements together + * @param {function} [process=Util.identity ] - Manipulate origValue when value is called + * @class TransformationParam + * @extends Param + * @ignore + */ + constructor(name, shortName = "t", sep = '.', process) { + super(name, shortName, process); + this.sep = sep; + } + + serialize() { + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(this.value())) { + return ''; + } else if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["allStrings"])(this.value())) { + let joined = this.value().join(this.sep); + if (!Object(_util__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(joined)) { + return `${this.shortName}_${joined}`; + } else { + return ''; + } + } else { + return this.value().map(t=>{ + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isString"])(t) && !Object(_util__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(t)) { + return `${this.shortName}_${t}`; + } else if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isFunction"])(t.serialize)) { + return t.serialize(); + } else if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isPlainObject"])(t) && !Object(_util__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(t)) { + return new _transformation__WEBPACK_IMPORTED_MODULE_1__["default"](t).serialize(); + } else { + return undefined; + } + }).filter(t=>t); + } + } - return Configuration; + set(origValue1) { + this.origValue = origValue1; + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isArray"])(this.origValue)) { + return super.set(this.origValue); + } else { + return super.set([this.origValue]); + } + } - })(); +}; +var RangeParam = class RangeParam extends Param { /** - * TransformationBase - * Depends on 'configuration', 'parameters','util' - * @internal + * A parameter that represents a range + * @param {string} name - The name of the parameter in snake_case + * @param {string} shortName - The name of the serialized form of the parameter + * If a value is not provided, the parameter will not be serialized. + * @param {function} [process=norm_range_value ] - Manipulate origValue when value is called + * @class RangeParam + * @extends Param + * @ignore */ - TransformationBase = (function() { - var VAR_NAME_RE, lastArgCallback, processVar; + constructor(name, shortName, process) { + super(name, shortName, process); + this.process || (this.process = this.norm_range_value); + } + + static norm_range_value(value) { + var modifier, offset; + offset = String(value).match(new RegExp('^' + offset_any_pattern + '$')); + if (offset) { + modifier = offset[5] != null ? 'p' : ''; + value = (offset[1] || offset[4]) + modifier; + } + return value; + } - VAR_NAME_RE = /^\$[a-zA-Z0-9]+$/; +}; - TransformationBase.prototype.trans_separator = '/'; +var RawParam = class RawParam extends Param { + constructor(name, shortName, process = _util__WEBPACK_IMPORTED_MODULE_2__["identity"]) { + super(name, shortName, process); + } - TransformationBase.prototype.param_separator = ','; + serialize() { + return this.value(); + } - lastArgCallback = function(args) { - var callback; - callback = args != null ? args[args.length - 1] : void 0; - if (Util.isFunction(callback)) { - return callback; +}; + +const LAYER_KEYWORD_PARAMS = [ + ["font_weight", "normal"], + ["font_style", "normal"], + ["text_decoration", "none"], + ["text_align", null], + ["stroke", "none"], + ["letter_spacing", null], + ["line_spacing", null] +]; + +class LayerParam extends Param { + // Parse layer options + // @return [string] layer transformation string + // @private + value() { + let result; + let layerOptions = this.origValue; + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isPlainObject"])(layerOptions)) { + layerOptions = Object(_util__WEBPACK_IMPORTED_MODULE_2__["withCamelCaseKeys"])(layerOptions); + if (layerOptions.resourceType === "text" || (layerOptions.text != null)) { + result = new _layer_textlayer__WEBPACK_IMPORTED_MODULE_4__["default"](layerOptions).toString(); + } else if (layerOptions.resourceType === "subtitles") { + result = new _layer_subtitleslayer__WEBPACK_IMPORTED_MODULE_5__["default"](layerOptions).toString(); + } else if (layerOptions.resourceType === "fetch" || (layerOptions.url != null)) { + result = new _layer_fetchlayer__WEBPACK_IMPORTED_MODULE_6__["default"](layerOptions).toString(); } else { - return void 0; + result = new _layer_layer__WEBPACK_IMPORTED_MODULE_3__["default"](layerOptions).toString(); } - }; + } else if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isString"])(layerOptions) && /^fetch:.+/.test(layerOptions)) { + result = new _layer_fetchlayer__WEBPACK_IMPORTED_MODULE_6__["default"](layerOptions.substr(6)).toString(); + } else { + result = layerOptions; + } + return result; + } + textStyle(layer) { + return (new _layer_textlayer__WEBPACK_IMPORTED_MODULE_4__["default"](layer)).textStyleIdentifier(); + } - /** - * The base class for transformations. - * Members of this class are documented as belonging to the {@link Transformation} class for convenience. - * @class TransformationBase - */ +} - function TransformationBase(options) { - var parent, trans; - if (options == null) { - options = {}; - } +var ExpressionParam = class ExpressionParam extends Param { + serialize() { + return _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize(super.serialize()); + } - /** @private */ - parent = void 0; +}; - /** @private */ - trans = {}; - /** - * Return an options object that can be used to create an identical Transformation - * @function Transformation#toOptions - * @return {Object} Returns a plain object representing this transformation - */ - this.toOptions || (this.toOptions = function(withChain) { - var key, list, opt, ref, ref1, tr, value; - if (withChain == null) { - withChain = true; - } - opt = {}; - for (key in trans) { - value = trans[key]; - opt[key] = value.origValue; - } - ref = this.otherOptions; - for (key in ref) { - value = ref[key]; - if (value !== void 0) { - opt[key] = value; - } - } - if (withChain && !Util.isEmpty(this.chained)) { - list = (function() { - var j, len, ref1, results; - ref1 = this.chained; - results = []; - for (j = 0, len = ref1.length; j < len; j++) { - tr = ref1[j]; - results.push(tr.toOptions()); - } - return results; - }).call(this); - list.push(opt); - opt = {}; - ref1 = this.otherOptions; - for (key in ref1) { - value = ref1[key]; - if (value !== void 0) { - opt[key] = value; - } - } - opt.transformation = list; - } - return opt; - }); - /** - * Set a parent for this object for chaining purposes. - * - * @function Transformation#setParent - * @param {Object} object - the parent to be assigned to - * @returns {Transformation} Returns this instance for chaining purposes. - */ - this.setParent || (this.setParent = function(object) { - parent = object; - if (object != null) { - this.fromOptions(typeof object.toOptions === "function" ? object.toOptions() : void 0); - } - return this; - }); - /** - * Returns the parent of this object in the chain - * @function Transformation#getParent - * @protected - * @return {Object} Returns the parent of this object if there is any - */ - this.getParent || (this.getParent = function() { - return parent; - }); +/***/ }), - /** @protected */ - this.param || (this.param = function(value, name, abbr, defaultValue, process) { - if (process == null) { - if (Util.isFunction(defaultValue)) { - process = defaultValue; - } else { - process = Util.identity; - } - } - trans[name] = new Param(name, abbr, process).set(value); - return this; - }); +/***/ "./src/tags/clienthintsmetatag.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** @protected */ - this.rawParam || (this.rawParam = function(value, name, abbr, defaultValue, process) { - if (process == null) { - process = Util.identity; - } - process = lastArgCallback(arguments); - trans[name] = new RawParam(name, abbr, process).set(value); - return this; - }); +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _htmltag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/tags/htmltag.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/util/jquery.js"); +/** + * Image Tag + * Depends on 'tags/htmltag', 'cloudinary' + */ - /** @protected */ - this.rangeParam || (this.rangeParam = function(value, name, abbr, defaultValue, process) { - if (process == null) { - process = Util.identity; - } - process = lastArgCallback(arguments); - trans[name] = new RangeParam(name, abbr, process).set(value); - return this; - }); - /** @protected */ - this.arrayParam || (this.arrayParam = function(value, name, abbr, sep, defaultValue, process) { - if (sep == null) { - sep = ":"; - } - if (defaultValue == null) { - defaultValue = []; - } - if (process == null) { - process = Util.identity; - } - process = lastArgCallback(arguments); - trans[name] = new ArrayParam(name, abbr, sep, process).set(value); - return this; - }); - /** @protected */ - this.transformationParam || (this.transformationParam = function(value, name, abbr, sep, defaultValue, process) { - if (sep == null) { - sep = "."; - } - if (process == null) { - process = Util.identity; - } - process = lastArgCallback(arguments); - trans[name] = new TransformationParam(name, abbr, sep, process).set(value); - return this; - }); - this.layerParam || (this.layerParam = function(value, name, abbr) { - trans[name] = new LayerParam(name, abbr).set(value); - return this; - }); - /** - * Get the value associated with the given name. - * @function Transformation#getValue - * @param {string} name - the name of the parameter - * @return {*} the processed value associated with the given name - * @description Use {@link get}.origValue for the value originally provided for the parameter - */ - this.getValue || (this.getValue = function(name) { - var ref, ref1; - return (ref = (ref1 = trans[name]) != null ? ref1.value() : void 0) != null ? ref : this.otherOptions[name]; - }); - /** - * Get the parameter object for the given parameter name - * @function Transformation#get - * @param {string} name the name of the transformation parameter - * @returns {Param} the param object for the given name, or undefined - */ - this.get || (this.get = function(name) { - return trans[name]; - }); +var ClientHintsMetaTag = class ClientHintsMetaTag extends _htmltag__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * Creates an HTML (DOM) Meta tag that enables client-hints. + * @constructor ClientHintsMetaTag + * @extends HtmlTag + */ + constructor(options) { + super('meta', void 0, Object(_util__WEBPACK_IMPORTED_MODULE_1__["assign"])({ + "http-equiv": "Accept-CH", + content: "DPR, Viewport-Width, Width" + }, options)); + } - /** - * Remove a transformation option from the transformation. - * @function Transformation#remove - * @param {string} name - the name of the option to remove - * @return {*} Returns the option that was removed or null if no option by that name was found. The type of the - * returned value depends on the value. - */ - this.remove || (this.remove = function(name) { - var temp; - switch (false) { - case trans[name] == null: - temp = trans[name]; - delete trans[name]; - return temp.origValue; - case this.otherOptions[name] == null: - temp = this.otherOptions[name]; - delete this.otherOptions[name]; - return temp; - default: - return null; - } - }); + /** @override */ + closeTag() { + return ""; + } - /** - * Return an array of all the keys (option names) in the transformation. - * @return {Array} the keys in snakeCase format - */ - this.keys || (this.keys = function() { - var key; - return ((function() { - var results; - results = []; - for (key in trans) { - if (key != null) { - results.push(key.match(VAR_NAME_RE) ? key : Util.snakeCase(key)); - } - } - return results; - })()).sort(); - }); +}; - /** - * Returns a plain object representation of the transformation. Values are processed. - * @function Transformation#toPlainObject - * @return {Object} the transformation options as plain object - */ - this.toPlainObject || (this.toPlainObject = function() { - var hash, key, list, tr; - hash = {}; - for (key in trans) { - hash[key] = trans[key].value(); - if (Util.isPlainObject(hash[key])) { - hash[key] = Util.cloneDeep(hash[key]); - } - } - if (!Util.isEmpty(this.chained)) { - list = (function() { - var j, len, ref, results; - ref = this.chained; - results = []; - for (j = 0, len = ref.length; j < len; j++) { - tr = ref[j]; - results.push(tr.toPlainObject()); - } - return results; - }).call(this); - list.push(hash); - hash = { - transformation: list - }; - } - return hash; - }); +/* harmony default export */ __webpack_exports__["default"] = (ClientHintsMetaTag); - /** - * Complete the current transformation and chain to a new one. - * In the URL, transformations are chained together by slashes. - * @function Transformation#chain - * @return {Transformation} Returns this transformation for chaining - * @example - * var tr = cloudinary.Transformation.new(); - * tr.width(10).crop('fit').chain().angle(15).serialize() - * // produces "c_fit,w_10/a_15" - */ - this.chain || (this.chain = function() { - var names, tr; - names = Object.getOwnPropertyNames(trans); - if (names.length !== 0) { - tr = new this.constructor(this.toOptions(false)); - this.resetTransformations(); - this.chained.push(tr); - } - return this; - }); - this.resetTransformations || (this.resetTransformations = function() { - trans = {}; - return this; - }); - this.otherOptions || (this.otherOptions = {}); - this.chained = []; - if (!Util.isEmpty(options)) { - this.fromOptions(options); - } - } +/***/ }), - /** - * Merge the provided options with own's options - * @param {Object} [options={}] key-value list of options - * @returns {Transformation} Returns this instance for chaining - */ +/***/ "./src/tags/htmltag.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - TransformationBase.prototype.fromOptions = function(options) { - var key, opt; - if (options instanceof TransformationBase) { - this.fromTransformation(options); - } else { - options || (options = {}); - if (Util.isString(options) || Util.isArray(options)) { - options = { - transformation: options - }; - } - options = Util.cloneDeep(options, function(value) { - if (value instanceof TransformationBase) { - return new value.constructor(value.toOptions()); - } - }); - if (options["if"]) { - this.set("if", options["if"]); - delete options["if"]; - } - for (key in options) { - opt = options[key]; - if (key.match(VAR_NAME_RE)) { - if (key !== '$attr') { - this.set('variable', key, opt); - } - } else { - this.set(key, opt); - } - } - } - return this; - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/transformation.js"); +/** + * Generic HTML tag + * Depends on 'transformation', 'util' + */ - TransformationBase.prototype.fromTransformation = function(other) { - var j, key, len, ref; - if (other instanceof TransformationBase) { - ref = other.keys(); - for (j = 0, len = ref.length; j < len; j++) { - key = ref[j]; - this.set(key, other.get(key).origValue); - } - } - return this; - }; - /** - * Set a parameter. - * The parameter name `key` is converted to - * @param {string} key - the name of the parameter - * @param {*} value - the value of the parameter - * @returns {Transformation} Returns this instance for chaining - */ - TransformationBase.prototype.set = function() { - var camelKey, key, values; - key = arguments[0], values = 2 <= arguments.length ? slice.call(arguments, 1) : []; - camelKey = Util.camelCase(key); - if (Util.contains(Transformation.methods, camelKey)) { - this[camelKey].apply(this, values); + +var HtmlTag = class HtmlTag { + /** + * Represents an HTML (DOM) tag + * @constructor HtmlTag + * @param {string} name - the name of the tag + * @param {string} [publicId] + * @param {Object} options + * @example tag = new HtmlTag( 'div', { 'width': 10}) + */ + constructor(name, publicId, options) { + var transformation; + this.name = name; + this.publicId = publicId; + if (options == null) { + if (Object(_util__WEBPACK_IMPORTED_MODULE_0__["isPlainObject"])(publicId)) { + options = publicId; + this.publicId = void 0; } else { - this.otherOptions[key] = values[0]; + options = {}; } - return this; - }; - - TransformationBase.prototype.hasLayer = function() { - return this.getValue("overlay") || this.getValue("underlay"); + } + transformation = new _transformation__WEBPACK_IMPORTED_MODULE_1__["default"](options); + transformation.setParent(this); + this.transformation = function () { + return transformation; }; + } + /** + * Convenience constructor + * Creates a new instance of an HTML (DOM) tag + * @function HtmlTag.new + * @param {string} name - the name of the tag + * @param {string} [publicId] + * @param {Object} options + * @return {HtmlTag} + * @example tag = HtmlTag.new( 'div', { 'width': 10}) + */ + static new(name, publicId, options) { + return new this(name, publicId, options); + } - /** - * Generate a string representation of the transformation. - * @function Transformation#serialize - * @return {string} Returns the transformation as a string - */ - - TransformationBase.prototype.serialize = function() { - var ifParam, j, len, paramList, ref, ref1, ref2, ref3, ref4, resultArray, t, tr, transformationList, transformationString, transformations, value, variables, vars; - resultArray = (function() { - var j, len, ref, results; - ref = this.chained; - results = []; - for (j = 0, len = ref.length; j < len; j++) { - tr = ref[j]; - results.push(tr.serialize()); - } - return results; - }).call(this); - paramList = this.keys(); - transformations = (ref = this.get("transformation")) != null ? ref.serialize() : void 0; - ifParam = (ref1 = this.get("if")) != null ? ref1.serialize() : void 0; - variables = processVar((ref2 = this.get("variables")) != null ? ref2.value() : void 0); - paramList = Util.difference(paramList, ["transformation", "if", "variables"]); - vars = []; - transformationList = []; - for (j = 0, len = paramList.length; j < len; j++) { - t = paramList[j]; - if (t.match(VAR_NAME_RE)) { - vars.push(t + "_" + Expression.normalize((ref3 = this.get(t)) != null ? ref3.value() : void 0)); - } else { - transformationList.push((ref4 = this.get(t)) != null ? ref4.serialize() : void 0); - } - } - switch (false) { - case !Util.isString(transformations): - transformationList.push(transformations); - break; - case !Util.isArray(transformations): - resultArray = resultArray.concat(transformations); - } - transformationList = (function() { - var l, len1, results; - results = []; - for (l = 0, len1 = transformationList.length; l < len1; l++) { - value = transformationList[l]; - if (Util.isArray(value) && !Util.isEmpty(value) || !Util.isArray(value) && value) { - results.push(value); - } + /** + * combine key and value from the `attr` to generate an HTML tag attributes string. + * `Transformation::toHtmlTagOptions` is used to filter out transformation and configuration keys. + * @protected + * @param {Object} attrs + * @return {string} the attributes in the format `'key1="value1" key2="value2"'` + * @ignore + */ + htmlAttrs(attrs) { + var key, pairs, value; + return pairs = ((function () { + var results; + results = []; + for (key in attrs) { + value = attrs[key]; + if (value) { + results.push(toAttribute(key, value)); } - return results; - })(); - transformationList = vars.sort().concat(variables).concat(transformationList.sort()); - if (ifParam === "if_end") { - transformationList.push(ifParam); - } else if (!Util.isEmpty(ifParam)) { - transformationList.unshift(ifParam); - } - transformationString = Util.compact(transformationList).join(this.param_separator); - if (!Util.isEmpty(transformationString)) { - resultArray.push(transformationString); } - return Util.compact(resultArray).join(this.trans_separator); - }; + return results; + })()).sort().join(' '); + } + /** + * Get all options related to this tag. + * @function HtmlTag#getOptions + * @returns {Object} the options + * + */ + getOptions() { + return this.transformation().toOptions(); + } - /** - * Provide a list of all the valid transformation option names - * @function Transformation#listNames - * @private - * @return {Array} a array of all the valid option names - */ + /** + * Get the value of option `name` + * @function HtmlTag#getOption + * @param {string} name - the name of the option + * @returns {*} Returns the value of the option + * + */ + getOption(name) { + return this.transformation().getValue(name); + } - TransformationBase.prototype.listNames = function() { - return Transformation.methods; - }; + /** + * Get the attributes of the tag. + * @function HtmlTag#attributes + * @returns {Object} attributes + */ + attributes() { + // The attributes are be computed from the options every time this method is invoked. + let htmlAttributes = this.transformation().toHtmlAttributes(); + Object.keys(htmlAttributes ).forEach(key => { + if(Object(_util__WEBPACK_IMPORTED_MODULE_0__["isPlainObject"])(htmlAttributes[key])){ + delete htmlAttributes[key]; + } + }); + if( htmlAttributes.attributes) { + // Currently HTML attributes are defined both at the top level and under 'attributes' + Object(_util__WEBPACK_IMPORTED_MODULE_0__["merge"])(htmlAttributes, htmlAttributes.attributes); + delete htmlAttributes.attributes; + } + return htmlAttributes; + } - /** - * Returns attributes for an HTML tag. - * @function Cloudinary.toHtmlAttributes - * @return PlainObject - */ + /** + * Set a tag attribute named `name` to `value` + * @function HtmlTag#setAttr + * @param {string} name - the name of the attribute + * @param {string} value - the value of the attribute + */ + setAttr(name, value) { + this.transformation().set(`html_${name}`, value); + return this; + } - TransformationBase.prototype.toHtmlAttributes = function() { - var attrName, height, j, key, len, options, ref, ref1, ref2, ref3, value; - options = {}; - ref = this.otherOptions; - for (key in ref) { - value = ref[key]; - if (!(!Util.contains(Transformation.PARAM_NAMES, Util.snakeCase(key)))) { - continue; - } - attrName = /^html_/.test(key) ? key.slice(5) : key; - options[attrName] = value; - } - ref1 = this.keys(); - for (j = 0, len = ref1.length; j < len; j++) { - key = ref1[j]; - if (/^html_/.test(key)) { - options[Util.camelCase(key.slice(5))] = this.getValue(key); - } - } - if (!(this.hasLayer() || this.getValue("angle") || Util.contains(["fit", "limit", "lfill"], this.getValue("crop")))) { - width = (ref2 = this.get("width")) != null ? ref2.origValue : void 0; - height = (ref3 = this.get("height")) != null ? ref3.origValue : void 0; - if (parseFloat(width) >= 1.0) { - if (options['width'] == null) { - options['width'] = width; - } - } - if (parseFloat(height) >= 1.0) { - if (options['height'] == null) { - options['height'] = height; - } - } - } - return options; - }; + /** + * Get the value of the tag attribute `name` + * @function HtmlTag#getAttr + * @param {string} name - the name of the attribute + * @returns {*} + */ + getAttr(name) { + return this.attributes()[`html_${name}`] || this.attributes()[name]; + } - TransformationBase.prototype.isValidParamName = function(name) { - return Transformation.methods.indexOf(Util.camelCase(name)) >= 0; - }; + /** + * Remove the tag attributed named `name` + * @function HtmlTag#removeAttr + * @param {string} name - the name of the attribute + * @returns {*} + */ + removeAttr(name) { + var ref; + return (ref = this.transformation().remove(`html_${name}`)) != null ? ref : this.transformation().remove(name); + } + /** + * @function HtmlTag#content + * @protected + * @ignore + */ + content() { + return ""; + } - /** - * Delegate to the parent (up the call chain) to produce HTML - * @function Transformation#toHtml - * @return {string} HTML representation of the parent if possible. - * @example - * tag = cloudinary.ImageTag.new("sample", {cloud_name: "demo"}) - * // ImageTag {name: "img", publicId: "sample"} - * tag.toHtml() - * // - * tag.transformation().crop("fit").width(300).toHtml() - * // - */ + /** + * @function HtmlTag#openTag + * @protected + * @ignore + */ + openTag() { + let tag = "<" + this.name; + let htmlAttrs = this.htmlAttrs(this.attributes()); + if(htmlAttrs && htmlAttrs.length > 0) { + tag += " " + htmlAttrs + } + return tag + ">"; + } - TransformationBase.prototype.toHtml = function() { - var ref; - return (ref = this.getParent()) != null ? typeof ref.toHtml === "function" ? ref.toHtml() : void 0 : void 0; - }; + /** + * @function HtmlTag#closeTag + * @protected + * @ignore + */ + closeTag() { + return ``; + } - TransformationBase.prototype.toString = function() { - return this.serialize(); - }; + /** + * Generates an HTML representation of the tag. + * @function HtmlTag#toHtml + * @returns {string} Returns HTML in string format + */ + toHtml() { + return this.openTag() + this.content() + this.closeTag(); + } - processVar = function(varArray) { - var j, len, name, ref, results, v; - if (Util.isArray(varArray)) { - results = []; - for (j = 0, len = varArray.length; j < len; j++) { - ref = varArray[j], name = ref[0], v = ref[1]; - results.push(name + "_" + (Expression.normalize(v))); - } - return results; - } else { - return varArray; - } + /** + * Creates a DOM object representing the tag. + * @function HtmlTag#toDOM + * @returns {Element} + */ + toDOM() { + var element, name, ref, value; + if (!Object(_util__WEBPACK_IMPORTED_MODULE_0__["isFunction"])(typeof document !== "undefined" && document !== null ? document.createElement : void 0)) { + throw "Can't create DOM if document is not present!"; + } + element = document.createElement(this.name); + ref = this.attributes(); + for (name in ref) { + value = ref[name]; + element.setAttribute(name, value); + } + return element; + } - /** - * Transformation Class methods. - * This is a list of the parameters defined in Transformation. - * Values are camelCased. - * @const Transformation.methods - * @private - * @ignore - * @type {Array} - */ - - /** - * Parameters that are filtered out before passing the options to an HTML tag. - * - * The list of parameters is a combination of `Transformation::methods` and `Configuration::CONFIG_PARAMS` - * @const {Array} Transformation.PARAM_NAMES - * @private - * @ignore - * @see toHtmlAttributes - */ - }; + static isResponsive(tag, responsiveClass) { + var dataSrc; + dataSrc = Object(_util__WEBPACK_IMPORTED_MODULE_0__["getData"])(tag, 'src-cache') || Object(_util__WEBPACK_IMPORTED_MODULE_0__["getData"])(tag, 'src'); + return Object(_util__WEBPACK_IMPORTED_MODULE_0__["hasClass"])(tag, responsiveClass) && /\bw_auto\b/.exec(dataSrc); + } - return TransformationBase; +}; - })(); - Transformation = (function(superClass) { - extend(Transformation, superClass); +/** + * Represent the given key and value as an HTML attribute. + * @function toAttribute + * @protected + * @param {string} key - attribute name + * @param {*|boolean} value - the value of the attribute. If the value is boolean `true`, return the key only. + * @returns {string} the attribute + * + */ +function toAttribute(key, value) { + if (!value) { + return void 0; + } else if (value === true) { + return key; + } else { + return `${key}="${value}"`; + } +} +/* harmony default export */ __webpack_exports__["default"] = (HtmlTag); - /** - * Represents a single transformation. - * @class Transformation - * @example - * t = new cloudinary.Transformation(); - * t.angle(20).crop("scale").width("auto"); - * - * // or - * - * t = new cloudinary.Transformation( {angle: 20, crop: "scale", width: "auto"}); - */ - function Transformation(options) { - if (options == null) { - options = {}; - } - Transformation.__super__.constructor.call(this, options); - this; - } +/***/ }), +/***/ "./src/tags/imagetag.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * Convenience constructor - * @param {Object} options - * @return {Transformation} - * @example cl = cloudinary.Transformation.new( {angle: 20, crop: "scale", width: "auto"}) - */ +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _htmltag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/tags/htmltag.js"); +/* harmony import */ var _url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/url.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _util_srcsetUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/util/srcsetUtils.js"); +/** + * Image Tag + * Depends on 'tags/htmltag', 'cloudinary' + */ - Transformation["new"] = function(args) { - return new Transformation(args); - }; - /* - Transformation Parameters - */ - Transformation.prototype.angle = function(value) { - return this.arrayParam(value, "angle", "a", ".", Expression.normalize); - }; - Transformation.prototype.audioCodec = function(value) { - return this.param(value, "audio_codec", "ac"); - }; - Transformation.prototype.audioFrequency = function(value) { - return this.param(value, "audio_frequency", "af"); - }; - Transformation.prototype.aspectRatio = function(value) { - return this.param(value, "aspect_ratio", "ar", Expression.normalize); - }; +var ImageTag = class ImageTag extends _htmltag__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * Creates an HTML (DOM) Image tag using Cloudinary as the source. + * @constructor ImageTag + * @extends HtmlTag + * @param {string} [publicId] + * @param {Object} [options] + */ + constructor(publicId, options = {}) { + super("img", publicId, options); + } - Transformation.prototype.background = function(value) { - return this.param(value, "background", "b", Param.norm_color); - }; + /** @override */ + closeTag() { + return ""; + } - Transformation.prototype.bitRate = function(value) { - return this.param(value, "bit_rate", "br"); - }; + /** @override */ + attributes() { + var attr, options, srcAttribute; + attr = super.attributes() || {}; + options = this.getOptions(); + let srcsetParam = this.getOption('srcset'); + let attributes = this.getOption('attributes') || {}; + + let responsiveAttributes = {}; + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isString"])(srcsetParam)) { + responsiveAttributes.srcset = srcsetParam + } else { + responsiveAttributes = Object(_util_srcsetUtils__WEBPACK_IMPORTED_MODULE_3__["generateImageResponsiveAttributes"])(this.publicId, attributes, srcsetParam, options); + } + if(!Object(_util__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(responsiveAttributes)) { + delete options.width; + delete options.height; + } - Transformation.prototype.border = function(value) { - return this.param(value, "border", "bo", function(border) { - if (Util.isPlainObject(border)) { - border = Util.assign({}, { - color: "black", - width: 2 - }, border); - return border.width + "px_solid_" + (Param.norm_color(border.color)); - } else { - return border; - } - }); - }; + Object(_util__WEBPACK_IMPORTED_MODULE_2__["merge"])(attr, responsiveAttributes); + srcAttribute = options.responsive && !options.client_hints ? 'data-src' : 'src'; + if (attr[srcAttribute] == null) { + attr[srcAttribute] = Object(_url__WEBPACK_IMPORTED_MODULE_1__["default"])(this.publicId, this.getOptions()); + } + return attr; + } - Transformation.prototype.color = function(value) { - return this.param(value, "color", "co", Param.norm_color); - }; +}; - Transformation.prototype.colorSpace = function(value) { - return this.param(value, "color_space", "cs"); - }; +/* harmony default export */ __webpack_exports__["default"] = (ImageTag); - Transformation.prototype.crop = function(value) { - return this.param(value, "crop", "c"); - }; - Transformation.prototype.defaultImage = function(value) { - return this.param(value, "default_image", "d"); - }; +/***/ }), - Transformation.prototype.delay = function(value) { - return this.param(value, "delay", "dl"); - }; +/***/ "./src/tags/picturetag.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - Transformation.prototype.density = function(value) { - return this.param(value, "density", "dn"); - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _htmltag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/tags/htmltag.js"); +/* harmony import */ var _imagetag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/tags/imagetag.js"); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/transformation.js"); +/* harmony import */ var _sourcetag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/tags/sourcetag.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/util/jquery.js"); - Transformation.prototype.duration = function(value) { - return this.rangeParam(value, "duration", "du"); - }; - Transformation.prototype.dpr = function(value) { - return this.param(value, "dpr", "dpr", (function(_this) { - return function(dpr) { - dpr = dpr.toString(); - if (dpr != null ? dpr.match(/^\d+$/) : void 0) { - return dpr + ".0"; - } else { - return Expression.normalize(dpr); - } - }; - })(this)); - }; - Transformation.prototype.effect = function(value) { - return this.arrayParam(value, "effect", "e", ":", Expression.normalize); - }; - Transformation.prototype["else"] = function() { - return this["if"]('else'); - }; - Transformation.prototype.endIf = function() { - return this["if"]('end'); - }; - Transformation.prototype.endOffset = function(value) { - return this.rangeParam(value, "end_offset", "eo"); - }; +const PictureTag = class PictureTag extends _htmltag__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor(publicId, options = {}, sources) { + super('picture', publicId, options); + this.widthList = sources; + } - Transformation.prototype.fallbackContent = function(value) { - return this.param(value, "fallback_content"); - }; + /** @override */ + content() { + return this.widthList.map(({min_width, max_width, transformation}) => { + let options = this.getOptions(); + let sourceTransformation = new _transformation__WEBPACK_IMPORTED_MODULE_2__["default"](options); + sourceTransformation.chain().fromOptions(typeof transformation === 'string' ? { + raw_transformation: transformation + } : transformation); + options = Object(_util__WEBPACK_IMPORTED_MODULE_4__["extractUrlParams"])(options); + options.media = {min_width, max_width}; + options.transformation = sourceTransformation; + return new _sourcetag__WEBPACK_IMPORTED_MODULE_3__["default"](this.publicId, options).toHtml(); + }).join('') + + new _imagetag__WEBPACK_IMPORTED_MODULE_1__["default"](this.publicId, this.getOptions()).toHtml(); + } - Transformation.prototype.fetchFormat = function(value) { - return this.param(value, "fetch_format", "f"); - }; + /** @override */ + attributes() { - Transformation.prototype.format = function(value) { - return this.param(value, "format"); - }; + let attr = super.attributes(); + delete attr.width; + delete attr.height; + return attr; + } - Transformation.prototype.flags = function(value) { - return this.arrayParam(value, "flags", "fl", "."); - }; + /** @override */ + closeTag() { + return ""; + } - Transformation.prototype.gravity = function(value) { - return this.param(value, "gravity", "g"); - }; +}; - Transformation.prototype.height = function(value) { - return this.param(value, "height", "h", (function(_this) { - return function() { - if (_this.getValue("crop") || _this.getValue("overlay") || _this.getValue("underlay")) { - return Expression.normalize(value); - } else { - return null; - } - }; - })(this)); - }; +/* harmony default export */ __webpack_exports__["default"] = (PictureTag); - Transformation.prototype.htmlHeight = function(value) { - return this.param(value, "html_height"); - }; - Transformation.prototype.htmlWidth = function(value) { - return this.param(value, "html_width"); - }; +/***/ }), - Transformation.prototype["if"] = function(value) { - var i, ifVal, j, ref, trIf, trRest; - if (value == null) { - value = ""; - } - switch (value) { - case "else": - this.chain(); - return this.param(value, "if", "if"); - case "end": - this.chain(); - for (i = j = ref = this.chained.length - 1; j >= 0; i = j += -1) { - ifVal = this.chained[i].getValue("if"); - if (ifVal === "end") { - break; - } else if (ifVal != null) { - trIf = Transformation["new"]()["if"](ifVal); - this.chained[i].remove("if"); - trRest = this.chained[i]; - this.chained[i] = Transformation["new"]().transformation([trIf, trRest]); - if (ifVal !== "else") { - break; - } - } - } - return this.param(value, "if", "if"); - case "": - return Condition["new"]().setParent(this); - default: - return this.param(value, "if", "if", function(value) { - return Condition["new"](value).toString(); - }); - } - }; +/***/ "./src/tags/sourcetag.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - Transformation.prototype.keyframeInterval = function(value) { - return this.param(value, "keyframe_interval", "ki"); - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _util_srcsetUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/util/srcsetUtils.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/url.js"); +/* harmony import */ var _htmltag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/tags/htmltag.js"); +/** + * Image Tag + * Depends on 'tags/htmltag', 'cloudinary' + */ - Transformation.prototype.offset = function(value) { - var end_o, ref, start_o; - ref = Util.isFunction(value != null ? value.split : void 0) ? value.split('..') : Util.isArray(value) ? value : [null, null], start_o = ref[0], end_o = ref[1]; - if (start_o != null) { - this.startOffset(start_o); - } - if (end_o != null) { - return this.endOffset(end_o); - } - }; - Transformation.prototype.opacity = function(value) { - return this.param(value, "opacity", "o", Expression.normalize); - }; - Transformation.prototype.overlay = function(value) { - return this.layerParam(value, "overlay", "l"); - }; - Transformation.prototype.page = function(value) { - return this.param(value, "page", "pg"); - }; - Transformation.prototype.poster = function(value) { - return this.param(value, "poster"); - }; +const SourceTag = class SourceTag extends _htmltag__WEBPACK_IMPORTED_MODULE_3__["default"] { + /** + * Creates an HTML (DOM) Image tag using Cloudinary as the source. + * @constructor SourceTag + * @extends HtmlTag + * @param {string} [publicId] + * @param {Object} [options] + */ + constructor(publicId, options = {}) { + super("source", publicId, options); + } - Transformation.prototype.prefix = function(value) { - return this.param(value, "prefix", "p"); - }; + /** @override */ + closeTag() { + return ""; + } - Transformation.prototype.quality = function(value) { - return this.param(value, "quality", "q", Expression.normalize); - }; + /** @override */ + attributes() { + let srcsetParam = this.getOption('srcset'); + let attr = super.attributes() || {}; + let options = this.getOptions(); + Object(_util__WEBPACK_IMPORTED_MODULE_1__["merge"])(attr, Object(_util_srcsetUtils__WEBPACK_IMPORTED_MODULE_0__["generateImageResponsiveAttributes"])(this.publicId, attr, srcsetParam, options)); + if(!attr.srcset){ + attr.srcset = Object(_url__WEBPACK_IMPORTED_MODULE_2__["default"])(this.publicId, options); + } + if(!attr.media && options.media){ + attr.media = Object(_util_srcsetUtils__WEBPACK_IMPORTED_MODULE_0__["generateMediaAttr"])(options.media); + } - Transformation.prototype.radius = function(value) { - return this.param(value, "radius", "r", Expression.normalize); - }; + return attr; + } - Transformation.prototype.rawTransformation = function(value) { - return this.rawParam(value, "raw_transformation"); - }; +}; - Transformation.prototype.size = function(value) { - var height, ref; - if (Util.isFunction(value != null ? value.split : void 0)) { - ref = value.split('x'), width = ref[0], height = ref[1]; - this.width(width); - return this.height(height); - } - }; +/* harmony default export */ __webpack_exports__["default"] = (SourceTag); - Transformation.prototype.sourceTypes = function(value) { - return this.param(value, "source_types"); - }; - Transformation.prototype.sourceTransformation = function(value) { - return this.param(value, "source_transformation"); - }; +/***/ }), - Transformation.prototype.startOffset = function(value) { - return this.rangeParam(value, "start_offset", "so"); - }; +/***/ "./src/tags/videotag.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - Transformation.prototype.streamingProfile = function(value) { - return this.param(value, "streaming_profile", "sp"); - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/constants.js"); +/* harmony import */ var _url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/url.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _htmltag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/tags/htmltag.js"); +/** + * Video Tag + * Depends on 'tags/htmltag', 'util', 'cloudinary' + */ - Transformation.prototype.transformation = function(value) { - return this.transformationParam(value, "transformation", "t"); - }; - Transformation.prototype.underlay = function(value) { - return this.layerParam(value, "underlay", "u"); - }; - Transformation.prototype.variable = function(name, value) { - return this.param(value, name, name); - }; - Transformation.prototype.variables = function(values) { - return this.arrayParam(values, "variables"); - }; - Transformation.prototype.videoCodec = function(value) { - return this.param(value, "video_codec", "vc", Param.process_video_params); - }; - Transformation.prototype.videoSampling = function(value) { - return this.param(value, "video_sampling", "vs"); - }; - Transformation.prototype.width = function(value) { - return this.param(value, "width", "w", (function(_this) { - return function() { - if (_this.getValue("crop") || _this.getValue("overlay") || _this.getValue("underlay")) { - return Expression.normalize(value); - } else { - return null; - } - }; - })(this)); - }; - Transformation.prototype.x = function(value) { - return this.param(value, "x", "x", Expression.normalize); - }; - Transformation.prototype.y = function(value) { - return this.param(value, "y", "y", Expression.normalize); - }; - Transformation.prototype.zoom = function(value) { - return this.param(value, "zoom", "z", Expression.normalize); - }; +const VIDEO_TAG_PARAMS = ['source_types', 'source_transformation', 'fallback_content', 'poster']; - return Transformation; +const DEFAULT_VIDEO_SOURCE_TYPES = ['webm', 'mp4', 'ogv']; - })(TransformationBase); +const DEFAULT_POSTER_OPTIONS = { + format: 'jpg', + resource_type: 'video' +}; +const VideoTag = class VideoTag extends _htmltag__WEBPACK_IMPORTED_MODULE_3__["default"] { /** - * Transformation Class methods. - * This is a list of the parameters defined in Transformation. - * Values are camelCased. + * Creates an HTML (DOM) Video tag using Cloudinary as the source. + * @constructor VideoTag + * @extends HtmlTag + * @param {string} [publicId] + * @param {Object} [options] */ - Transformation.methods || (Transformation.methods = Util.difference(Util.functions(Transformation.prototype), Util.functions(TransformationBase.prototype))); + constructor(publicId, options = {}) { + options = Object(_util__WEBPACK_IMPORTED_MODULE_2__["defaults"])({}, options, _constants__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_VIDEO_PARAMS"]); + super("video", publicId.replace(/\.(mp4|ogv|webm)$/, ''), options); + } /** - * Parameters that are filtered out before passing the options to an HTML tag. - * - * The list of parameters is a combination of `Transformation::methods` and `Configuration::CONFIG_PARAMS` + * Set the transformation to apply on each source + * @function VideoTag#setSourceTransformation + * @param {Object} an object with pairs of source type and source transformation + * @returns {VideoTag} Returns this instance for chaining purposes. */ - Transformation.PARAM_NAMES || (Transformation.PARAM_NAMES = ((function() { - var j, len, ref, results; - ref = Transformation.methods; - results = []; - for (j = 0, len = ref.length; j < len; j++) { - m = ref[j]; - results.push(Util.snakeCase(m)); - } - return results; - })()).concat(Configuration.CONFIG_PARAMS)); + setSourceTransformation(value) { + this.transformation().sourceTransformation(value); + return this; + } /** - * Generic HTML tag - * Depends on 'transformation', 'util' + * Set the source types to include in the video tag + * @function VideoTag#setSourceTypes + * @param {Array} an array of source types + * @returns {VideoTag} Returns this instance for chaining purposes. */ - HtmlTag = (function() { + setSourceTypes(value) { + this.transformation().sourceTypes(value); + return this; + } - /** - * Represents an HTML (DOM) tag - * @constructor HtmlTag - * @param {string} name - the name of the tag - * @param {string} [publicId] - * @param {Object} options - * @example tag = new HtmlTag( 'div', { 'width': 10}) - */ - var toAttribute; - - function HtmlTag(name, publicId, options) { - var transformation; - this.name = name; - this.publicId = publicId; - if (options == null) { - if (Util.isPlainObject(publicId)) { - options = publicId; - this.publicId = void 0; - } else { - options = {}; - } - } - transformation = new Transformation(options); - transformation.setParent(this); - this.transformation = function() { - return transformation; - }; - } + /** + * Set the poster to be used in the video tag + * @function VideoTag#setPoster + * @param {string|Object} value + * - string: a URL to use for the poster + * - Object: transformation parameters to apply to the poster. May optionally include a public_id to use instead of the video public_id. + * @returns {VideoTag} Returns this instance for chaining purposes. + */ + setPoster(value) { + this.transformation().poster(value); + return this; + } + /** + * Set the content to use as fallback in the video tag + * @function VideoTag#setFallbackContent + * @param {string} value - the content to use, in HTML format + * @returns {VideoTag} Returns this instance for chaining purposes. + */ + setFallbackContent(value) { + this.transformation().fallbackContent(value); + return this; + } - /** - * Convenience constructor - * Creates a new instance of an HTML (DOM) tag - * @function HtmlTag.new - * @param {string} name - the name of the tag - * @param {string} [publicId] - * @param {Object} options - * @return {HtmlTag} - * @example tag = HtmlTag.new( 'div', { 'width': 10}) - */ + content() { + var fallback, innerTags, type, sourceTransformation, sourceTypes, src, srcType, transformation, videoType; + sourceTypes = this.transformation().getValue('source_types'); + sourceTransformation = this.transformation().getValue('source_transformation'); + fallback = this.transformation().getValue('fallback_content'); + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isArray"])(sourceTypes)) { + let options = this.getOptions(); + innerTags = (function () { + var i, len, results; + results = []; + for (i = 0, len = sourceTypes.length; i < len; i++) { + srcType = sourceTypes[i]; + transformation = sourceTransformation[srcType] || {}; + src = Object(_url__WEBPACK_IMPORTED_MODULE_1__["default"])(`${this.publicId}`, Object(_util__WEBPACK_IMPORTED_MODULE_2__["defaults"])({}, transformation, { + resource_type: 'video', + format: srcType + }, options)); + videoType = srcType === 'ogv' ? 'ogg' : srcType; + type = 'video/' + videoType; + results.push(``); + } + return results; + }).call(this); + } else { + innerTags = []; + } + return innerTags.join('') + fallback; + } - HtmlTag["new"] = function(name, publicId, options) { - return new this(name, publicId, options); - }; + attributes() { + var a, attr, defaultOptions, i, len, poster, ref, ref1, sourceTypes; + sourceTypes = this.getOption('source_types'); + poster = (ref = this.getOption('poster')) != null ? ref : {}; + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isPlainObject"])(poster)) { + defaultOptions = poster.public_id != null ? _constants__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_IMAGE_PARAMS"] : DEFAULT_POSTER_OPTIONS; + poster = Object(_url__WEBPACK_IMPORTED_MODULE_1__["default"])((ref1 = poster.public_id) != null ? ref1 : this.publicId, Object(_util__WEBPACK_IMPORTED_MODULE_2__["defaults"])({}, poster, defaultOptions, this.getOptions())); + } + attr = super.attributes() || []; + for (i = 0, len = attr.length; i < len; i++) { + a = attr[i]; + if (!Object(_util__WEBPACK_IMPORTED_MODULE_2__["contains"])(VIDEO_TAG_PARAMS)) { + attr = a; + } + } + if (!Object(_util__WEBPACK_IMPORTED_MODULE_2__["isArray"])(sourceTypes)) { + attr["src"] = Object(_url__WEBPACK_IMPORTED_MODULE_1__["default"])(this.publicId, this.getOptions(), { + resource_type: 'video', + format: sourceTypes + }); + } + if (poster != null) { + attr["poster"] = poster; + } + return attr; + } +}; - /** - * Represent the given key and value as an HTML attribute. - * @function HtmlTag#toAttribute - * @protected - * @param {string} key - attribute name - * @param {*|boolean} value - the value of the attribute. If the value is boolean `true`, return the key only. - * @returns {string} the attribute - * - */ +/* harmony default export */ __webpack_exports__["default"] = (VideoTag); - toAttribute = function(key, value) { - if (!value) { - return void 0; - } else if (value === true) { - return key; - } else { - return key + "=\"" + value + "\""; - } - }; +/***/ }), - /** - * combine key and value from the `attr` to generate an HTML tag attributes string. - * `Transformation::toHtmlTagOptions` is used to filter out transformation and configuration keys. - * @protected - * @param {Object} attrs - * @return {string} the attributes in the format `'key1="value1" key2="value2"'` - * @ignore - */ +/***/ "./src/transformation.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - HtmlTag.prototype.htmlAttrs = function(attrs) { - var key, pairs, value; - return pairs = ((function() { - var results; - results = []; - for (key in attrs) { - value = attrs[key]; - if (value) { - results.push(toAttribute(key, value)); - } - } - return results; - })()).sort().join(' '); - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _expression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/expression.js"); +/* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/condition.js"); +/* harmony import */ var _configuration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/configuration.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _parameters__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/parameters.js"); - /** - * Get all options related to this tag. - * @function HtmlTag#getOptions - * @returns {Object} the options - * - */ - HtmlTag.prototype.getOptions = function() { - return this.transformation().toOptions(); - }; - /** - * Get the value of option `name` - * @function HtmlTag#getOption - * @param {string} name - the name of the option - * @returns {*} Returns the value of the option - * - */ - HtmlTag.prototype.getOption = function(name) { - return this.transformation().getValue(name); - }; +/** + * Assign key, value to target, when value is not null.
+ * This function mutates the target! + * @param {object} target the object to assign the values to + * @param {object} sources one or more objects to get values from + * @returns {object} the target after the assignment + */ +function assignNotNull(target, ...sources) { + sources.forEach(source => { + Object.keys(source).forEach(key => { + if (source[key] != null) { + target[key] = source[key]; + } + }) + }); + return target; +} + +/** + * TransformationBase + * Depends on 'configuration', 'parameters','util' + * @internal + */ + +var TransformationBase = class TransformationBase { + /** + * The base class for transformations. + * Members of this class are documented as belonging to the {@link Transformation} class for convenience. + * @class TransformationBase + */ + constructor(options = {}) { + /** @private */ + /** @private */ + var parent, trans; + parent = void 0; + trans = {}; /** - * Get the attributes of the tag. - * @function HtmlTag#attributes - * @returns {Object} attributes + * Return an options object that can be used to create an identical Transformation + * @function Transformation#toOptions + * @return {Object} Returns a plain object representing this transformation */ - - HtmlTag.prototype.attributes = function() { - return this.transformation().toHtmlAttributes(); + this.toOptions = function (withChain = true) { + let opt = {}; + Object.keys(trans).forEach(key => opt[key] = trans[key].origValue); + assignNotNull(opt, this.otherOptions); + if (withChain && !Object(_util__WEBPACK_IMPORTED_MODULE_3__["isEmpty"])(this.chained)) { + let list = this.chained.map(tr => tr.toOptions()); + list.push(opt); + opt = {}; + assignNotNull(opt, this.otherOptions); + opt.transformation = list; + } + return opt; }; - - /** - * Set a tag attribute named `name` to `value` - * @function HtmlTag#setAttr - * @param {string} name - the name of the attribute - * @param {string} value - the value of the attribute + * Set a parent for this object for chaining purposes. + * + * @function Transformation#setParent + * @param {Object} object - the parent to be assigned to + * @returns {Transformation} Returns this instance for chaining purposes. */ - - HtmlTag.prototype.setAttr = function(name, value) { - this.transformation().set("html_" + name, value); + this.setParent = function (object) { + parent = object; + if (object != null) { + this.fromOptions(typeof object.toOptions === "function" ? object.toOptions() : void 0); + } return this; }; - - /** - * Get the value of the tag attribute `name` - * @function HtmlTag#getAttr - * @param {string} name - the name of the attribute - * @returns {*} + * Returns the parent of this object in the chain + * @function Transformation#getParent + * @protected + * @return {Object} Returns the parent of this object if there is any */ - - HtmlTag.prototype.getAttr = function(name) { - return this.attributes()["html_" + name] || this.attributes()[name]; + this.getParent = function () { + return parent; }; + // Helper methods to create parameter methods + // These methods are defined here because they access `trans` which is + // a private member of `TransformationBase` - /** - * Remove the tag attributed named `name` - * @function HtmlTag#removeAttr - * @param {string} name - the name of the attribute - * @returns {*} - */ - - HtmlTag.prototype.removeAttr = function(name) { - var ref; - return (ref = this.transformation().remove("html_" + name)) != null ? ref : this.transformation().remove(name); + /** @protected */ + this.param = function (value, name, abbr, defaultValue, process) { + if (process == null) { + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isFunction"])(defaultValue)) { + process = defaultValue; + } else { + process = _util__WEBPACK_IMPORTED_MODULE_3__["identity"]; + } + } + trans[name] = new _parameters__WEBPACK_IMPORTED_MODULE_4__["Param"](name, abbr, process).set(value); + return this; + }; + /** @protected */ + this.rawParam && console.log("rawParam: **********************************************"); + this.rawParam = function (value, name, abbr, defaultValue, process = _util__WEBPACK_IMPORTED_MODULE_3__["identity"]) { + process = lastArgCallback(arguments); + trans[name] = new _parameters__WEBPACK_IMPORTED_MODULE_4__["RawParam"](name, abbr, process).set(value); + return this; + }; + /** @protected */ + this.rangeParam = function (value, name, abbr, defaultValue, process = _util__WEBPACK_IMPORTED_MODULE_3__["identity"]) { + process = lastArgCallback(arguments); + trans[name] = new _parameters__WEBPACK_IMPORTED_MODULE_4__["RangeParam"](name, abbr, process).set(value); + return this; + }; + /** @protected */ + this.arrayParam = function (value, name, abbr, sep = ":", defaultValue = [], process = _util__WEBPACK_IMPORTED_MODULE_3__["identity"]) { + process = lastArgCallback(arguments); + trans[name] = new _parameters__WEBPACK_IMPORTED_MODULE_4__["ArrayParam"](name, abbr, sep, process).set(value); + return this; + }; + /** @protected */ + this.transformationParam = function (value, name, abbr, sep = ".", defaultValue, process = _util__WEBPACK_IMPORTED_MODULE_3__["identity"]) { + process = lastArgCallback(arguments); + trans[name] = new _parameters__WEBPACK_IMPORTED_MODULE_4__["TransformationParam"](name, abbr, sep, process).set(value); + return this; + }; + this.layerParam = function (value, name, abbr) { + trans[name] = new _parameters__WEBPACK_IMPORTED_MODULE_4__["LayerParam"](name, abbr).set(value); + return this; }; + // End Helper methods /** - * @function HtmlTag#content - * @protected - * @ignore + * Get the value associated with the given name. + * @function Transformation#getValue + * @param {string} name - the name of the parameter + * @return {*} the processed value associated with the given name + * @description Use {@link get}.origValue for the value originally provided for the parameter */ - - HtmlTag.prototype.content = function() { - return ""; + this.getValue = function (name) { + let value = trans[name] && trans[name].value(); + return value != null ? value : this.otherOptions[name]; }; - - /** - * @function HtmlTag#openTag - * @protected - * @ignore + * Get the parameter object for the given parameter name + * @function Transformation#get + * @param {string} name the name of the transformation parameter + * @returns {Param} the param object for the given name, or undefined */ - - HtmlTag.prototype.openTag = function() { - return "<" + this.name + " " + (this.htmlAttrs(this.attributes())) + ">"; + this.get = function (name) { + return trans[name]; }; - - /** - * @function HtmlTag#closeTag - * @protected - * @ignore + * Remove a transformation option from the transformation. + * @function Transformation#remove + * @param {string} name - the name of the option to remove + * @return {*} Returns the option that was removed or null if no option by that name was found. The type of the + * returned value depends on the value. */ - - HtmlTag.prototype.closeTag = function() { - return ""; + this.remove = function (name) { + var temp; + switch (false) { + case trans[name] == null: + temp = trans[name]; + delete trans[name]; + return temp.origValue; + case this.otherOptions[name] == null: + temp = this.otherOptions[name]; + delete this.otherOptions[name]; + return temp; + default: + return null; + } }; - - /** - * Generates an HTML representation of the tag. - * @function HtmlTag#toHtml - * @returns {string} Returns HTML in string format + * Return an array of all the keys (option names) in the transformation. + * @return {Array} the keys in snakeCase format */ - - HtmlTag.prototype.toHtml = function() { - return this.openTag() + this.content() + this.closeTag(); + this.keys = function () { + var key; + return ((function () { + var results; + results = []; + for (key in trans) { + if (key != null) { + results.push(key.match(VAR_NAME_RE) ? key : Object(_util__WEBPACK_IMPORTED_MODULE_3__["snakeCase"])(key)); + } + } + return results; + })()).sort(); }; - - /** - * Creates a DOM object representing the tag. - * @function HtmlTag#toDOM - * @returns {Element} + * Returns a plain object representation of the transformation. Values are processed. + * @function Transformation#toPlainObject + * @return {Object} the transformation options as plain object */ - - HtmlTag.prototype.toDOM = function() { - var element, name, ref, value; - if (!Util.isFunction(typeof document !== "undefined" && document !== null ? document.createElement : void 0)) { - throw "Can't create DOM if document is not present!"; + this.toPlainObject = function () { + var hash, key, list; + hash = {}; + for (key in trans) { + hash[key] = trans[key].value(); + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isPlainObject"])(hash[key])) { + hash[key] = Object(_util__WEBPACK_IMPORTED_MODULE_3__["cloneDeep"])(hash[key]); + } } - element = document.createElement(this.name); - ref = this.attributes(); - for (name in ref) { - value = ref[name]; - element[name] = value; + if (!Object(_util__WEBPACK_IMPORTED_MODULE_3__["isEmpty"])(this.chained)) { + list = this.chained.map(tr => tr.toPlainObject()); + list.push(hash); + hash = { + transformation: list + }; } - return element; + return hash; }; - - HtmlTag.isResponsive = function(tag, responsiveClass) { - var dataSrc; - dataSrc = Util.getData(tag, 'src-cache') || Util.getData(tag, 'src'); - return Util.hasClass(tag, responsiveClass) && /\bw_auto\b/.exec(dataSrc); + /** + * Complete the current transformation and chain to a new one. + * In the URL, transformations are chained together by slashes. + * @function Transformation#chain + * @return {Transformation} Returns this transformation for chaining + * @example + * var tr = cloudinary.Transformation.new(); + * tr.width(10).crop('fit').chain().angle(15).serialize() + * // produces "c_fit,w_10/a_15" + */ + this.chain = function () { + var names, tr; + names = Object.getOwnPropertyNames(trans); + if (names.length !== 0) { + tr = new this.constructor(this.toOptions(false)); + this.resetTransformations(); + this.chained.push(tr); + } + return this; + }; + this.resetTransformations = function () { + trans = {}; + return this; }; + this.otherOptions = {}; + this.chained = []; + if (!Object(_util__WEBPACK_IMPORTED_MODULE_3__["isEmpty"])(options)) { + // Finished constructing the instance, now process the options + this.fromOptions(options); + } + } - return HtmlTag; + /** + * Merge the provided options with own's options + * @param {Object} [options={}] key-value list of options + * @returns {Transformation} Returns this instance for chaining + */ + fromOptions(options) { + var key, opt; + if (options instanceof TransformationBase) { + this.fromTransformation(options); + } else { + options || (options = {}); + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isString"])(options) || Object(_util__WEBPACK_IMPORTED_MODULE_3__["isArray"])(options)) { + options = { + transformation: options + }; + } + options = Object(_util__WEBPACK_IMPORTED_MODULE_3__["cloneDeep"])(options, function (value) { + if (value instanceof TransformationBase) { + return new value.constructor(value.toOptions()); + } + }); + // Handling of "if" statements precedes other options as it creates a chained transformation + if (options["if"]) { + this.set("if", options["if"]); + delete options["if"]; + } + for (key in options) { + opt = options[key]; + if (key.match(VAR_NAME_RE)) { + if (key !== '$attr') { + this.set('variable', key, opt); + } + } else { + this.set(key, opt); + } + } + } + return this; + } - })(); + fromTransformation(other) { + if (other instanceof TransformationBase) { + other.keys().forEach(key => + this.set(key, other.get(key).origValue) + ); + } + return this; + } /** - * Image Tag - * Depends on 'tags/htmltag', 'cloudinary' + * Set a parameter. + * The parameter name `key` is converted to + * @param {string} key - the name of the parameter + * @param {*} values - the value of the parameter + * @returns {Transformation} Returns this instance for chaining */ - ImageTag = (function(superClass) { - extend(ImageTag, superClass); - + set(key, ...values) { + var camelKey; + camelKey = Object(_util__WEBPACK_IMPORTED_MODULE_3__["camelCase"])(key); + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["contains"])(Transformation.methods, camelKey)) { + this[camelKey].apply(this, values); + } else { + this.otherOptions[key] = values[0]; + } + return this; + } - /** - * Creates an HTML (DOM) Image tag using Cloudinary as the source. - * @constructor ImageTag - * @extends HtmlTag - * @param {string} [publicId] - * @param {Object} [options] - */ + hasLayer() { + return this.getValue("overlay") || this.getValue("underlay"); + } - function ImageTag(publicId, options) { - if (options == null) { - options = {}; + /** + * Generate a string representation of the transformation. + * @function Transformation#serialize + * @return {string} Returns the transformation as a string + */ + serialize() { + var ifParam, j, len, paramList, ref, ref1, ref2, ref3, ref4, resultArray, t, transformationList, + transformationString, transformations, value, variables, vars; + resultArray = this.chained.map(tr => tr.serialize()); + paramList = this.keys(); + transformations = (ref = this.get("transformation")) != null ? ref.serialize() : void 0; + ifParam = (ref1 = this.get("if")) != null ? ref1.serialize() : void 0; + variables = processVar((ref2 = this.get("variables")) != null ? ref2.value() : void 0); + paramList = Object(_util__WEBPACK_IMPORTED_MODULE_3__["difference"])(paramList, ["transformation", "if", "variables"]); + vars = []; + transformationList = []; + for (j = 0, len = paramList.length; j < len; j++) { + t = paramList[j]; + if (t.match(VAR_NAME_RE)) { + vars.push(t + "_" + _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize((ref3 = this.get(t)) != null ? ref3.value() : void 0)); + } else { + transformationList.push((ref4 = this.get(t)) != null ? ref4.serialize() : void 0); + } + } + switch (false) { + case !Object(_util__WEBPACK_IMPORTED_MODULE_3__["isString"])(transformations): + transformationList.push(transformations); + break; + case !Object(_util__WEBPACK_IMPORTED_MODULE_3__["isArray"])(transformations): + resultArray = resultArray.concat(transformations); + } + transformationList = (function () { + var k, len1, results; + results = []; + for (k = 0, len1 = transformationList.length; k < len1; k++) { + value = transformationList[k]; + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isArray"])(value) && !Object(_util__WEBPACK_IMPORTED_MODULE_3__["isEmpty"])(value) || !Object(_util__WEBPACK_IMPORTED_MODULE_3__["isArray"])(value) && value) { + results.push(value); + } } - ImageTag.__super__.constructor.call(this, "img", publicId, options); + return results; + })(); + transformationList = vars.sort().concat(variables).concat(transformationList.sort()); + if (ifParam === "if_end") { + transformationList.push(ifParam); + } else if (!Object(_util__WEBPACK_IMPORTED_MODULE_3__["isEmpty"])(ifParam)) { + transformationList.unshift(ifParam); + } + transformationString = Object(_util__WEBPACK_IMPORTED_MODULE_3__["compact"])(transformationList).join(this.param_separator); + if (!Object(_util__WEBPACK_IMPORTED_MODULE_3__["isEmpty"])(transformationString)) { + resultArray.push(transformationString); } + return Object(_util__WEBPACK_IMPORTED_MODULE_3__["compact"])(resultArray).join(this.trans_separator); + } + /** + * Provide a list of all the valid transformation option names + * @function Transformation#listNames + * @private + * @return {Array} a array of all the valid option names + */ + listNames() { + return Transformation.methods; + } - /** @override */ + /** + * Returns attributes for an HTML tag. + * @function Cloudinary.toHtmlAttributes + * @return PlainObject + */ + toHtmlAttributes() { + var attrName, height, key, options, ref2, ref3, value, width; + options = {}; + for (key in this.otherOptions) { + value = this.otherOptions[key]; + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["contains"])(Transformation.PARAM_NAMES, Object(_util__WEBPACK_IMPORTED_MODULE_3__["snakeCase"])(key))) { + continue; + } + attrName = /^html_/.test(key) ? key.slice(5) : key; + options[attrName] = value; + } + // convert all "html_key" to "key" with the same value + this.keys().forEach(key => { + if (/^html_/.test(key)) { + options[Object(_util__WEBPACK_IMPORTED_MODULE_3__["camelCase"])(key.slice(5))] = this.getValue(key); + } + }); + if (!(this.hasLayer() || this.getValue("angle") || Object(_util__WEBPACK_IMPORTED_MODULE_3__["contains"])(["fit", "limit", "lfill"], this.getValue("crop")))) { + width = (ref2 = this.get("width")) != null ? ref2.origValue : void 0; + height = (ref3 = this.get("height")) != null ? ref3.origValue : void 0; + if (parseFloat(width) >= 1.0) { + if (options['width'] == null) { + options['width'] = width; + } + } + if (parseFloat(height) >= 1.0) { + if (options['height'] == null) { + options['height'] = height; + } + } + } + return options; + } - ImageTag.prototype.closeTag = function() { - return ""; - }; + isValidParamName(name) { + return Transformation.methods.indexOf(Object(_util__WEBPACK_IMPORTED_MODULE_3__["camelCase"])(name)) >= 0; + } + /** + * Delegate to the parent (up the call chain) to produce HTML + * @function Transformation#toHtml + * @return {string} HTML representation of the parent if possible. + * @example + * tag = cloudinary.ImageTag.new("sample", {cloud_name: "demo"}) + * // ImageTag {name: "img", publicId: "sample"} + * tag.toHtml() + * // + * tag.transformation().crop("fit").width(300).toHtml() + * // + */ + toHtml() { + var ref; + return (ref = this.getParent()) != null ? typeof ref.toHtml === "function" ? ref.toHtml() : void 0 : void 0; + } - /** @override */ + toString() { + return this.serialize(); + } - ImageTag.prototype.attributes = function() { - var attr, options, srcAttribute; - attr = ImageTag.__super__.attributes.call(this) || []; - options = this.getOptions(); - srcAttribute = options.responsive && !options.client_hints ? 'data-src' : 'src'; - if (attr[srcAttribute] == null) { - attr[srcAttribute] = new Cloudinary(this.getOptions()).url(this.publicId); - } - return attr; - }; +}; - return ImageTag; +const VAR_NAME_RE = /^\$[a-zA-Z0-9]+$/; - })(HtmlTag); +TransformationBase.prototype.trans_separator = '/'; - /** - * Video Tag - * Depends on 'tags/htmltag', 'util', 'cloudinary' - */ - VideoTag = (function(superClass) { - var DEFAULT_POSTER_OPTIONS, DEFAULT_VIDEO_SOURCE_TYPES, VIDEO_TAG_PARAMS; +TransformationBase.prototype.param_separator = ','; - extend(VideoTag, superClass); - VIDEO_TAG_PARAMS = ['source_types', 'source_transformation', 'fallback_content', 'poster']; +function lastArgCallback(args) { + var callback; + callback = args != null ? args[args.length - 1] : void 0; + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isFunction"])(callback)) { + return callback; + } else { + return void 0; + } +} - DEFAULT_VIDEO_SOURCE_TYPES = ['webm', 'mp4', 'ogv']; +function processVar(varArray) { + var j, len, name, results, v; + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isArray"])(varArray)) { + results = []; + for (j = 0, len = varArray.length; j < len; j++) { + [name, v] = varArray[j]; + results.push(`${name}_${_expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize(v)}`); + } + return results; + } else { + return varArray; + } +} - DEFAULT_POSTER_OPTIONS = { - format: 'jpg', - resource_type: 'video' - }; +/** + * Transformation Class methods. + * This is a list of the parameters defined in Transformation. + * Values are camelCased. + * @const Transformation.methods + * @private + * @ignore + * @type {Array} + */ +/** + * Parameters that are filtered out before passing the options to an HTML tag. + * + * The list of parameters is a combination of `Transformation::methods` and `Configuration::CONFIG_PARAMS` + * @const {Array} Transformation.PARAM_NAMES + * @private + * @ignore + * @see toHtmlAttributes + */ +var Transformation = class Transformation extends TransformationBase { + /** + * Represents a single transformation. + * @class Transformation + * @example + * t = new cloudinary.Transformation(); + * t.angle(20).crop("scale").width("auto"); + * + * // or + * + * t = new cloudinary.Transformation( {angle: 20, crop: "scale", width: "auto"}); + */ + constructor(options = {}) { + super(options); + } + /** + * Convenience constructor + * @param {Object} options + * @return {Transformation} + * @example cl = cloudinary.Transformation.new( {angle: 20, crop: "scale", width: "auto"}) + */ + static new(options) { + return new Transformation(options); + } - /** - * Creates an HTML (DOM) Video tag using Cloudinary as the source. - * @constructor VideoTag - * @extends HtmlTag - * @param {string} [publicId] - * @param {Object} [options] - */ + /* + Transformation Parameters + */ + angle(value) { + return this.arrayParam(value, "angle", "a", ".", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } - function VideoTag(publicId, options) { - if (options == null) { - options = {}; - } - options = Util.defaults({}, options, Cloudinary.DEFAULT_VIDEO_PARAMS); - VideoTag.__super__.constructor.call(this, "video", publicId.replace(/\.(mp4|ogv|webm)$/, ''), options); - } + audioCodec(value) { + return this.param(value, "audio_codec", "ac"); + } + audioFrequency(value) { + return this.param(value, "audio_frequency", "af"); + } - /** - * Set the transformation to apply on each source - * @function VideoTag#setSourceTransformation - * @param {Object} an object with pairs of source type and source transformation - * @returns {VideoTag} Returns this instance for chaining purposes. - */ + aspectRatio(value) { + return this.param(value, "aspect_ratio", "ar", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } - VideoTag.prototype.setSourceTransformation = function(value) { - this.transformation().sourceTransformation(value); - return this; - }; + background(value) { + return this.param(value, "background", "b", _parameters__WEBPACK_IMPORTED_MODULE_4__["Param"].norm_color); + } + bitRate(value) { + return this.param(value, "bit_rate", "br"); + } - /** - * Set the source types to include in the video tag - * @function VideoTag#setSourceTypes - * @param {Array} an array of source types - * @returns {VideoTag} Returns this instance for chaining purposes. - */ + border(value) { + return this.param(value, "border", "bo", function (border) { + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isPlainObject"])(border)) { + border = Object(_util__WEBPACK_IMPORTED_MODULE_3__["assign"])({}, { + color: "black", + width: 2 + }, border); + return `${border.width}px_solid_${_parameters__WEBPACK_IMPORTED_MODULE_4__["Param"].norm_color(border.color)}`; + } else { + return border; + } + }); + } - VideoTag.prototype.setSourceTypes = function(value) { - this.transformation().sourceTypes(value); - return this; - }; + color(value) { + return this.param(value, "color", "co", _parameters__WEBPACK_IMPORTED_MODULE_4__["Param"].norm_color); + } + colorSpace(value) { + return this.param(value, "color_space", "cs"); + } - /** - * Set the poster to be used in the video tag - * @function VideoTag#setPoster - * @param {string|Object} value - * - string: a URL to use for the poster - * - Object: transformation parameters to apply to the poster. May optionally include a public_id to use instead of the video public_id. - * @returns {VideoTag} Returns this instance for chaining purposes. - */ + crop(value) { + return this.param(value, "crop", "c"); + } - VideoTag.prototype.setPoster = function(value) { - this.transformation().poster(value); - return this; - }; + defaultImage(value) { + return this.param(value, "default_image", "d"); + } + delay(value) { + return this.param(value, "delay", "dl"); + } - /** - * Set the content to use as fallback in the video tag - * @function VideoTag#setFallbackContent - * @param {string} value - the content to use, in HTML format - * @returns {VideoTag} Returns this instance for chaining purposes. - */ + density(value) { + return this.param(value, "density", "dn"); + } - VideoTag.prototype.setFallbackContent = function(value) { - this.transformation().fallbackContent(value); - return this; - }; + duration(value) { + return this.rangeParam(value, "duration", "du"); + } - VideoTag.prototype.content = function() { - var cld, fallback, innerTags, mimeType, sourceTransformation, sourceTypes, src, srcType, transformation, videoType; - sourceTypes = this.transformation().getValue('source_types'); - sourceTransformation = this.transformation().getValue('source_transformation'); - fallback = this.transformation().getValue('fallback_content'); - if (Util.isArray(sourceTypes)) { - cld = new Cloudinary(this.getOptions()); - innerTags = (function() { - var j, len, results; - results = []; - for (j = 0, len = sourceTypes.length; j < len; j++) { - srcType = sourceTypes[j]; - transformation = sourceTransformation[srcType] || {}; - src = cld.url("" + this.publicId, Util.defaults({}, transformation, { - resource_type: 'video', - format: srcType - })); - videoType = srcType === 'ogv' ? 'ogg' : srcType; - mimeType = 'video/' + videoType; - results.push(""); - } - return results; - }).call(this); + dpr(value) { + return this.param(value, "dpr", "dpr", (dpr) => { + dpr = dpr.toString(); + if (dpr != null ? dpr.match(/^\d+$/) : void 0) { + return dpr + ".0"; } else { - innerTags = []; + return _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize(dpr); } - return innerTags.join('') + fallback; - }; + }); + } - VideoTag.prototype.attributes = function() { - var a, attr, j, len, poster, ref, ref1, sourceTypes; - sourceTypes = this.getOption('source_types'); - poster = (ref = this.getOption('poster')) != null ? ref : {}; - if (Util.isPlainObject(poster)) { - defaults = poster.public_id != null ? Cloudinary.DEFAULT_IMAGE_PARAMS : DEFAULT_POSTER_OPTIONS; - poster = new Cloudinary(this.getOptions()).url((ref1 = poster.public_id) != null ? ref1 : this.publicId, Util.defaults({}, poster, defaults)); - } - attr = VideoTag.__super__.attributes.call(this) || []; - for (j = 0, len = attr.length; j < len; j++) { - a = attr[j]; - if (!Util.contains(VIDEO_TAG_PARAMS)) { - attr = a; - } - } - if (!Util.isArray(sourceTypes)) { - attr["src"] = new Cloudinary(this.getOptions()).url(this.publicId, { - resource_type: 'video', - format: sourceTypes - }); - } - if (poster != null) { - attr["poster"] = poster; - } - return attr; - }; + effect(value) { + return this.arrayParam(value, "effect", "e", ":", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } - return VideoTag; + else() { + return this.if('else'); + } - })(HtmlTag); - - /** - * Image Tag - * Depends on 'tags/htmltag', 'cloudinary' - */ - ClientHintsMetaTag = (function(superClass) { - extend(ClientHintsMetaTag, superClass); - - - /** - * Creates an HTML (DOM) Meta tag that enables client-hints. - * @constructor ClientHintsMetaTag - * @extends HtmlTag - */ - - function ClientHintsMetaTag(options) { - ClientHintsMetaTag.__super__.constructor.call(this, 'meta', void 0, Util.assign({ - "http-equiv": "Accept-CH", - content: "DPR, Viewport-Width, Width" - }, options)); - } + endIf() { + return this.if('end'); + } + endOffset(value) { + return this.rangeParam(value, "end_offset", "eo"); + } - /** @override */ + fallbackContent(value) { + return this.param(value, "fallback_content"); + } - ClientHintsMetaTag.prototype.closeTag = function() { - return ""; - }; + fetchFormat(value) { + return this.param(value, "fetch_format", "f"); + } - return ClientHintsMetaTag; + format(value) { + return this.param(value, "format"); + } - })(HtmlTag); - Cloudinary = (function() { - var AKAMAI_SHARED_CDN, CF_SHARED_CDN, DEFAULT_POSTER_OPTIONS, DEFAULT_VIDEO_SOURCE_TYPES, OLD_AKAMAI_SHARED_CDN, SEO_TYPES, SHARED_CDN, VERSION, absolutize, applyBreakpoints, cdnSubdomainNumber, closestAbove, cloudinaryUrlPrefix, defaultBreakpoints, finalizeResourceType, findContainerWidth, maxWidth, updateDpr; + flags(value) { + return this.arrayParam(value, "flags", "fl", "."); + } - VERSION = "2.5.0"; + gravity(value) { + return this.param(value, "gravity", "g"); + } - CF_SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net"; + fps(value) { + return this.param(value, "fps", "fps", (fps) => { + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isString"])(fps)) { + return fps; + } else if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isArray"])(fps)) { + return fps.join("-"); + } else { + return fps; + } + }); + } - OLD_AKAMAI_SHARED_CDN = "cloudinary-a.akamaihd.net"; + height(value) { + return this.param(value, "height", "h", () => { + if (this.getValue("crop") || this.getValue("overlay") || this.getValue("underlay")) { + return _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize(value); + } else { + return null; + } + }); + } - AKAMAI_SHARED_CDN = "res.cloudinary.com"; + htmlHeight(value) { + return this.param(value, "html_height"); + } - SHARED_CDN = AKAMAI_SHARED_CDN; + htmlWidth(value) { + return this.param(value, "html_width"); + } - DEFAULT_POSTER_OPTIONS = { - format: 'jpg', - resource_type: 'video' - }; + if(value = "") { + var i, ifVal, j, ref, trIf, trRest; + switch (value) { + case "else": + this.chain(); + return this.param(value, "if", "if"); + case "end": + this.chain(); + for (i = j = ref = this.chained.length - 1; j >= 0; i = j += -1) { + ifVal = this.chained[i].getValue("if"); + if (ifVal === "end") { + break; + } else if (ifVal != null) { + trIf = Transformation.new().if(ifVal); + this.chained[i].remove("if"); + trRest = this.chained[i]; + this.chained[i] = Transformation.new().transformation([trIf, trRest]); + if (ifVal !== "else") { + break; + } + } + } + return this.param(value, "if", "if"); + case "": + return _condition__WEBPACK_IMPORTED_MODULE_1__["default"].new().setParent(this); + default: + return this.param(value, "if", "if", function (value) { + return _condition__WEBPACK_IMPORTED_MODULE_1__["default"].new(value).toString(); + }); + } + } - DEFAULT_VIDEO_SOURCE_TYPES = ['webm', 'mp4', 'ogv']; + keyframeInterval(value) { + return this.param(value, "keyframe_interval", "ki"); + } - SEO_TYPES = { - "image/upload": "images", - "image/private": "private_images", - "image/authenticated": "authenticated_images", - "raw/upload": "files", - "video/upload": "videos" - }; + offset(value) { + var end_o, start_o; + [start_o, end_o] = (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isFunction"])(value != null ? value.split : void 0)) ? value.split('..') : Object(_util__WEBPACK_IMPORTED_MODULE_3__["isArray"])(value) ? value : [null, null]; + if (start_o != null) { + this.startOffset(start_o); + } + if (end_o != null) { + return this.endOffset(end_o); + } + } + opacity(value) { + return this.param(value, "opacity", "o", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } - /** - * @const {Object} Cloudinary.DEFAULT_IMAGE_PARAMS - * Defaults values for image parameters. - * - * (Previously defined using option_consume() ) - */ + overlay(value) { + return this.layerParam(value, "overlay", "l"); + } - Cloudinary.DEFAULT_IMAGE_PARAMS = { - resource_type: "image", - transformation: [], - type: 'upload' - }; + page(value) { + return this.param(value, "page", "pg"); + } + poster(value) { + return this.param(value, "poster"); + } - /** - * Defaults values for video parameters. - * @const {Object} Cloudinary.DEFAULT_VIDEO_PARAMS - * (Previously defined using option_consume() ) - */ + prefix(value) { + return this.param(value, "prefix", "p"); + } - Cloudinary.DEFAULT_VIDEO_PARAMS = { - fallback_content: '', - resource_type: "video", - source_transformation: {}, - source_types: DEFAULT_VIDEO_SOURCE_TYPES, - transformation: [], - type: 'upload' - }; + quality(value) { + return this.param(value, "quality", "q", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } + radius(value) { + return this.param(value, "radius", "r", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } - /** - * Main Cloudinary class - * @class Cloudinary - * @param {Object} options - options to configure Cloudinary - * @see Configuration for more details - * @example - * var cl = new cloudinary.Cloudinary( { cloud_name: "mycloud"}); - * var imgTag = cl.image("myPicID"); - */ + rawTransformation(value) { + return this.rawParam(value, "raw_transformation"); + } - function Cloudinary(options) { - var configuration; - this.devicePixelRatioCache = {}; - this.responsiveConfig = {}; - this.responsiveResizeInitialized = false; - configuration = new Configuration(options); - this.config = function(newConfig, newValue) { - return configuration.config(newConfig, newValue); - }; - - /** - * Use \ tags in the document to configure this Cloudinary instance. - * @return {Cloudinary} this for chaining - */ - this.fromDocument = function() { - configuration.fromDocument(); - return this; - }; - - /** - * Use environment variables to configure this Cloudinary instance. - * @return {Cloudinary} this for chaining - */ - this.fromEnvironment = function() { - configuration.fromEnvironment(); - return this; - }; - - /** - * Initialize configuration. - * @function Cloudinary#init - * @see Configuration#init - * @return {Cloudinary} this for chaining - */ - this.init = function() { - configuration.init(); - return this; - }; + size(value) { + var height, width; + if (Object(_util__WEBPACK_IMPORTED_MODULE_3__["isFunction"])(value != null ? value.split : void 0)) { + [width, height] = value.split('x'); + this.width(width); + return this.height(height); } + } + sourceTypes(value) { + return this.param(value, "source_types"); + } - /** - * Convenience constructor - * @param {Object} options - * @return {Cloudinary} - * @example cl = cloudinary.Cloudinary.new( { cloud_name: "mycloud"}) - */ + sourceTransformation(value) { + return this.param(value, "source_transformation"); + } - Cloudinary["new"] = function(options) { - return new this(options); - }; + startOffset(value) { + return this.rangeParam(value, "start_offset", "so"); + } + streamingProfile(value) { + return this.param(value, "streaming_profile", "sp"); + } - /** - * Return the resource type and action type based on the given configuration - * @function Cloudinary#finalizeResourceType - * @param {Object|string} resourceType - * @param {string} [type='upload'] - * @param {string} [urlSuffix] - * @param {boolean} [useRootPath] - * @param {boolean} [shorten] - * @returns {string} resource_type/type - * @ignore - */ + transformation(value) { + return this.transformationParam(value, "transformation", "t"); + } - finalizeResourceType = function(resourceType, type, urlSuffix, useRootPath, shorten) { - var key, options; - if (resourceType == null) { - resourceType = "image"; - } - if (type == null) { - type = "upload"; - } - if (Util.isPlainObject(resourceType)) { - options = resourceType; - resourceType = options.resource_type; - type = options.type; - urlSuffix = options.url_suffix; - useRootPath = options.use_root_path; - shorten = options.shorten; - } - if (type == null) { - type = 'upload'; - } - if (urlSuffix != null) { - resourceType = SEO_TYPES[resourceType + "/" + type]; - type = null; - if (resourceType == null) { - throw new Error("URL Suffix only supported for " + (((function() { - var results; - results = []; - for (key in SEO_TYPES) { - results.push(key); - } - return results; - })()).join(', '))); - } - } - if (useRootPath) { - if (resourceType === 'image' && type === 'upload' || resourceType === "images") { - resourceType = null; - type = null; - } else { - throw new Error("Root path only supported for image/upload"); - } - } - if (shorten && resourceType === 'image' && type === 'upload') { - resourceType = 'iu'; - type = null; - } - return [resourceType, type].join("/"); - }; + underlay(value) { + return this.layerParam(value, "underlay", "u"); + } - absolutize = function(url) { - var prefix; - if (!url.match(/^https?:\//)) { - prefix = document.location.protocol + '//' + document.location.host; - if (url[0] === '?') { - prefix += document.location.pathname; - } else if (url[0] !== '/') { - prefix += document.location.pathname.replace(/\/[^\/]*$/, '/'); - } - url = prefix + url; - } - return url; - }; + variable(name, value) { + return this.param(value, name, name); + } + variables(values) { + return this.arrayParam(values, "variables"); + } - /** - * Generate an resource URL. - * @function Cloudinary#url - * @param {string} publicId - the public ID of the resource - * @param {Object} [options] - options for the tag and transformations, possible values include all {@link Transformation} parameters - * and {@link Configuration} parameters - * @param {string} [options.type='upload'] - the classification of the resource - * @param {Object} [options.resource_type='image'] - the type of the resource - * @return {string} The resource URL - */ + videoCodec(value) { + return this.param(value, "video_codec", "vc", _parameters__WEBPACK_IMPORTED_MODULE_4__["Param"].process_video_params); + } - Cloudinary.prototype.url = function(publicId, options) { - var error, error1, prefix, ref, resourceTypeAndType, transformation, transformationString, url, version; - if (options == null) { - options = {}; - } - if (!publicId) { - return publicId; - } - if (options instanceof Transformation) { - options = options.toOptions(); - } - options = Util.defaults({}, options, this.config(), Cloudinary.DEFAULT_IMAGE_PARAMS); - if (options.type === 'fetch') { - options.fetch_format = options.fetch_format || options.format; - publicId = absolutize(publicId); - } - transformation = new Transformation(options); - transformationString = transformation.serialize(); - if (!options.cloud_name) { - throw 'Unknown cloud_name'; - } - if (publicId.search('/') >= 0 && !publicId.match(/^v[0-9]+/) && !publicId.match(/^https?:\//) && !((ref = options.version) != null ? ref.toString() : void 0)) { - options.version = 1; - } - if (publicId.match(/^https?:/)) { - if (options.type === 'upload' || options.type === 'asset') { - url = publicId; - } else { - publicId = encodeURIComponent(publicId).replace(/%3A/g, ':').replace(/%2F/g, '/'); - } + videoSampling(value) { + return this.param(value, "video_sampling", "vs"); + } + + width(value) { + return this.param(value, "width", "w", () => { + if (this.getValue("crop") || this.getValue("overlay") || this.getValue("underlay")) { + return _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize(value); } else { - try { - publicId = decodeURIComponent(publicId); - } catch (error1) { - error = error1; - } - publicId = encodeURIComponent(publicId).replace(/%3A/g, ':').replace(/%2F/g, '/'); - if (options.url_suffix) { - if (options.url_suffix.match(/[\.\/]/)) { - throw 'url_suffix should not include . or /'; - } - publicId = publicId + '/' + options.url_suffix; - } - if (options.format) { - if (!options.trust_public_id) { - publicId = publicId.replace(/\.(jpg|png|gif|webp)$/, ''); - } - publicId = publicId + '.' + options.format; - } + return null; } - prefix = cloudinaryUrlPrefix(publicId, options); - resourceTypeAndType = finalizeResourceType(options.resource_type, options.type, options.url_suffix, options.use_root_path, options.shorten); - version = options.version ? 'v' + options.version : ''; - return url || Util.compact([prefix, resourceTypeAndType, transformationString, version, publicId]).join('/').replace(/([^:])\/+/g, '$1/'); - }; + }); + } + x(value) { + return this.param(value, "x", "x", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } - /** - * Generate an video resource URL. - * @function Cloudinary#video_url - * @param {string} publicId - the public ID of the resource - * @param {Object} [options] - options for the tag and transformations, possible values include all {@link Transformation} parameters - * and {@link Configuration} parameters - * @param {string} [options.type='upload'] - the classification of the resource - * @return {string} The video URL - */ + y(value) { + return this.param(value, "y", "y", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } - Cloudinary.prototype.video_url = function(publicId, options) { - options = Util.assign({ - resource_type: 'video' - }, options); - return this.url(publicId, options); - }; + zoom(value) { + return this.param(value, "zoom", "z", _expression__WEBPACK_IMPORTED_MODULE_0__["default"].normalize); + } +}; - /** - * Generate an video thumbnail URL. - * @function Cloudinary#video_thumbnail_url - * @param {string} publicId - the public ID of the resource - * @param {Object} [options] - options for the tag and transformations, possible values include all {@link Transformation} parameters - * and {@link Configuration} parameters - * @param {string} [options.type='upload'] - the classification of the resource - * @return {string} The video thumbnail URL - */ +/** + * Transformation Class methods. + * This is a list of the parameters defined in Transformation. + * Values are camelCased. + */ +Transformation.methods = Object.getOwnPropertyNames(Transformation.prototype); - Cloudinary.prototype.video_thumbnail_url = function(publicId, options) { - options = Util.assign({}, DEFAULT_POSTER_OPTIONS, options); - return this.url(publicId, options); - }; +/** + * Parameters that are filtered out before passing the options to an HTML tag. + * + * The list of parameters is a combination of `Transformation::methods` and `Configuration::CONFIG_PARAMS` + */ +Transformation.PARAM_NAMES = Transformation.methods.map(_util__WEBPACK_IMPORTED_MODULE_3__["snakeCase"]).concat(_configuration__WEBPACK_IMPORTED_MODULE_2__["default"].CONFIG_PARAMS); +/* harmony default export */ __webpack_exports__["default"] = (Transformation); - /** - * Generate a string representation of the provided transformation options. - * @function Cloudinary#transformation_string - * @param {Object} options - the transformation options - * @returns {string} The transformation string - */ - Cloudinary.prototype.transformation_string = function(options) { - return new Transformation(options).serialize(); - }; +/***/ }), +/***/ "./src/url.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * Generate an image tag. - * @function Cloudinary#image - * @param {string} publicId - the public ID of the image - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} an image tag element - */ +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return url; }); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/transformation.js"); +/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/constants.js"); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _crc32__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/crc32.js"); - Cloudinary.prototype.image = function(publicId, options) { - var client_hints, img, ref, ref1; - if (options == null) { - options = {}; - } - img = this.imageTag(publicId, options); - client_hints = (ref = (ref1 = options.client_hints) != null ? ref1 : this.config('client_hints')) != null ? ref : false; - if (!((options.src != null) || client_hints)) { - img.setAttr("src", ''); - } - img = img.toDOM(); - if (!client_hints) { - Util.setData(img, 'src-cache', this.url(publicId, options)); - this.cloudinary_update(img, options); - } - return img; - }; - /** - * Creates a new ImageTag instance, configured using this own's configuration. - * @function Cloudinary#imageTag - * @param {string} publicId - the public ID of the resource - * @param {Object} options - additional options to pass to the new ImageTag instance - * @return {ImageTag} An ImageTag that is attached (chained) to this Cloudinary instance - */ - Cloudinary.prototype.imageTag = function(publicId, options) { - var tag; - tag = new ImageTag(publicId, this.config()); - tag.transformation().fromOptions(options); - return tag; - }; - /** - * Generate an image tag for the video thumbnail. - * @function Cloudinary#video_thumbnail - * @param {string} publicId - the public ID of the video - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} An image tag element - */ - Cloudinary.prototype.video_thumbnail = function(publicId, options) { - return this.image(publicId, Util.merge({}, DEFAULT_POSTER_OPTIONS, options)); - }; - /** - * @function Cloudinary#facebook_profile_image - * @param {string} publicId - the public ID of the image - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} an image tag element - */ +function absolutize(url) { + var prefix; + if (!url.match(/^https?:\//)) { + prefix = document.location.protocol + '//' + document.location.host; + if (url[0] === '?') { + prefix += document.location.pathname; + } else if (url[0] !== '/') { + prefix += document.location.pathname.replace(/\/[^\/]*$/, '/'); + } + url = prefix + url; + } + return url; +} + +// Produce a number between 1 and 5 to be used for cdn sub domains designation +function cdnSubdomainNumber(publicId) { + return Object(_crc32__WEBPACK_IMPORTED_MODULE_3__["default"])(publicId) % 5 + 1; +} + +// * cdn_subdomain - Boolean (default: false). Whether to automatically build URLs with multiple CDN sub-domains. See this blog post for more details. +// * private_cdn - Boolean (default: false). Should be set to true for Advanced plan's users that have a private CDN distribution. +// * secure_distribution - The domain name of the CDN distribution to use for building HTTPS URLs. Relevant only for Advanced plan's users that have a private CDN distribution. +// * cname - Custom domain name to use for building HTTP URLs. Relevant only for Advanced plan's users that have a private CDN distribution and a custom CNAME. +// * secure - Boolean (default: false). Force HTTPS URLs of images even if embedded in non-secure HTTP pages. +function cloudinaryUrlPrefix(publicId, options) { + var cdnPart, host, path, protocol, ref, subdomain; + if (((ref = options.cloud_name) != null ? ref.indexOf("/") : void 0) === 0) { + return '/res' + options.cloud_name; + } + // defaults + protocol = "http://"; + cdnPart = ""; + subdomain = "res"; + host = ".cloudinary.com"; + path = "/" + options.cloud_name; + // modifications + if (options.protocol) { + protocol = options.protocol + '//'; + } + if (options.private_cdn) { + cdnPart = options.cloud_name + "-"; + path = ""; + } + if (options.cdn_subdomain) { + subdomain = "res-" + cdnSubdomainNumber(publicId); + } + if (options.secure) { + protocol = "https://"; + if (options.secure_cdn_subdomain === false) { + subdomain = "res"; + } + if ((options.secure_distribution != null) && options.secure_distribution !== _constants__WEBPACK_IMPORTED_MODULE_1__["OLD_AKAMAI_SHARED_CDN"] && options.secure_distribution !== _constants__WEBPACK_IMPORTED_MODULE_1__["SHARED_CDN"]) { + cdnPart = ""; + subdomain = ""; + host = options.secure_distribution; + } + } else if (options.cname) { + protocol = "http://"; + cdnPart = ""; + subdomain = options.cdn_subdomain ? 'a' + ((Object(_crc32__WEBPACK_IMPORTED_MODULE_3__["default"])(publicId) % 5) + 1) + '.' : ''; + host = options.cname; + } + return [protocol, cdnPart, subdomain, host, path].join(""); +} - Cloudinary.prototype.facebook_profile_image = function(publicId, options) { - return this.image(publicId, Util.assign({ - type: 'facebook' - }, options)); - }; +/** + * Return the resource type and action type based on the given configuration + * @function Cloudinary#finalizeResourceType + * @param {Object|string} resourceType + * @param {string} [type='upload'] + * @param {string} [urlSuffix] + * @param {boolean} [useRootPath] + * @param {boolean} [shorten] + * @returns {string} resource_type/type + * @ignore + */ +function finalizeResourceType(resourceType = "image", type = "upload", urlSuffix, useRootPath, shorten) { + var key, options; + if (Object(_util__WEBPACK_IMPORTED_MODULE_2__["isPlainObject"])(resourceType)) { + options = resourceType; + resourceType = options.resource_type; + type = options.type; + urlSuffix = options.url_suffix; + useRootPath = options.use_root_path; + shorten = options.shorten; + } + if (type == null) { + type = 'upload'; + } + if (urlSuffix != null) { + resourceType = _constants__WEBPACK_IMPORTED_MODULE_1__["SEO_TYPES"][`${resourceType}/${type}`]; + type = null; + if (resourceType == null) { + throw new Error(`URL Suffix only supported for ${((function () { + var results; + results = []; + for (key in _constants__WEBPACK_IMPORTED_MODULE_1__["SEO_TYPES"]) { + results.push(key); + } + return results; + })()).join(', ')}`); + } + } + if (useRootPath) { + if (resourceType === 'image' && type === 'upload' || resourceType === "images") { + resourceType = null; + type = null; + } else { + throw new Error("Root path only supported for image/upload"); + } + } + if (shorten && resourceType === 'image' && type === 'upload') { + resourceType = 'iu'; + type = null; + } + return [resourceType, type].join("/"); +} +/** + * Generate an resource URL. + * @function Cloudinary#url + * @param {string} publicId - the public ID of the resource + * @param {Object} [options] - options for the tag and transformations, possible values include all {@link Transformation} parameters + * and {@link Configuration} parameters + * @param {string} [options.type='upload'] - the classification of the resource + * @param {Object} [options.resource_type='image'] - the type of the resource + * @param {Object} [config] URL configuration + * @return {string} The resource URL + */ +function url(publicId, options = {}, config = {}) { + var error, prefix, ref, resourceTypeAndType, transformation, transformationString, url, version; + if (!publicId) { + return publicId; + } + if (options instanceof _transformation__WEBPACK_IMPORTED_MODULE_0__["default"]) { + options = options.toOptions(); + } + options = Object(_util__WEBPACK_IMPORTED_MODULE_2__["defaults"])({}, options, config, _constants__WEBPACK_IMPORTED_MODULE_1__["DEFAULT_IMAGE_PARAMS"]); + if (options.type === 'fetch') { + options.fetch_format = options.fetch_format || options.format; + publicId = absolutize(publicId); + } + transformation = new _transformation__WEBPACK_IMPORTED_MODULE_0__["default"](options); + transformationString = transformation.serialize(); + if (!options.cloud_name) { + throw 'Unknown cloud_name'; + } + // if publicId has a '/' and doesn't begin with v and doesn't start with http[s]:/ and version is empty + if (publicId.search('/') >= 0 && !publicId.match(/^v[0-9]+/) && !publicId.match(/^https?:\//) && !((ref = options.version) != null ? ref.toString() : void 0)) { + options.version = 1; + } + if (publicId.match(/^https?:/)) { + if (options.type === 'upload' || options.type === 'asset') { + url = publicId; + } else { + publicId = encodeURIComponent(publicId).replace(/%3A/g, ':').replace(/%2F/g, '/'); + } + } else { + try { + // Make sure publicId is URI encoded. + publicId = decodeURIComponent(publicId); + } catch (error1) { + error = error1; + } + publicId = encodeURIComponent(publicId).replace(/%3A/g, ':').replace(/%2F/g, '/'); + if (options.url_suffix) { + if (options.url_suffix.match(/[\.\/]/)) { + throw 'url_suffix should not include . or /'; + } + publicId = publicId + '/' + options.url_suffix; + } + if (options.format) { + if (!options.trust_public_id) { + publicId = publicId.replace(/\.(jpg|png|gif|webp)$/, ''); + } + publicId = publicId + '.' + options.format; + } + } + prefix = cloudinaryUrlPrefix(publicId, options); + resourceTypeAndType = finalizeResourceType(options.resource_type, options.type, options.url_suffix, options.use_root_path, options.shorten); + version = options.version ? 'v' + options.version : ''; + return url || Object(_util__WEBPACK_IMPORTED_MODULE_2__["compact"])([prefix, resourceTypeAndType, transformationString, version, publicId]).join('/').replace(/([^:])\/+/g, '$1/'); +}; - /** - * @function Cloudinary#twitter_profile_image - * @param {string} publicId - the public ID of the image - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} an image tag element - */ - Cloudinary.prototype.twitter_profile_image = function(publicId, options) { - return this.image(publicId, Util.assign({ - type: 'twitter' - }, options)); - }; +/***/ }), +/***/ "./src/utf8_encode.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * @function Cloudinary#twitter_name_profile_image - * @param {string} publicId - the public ID of the image - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} an image tag element - */ +"use strict"; +__webpack_require__.r(__webpack_exports__); +/** + * UTF8 encoder + * + */ +var utf8_encode; + +/* harmony default export */ __webpack_exports__["default"] = (utf8_encode = function(argString) { + var c1, enc, end, n, start, string, stringl, utftext; + // http://kevin.vanzonneveld.net + // + original by: Webtoolkit.info (http://www.webtoolkit.info/) + // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + improved by: sowberry + // + tweaked by: Jack + // + bugfixed by: Onno Marsman + // + improved by: Yves Sucaet + // + bugfixed by: Onno Marsman + // + bugfixed by: Ulrich + // + bugfixed by: Rafal Kukawski + // + improved by: kirilloid + // * example 1: utf8_encode('Kevin van Zonneveld'); + // * returns 1: 'Kevin van Zonneveld' + if (argString === null || typeof argString === 'undefined') { + return ''; + } + string = argString + ''; + // .replace(/\r\n/g, "\n").replace(/\r/g, "\n"); + utftext = ''; + start = void 0; + end = void 0; + stringl = 0; + start = end = 0; + stringl = string.length; + n = 0; + while (n < stringl) { + c1 = string.charCodeAt(n); + enc = null; + if (c1 < 128) { + end++; + } else if (c1 > 127 && c1 < 2048) { + enc = String.fromCharCode(c1 >> 6 | 192, c1 & 63 | 128); + } else { + enc = String.fromCharCode(c1 >> 12 | 224, c1 >> 6 & 63 | 128, c1 & 63 | 128); + } + if (enc !== null) { + if (end > start) { + utftext += string.slice(start, end); + } + utftext += enc; + start = end = n + 1; + } + n++; + } + if (end > start) { + utftext += string.slice(start, stringl); + } + return utftext; +}); - Cloudinary.prototype.twitter_name_profile_image = function(publicId, options) { - return this.image(publicId, Util.assign({ - type: 'twitter_name' - }, options)); - }; +/***/ }), + +/***/ "./src/util/baseutil.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "allStrings", function() { return allStrings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "without", function() { return without; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNumberLike", function() { return isNumberLike; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "smartEscape", function() { return smartEscape; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaults", function() { return defaults; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "objectProto", function() { return objectProto; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "objToString", function() { return objToString; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isObject", function() { return isObject; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "funcTag", function() { return funcTag; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isFunction", function() { return isFunction; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reWords", function() { return reWords; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "camelCase", function() { return camelCase; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "snakeCase", function() { return snakeCase; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertKeys", function() { return convertKeys; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "withCamelCaseKeys", function() { return withCamelCaseKeys; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "withSnakeCaseKeys", function() { return withSnakeCaseKeys; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "base64Encode", function() { return base64Encode; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "base64EncodeURL", function() { return base64EncodeURL; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractUrlParams", function() { return extractUrlParams; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "patchFetchFormat", function() { return patchFetchFormat; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "optionConsume", function() { return optionConsume; }); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/util/jquery.js"); +/* + * Includes common utility methods and shims + */ - /** - * @function Cloudinary#gravatar_image - * @param {string} publicId - the public ID of the image - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} an image tag element - */ - Cloudinary.prototype.gravatar_image = function(publicId, options) { - return this.image(publicId, Util.assign({ - type: 'gravatar' - }, options)); - }; - /** - * @function Cloudinary#fetch_image - * @param {string} publicId - the public ID of the image - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} an image tag element - */ +/** + * Return true if all items in list are strings + * @function Util.allString + * @param {Array} list - an array of items + */ +var allStrings = function(list) { + return list.length && list.every(_util__WEBPACK_IMPORTED_MODULE_0__["isString"]); +}; - Cloudinary.prototype.fetch_image = function(publicId, options) { - return this.image(publicId, Util.assign({ - type: 'fetch' - }, options)); - }; +/** +* Creates a new array without the given item. +* @function Util.without +* @param {Array} array - original array +* @param {*} item - the item to exclude from the new array +* @return {Array} a new array made of the original array's items except for `item` + */ +var without = function(array, item) { + return array.filter(v=>v!==item); +}; +/** +* Return true is value is a number or a string representation of a number. +* @function Util.isNumberLike +* @param {*} value +* @returns {boolean} true if value is a number +* @example +* Util.isNumber(0) // true +* Util.isNumber("1.3") // true +* Util.isNumber("") // false +* Util.isNumber(undefined) // false + */ +var isNumberLike = function(value) { + return (value != null) && !isNaN(parseFloat(value)); +}; - /** - * @function Cloudinary#video - * @param {string} publicId - the public ID of the image - * @param {Object} [options] - options for the tag and transformations - * @return {HTMLImageElement} an image tag element - */ +/** + * Escape all characters matching unsafe in the given string + * @function Util.smartEscape + * @param {string} string - source string to escape + * @param {RegExp} unsafe - characters that must be escaped + * @return {string} escaped string + */ +var smartEscape = function(string, unsafe = /([^a-zA-Z0-9_.\-\/:]+)/g) { + return string.replace(unsafe, function(match) { + return match.split("").map(function(c) { + return "%" + c.charCodeAt(0).toString(16).toUpperCase(); + }).join(""); + }); +}; - Cloudinary.prototype.video = function(publicId, options) { - if (options == null) { - options = {}; +/** + * Assign values from sources if they are not defined in the destination. + * Once a value is set it does not change + * @function Util.defaults + * @param {Object} destination - the object to assign defaults to + * @param {...Object} source - the source object(s) to assign defaults from + * @return {Object} destination after it was modified + */ +var defaults = function(destination, ...sources) { + return sources.reduce(function(dest, source) { + let key, value; + for (key in source) { + value = source[key]; + if (dest[key] === void 0) { + dest[key] = value; } - return this.videoTag(publicId, options).toHtml(); - }; - + } + return dest; + }, destination); +}; - /** - * Creates a new VideoTag instance, configured using this own's configuration. - * @function Cloudinary#videoTag - * @param {string} publicId - the public ID of the resource - * @param {Object} options - additional options to pass to the new VideoTag instance - * @return {VideoTag} A VideoTag that is attached (chained) to this Cloudinary instance - */ +/*********** lodash functions */ +var objectProto = Object.prototype; - Cloudinary.prototype.videoTag = function(publicId, options) { - options = Util.defaults({}, options, this.config()); - return new VideoTag(publicId, options); - }; +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; +/** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * +#isObject({}); + * // => true + * +#isObject([1, 2, 3]); + * // => true + * +#isObject(1); + * // => false + */ +var isObject = function(value) { + var type; + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + type = typeof value; + return !!value && (type === 'object' || type === 'function'); +}; - /** - * Generate the URL of the sprite image - * @function Cloudinary#sprite_css - * @param {string} publicId - the public ID of the resource - * @param {Object} [options] - options for the tag and transformations - * @see {@link http://cloudinary.com/documentation/sprite_generation Sprite generation} - */ +var funcTag = '[object Function]'; - Cloudinary.prototype.sprite_css = function(publicId, options) { - options = Util.assign({ - type: 'sprite' - }, options); - if (!publicId.match(/.css$/)) { - options.format = 'css'; - } - return this.url(publicId, options); - }; +/** +* Checks if `value` is classified as a `Function` object. +* @function Util.isFunction +* @param {*} value The value to check. +* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. +* @example +* +* function Foo(){}; +* isFunction(Foo); +* // => true +* +* isFunction(/abc/); +* // => false + */ +var isFunction = function(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 which returns 'object' for typed array constructors. + return isObject(value) && objToString.call(value) === funcTag; +}; + +/*********** lodash functions */ +/** Used to match words to create compound words. */ +var reWords = (function() { + var lower, upper; + upper = '[A-Z]'; + lower = '[a-z]+'; + return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); +})(); +/** +* Convert string to camelCase +* @function Util.camelCase +* @param {string} source - the string to convert +* @return {string} in camelCase format + */ +var camelCase = function(source) { + var words = source.match(reWords); + words = words.map(word=> word.charAt(0).toLocaleUpperCase() + word.slice(1).toLocaleLowerCase()); + words[0] = words[0].toLocaleLowerCase(); - /** - * Initialize the responsive behaviour.
- * Calls {@link Cloudinary#cloudinary_update} to modify image tags. - * @function Cloudinary#responsive - * @param {Object} options - * @param {String} [options.responsive_class='cld-responsive'] - provide an alternative class used to locate img tags - * @param {number} [options.responsive_debounce=100] - the debounce interval in milliseconds. - * @param {boolean} [bootstrap=true] if true processes the img tags by calling cloudinary_update. When false the tags will be processed only after a resize event. - * @see {@link Cloudinary#cloudinary_update} for additional configuration parameters - */ + return words.join(''); +}; - Cloudinary.prototype.responsive = function(options, bootstrap) { - var ref, ref1, ref2, responsiveClass, responsiveResize, timeout; - if (bootstrap == null) { - bootstrap = true; - } - this.responsiveConfig = Util.merge(this.responsiveConfig || {}, options); - responsiveClass = (ref = this.responsiveConfig['responsive_class']) != null ? ref : this.config('responsive_class'); - if (bootstrap) { - this.cloudinary_update("img." + responsiveClass + ", img.cld-hidpi", this.responsiveConfig); - } - responsiveResize = (ref1 = (ref2 = this.responsiveConfig['responsive_resize']) != null ? ref2 : this.config('responsive_resize')) != null ? ref1 : true; - if (responsiveResize && !this.responsiveResizeInitialized) { - this.responsiveConfig.resizing = this.responsiveResizeInitialized = true; - timeout = null; - return window.addEventListener('resize', (function(_this) { - return function() { - var debounce, ref3, ref4, reset, run, wait, waitFunc; - debounce = (ref3 = (ref4 = _this.responsiveConfig['responsive_debounce']) != null ? ref4 : _this.config('responsive_debounce')) != null ? ref3 : 100; - reset = function() { - if (timeout) { - clearTimeout(timeout); - return timeout = null; - } - }; - run = function() { - return _this.cloudinary_update("img." + responsiveClass, _this.responsiveConfig); - }; - waitFunc = function() { - reset(); - return run(); - }; - wait = function() { - reset(); - return timeout = setTimeout(waitFunc, debounce); - }; - if (debounce) { - return wait(); - } else { - return run(); - } - }; - })(this)); - } - }; +/** + * Convert string to snake_case + * @function Util.snakeCase + * @param {string} source - the string to convert + * @return {string} in snake_case format + */ +var snakeCase = function(source) { + var words = source.match(reWords); + words = words.map(word=> word.toLocaleLowerCase()); + return words.join('_'); +}; + +var convertKeys = function(source, converter = _util__WEBPACK_IMPORTED_MODULE_0__["identity"]) { + var key, result, value; + result = {}; + for (key in source) { + value = source[key]; + key = converter(key); + if (!Object(_util__WEBPACK_IMPORTED_MODULE_0__["isEmpty"])(key)) { + result[key] = value; + } + } + return result; +}; +/** + * Create a copy of the source object with all keys in camelCase + * @function Util.withCamelCaseKeys + * @param {Object} value - the object to copy + * @return {Object} a new object + */ +var withCamelCaseKeys = function(source) { + return convertKeys(source, camelCase); +}; - /** - * @function Cloudinary#calc_breakpoint - * @private - * @ignore - */ +/** + * Create a copy of the source object with all keys in snake_case + * @function Util.withSnakeCaseKeys + * @param {Object} value - the object to copy + * @return {Object} a new object + */ +var withSnakeCaseKeys = function(source) { + return convertKeys(source, snakeCase); +}; + +// Browser +// Node.js +var base64Encode = typeof btoa !== 'undefined' && isFunction(btoa) ? btoa : typeof Buffer !== 'undefined' && isFunction(Buffer) ? function(input) { + if (!(input instanceof Buffer)) { + input = new Buffer.from(String(input), 'binary'); + } + return input.toString('base64'); +} : function(input) { + throw new Error("No base64 encoding function found"); +}; - Cloudinary.prototype.calc_breakpoint = function(element, width, steps) { - var breakpoints, point; - breakpoints = Util.getData(element, 'breakpoints') || Util.getData(element, 'stoppoints') || this.config('breakpoints') || this.config('stoppoints') || defaultBreakpoints; - if (Util.isFunction(breakpoints)) { - return breakpoints(width, steps); - } else { - if (Util.isString(breakpoints)) { - breakpoints = ((function() { - var j, len, ref, results; - ref = breakpoints.split(','); - results = []; - for (j = 0, len = ref.length; j < len; j++) { - point = ref[j]; - results.push(parseInt(point)); - } - return results; - })()).sort(function(a, b) { - return a - b; - }); - } - return closestAbove(breakpoints, width); - } - }; +/** +* Returns the Base64-decoded version of url.
+* This method delegates to `btoa` if present. Otherwise it tries `Buffer`. +* @function Util.base64EncodeURL +* @param {string} url - the url to encode. the value is URIdecoded and then re-encoded before converting to base64 representation +* @return {string} the base64 representation of the URL + */ +var base64EncodeURL = function(url) { + try { + url = decodeURI(url); + } finally { + url = encodeURI(url); + } + return base64Encode(url); +}; +/** + * A list of keys used by the url() function. + * @private + */ +const URL_KEYS = [ + 'api_secret', + 'auth_token', + 'cdn_subdomain', + 'cloud_name', + 'cname', + 'format', + 'private_cdn', + 'resource_type', + 'secure', + 'secure_cdn_subdomain', + 'secure_distribution', + 'shorten', + 'sign_url', + 'ssl_detected', + 'type', + 'url_suffix', + 'use_root_path', + 'version' +]; - /** - * @function Cloudinary#calc_stoppoint - * @deprecated Use {@link calc_breakpoint} instead. - * @private - * @ignore - */ +/** + * Create a new object with only URL parameters + * @param {object} options The source object + * @return {Object} An object containing only URL parameters + */ +function extractUrlParams(options) { + return URL_KEYS.reduce((obj, key) => { + if (options[key] != null) { + obj[key] = options[key]; + } + return obj; + }, {}); +} - Cloudinary.prototype.calc_stoppoint = Cloudinary.prototype.calc_breakpoint; +/** + * Handle the format parameter for fetch urls + * @private + * @param options url and transformation options. This argument may be changed by the function! + */ +function patchFetchFormat(options={}) { + if (options.type === "fetch") { + if (options.fetch_format == null) { + options.fetch_format = optionConsume(options, "format"); + } + } +} - /** - * @function Cloudinary#device_pixel_ratio - * @private - */ +/** + * Deletes `option_name` from `options` and return the value if present. + * If `options` doesn't contain `option_name` the default value is returned. + * @param {Object} options a collection + * @param {String} option_name the name (key) of the desired value + * @param {*} [default_value] the value to return is option_name is missing + */ +function optionConsume(options, option_name, default_value) { + let result = options[option_name]; + delete options[option_name]; + if (result != null) { + return result; + } else { + return default_value; + } +} - Cloudinary.prototype.device_pixel_ratio = function(roundDpr) { - var dpr, dprString; - if (roundDpr == null) { - roundDpr = true; - } - dpr = (typeof window !== "undefined" && window !== null ? window.devicePixelRatio : void 0) || 1; - if (roundDpr) { - dpr = Math.ceil(dpr); - } - if (dpr <= 0 || dpr === NaN) { - dpr = 1; - } - dprString = dpr.toString(); - if (dprString.match(/^\d+$/)) { - dprString += '.0'; - } - return dprString; - }; - defaultBreakpoints = function(width, steps) { - if (steps == null) { - steps = 100; - } - return steps * Math.ceil(width / steps); - }; +/***/ }), - closestAbove = function(list, value) { - var i; - i = list.length - 2; - while (i >= 0 && list[i] >= value) { - i--; - } - return list[i + 1]; - }; +/***/ "./src/util/firstNotNull.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - cdnSubdomainNumber = function(publicId) { - return crc32(publicId) % 5 + 1; - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/** + * Return the first argument whose value is not null + * @param args + * @returns {*} + */ +let firstNotNull = function firstNotNull(...args) { + while(args && args.length > 0) { + let next = args.shift(); + if( next != null){ + return next; + } + } + return null; +}; - cloudinaryUrlPrefix = function(publicId, options) { - var cdnPart, host, path, protocol, ref, subdomain; - if (((ref = options.cloud_name) != null ? ref.indexOf("/") : void 0) === 0) { - return '/res' + options.cloud_name; - } - protocol = "http://"; - cdnPart = ""; - subdomain = "res"; - host = ".cloudinary.com"; - path = "/" + options.cloud_name; - if (options.protocol) { - protocol = options.protocol + '//'; - } - if (options.private_cdn) { - cdnPart = options.cloud_name + "-"; - path = ""; - } - if (options.cdn_subdomain) { - subdomain = "res-" + cdnSubdomainNumber(publicId); - } - if (options.secure) { - protocol = "https://"; - if (options.secure_cdn_subdomain === false) { - subdomain = "res"; - } - if ((options.secure_distribution != null) && options.secure_distribution !== OLD_AKAMAI_SHARED_CDN && options.secure_distribution !== SHARED_CDN) { - cdnPart = ""; - subdomain = ""; - host = options.secure_distribution; - } - } else if (options.cname) { - protocol = "http://"; - cdnPart = ""; - subdomain = options.cdn_subdomain ? 'a' + ((crc32(publicId) % 5) + 1) + '.' : ''; - host = options.cname; - } - return [protocol, cdnPart, subdomain, host, path].join(""); - }; +/* harmony default export */ __webpack_exports__["default"] = (firstNotNull); - /** - * Finds all `img` tags under each node and sets it up to provide the image through Cloudinary - * @param {Element[]} nodes the parent nodes to search for img under - * @param {Object} [options={}] options and transformations params - * @function Cloudinary#processImageTags - */ +/***/ }), - Cloudinary.prototype.processImageTags = function(nodes, options) { - var images, imgOptions, node, publicId, url; - if (options == null) { - options = {}; - } - if (Util.isEmpty(nodes)) { - return this; - } - options = Util.defaults({}, options, this.config()); - images = (function() { - var j, len, ref, results; - results = []; - for (j = 0, len = nodes.length; j < len; j++) { - node = nodes[j]; - if (!(((ref = node.tagName) != null ? ref.toUpperCase() : void 0) === 'IMG')) { - continue; - } - imgOptions = Util.assign({ - width: node.getAttribute('width'), - height: node.getAttribute('height'), - src: node.getAttribute('src') - }, options); - publicId = imgOptions['source'] || imgOptions['src']; - delete imgOptions['source']; - delete imgOptions['src']; - url = this.url(publicId, imgOptions); - imgOptions = new Transformation(imgOptions).toHtmlAttributes(); - Util.setData(node, 'src-cache', url); - node.setAttribute('width', imgOptions.width); - node.setAttribute('height', imgOptions.height); - results.push(node); - } - return results; - }).call(this); - this.cloudinary_update(images, options); - return this; - }; +/***/ "./src/util/generateBreakpoints.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - applyBreakpoints = function(tag, width, steps, options) { - var ref, ref1, ref2, responsive_use_breakpoints; - responsive_use_breakpoints = (ref = (ref1 = (ref2 = options['responsive_use_breakpoints']) != null ? ref2 : options['responsive_use_stoppoints']) != null ? ref1 : this.config('responsive_use_breakpoints')) != null ? ref : this.config('responsive_use_stoppoints'); - if ((!responsive_use_breakpoints) || (responsive_use_breakpoints === 'resize' && !options.resizing)) { - return width; - } else { - return this.calc_breakpoint(tag, width, steps); - } - }; +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return generateBreakpoints; }); - findContainerWidth = function(element) { - var containerWidth, style; - containerWidth = 0; - while (((element = element != null ? element.parentNode : void 0) instanceof Element) && !containerWidth) { - style = window.getComputedStyle(element); - if (!/^inline/.test(style.display)) { - containerWidth = Util.width(element); - } - } - return containerWidth; - }; +/** + * Helper function. Gets or populates srcset breakpoints using provided parameters + * Either the breakpoints or min_width, max_width, max_images must be provided. + * + * @module utils + * @private + * @param {srcset} srcset Options with either `breakpoints` or `min_width`, `max_width`, and `max_images` + * + * @return {number[]} Array of breakpoints + * + */ +function generateBreakpoints(srcset) { + let breakpoints = srcset.breakpoints || []; + if (breakpoints.length) { + return breakpoints; + } + let [min_width, max_width, max_images] = [srcset.min_width, srcset.max_width, srcset.max_images].map(Number); + if ([min_width, max_width, max_images].some(isNaN)) { + throw 'Either (min_width, max_width, max_images) ' + + 'or breakpoints must be provided to the image srcset attribute'; + } - updateDpr = function(dataSrc, roundDpr) { - return dataSrc.replace(/\bdpr_(1\.0|auto)\b/g, 'dpr_' + this.device_pixel_ratio(roundDpr)); - }; + if (min_width > max_width) { + throw 'min_width must be less than max_width' + } - maxWidth = function(requiredWidth, tag) { - var imageWidth; - imageWidth = Util.getData(tag, 'width') || 0; - if (requiredWidth > imageWidth) { - imageWidth = requiredWidth; - Util.setData(tag, 'width', requiredWidth); - } - return imageWidth; - }; + if (max_images <= 0) { + throw 'max_images must be a positive integer'; + } else if (max_images === 1) { + min_width = max_width; + } + let stepSize = Math.ceil((max_width - min_width) / Math.max(max_images - 1, 1)); + for (let current = min_width; current < max_width; current += stepSize) { + breakpoints.push(current); + } + breakpoints.push(max_width); + return breakpoints; +} - /** - * Update hidpi (dpr_auto) and responsive (w_auto) fields according to the current container size and the device pixel ratio. - * Only images marked with the cld-responsive class have w_auto updated. - * @function Cloudinary#cloudinary_update - * @param {(Array|string|NodeList)} elements - the elements to modify - * @param {Object} options - * @param {boolean|string} [options.responsive_use_breakpoints=true] - * - when `true`, always use breakpoints for width - * - when `"resize"` use exact width on first render and breakpoints on resize - * - when `false` always use exact width - * @param {boolean} [options.responsive] - if `true`, enable responsive on this element. Can be done by adding cld-responsive. - * @param {boolean} [options.responsive_preserve_height] - if set to true, original css height is preserved. - * Should only be used if the transformation supports different aspect ratios. - */ - Cloudinary.prototype.cloudinary_update = function(elements, options) { - var containerWidth, dataSrc, j, len, match, ref, ref1, ref2, ref3, ref4, ref5, requiredWidth, responsive, responsiveClass, roundDpr, setUrl, tag; - if (options == null) { - options = {}; - } - if (elements === null) { - return this; - } - responsive = (ref = (ref1 = options.responsive) != null ? ref1 : this.config('responsive')) != null ? ref : false; - elements = (function() { - switch (false) { - case !Util.isArray(elements): - return elements; - case elements.constructor.name !== "NodeList": - return elements; - case !Util.isString(elements): - return document.querySelectorAll(elements); - default: - return [elements]; - } - })(); - responsiveClass = (ref2 = (ref3 = this.responsiveConfig['responsive_class']) != null ? ref3 : options['responsive_class']) != null ? ref2 : this.config('responsive_class'); - roundDpr = (ref4 = options['round_dpr']) != null ? ref4 : this.config('round_dpr'); - for (j = 0, len = elements.length; j < len; j++) { - tag = elements[j]; - if (!((ref5 = tag.tagName) != null ? ref5.match(/img/i) : void 0)) { - continue; - } - setUrl = true; - if (responsive) { - Util.addClass(tag, responsiveClass); - } - dataSrc = Util.getData(tag, 'src-cache') || Util.getData(tag, 'src'); - if (!Util.isEmpty(dataSrc)) { - dataSrc = updateDpr.call(this, dataSrc, roundDpr); - if (HtmlTag.isResponsive(tag, responsiveClass)) { - containerWidth = findContainerWidth(tag); - if (containerWidth !== 0) { - switch (false) { - case !/w_auto:breakpoints/.test(dataSrc): - requiredWidth = maxWidth(containerWidth, tag); - dataSrc = dataSrc.replace(/w_auto:breakpoints([_0-9]*)(:[0-9]+)?/, "w_auto:breakpoints$1:" + requiredWidth); - break; - case !(match = /w_auto(:(\d+))?/.exec(dataSrc)): - requiredWidth = applyBreakpoints.call(this, tag, containerWidth, match[2], options); - requiredWidth = maxWidth(requiredWidth, tag); - dataSrc = dataSrc.replace(/w_auto[^,\/]*/g, "w_" + requiredWidth); - } - Util.removeAttribute(tag, 'width'); - if (!options.responsive_preserve_height) { - Util.removeAttribute(tag, 'height'); - } - } else { - setUrl = false; - } - } - if (setUrl) { - Util.setAttribute(tag, 'src', dataSrc); - } - } - } - return this; - }; +/***/ }), +/***/ "./src/util/jquery.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { - /** - * Provide a transformation object, initialized with own's options, for chaining purposes. - * @function Cloudinary#transformation - * @param {Object} options - * @return {Transformation} - */ +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getData", function() { return getData; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setData", function() { return setData; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAttribute", function() { return getAttribute; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setAttribute", function() { return setAttribute; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAttribute", function() { return removeAttribute; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setAttributes", function() { return setAttributes; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasClass", function() { return hasClass; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addClass", function() { return addClass; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "width", function() { return width; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return isEmpty; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isString", function() { return isString; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "merge", function() { return merge; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compact", function() { return compact; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cloneDeep", function() { return cloneDeep; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "contains", function() { return contains; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "difference", function() { return difference; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "functions", function() { return functions; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isArray", function() { return isArray; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "assign", function() { return assign; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isPlainObject", function() { return isPlainObject; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "trim", function() { return trim; }); +/* harmony import */ var _baseutil__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/util/baseutil.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "allStrings", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["allStrings"]; }); - Cloudinary.prototype.transformation = function(options) { - return Transformation["new"](this.config()).fromOptions(options).setParent(this); - }; +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "without", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["without"]; }); - return Cloudinary; +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isNumberLike", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["isNumberLike"]; }); - })(); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "smartEscape", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["smartEscape"]; }); - /** - * Cloudinary jQuery plugin - * Depends on 'jquery', 'util', 'transformation', 'cloudinary' - */ - CloudinaryJQuery = (function(superClass) { - extend(CloudinaryJQuery, superClass); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "defaults", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["defaults"]; }); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "objectProto", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["objectProto"]; }); - /** - * Cloudinary class with jQuery support - * @constructor CloudinaryJQuery - * @extends Cloudinary - */ +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "objToString", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["objToString"]; }); - function CloudinaryJQuery(options) { - CloudinaryJQuery.__super__.constructor.call(this, options); - } +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isObject", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["isObject"]; }); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "funcTag", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["funcTag"]; }); - /** - * @override - */ +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isFunction", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["isFunction"]; }); - CloudinaryJQuery.prototype.image = function(publicId, options) { - var client_hints, img, ref, ref1; - if (options == null) { - options = {}; - } - img = this.imageTag(publicId, options); - client_hints = (ref = (ref1 = options.client_hints) != null ? ref1 : this.config('client_hints')) != null ? ref : false; - if (!((options.src != null) || client_hints)) { - img.setAttr("src", ''); - } - img = jQuery(img.toHtml()); - if (!client_hints) { - img.data('src-cache', this.url(publicId, options)).cloudinary_update(options); - } - return img; - }; +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "reWords", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["reWords"]; }); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "camelCase", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["camelCase"]; }); - /** - * @override - */ +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "snakeCase", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["snakeCase"]; }); - CloudinaryJQuery.prototype.responsive = function(options) { - var ref, ref1, ref2, responsiveClass, responsiveConfig, responsiveResizeInitialized, responsive_resize, timeout; - responsiveConfig = jQuery.extend(responsiveConfig || {}, options); - responsiveClass = (ref = this.responsiveConfig['responsive_class']) != null ? ref : this.config('responsive_class'); - jQuery("img." + responsiveClass + ", img.cld-hidpi").cloudinary_update(responsiveConfig); - responsive_resize = (ref1 = (ref2 = responsiveConfig['responsive_resize']) != null ? ref2 : this.config('responsive_resize')) != null ? ref1 : true; - if (responsive_resize && !responsiveResizeInitialized) { - responsiveConfig.resizing = responsiveResizeInitialized = true; - timeout = null; - return jQuery(window).on('resize', (function(_this) { - return function() { - var debounce, ref3, ref4, reset, run, wait; - debounce = (ref3 = (ref4 = responsiveConfig['responsive_debounce']) != null ? ref4 : _this.config('responsive_debounce')) != null ? ref3 : 100; - reset = function() { - if (timeout) { - clearTimeout(timeout); - return timeout = null; - } - }; - run = function() { - return jQuery("img." + responsiveClass).cloudinary_update(responsiveConfig); - }; - wait = function() { - reset(); - return setTimeout((function() { - reset(); - return run(); - }), debounce); - }; - if (debounce) { - return wait(); - } else { - return run(); - } - }; - })(this)); - } - }; +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "convertKeys", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["convertKeys"]; }); - return CloudinaryJQuery; +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "withCamelCaseKeys", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["withCamelCaseKeys"]; }); - })(Cloudinary); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "withSnakeCaseKeys", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["withSnakeCaseKeys"]; }); - /** - * The following methods are provided through the jQuery class - * @class jQuery - */ +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "base64Encode", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["base64Encode"]; }); - /** - * Convert all img tags in the collection to utilize Cloudinary. - * @function jQuery#cloudinary - * @param {Object} [options] - options for the tag and transformations - * @returns {jQuery} - */ - jQuery.fn.cloudinary = function(options) { - this.filter('img').each(function() { - var img_options, public_id, url; - img_options = jQuery.extend({ - width: jQuery(this).attr('width'), - height: jQuery(this).attr('height'), - src: jQuery(this).attr('src') - }, jQuery(this).data(), options); - public_id = img_options.source || img_options.src; - delete img_options.source; - delete img_options.src; - url = jQuery.cloudinary.url(public_id, img_options); - img_options = new Transformation(img_options).toHtmlAttributes(); - return jQuery(this).data('src-cache', url).attr({ - width: img_options.width, - height: img_options.height - }); - }).cloudinary_update(options); - return this; - }; +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "base64EncodeURL", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["base64EncodeURL"]; }); - /** - * Update hidpi (dpr_auto) and responsive (w_auto) fields according to the current container size and the device pixel ratio. - * Only images marked with the cld-responsive class have w_auto updated. - * options: - * - responsive_use_stoppoints: - * - true - always use stoppoints for width - * - "resize" - use exact width on first render and stoppoints on resize (default) - * - false - always use exact width - * - responsive: - * - true - enable responsive on this element. Can be done by adding cld-responsive. - * Note that jQuery.cloudinary.responsive() should be called once on the page. - * - responsive_preserve_height: if set to true, original css height is perserved. Should only be used if the transformation supports different aspect ratios. - */ - jQuery.fn.cloudinary_update = function(options) { - if (options == null) { - options = {}; - } - jQuery.cloudinary.cloudinary_update(this.filter('img').toArray(), options); - return this; - }; - webp = null; +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "extractUrlParams", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["extractUrlParams"]; }); - /** - * @function jQuery#webpify - */ - jQuery.fn.webpify = function(options, webp_options) { - var that, webp_canary; - if (options == null) { - options = {}; - } - that = this; - webp_options = webp_options != null ? webp_options : options; - if (!webp) { - webp = jQuery.Deferred(); - webp_canary = new Image; - webp_canary.onerror = webp.reject; - webp_canary.onload = webp.resolve; - webp_canary.src = 'data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA'; - } - jQuery(function() { - return webp.done(function() { - return jQuery(that).cloudinary(jQuery.extend({}, webp_options, { - format: 'webp' - })); - }).fail(function() { - return jQuery(that).cloudinary(options); - }); - }); - return this; - }; - jQuery.fn.fetchify = function(options) { - return this.cloudinary(jQuery.extend(options, { - 'type': 'fetch' - })); - }; - jQuery.cloudinary = new CloudinaryJQuery(); - jQuery.cloudinary.fromDocument(); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "patchFetchFormat", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["patchFetchFormat"]; }); - /** - * This module extends CloudinaryJquery to support jQuery File Upload - * Depends on 'jquery', 'util', 'cloudinaryjquery', 'jquery.ui.widget', 'jquery.iframe-transport','jquery.fileupload' - */ +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "optionConsume", function() { return _baseutil__WEBPACK_IMPORTED_MODULE_0__["optionConsume"]; }); - /** - * Delete a resource using the upload token - * @function CloudinaryJQuery#delete_by_token - * @param {string} delete_token - the delete token - * @param {Object} [options] - * @param {string} [options.url] - an alternative URL to use for the API - * @param {string} [options.cloud_name] - an alternative cloud_name to use. This parameter is ignored if `options.url` is provided. - */ - CloudinaryJQuery.prototype.delete_by_token = function(delete_token, options) { - var cloud_name, dataType, url; - options = options || {}; - url = options.url; - if (!url) { - cloud_name = options.cloud_name || jQuery.cloudinary.config().cloud_name; - url = 'https://api.cloudinary.com/v1_1/' + cloud_name + '/delete_by_token'; - } - dataType = jQuery.support.xhrFileUpload ? 'json' : 'iframe json'; - return jQuery.ajax({ - url: url, - method: 'POST', - data: { - token: delete_token - }, - headers: { - 'X-Requested-With': 'XMLHttpRequest' - }, - dataType: dataType - }); - }; +/** + * Includes utility methods and lodash / jQuery shims + */ - /** - * Creates an `input` tag and sets it up to upload files to cloudinary - * @function CloudinaryJQuery#unsigned_upload_tag - * @param {string} - */ - CloudinaryJQuery.prototype.unsigned_upload_tag = function(upload_preset, upload_params, options) { - return jQuery('').attr({ - type: 'file', - name: 'file' - }).unsigned_cloudinary_upload(upload_preset, upload_params, options); - }; - /** - * Initialize the jQuery File Upload plugin to upload to Cloudinary - * @function jQuery#cloudinary_fileupload - * @param {Object} options - * @returns {jQuery} - */ - jQuery.fn.cloudinary_fileupload = function(options) { - var cloud_name, initializing, resource_type, type, upload_url; - if (!Util.isFunction(jQuery.fn.fileupload)) { - return this; - } - initializing = !this.data('blueimpFileupload'); - if (initializing) { - options = jQuery.extend({ - maxFileSize: 20000000, - dataType: 'json', - headers: { - 'X-Requested-With': 'XMLHttpRequest' - } - }, options); +/** + * Get data from the DOM element. + * + * This method will use jQuery's `data()` method if it is available, otherwise it will get the `data-` attribute + * @param {Element} element - the element to get the data from + * @param {string} name - the name of the data item + * @returns the value associated with the `name` + * @function Util.getData + */ +var getData = function(element, name) { + return jQuery(element).data(name); +}; + +/** +* Set data in the DOM element. +* +* This method will use jQuery's `data()` method if it is available, otherwise it will set the `data-` attribute +* @function Util.setData +* @param {Element} element - the element to set the data in +* @param {string} name - the name of the data item +* @param {*} value - the value to be set +* + */ +var setData = function(element, name, value) { + return jQuery(element).data(name, value); +}; + +/** +* Get attribute from the DOM element. +* +* This method will use jQuery's `attr()` method if it is available, otherwise it will get the attribute directly +* @function Util.getAttribute +* @param {Element} element - the element to set the attribute for +* @param {string} name - the name of the attribute +* @returns {*} the value of the attribute +* + */ +var getAttribute = function(element, name) { + return jQuery(element).attr(name); +}; + +/** +* Set attribute in the DOM element. +* +* This method will use jQuery's `attr()` method if it is available, otherwise it will set the attribute directly +* @function Util.setAttribute +* @param {Element} element - the element to set the attribute for +* @param {string} name - the name of the attribute +* @param {*} value - the value to be set + */ +var setAttribute = function(element, name, value) { + return jQuery(element).attr(name, value); +}; + +/** + * Remove an attribute in the DOM element. + * + * @function Util.removeAttribute + * @param {Element} element - the element to set the attribute for + * @param {string} name - the name of the attribute + */ +var removeAttribute = function(element, name) { + return jQuery(element).removeAttr(name); +}; + +/** +* Set a group of attributes to the element +* @function Util.setAttributes +* @param {Element} element - the element to set the attributes for +* @param {Object} attributes - a hash of attribute names and values + */ +var setAttributes = function(element, attributes) { + return jQuery(element).attr(attributes); +}; + +/** +* Checks if element has a css class +* @function Util.hasClass +* @param {Element} element - the element to check +* @param {string} name - the class name +@returns {boolean} true if the element has the class + */ +var hasClass = function(element, name) { + return jQuery(element).hasClass(name); +}; + +/** +* Add class to the element +* @function Util.addClass +* @param {Element} element - the element +* @param {string} name - the class name to add + */ +var addClass = function(element, name) { + return jQuery(element).addClass(name); +}; + +var width = function(element) { + return jQuery(element).width(); +}; + +/** + * Returns true if item is empty: + *
    + *
  • item is null or undefined
  • + *
  • item is an array or string of length 0
  • + *
  • item is an object with no keys
  • + *
+ * @function Util.isEmpty + * @param item + * @returns {boolean} true if item is empty + */ +var isEmpty = function(item) { + return (item == null) || (jQuery.isArray(item) || isString(item)) && item.length === 0 || (jQuery.isPlainObject(item) && jQuery.isEmptyObject(item)); +}; + +/** + * Returns true if item is a string + * @param item + * @returns {boolean} true if item is a string + */ +var isString = function(item) { + return typeof item === 'string' || (item != null ? item.toString() : void 0) === '[object String]'; +}; + +/** + * Recursively assign source properties to destination + * @function Util.merge + * @param {Object} destination - the object to assign to + * @param {...Object} [sources] The source objects. + */ +var merge = function() { + var args, i; + args = (function() { + var j, len, results; + results = []; + for (j = 0, len = arguments.length; j < len; j++) { + i = arguments[j]; + results.push(i); } - this.fileupload(options); - if (initializing) { - this.bind('fileuploaddone', function(e, data) { - var add_field, field, multiple, upload_info; - if (data.result.error) { - return; - } - data.result.path = ['v', data.result.version, '/', data.result.public_id, data.result.format ? '.' + data.result.format : ''].join(''); - if (data.cloudinaryField && data.form.length > 0) { - upload_info = [data.result.resource_type, data.result.type, data.result.path].join('/') + '#' + data.result.signature; - multiple = jQuery(e.target).prop('multiple'); - add_field = function() { - return jQuery('').attr({ - type: 'hidden', - name: data.cloudinaryField - }).val(upload_info).appendTo(data.form); - }; - if (multiple) { - add_field(); - } else { - field = jQuery(data.form).find('input[name="' + data.cloudinaryField + '"]'); - if (field.length > 0) { - field.val(upload_info); - } else { - add_field(); - } - } - } - return jQuery(e.target).trigger('cloudinarydone', data); - }); - this.bind('fileuploadsend', function(e, data) { - data.headers = jQuery.extend({}, data.headers, { - 'X-Unique-Upload-Id': (Math.random() * 10000000000).toString(16) - }); - return true; - }); - this.bind('fileuploadstart', function(e) { - return jQuery(e.target).trigger('cloudinarystart'); - }); - this.bind('fileuploadstop', function(e) { - return jQuery(e.target).trigger('cloudinarystop'); - }); - this.bind('fileuploadprogress', function(e, data) { - return jQuery(e.target).trigger('cloudinaryprogress', data); - }); - this.bind('fileuploadprogressall', function(e, data) { - return jQuery(e.target).trigger('cloudinaryprogressall', data); - }); - this.bind('fileuploadfail', function(e, data) { - return jQuery(e.target).trigger('cloudinaryfail', data); - }); - this.bind('fileuploadalways', function(e, data) { - return jQuery(e.target).trigger('cloudinaryalways', data); - }); - if (!this.fileupload('option').url) { - cloud_name = options.cloud_name || jQuery.cloudinary.config().cloud_name; - resource_type = options.resource_type || 'auto'; - type = options.type || 'upload'; - upload_url = 'https://api.cloudinary.com/v1_1/' + cloud_name + '/' + resource_type + '/' + type; - this.fileupload('option', 'url', upload_url); - } + return results; + }).apply(this, arguments); + args.unshift(true); // deep extend + return jQuery.extend.apply(this, args); +}; + +/** + * Creates a new array from the parameter with "falsey" values removed + * @function Util.compact + * @param {Array} array - the array to remove values from + * @return {Array} a new array without falsey values + */ +var compact = function(arr) { + var item, j, len, results; + results = []; + for (j = 0, len = arr.length; j < len; j++) { + item = arr[j]; + if (item) { + results.push(item); } - return this; - }; + } + return results; +}; - /** - * Add a file to upload - * @function jQuery#cloudinary_upload_url - * @param {string} remote_url - the url to add - * @returns {jQuery} - */ - jQuery.fn.cloudinary_upload_url = function(remote_url) { - if (!Util.isFunction(jQuery.fn.fileupload)) { - return this; +/** + * Create a new copy of the given object, including all internal objects. + * @function Util.cloneDeep + * @param {Object} value - the object to clone + * @return {Object} a new deep copy of the object + */ +var cloneDeep = function() { + var args; + args = jQuery.makeArray(arguments); + args.unshift({}); // add "fresh" destination + args.unshift(true); // deep + return jQuery.extend.apply(this, args); +}; + +/** + * Check if a given item is included in the given array + * @function Util.contains + * @param {Array} array - the array to search in + * @param {*} item - the item to search for + * @return {boolean} true if the item is included in the array + */ +var contains = function(arr, item) { + var i, j, len; + for (j = 0, len = arr.length; j < len; j++) { + i = arr[j]; + if (i === item) { + return true; } - this.fileupload('option', 'formData').file = remote_url; - this.fileupload('add', { - files: [remote_url] - }); - delete this.fileupload('option', 'formData').file; - return this; - }; + } + return false; +}; - /** - * Initialize the jQuery File Upload plugin to upload to Cloudinary using unsigned upload - * @function jQuery#unsigned_cloudinary_upload - * @param {string} upload_preset - the upload preset to use - * @param {Object} [upload_params] - parameters that should be past to the server - * @param {Object} [options] - * @returns {jQuery} - */ - jQuery.fn.unsigned_cloudinary_upload = function(upload_preset, upload_params, options) { - var attr, attrs_to_move, html_options, i, key, value; - if (upload_params == null) { - upload_params = {}; +/** + * Returns values in the given array that are not included in the other array + * @function Util.difference + * @param {Array} arr - the array to select from + * @param {Array} values - values to filter from arr + * @return {Array} the filtered values + */ +var difference = function(arr, values) { + var item, j, len, results; + results = []; + for (j = 0, len = arr.length; j < len; j++) { + item = arr[j]; + if (!contains(values, item)) { + results.push(item); } - if (options == null) { - options = {}; + } + return results; +}; + +/** + * Returns a list of all the function names in obj + * @function Util.functions + * @param {Object} object - the object to inspect + * @return {Array} a list of functions of object + */ +var functions = function(object) { + var i, results; + results = []; + for (i in object) { + if (jQuery.isFunction(object[i])) { + results.push(i); } - upload_params = Util.cloneDeep(upload_params); - options = Util.cloneDeep(options); - attrs_to_move = ['cloud_name', 'resource_type', 'type']; - i = 0; - while (i < attrs_to_move.length) { - attr = attrs_to_move[i]; - if (upload_params[attr]) { - options[attr] = upload_params[attr]; - delete upload_params[attr]; + } + return results; +}; + +/** + * Returns the provided value. This functions is used as a default predicate function. + * @function Util.identity + * @param {*} value + * @return {*} the provided value + */ +var identity = function(value) { + return value; +}; + +/** + * @class Util + */ +var isArray = jQuery.isArray; + +var assign = jQuery.extend; + +var isPlainObject = jQuery.isPlainObject; + +/** + * Remove leading or trailing spaces from text + * @function Util.trim + * @param {string} text + * @return {string} the `text` without leading or trailing spaces + */ +var trim = jQuery.trim; + + +/***/ }), + +/***/ "./src/util/srcsetUtils.js": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scaledUrl", function() { return scaledUrl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getOrGenerateBreakpoints", function() { return getOrGenerateBreakpoints; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateSrcsetAttribute", function() { return generateSrcsetAttribute; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateSizesAttribute", function() { return generateSizesAttribute; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateImageResponsiveAttributes", function() { return generateImageResponsiveAttributes; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateMediaAttr", function() { return generateMediaAttr; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "srcsetUrl", function() { return srcsetUrl; }); +/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/util/jquery.js"); +/* harmony import */ var _generateBreakpoints__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/util/generateBreakpoints.js"); +/* harmony import */ var _transformation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/transformation.js"); +/* harmony import */ var _url__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/url.js"); + +const isEmpty = _util__WEBPACK_IMPORTED_MODULE_0__["isEmpty"]; + + + + +/** + * Options used to generate the srcset attribute. + * @typedef {object} srcset + * @property {(number[]|string[])} [breakpoints] An array of breakpoints. + * @property {number} [min_width] Minimal width of the srcset images. + * @property {number} [max_width] Maximal width of the srcset images. + * @property {number} [max_images] Number of srcset images to generate. + * @property {object|string} [transformation] The transformation to use in the srcset urls. + * @property {boolean} [sizes] Whether to calculate and add the sizes attribute. + */ + +/** + * Options used to generate the srcset attribute. + * @typedef {object} srcset + * @property {(number[]|string[])} [breakpoints] An array of breakpoints. + * @property {number} [min_width] Minimal width of the srcset images. + * @property {number} [max_width] Maximal width of the srcset images. + * @property {number} [max_images] Number of srcset images to generate. + * @property {object|string} [transformation] The transformation to use in the srcset urls. + * @property {boolean} [sizes] Whether to calculate and add the sizes attribute. + */ + +/** + * Helper function. Generates a single srcset item url + * + * @private + * @param {string} public_id Public ID of the resource. + * @param {number} width Width in pixels of the srcset item. + * @param {object|string} transformation + * @param {object} options Additional options. + * + * @return {string} Resulting URL of the item + */ +function scaledUrl(public_id, width, transformation, options = {}) { + let configParams = _util__WEBPACK_IMPORTED_MODULE_0__["extractUrlParams"](options); + transformation = transformation || options; + configParams.raw_transformation = new _transformation__WEBPACK_IMPORTED_MODULE_2__["default"]([_util__WEBPACK_IMPORTED_MODULE_0__["merge"]({}, transformation), {crop: 'scale', width: width}]).toString(); + + return Object(_url__WEBPACK_IMPORTED_MODULE_3__["default"])(public_id, configParams); +} + +/** + * If cache is enabled, get the breakpoints from the cache. If the values were not found in the cache, + * or cache is not enabled, generate the values. + * @param {srcset} srcset The srcset configuration parameters + * @param {string} public_id + * @param {object} options + * @return {*|Array} + */ +function getOrGenerateBreakpoints(public_id, srcset={}, options={}) { + return Object(_generateBreakpoints__WEBPACK_IMPORTED_MODULE_1__["default"])(srcset); +} + +/** + * Helper function. Generates srcset attribute value of the HTML img tag + * @private + * + * @param {string} public_id Public ID of the resource + * @param {number[]} breakpoints An array of breakpoints (in pixels) + * @param {object} transformation The transformation + * @param {object} options Includes html tag options, transformation options + * @return {string} Resulting srcset attribute value + */ +function generateSrcsetAttribute(public_id, breakpoints, transformation, options) { + options = _util__WEBPACK_IMPORTED_MODULE_0__["cloneDeep"](options); + _util__WEBPACK_IMPORTED_MODULE_0__["patchFetchFormat"](options); + return breakpoints.map(width=>`${scaledUrl(public_id, width, transformation, options)} ${width}w`).join(', '); +} + +/** + * Helper function. Generates sizes attribute value of the HTML img tag + * @private + * @param {number[]} breakpoints An array of breakpoints. + * @return {string} Resulting sizes attribute value + */ +function generateSizesAttribute(breakpoints=[]){ + return breakpoints.map(width=>`(max-width: ${width}px) ${width}px`).join(', '); +} + +/** + * Helper function. Generates srcset and sizes attributes of the image tag + * + * Generated attributes are added to attributes argument + * + * @private + * @param {string} publicId The public ID of the resource + * @param {object} attributes Existing HTML attributes. + * @param {srcset} srcsetData + * @param {object} options Additional options. + * + * @return array The responsive attributes + */ +function generateImageResponsiveAttributes(publicId, attributes={}, srcsetData={}, options={}){ + // Create both srcset and sizes here to avoid fetching breakpoints twice + + let responsiveAttributes = {}; + if (isEmpty(srcsetData)) { + return responsiveAttributes; + } + + const generateSizes = (!attributes.sizes && srcsetData.sizes === true); + + const generateSrcset = !attributes.srcset; + if (generateSrcset || generateSizes) { + let breakpoints = getOrGenerateBreakpoints(publicId, srcsetData, options); + + if (generateSrcset) { + let transformation = srcsetData.transformation; + let srcsetAttr = generateSrcsetAttribute(publicId, breakpoints, transformation, options); + if (!isEmpty(srcsetAttr)) { + responsiveAttributes.srcset = srcsetAttr; } - i++; } - for (key in upload_params) { - value = upload_params[key]; - if (Util.isPlainObject(value)) { - upload_params[key] = jQuery.map(value, function(v, k) { - if (Util.isString(v)) { - v = v.replace(/[\|=]/g, "\\$&"); - } - return k + '=' + v; - }).join('|'); - } else if (Util.isArray(value)) { - if (value.length > 0 && jQuery.isArray(value[0])) { - upload_params[key] = jQuery.map(value, function(array_value) { - return array_value.join(','); - }).join('|'); - } else { - upload_params[key] = value.join(','); - } + + if (generateSizes) { + let sizesAttr = generateSizesAttribute(breakpoints); + if (!isEmpty(sizesAttr)) { + responsiveAttributes.sizes = sizesAttr; } } - if (!upload_params.callback) { - upload_params.callback = '/cloudinary_cors.html'; - } - upload_params.upload_preset = upload_preset; - options.formData = upload_params; - if (options.cloudinary_field) { - options.cloudinaryField = options.cloudinary_field; - delete options.cloudinary_field; - } - html_options = options.html || {}; - html_options["class"] = Util.trim("cloudinary_fileupload " + (html_options["class"] || '')); - if (options.multiple) { - html_options.multiple = true; - } - this.attr(html_options).cloudinary_fileupload(options); - return this; - }; - jQuery.cloudinary = new CloudinaryJQuery(); - cloudinary = { - utf8_encode: utf8_encode, - crc32: crc32, - Util: Util, - Condition: Condition, - Transformation: Transformation, - Configuration: Configuration, - HtmlTag: HtmlTag, - ImageTag: ImageTag, - VideoTag: VideoTag, - ClientHintsMetaTag: ClientHintsMetaTag, - Layer: Layer, - FetchLayer: FetchLayer, - TextLayer: TextLayer, - SubtitlesLayer: SubtitlesLayer, - Cloudinary: Cloudinary, - VERSION: "2.5.0", - CloudinaryJQuery: CloudinaryJQuery - }; - return cloudinary; -}); + } + return responsiveAttributes; +} +/** + * Generate a media query + * + * @private + * @param {object} options configuration options + * @param {number|string} options.min_width + * @param {number|string} options.max_width + * @return {string} a media query string + */ +function generateMediaAttr(options={}){ + let mediaQuery = []; + if(options.min_width != null){ + mediaQuery.push(`(min-width: ${options.min_width}px)`); + } + if(options.max_width != null){ + mediaQuery.push(`(max-width: ${options.max_width}px)`); + } + return mediaQuery.join(' and '); +} +const srcsetUrl = scaledUrl; + + +/***/ }) + +/******/ }); +}); +//# sourceMappingURL=cloudinary-jquery-file-upload.js.map \ No newline at end of file diff --git a/cloudinary-jquery-file-upload.min.js b/cloudinary-jquery-file-upload.min.js index 2930a2f..5248bf8 100644 --- a/cloudinary-jquery-file-upload.min.js +++ b/cloudinary-jquery-file-upload.min.js @@ -1,4 +1 @@ -var slice=[].slice,extend=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child},hasProp={}.hasOwnProperty;!function(root,factory){var name,ref,results,value;if("function"==typeof define&&define.amd)return define(["jquery"],factory);if("object"==typeof exports)return module.exports=factory(require("jquery"));root.cloudinary||(root.cloudinary={}),ref=factory(jQuery),results=[];for(name in ref)value=ref[name],results.push(root.cloudinary[name]=value)}(this,function(jQuery){var ArrayParam,BaseUtil,ClientHintsMetaTag,Cloudinary,CloudinaryJQuery,Condition,Configuration,Expression,ExpressionParam,FetchLayer,HtmlTag,ImageTag,Layer,LayerParam,Param,RangeParam,RawParam,SubtitlesLayer,TextLayer,Transformation,TransformationBase,TransformationParam,Util,VideoTag,addClass,allStrings,base64Encode,base64EncodeURL,camelCase,cloneDeep,cloudinary,compact,contains,convertKeys,crc32,defaults,difference,funcTag,functions,getAttribute,getData,hasClass,identity,isEmpty,isFunction,isNumberLike,isObject,isString,m,merge,objToString,objectProto,parameters,reWords,removeAttribute,setAttribute,setAttributes,setData,smartEscape,snakeCase,utf8_encode,webp,width,withCamelCaseKeys,withSnakeCaseKeys,without;return allStrings=function(list){var item,j,len;for(j=0,len=list.length;j127&&c1<2048?String.fromCharCode(c1>>6|192,63&c1|128):String.fromCharCode(c1>>12|224,c1>>6&63|128,63&c1|128),null!==enc&&(end>start&&(utftext+=string.slice(start,end)),utftext+=enc,start=end=n+1),n++;return end>start&&(utftext+=string.slice(start,stringl)),utftext},crc32=function(str){var crc,i,iTop,table,x,y;for(str=utf8_encode(str),table="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D",crc=0,x=0,y=0,crc^=-1,i=0,iTop=str.length;i>>8^x,i++;return crc^=-1,crc<0&&(crc+=4294967296),crc},Layer=function(){function Layer(options){this.options={},null!=options&&["resourceType","type","publicId","format"].forEach(function(_this){return function(key){var ref;return _this.options[key]=null!=(ref=options[key])?ref:options[Util.snakeCase(key)]}}(this))}return Layer.prototype.resourceType=function(value){return this.options.resourceType=value,this},Layer.prototype.type=function(value){return this.options.type=value,this},Layer.prototype.publicId=function(value){return this.options.publicId=value,this},Layer.prototype.getPublicId=function(){var ref;return null!=(ref=this.options.publicId)?ref.replace(/\//g,":"):void 0},Layer.prototype.getFullPublicId=function(){return null!=this.options.format?this.getPublicId()+"."+this.options.format:this.getPublicId()},Layer.prototype.format=function(value){return this.options.format=value,this},Layer.prototype.toString=function(){var components;if(components=[],null==this.options.publicId)throw"Must supply publicId";return"image"!==this.options.resourceType&&components.push(this.options.resourceType),"upload"!==this.options.type&&components.push(this.options.type),components.push(this.getFullPublicId()),Util.compact(components).join(":")},Layer}(),FetchLayer=function(superClass){function FetchLayer(options){FetchLayer.__super__.constructor.call(this,options),Util.isString(options)?this.options.url=options:(null!=options?options.url:void 0)&&(this.options.url=options.url)}return extend(FetchLayer,superClass),FetchLayer.prototype.url=function(url){return this.options.url=url,this},FetchLayer.prototype.toString=function(){return"fetch:"+cloudinary.Util.base64EncodeURL(this.options.url)},FetchLayer}(Layer),TextLayer=function(superClass){function TextLayer(options){var keys;TextLayer.__super__.constructor.call(this,options),keys=["resourceType","resourceType","fontFamily","fontSize","fontWeight","fontStyle","textDecoration","textAlign","stroke","letterSpacing","lineSpacing","text"],null!=options&&keys.forEach(function(_this){return function(key){var ref;return _this.options[key]=null!=(ref=options[key])?ref:options[Util.snakeCase(key)]}}(this)),this.options.resourceType="text"}return extend(TextLayer,superClass),TextLayer.prototype.resourceType=function(resourceType){throw"Cannot modify resourceType for text layers"},TextLayer.prototype.type=function(type){throw"Cannot modify type for text layers"},TextLayer.prototype.format=function(format){throw"Cannot modify format for text layers"},TextLayer.prototype.fontFamily=function(fontFamily){return this.options.fontFamily=fontFamily,this},TextLayer.prototype.fontSize=function(fontSize){return this.options.fontSize=fontSize,this},TextLayer.prototype.fontWeight=function(fontWeight){return this.options.fontWeight=fontWeight,this},TextLayer.prototype.fontStyle=function(fontStyle){return this.options.fontStyle=fontStyle,this},TextLayer.prototype.textDecoration=function(textDecoration){return this.options.textDecoration=textDecoration,this},TextLayer.prototype.textAlign=function(textAlign){return this.options.textAlign=textAlign,this},TextLayer.prototype.stroke=function(stroke){return this.options.stroke=stroke,this},TextLayer.prototype.letterSpacing=function(letterSpacing){return this.options.letterSpacing=letterSpacing,this},TextLayer.prototype.lineSpacing=function(lineSpacing){return this.options.lineSpacing=lineSpacing,this},TextLayer.prototype.text=function(text){return this.options.text=text,this},TextLayer.prototype.toString=function(){var components,hasPublicId,hasStyle,publicId,re,res,start,style,text,textSource;if(style=this.textStyleIdentifier(),null!=this.options.publicId&&(publicId=this.getFullPublicId()),null!=this.options.text){if(hasPublicId=!Util.isEmpty(publicId),hasStyle=!Util.isEmpty(style),hasPublicId&&hasStyle||!hasPublicId&&!hasStyle)throw"Must supply either style parameters or a public_id when providing text parameter in a text overlay/underlay, but not both!";for(re=/\$\([a-zA-Z]\w*\)/g,start=0,textSource=Util.smartEscape(this.options.text,/[,\/]/g),text="";res=re.exec(textSource);)text+=Util.smartEscape(textSource.slice(start,res.index)),text+=res[0],start=res.index+res[0].length;text+=Util.smartEscape(textSource.slice(start))}return components=[this.options.resourceType,style,publicId,text],Util.compact(components).join(":")},TextLayer.prototype.textStyleIdentifier=function(){var components;if(components=[],"normal"!==this.options.fontWeight&&components.push(this.options.fontWeight),"normal"!==this.options.fontStyle&&components.push(this.options.fontStyle),"none"!==this.options.textDecoration&&components.push(this.options.textDecoration),components.push(this.options.textAlign),"none"!==this.options.stroke&&components.push(this.options.stroke),Util.isEmpty(this.options.letterSpacing)&&!Util.isNumberLike(this.options.letterSpacing)||components.push("letter_spacing_"+this.options.letterSpacing),Util.isEmpty(this.options.lineSpacing)&&!Util.isNumberLike(this.options.lineSpacing)||components.push("line_spacing_"+this.options.lineSpacing),!Util.isEmpty(Util.compact(components))){if(Util.isEmpty(this.options.fontFamily))throw"Must supply fontFamily. "+components;if(Util.isEmpty(this.options.fontSize)&&!Util.isNumberLike(this.options.fontSize))throw"Must supply fontSize."}return components.unshift(this.options.fontFamily,this.options.fontSize),components=Util.compact(components).join("_")},TextLayer}(Layer),SubtitlesLayer=function(superClass){function SubtitlesLayer(options){SubtitlesLayer.__super__.constructor.call(this,options),this.options.resourceType="subtitles"}return extend(SubtitlesLayer,superClass),SubtitlesLayer}(TextLayer),Param=function(){function Param(name,shortName,process){null==process&&(process=cloudinary.Util.identity),this.name=name,this.shortName=shortName,this.process=process}return Param.prototype.set=function(origValue){return this.origValue=origValue,this},Param.prototype.serialize=function(){var val,valid;return val=this.value(),valid=cloudinary.Util.isArray(val)||cloudinary.Util.isPlainObject(val)||cloudinary.Util.isString(val)?!cloudinary.Util.isEmpty(val):null!=val,null!=this.shortName&&valid?this.shortName+"_"+val:""},Param.prototype.value=function(){return this.process(this.origValue)},Param.norm_color=function(value){return null!=value?value.replace(/^#/,"rgb:"):void 0},Param.prototype.build_array=function(arg){return null==arg&&(arg=[]),cloudinary.Util.isArray(arg)?arg:[arg]},Param.process_video_params=function(param){var video;switch(param.constructor){case Object:return video="","codec"in param&&(video=param.codec,"profile"in param&&(video+=":"+param.profile,"level"in param&&(video+=":"+param.level))),video;case String:return param;default:return null}},Param}(),ArrayParam=function(superClass){function ArrayParam(name,shortName,sep,process){null==sep&&(sep="."),this.sep=sep,ArrayParam.__super__.constructor.call(this,name,shortName,process)}return extend(ArrayParam,superClass),ArrayParam.prototype.serialize=function(){var arrayValue,flat,t;return null!=this.shortName?(arrayValue=this.value(),cloudinary.Util.isEmpty(arrayValue)?"":cloudinary.Util.isString(arrayValue)?this.shortName+"_"+arrayValue:(flat=function(){var j,len,results;for(results=[],j=0,len=arrayValue.length;j":"gt","<=":"lte",">=":"gte","&&":"and","||":"or","*":"mul","/":"div","+":"add","-":"sub"},Expression.PREDEFINED_VARS={aspect_ratio:"ar",aspectRatio:"ar",current_page:"cp",currentPage:"cp",face_count:"fc",faceCount:"fc",height:"h",initial_aspect_ratio:"iar",initial_height:"ih",initial_width:"iw",initialAspectRatio:"iar",initialHeight:"ih",initialWidth:"iw",page_count:"pc",page_x:"px",page_y:"py",pageCount:"pc",pageX:"px",pageY:"py",tags:"tags",width:"w"},Expression.BOUNDRY="[ _]+",Expression.new=function(expressionStr){return new this(expressionStr)},Expression.normalize=function(expression){var operators,pattern,replaceRE;return null==expression?expression:(expression=String(expression),operators="\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*",pattern="(("+operators+")(?=[ _])|"+Object.keys(Expression.PREDEFINED_VARS).join("|")+")",replaceRE=new RegExp(pattern,"g"),expression=expression.replace(replaceRE,function(match){return Expression.OPERATORS[match]||Expression.PREDEFINED_VARS[match]}),expression.replace(/[ _]+/g,"_"))},Expression.prototype.serialize=function(){return Expression.normalize(this.expressions.join("_"))},Expression.prototype.toString=function(){return this.serialize()},Expression.prototype.getParent=function(){return this.parent},Expression.prototype.setParent=function(parent){return this.parent=parent,this},Expression.prototype.predicate=function(name,operator,value){return null!=Expression.OPERATORS[operator]&&(operator=Expression.OPERATORS[operator]),this.expressions.push(name+"_"+operator+"_"+value),this},Expression.prototype.and=function(){return this.expressions.push("and"),this},Expression.prototype.or=function(){return this.expressions.push("or"),this},Expression.prototype.then=function(){return this.getParent().if(this.toString())},Expression.prototype.height=function(operator,value){return this.predicate("h",operator,value)},Expression.prototype.width=function(operator,value){return this.predicate("w",operator,value)},Expression.prototype.aspectRatio=function(operator,value){return this.predicate("ar",operator,value)},Expression.prototype.pageCount=function(operator,value){return this.predicate("pc",operator,value)},Expression.prototype.faceCount=function(operator,value){return this.predicate("fc",operator,value)},Expression.prototype.value=function(value){return this.expressions.push(value),this},Expression.variable=function(name,value){return new this(name).value(value)},Expression.width=function(){return new this("width")},Expression.height=function(){return new this("height")},Expression.initialWidth=function(){return new this("initialWidth")},Expression.initialHeight=function(){return new this("initialHeight")},Expression.aspectRatio=function(){return new this("aspectRatio")},Expression.initialAspectRatio=function(){return new this("initialAspectRatio")},Expression.pageCount=function(){return new this("pageCount")},function(){return new this("faceCount")},Expression.currentPage=function(){return new this("currentPage")},Expression.tags=function(){return new this("tags")},Expression.pageX=function(){return new this("pageX")},Expression.pageY=function(){return new this("pageY")},Expression}(),Condition=function(superClass){function Condition(conditionStr){Condition.__super__.constructor.call(this,conditionStr)}return extend(Condition,superClass),Condition.prototype.height=function(operator,value){return this.predicate("h",operator,value)},Condition.prototype.width=function(operator,value){return this.predicate("w",operator,value)},Condition.prototype.aspectRatio=function(operator,value){return this.predicate("ar",operator,value)},Condition.prototype.pageCount=function(operator,value){return this.predicate("pc",operator,value)},Condition.prototype.faceCount=function(operator,value){return this.predicate("fc",operator,value)},Condition}(Expression),Configuration=function(){function Configuration(options){null==options&&(options={}),this.configuration=Util.cloneDeep(options),Util.defaults(this.configuration,DEFAULT_CONFIGURATION_PARAMS)}var DEFAULT_CONFIGURATION_PARAMS,ref;return DEFAULT_CONFIGURATION_PARAMS={responsive_class:"cld-responsive",responsive_use_breakpoints:!0,round_dpr:!0,secure:"https:"===("undefined"!=typeof window&&null!==window&&null!=(ref=window.location)?ref.protocol:void 0)},Configuration.CONFIG_PARAMS=["api_key","api_secret","callback","cdn_subdomain","cloud_name","cname","private_cdn","protocol","resource_type","responsive","responsive_class","responsive_use_breakpoints","responsive_width","round_dpr","secure","secure_cdn_subdomain","secure_distribution","shorten","type","upload_preset","url_suffix","use_root_path","version"],Configuration.prototype.init=function(){return this.fromEnvironment(),this.fromDocument(),this},Configuration.prototype.set=function(name,value){return this.configuration[name]=value,this},Configuration.prototype.get=function(name){return this.configuration[name]},Configuration.prototype.merge=function(config){return null==config&&(config={}),Util.assign(this.configuration,Util.cloneDeep(config)),this},Configuration.prototype.fromDocument=function(){var el,j,len,meta_elements;if(meta_elements="undefined"!=typeof document&&null!==document?document.querySelectorAll('meta[name^="cloudinary_"]'):void 0)for(j=0,len=meta_elements.length;j=1&&null==options.width&&(options.width=width),parseFloat(height)>=1&&null==options.height&&(options.height=height)),options},TransformationBase.prototype.isValidParamName=function(name){return Transformation.methods.indexOf(Util.camelCase(name))>=0},TransformationBase.prototype.toHtml=function(){var ref;return null!=(ref=this.getParent())&&"function"==typeof ref.toHtml?ref.toHtml():void 0},TransformationBase.prototype.toString=function(){return this.serialize()},processVar=function(varArray){var j,len,name,ref,results,v;if(Util.isArray(varArray)){for(results=[],j=0,len=varArray.length;j=0&&"end"!==(ifVal=this.chained[i].getValue("if"))&&(null==ifVal||(trIf=Transformation.new().if(ifVal),this.chained[i].remove("if"),trRest=this.chained[i],this.chained[i]=Transformation.new().transformation([trIf,trRest]),"else"===ifVal));i=j+=-1);return this.param(value,"if","if");case"":return Condition.new().setParent(this);default:return this.param(value,"if","if",function(value){return Condition.new(value).toString()})}},Transformation.prototype.keyframeInterval=function(value){return this.param(value,"keyframe_interval","ki")},Transformation.prototype.offset=function(value){var end_o,ref,start_o;if(ref=Util.isFunction(null!=value?value.split:void 0)?value.split(".."):Util.isArray(value)?value:[null,null],start_o=ref[0],end_o=ref[1],null!=start_o&&this.startOffset(start_o),null!=end_o)return this.endOffset(end_o)},Transformation.prototype.opacity=function(value){return this.param(value,"opacity","o",Expression.normalize)},Transformation.prototype.overlay=function(value){return this.layerParam(value,"overlay","l")},Transformation.prototype.page=function(value){return this.param(value,"page","pg")},Transformation.prototype.poster=function(value){return this.param(value,"poster")},Transformation.prototype.prefix=function(value){return this.param(value,"prefix","p")},Transformation.prototype.quality=function(value){return this.param(value,"quality","q",Expression.normalize)},Transformation.prototype.radius=function(value){return this.param(value,"radius","r",Expression.normalize)},Transformation.prototype.rawTransformation=function(value){return this.rawParam(value,"raw_transformation")},Transformation.prototype.size=function(value){var height,ref;if(Util.isFunction(null!=value?value.split:void 0))return ref=value.split("x"),width=ref[0],height=ref[1],this.width(width),this.height(height)},Transformation.prototype.sourceTypes=function(value){return this.param(value,"source_types")},Transformation.prototype.sourceTransformation=function(value){return this.param(value,"source_transformation")},Transformation.prototype.startOffset=function(value){return this.rangeParam(value,"start_offset","so")},Transformation.prototype.streamingProfile=function(value){return this.param(value,"streaming_profile","sp")},Transformation.prototype.transformation=function(value){return this.transformationParam(value,"transformation","t")},Transformation.prototype.underlay=function(value){return this.layerParam(value,"underlay","u")},Transformation.prototype.variable=function(name,value){return this.param(value,name,name)},Transformation.prototype.variables=function(values){return this.arrayParam(values,"variables")},Transformation.prototype.videoCodec=function(value){return this.param(value,"video_codec","vc",Param.process_video_params)},Transformation.prototype.videoSampling=function(value){return this.param(value,"video_sampling","vs")},Transformation.prototype.width=function(value){return this.param(value,"width","w",function(_this){return function(){return _this.getValue("crop")||_this.getValue("overlay")||_this.getValue("underlay")?Expression.normalize(value):null}}(this))},Transformation.prototype.x=function(value){return this.param(value,"x","x",Expression.normalize)},Transformation.prototype.y=function(value){return this.param(value,"y","y",Expression.normalize)},Transformation.prototype.zoom=function(value){return this.param(value,"zoom","z",Expression.normalize)},Transformation}(TransformationBase),Transformation.methods||(Transformation.methods=Util.difference(Util.functions(Transformation.prototype),Util.functions(TransformationBase.prototype))),Transformation.PARAM_NAMES||(Transformation.PARAM_NAMES=function(){var j,len,ref,results;for(ref=Transformation.methods,results=[],j=0,len=ref.length;j"},HtmlTag.prototype.closeTag=function(){return""},HtmlTag.prototype.toHtml=function(){return this.openTag()+this.content()+this.closeTag()},HtmlTag.prototype.toDOM=function(){var element,name,ref,value;if(!Util.isFunction("undefined"!=typeof document&&null!==document?document.createElement:void 0))throw"Can't create DOM if document is not present!";element=document.createElement(this.name),ref=this.attributes();for(name in ref)value=ref[name],element[name]=value;return element},HtmlTag.isResponsive=function(tag,responsiveClass){var dataSrc;return dataSrc=Util.getData(tag,"src-cache")||Util.getData(tag,"src"),Util.hasClass(tag,responsiveClass)&&/\bw_auto\b/.exec(dataSrc)},HtmlTag}(),ImageTag=function(superClass){function ImageTag(publicId,options){null==options&&(options={}),ImageTag.__super__.constructor.call(this,"img",publicId,options)}return extend(ImageTag,superClass),ImageTag.prototype.closeTag=function(){return""},ImageTag.prototype.attributes=function(){var attr,options,srcAttribute;return attr=ImageTag.__super__.attributes.call(this)||[],options=this.getOptions(),srcAttribute=options.responsive&&!options.client_hints?"data-src":"src",null==attr[srcAttribute]&&(attr[srcAttribute]=new Cloudinary(this.getOptions()).url(this.publicId)),attr},ImageTag}(HtmlTag),VideoTag=function(superClass){function VideoTag(publicId,options){null==options&&(options={}),options=Util.defaults({},options,Cloudinary.DEFAULT_VIDEO_PARAMS),VideoTag.__super__.constructor.call(this,"video",publicId.replace(/\.(mp4|ogv|webm)$/,""),options)}var DEFAULT_POSTER_OPTIONS,VIDEO_TAG_PARAMS;return extend(VideoTag,superClass),VIDEO_TAG_PARAMS=["source_types","source_transformation","fallback_content","poster"],["webm","mp4","ogv"],DEFAULT_POSTER_OPTIONS={format:"jpg",resource_type:"video"},VideoTag.prototype.setSourceTransformation=function(value){return this.transformation().sourceTransformation(value),this},VideoTag.prototype.setSourceTypes=function(value){return this.transformation().sourceTypes(value),this},VideoTag.prototype.setPoster=function(value){return this.transformation().poster(value),this},VideoTag.prototype.setFallbackContent=function(value){return this.transformation().fallbackContent(value),this},VideoTag.prototype.content=function(){var cld,fallback,innerTags,mimeType,sourceTransformation,sourceTypes,src,srcType,transformation,videoType;return sourceTypes=this.transformation().getValue("source_types"),sourceTransformation=this.transformation().getValue("source_transformation"),fallback=this.transformation().getValue("fallback_content"),Util.isArray(sourceTypes)?(cld=new Cloudinary(this.getOptions()),innerTags=function(){var j,len,results;for(results=[],j=0,len=sourceTypes.length;j");return results}.call(this)):innerTags=[],innerTags.join("")+fallback},VideoTag.prototype.attributes=function(){var a,attr,j,len,poster,ref,ref1,sourceTypes;for(sourceTypes=this.getOption("source_types"),poster=null!=(ref=this.getOption("poster"))?ref:{},Util.isPlainObject(poster)&&(defaults=null!=poster.public_id?Cloudinary.DEFAULT_IMAGE_PARAMS:DEFAULT_POSTER_OPTIONS,poster=new Cloudinary(this.getOptions()).url(null!=(ref1=poster.public_id)?ref1:this.publicId,Util.defaults({},poster,defaults))),attr=VideoTag.__super__.attributes.call(this)||[],j=0,len=attr.length;j=0&&!publicId.match(/^v[0-9]+/)&&!publicId.match(/^https?:\//)&&!(null!=(ref=options.version)?ref.toString():void 0)&&(options.version=1),publicId.match(/^https?:/))"upload"===options.type||"asset"===options.type?url=publicId:publicId=encodeURIComponent(publicId).replace(/%3A/g,":").replace(/%2F/g,"/");else{try{publicId=decodeURIComponent(publicId)}catch(error1){error1}if(publicId=encodeURIComponent(publicId).replace(/%3A/g,":").replace(/%2F/g,"/"),options.url_suffix){if(options.url_suffix.match(/[\.\/]/))throw"url_suffix should not include . or /";publicId=publicId+"/"+options.url_suffix}options.format&&(options.trust_public_id||(publicId=publicId.replace(/\.(jpg|png|gif|webp)$/,"")),publicId=publicId+"."+options.format)}return prefix=cloudinaryUrlPrefix(publicId,options),resourceTypeAndType=finalizeResourceType(options.resource_type,options.type,options.url_suffix,options.use_root_path,options.shorten),version=options.version?"v"+options.version:"",url||Util.compact([prefix,resourceTypeAndType,transformationString,version,publicId]).join("/").replace(/([^:])\/+/g,"$1/")},Cloudinary.prototype.video_url=function(publicId,options){return options=Util.assign({resource_type:"video"},options),this.url(publicId,options)},Cloudinary.prototype.video_thumbnail_url=function(publicId,options){return options=Util.assign({},DEFAULT_POSTER_OPTIONS,options),this.url(publicId,options)},Cloudinary.prototype.transformation_string=function(options){return new Transformation(options).serialize()},Cloudinary.prototype.image=function(publicId,options){var client_hints,img,ref,ref1;return null==options&&(options={}),img=this.imageTag(publicId,options),client_hints=null!=(ref=null!=(ref1=options.client_hints)?ref1:this.config("client_hints"))&&ref,null!=options.src||client_hints||img.setAttr("src",""),img=img.toDOM(),client_hints||(Util.setData(img,"src-cache",this.url(publicId,options)),this.cloudinary_update(img,options)),img},Cloudinary.prototype.imageTag=function(publicId,options){var tag;return tag=new ImageTag(publicId,this.config()),tag.transformation().fromOptions(options),tag},Cloudinary.prototype.video_thumbnail=function(publicId,options){return this.image(publicId,Util.merge({},DEFAULT_POSTER_OPTIONS,options))},Cloudinary.prototype.facebook_profile_image=function(publicId,options){return this.image(publicId,Util.assign({type:"facebook"},options))},Cloudinary.prototype.twitter_profile_image=function(publicId,options){return this.image(publicId,Util.assign({type:"twitter"},options))},Cloudinary.prototype.twitter_name_profile_image=function(publicId,options){return this.image(publicId,Util.assign({type:"twitter_name"},options))},Cloudinary.prototype.gravatar_image=function(publicId,options){return this.image(publicId,Util.assign({type:"gravatar"},options))},Cloudinary.prototype.fetch_image=function(publicId,options){return this.image(publicId,Util.assign({type:"fetch"},options))},Cloudinary.prototype.video=function(publicId,options){return null==options&&(options={}),this.videoTag(publicId,options).toHtml()},Cloudinary.prototype.videoTag=function(publicId,options){return options=Util.defaults({},options,this.config()),new VideoTag(publicId,options)},Cloudinary.prototype.sprite_css=function(publicId,options){return options=Util.assign({type:"sprite"},options),publicId.match(/.css$/)||(options.format="css"),this.url(publicId,options)},Cloudinary.prototype.responsive=function(options,bootstrap){var ref,ref1,ref2,responsiveClass,timeout;if(null==bootstrap&&(bootstrap=!0),this.responsiveConfig=Util.merge(this.responsiveConfig||{},options),responsiveClass=null!=(ref=this.responsiveConfig.responsive_class)?ref:this.config("responsive_class"),bootstrap&&this.cloudinary_update("img."+responsiveClass+", img.cld-hidpi",this.responsiveConfig),(null==(ref1=null!=(ref2=this.responsiveConfig.responsive_resize)?ref2:this.config("responsive_resize"))||ref1)&&!this.responsiveResizeInitialized)return this.responsiveConfig.resizing=this.responsiveResizeInitialized=!0,timeout=null,window.addEventListener("resize",function(_this){return function(){var debounce,ref3,ref4,reset,run,wait,waitFunc;return debounce=null!=(ref3=null!=(ref4=_this.responsiveConfig.responsive_debounce)?ref4:_this.config("responsive_debounce"))?ref3:100,reset=function(){if(timeout)return clearTimeout(timeout),timeout=null},run=function(){return _this.cloudinary_update("img."+responsiveClass,_this.responsiveConfig)},waitFunc=function(){return reset(),run()},wait=function(){return reset(),timeout=setTimeout(waitFunc,debounce)},debounce?wait():run()}}(this))},Cloudinary.prototype.calc_breakpoint=function(element,width,steps){var breakpoints,point;return breakpoints=Util.getData(element,"breakpoints")||Util.getData(element,"stoppoints")||this.config("breakpoints")||this.config("stoppoints")||defaultBreakpoints,Util.isFunction(breakpoints)?breakpoints(width,steps):(Util.isString(breakpoints)&&(breakpoints=function(){var j,len,ref,results;for(ref=breakpoints.split(","),results=[],j=0,len=ref.length;j=0&&list[i]>=value;)i--;return list[i+1]},cdnSubdomainNumber=function(publicId){return crc32(publicId)%5+1},cloudinaryUrlPrefix=function(publicId,options){var cdnPart,host,path,protocol,ref,subdomain;return 0===(null!=(ref=options.cloud_name)?ref.indexOf("/"):void 0)?"/res"+options.cloud_name:(protocol="http://",cdnPart="",subdomain="res",host=".cloudinary.com",path="/"+options.cloud_name,options.protocol&&(protocol=options.protocol+"//"),options.private_cdn&&(cdnPart=options.cloud_name+"-",path=""),options.cdn_subdomain&&(subdomain="res-"+cdnSubdomainNumber(publicId)),options.secure?(protocol="https://",!1===options.secure_cdn_subdomain&&(subdomain="res"),null!=options.secure_distribution&&options.secure_distribution!==OLD_AKAMAI_SHARED_CDN&&options.secure_distribution!==SHARED_CDN&&(cdnPart="",subdomain="",host=options.secure_distribution)):options.cname&&(protocol="http://",cdnPart="",subdomain=options.cdn_subdomain?"a"+(crc32(publicId)%5+1)+".":"",host=options.cname),[protocol,cdnPart,subdomain,host,path].join(""))},Cloudinary.prototype.processImageTags=function(nodes,options){var images,imgOptions,node,publicId,url;return null==options&&(options={}),Util.isEmpty(nodes)?this:(options=Util.defaults({},options,this.config()),images=function(){var j,len,ref,results;for(results=[],j=0,len=nodes.length;jimageWidth&&(imageWidth=requiredWidth,Util.setData(tag,"width",requiredWidth)),imageWidth},Cloudinary.prototype.cloudinary_update=function(elements,options){var containerWidth,dataSrc,j,len,match,ref,ref1,ref2,ref3,ref4,ref5,requiredWidth,responsive,responsiveClass,roundDpr,setUrl,tag;if(null==options&&(options={}),null===elements)return this;for(responsive=null!=(ref=null!=(ref1=options.responsive)?ref1:this.config("responsive"))&&ref,elements=function(){switch(!1){case!Util.isArray(elements):case"NodeList"!==elements.constructor.name:return elements;case!Util.isString(elements):return document.querySelectorAll(elements);default:return[elements]}}(),responsiveClass=null!=(ref2=null!=(ref3=this.responsiveConfig.responsive_class)?ref3:options.responsive_class)?ref2:this.config("responsive_class"),roundDpr=null!=(ref4=options.round_dpr)?ref4:this.config("round_dpr"),j=0,len=elements.length;j").attr({type:"file",name:"file"}).unsigned_cloudinary_upload(upload_preset,upload_params,options)},jQuery.fn.cloudinary_fileupload=function(options){var cloud_name,initializing,resource_type,type,upload_url;return Util.isFunction(jQuery.fn.fileupload)?(initializing=!this.data("blueimpFileupload"),initializing&&(options=jQuery.extend({maxFileSize:2e7,dataType:"json",headers:{"X-Requested-With":"XMLHttpRequest"}},options)),this.fileupload(options),initializing&&(this.bind("fileuploaddone",function(e,data){var add_field,field,multiple,upload_info;if(!data.result.error)return data.result.path=["v",data.result.version,"/",data.result.public_id,data.result.format?"."+data.result.format:""].join(""),data.cloudinaryField&&data.form.length>0&&(upload_info=[data.result.resource_type,data.result.type,data.result.path].join("/")+"#"+data.result.signature,multiple=jQuery(e.target).prop("multiple"),add_field=function(){return jQuery("").attr({type:"hidden",name:data.cloudinaryField}).val(upload_info).appendTo(data.form)},multiple?add_field():(field=jQuery(data.form).find('input[name="'+data.cloudinaryField+'"]'),field.length>0?field.val(upload_info):add_field())),jQuery(e.target).trigger("cloudinarydone",data)}),this.bind("fileuploadsend",function(e,data){return data.headers=jQuery.extend({},data.headers,{"X-Unique-Upload-Id":(1e10*Math.random()).toString(16)}),!0}),this.bind("fileuploadstart",function(e){return jQuery(e.target).trigger("cloudinarystart")}),this.bind("fileuploadstop",function(e){return jQuery(e.target).trigger("cloudinarystop")}),this.bind("fileuploadprogress",function(e,data){return jQuery(e.target).trigger("cloudinaryprogress",data)}),this.bind("fileuploadprogressall",function(e,data){return jQuery(e.target).trigger("cloudinaryprogressall",data)}),this.bind("fileuploadfail",function(e,data){return jQuery(e.target).trigger("cloudinaryfail",data)}),this.bind("fileuploadalways",function(e,data){return jQuery(e.target).trigger("cloudinaryalways",data)}),this.fileupload("option").url||(cloud_name=options.cloud_name||jQuery.cloudinary.config().cloud_name,resource_type=options.resource_type||"auto",type=options.type||"upload",upload_url="https://api.cloudinary.com/v1_1/"+cloud_name+"/"+resource_type+"/"+type,this.fileupload("option","url",upload_url))),this):this},jQuery.fn.cloudinary_upload_url=function(remote_url){return Util.isFunction(jQuery.fn.fileupload)?(this.fileupload("option","formData").file=remote_url,this.fileupload("add",{files:[remote_url]}),delete this.fileupload("option","formData").file,this):this},jQuery.fn.unsigned_cloudinary_upload=function(upload_preset,upload_params,options){var attr,attrs_to_move,html_options,i,key,value;for(null==upload_params&&(upload_params={}),null==options&&(options={}),upload_params=Util.cloneDeep(upload_params),options=Util.cloneDeep(options),attrs_to_move=["cloud_name","resource_type","type"],i=0;i0&&jQuery.isArray(value[0])?upload_params[key]=jQuery.map(value,function(array_value){return array_value.join(",")}).join("|"):upload_params[key]=value.join(","));return upload_params.callback||(upload_params.callback="/cloudinary_cors.html"),upload_params.upload_preset=upload_preset,options.formData=upload_params,options.cloudinary_field&&(options.cloudinaryField=options.cloudinary_field,delete options.cloudinary_field),html_options=options.html||{},html_options.class=Util.trim("cloudinary_fileupload "+(html_options.class||"")),options.multiple&&(html_options.multiple=!0),this.attr(html_options).cloudinary_fileupload(options),this},jQuery.cloudinary=new CloudinaryJQuery,cloudinary={utf8_encode:utf8_encode,crc32:crc32,Util:Util,Condition:Condition,Transformation:Transformation,Configuration:Configuration,HtmlTag:HtmlTag,ImageTag:ImageTag,VideoTag:VideoTag,ClientHintsMetaTag:ClientHintsMetaTag,Layer:Layer,FetchLayer:FetchLayer,TextLayer:TextLayer,SubtitlesLayer:SubtitlesLayer,Cloudinary:Cloudinary,VERSION:"2.5.0",CloudinaryJQuery:CloudinaryJQuery}}); -//# sourceMappingURL=cloudinary-jquery-file-upload.min.js.map \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cloudinary=e():t.cloudinary=e()}(this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r={};n.r(r),n.d(r,"getData",function(){return j}),n.d(r,"setData",function(){return O}),n.d(r,"getAttribute",function(){return S}),n.d(r,"setAttribute",function(){return P}),n.d(r,"removeAttribute",function(){return x}),n.d(r,"setAttributes",function(){return T}),n.d(r,"hasClass",function(){return R}),n.d(r,"addClass",function(){return Q}),n.d(r,"width",function(){return z}),n.d(r,"isEmpty",function(){return I}),n.d(r,"isString",function(){return V}),n.d(r,"merge",function(){return N}),n.d(r,"compact",function(){return M}),n.d(r,"cloneDeep",function(){return L}),n.d(r,"contains",function(){return U}),n.d(r,"difference",function(){return H}),n.d(r,"functions",function(){return W}),n.d(r,"identity",function(){return q}),n.d(r,"isArray",function(){return $}),n.d(r,"assign",function(){return X}),n.d(r,"isPlainObject",function(){return Y}),n.d(r,"trim",function(){return Z}),n.d(r,"allStrings",function(){return a}),n.d(r,"without",function(){return c}),n.d(r,"isNumberLike",function(){return s}),n.d(r,"smartEscape",function(){return l}),n.d(r,"defaults",function(){return f}),n.d(r,"objectProto",function(){return p}),n.d(r,"objToString",function(){return h}),n.d(r,"isObject",function(){return y}),n.d(r,"funcTag",function(){return d}),n.d(r,"isFunction",function(){return v}),n.d(r,"reWords",function(){return m}),n.d(r,"camelCase",function(){return g}),n.d(r,"snakeCase",function(){return b}),n.d(r,"convertKeys",function(){return _}),n.d(r,"withCamelCaseKeys",function(){return D}),n.d(r,"withSnakeCaseKeys",function(){return B}),n.d(r,"base64Encode",function(){return w}),n.d(r,"base64EncodeURL",function(){return A}),n.d(r,"extractUrlParams",function(){return C}),n.d(r,"patchFetchFormat",function(){return k}),n.d(r,"optionConsume",function(){return F});var o=function(t){var e,n,r,o,i,u,a,c;if(null==t)return"";for(c="",i=void 0,r=void 0,0,i=r=0,a=(u=t+"").length,o=0;o127&&e<2048?String.fromCharCode(e>>6|192,63&e|128):String.fromCharCode(e>>12|224,e>>6&63|128,63&e|128),null!==n&&(r>i&&(c+=u.slice(i,r)),c+=n,i=r=o+1),o++;return r>i&&(c+=u.slice(i,a)),c},i=function(t){var e,n,r,i;for("00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D",e=0,0,i=0,e^=-1,n=0,r=(t=o(t)).length;n>>8^"0x"+"00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D".substr(9*i,8),n++;return(e^=-1)<0&&(e+=4294967296),e};function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var a=function(t){return t.length&&t.every(V)},c=function(t,e){return t.filter(function(t){return t!==e})},s=function(t){return null!=t&&!isNaN(parseFloat(t))},l=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:/([^a-zA-Z0-9_.\-\/:]+)/g;return t.replace(e,function(t){return t.split("").map(function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()}).join("")})},f=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:q;for(e in n={},t)r=t[e],e=o(e),I(e)||(n[e]=r);return n},D=function(t){return _(t,g)},B=function(t){return _(t,b)},w="undefined"!=typeof btoa&&v(btoa)?btoa:"undefined"!=typeof Buffer&&v(Buffer)?function(t){return t instanceof Buffer||(t=new Buffer.from(String(t),"binary")),t.toString("base64")}:function(t){throw new Error("No base64 encoding function found")},A=function(t){try{t=decodeURI(t)}finally{t=encodeURI(t)}return w(t)},E=["api_secret","auth_token","cdn_subdomain","cloud_name","cname","format","private_cdn","resource_type","secure","secure_cdn_subdomain","secure_distribution","shorten","sign_url","ssl_detected","type","url_suffix","use_root_path","version"];function C(t){return E.reduce(function(e,n){return null!=t[n]&&(e[n]=t[n]),e},{})}function k(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"fetch"===t.type&&null==t.fetch_format&&(t.fetch_format=F(t,"format"))}function F(t,e,n){var r=t[e];return delete t[e],null!=r?r:n}var j=function(t,e){return jQuery(t).data(e)},O=function(t,e,n){return jQuery(t).data(e,n)},S=function(t,e){return jQuery(t).attr(e)},P=function(t,e,n){return jQuery(t).attr(e,n)},x=function(t,e){return jQuery(t).removeAttr(e)},T=function(t,e){return jQuery(t).attr(e)},R=function(t,e){return jQuery(t).hasClass(e)},Q=function(t,e){return jQuery(t).addClass(e)},z=function(t){return jQuery(t).width()},I=function(t){return null==t||(jQuery.isArray(t)||V(t))&&0===t.length||jQuery.isPlainObject(t)&&jQuery.isEmptyObject(t)},V=function(t){return"string"==typeof t||"[object String]"===(null!=t?t.toString():void 0)},N=function(){var t,e;return(t=function(){var t,n,r;for(r=[],t=0,n=arguments.length;t=|<=|&&|!=|>|=|<|/|-|\\+|\\*",n="((\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*)(?=[ _])|"+Object.keys(t.PREDEFINED_VARS).join("|")+")",r=new RegExp(n,"g"),(e=e.replace(r,function(e){return t.OPERATORS[e]||t.PREDEFINED_VARS[e]})).replace(/[ _]+/g,"_"))}},{key:"variable",value:function(t,e){return new this(t).value(e)}},{key:"width",value:function(){return new this("width")}},{key:"height",value:function(){return new this("height")}},{key:"initialWidth",value:function(){return new this("initialWidth")}},{key:"initialHeight",value:function(){return new this("initialHeight")}},{key:"aspectRatio",value:function(){return new this("aspectRatio")}},{key:"initialAspectRatio",value:function(){return new this("initialAspectRatio")}},{key:"pageCount",value:function(){return new this("pageCount")}},{key:"faceCount",value:function(){return new this("faceCount")}},{key:"currentPage",value:function(){return new this("currentPage")}},{key:"tags",value:function(){return new this("tags")}},{key:"pageX",value:function(){return new this("pageX")}},{key:"pageY",value:function(){return new this("pageY")}}],(n=[{key:"serialize",value:function(){return t.normalize(this.expressions.join("_"))}},{key:"toString",value:function(){return this.serialize()}},{key:"getParent",value:function(){return this.parent}},{key:"setParent",value:function(t){return this.parent=t,this}},{key:"predicate",value:function(e,n,r){return null!=t.OPERATORS[n]&&(n=t.OPERATORS[n]),this.expressions.push("".concat(e,"_").concat(n,"_").concat(r)),this}},{key:"and",value:function(){return this.expressions.push("and"),this}},{key:"or",value:function(){return this.expressions.push("or"),this}},{key:"then",value:function(){return this.getParent().if(this.toString())}},{key:"height",value:function(t,e){return this.predicate("h",t,e)}},{key:"width",value:function(t,e){return this.predicate("w",t,e)}},{key:"aspectRatio",value:function(t,e){return this.predicate("ar",t,e)}},{key:"pageCount",value:function(t,e){return this.predicate("pc",t,e)}},{key:"faceCount",value:function(t,e){return this.predicate("fc",t,e)}},{key:"value",value:function(t){return this.expressions.push(t),this}}])&&G(e.prototype,n),r&&G(e,r),t}();K.OPERATORS={"=":"eq","!=":"ne","<":"lt",">":"gt","<=":"lte",">=":"gte","&&":"and","||":"or","*":"mul","/":"div","+":"add","-":"sub"},K.PREDEFINED_VARS={aspect_ratio:"ar",aspectRatio:"ar",current_page:"cp",currentPage:"cp",face_count:"fc",faceCount:"fc",height:"h",initial_aspect_ratio:"iar",initial_height:"ih",initial_width:"iw",initialAspectRatio:"iar",initialHeight:"ih",initialWidth:"iw",page_count:"pc",page_x:"px",page_y:"py",pageCount:"pc",pageX:"px",pageY:"py",tags:"tags",width:"w"},K.BOUNDRY="[ _]+";var J=K;function tt(t){return(tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function et(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,Configuration),this.configuration=L(t),f(this.configuration,st)}var t,e,n;return t=Configuration,(e=[{key:"init",value:function(){return this.fromEnvironment(),this.fromDocument(),this}},{key:"set",value:function(t,e){return this.configuration[t]=e,this}},{key:"get",value:function(t){return this.configuration[t]}},{key:"merge",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return X(this.configuration,L(t)),this}},{key:"fromDocument",value:function(){var t,e,n,r;if(r="undefined"!=typeof document&&null!==document?document.querySelectorAll('meta[name^="cloudinary_"]'):void 0)for(e=0,n=r.length;e2&&void 0!==arguments[2]?arguments[2]:q;Qt(this,t),this.name=e,this.shortName=n,this.process=r}return It(t,[{key:"set",value:function(t){return this.origValue=t,this}},{key:"serialize",value:function(){var t,e;return t=this.value(),e=$(t)||Y(t)||V(t)?!I(t):null!=t,null!=this.shortName&&e?"".concat(this.shortName,"_").concat(t):""}},{key:"value",value:function(){return this.process(this.origValue)}},{key:"build_array",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return $(t)?t:[t]}}],[{key:"norm_color",value:function(t){return null!=t?t.replace(/^#/,"rgb:"):void 0}},{key:"process_video_params",value:function(t){var e;switch(t.constructor){case Object:return e="","codec"in t&&(e=t.codec,"profile"in t&&(e+=":"+t.profile,"level"in t&&(e+=":"+t.level))),e;case String:return t;default:return null}}}]),t}(),Nt=function(t){function e(t,n){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",i=arguments.length>3?arguments[3]:void 0;return Qt(this,e),(r=St(this,xt(e).call(this,t,n,i))).sep=o,r}return Tt(e,Vt),It(e,[{key:"serialize",value:function(){if(null!=this.shortName){var t=this.value();if(I(t))return"";if(V(t))return"".concat(this.shortName,"_").concat(t);var e=t.map(function(t){return v(t.serialize)?t.serialize():t}).join(this.sep);return"".concat(this.shortName,"_").concat(e)}return""}},{key:"value",value:function(){var t=this;return $(this.origValue)?this.origValue.map(function(e){return t.process(e)}):this.process(this.origValue)}},{key:"set",value:function(t){return null==t||$(t)?Pt(xt(e.prototype),"set",this).call(this,t):Pt(xt(e.prototype),"set",this).call(this,[t])}}]),e}(),Mt=function(t){function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"t",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",i=arguments.length>3?arguments[3]:void 0;return Qt(this,e),(n=St(this,xt(e).call(this,t,r,i))).sep=o,n}return Tt(e,Vt),It(e,[{key:"serialize",value:function(){var t=this;if(I(this.value()))return"";if(a(this.value())){var e=this.value().join(this.sep);return I(e)?"":"".concat(this.shortName,"_").concat(e)}return this.value().map(function(e){return V(e)&&!I(e)?"".concat(t.shortName,"_").concat(e):v(e.serialize)?e.serialize():Y(e)&&!I(e)?new oe(e).serialize():void 0}).filter(function(t){return t})}},{key:"set",value:function(t){return this.origValue=t,$(this.origValue)?Pt(xt(e.prototype),"set",this).call(this,this.origValue):Pt(xt(e.prototype),"set",this).call(this,[this.origValue])}}]),e}(),Lt=function(t){function e(t,n,r){var o;return Qt(this,e),(o=St(this,xt(e).call(this,t,n,r))).process||(o.process=o.norm_range_value),o}return Tt(e,Vt),It(e,null,[{key:"norm_range_value",value:function(t){var e,n;return(n=String(t).match(new RegExp("^"+offset_any_pattern+"$")))&&(e=null!=n[5]?"p":"",t=(n[1]||n[4])+e),t}}]),e}(),Ut=function(t){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:q;return Qt(this,e),St(this,xt(e).call(this,t,n,r))}return Tt(e,Vt),It(e,[{key:"serialize",value:function(){return this.value()}}]),e}(),Ht=function(t){function e(){return Qt(this,e),St(this,xt(e).apply(this,arguments))}return Tt(e,Vt),It(e,[{key:"value",value:function(){var t=this.origValue;return Y(t)?"text"===(t=D(t)).resourceType||null!=t.text?new gt(t).toString():"subtitles"===t.resourceType?new wt(t).toString():"fetch"===t.resourceType||null!=t.url?new jt(t).toString():new pt(t).toString():V(t)&&/^fetch:.+/.test(t)?new jt(t.substr(6)).toString():t}},{key:"textStyle",value:function(t){return new gt(t).textStyleIdentifier()}}]),e}();function Wt(t){return(Wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function qt(t,e){return!e||"object"!==Wt(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function $t(t){return($t=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Xt(t,e){return(Xt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Yt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(c){o=!0,i=c}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Zt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Gt(t,e){for(var n=0;n1?e-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{};Zt(this,t),e=void 0,n={},this.toOptions=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e={};if(Object.keys(n).forEach(function(t){return e[t]=n[t].origValue}),Jt(e,this.otherOptions),t&&!I(this.chained)){var r=this.chained.map(function(t){return t.toOptions()});r.push(e),Jt(e={},this.otherOptions),e.transformation=r}return e},this.setParent=function(t){return e=t,null!=t&&this.fromOptions("function"==typeof t.toOptions?t.toOptions():void 0),this},this.getParent=function(){return e},this.param=function(t,e,r,o,i){return null==i&&(i=v(o)?o:q),n[e]=new Vt(e,r,i).set(t),this},this.rawParam&&console.log("rawParam: **********************************************"),this.rawParam=function(t,e,r,o){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return i=ne(arguments),n[e]=new Ut(e,r,i).set(t),this},this.rangeParam=function(t,e,r,o){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return i=ne(arguments),n[e]=new Lt(e,r,i).set(t),this},this.arrayParam=function(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:":",i=(arguments.length>4&&void 0!==arguments[4]&&arguments[4],arguments.length>5&&void 0!==arguments[5]&&arguments[5]);return i=ne(arguments),n[e]=new Nt(e,r,o,i).set(t),this},this.transformationParam=function(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=(arguments.length>4&&arguments[4],arguments.length>5&&void 0!==arguments[5]&&arguments[5]);return i=ne(arguments),n[e]=new Mt(e,r,o,i).set(t),this},this.layerParam=function(t,e,r){return n[e]=new Ht(e,r).set(t),this},this.getValue=function(t){var e=n[t]&&n[t].value();return null!=e?e:this.otherOptions[t]},this.get=function(t){return n[t]},this.remove=function(t){var e;switch(!1){case null==n[t]:return e=n[t],delete n[t],e.origValue;case null==this.otherOptions[t]:return e=this.otherOptions[t],delete this.otherOptions[t],e;default:return null}},this.keys=function(){var t;return function(){var e;for(t in e=[],n)null!=t&&e.push(t.match(ee)?t:b(t));return e}().sort()},this.toPlainObject=function(){var t,e,r;for(e in t={},n)t[e]=n[e].value(),Y(t[e])&&(t[e]=L(t[e]));return I(this.chained)||((r=this.chained.map(function(t){return t.toPlainObject()})).push(t),t={transformation:r}),t},this.chain=function(){var t;return 0!==Object.getOwnPropertyNames(n).length&&(t=new this.constructor(this.toOptions(!1)),this.resetTransformations(),this.chained.push(t)),this},this.resetTransformations=function(){return n={},this},this.otherOptions={},this.chained=[],I(r)||this.fromOptions(r)}return Kt(t,[{key:"fromOptions",value:function(e){var n,r;if(e instanceof t)this.fromTransformation(e);else for(n in e||(e={}),(V(e)||$(e))&&(e={transformation:e}),(e=L(e,function(e){if(e instanceof t)return new e.constructor(e.toOptions())})).if&&(this.set("if",e.if),delete e.if),e)r=e[n],n.match(ee)?"$attr"!==n&&this.set("variable",n,r):this.set(n,r);return this}},{key:"fromTransformation",value:function(e){var n=this;return e instanceof t&&e.keys().forEach(function(t){return n.set(t,e.get(t).origValue)}),this}},{key:"set",value:function(t){var e;e=g(t);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o=1&&null==r.width&&(r.width=a),parseFloat(e)>=1&&null==r.height&&(r.height=e)),r}},{key:"isValidParamName",value:function(t){return re.methods.indexOf(g(t))>=0}},{key:"toHtml",value:function(){var t;return null!=(t=this.getParent())&&"function"==typeof t.toHtml?t.toHtml():void 0}},{key:"toString",value:function(){return this.serialize()}}]),t}(),ee=/^\$[a-zA-Z0-9]+$/;function ne(t){var e;return e=null!=t?t[t.length-1]:void 0,v(e)?e:void 0}te.prototype.trans_separator="/",te.prototype.param_separator=",";var re=function(t){function Transformation(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Zt(this,Transformation),qt(this,$t(Transformation).call(this,t))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Xt(t,e)}(Transformation,te),Kt(Transformation,[{key:"angle",value:function(t){return this.arrayParam(t,"angle","a",".",J.normalize)}},{key:"audioCodec",value:function(t){return this.param(t,"audio_codec","ac")}},{key:"audioFrequency",value:function(t){return this.param(t,"audio_frequency","af")}},{key:"aspectRatio",value:function(t){return this.param(t,"aspect_ratio","ar",J.normalize)}},{key:"background",value:function(t){return this.param(t,"background","b",Vt.norm_color)}},{key:"bitRate",value:function(t){return this.param(t,"bit_rate","br")}},{key:"border",value:function(t){return this.param(t,"border","bo",function(t){return Y(t)?(t=X({},{color:"black",width:2},t),"".concat(t.width,"px_solid_").concat(Vt.norm_color(t.color))):t})}},{key:"color",value:function(t){return this.param(t,"color","co",Vt.norm_color)}},{key:"colorSpace",value:function(t){return this.param(t,"color_space","cs")}},{key:"crop",value:function(t){return this.param(t,"crop","c")}},{key:"defaultImage",value:function(t){return this.param(t,"default_image","d")}},{key:"delay",value:function(t){return this.param(t,"delay","dl")}},{key:"density",value:function(t){return this.param(t,"density","dn")}},{key:"duration",value:function(t){return this.rangeParam(t,"duration","du")}},{key:"dpr",value:function(t){return this.param(t,"dpr","dpr",function(t){return(null!=(t=t.toString())?t.match(/^\d+$/):void 0)?t+".0":J.normalize(t)})}},{key:"effect",value:function(t){return this.arrayParam(t,"effect","e",":",J.normalize)}},{key:"else",value:function(){return this.if("else")}},{key:"endIf",value:function(){return this.if("end")}},{key:"endOffset",value:function(t){return this.rangeParam(t,"end_offset","eo")}},{key:"fallbackContent",value:function(t){return this.param(t,"fallback_content")}},{key:"fetchFormat",value:function(t){return this.param(t,"fetch_format","f")}},{key:"format",value:function(t){return this.param(t,"format")}},{key:"flags",value:function(t){return this.arrayParam(t,"flags","fl",".")}},{key:"gravity",value:function(t){return this.param(t,"gravity","g")}},{key:"fps",value:function(t){return this.param(t,"fps","fps",function(t){return V(t)?t:$(t)?t.join("-"):t})}},{key:"height",value:function(t){var e=this;return this.param(t,"height","h",function(){return e.getValue("crop")||e.getValue("overlay")||e.getValue("underlay")?J.normalize(t):null})}},{key:"htmlHeight",value:function(t){return this.param(t,"html_height")}},{key:"htmlWidth",value:function(t){return this.param(t,"html_width")}},{key:"if",value:function(){var t,e,n,r,o,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";switch(i){case"else":return this.chain(),this.param(i,"if","if");case"end":for(this.chain(),t=n=this.chained.length-1;n>=0&&"end"!==(e=this.chained[t].getValue("if"))&&(null==e||(r=Transformation.new().if(e),this.chained[t].remove("if"),o=this.chained[t],this.chained[t]=Transformation.new().transformation([r,o]),"else"===e));t=n+=-1);return this.param(i,"if","if");case"":return it.new().setParent(this);default:return this.param(i,"if","if",function(t){return it.new(t).toString()})}}},{key:"keyframeInterval",value:function(t){return this.param(t,"keyframe_interval","ki")}},{key:"offset",value:function(t){var e,n,r=Yt(v(null!=t?t.split:void 0)?t.split(".."):$(t)?t:[null,null],2);if(n=r[0],e=r[1],null!=n&&this.startOffset(n),null!=e)return this.endOffset(e)}},{key:"opacity",value:function(t){return this.param(t,"opacity","o",J.normalize)}},{key:"overlay",value:function(t){return this.layerParam(t,"overlay","l")}},{key:"page",value:function(t){return this.param(t,"page","pg")}},{key:"poster",value:function(t){return this.param(t,"poster")}},{key:"prefix",value:function(t){return this.param(t,"prefix","p")}},{key:"quality",value:function(t){return this.param(t,"quality","q",J.normalize)}},{key:"radius",value:function(t){return this.param(t,"radius","r",J.normalize)}},{key:"rawTransformation",value:function(t){return this.rawParam(t,"raw_transformation")}},{key:"size",value:function(t){var e,n;if(v(null!=t?t.split:void 0)){var r=Yt(t.split("x"),2);return n=r[0],e=r[1],this.width(n),this.height(e)}}},{key:"sourceTypes",value:function(t){return this.param(t,"source_types")}},{key:"sourceTransformation",value:function(t){return this.param(t,"source_transformation")}},{key:"startOffset",value:function(t){return this.rangeParam(t,"start_offset","so")}},{key:"streamingProfile",value:function(t){return this.param(t,"streaming_profile","sp")}},{key:"transformation",value:function(t){return this.transformationParam(t,"transformation","t")}},{key:"underlay",value:function(t){return this.layerParam(t,"underlay","u")}},{key:"variable",value:function(t,e){return this.param(e,t,t)}},{key:"variables",value:function(t){return this.arrayParam(t,"variables")}},{key:"videoCodec",value:function(t){return this.param(t,"video_codec","vc",Vt.process_video_params)}},{key:"videoSampling",value:function(t){return this.param(t,"video_sampling","vs")}},{key:"width",value:function(t){var e=this;return this.param(t,"width","w",function(){return e.getValue("crop")||e.getValue("overlay")||e.getValue("underlay")?J.normalize(t):null})}},{key:"x",value:function(t){return this.param(t,"x","x",J.normalize)}},{key:"y",value:function(t){return this.param(t,"y","y",J.normalize)}},{key:"zoom",value:function(t){return this.param(t,"zoom","z",J.normalize)}}],[{key:"new",value:function(t){return new Transformation(t)}}]),Transformation}();re.methods=Object.getOwnPropertyNames(re.prototype),re.PARAM_NAMES=re.methods.map(b).concat(lt.CONFIG_PARAMS);var oe=re;function ie(t,e){for(var n=0;n0&&(t+=" "+e),t+">"}},{key:"closeTag",value:function(){return"")}},{key:"toHtml",value:function(){return this.openTag()+this.content()+this.closeTag()}},{key:"toDOM",value:function(){var t,e,n,r;if(!v("undefined"!=typeof document&&null!==document?document.createElement:void 0))throw"Can't create DOM if document is not present!";for(e in t=document.createElement(this.name),n=this.attributes())r=n[e],t.setAttribute(e,r);return t}}])&&ie(t.prototype,e),n&&ie(t,n),HtmlTag}(),ce="cloudinary-a.akamaihd.net",se="res.cloudinary.com",le={format:"jpg",resource_type:"video"},fe={"image/upload":"images","image/private":"private_images","image/authenticated":"authenticated_images","raw/upload":"files","video/upload":"videos"},pe={resource_type:"image",transformation:[],type:"upload"},he={fallback_content:"",resource_type:"video",source_transformation:{},source_types:["webm","mp4","ogv"],transformation:[],type:"upload"};function ye(t,e){var n,r,o,u,a,c;return 0===(null!=(a=e.cloud_name)?a.indexOf("/"):void 0)?"/res"+e.cloud_name:(u="http://",n="",c="res",r=".cloudinary.com",o="/"+e.cloud_name,e.protocol&&(u=e.protocol+"//"),e.private_cdn&&(n=e.cloud_name+"-",o=""),e.cdn_subdomain&&(c="res-"+function(t){return i(t)%5+1}(t)),e.secure?(u="https://",!1===e.secure_cdn_subdomain&&(c="res"),null!=e.secure_distribution&&e.secure_distribution!==ce&&e.secure_distribution!==se&&(n="",c="",r=e.secure_distribution)):e.cname&&(u="http://",n="",c=e.cdn_subdomain?"a"+(i(t)%5+1)+".":"",r=e.cname),[u,n,c,r,o].join(""))}function de(t){var e,n,r,o,i,u,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return t;if(a instanceof oe&&(a=a.toOptions()),"fetch"===(a=f({},a,c,pe)).type&&(a.fetch_format=a.fetch_format||a.format,t=function(t){var e;return t.match(/^https?:\//)||(e=document.location.protocol+"//"+document.location.host,"?"===t[0]?e+=document.location.pathname:"/"!==t[0]&&(e+=document.location.pathname.replace(/\/[^\/]*$/,"/")),t=e+t),t}(t)),o=new oe(a).serialize(),!a.cloud_name)throw"Unknown cloud_name";if(t.search("/")>=0&&!t.match(/^v[0-9]+/)&&!t.match(/^https?:\//)&&!(null!=(n=a.version)?n.toString():void 0)&&(a.version=1),t.match(/^https?:/))"upload"===a.type||"asset"===a.type?i=t:t=encodeURIComponent(t).replace(/%3A/g,":").replace(/%2F/g,"/");else{try{t=decodeURIComponent(t)}catch(s){s}if(t=encodeURIComponent(t).replace(/%3A/g,":").replace(/%2F/g,"/"),a.url_suffix){if(a.url_suffix.match(/[\.\/]/))throw"url_suffix should not include . or /";t=t+"/"+a.url_suffix}a.format&&(a.trust_public_id||(t=t.replace(/\.(jpg|png|gif|webp)$/,"")),t=t+"."+a.format)}return e=ye(t,a),r=function(){var t,e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"upload",o=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0;if(Y(n)&&(n=(e=n).resource_type,r=e.type,o=e.url_suffix,i=e.use_root_path,u=e.shorten),null==r&&(r="upload"),null!=o&&(n=fe["".concat(n,"/").concat(r)],r=null,null==n))throw new Error("URL Suffix only supported for ".concat(function(){var e;for(t in e=[],fe)e.push(t);return e}().join(", ")));if(i){if(("image"!==n||"upload"!==r)&&"images"!==n)throw new Error("Root path only supported for image/upload");n=null,r=null}return u&&"image"===n&&"upload"===r&&(n="iu",r=null),[n,r].join("/")}(a.resource_type,a.type,a.url_suffix,a.use_root_path,a.shorten),u=a.version?"v"+a.version:"",i||M([e,r,o,u,t]).join("/").replace(/([^:])\/+/g,"$1/")}function ve(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(c){o=!0,i=c}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var me=I;function ge(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=C(r);return n=n||r,o.raw_transformation=new oe([N({},n),{crop:"scale",width:e}]).toString(),de(t,o)}function be(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(t){var e=t.breakpoints||[];if(e.length)return e;var n=ve([t.min_width,t.max_width,t.max_images].map(Number),3),r=n[0],o=n[1],i=n[2];if([r,o,i].some(isNaN))throw"Either (min_width, max_width, max_images) or breakpoints must be provided to the image srcset attribute";if(r>o)throw"min_width must be less than max_width";if(i<=0)throw"max_images must be a positive integer";1===i&&(r=o);for(var u=Math.ceil((o-r)/Math.max(i-1,1)),a=r;a1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o={};if(me(n))return o;var i=!e.sizes&&!0===n.sizes,u=!e.srcset;if(u||i){var a=be(t,n,r);if(u){var c=function(t,e,n,r){return k(r=L(r)),e.map(function(e){return"".concat(ge(t,e,n,r)," ").concat(e,"w")}).join(", ")}(t,a,n.transformation,r);me(c)||(o.srcset=c)}if(i){var s=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return"(max-width: ".concat(t,"px) ").concat(t,"px")}).join(", ")}(a);me(s)||(o.sizes=s)}}return o}function De(t){return(De="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Be(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,ImageTag),we(this,Ee(ImageTag).call(this,"img",t,e))}var e,n,r;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ce(t,e)}(ImageTag,ae),e=ImageTag,(n=[{key:"closeTag",value:function(){return""}},{key:"attributes",value:function(){var t,e,n;t=Ae(Ee(ImageTag.prototype),"attributes",this).call(this)||{},e=this.getOptions();var r=this.getOption("srcset"),o=this.getOption("attributes")||{},i={};return V(r)?i.srcset=r:i=_e(this.publicId,o,r,e),I(i)||(delete e.width,delete e.height),N(t,i),null==t[n=e.responsive&&!e.client_hints?"data-src":"src"]&&(t[n]=de(this.publicId,this.getOptions())),t}}])&&Be(e.prototype,n),r&&Be(e,r),ImageTag}();function Fe(t){return(Fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function je(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Oe(this,Pe(e).call(this,"source",t,n))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&xe(t,e)}(e,ae),n=e,(r=[{key:"closeTag",value:function(){return""}},{key:"attributes",value:function(){var t=this.getOption("srcset"),n=Se(Pe(e.prototype),"attributes",this).call(this)||{},r=this.getOptions();return N(n,_e(this.publicId,n,t,r)),n.srcset||(n.srcset=de(this.publicId,r)),!n.media&&r.media&&(n.media=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=[];return null!=t.min_width&&e.push("(min-width: ".concat(t.min_width,"px)")),null!=t.max_width&&e.push("(max-width: ".concat(t.max_width,"px)")),e.join(" and ")}(r.media)),n}}])&&je(n.prototype,r),o&&je(n,o),e}();function Re(t){return(Re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Qe(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,PictureTag),(e=ze(this,Ve(PictureTag).call(this,"picture",t,n))).widthList=r,e}var e,n,r;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ne(t,e)}(PictureTag,ae),e=PictureTag,(n=[{key:"content",value:function(){var t=this;return this.widthList.map(function(e){var n=e.min_width,r=e.max_width,o=e.transformation,i=t.getOptions(),u=new oe(i);return u.chain().fromOptions("string"==typeof o?{raw_transformation:o}:o),(i=C(i)).media={min_width:n,max_width:r},i.transformation=u,new Te(t.publicId,i).toHtml()}).join("")+new ke(this.publicId,this.getOptions()).toHtml()}},{key:"attributes",value:function(){var t=Ie(Ve(PictureTag.prototype),"attributes",this).call(this);return delete t.width,delete t.height,t}},{key:"closeTag",value:function(){return""}}])&&Qe(e.prototype,n),r&&Qe(e,r),PictureTag}();function Le(t){return(Le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ue(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,VideoTag),e=f({},e,he),He(this,qe(VideoTag).call(this,"video",t.replace(/\.(mp4|ogv|webm)$/,""),e))}var e,n,r;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&$e(t,e)}(VideoTag,ae),e=VideoTag,(n=[{key:"setSourceTransformation",value:function(t){return this.transformation().sourceTransformation(t),this}},{key:"setSourceTypes",value:function(t){return this.transformation().sourceTypes(t),this}},{key:"setPoster",value:function(t){return this.transformation().poster(t),this}},{key:"setFallbackContent",value:function(t){return this.transformation().fallbackContent(t),this}},{key:"content",value:function(){var t,e,n,r,o,i,u,a;if(o=this.transformation().getValue("source_types"),r=this.transformation().getValue("source_transformation"),t=this.transformation().getValue("fallback_content"),$(o)){var c=this.getOptions();e=function(){var t,e,s;for(s=[],t=0,e=o.length;t"));return s}.call(this)}else e=[];return e.join("")+t}},{key:"attributes",value:function(){var t,e,n,r,o,i,u,a,c;for(c=this.getOption("source_types"),i=null!=(u=this.getOption("poster"))?u:{},Y(i)&&(n=null!=i.public_id?pe:Ye,i=de(null!=(a=i.public_id)?a:this.publicId,f({},i,n,this.getOptions()))),r=0,o=(e=We(qe(VideoTag.prototype),"attributes",this).call(this)||[]).length;r1&&void 0!==arguments[1]?arguments[1]:100;return e*Math.ceil(t/e)},rn=function(t,e){var n;for(n=t.length-2;n>=0&&t[n]>=e;)n--;return t[n+1]},nn=function(t,e,n,r){var o,i,u,a;return!(a=null!=(o=null!=(i=null!=(u=r.responsive_use_breakpoints)?u:r.responsive_use_stoppoints)?i:this.config("responsive_use_breakpoints"))?o:this.config("responsive_use_stoppoints"))||"resize"===a&&!r.resizing?e:this.calc_breakpoint(t,e,n)},un=function(t){var e,n;for(e=0;(t=null!=t?t.parentNode:void 0)instanceof Element&&!e;)n=window.getComputedStyle(t),/^inline/.test(n.display)||(e=z(t));return e},cn=function(t,e){return t.replace(/\bdpr_(1\.0|auto)\b/g,"dpr_"+this.device_pixel_ratio(e))},an=function(t,e){var n;return t>(n=j(e,"width")||0)&&(n=t,O(e,"width",t)),n};var fn,pn=function(){function Cloudinary(t){var e;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,Cloudinary),this.devicePixelRatioCache={},this.responsiveConfig={},this.responsiveResizeInitialized=!1,e=new lt(t),this.config=function(t,n){return e.config(t,n)},this.fromDocument=function(){return e.fromDocument(),this},this.fromEnvironment=function(){return e.fromEnvironment(),this},this.init=function(){return e.init(),this}}var t,e,n;return t=Cloudinary,n=[{key:"new",value:function(t){return new this(t)}}],(e=[{key:"url",value:function(t){return de(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},this.config())}},{key:"video_url",value:function(t,e){return e=X({resource_type:"video"},e),this.url(t,e)}},{key:"video_thumbnail_url",value:function(t,e){return e=X({},le,e),this.url(t,e)}},{key:"transformation_string",value:function(t){return new oe(t).serialize()}},{key:"image",value:function(t){var e,n,r,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n=this.imageTag(t,i),e=null!=(r=null!=(o=i.client_hints)?o:this.config("client_hints"))&&r,null!=i.src||e||n.setAttr("src",""),n=n.toDOM(),e||(O(n,"src-cache",this.url(t,i)),this.cloudinary_update(n,i)),n}},{key:"imageTag",value:function(t,e){var n;return(n=new ke(t,this.config())).transformation().fromOptions(e),n}},{key:"pictureTag",value:function(t,e){var n;return(n=new Me(t,this.config())).transformation().fromOptions(e),n}},{key:"sourceTag",value:function(t,e){var n;return(n=new Te(t,this.config())).transformation().fromOptions(e),n}},{key:"video_thumbnail",value:function(t,e){return this.image(t,N({},le,e))}},{key:"facebook_profile_image",value:function(t,e){return this.image(t,X({type:"facebook"},e))}},{key:"twitter_profile_image",value:function(t,e){return this.image(t,X({type:"twitter"},e))}},{key:"twitter_name_profile_image",value:function(t,e){return this.image(t,X({type:"twitter_name"},e))}},{key:"gravatar_image",value:function(t,e){return this.image(t,X({type:"gravatar"},e))}},{key:"fetch_image",value:function(t,e){return this.image(t,X({type:"fetch"},e))}},{key:"video",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.videoTag(t,e).toHtml()}},{key:"videoTag",value:function(t,e){return e=f({},e,this.config()),new Ze(t,e)}},{key:"sprite_css",value:function(t,e){return e=X({type:"sprite"},e),t.match(/.css$/)||(e.format="css"),this.url(t,e)}},{key:"responsive",value:function(t){var e,n,r,o,i,u=this,a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.responsiveConfig=N(this.responsiveConfig||{},t),o=null!=(e=this.responsiveConfig.responsive_class)?e:this.config("responsive_class"),a&&this.cloudinary_update("img.".concat(o,", img.cld-hidpi"),this.responsiveConfig),(null==(n=null!=(r=this.responsiveConfig.responsive_resize)?r:this.config("responsive_resize"))||n)&&!this.responsiveResizeInitialized)return this.responsiveConfig.resizing=this.responsiveResizeInitialized=!0,i=null,window.addEventListener("resize",function(){var t,e,n,r,a,c;return t=null!=(e=null!=(n=u.responsiveConfig.responsive_debounce)?n:u.config("responsive_debounce"))?e:100,r=function(){if(i)return clearTimeout(i),i=null},a=function(){return u.cloudinary_update("img.".concat(o),u.responsiveConfig)},c=function(){return r(),a()},t?function(){return r(),i=setTimeout(c,t)}():a()})}},{key:"calc_breakpoint",value:function(t,e,n){var r=j(t,"breakpoints")||j(t,"stoppoints")||this.config("breakpoints")||this.config("stoppoints")||on;return v(r)?r(e,n):(V(r)&&(r=r.split(",").map(function(t){return parseInt(t)}).sort(function(t,e){return t-e})),rn(r,e))}},{key:"calc_stoppoint",value:function(t,e,n){return this.calc_breakpoint(t,e,n)}},{key:"device_pixel_ratio",value:function(){var t,e,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return t=("undefined"!=typeof window&&null!==window?window.devicePixelRatio:void 0)||1,n&&(t=Math.ceil(t)),(t<=0||NaN===t)&&(t=1),(e=t.toString()).match(/^\d+$/)&&(e+=".0"),e}},{key:"processImageTags",value:function(t){var e,n,r,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return I(t)?this:(i=f({},i,this.config()),e=function(){var e,u,a,c;for(c=[],e=0,u=t.length;e1&&void 0!==arguments[1]?arguments[1]:{};if(null===t)return this;for(h=null!=(u=null!=(a=g.responsive)?a:this.config("responsive"))&&u,t=function(){switch(!1){case!$(t):case"NodeList"!==t.constructor.name:return t;case!V(t):return document.querySelectorAll(t);default:return[t]}}(),y=null!=(c=null!=(s=this.responsiveConfig.responsive_class)?s:g.responsive_class)?c:this.config("responsive_class"),d=null!=(l=g.round_dpr)?l:this.config("round_dpr"),r=0,o=t.length;r0;){var r=e.shift();if(null!=r)return r}return null};function yn(t){return(yn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function dn(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};return n=this.imageTag(t,r),e=hn(r.client_hints,this.config("client_hints"),!1),null!=r.src||e||n.setAttr("src",""),n=jQuery(n.toHtml()),e||n.data("src-cache",this.url(t,r)).cloudinary_update(r),n}},{key:"responsive",value:function(t){var e,n,r,o,i=this;if(n=jQuery.extend(n||{},t),e=this.responsiveConfig.responsive_class||this.config("responsive_class"),jQuery("img.".concat(e,", img.cld-hidpi")).cloudinary_update(n),hn(n.responsive_resize,this.config("responsive_resize"),!0)&&!r)return n.resizing=r=!0,o=null,jQuery(window).on("resize",function(){var t=hn(n.responsive_debounce,i.config("responsive_debounce"),100),r=function(){if(o)return clearTimeout(o),o=null},u=function(){return jQuery("img.".concat(e)).cloudinary_update(n)};return t?(r(),setTimeout(function(){return r(),u()},t)):u()})}}])&&dn(e.prototype,n),r&&dn(e,r),CloudinaryJQuery}();jQuery.fn.cloudinary=function(t){return this.filter("img").each(function(){var e,n,r;return n=(e=jQuery.extend({width:jQuery(this).attr("width"),height:jQuery(this).attr("height"),src:jQuery(this).attr("src")},jQuery(this).data(),t)).source||e.src,delete e.source,delete e.src,r=jQuery.cloudinary.url(n,e),e=new oe(e).toHtmlAttributes(),jQuery(this).data("src-cache",r).attr({width:e.width,height:e.height})}).cloudinary_update(t),this},jQuery.fn.cloudinary_update=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return jQuery.cloudinary.cloudinary_update(this.filter("img").toArray(),t),this},fn=null,jQuery.fn.webpify=function(){var t,e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return t=this,r=null!=r?r:n,fn||(fn=jQuery.Deferred(),(e=new Image).onerror=fn.reject,e.onload=fn.resolve,e.src="data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA"),jQuery(function(){return fn.done(function(){return jQuery(t).cloudinary(jQuery.extend({},r,{format:"webp"}))}).fail(function(){return jQuery(t).cloudinary(n)})}),this},jQuery.fn.fetchify=function(t){return this.cloudinary(jQuery.extend(t,{type:"fetch"}))},jQuery.cloudinary=new bn,jQuery.cloudinary.fromDocument();var _n=bn;_n.prototype.delete_by_token=function(t,e){var n,r;return(r=(e=e||{}).url)||(r="https://api.cloudinary.com/v1_1/"+(e.cloud_name||jQuery.cloudinary.config().cloud_name)+"/delete_by_token"),n=jQuery.support.xhrFileUpload?"json":"iframe json",jQuery.ajax({url:r,method:"POST",data:{token:t},headers:{"X-Requested-With":"XMLHttpRequest"},dataType:n})},_n.prototype.unsigned_upload_tag=function(t,e,n){return jQuery("").attr({type:"file",name:"file"}).unsigned_cloudinary_upload(t,e,n)},jQuery.fn.cloudinary_fileupload=function(t){var e,n;return v(jQuery.fn.fileupload)?((e=!this.data("blueimpFileupload"))&&(t=jQuery.extend({maxFileSize:2e7,dataType:"json",headers:{"X-Requested-With":"XMLHttpRequest"}},t)),this.fileupload(t),e&&(this.bind("fileuploaddone",function(t,e){var n,r,o;if(!e.result.error)return e.result.path=["v",e.result.version,"/",e.result.public_id,e.result.format?"."+e.result.format:""].join(""),e.cloudinaryField&&e.form.length>0&&(o=[e.result.resource_type,e.result.type,e.result.path].join("/")+"#"+e.result.signature,n=function(){return jQuery("").attr({type:"hidden",name:e.cloudinaryField}).val(o).appendTo(e.form)},jQuery(t.target).prop("multiple")?n():(r=jQuery(e.form).find('input[name="'+e.cloudinaryField+'"]')).length>0?r.val(o):n()),jQuery(t.target).trigger("cloudinarydone",e)}),this.bind("fileuploadsend",function(t,e){return e.headers=jQuery.extend({},e.headers,{"X-Unique-Upload-Id":(1e10*Math.random()).toString(16)}),!0}),this.bind("fileuploadstart",function(t){return jQuery(t.target).trigger("cloudinarystart")}),this.bind("fileuploadstop",function(t){return jQuery(t.target).trigger("cloudinarystop")}),this.bind("fileuploadprogress",function(t,e){return jQuery(t.target).trigger("cloudinaryprogress",e)}),this.bind("fileuploadprogressall",function(t,e){return jQuery(t.target).trigger("cloudinaryprogressall",e)}),this.bind("fileuploadfail",function(t,e){return jQuery(t.target).trigger("cloudinaryfail",e)}),this.bind("fileuploadalways",function(t,e){return jQuery(t.target).trigger("cloudinaryalways",e)}),this.fileupload("option").url||(n="https://api.cloudinary.com/v1_1/"+(t.cloud_name||jQuery.cloudinary.config().cloud_name)+"/"+(t.resource_type||"auto")+"/"+(t.type||"upload"),this.fileupload("option","url",n))),this):this},jQuery.fn.cloudinary_upload_url=function(t){return v(jQuery.fn.fileupload)?(this.fileupload("option","formData").file=t,this.fileupload("add",{files:[t]}),delete this.fileupload("option","formData").file,this):this},jQuery.fn.unsigned_cloudinary_upload=function(t){var e,n,r,o,i,u,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(a=L(a),c=L(c),n=["cloud_name","resource_type","type"],o=0;o0&&jQuery.isArray(u[0])?a[i]=jQuery.map(u,function(t){return t.join(",")}).join("|"):a[i]=u.join(","));return a.callback||(a.callback="/cloudinary_cors.html"),a.upload_preset=t,c.formData=a,c.cloudinary_field&&(c.cloudinaryField=c.cloudinary_field,delete c.cloudinary_field),(r=c.html||{}).class=Z("cloudinary_fileupload ".concat(r.class||"")),c.multiple&&(r.multiple=!0),this.attr(r).cloudinary_fileupload(c),this},jQuery.cloudinary=new _n;var Dn=_n;n.d(e,"utf8_encode",function(){return o}),n.d(e,"crc32",function(){return i}),n.d(e,"Util",function(){return r}),n.d(e,"Transformation",function(){return oe}),n.d(e,"Condition",function(){return it}),n.d(e,"Configuration",function(){return lt}),n.d(e,"HtmlTag",function(){return ae}),n.d(e,"ImageTag",function(){return ke}),n.d(e,"PictureTag",function(){return Me}),n.d(e,"VideoTag",function(){return Ze}),n.d(e,"ClientHintsMetaTag",function(){return sn}),n.d(e,"Layer",function(){return pt}),n.d(e,"FetchLayer",function(){return jt}),n.d(e,"TextLayer",function(){return gt}),n.d(e,"SubtitlesLayer",function(){return wt}),n.d(e,"Cloudinary",function(){return pn}),n.d(e,"CloudinaryJQuery",function(){return Dn})}])}); \ No newline at end of file diff --git a/package.json b/package.json index 78cd544..df087f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cloudinary-jquery-file-upload", - "version": "2.5.0", + "version": "2.6.0", "description": "Cloudinary Client Side JS library. Cloudinary streamlines your web application’s image manipulation needs. Cloudinary's cloud-based servers automate image uploading, resizing, cropping, optimizing, sprite generation and more. Cloudinary's jQuery File Upload plugin allows direct uploading from the browser to the cloud and dynamic cloud-based image transformations and effects.", "main": "cloudinary-jquery-file-upload.js", "files": ["*.js"],