Set the cropped area position and size with new data
@param {Object} data - The new data.
@returns {Cropper} this
762072
function setData$$1(data) {
    var options = this.options,
        imageData = this.imageData,
        canvasData = this.canvasData;

    var cropBoxData = {};

    if (this.ready && !this.disabled && isPlainObject(data)) {
      var transformed = false;

      if (options.rotatable) {
        if (isNumber(data.rotate) && data.rotate !== imageData.rotate) {
          imageData.rotate = data.rotate;
          transformed = true;
        }
      }

      if (options.scalable) {
        if (isNumber(data.scaleX) && data.scaleX !== imageData.scaleX) {
          imageData.scaleX = data.scaleX;
          transformed = true;
        }

        if (isNumber(data.scaleY) && data.scaleY !== imageData.scaleY) {
          imageData.scaleY = data.scaleY;
          transformed = true;
        }
      }

      if (transformed) {
        this.renderCanvas(true, true);
      }

      var ratio = imageData.width / imageData.naturalWidth;

      if (isNumber(data.x)) {
        cropBoxData.left = data.x * ratio + canvasData.left;
      }

      if (isNumber(data.y)) {
        cropBoxData.top = data.y * ratio + canvasData.top;
      }

      if (isNumber(data.width)) {
        cropBoxData.width = data.width * ratio;
      }

      if (isNumber(data.height)) {
        cropBoxData.height = data.height * ratio;
      }

      this.setCropBoxData(cropBoxData);
    }

    return this;
  }
1177870
function (data) {
            var zoomMode = this.state.zoomState.zoomMode;
            this.state.viewportDimensions = data;
            this.updateZoomLevels();
            this.setZoom(zoomMode);
        }
401221
function (data) {
    this.on("change:parent", this._onParent);

    // copy the data to this object. Note this shaves a TON
    // of time off initializing any view, especially list items if we
    // use this method over @setProperties data
    if (false) {
      for(var key in data) {
        this[key] = data[key];
      }
    }

    // necessary to properly dispose this view so it can be recycled
    if (this.parent) this._onParent(this.parent);
  }
1071964
function (data, width, height, normalize, colorFunc, isInRange) {
        var brush = this._getBrush();
        var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
        var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
        var r = this.pointSize + this.blurSize;

        var canvas = this.canvas;
        var ctx = canvas.getContext('2d');
        var len = data.length;
        canvas.width = width;
        canvas.height = height;
        for (var i = 0; i < len; ++i) {
            var p = data[i];
            var x = p[0];
            var y = p[1];
            var value = p[2];

            // calculate alpha using value
            var alpha = normalize(value);

            // draw with the circle brush with alpha
            ctx.globalAlpha = alpha;
            ctx.drawImage(brush, x - r, y - r);
        }

        if (!canvas.width || !canvas.height) {
            // Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
            // 'CanvasRenderingContext2D': The source height is 0."
            return canvas;
        }

        // colorize the canvas using alpha value and set with gradient
        var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);

        var pixels = imageData.data;
        var offset = 0;
        var pixelLen = pixels.length;
        var minOpacity = this.minOpacity;
        var maxOpacity = this.maxOpacity;
        var diffOpacity = maxOpacity - minOpacity;

        while (offset < pixelLen) {
            var alpha = pixels[offset + 3] / 256;
            var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
            // Simple optimize to ignore the empty data
            if (alpha > 0) {
                var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
                // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
                alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
                pixels[offset++] = gradient[gradientOffset];
                pixels[offset++] = gradient[gradientOffset + 1];
                pixels[offset++] = gradient[gradientOffset + 2];
                pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
            }
            else {
                offset += 4;
            }
        }
        ctx.putImageData(imageData, 0, 0);

        return canvas;
    }
281074
function (crop, setAsCurrent) {
            var _this = this;

            // Create image container element
            var pvDivOuter = document.createElement('div');
            pvDivOuter.id = this._image.id + '_' + crop.id;
            pvDivOuter.classList.add('imc_preview_image_container');

            if (setAsCurrent) {
                pvDivOuter.classList.add('active');
            }

            pvDivOuter.addEventListener(
                'click',
                function () {
                    _this.setActiveCrop(crop);
                }
            );

            // Create inner container element
            var pvDivInner = document.createElement('div');
            pvDivInner.classList.add('imc_preview_image');

            var previewHeight = 90; // Dummy default, will be overriden in _renderUpdatedPreview
            var previewWidth = IMSoftcrop.Ratio.width(previewHeight, crop.ratio.f);
            pvDivInner.style.width = IMSoftcrop.Ratio.width(previewHeight, crop.ratio.f) + 'px';

            // Create span (title) element, including warning element
            var pvSpan = document.createElement('span');
            var pvSpanEm = document.createElement('em');
            var pvWarning = document.createElement('i');
            pvWarning.className = 'fa fa-warning';

            var pvUsed = document.createElement('b');
            var pvUsedCrop = crop;
            pvUsed.className = 'fa fa-check';
            pvUsed.addEventListener(
                'click',
                function(e) {
                    _this.toggleCropUsable(pvUsedCrop)
                    e.preventDefault();
                    e.stopPropagation();
                    return false;
                }
            )

            pvSpanEm.appendChild(document.createTextNode(crop.id))
            pvSpan.appendChild(pvUsed);
            pvSpan.appendChild(pvSpanEm);
            pvSpan.appendChild(pvWarning);


            // Create image element
            var pvImg = document.createElement('img');
            pvImg.src = this._image.src;

            // Put it together
            pvDivInner.appendChild(pvImg);
            pvDivInner.appendChild(pvSpan);
            pvDivOuter.appendChild(pvDivInner);
            this._previewContainer.appendChild(pvDivOuter);


            // Render update
            this._renderUpdatedPreview(crop);
        }
