/*!
 * Cropper v3.0.0
 */
layui.define(['jquery'], function (exports) {
    var $ = layui.jquery;
    $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
    var DEFAULTS = {
        // Define the view mode of the cropper
        viewMode: 0, // 0, 1, 2, 3
        // Define the dragging mode of the cropper
        dragMode: 'crop', // 'crop', 'move' or 'none'
        // Define the aspect ratio of the crop box
        aspectRatio: NaN,
        // An object with the previous cropping result data
        data: null,
        // A selector for adding extra containers to preview
        preview: '',
        // Re-render the cropper when resize the window
        responsive: true,
        // Restore the cropped area after resize the window
        restore: true,
        // Check if the current image is a cross-origin image
        checkCrossOrigin: true,
        // Check the current image's Exif Orientation information
        checkOrientation: true,
        // Show the black modal
        modal: true,
        // Show the dashed lines for guiding
        guides: true,
        // Show the center indicator for guiding
        center: true,
        // Show the white modal to highlight the crop box
        highlight: true,
        // Show the grid background
        background: true,
        // Enable to crop the image automatically when initialize
        autoCrop: true,
        // Define the percentage of automatic cropping area when initializes
        autoCropArea: 0.8,
        // Enable to move the image
        movable: true,
        // Enable to rotate the image
        rotatable: true,
        // Enable to scale the image
        scalable: true,
        // Enable to zoom the image
        zoomable: true,
        // Enable to zoom the image by dragging touch
        zoomOnTouch: true,
        // Enable to zoom the image by wheeling mouse
        zoomOnWheel: true,
        // Define zoom ratio when zoom the image by wheeling mouse
        wheelZoomRatio: 0.1,
        // Enable to move the crop box
        cropBoxMovable: true,
        // Enable to resize the crop box
        cropBoxResizable: true,
        // Toggle drag mode between "crop" and "move" when click twice on the cropper
        toggleDragModeOnDblclick: true,
        // Size limitation
        minCanvasWidth: 0,
        minCanvasHeight: 0,
        minCropBoxWidth: 0,
        minCropBoxHeight: 0,
        minContainerWidth: 200,
        minContainerHeight: 100,
        // Shortcuts of events
        ready: null,
        cropstart: null,
        cropmove: null,
        cropend: null,
        crop: null,
        zoom: null
    };
    var TEMPLATE = '
' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '
 ';
    var REGEXP_DATA_URL_HEAD = /^data:.*,/;
    var REGEXP_USERAGENT = /(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i;
    var navigator = typeof window !== 'undefined' ? window.navigator : null;
    var IS_SAFARI_OR_UIWEBVIEW = navigator && REGEXP_USERAGENT.test(navigator.userAgent);
    var fromCharCode = String.fromCharCode;
    function isNumber(n) {
        return typeof n === 'number' && !isNaN(n);
    }
    function isUndefined(n) {
        return typeof n === 'undefined';
    }
    function toArray(obj, offset) {
        var args = [];
        // This is necessary for IE8
        if (isNumber(offset)) {
            args.push(offset);
        }
        return args.slice.apply(obj, args);
    }
    // Custom proxy to avoid jQuery's guid
    function proxy(fn, context) {
        for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
            args[_key - 2] = arguments[_key];
        }
        return function () {
            for (var _len2 = arguments.length, args2 = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
                args2[_key2] = arguments[_key2];
            }
            return fn.apply(context, args.concat(toArray(args2)));
        };
    }
    function objectKeys(obj) {
        var keys = [];
        $.each(obj, function (key) {
            keys.push(key);
        });
        return keys;
    }
    function isCrossOriginURL(url) {
        var parts = url.match(/^(https?:)\/\/([^:/?#]+):?(\d*)/i);
        return parts && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port);
    }
    function addTimestamp(url) {
        var timestamp = 'timestamp=' + new Date().getTime();
        return url + (url.indexOf('?') === -1 ? '?' : '&') + timestamp;
    }
    function getImageSize(image, callback) {
        // Modern browsers (ignore Safari, #120 & #509)
        if (image.naturalWidth && !IS_SAFARI_OR_UIWEBVIEW) {
            callback(image.naturalWidth, image.naturalHeight);
            return;
        }
        // IE8: Don't use `new Image()` here (#319)
        var newImage = document.createElement('img');
        newImage.onload = function load() {
            callback(this.width, this.height);
        };
        newImage.src = image.src;
    }
    function getTransform(options) {
        var transforms = [];
        var translateX = options.translateX;
        var translateY = options.translateY;
        var rotate = options.rotate;
        var scaleX = options.scaleX;
        var scaleY = options.scaleY;
        if (isNumber(translateX) && translateX !== 0) {
            transforms.push('translateX(' + translateX + 'px)');
        }
        if (isNumber(translateY) && translateY !== 0) {
            transforms.push('translateY(' + translateY + 'px)');
        }
        // Rotate should come first before scale to match orientation transform
        if (isNumber(rotate) && rotate !== 0) {
            transforms.push('rotate(' + rotate + 'deg)');
        }
        if (isNumber(scaleX) && scaleX !== 1) {
            transforms.push('scaleX(' + scaleX + ')');
        }
        if (isNumber(scaleY) && scaleY !== 1) {
            transforms.push('scaleY(' + scaleY + ')');
        }
        return transforms.length ? transforms.join(' ') : 'none';
    }
    function getRotatedSizes(data, isReversed) {
        var deg = Math.abs(data.degree) % 180;
        var arc = (deg > 90 ? 180 - deg : deg) * Math.PI / 180;
        var sinArc = Math.sin(arc);
        var cosArc = Math.cos(arc);
        var width = data.width;
        var height = data.height;
        var aspectRatio = data.aspectRatio;
        var newWidth = void 0;
        var newHeight = void 0;
        if (!isReversed) {
            newWidth = width * cosArc + height * sinArc;
            newHeight = width * sinArc + height * cosArc;
        } else {
            newWidth = width / (cosArc + sinArc / aspectRatio);
            newHeight = newWidth / aspectRatio;
        }
        return {
            width: newWidth,
            height: newHeight
        };
    }
    function getSourceCanvas(image, data, options) {
        var canvas = $('