- md5
- cfd7120d0fa2f63f8ba2adcc31f85830
- sha1
- 4b693ba1dfa8d9ea4d23297a4d453a10a8123a81
- sha256
- 6eae65e55d4e2c7b19f57b16b25ad8a742feb7895f52b3c4757f836cd8912732
/*!
* Cropper.js v1.1.3
* https://github.com/fengyuanchen/cropperjs
*
* Copyright (c) 2015-2017 Chen Fengyuan
* Released under the MIT license
*
* Date: 2017-10-21T09:27:36.848Z
*/
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.Cropper=i()}(this,function(){"use strict";function t(t){if(Array.isArray(t)){for(var i=0,e=Array(t.length);i<t.length;i++)e[i]=t[i];return e}return Array.from(t)}function i(t){return"number"==typeof t&&!J(t)}function e(t){return void 0===t}function a(t){return"object"===(void 0===t?"undefined":G(t))&&null!==t}function n(t){if(!a(t))return!1;try{var i=t.constructor,e=i.prototype;return i&&e&&_.call(e,"isPrototypeOf")}catch(t){return!1}}function o(t){return"function"==typeof t}function r(t,e){if(t&&o(e))if(Array.isArray(t)||i(t.length)){var n=t.length,r=void 0;for(r=0;r<n&&!1!==e.call(t,t[r],r,t);r+=1);}else a(t)&&Object.keys(t).forEach(function(i){e.call(t,t[i],i,t)});return t}function h(t){for(var i=arguments.length,e=Array(i>1?i-1:0),n=1;n<i;n++)e[n-1]=arguments[n];if(a(t)&&e.length>0){if(Object.assign)return Object.assign.apply(Object,[t].concat(e));e.forEach(function(i){a(i)&&Object.keys(i).forEach(function(e){t[e]=i[e]})})}return t}function s(t,i){for(var e=arguments.length,a=Array(e>2?e-2:0),n=2;n<e;n++)a[n-2]=arguments[n];return function(){for(var e=arguments.length,n=Array(e),o=0;o<e;o++)n[o]=arguments[o];return t.apply(i,a.concat(n))}}function c(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return tt.test(t)?Math.round(t*i)/i:t}function l(t,e){var a=t.style;r(e,function(t,e){it.test(e)&&i(t)&&(t+="px"),a[e]=t})}function d(t,i){return t.classList?t.classList.contains(i):t.className.indexOf(i)>-1}function p(t,e){if(e)if(i(t.length))r(t,function(t){p(t,e)});else if(t.classList)t.classList.add(e);else{var a=t.className.trim();a?a.indexOf(e)<0&&(t.className=a+" "+e):t.className=e}}function m(t,e){e&&(i(t.length)?r(t,function(t){m(t,e)}):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function u(t,e,a){e&&(i(t.length)?r(t,function(t){u(t,e,a)}):a?p(t,e):m(t,e))}function g(t){return t.replace(et,"$1-$2").toLowerCase()}function f(t,i){return a(t[i])?t[i]:t.dataset?t.dataset[i]:t.getAttribute("data-"+g(i))}function v(t,i,e){a(e)?t[i]=e:t.dataset?t.dataset[i]=e:t.setAttribute("data-"+g(i),e)}function w(t,i){if(a(t[i]))delete t[i];else if(t.dataset)try{delete t.dataset[i]}catch(e){t.dataset[i]=null}else t.removeAttribute("data-"+g(i))}function b(t,i,e){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(o(e)){var n=i.trim().split(at);n.length>1?r(n,function(i){b(t,i,e)}):(o(e.onceListener)&&delete(e=e.onceListener).onceListener,t.removeEventListener?t.removeEventListener(i,e,a):t.detachEvent&&t.detachEvent("on"+i,e))}}function x(t,i,e){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(o(e)){var n=i.trim().split(at);if(n.length>1)r(n,function(i){x(t,i,e)});else{if(a.once){var h=e,s=function e(){for(var a=arguments.length,n=Array(a),o=0;o<a;o++)n[o]=arguments[o];return b(t,i,e),h.apply(t,n)};h.onceListener=s,e=s}t.addEventListener?t.addEventListener(i,e,a):t.attachEvent&&t.attachEvent("on"+i,e)}}}function y(t,i,a){if(t.dispatchEvent){var n=void 0;return o(Event)&&o(CustomEvent)?n=e(a)?new Event(i,{bubbles:!0,cancelable:!0}):new CustomEvent(i,{detail:a,bubbles:!0,cancelable:!0}):e(a)?(n=document.createEvent("Event")).initEvent(i,!0,!0):(n=document.createEvent("CustomEvent")).initCustomEvent(i,!0,!0,a),t.dispatchEvent(n)}return!t.fireEvent||t.fireEvent("on"+i)}function M(t){var i=document.documentElement,e=t.getBoundingClientRect();return{left:e.left+((window.scrollX||i&&i.scrollLeft||0)-(i&&i.clientLeft||0)),top:e.top+((window.scrollY||i&&i.scrollTop||0)-(i&&i.clientTop||0))}}function C(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function D(t){var i=t.match(ot);return i&&(i[1]!==nt.protocol||i[2]!==nt.hostname||i[3]!==nt.port)}function B(t){var i="timestamp="+(new Date).getTime();return t+(-1===t.indexOf("?")?"?":"&")+i}function k(t){var e=t.rotate,a=t.scaleX,n=t.scaleY,o=t.translateX,r=t.translateY,h=[];i(o)&&0!==o&&h.push("translateX("+o+"px)"),i(r)&&0!==r&&h.push("translateY("+r+"px)"),i(e)&&0!==e&&h.push("rotate("+e+"deg)"),i(a)&&1!==a&&h.push("scaleX("+a+")"),i(n)&&1!==n&&h.push("scaleY("+n+")");var s=h.length?h.join(" "):"none";return{WebkitTransform:s,msTransform:s,transform:s}}function E(t,i){if(!t.naturalWidth||ht){var e=document.createElement("img");e.onload=function(){i(e.width,e.height)},e.src=t.src}else i(t.naturalWidth,t.naturalHeight)}function T(t){var i=h({},t),e=[];return r(t,function(t,a){delete i[a],r(i,function(i){var a=Math.abs(t.startX-i.startX),n=Math.abs(t.startY-i.startY),o=Math.abs(t.endX-i.endX),r=Math.abs(t.endY-i.endY),h=Math.sqrt(a*a+n*n),s=(Math.sqrt(o*o+r*r)-h)/h;e.push(s)})}),e.sort(function(t,i){return Math.abs(t)<Math.abs(i)}),e[0]}function W(t,i){var e=t.pageX,a=t.pageY,n={endX:e,endY:a};return i?n:h({startX:e,startY:a},n)}function N(t){var i=0,e=0,a=0;return r(t,function(t){var n=t.startX,o=t.startY;i+=n,e+=o,a+=1}),i/=a,e/=a,{pageX:i,pageY:e}}function H(t){var i=t.aspectRatio,e=t.height,a=t.width,n=function(t){return st(t)&&t>0};return n(a)&&n(e)?e*i>a?e=a/i:a=e*i:n(a)?e=a/i:n(e)&&(a=e*i),{width:a,height:e}}function L(t){var i=t.width,e=t.height,a=t.degree;if((a=Math.abs(a))%180==90)return{width:e,height:i};var n=a%90*Math.PI/180,o=Math.sin(n),r=Math.cos(n);return{width:i*r+e*o,height:i*o+e*r}}function Y(i,e,a,n){var o=e.naturalWidth,r=e.naturalHeight,h=e.rotate,s=void 0===h?0:h,l=e.scaleX,d=void 0===l?1:l,p=e.scaleY,m=void 0===p?1:p,u=a.aspectRatio,g=a.naturalWidth,f=a.naturalHeight,v=n.fillColor,w=void 0===v?"transparent":v,b=n.imageSmoothingEnabled,x=void 0===b||b,y=n.imageSmoothingQuality,M=void 0===y?"low":y,C=n.maxWidth,D=void 0===C?1/0:C,B=n.maxHeight,k=void 0===B?1/0:B,E=n.minWidth,T=void 0===E?0:E,W=n.minHeight,N=void 0===W?0:W,L=document.createElement("canvas"),Y=L.getContext("2d"),X=H({aspectRatio:u,width:D,height:k}),O=H({aspectRatio:u,width:T,height:N}),S=Math.min(X.width,Math.max(O.width,g)),z=Math.min(X.height,Math.max(O.height,f)),R=[-o/2,-r/2,o,r];return L.width=c(S),L.height=c(z),Y.fillStyle=w,Y.fillRect(0,0,S,z),Y.save(),Y.translate(S/2,z/2),Y.rotate(s*Math.PI/180),Y.scale(d,m),Y.imageSmoothingEnabled=x,Y.imageSmoothingQuality=M,Y.drawImage.apply(Y,[i].concat(t(R.map(function(t){return Math.floor(c(t))})))),Y.restore(),L}function X(t,i,e){var a="",n=void 0;for(e+=i,n=i;n<e;n+=1)a+=ct(t.getUint8(n));return a}function O(t){var i=t.replace(lt,""),e=atob(i),a=new ArrayBuffer(e.length),n=new Uint8Array(a);return r(n,function(t,i){n[i]=e.charCodeAt(i)}),a}function S(t,i){var e="";return r(new Uint8Array(t),function(t){e+=ct(t)}),"data:"+i+";base64,"+btoa(e)}function z(t){var i=new DataView(t),e=void 0,a=void 0,n=void 0,o=void 0;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var r=i.byteLength,h=2;h<r;){if(255===i.getUint8(h)&&225===i.getUint8(h+1)){n=h;break}h+=1}if(n){var s=n+10;if("Exif"===X(i,n+4,4)){var c=i.getUint16(s);if(((a=18761===c)||19789===c)&&42===i.getUint16(s+2,a)){var l=i.getUint32(s+4,a);l>=8&&(o=s+l)}}}if(o){var d=i.getUint16(o,a),p=void 0,m=void 0;for(m=0;m<d;m+=1)if(p=o+12*m+2,274===i.getUint16(p,a)){p+=8,e=i.getUint16(p,a),i.setUint16(p,1,a);break}}return e}function R(t){var i=0,e=1,a=1;switch(t){case 2:e=-1;break;case 3:i=-180;break;case 4:a=-1;break;case 5:i=90,a=-1;break;case 6:i=90;break;case 7:i=90,e=-1;break;case 8:i=-90}return{rotate:i,scaleX:e,scaleY:a}}function A(t){if(Array.isArray(t)){for(var i=0,e=Array(t.length);i<t.length;i++)e[i]=t[i];return e}return Array.from(t)}function I(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}var U="undefined"!=typeof window?window:{},j="cropper-hidden",P=U.PointerEvent?"pointerdown":"touchstart mousedown",q=U.PointerEvent?"pointermove":"touchmove mousemove",$=U.PointerEvent?" pointerup pointercancel":"touchend touchcancel mouseup",Q=/^(e|w|s|n|se|sw|ne|nw|all|crop|move|zoom)$/,Z=/^data:/,F=/^data:image\/jpeg;base64,/,K=/^(img|canvas)$/i,V={viewMode:0,dragMode:"crop",aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},G="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},J=Number.isNaN||U.isNaN,_=Object.prototype.hasOwnProperty,tt=/\.\d*(?:0|9){12}\d*$/i,it=/^(width|height|left|top|marginLeft|marginTop)$/,et=/([a-z\d])([A-Z])/g,at=/\s+/,nt=U.location,ot=/^(https?:)\/\/([^:/?#]+):?(\d*)/i,rt=U.navigator,ht=rt&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(rt.userAgent),st=Number.isFinite||U.isFinite,ct=String.fromCharCode,lt=/^data:.*,/,dt={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,i=this.options,e=this.container,a=this.cropper;p(a,j),m(t,j);var n={width:Math.max(e.offsetWidth,Number(i.minContainerWidth)||200),height:Math.max(e.offsetHeight,Number(i.minContainerHeight)||100)};this.containerData=n,l(a,{width:n.width,height:n.height}),p(t,j),m(a,j)},initCanvas:function(){var t=this.containerData,i=this.imageData,e=this.options.viewMode,a=Math.abs(i.rotate)%180==90,n=a?i.naturalHeight:i.naturalWidth,o=a?i.naturalWidth:i.naturalHeight,r=n/o,s=t.width,c=t.height;t.height*r>t.width?3===e?s=t.height*r:c=t.width/r:3===e?c=t.width/r:s=t.height*r;var l={aspectRatio:r,naturalWidth:n,naturalHeight:o,width:s,height:c};l.left=(t.width-s)/2,l.top=(t.height-c)/2,l.oldLeft=l.left,l.oldTop=l.top,this.canvasData=l,this.limited=1===e||2===e,this.limitCanvas(!0,!0),this.initialImageData=h({},i),this.initialCanvasData=h({},l)},limitCanvas:function(t,i){var e=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=e.viewMode,h=n.aspectRatio,s=this.cropped&&o;if(t){var c=Number(e.minCanvasWidth)||0,l=Number(e.minCanvasHeight)||0;r>1?(c=Math.max(c,a.width),l=Math.max(l,a.height),3===r&&(l*h>c?c=l*h:l=c/h)):r>0&&(c?c=Math.max(c,s?o.width:0):l?l=Math.max(l,s?o.height:0):s&&(c=o.width,(l=o.height)*h>c?c=l*h:l=c/h));var d=H({aspectRatio:h,width:c,height:l});c=d.width,l=d.height,n.minWidth=c,n.minHeight=l,n.maxWidth=1/0,n.maxHeight=1/0}if(i)if(r){var p=a.width-n.width,m=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,m),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,m),s&&this.limited&&(n.minLeft=Math.min(o.left,o.left+(o.width-n.width)),n.minTop=Math.min(o.top,o.top+(o.height-n.height)),n.maxLeft=o.left,n.maxTop=o.top,2===r&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,m),n.maxTop=Math.max(0,m))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,i){var e=this.canvasData,a=this.imageData;if(i){var n=L({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,r=n.height,s=e.width*(o/e.naturalWidth),c=e.height*(r/e.naturalHeight);e.left-=(s-e.width)/2,e.top-=(c-e.height)/2,e.width=s,e.height=c,e.aspectRatio=o/r,e.naturalWidth=o,e.naturalHeight=r,this.limitCanvas(!0,!1)}(e.width>e.maxWidth||e.width<e.minWidth)&&(e.left=e.oldLeft),(e.height>e.maxHeight||e.height<e.minHeight)&&(e.top=e.oldTop),e.width=Math.min(Math.max(e.width,e.minWidth),e.maxWidth),e.height=Math.min(Math.max(e.height,e.minHeight),e.maxHeight),this.limitCanvas(!1,!0),e.left=Math.min(Math.max(e.left,e.minLeft),e.maxLeft),e.top=Math.min(Math.max(e.top,e.minTop),e.maxTop),e.oldLeft=e.left,e.oldTop=e.top,l(this.canvas,h({width:e.width,height:e.height},k({translateX:e.left,translateY:e.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var i=this.canvasData,e=this.imageData,a=e.naturalWidth*(i.width/i.naturalWidth),n=e.naturalHeight*(i.height/i.naturalHeight);h(e,{width:a,height:n,left:(i.width-a)/2,top:(i.height-n)/2}),l(this.image,h({width:e.width,height:e.height},k(h({translateX:e.left,translateY:e.top},e)))),t&&this.output()},initCropBox:function(){var t=this.options,i=this.canvasData,e=t.aspectRatio,a=Number(t.autoCropArea)||.8,n={width:i.width,height:i.height};e&&(i.height*e>i.width?n.height=n.width/e:n.width=n.height*e),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=i.left+(i.width-n.width)/2,n.top=i.top+(i.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=h({},n)},limitCropBox:function(t,i){var e=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=this.limited,h=e.aspectRatio;if(t){var s=Number(e.minCropBoxWidth)||0,c=Number(e.minCropBoxHeight)||0,l=Math.min(a.width,r?n.width:a.width),d=Math.min(a.height,r?n.height:a.height);s=Math.min(s,a.width),c=Math.min(c,a.height),h&&(s&&c?c*h>s?c=s/h:s=c*h:s?c=s/h:c&&(s=c*h),d*h>l?d=l/h:l=d*h),o.minWidth=Math.min(s,l),o.minHeight=Math.min(c,d),o.maxWidth=l,o.maxHeight=d}i&&(r?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function(){var t=this.options,i=this.containerData,e=this.cropBoxData;(e.width>e.maxWidth||e.width<e.minWidth)&&(e.left=e.oldLeft),(e.height>e.maxHeight||e.height<e.minHeight)&&(e.top=e.oldTop),e.width=Math.min(Math.max(e.width,e.minWidth),e.maxWidth),e.height=Math.min(Math.max(e.height,e.minHeight),e.maxHeight),this.limitCropBox(!1,!0),e.left=Math.min(Math.max(e.left,e.minLeft),e.maxLeft),e.top=Math.min(Math.max(e.top,e.minTop),e.maxTop),e.oldLeft=e.left,e.oldTop=e.top,t.movable&&t.cropBoxMovable&&v(this.face,"action",e.width>=i.width&&e.height>=i.height?"move":"all"),l(this.cropBox,h({width:e.width,height:e.height},k({translateX:e.left,translateY:e.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),this.complete&&y(this.element,"crop",this.getData())}},pt={initPreview:function(){var t=this.crossOrigin,i=this.options.preview,e=t?this.crossOriginUrl:this.url,a=document.createElement("img");if(t&&(a.crossOrigin=t),a.src=e,this.viewBox.appendChild(a),this.image2=a,i){var n=i.querySelector?[i]:document.querySelectorAll(i);this.previews=n,r(n,function(i){var a=document.createElement("img");v(i,"preview",{width:i.offsetWidth,height:i.offsetHeight,html:i.innerHTML}),t&&(a.crossOrigin=t),a.src=e,a.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',C(i),i.appendChild(a)})}},resetPreview:function(){r(this.previews,function(t){var i=f(t,"preview");l(t,{width:i.width,height:i.height}),t.innerHTML=i.html,w(t,"preview")})},preview:function(){var t=this.imageData,i=this.canvasData,e=this.cropBoxData,a=e.width,n=e.height,o=t.width,s=t.height,c=e.left-i.left-t.left,d=e.top-i.top-t.top;this.cropped&&!this.disabled&&(l(this.image2,h({width:o,height:s},k(h({translateX:-c,translateY:-d},t)))),r(this.previews,function(i){var e=f(i,"preview"),r=e.width,p=e.height,m=r,u=p,g=1;a&&(u=n*(g=r/a)),n&&u>p&&(m=a*(g=p/n),u=p),l(i,{width:m,height:u}),l(i.getElementsByTagName("img")[0],h({width:o*g,height:s*g},k(h({translateX:-c*g,translateY:-d*g},t))))}))}},mt={bind:function(){var t=this.element,i=this.options,e=this.cropper;o(i.cropstart)&&x(t,"cropstart",i.cropstart),o(i.cropmove)&&x(t,"cropmove",i.cropmove),o(i.cropend)&&x(t,"cropend",i.cropend),o(i.crop)&&x(t,"crop",i.crop),o(i.zoom)&&x(t,"zoom",i.zoom),x(e,P,this.onCropStart=s(this.cropStart,this)),i.zoomable&&i.zoomOnWheel&&x(e,"wheel mousewheel DOMMouseScroll",this.onWheel=s(this.wheel,this)),i.toggleDragModeOnDblclick&&x(e,"dblclick",this.onDblclick=s(this.dblclick,this)),x(document,q,this.onCropMove=s(this.cropMove,this)),x(document,$,this.onCropEnd=s(this.cropEnd,this)),i.responsive&&x(window,"resize",this.onResize=s(this.resize,this))},unbind:function(){var t=this.element,i=this.options,e=this.cropper;o(i.cropstart)&&b(t,"cropstart",i.cropstart),o(i.cropmove)&&b(t,"cropmove",i.cropmove),o(i.cropend)&&b(t,"cropend",i.cropend),o(i.crop)&&b(t,"crop",i.crop),o(i.zoom)&&b(t,"zoom",i.zoom),b(e,P,this.onCropStart),i.zoomable&&i.zoomOnWheel&&b(e,"wheel mousewheel DOMMouseScroll",this.onWheel),i.toggleDragModeOnDblclick&&b(e,"dblclick",this.onDblclick),b(document,q,this.onCropMove),b(document,$,this.onCropEnd),i.responsive&&b(window,"resize",this.onResize)}},ut={resize:function(){var t=this.options,i=this.container,e=this.containerData,a=Number(t.minContainerWidth)||200,n=Number(t.minContainerHeight)||100;if(!(this.disabled||e.width<=a||e.height<=n)){var o=i.offsetWidth/e.width;if(1!==o||i.offsetHeight!==e.height){var h=void 0,s=void 0;t.restore&&(h=this.getCanvasData(),s=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(r(h,function(t,i){h[i]=t*o})),this.setCropBoxData(r(s,function(t,i){s[i]=t*o})))}}},dblclick:function(){this.disabled||"none"===this.options.dragMode||this.setDragMode(d(this.dragBox,"cropper-crop")?"move":"crop")},wheel:function(t){var i=this,e=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){i.wheeling=!1},50),t.deltaY?a=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*e,t)))},cropStart:function(t){if(!this.disabled){var i=this.options,e=this.pointers,a=void 0;t.changedTouches?r(t.changedTouches,function(t){e[t.identifier]=W(t)}):e[t.pointerId||0]=W(t),a=Object.keys(e).length>1&&i.zoomable&&i.zoomOnTouch?"zoom":f(t.target,"action"),Q.test(a)&&!1!==y(this.element,"cropstart",{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,"crop"===a&&(this.cropping=!0,p(this.dragBox,"cropper-modal")))}},cropMove:function(t){var i=this.action;if(!this.disabled&&i){var e=this.pointers;t.preventDefault(),!1!==y(this.element,"cropmove",{originalEvent:t,action:i})&&(t.changedTouches?r(t.changedTouches,function(t){h(e[t.identifier],W(t,!0))}):h(e[t.pointerId||0],W(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var i=this.action,e=this.pointers;t.changedTouches?r(t.changedTouches,function(t){delete e[t.identifier]}):delete e[t.pointerId||0],i&&(t.preventDefault(),Object.keys(e).length||(this.action=""),this.cropping&&(this.cropping=!1,u(this.dragBox,"cropper-modal",this.cropped&&this.options.modal)),y(this.element,"cropend",{originalEvent:t,action:i}))}}},gt={change:function(t){var i=this.options,e=this.canvasData,a=this.containerData,n=this.cropBoxData,o=this.pointers,h=this.action,s=i.aspectRatio,c=n.left,l=n.top,d=n.width,p=n.height,u=c+d,g=l+p,f=0,v=0,w=a.width,b=a.height,x=!0,y=void 0;!s&&t.shiftKey&&(s=d&&p?d/p:1),this.limited&&(f=n.minLeft,v=n.minTop,w=f+Math.min(a.width,e.width,e.left+e.width),b=v+Math.min(a.height,e.height,e.top+e.height));var C=o[Object.keys(o)[0]],D={x:C.endX-C.startX,y:C.endY-C.startY},B=function(t){switch(t){case"e":u+D.x>w&&(D.x=w-u);break;case"w":c+D.x<f&&(D.x=f-c);break;case"n":l+D.y<v&&(D.y=v-l);break;case"s":g+D.y>b&&(D.y=b-g)}};switch(h){case"all":c+=D.x,l+=D.y;break;case"e":if(D.x>=0&&(u>=w||s&&(l<=v||g>=b))){x=!1;break}B("e"),d+=D.x,s&&(p=d/s,l-=D.x/s/2),d<0&&(h="w",d=0);break;case"n":if(D.y<=0&&(l<=v||s&&(c<=f||u>=w))){x=!1;break}B("n"),p-=D.y,l+=D.y,s&&(d=p*s,c+=D.y*s/2),p<0&&(h="s",p=0);break;case"w":if(D.x<=0&&(c<=f||s&&(l<=v||g>=b))){x=!1;break}B("w"),d-=D.x,c+=D.x,s&&(p=d/s,l+=D.x/s/2),d<0&&(h="e",d=0);break;case"s":if(D.y>=0&&(g>=b||s&&(c<=f||u>=w))){x=!1;break}B("s"),p+=D.y,s&&(d=p*s,c-=D.y*s/2),p<0&&(h="n",p=0);break;case"ne":if(s){if(D.y<=0&&(l<=v||u>=w)){x=!1;break}B("n"),p-=D.y,l+=D.y,d=p*s}else B("n"),B("e"),D.x>=0?u<w?d+=D.x:D.y<=0&&l<=v&&(x=!1):d+=D.x,D.y<=0?l>v&&(p-=D.y,l+=D.y):(p-=D.y,l+=D.y);d<0&&p<0?(h="sw",p=0,d=0):d<0?(h="nw",d=0):p<0&&(h="se",p=0);break;case"nw":if(s){if(D.y<=0&&(l<=v||c<=f)){x=!1;break}B("n"),p-=D.y,l+=D.y,d=p*s,c+=D.y*s}else B("n"),B("w"),D.x<=0?c>f?(d-=D.x,c+=D.x):D.y<=0&&l<=v&&(x=!1):(d-=D.x,c+=D.x),D.y<=0?l>v&&(p-=D.y,l+=D.y):(p-=D.y,l+=D.y);d<0&&p<0?(h="se",p=0,d=0):d<0?(h="ne",d=0):p<0&&(h="sw",p=0);break;case"sw":if(s){if(D.x<=0&&(c<=f||g>=b)){x=!1;break}B("w"),d-=D.x,c+=D.x,p=d/s}else B("s"),B("w"),D.x<=0?c>f?(d-=D.x,c+=D.x):D.y>=0&&g>=b&&(x=!1):(d-=D.x,c+=D.x),D.y>=0?g<b&&(p+=D.y):p+=D.y;d<0&&p<0?(h="ne",p=0,d=0):d<0?(h="se",d=0):p<0&&(h="nw",p=0);break;case"se":if(s){if(D.x>=0&&(u>=w||g>=b)){x=!1;break}B("e"),p=(d+=D.x)/s}else B("s"),B("e"),D.x>=0?u<w?d+=D.x:D.y>=0&&g>=b&&(x=!1):d+=D.x,D.y>=0?g<b&&(p+=D.y):p+=D.y;d<0&&p<0?(h="nw",p=0,d=0):d<0?(h="sw",d=0):p<0&&(h="ne",p=0);break;case"move":this.move(D.x,D.y),x=!1;break;case"zoom":this.zoom(T(o),t),x=!1;break;case"crop":if(!D.x||!D.y){x=!1;break}y=M(this.cropper),c=C.startX-y.left,l=C.startY-y.top,d=n.minWidth,p=n.minHeight,D.x>0?h=D.y>0?"se":"ne":D.x<0&&(c-=d,h=D.y>0?"sw":"nw"),D.y<0&&(l-=p),this.cropped||(m(this.cropBox,j),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}x&&(n.width=d,n.height=p,n.left=c,n.top=l,this.action=h,this.renderCropBox()),r(o,function(t){t.startX=t.endX,t.startY=t.endY})}},ft={crop:function(){return this.ready&&!this.disabled&&(this.cropped||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&p(this.dragBox,"cropper-modal"),m(this.cropBox,j)),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=h({},this.initialImageData),this.canvasData=h({},this.initialCanvasData),this.cropBoxData=h({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(h(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),m(this.dragBox,"cropper-modal"),p(this.cropBox,j)),this},replace:function(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),i?(this.url=t,this.image.src=t,this.ready&&(this.image2.src=t,r(this.previews,function(i){i.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.load(t))),this},enable:function(){return this.ready&&(this.disabled=!1,m(this.cropper,"cropper-disabled")),this},disable:function(){return this.ready&&(this.disabled=!0,p(this.cropper,"cropper-disabled")),this},destroy:function(){var t=this.element,i=this.image;return this.loaded?(this.isImg&&this.replaced&&(t.src=this.originalUrl),this.unbuild(),m(t,j)):this.isImg?b(t,"load",this.onStart):i&&i.parentNode.removeChild(i),w(t,"cropper"),this},move:function(t,i){var a=this.canvasData,n=a.left,o=a.top;return this.moveTo(e(t)?t:n+Number(t),e(i)?i:o+Number(i))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,a=this.canvasData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(i(t)&&(a.left=t,n=!0),i(e)&&(a.top=e,n=!0),n&&this.renderCanvas(!0)),this},zoom:function(t,i){var e=this.canvasData;return t=Number(t),t=t<0?1/(1-t):1+t,this.zoomTo(e.width*t/e.naturalWidth,i)},zoomTo:function(t,i){var e=this.options,a=this.canvasData,n=a.width,o=a.height,r=a.naturalWidth,h=a.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&e.zoomable){var s=r*t,c=h*t;if(!1===y(this.element,"zoom",{originalEvent:i,oldRatio:n/r,ratio:s/r}))return this;if(i){var l=this.pointers,d=M(this.cropper),p=l&&Object.keys(l).length?N(l):{pageX:i.pageX,pageY:i.pageY};a.left-=(s-n)*((p.pageX-d.left-a.left)/n),a.top-=(c-o)*((p.pageY-d.top-a.top)/o)}else a.left-=(s-n)/2,a.top-=(c-o)/2;a.width=s,a.height=c,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return t=Number(t),i(t)&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,i(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(i(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,a=this.imageData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(i(t)&&(a.scaleX=t,n=!0),i(e)&&(a.scaleY=e,n=!0),n&&this.renderCanvas(!0,!0)),this},getData:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,e=this.imageData,a=this.canvasData,n=this.cropBoxData,o=void 0;if(this.ready&&this.cropped){o={x:n.left-a.left,y:n.top-a.top,width:n.width,height:n.height};var h=e.width/e.naturalWidth;r(o,function(i,e){i/=h,o[e]=t?Math.round(i):i})}else o={x:0,y:0,width:0,height:0};return i.rotatable&&(o.rotate=e.rotate||0),i.scalable&&(o.scaleX=e.scaleX||1,o.scaleY=e.scaleY||1),o},setData:function(t){var e=this.options,a=this.imageData,r=this.canvasData,h={};if(o(t)&&(t=t.call(this.element)),this.ready&&!this.disabled&&n(t)){var s=!1;e.rotatable&&i(t.rotate)&&t.rotate!==a.rotate&&(a.rotate=t.rotate,s=!0),e.scalable&&(i(t.scaleX)&&t.scaleX!==a.scaleX&&(a.scaleX=t.scaleX,s=!0),i(t.scaleY)&&t.scaleY!==a.scaleY&&(a.scaleY=t.scaleY,s=!0)),s&&this.renderCanvas(!0,!0);var c=a.width/a.naturalWidth;i(t.x)&&(h.left=t.x*c+r.left),i(t.y)&&(h.top=t.y*c+r.top),i(t.width)&&(h.width=t.width*c),i(t.height)&&(h.height=t.height*c),this.setCropBoxData(h)}return this},getContainerData:function(){return this.ready?h({},this.containerData):{}},getImageData:function(){return this.loaded?h({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,i={};return this.ready&&r(["left","top","width","height","naturalWidth","naturalHeight"],function(e){i[e]=t[e]}),i},setCanvasData:function(t){var e=this.canvasData,a=e.aspectRatio;return o(t)&&(t=t.call(this.element)),this.ready&&!this.disabled&&n(t)&&(i(t.left)&&(e.left=t.left),i(t.top)&&(e.top=t.top),i(t.width)?(e.width=t.width,e.height=t.width/a):i(t.height)&&(e.height=t.height,e.width=t.height*a),this.renderCanvas(!0)),this},getCropBoxData:function(){var t=this.cropBoxData,i=void 0;return this.ready&&this.cropped&&(i={left:t.left,top:t.top,width:t.width,height:t.height}),i||{}},setCropBoxData:function(t){var e=this.cropBoxData,a=this.options.aspectRatio,r=void 0,h=void 0;return o(t)&&(t=t.call(this.element)),this.ready&&this.cropped&&!this.disabled&&n(t)&&(i(t.left)&&(e.left=t.left),i(t.top)&&(e.top=t.top),i(t.width)&&t.width!==e.width&&(r=!0,e.width=t.width),i(t.height)&&t.height!==e.height&&(h=!0,e.height=t.height),a&&(r?e.height=e.width/a:h&&(e.width=e.height*a)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var i=this.canvasData,e=Y(this.image,this.imageData,i,t);if(!this.cropped)return e;var a=this.getData(),n=a.x,o=a.y,r=a.width,h=a.height,s=r/h,l=H({aspectRatio:s,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),d=H({aspectRatio:s,width:t.minWidth||0,height:t.minHeight||0}),p=H({aspectRatio:s,width:t.width||r,height:t.height||h}),m=p.width,u=p.height;m=Math.min(l.width,Math.max(d.width,m)),u=Math.min(l.height,Math.max(d.height,u));var g=document.createElement("canvas"),f=g.getContext("2d");g.width=c(m),g.height=c(u),f.fillStyle=t.fillColor||"transparent",f.fillRect(0,0,m,u);var v=t.imageSmoothingEnabled,w=void 0===v||v,b=t.imageSmoothingQuality;f.imageSmoothingEnabled=w,b&&(f.imageSmoothingQuality=b);var x=e.width,y=e.height,M=n,C=o,D=void 0,B=void 0,k=void 0,E=void 0,T=void 0,W=void 0;M<=-r||M>x?(M=0,D=0,k=0,T=0):M<=0?(k=-M,M=0,T=D=Math.min(x,r+M)):M<=x&&(k=0,T=D=Math.min(r,x-M)),D<=0||C<=-h||C>y?(C=0,B=0,E=0,W=0):C<=0?(E=-C,C=0,W=B=Math.min(y,h+C)):C<=y&&(E=0,W=B=Math.min(h,y-C));var N=[M,C,D,B];if(T>0&&W>0){var L=m/r;N.push(k*L,E*L,T*L,W*L)}return f.drawImage.apply(f,[e].concat(A(N.map(function(t){return Math.floor(c(t))})))),g},setAspectRatio:function(t){var i=this.options;return this.disabled||e(t)||(i.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var i=this.options,e=this.dragBox,a=this.face;if(this.loaded&&!this.disabled){var n="crop"===t,o=i.movable&&"move"===t;v(e,"action",t=n||o?t:"none"),u(e,"cropper-crop",n),u(e,"cropper-move",o),i.cropBoxMovable||(v(a,"action",t),u(a,"cropper-crop",n),u(a,"cropper-move",o))}return this}},vt=function(){function t(t,i){for(var e=0;e<i.length;e++){var a=i[e];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}return function(i,e,a){return e&&t(i.prototype,e),a&&t(i,a),i}}(),wt=U.Cropper,bt=function(){function t(i){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(I(this,t),!i||!K.test(i.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=i,this.options=h({},V,n(e)&&e),this.complete=!1,this.cropped=!1,this.disabled=!1,this.isImg=!1,this.limited=!1,this.loaded=!1,this.ready=!1,this.replaced=!1,this.wheeling=!1,this.originalUrl="",this.canvasData=null,this.cropBoxData=null,this.previews=null,this.pointers={},this.init()}return vt(t,[{key:"init",value:function(){var t=this.element,i=t.tagName.toLowerCase(),e=void 0;if(!f(t,"cropper")){if(v(t,"cropper",this),"img"===i){if(this.isImg=!0,e=t.getAttribute("src")||"",this.originalUrl=e,!e)return;e=t.src}else"canvas"===i&&window.HTMLCanvasElement&&(e=t.toDataURL());this.load(e)}}},{key:"load",value:function(t){var i=this;if(t){this.url=t,this.imageData={};var e=this.element,a=this.options;if(a.checkOrientation&&window.ArrayBuffer)if(Z.test(t))F.test(t)?this.read(O(t)):this.clone();else{var n=new XMLHttpRequest;n.onerror=function(){i.clone()},n.onload=function(){i.read(n.response)},a.checkCrossOrigin&&D(t)&&e.crossOrigin&&(t=B(t)),n.open("get",t),n.responseType="arraybuffer",n.withCredentials="use-credentials"===e.crossOrigin,n.send()}else this.clone()}}},{key:"read",value:function(t){var i=this.options,e=this.imageData,a=z(t),n=0,o=1,r=1;if(a>1){this.url=S(t,"image/jpeg");var h=R(a);n=h.rotate,o=h.scaleX,r=h.scaleY}i.rotatable&&(e.rotate=n),i.scalable&&(e.scaleX=o,e.scaleY=r),this.clone()}},{key:"clone",value:function(){var t=this.element,i=this.url,e=void 0,a=void 0;this.options.checkCrossOrigin&&D(i)&&((e=t.crossOrigin)?a=i:(e="anonymous",a=B(i))),this.crossOrigin=e,this.crossOriginUrl=a;var n=document.createElement("img");e&&(n.crossOrigin=e),n.src=a||i;var o=s(this.start,this),r=s(this.stop,this);this.image=n,this.onStart=o,this.onStop=r,this.isImg?t.complete?this.start():x(t,"load",o):(x(n,"load",o),x(n,"error",r),p(n,"cropper-hide"),t.parentNode.insertBefore(n,t.nextSibling))}},{key:"start",value:function(t){var i=this,e=this.isImg?this.element:this.image;t&&(b(e,"load",this.onStart),b(e,"error",this.onStop)),E(e,function(t,e){h(i.imageData,{naturalWidth:t,naturalHeight:e,aspectRatio:t/e}),i.loaded=!0,i.build()})}},{key:"stop",value:function(){var t=this.image;b(t,"load",this.onStart),b(t,"error",this.onStop),t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){var t=this;if(this.loaded){this.ready&&this.unbuild();var i=this.element,e=this.options,a=this.image,n=i.parentNode,r=document.createElement("div");r.innerHTML='<div class="cropper-container"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-action="e"></span><span class="cropper-line line-n" data-action="n"></span><span class="cropper-line line-w" data-action="w"></span><span class="cropper-line line-s" data-action="s"></span><span class="cropper-point point-e" data-action="e"></span><span class="cropper-point point-n" data-action="n"></span><span class="cropper-point point-w" data-action="w"></span><span class="cropper-point point-s" data-action="s"></span><span class="cropper-point point-ne" data-action="ne"></span><span class="cropper-point point-nw" data-action="nw"></span><span class="cropper-point point-sw" data-action="sw"></span><span class="cropper-point point-se" data-action="se"></span></div></div>';var h=r.querySelector(".cropper-container"),s=h.querySelector(".cropper-canvas"),c=h.querySelector(".cropper-drag-box"),l=h.querySelector(".cropper-crop-box"),d=l.querySelector(".cropper-face");this.container=n,this.cropper=h,this.canvas=s,this.dragBox=c,this.cropBox=l,this.viewBox=h.querySelector(".cropper-view-box"),this.face=d,s.appendChild(a),p(i,j),n.insertBefore(h,i.nextSibling),this.isImg||m(a,"cropper-hide"),this.initPreview(),this.bind(),e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,this.cropped=e.autoCrop,e.autoCrop?e.modal&&p(c,"cropper-modal"):p(l,j),e.guides||p(l.getElementsByClassName("cropper-dashed"),j),e.center||p(l.getElementsByClassName("cropper-center"),j),e.background&&p(h,"cropper-bg"),e.highlight||p(d,"cropper-invisible"),e.cropBoxMovable&&(p(d,"cropper-move"),v(d,"action","all")),e.cropBoxResizable||(p(l.getElementsByClassName("cropper-line"),j),p(l.getElementsByClassName("cropper-point"),j)),this.setDragMode(e.dragMode),this.render(),this.ready=!0,this.setData(e.data),this.completing=setTimeout(function(){o(e.ready)&&x(i,"ready",e.ready,{once:!0}),y(i,"ready"),y(i,"crop",t.getData()),t.complete=!0},0)}}},{key:"unbuild",value:function(){this.ready&&(this.complete||clearTimeout(this.completing),this.ready=!1,this.complete=!1,this.initialImageData=null,this.initialCanvasData=null,this.initialCropBoxData=null,this.containerData=null,this.canvasData=null,this.cropBoxData=null,this.unbind(),this.resetPreview(),this.previews=null,this.viewBox=null,this.cropBox=null,this.dragBox=null,this.canvas=null,this.container=null,this.cropper.parentNode.removeChild(this.cropper),this.cropper=null)}}],[{key:"noConflict",value:function(){return window.Cropper=wt,t}},{key:"setDefaults",value:function(t){h(V,n(t)&&t)}}]),t}();return h(bt.prototype,dt,pt,mt,ut,gt,ft),bt});
No other release has this exact content. See every version of this file.