1157752
function( data ){
		data = $.extend({
			distance: drag.distance,
			which: drag.which,
			not: drag.not,
			drop: drag.drop
			}, data || {});
		data.distance = squared( data.distance ); //  x² + y² = distance²
		$event.add( this, "mousedown", handler, data );
		if ( this.attachEvent ) this.attachEvent("ondragstart", dontStart ); // prevent image dragging in IE...
		}
604208
function getCropBoxData() {
    var cropBoxData = this.cropBoxData;

    var data = void 0;

    if (this.ready && this.cropped) {
      data = {
        left: cropBoxData.left,
        top: cropBoxData.top,
        width: cropBoxData.width,
        height: cropBoxData.height
      };
    }

    return data || {};
  }
157467
function(data) {
            var corners = [];
            for (var i = 0; i < data.length; i += 2) {
                corners.push({
                    x: data[i],
                    y: data[i + 1]
                });
            }

            this._image.addDetailData(corners);
        }
1258580
function crop(data, rows, cols, nRows, nCols) {

    if (rows === nRows && cols === nCols) {
        //Do nothing. Returns the same input!!! Be careful
        return data;
    }

    var output = new Array(nCols * nRows);

    var shiftR = Math.floor((rows - nRows) / 2);
    var shiftC = Math.floor((cols - nCols) / 2);
    var destinyRow, sourceRow, i, j;
    for (i = 0; i < nRows; i++) {
        destinyRow = i * nCols;
        sourceRow = (i + shiftR) * cols;
        for (j = 0; j < nCols; j++) {
            output[destinyRow + j] = data[sourceRow + (j + shiftC)];
        }
    }

    return output;
}
549542
function resizeImage(ctx, imageData, width, height) {
  const {naturalWidth, naturalHeight} = imageData;
  if (width === naturalWidth && height === naturalHeight) {
    return imageData;
  }

  ctx.canvas.height = height;
  ctx.canvas.width = width;

  ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);

  // image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight
  ctx.drawImage(imageData, 0, 0, naturalWidth, naturalHeight, 0, 0, width, height);

  return ctx.canvas;
}
1224514
function(options) {
        this.options = options || {};
        if (typeof this.options.getGeometry === 'function') {
            this.getGeometry = this.options.getGeometry;
        }
        this.setData(this.options.data);
    }
444976
function (inData, outData, width, height, options) {
        options = defaultOptions(options, {radius: 10});
        for (var i = 0; i < inData.length; i += 1) {
            outData[i] = inData[i];
        }
        stackblur(outData, width, height, options.radius);
    }
990394
function (oldData) {
    var data = this.data;
    var camera = this.camera;

    // Update properties.
    camera.aspect = data.aspect || (window.innerWidth / window.innerHeight);
    camera.far = data.far;
    camera.fov = data.fov;
    camera.near = data.near;
    camera.zoom = data.zoom;
    camera.updateProjectionMatrix();

    this.updateActiveCamera(oldData);
    this.updateSpectatorCamera(oldData);
  }
