vue-crop-image
Version:
一个基于VUE框架的裁剪组件
11 lines • 47.9 kB
JavaScript
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var a in i)("object"==typeof exports?exports:t)[a]=i[a]}}("undefined"!=typeof self?self:this,function(){return function(t){function e(a){if(i[a])return i[a].exports;var n=i[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,a){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:a})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=3)}([function(t,e){function i(t,e){var i=t[1]||"",n=t[3];if(!n)return i;if(e&&"function"==typeof btoa){var o=a(n);return[i].concat(n.sources.map(function(t){return"/*# sourceURL="+n.sourceRoot+t+" */"})).concat([o]).join("\n")}return[i].join("\n")}function a(t){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t))))+" */"}t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var a=i(e,t);return e[2]?"@media "+e[2]+"{"+a+"}":a}).join("")},e.i=function(t,i){"string"==typeof t&&(t=[[null,t,""]]);for(var a={},n=0;n<this.length;n++){var o=this[n][0];"number"==typeof o&&(a[o]=!0)}for(n=0;n<t.length;n++){var r=t[n];"number"==typeof r[0]&&a[r[0]]||(i&&!r[2]?r[2]=i:i&&(r[2]="("+r[2]+") and ("+i+")"),e.push(r))}},e}},function(t,e,i){function a(t){for(var e=0;e<t.length;e++){var i=t[e],a=p[i.id];if(a){a.refs++;for(var n=0;n<a.parts.length;n++)a.parts[n](i.parts[n]);for(;n<i.parts.length;n++)a.parts.push(o(i.parts[n]));a.parts.length>i.parts.length&&(a.parts.length=i.parts.length)}else{for(var r=[],n=0;n<i.parts.length;n++)r.push(o(i.parts[n]));p[i.id]={id:i.id,refs:1,parts:r}}}}function n(){var t=document.createElement("style");return t.type="text/css",d.appendChild(t),t}function o(t){var e,i,a=document.querySelector("style["+v+'~="'+t.id+'"]');if(a){if(f)return g;a.parentNode.removeChild(a)}if(w){var o=u++;a=l||(l=n()),e=r.bind(null,a,o,!1),i=r.bind(null,a,o,!0)}else a=n(),e=s.bind(null,a),i=function(){a.parentNode.removeChild(a)};return e(t),function(a){if(a){if(a.css===t.css&&a.media===t.media&&a.sourceMap===t.sourceMap)return;e(t=a)}else i()}}function r(t,e,i,a){var n=i?"":a.css;if(t.styleSheet)t.styleSheet.cssText=b(e,n);else{var o=document.createTextNode(n),r=t.childNodes;r[e]&&t.removeChild(r[e]),r.length?t.insertBefore(o,r[e]):t.appendChild(o)}}function s(t,e){var i=e.css,a=e.media,n=e.sourceMap;if(a&&t.setAttribute("media",a),m.ssrId&&t.setAttribute(v,e.id),n&&(i+="\n/*# sourceURL="+n.sources[0]+" */",i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),t.styleSheet)t.styleSheet.cssText=i;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(i))}}var h="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!h)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var c=i(7),p={},d=h&&(document.head||document.getElementsByTagName("head")[0]),l=null,u=0,f=!1,g=function(){},m=null,v="data-vue-ssr-id",w="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());t.exports=function(t,e,i,n){f=i,m=n||{};var o=c(t,e);return a(o),function(e){for(var i=[],n=0;n<o.length;n++){var r=o[n],s=p[r.id];s.refs--,i.push(s)}e?(o=c(t,e),a(o)):o=[];for(var n=0;n<i.length;n++){var s=i[n];if(0===s.refs){for(var h=0;h<s.parts.length;h++)s.parts[h]();delete p[s.id]}}}};var b=function(){var t=[];return function(e,i){return t[e]=i,t.filter(Boolean).join("\n")}}()},function(t,e,i){"use strict";var a=i(9),n=i.n(a),o=i(10);i.n(o);e.a={name:"vue-crop",props:{src:{type:String,default:"https://lh-static.playhudong.com/forever/image/funCoverDefault1.pngtapd_23436241_base64_1542093035_53%281%29.png"},aspectRatio:{type:Number,default:null},modal:{type:Boolean,default:!0},cropBoxResizable:{type:Boolean,default:!0},getImg:{type:Function,default:function(){return null}}},data:function(){return{canvasImg:null}},mounted:function(){this.initCopper()},methods:{initCopper:function(){var t=this,e=new n.a(this.$refs.img,{viewMode:1,dragMode:"none",aspectRatio:this.aspectRatio,modal:this.modal,toggleDragModeOnDblclick:!1,cropBoxResizable:this.cropBoxResizable,checkCrossOrigin:!1,autoCropArea:1,rotatable:!1,ready:function(){t.callback()},cropend:function(){t.callback()}});this.copper=e},callback:function(){this.cropEnd()},cropEnd:function(){var t=this.copper.getData();this.createCanvas(t)},createCanvas:function(t){var e=this,i=document.createElement("canvas"),a=i.getContext("2d");i.width=t.width,i.height=t.height;var n=new Image;n.setAttribute("crossOrigin","Anonymous"),n.src=this.src,n.onload=function(){e.canvasCover(i,a,t.width,t.height,t.x,t.y,n)}},canvasCover:function(t,e,i,a,n,o,r){var s=document.createElement("canvas"),h=s.getContext("2d");s.width=r.width,s.height=r.height,h.drawImage(r,0,0,r.width,r.height);var c=h.getImageData(n,o,r.width,r.height);e.putImageData(c,0,0,0,0,i,a),this.canvasImg=t.toDataURL("image/png",1),this.$emit("copperImg",this.canvasImg)}}}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=i(4);e.default=a.a},function(t,e,i){"use strict";function a(t){i(5)}var n=i(2),o=i(12),r=i(8),s=a,h=r(n.a,o.a,!1,s,"data-v-fe98b570",null);e.a=h.exports},function(t,e,i){var a=i(6);"string"==typeof a&&(a=[[t.i,a,""]]),a.locals&&(t.exports=a.locals);i(1)("d66653a8",a,!0,{})},function(t,e,i){e=t.exports=i(0)(!1),e.push([t.i,".copper[data-v-fe98b570]{width:100%;height:100%;position:relative}.canvas[data-v-fe98b570]{position:absolute;top:0;left:0;width:100%;height:100%}.copper-box[data-v-fe98b570]{width:100%;height:100%}.copper-img[data-v-fe98b570]{width:100%;height:auto}",""])},function(t,e){t.exports=function(t,e){for(var i=[],a={},n=0;n<e.length;n++){var o=e[n],r=o[0],s=o[1],h=o[2],c=o[3],p={id:t+":"+n,css:s,media:h,sourceMap:c};a[r]?a[r].parts.push(p):i.push(a[r]={id:r,parts:[p]})}return i}},function(t,e){t.exports=function(t,e,i,a,n,o){var r,s=t=t||{},h=typeof t.default;"object"!==h&&"function"!==h||(r=t,s=t.default);var c="function"==typeof s?s.options:s;e&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0),i&&(c.functional=!0),n&&(c._scopeId=n);var p;if(o?(p=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),a&&a.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},c._ssrRegister=p):a&&(p=a),p){var d=c.functional,l=d?c.render:c.beforeCreate;d?(c._injectStyles=p,c.render=function(t,e){return p.call(e),l(t,e)}):c.beforeCreate=l?[].concat(l,p):[p]}return{esModule:r,exports:s,options:c}}},function(t,e,i){/*!
* Cropper.js v1.5.4
* https://fengyuanchen.github.io/cropperjs
*
* Copyright 2015-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2019-08-03T08:38:42.128Z
*/
!function(e,i){t.exports=i()}(0,function(){"use strict";function t(e){return(t="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})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function a(t,e,a){return e&&i(t.prototype,e),a&&i(t,a),t}function n(t){return o(t)||r(t)||s()}function o(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}function r(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function s(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function h(t){return"number"==typeof t&&!ut(t)}function c(t){return void 0===t}function p(e){return"object"===t(e)&&null!==e}function d(t){if(!p(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&>.call(i,"isPrototypeOf")}catch(t){return!1}}function l(t){return"function"==typeof t}function u(t){return Array.from?Array.from(t):mt.call(t)}function f(t,e){return t&&l(e)&&(Array.isArray(t)||h(t.length)?u(t).forEach(function(i,a){e.call(t,i,a,t)}):p(t)&&Object.keys(t).forEach(function(i){e.call(t,t[i],i,t)})),t}function g(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return wt.test(t)?Math.round(t*e)/e:t}function m(t,e){var i=t.style;f(e,function(t,e){bt.test(e)&&h(t)&&(t="".concat(t,"px")),i[e]=t})}function v(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}function w(t,e){if(e){if(h(t.length))return void f(t,function(t){w(t,e)});if(t.classList)return void t.classList.add(e);var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function b(t,e){if(e)return h(t.length)?void f(t,function(t){b(t,e)}):t.classList?void t.classList.remove(e):void(t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function x(t,e,i){if(e)return h(t.length)?void f(t,function(t){x(t,e,i)}):void(i?w(t,e):b(t,e))}function y(t){return t.replace(xt,"$1-$2").toLowerCase()}function C(t,e){return p(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(y(e)))}function M(t,e,i){p(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(y(e)),i)}function D(t,e){if(p(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(y(e)))}function k(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(yt).forEach(function(e){if(!Ct){var o=t.listeners;o&&o[e]&&o[e][i]&&(n=o[e][i],delete o[e][i],0===Object.keys(o[e]).length&&delete o[e],0===Object.keys(o).length&&delete t.listeners)}t.removeEventListener(e,n,a)})}function B(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(yt).forEach(function(e){if(a.once&&!Ct){var o=t.listeners,r=void 0===o?{}:o;n=function(){delete r[e][i],t.removeEventListener(e,n,a);for(var o=arguments.length,s=new Array(o),h=0;h<o;h++)s[h]=arguments[h];i.apply(t,s)},r[e]||(r[e]={}),r[e][i]&&t.removeEventListener(e,r[e][i],a),r[e][i]=n,t.listeners=r}t.addEventListener(e,n,a)})}function A(t,e,i){var a;return l(Event)&&l(CustomEvent)?a=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(a=document.createEvent("CustomEvent"),a.initCustomEvent(e,!0,!0,i)),t.dispatchEvent(a)}function E(t){var e=t.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}function T(t){var e=t.match(Dt);return null!==e&&(e[1]!==Mt.protocol||e[2]!==Mt.hostname||e[3]!==Mt.port)}function R(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function z(t){var e=t.rotate,i=t.scaleX,a=t.scaleY,n=t.translateX,o=t.translateY,r=[];h(n)&&0!==n&&r.push("translateX(".concat(n,"px)")),h(o)&&0!==o&&r.push("translateY(".concat(o,"px)")),h(e)&&0!==e&&r.push("rotate(".concat(e,"deg)")),h(i)&&1!==i&&r.push("scaleX(".concat(i,")")),h(a)&&1!==a&&r.push("scaleY(".concat(a,")"));var s=r.length?r.join(" "):"none";return{WebkitTransform:s,msTransform:s,transform:s}}function N(t){var e=vt({},t),i=[];return f(t,function(t,a){delete e[a],f(e,function(e){var a=Math.abs(t.startX-e.startX),n=Math.abs(t.startY-e.startY),o=Math.abs(t.endX-e.endX),r=Math.abs(t.endY-e.endY),s=Math.sqrt(a*a+n*n),h=Math.sqrt(o*o+r*r),c=(h-s)/s;i.push(c)})}),i.sort(function(t,e){return Math.abs(t)<Math.abs(e)}),i[0]}function W(t,e){var i=t.pageX,a=t.pageY,n={endX:i,endY:a};return e?n:vt({startX:i,startY:a},n)}function O(t){var e=0,i=0,a=0;return f(t,function(t){var n=t.startX,o=t.startY;e+=n,i+=o,a+=1}),e/=a,i/=a,{pageX:e,pageY:i}}function H(t){var e=t.aspectRatio,i=t.height,a=t.width,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",o=ft(a),r=ft(i);if(o&&r){var s=i*e;"contain"===n&&s>a||"cover"===n&&s<a?i=a/e:a=i*e}else o?i=a/e:r&&(a=i*e);return{width:a,height:i}}function L(t){var e=t.width,i=t.height,a=t.degree;if(90===(a=Math.abs(a)%180))return{width:i,height:e};var n=a%90*Math.PI/180,o=Math.sin(n),r=Math.cos(n),s=e*r+i*o,h=e*o+i*r;return a>90?{width:h,height:s}:{width:s,height:h}}function S(t,e,i,a){var o=e.aspectRatio,r=e.naturalWidth,s=e.naturalHeight,h=e.rotate,c=void 0===h?0:h,p=e.scaleX,d=void 0===p?1:p,l=e.scaleY,u=void 0===l?1:l,f=i.aspectRatio,m=i.naturalWidth,v=i.naturalHeight,w=a.fillColor,b=void 0===w?"transparent":w,x=a.imageSmoothingEnabled,y=void 0===x||x,C=a.imageSmoothingQuality,M=void 0===C?"low":C,D=a.maxWidth,k=void 0===D?1/0:D,B=a.maxHeight,A=void 0===B?1/0:B,E=a.minWidth,T=void 0===E?0:E,R=a.minHeight,z=void 0===R?0:R,N=document.createElement("canvas"),W=N.getContext("2d"),O=H({aspectRatio:f,width:k,height:A}),L=H({aspectRatio:f,width:T,height:z},"cover"),S=Math.min(O.width,Math.max(L.width,m)),X=Math.min(O.height,Math.max(L.height,v)),Y=H({aspectRatio:o,width:k,height:A}),j=H({aspectRatio:o,width:T,height:z},"cover"),I=Math.min(Y.width,Math.max(j.width,r)),U=Math.min(Y.height,Math.max(j.height,s)),_=[-I/2,-U/2,I,U];return N.width=g(S),N.height=g(X),W.fillStyle=b,W.fillRect(0,0,S,X),W.save(),W.translate(S/2,X/2),W.rotate(c*Math.PI/180),W.scale(d,u),W.imageSmoothingEnabled=y,W.imageSmoothingQuality=M,W.drawImage.apply(W,[t].concat(n(_.map(function(t){return Math.floor(g(t))})))),W.restore(),N}function X(t,e,i){var a="";i+=e;for(var n=e;n<i;n+=1)a+=kt(t.getUint8(n));return a}function Y(t){var e=t.replace(Bt,""),i=atob(e),a=new ArrayBuffer(i.length),n=new Uint8Array(a);return f(n,function(t,e){n[e]=i.charCodeAt(e)}),a}function j(t,e){for(var i=[],a=new Uint8Array(t);a.length>0;)i.push(kt.apply(null,u(a.subarray(0,8192)))),a=a.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}function I(t){var e,i=new DataView(t);try{var a,n,o;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var r=i.byteLength,s=2;s+1<r;){if(255===i.getUint8(s)&&225===i.getUint8(s+1)){n=s;break}s+=1}if(n){var h=n+4,c=n+10;if("Exif"===X(i,h,4)){var p=i.getUint16(c);if(((a=18761===p)||19789===p)&&42===i.getUint16(c+2,a)){var d=i.getUint32(c+4,a);d>=8&&(o=c+d)}}}if(o){var l,u,f=i.getUint16(o,a);for(u=0;u<f;u+=1)if(l=o+12*u+2,274===i.getUint16(l,a)){l+=8,e=i.getUint16(l,a),i.setUint16(l,1,a);break}}}catch(t){e=1}return e}function U(t){var e=0,i=1,a=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:a}}var _="undefined"!=typeof window&&void 0!==window.document,P=_?window:{},q=!!_&&"ontouchstart"in P.document.documentElement,$=!!_&&"PointerEvent"in P,F="".concat("cropper","-crop"),Q="".concat("cropper","-disabled"),G="".concat("cropper","-hidden"),V="".concat("cropper","-hide"),Z="".concat("cropper","-invisible"),J="".concat("cropper","-modal"),K="".concat("cropper","-move"),tt="".concat("cropper","Action"),et="".concat("cropper","Preview"),it=q?"touchstart":"mousedown",at=q?"touchmove":"mousemove",nt=q?"touchend touchcancel":"mouseup",ot=$?"pointerdown":it,rt=$?"pointermove":at,st=$?"pointerup pointercancel":nt,ht=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,ct=/^data:/,pt=/^data:image\/jpeg;base64,/,dt=/^img|canvas$/i,lt={viewMode:0,dragMode:"crop",initialAspectRatio:NaN,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},ut=Number.isNaN||P.isNaN,ft=function(t){return t>0&&t<1/0},gt=Object.prototype.hasOwnProperty,mt=Array.prototype.slice,vt=Object.assign||function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),a=1;a<e;a++)i[a-1]=arguments[a];return p(t)&&i.length>0&&i.forEach(function(e){p(e)&&Object.keys(e).forEach(function(i){t[i]=e[i]})}),t},wt=/\.\d*(?:0|9){12}\d*$/,bt=/^width|height|left|top|marginLeft|marginTop$/,xt=/([a-z\d])([A-Z])/g,yt=/\s\s*/,Ct=function(){var t=!1;if(_){var e=!1,i=function(){},a=Object.defineProperty({},"once",{get:function(){return t=!0,e},set:function(t){e=t}});P.addEventListener("test",i,a),P.removeEventListener("test",i,a)}return t}(),Mt=P.location,Dt=/^(\w+:)\/\/([^:\/?#]*):?(\d*)/i,kt=String.fromCharCode,Bt=/^data:.*,/,At={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,e=this.options,i=this.container,a=this.cropper;w(a,G),b(t,G);var n={width:Math.max(i.offsetWidth,Number(e.minContainerWidth)||200),height:Math.max(i.offsetHeight,Number(e.minContainerHeight)||100)};this.containerData=n,m(a,{width:n.width,height:n.height}),w(t,G),b(a,G)},initCanvas:function(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,a=Math.abs(e.rotate)%180==90,n=a?e.naturalHeight:e.naturalWidth,o=a?e.naturalWidth:e.naturalHeight,r=n/o,s=t.width,h=t.height;t.height*r>t.width?3===i?s=t.height*r:h=t.width/r:3===i?h=t.width/r:s=t.height*r;var c={aspectRatio:r,naturalWidth:n,naturalHeight:o,width:s,height:h};c.left=(t.width-s)/2,c.top=(t.height-h)/2,c.oldLeft=c.left,c.oldTop=c.top,this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),this.initialImageData=vt({},e),this.initialCanvasData=vt({},c)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=i.viewMode,s=n.aspectRatio,h=this.cropped&&o;if(t){var c=Number(i.minCanvasWidth)||0,p=Number(i.minCanvasHeight)||0;r>1?(c=Math.max(c,a.width),p=Math.max(p,a.height),3===r&&(p*s>c?c=p*s:p=c/s)):r>0&&(c?c=Math.max(c,h?o.width:0):p?p=Math.max(p,h?o.height:0):h&&(c=o.width,p=o.height,p*s>c?c=p*s:p=c/s));var d=H({aspectRatio:s,width:c,height:p});c=d.width,p=d.height,n.minWidth=c,n.minHeight=p,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(r>(h?0:1)){var l=a.width-n.width,u=a.height-n.height;n.minLeft=Math.min(0,l),n.minTop=Math.min(0,u),n.maxLeft=Math.max(0,l),n.maxTop=Math.max(0,u),h&&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,l),n.maxLeft=Math.max(0,l)),n.height>=a.height&&(n.minTop=Math.min(0,u),n.maxTop=Math.max(0,u))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,e){var i=this.canvasData,a=this.imageData;if(e){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=i.width*(o/i.naturalWidth),h=i.height*(r/i.naturalHeight);i.left-=(s-i.width)/2,i.top-=(h-i.height)/2,i.width=s,i.height=h,i.aspectRatio=o/r,i.naturalWidth=o,i.naturalHeight=r,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,m(this.canvas,vt({width:i.width,height:i.height},z({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var e=this.canvasData,i=this.imageData,a=i.naturalWidth*(e.width/e.naturalWidth),n=i.naturalHeight*(e.height/e.naturalHeight);vt(i,{width:a,height:n,left:(e.width-a)/2,top:(e.height-n)/2}),m(this.image,vt({width:i.width,height:i.height},z(vt({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,a=Number(t.autoCropArea)||.8,n={width:e.width,height:e.height};i&&(e.height*i>e.width?n.height=n.width/i:n.width=n.height*i),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=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=vt({},n)},limitCropBox:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=this.limited,s=i.aspectRatio;if(t){var h=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,p=r?Math.min(a.width,n.width,n.width+n.left,a.width-n.left):a.width,d=r?Math.min(a.height,n.height,n.height+n.top,a.height-n.top):a.height;h=Math.min(h,a.width),c=Math.min(c,a.height),s&&(h&&c?c*s>h?c=h/s:h=c*s:h?c=h/s:c&&(h=c*s),d*s>p?d=p/s:p=d*s),o.minWidth=Math.min(h,p),o.minHeight=Math.min(c,d),o.maxWidth=p,o.maxHeight=d}e&&(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,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&M(this.face,tt,i.width>=e.width&&i.height>=e.height?"move":"all"),m(this.cropBox,vt({width:i.width,height:i.height},z({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),A(this.element,"crop",this.getData())}},Et={initPreview:function(){var t=this.element,e=this.crossOrigin,i=this.options.preview,a=e?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",o=document.createElement("img");if(e&&(o.crossOrigin=e),o.src=a,o.alt=n,this.viewBox.appendChild(o),this.viewBoxImage=o,i){var r=i;"string"==typeof i?r=t.ownerDocument.querySelectorAll(i):i.querySelector&&(r=[i]),this.previews=r,f(r,function(t){var i=document.createElement("img");M(t,et,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=a,i.alt=n,i.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;"',t.innerHTML="",t.appendChild(i)})}},resetPreview:function(){f(this.previews,function(t){var e=C(t,et);m(t,{width:e.width,height:e.height}),t.innerHTML=e.html,D(t,et)})},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,o=t.width,r=t.height,s=i.left-e.left-t.left,h=i.top-e.top-t.top;this.cropped&&!this.disabled&&(m(this.viewBoxImage,vt({width:o,height:r},z(vt({translateX:-s,translateY:-h},t)))),f(this.previews,function(e){var i=C(e,et),c=i.width,p=i.height,d=c,l=p,u=1;a&&(u=c/a,l=n*u),n&&l>p&&(u=p/n,d=a*u,l=p),m(e,{width:d,height:l}),m(e.getElementsByTagName("img")[0],vt({width:o*u,height:r*u},z(vt({translateX:-s*u,translateY:-h*u},t))))}))}},Tt={bind:function(){var t=this.element,e=this.options,i=this.cropper;l(e.cropstart)&&B(t,"cropstart",e.cropstart),l(e.cropmove)&&B(t,"cropmove",e.cropmove),l(e.cropend)&&B(t,"cropend",e.cropend),l(e.crop)&&B(t,"crop",e.crop),l(e.zoom)&&B(t,"zoom",e.zoom),B(i,ot,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&B(i,"wheel",this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&B(i,"dblclick",this.onDblclick=this.dblclick.bind(this)),B(t.ownerDocument,rt,this.onCropMove=this.cropMove.bind(this)),B(t.ownerDocument,st,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&B(window,"resize",this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;l(e.cropstart)&&k(t,"cropstart",e.cropstart),l(e.cropmove)&&k(t,"cropmove",e.cropmove),l(e.cropend)&&k(t,"cropend",e.cropend),l(e.crop)&&k(t,"crop",e.crop),l(e.zoom)&&k(t,"zoom",e.zoom),k(i,ot,this.onCropStart),e.zoomable&&e.zoomOnWheel&&k(i,"wheel",this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&k(i,"dblclick",this.onDblclick),k(t.ownerDocument,rt,this.onCropMove),k(t.ownerDocument,st,this.onCropEnd),e.responsive&&k(window,"resize",this.onResize)}},Rt={resize:function(){var t=this.options,e=this.container,i=this.containerData,a=Number(t.minContainerWidth)||200,n=Number(t.minContainerHeight)||100;if(!(this.disabled||i.width<=a||i.height<=n)){var o=e.offsetWidth/i.width;if(1!==o||e.offsetHeight!==i.height){var r,s;t.restore&&(r=this.getCanvasData(),s=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(f(r,function(t,e){r[e]=t*o})),this.setCropBoxData(f(s,function(t,e){s[e]=t*o})))}}},dblclick:function(){this.disabled||"none"===this.options.dragMode||this.setDragMode(v(this.dragBox,F)?"move":"crop")},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){e.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*i,t)))},cropStart:function(t){var e=t.buttons,i=t.button;if(!(this.disabled||h(e)&&1!==e||h(i)&&0!==i||t.ctrlKey)){var a,n=this.options,o=this.pointers;t.changedTouches?f(t.changedTouches,function(t){o[t.identifier]=W(t)}):o[t.pointerId||0]=W(t),a=Object.keys(o).length>1&&n.zoomable&&n.zoomOnTouch?"zoom":C(t.target,tt),ht.test(a)&&!1!==A(this.element,"cropstart",{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,"crop"===a&&(this.cropping=!0,w(this.dragBox,J)))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==A(this.element,"cropmove",{originalEvent:t,action:e})&&(t.changedTouches?f(t.changedTouches,function(t){vt(i[t.identifier]||{},W(t,!0))}):vt(i[t.pointerId||0]||{},W(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?f(t.changedTouches,function(t){delete i[t.identifier]}):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,x(this.dragBox,J,this.cropped&&this.options.modal)),A(this.element,"cropend",{originalEvent:t,action:e}))}}},zt={change:function(t){var e,i=this.options,a=this.canvasData,n=this.containerData,o=this.cropBoxData,r=this.pointers,s=this.action,h=i.aspectRatio,c=o.left,p=o.top,d=o.width,l=o.height,u=c+d,g=p+l,m=0,v=0,w=n.width,x=n.height,y=!0;!h&&t.shiftKey&&(h=d&&l?d/l:1),this.limited&&(m=o.minLeft,v=o.minTop,w=m+Math.min(n.width,a.width,a.left+a.width),x=v+Math.min(n.height,a.height,a.top+a.height));var C=r[Object.keys(r)[0]],M={x:C.endX-C.startX,y:C.endY-C.startY},D=function(t){switch(t){case"e":u+M.x>w&&(M.x=w-u);break;case"w":c+M.x<m&&(M.x=m-c);break;case"n":p+M.y<v&&(M.y=v-p);break;case"s":g+M.y>x&&(M.y=x-g)}};switch(s){case"all":c+=M.x,p+=M.y;break;case"e":if(M.x>=0&&(u>=w||h&&(p<=v||g>=x))){y=!1;break}D("e"),d+=M.x,d<0&&(s="w",d=-d,c-=d),h&&(l=d/h,p+=(o.height-l)/2);break;case"n":if(M.y<=0&&(p<=v||h&&(c<=m||u>=w))){y=!1;break}D("n"),l-=M.y,p+=M.y,l<0&&(s="s",l=-l,p-=l),h&&(d=l*h,c+=(o.width-d)/2);break;case"w":if(M.x<=0&&(c<=m||h&&(p<=v||g>=x))){y=!1;break}D("w"),d-=M.x,c+=M.x,d<0&&(s="e",d=-d,c-=d),h&&(l=d/h,p+=(o.height-l)/2);break;case"s":if(M.y>=0&&(g>=x||h&&(c<=m||u>=w))){y=!1;break}D("s"),l+=M.y,l<0&&(s="n",l=-l,p-=l),h&&(d=l*h,c+=(o.width-d)/2);break;case"ne":if(h){if(M.y<=0&&(p<=v||u>=w)){y=!1;break}D("n"),l-=M.y,p+=M.y,d=l*h}else D("n"),D("e"),M.x>=0?u<w?d+=M.x:M.y<=0&&p<=v&&(y=!1):d+=M.x,M.y<=0?p>v&&(l-=M.y,p+=M.y):(l-=M.y,p+=M.y);d<0&&l<0?(s="sw",l=-l,d=-d,p-=l,c-=d):d<0?(s="nw",d=-d,c-=d):l<0&&(s="se",l=-l,p-=l);break;case"nw":if(h){if(M.y<=0&&(p<=v||c<=m)){y=!1;break}D("n"),l-=M.y,p+=M.y,d=l*h,c+=o.width-d}else D("n"),D("w"),M.x<=0?c>m?(d-=M.x,c+=M.x):M.y<=0&&p<=v&&(y=!1):(d-=M.x,c+=M.x),M.y<=0?p>v&&(l-=M.y,p+=M.y):(l-=M.y,p+=M.y);d<0&&l<0?(s="se",l=-l,d=-d,p-=l,c-=d):d<0?(s="ne",d=-d,c-=d):l<0&&(s="sw",l=-l,p-=l);break;case"sw":if(h){if(M.x<=0&&(c<=m||g>=x)){y=!1;break}D("w"),d-=M.x,c+=M.x,l=d/h}else D("s"),D("w"),M.x<=0?c>m?(d-=M.x,c+=M.x):M.y>=0&&g>=x&&(y=!1):(d-=M.x,c+=M.x),M.y>=0?g<x&&(l+=M.y):l+=M.y;d<0&&l<0?(s="ne",l=-l,d=-d,p-=l,c-=d):d<0?(s="se",d=-d,c-=d):l<0&&(s="nw",l=-l,p-=l);break;case"se":if(h){if(M.x>=0&&(u>=w||g>=x)){y=!1;break}D("e"),d+=M.x,l=d/h}else D("s"),D("e"),M.x>=0?u<w?d+=M.x:M.y>=0&&g>=x&&(y=!1):d+=M.x,M.y>=0?g<x&&(l+=M.y):l+=M.y;d<0&&l<0?(s="nw",l=-l,d=-d,p-=l,c-=d):d<0?(s="sw",d=-d,c-=d):l<0&&(s="ne",l=-l,p-=l);break;case"move":this.move(M.x,M.y),y=!1;break;case"zoom":this.zoom(N(r),t),y=!1;break;case"crop":if(!M.x||!M.y){y=!1;break}e=E(this.cropper),c=C.startX-e.left,p=C.startY-e.top,d=o.minWidth,l=o.minHeight,M.x>0?s=M.y>0?"se":"ne":M.x<0&&(c-=d,s=M.y>0?"sw":"nw"),M.y<0&&(p-=l),this.cropped||(b(this.cropBox,G),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}y&&(o.width=d,o.height=l,o.left=c,o.top=p,this.action=s,this.renderCropBox()),f(r,function(t){t.startX=t.endX,t.startY=t.endY})}},Nt={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&w(this.dragBox,J),b(this.cropBox,G),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=vt({},this.initialImageData),this.canvasData=vt({},this.initialCanvasData),this.cropBoxData=vt({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(vt(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),b(this.dragBox,J),w(this.cropBox,G)),this},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,f(this.previews,function(e){e.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,b(this.cropper,Q)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,w(this.cropper,Q)),this},destroy:function(){var t=this.element;return t.cropper?(t.cropper=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(c(t)?t:a+Number(t),c(e)?e:n+Number(e))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(h(t)&&(i.left=t,a=!0),h(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=Number(t),t=t<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var a=this.options,n=this.canvasData,o=n.width,r=n.height,s=n.naturalWidth,c=n.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&a.zoomable){var p=s*t,l=c*t;if(!1===A(this.element,"zoom",{ratio:t,oldRatio:o/s,originalEvent:i}))return this;if(i){var u=this.pointers,f=E(this.cropper),g=u&&Object.keys(u).length?O(u):{pageX:i.pageX,pageY:i.pageY};n.left-=(p-o)*((g.pageX-f.left-n.left)/o),n.top-=(l-r)*((g.pageY-f.top-n.top)/r)}else d(e)&&h(e.x)&&h(e.y)?(n.left-=(p-o)*((e.x-n.left)/o),n.top-=(l-r)*((e.y-n.top)/r)):(n.left-=(p-o)/2,n.top-=(l-r)/2);n.width=p,n.height=l,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return t=Number(t),h(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,h(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(h(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(h(t)&&(i.scaleX=t,a=!0),h(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,a=this.imageData,n=this.canvasData,o=this.cropBoxData;if(this.ready&&this.cropped){t={x:o.left-n.left,y:o.top-n.top,width:o.width,height:o.height};var r=a.width/a.naturalWidth;if(f(t,function(e,i){t[i]=e/r}),e){var s=Math.round(t.y+t.height),h=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=h-t.x,t.height=s-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=a.rotate||0),i.scalable&&(t.scaleX=a.scaleX||1,t.scaleY=a.scaleY||1),t},setData:function(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&d(t)){var o=!1;e.rotatable&&h(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,o=!0),e.scalable&&(h(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,o=!0),h(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,o=!0)),o&&this.renderCanvas(!0,!0);var r=i.width/i.naturalWidth;h(t.x)&&(n.left=t.x*r+a.left),h(t.y)&&(n.top=t.y*r+a.top),h(t.width)&&(n.width=t.width*r),h(t.height)&&(n.height=t.height*r),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?vt({},this.containerData):{}},getImageData:function(){return this.sized?vt({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&f(["left","top","width","height","naturalWidth","naturalHeight"],function(i){e[i]=t[i]}),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&d(t)&&(h(t.left)&&(e.left=t.left),h(t.top)&&(e.top=t.top),h(t.width)?(e.width=t.width,e.height=t.width/i):h(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function(t){var e,i,a=this.cropBoxData,n=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&d(t)&&(h(t.left)&&(a.left=t.left),h(t.top)&&(a.top=t.top),h(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),h(t.height)&&t.height!==a.height&&(i=!0,a.height=t.height),n&&(e?a.height=a.width/n:i&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=S(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(),o=a.x,r=a.y,s=a.width,h=a.height,c=i.width/Math.floor(e.naturalWidth);1!==c&&(o*=c,r*=c,s*=c,h*=c);var p=s/h,d=H({aspectRatio:p,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),l=H({aspectRatio:p,width:t.minWidth||0,height:t.minHeight||0},"cover"),u=H({aspectRatio:p,width:t.width||(1!==c?i.width:s),height:t.height||(1!==c?i.height:h)}),f=u.width,m=u.height;f=Math.min(d.width,Math.max(l.width,f)),m=Math.min(d.height,Math.max(l.height,m));var v=document.createElement("canvas"),w=v.getContext("2d");v.width=g(f),v.height=g(m),w.fillStyle=t.fillColor||"transparent",w.fillRect(0,0,f,m);var b=t.imageSmoothingEnabled,x=void 0===b||b,y=t.imageSmoothingQuality;w.imageSmoothingEnabled=x,y&&(w.imageSmoothingQuality=y);var C,M,D,k,B,A,E=i.width,T=i.height,R=o,z=r;R<=-s||R>E?(R=0,C=0,D=0,B=0):R<=0?(D=-R,R=0,C=Math.min(E,s+R),B=C):R<=E&&(D=0,C=Math.min(s,E-R),B=C),C<=0||z<=-h||z>T?(z=0,M=0,k=0,A=0):z<=0?(k=-z,z=0,M=Math.min(T,h+z),A=M):z<=T&&(k=0,M=Math.min(h,T-z),A=M);var N=[R,z,C,M];if(B>0&&A>0){var W=f/s;N.push(D*W,k*W,B*W,A*W)}return w.drawImage.apply(w,[i].concat(n(N.map(function(t){return Math.floor(g(t))})))),v},setAspectRatio:function(t){var e=this.options;return this.disabled||c(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n="crop"===t,o=e.movable&&"move"===t;t=n||o?t:"none",e.dragMode=t,M(i,tt,t),x(i,F,n),x(i,K,o),e.cropBoxMovable||(M(a,tt,t),x(a,F,n),x(a,K,o))}return this}},Wt=P.Cropper,Ot=function(){function t(i){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e(this,t),!i||!dt.test(i.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=i,this.options=vt({},lt,d(a)&&a),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return a(t,[{key:"init",value:function(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e.cropper){if(e.cropper=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,a=this.options;if(a.rotatable||a.scalable||(a.checkOrientation=!1),!a.checkOrientation||!window.ArrayBuffer)return void this.clone();if(ct.test(t))return void(pt.test(t)?this.read(Y(t)):this.clone());var n=new XMLHttpRequest,o=this.clone.bind(this);this.reloading=!0,this.xhr=n,n.onabort=o,n.onerror=o,n.ontimeout=o,n.onprogress=function(){"image/jpeg"!==n.getResponseHeader("content-type")&&n.abort()},n.onload=function(){e.read(n.response)},n.onloadend=function(){e.reloading=!1,e.xhr=null},a.checkCrossOrigin&&T(t)&&i.crossOrigin&&(t=R(t)),n.open("GET",t),n.responseType="arraybuffer",n.withCredentials="use-credentials"===i.crossOrigin,n.send()}}},{key:"read",value:function(t){var e=this.options,i=this.imageData,a=I(t),n=0,o=1,r=1;if(a>1){this.url=j(t,"image/jpeg");var s=U(a);n=s.rotate,o=s.scaleX,r=s.scaleY}e.rotatable&&(i.rotate=n),e.scalable&&(i.scaleX=o,i.scaleY=r),this.clone()}},{key:"clone",value:function(){var t=this.element,e=this.url,i=t.crossOrigin,a=e;this.options.checkCrossOrigin&&T(e)&&(i||(i="anonymous"),a=R(e)),this.crossOrigin=i,this.crossOriginUrl=a;var n=document.createElement("img");i&&(n.crossOrigin=i),n.src=a||e,n.alt=t.alt||"The image to crop",this.image=n,n.onload=this.start.bind(this),n.onerror=this.stop.bind(this),w(n,V),t.parentNode.insertBefore(n,t.nextSibling)}},{key:"start",value:function(){var t=this,e=this.image;e.onload=null,e.onerror=null,this.sizing=!0;var i=P.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(P.navigator.userAgent),a=function(e,i){vt(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.sizing=!1,t.sized=!0,t.build()};if(e.naturalWidth&&!i)return void a(e.naturalWidth,e.naturalHeight);var n=document.createElement("img"),o=document.body||document.documentElement;this.sizingImage=n,n.onload=function(){a(n.width,n.height),i||o.removeChild(n)},n.src=e.src,i||(n.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",o.appendChild(n))}},{key:"stop",value:function(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,a=t.parentNode,n=document.createElement("div");n.innerHTML='<div class="cropper-container" touch-action="none"><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-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';var o=n.querySelector(".".concat("cropper","-container")),r=o.querySelector(".".concat("cropper","-canvas")),s=o.querySelector(".".concat("cropper","-drag-box")),h=o.querySelector(".".concat("cropper","-crop-box")),c=h.querySelector(".".concat("cropper","-face"));this.container=a,this.cropper=o,this.canvas=r,this.dragBox=s,this.cropBox=h,this.viewBox=o.querySelector(".".concat("cropper","-view-box")),this.face=c,r.appendChild(i),w(t,G),a.insertBefore(o,t.nextSibling),this.isImg||b(i,V),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,w(h,G),e.guides||w(h.getElementsByClassName("".concat("cropper","-dashed")),G),e.center||w(h.getElementsByClassName("".concat("cropper","-center")),G),e.background&&w(o,"".concat("cropper","-bg")),e.highlight||w(c,Z),e.cropBoxMovable&&(w(c,K),M(c,tt,"all")),e.cropBoxResizable||(w(h.getElementsByClassName("".concat("cropper","-line")),G),w(h.getElementsByClassName("".concat("cropper","-point")),G)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),l(e.ready)&&B(t,"ready",e.ready,{once:!0}),A(t,"ready")}}},{key:"unbuild",value:function(){this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),this.cropper.parentNode.removeChild(this.cropper),b(this.element,G))}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function(){return window.Cropper=Wt,t}},{key:"setDefaults",value:function(t){vt(lt,d(t)&&t)}}]),t}();return vt(Ot.prototype,At,Et,Tt,Rt,zt,Nt),Ot})},function(t,e,i){var a=i(11);"string"==typeof a&&(a=[[t.i,a,""]]),a.locals&&(t.exports=a.locals);i(1)("354ec51f",a,!0,{})},function(t,e,i){e=t.exports=i(0)(!1),e.push([t.i,'/*!\n * Cropper.js v1.5.4\n * https://fengyuanchen.github.io/cropperjs\n *\n * Copyright 2015-present Chen Fengyuan\n * Released under the MIT license\n *\n * Date: 2019-08-03T08:38:38.177Z\n */.cropper-container{direction:ltr;font-size:0;line-height:0;position:relative;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.cropper-container img{display:block;height:100%;image-orientation:0deg;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{bottom:0;left:0;position:absolute;right:0;top:0}.cropper-canvas,.cropper-wrap-box{overflow:hidden}.cropper-drag-box{background-color:#fff;opacity:0}.cropper-modal{background-color:#000;opacity:.5}.cropper-view-box{display:block;height:100%;outline:1px solid #39f;outline-color:rgba(51,153,255,.75);overflow:hidden;width:100%}.cropper-dashed{border:0 dashed #eee;display:block;opacity:.5;position:absolute}.cropper-dashed.dashed-h{border-bottom-width:1px;border-top-width:1px;height:33.33333%;left:0;top:33.33333%;width:100%}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;height:100%;left:33.33333%;top:0;width:33.33333%}.cropper-center{display:block;height:0;left:50%;opacity:.75;position:absolute;top:50%;width:0}.cropper-center:after,.cropper-center:before{background-color:#eee;content:" ";display:block;position:absolute}.cropper-center:before{height:1px;left:-3px;top:0;width:7px}.cropper-center:after{height:7px;left:0;top:-3px;width:1px}.cropper-face,.cropper-line,.cropper-point{display:block;height:100%;opacity:.1;position:absolute;width:100%}.cropper-face{background-color:#fff;left:0;top:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:ew-resize;right:-3px;top:0;width:5px}.cropper-line.line-n{cursor:ns-resize;height:5px;left:0;top:-3px}.cropper-line.line-w{cursor:ew-resize;left:-3px;top:0;width:5px}.cropper-line.line-s{bottom:-3px;cursor:ns-resize;height:5px;left:0}.cropper-point{background-color:#39f;height:5px;opacity:.75;width:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;right:-3px;top:50%}.cropper-point.point-n{cursor:ns-resize;left:50%;margin-left:-3px;top:-3px}.cropper-point.point-w{cursor:ew-resize;left:-3px;margin-top:-3px;top:50%}.cropper-point.point-s{bottom:-3px;cursor:s-resize;left:50%;margin-left:-3px}.cropper-point.point-ne{cursor:nesw-resize;right:-3px;top:-3px}.cropper-point.point-nw{cursor:nwse-resize;left:-3px;top:-3px}.cropper-point.point-sw{bottom:-3px;cursor:nesw-resize;left:-3px}.cropper-point.point-se{bottom:-3px;cursor:nwse-resize;height:20px;opacity:1;right:-3px;width:20px}@media (min-width:768px){.cropper-point.point-se{height:15px;width:15px}}@media (min-width:992px){.cropper-point.point-se{height:10px;width:10px}}@media (min-width:1200px){.cropper-point.point-se{height:5px;opacity:.75;width:5px}}.cropper-point.point-se:before{background-color:#39f;bottom:-50%;content:" ";display:block;height:200%;opacity:0;position:absolute;right:-50%;width:200%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC")}.cropper-hide{display:block;height:0;position:absolute;width:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}',""])},function(t,e,i){"use strict";var a=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"copper-box"},[i("img",{ref:"img",staticClass:"copper-img",attrs:{src:t.src}})])},n=[],o={render:a,staticRenderFns:n};e.a=o}])});
//# sourceMappingURL=index.js.map