218504
function (event) {
            var point = this.getMousePoint(event);

            // Move dragged object
            if (typeof this._dragObject != 'undefined') {

                if (typeof this._dragObject == 'string') {
                    // Dragging handle
                    if (!this._image.detectionReady()) {
                        // Lock crop so that detection does not override users choice
                        this._crop.locked = true;
                    }

                    this._crop.dragHandle(
                        this._dragObject,
                        {
                            x: (point.x - this._dragPoint.x) / this._zoomLevel,
                            y: (point.y - this._dragPoint.y) / this._zoomLevel
                        }
                    );
                    this.updateImageInfo(true);
                }
                else {
                    if (this._dragObject instanceof IMSoftcrop.Image) {
                        this._keepCenter = false;
                    }

                    this._dragObject.move({
                            x: (point.x - this._dragPoint.x) / this._zoomLevel,
                            y: (point.y - this._dragPoint.y) / this._zoomLevel
                        }
                    );
                }

                this.updateImageInfo(true);
                this.redraw();
                this._dragPoint = point;
                return;
            }

            // Handle hover
            if (this._crop instanceof IMSoftcrop.Softcrop) {
                var handle = this._crop.overHandle(point);

                if (handle !== false && this.handle != handle) {
                    if (handle == 'nw' || handle == 'se') {
                        this._canvas.style.cursor = 'nwse-resize';
                    }
                    else if (handle == 'ne' || handle == 'sw') {
                        this._canvas.style.cursor = 'nesw-resize';
                    }
                    else if (handle == 'n' || handle == 's') {
                        this._canvas.style.cursor = 'ns-resize';
                    }
                    else {
                        this._canvas.style.cursor = 'ew-resize';
                    }

                    this.handle = handle;
                    return;
                }
                else if (handle === false && this.handle) {
                    this._canvas.style.cursor = 'default';
                    this.handle = undefined;
                    return;
                }
                else if (this.handle) {
                    return;
                }
            }

            // Reset hover
            if (this._image instanceof IMSoftcrop.Image && this._image.inArea(point)) {
                this._canvas.style.cursor = 'move';
                return;
            }

            this._canvas.style.cursor = 'default';
        }
126642
function transformData(data, config, done) {

  data.baseSize = config.baseSize;

  data.svgPath = config.svgPath.replace("%f", config.svg.sprite);
  data.pngPath = config.pngPath.replace("%f", config.svg.sprite.replace(/\.svg$/, ".png"));

  data.svg = data.svg.map(function(item) {

      item.relHeight = item.height / config.baseSize;
      item.relWidth  = item.width / config.baseSize;

      item.relPositionX = item.positionX / config.baseSize - config.padding / config.baseSize;
      item.relPositionY = item.positionY / config.baseSize - config.padding / config.baseSize;
      item.normal = true;

      if (item.name.match(/~/g)) {
        if (config.mode !== "sprite") {
          return false;
        } else {
          var segs  = item.name.split("~");
          item.name = item.selector[0].expression + ":" + segs[1];
          item.normal = false;
        }
      } else {
        item.name = item.selector[0].expression;
      }

      return item;
    });

  data.svg = data.svg.filter(function(item) { return item; });

  data.relWidth  = data.swidth / config.baseSize;
  data.relHeight = data.sheight / config.baseSize;

  if (config.asyncTransforms) {
    return done(data);
  }
  return data;
}
316796
function resize(newWidth, newHeight) {

        // Default size to zero
        newWidth = newWidth || 0;
        newHeight = newHeight || 0;

        // Calculate new dimensions of internal canvas
        var canvasWidth  = Math.ceil(newWidth  / CANVAS_SIZE_FACTOR) * CANVAS_SIZE_FACTOR;
        var canvasHeight = Math.ceil(newHeight / CANVAS_SIZE_FACTOR) * CANVAS_SIZE_FACTOR;

        // Resize only if canvas dimensions are actually changing
        if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {

            // Copy old data only if relevant and non-empty
            var oldData = null;
            if (!empty && canvas.width !== 0 && canvas.height !== 0) {

                // Create canvas and context for holding old data
                oldData = document.createElement("canvas");
                oldData.width = Math.min(layer.width, newWidth);
                oldData.height = Math.min(layer.height, newHeight);

                var oldDataContext = oldData.getContext("2d");

                // Copy image data from current
                oldDataContext.drawImage(canvas,
                        0, 0, oldData.width, oldData.height,
                        0, 0, oldData.width, oldData.height);

            }

            // Preserve composite operation
            var oldCompositeOperation = context.globalCompositeOperation;

            // Resize canvas
            canvas.width = canvasWidth;
            canvas.height = canvasHeight;

            // Redraw old data, if any
            if (oldData)
                context.drawImage(oldData,
                    0, 0, oldData.width, oldData.height,
                    0, 0, oldData.width, oldData.height);

            // Restore composite operation
            context.globalCompositeOperation = oldCompositeOperation;

            // Acknowledge reset of stack (happens on resize of canvas)
            stackSize = 0;
            context.save();

        }

        // If the canvas size is not changing, manually force state reset
        else
            layer.reset();

        // Assign new layer dimensions
        layer.width = newWidth;
        layer.height = newHeight;

    }
716137
function (data) {
    return this.fields.reduce(function (output, field) {
      var replacement = ''
      var placeholder = field.placeholder
      var width = field.width

      if (field.prefix) {
        output += field.prefix
      }
      if (placeholder) {
        replacement = data[placeholder] || ''
        if (width && (placeholder === 'hash' || placeholder === 'chunkhash')) {
          replacement = replacement.slice(0, width)
        }
        output += replacement
      }

      return output
    }, '')
  }