;(function(){function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e2){throw _e2;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e3){didErr=true;err=_e3;},f:function f(){try{if(!normalCompletion&&it.return!=null)it.return();}finally{if(didErr)throw err;}}};}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=8){ifdStart=tiffOffset+firstIFDOffset;}}}}}if(ifdStart){length=dataView.getUint16(ifdStart,littleEndian);for(i=0;i21?"-21px":"0px";obj.width=this.cropW>0?this.cropW:0;obj.height=this.cropH>0?this.cropH:0;if(this.infoTrue){var dpr=1;if(this.high&&!this.full){dpr=window.devicePixelRatio;}if(this.enlarge!==1&!this.full){dpr=Math.abs(Number(this.enlarge));}obj.width=obj.width*dpr;obj.height=obj.height*dpr;if(this.full){obj.width=obj.width/this.scale;obj.height=obj.height/this.scale;}}obj.width=obj.width.toFixed(0);obj.height=obj.height.toFixed(0);return obj;},isIE:function isIE(){var isIE=!!window.ActiveXObject||"ActiveXObject"in window;return isIE;},passive:function passive(){return this.isIE?null:{passive:false};}},watch:{img:function img(){this.checkedImg();},imgs:function imgs(val){if(val===""){return;}this.reload();},cropW:function cropW(){this.showPreview();},cropH:function cropH(){this.showPreview();},cropOffsertX:function cropOffsertX(){this.showPreview();},cropOffsertY:function cropOffsertY(){this.showPreview();},scale:function scale(val,oldVal){this.showPreview();},x:function x(){this.showPreview();},y:function y(){this.showPreview();},autoCrop:function autoCrop(val){if(val){this.goAutoCrop();}},autoCropWidth:function autoCropWidth(){if(this.autoCrop){this.goAutoCrop();}},autoCropHeight:function autoCropHeight(){if(this.autoCrop){this.goAutoCrop();}},mode:function mode(){this.checkedImg();},rotate:function rotate(){this.showPreview();if(this.autoCrop){this.goAutoCrop(this.cropW,this.cropH);}else{if(this.cropW>0||this.cropH>0){this.goAutoCrop(this.cropW,this.cropH);}}}},methods:{getVersion:function getVersion(name){var arr=navigator.userAgent.split(" ");var chromeVersion="";var result=0;var reg=new RegExp(name,"i");for(var i=0;i=81){orientation=-1;}else{if(this.getVersion("safari")[0]>=605){var safariVersion=this.getVersion("version");if(safariVersion[0]>13&&safariVersion[1]>1){orientation=-1;}}else{var isIos=navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/);if(isIos){var version=isIos[1];version=version.split("_");if(version[0]>13||version[0]>=13&&version[1]>=4){orientation=-1;}}}}var canvas=document.createElement("canvas");var ctx=canvas.getContext("2d");ctx.save();switch(orientation){case 2:canvas.width=width;canvas.height=height;ctx.translate(width,0);ctx.scale(-1,1);break;case 3:canvas.width=width;canvas.height=height;ctx.translate(width/2,height/2);ctx.rotate(180*Math.PI/180);ctx.translate(-width/2,-height/2);break;case 4:canvas.width=width;canvas.height=height;ctx.translate(0,height);ctx.scale(1,-1);break;case 5:canvas.height=width;canvas.width=height;ctx.rotate(0.5*Math.PI);ctx.scale(1,-1);break;case 6:canvas.width=height;canvas.height=width;ctx.translate(height/2,width/2);ctx.rotate(90*Math.PI/180);ctx.translate(-width/2,-height/2);break;case 7:canvas.height=width;canvas.width=height;ctx.rotate(0.5*Math.PI);ctx.translate(width,-height);ctx.scale(-1,1);break;case 8:canvas.height=width;canvas.width=height;ctx.translate(height/2,width/2);ctx.rotate(-90*Math.PI/180);ctx.translate(-width/2,-height/2);break;default:canvas.width=width;canvas.height=height;}ctx.drawImage(img,0,0,width,height);ctx.restore();canvas.toBlob(function(blob){var data=URL.createObjectURL(blob);URL.revokeObjectURL(_this.imgs);_this.imgs=data;},"image/"+this.outputType,1);},checkedImg:function checkedImg(){var _this2=this;if(this.img===null||this.img===""){this.imgs="";this.clearCrop();return;}this.loading=true;this.scale=1;this.rotate=0;this.clearCrop();var img=new Image();img.onload=function(){if(_this2.img===""){_this2.$emit("img-load","error");return false;}var width=img.width;var height=img.height;Exif.getData(img).then(function(data){_this2.orientation=data.orientation||1;var max=Number(_this2.maxImgSize);if(!_this2.orientation&&widthmax){height=height/width*max;width=max;}if(height>max){width=width/height*max;height=max;}_this2.checkOrientationImage(img,_this2.orientation,width,height);});};img.onerror=function(){_this2.$emit("img-load","error");};if(this.img.substr(0,4)!=="data"){img.crossOrigin="";}if(this.isIE){var xhr=new XMLHttpRequest();xhr.onload=function(){var url=URL.createObjectURL(this.response);img.src=url;};xhr.open("GET",this.img,true);xhr.responseType="blob";xhr.send();}else{img.src=this.img;}},startMove:function startMove(e){e.preventDefault();if(this.move&&!this.crop){if(!this.canMove){return false;}this.moveX=("clientX"in e?e.clientX:e.touches[0].clientX)-this.x;this.moveY=("clientY"in e?e.clientY:e.touches[0].clientY)-this.y;if(e.touches){window.addEventListener("touchmove",this.moveImg);window.addEventListener("touchend",this.leaveImg);if(e.touches.length==2){this.touches=e.touches;window.addEventListener("touchmove",this.touchScale);window.addEventListener("touchend",this.cancelTouchScale);}}else{window.addEventListener("mousemove",this.moveImg);window.addEventListener("mouseup",this.leaveImg);}this.$emit("imgMoving",{moving:true,axis:this.getImgAxis()});this.$emit("img-moving",{moving:true,axis:this.getImgAxis()});}else{this.cropping=true;window.addEventListener("mousemove",this.createCrop);window.addEventListener("mouseup",this.endCrop);window.addEventListener("touchmove",this.createCrop);window.addEventListener("touchend",this.endCrop);this.cropOffsertX=e.offsetX?e.offsetX:e.touches[0].pageX-this.$refs.cropper.offsetLeft;this.cropOffsertY=e.offsetY?e.offsetY:e.touches[0].pageY-this.$refs.cropper.offsetTop;this.cropX="clientX"in e?e.clientX:e.touches[0].clientX;this.cropY="clientY"in e?e.clientY:e.touches[0].clientY;this.cropChangeX=this.cropOffsertX;this.cropChangeY=this.cropOffsertY;this.cropW=0;this.cropH=0;}},touchScale:function touchScale(e){var _this3=this;e.preventDefault();var scale=this.scale;var oldTouch1={x:this.touches[0].clientX,y:this.touches[0].clientY};var newTouch1={x:e.touches[0].clientX,y:e.touches[0].clientY};var oldTouch2={x:this.touches[1].clientX,y:this.touches[1].clientY};var newTouch2={x:e.touches[1].clientX,y:e.touches[1].clientY};var oldL=Math.sqrt(Math.pow(oldTouch1.x-oldTouch2.x,2)+Math.pow(oldTouch1.y-oldTouch2.y,2));var newL=Math.sqrt(Math.pow(newTouch1.x-newTouch2.x,2)+Math.pow(newTouch1.y-newTouch2.y,2));var cha=newL-oldL;var coe=1;coe=coe/this.trueWidth>coe/this.trueHeight?coe/this.trueHeight:coe/this.trueWidth;coe=coe>0.1?0.1:coe;var num=coe*cha;if(!this.touchNow){this.touchNow=true;if(cha>0){scale+=Math.abs(num);}else if(cha<0){scale>Math.abs(num)?scale-=Math.abs(num):scale;}this.touches=e.touches;setTimeout(function(){_this3.touchNow=false;},8);if(!this.checkoutImgAxis(this.x,this.y,scale)){return false;}this.scale=scale;}},cancelTouchScale:function cancelTouchScale(e){window.removeEventListener("touchmove",this.touchScale);},moveImg:function moveImg(e){var _this4=this;e.preventDefault();if(e.touches&&e.touches.length===2){this.touches=e.touches;window.addEventListener("touchmove",this.touchScale);window.addEventListener("touchend",this.cancelTouchScale);window.removeEventListener("touchmove",this.moveImg);return false;}var nowX="clientX"in e?e.clientX:e.touches[0].clientX;var nowY="clientY"in e?e.clientY:e.touches[0].clientY;var changeX,changeY;changeX=nowX-this.moveX;changeY=nowY-this.moveY;this.$nextTick(function(){if(_this4.centerBox){var axis=_this4.getImgAxis(changeX,changeY,_this4.scale);var cropAxis=_this4.getCropAxis();var imgW=_this4.trueHeight*_this4.scale;var imgH=_this4.trueWidth*_this4.scale;var maxLeft,maxTop,maxRight,maxBottom;switch(_this4.rotate){case 1:case-1:case 3:case-3:maxLeft=_this4.cropOffsertX-_this4.trueWidth*(1-_this4.scale)/2+(imgW-imgH)/2;maxTop=_this4.cropOffsertY-_this4.trueHeight*(1-_this4.scale)/2+(imgH-imgW)/2;maxRight=maxLeft-imgW+_this4.cropW;maxBottom=maxTop-imgH+_this4.cropH;break;default:maxLeft=_this4.cropOffsertX-_this4.trueWidth*(1-_this4.scale)/2;maxTop=_this4.cropOffsertY-_this4.trueHeight*(1-_this4.scale)/2;maxRight=maxLeft-imgH+_this4.cropW;maxBottom=maxTop-imgW+_this4.cropH;break;}if(axis.x1>=cropAxis.x1){changeX=maxLeft;}if(axis.y1>=cropAxis.y1){changeY=maxTop;}if(axis.x2<=cropAxis.x2){changeX=maxRight;}if(axis.y2<=cropAxis.y2){changeY=maxBottom;}}_this4.x=changeX;_this4.y=changeY;_this4.$emit("imgMoving",{moving:true,axis:_this4.getImgAxis()});_this4.$emit("img-moving",{moving:true,axis:_this4.getImgAxis()});});},leaveImg:function leaveImg(e){window.removeEventListener("mousemove",this.moveImg);window.removeEventListener("touchmove",this.moveImg);window.removeEventListener("mouseup",this.leaveImg);window.removeEventListener("touchend",this.leaveImg);this.$emit("imgMoving",{moving:false,axis:this.getImgAxis()});this.$emit("img-moving",{moving:false,axis:this.getImgAxis()});},scaleImg:function scaleImg(){if(this.canScale){window.addEventListener(this.support,this.changeSize,this.passive);}},cancelScale:function cancelScale(){if(this.canScale){window.removeEventListener(this.support,this.changeSize);}},changeSize:function changeSize(e){var _this5=this;e.preventDefault();var scale=this.scale;var change=e.deltaY||e.wheelDelta;var isFirefox=navigator.userAgent.indexOf("Firefox");change=isFirefox>0?change*30:change;if(this.isIE){change=-change;}var coe=this.coe;coe=coe/this.trueWidth>coe/this.trueHeight?coe/this.trueHeight:coe/this.trueWidth;var num=coe*change;num<0?scale+=Math.abs(num):scale>Math.abs(num)?scale-=Math.abs(num):scale;var status=num<0?"add":"reduce";if(status!==this.coeStatus){this.coeStatus=status;this.coe=0.2;}if(!this.scaling){this.scalingSet=setTimeout(function(){_this5.scaling=false;_this5.coe=_this5.coe+=0.01;},50);}this.scaling=true;if(!this.checkoutImgAxis(this.x,this.y,scale)){return false;}this.scale=scale;},changeScale:function changeScale(num){var scale=this.scale;num=num||1;var coe=20;coe=coe/this.trueWidth>coe/this.trueHeight?coe/this.trueHeight:coe/this.trueWidth;num=num*coe;num>0?scale+=Math.abs(num):scale>Math.abs(num)?scale-=Math.abs(num):scale;if(!this.checkoutImgAxis(this.x,this.y,scale)){return false;}this.scale=scale;},createCrop:function createCrop(e){var _this6=this;e.preventDefault();var nowX="clientX"in e?e.clientX:e.touches?e.touches[0].clientX:0;var nowY="clientY"in e?e.clientY:e.touches?e.touches[0].clientY:0;this.$nextTick(function(){var fw=nowX-_this6.cropX;var fh=nowY-_this6.cropY;if(fw>0){_this6.cropW=fw+_this6.cropChangeX>_this6.w?_this6.w-_this6.cropChangeX:fw;_this6.cropOffsertX=_this6.cropChangeX;}else{_this6.cropW=_this6.w-_this6.cropChangeX+Math.abs(fw)>_this6.w?_this6.cropChangeX:Math.abs(fw);_this6.cropOffsertX=_this6.cropChangeX+fw>0?_this6.cropChangeX+fw:0;}if(!_this6.fixed){if(fh>0){_this6.cropH=fh+_this6.cropChangeY>_this6.h?_this6.h-_this6.cropChangeY:fh;_this6.cropOffsertY=_this6.cropChangeY;}else{_this6.cropH=_this6.h-_this6.cropChangeY+Math.abs(fh)>_this6.h?_this6.cropChangeY:Math.abs(fh);_this6.cropOffsertY=_this6.cropChangeY+fh>0?_this6.cropChangeY+fh:0;}}else{var fixedHeight=_this6.cropW/_this6.fixedNumber[0]*_this6.fixedNumber[1];if(fixedHeight+_this6.cropOffsertY>_this6.h){_this6.cropH=_this6.h-_this6.cropOffsertY;_this6.cropW=_this6.cropH/_this6.fixedNumber[1]*_this6.fixedNumber[0];if(fw>0){_this6.cropOffsertX=_this6.cropChangeX;}else{_this6.cropOffsertX=_this6.cropChangeX-_this6.cropW;}}else{_this6.cropH=fixedHeight;}_this6.cropOffsertY=_this6.cropOffsertY;}});},changeCropSize:function changeCropSize(e,w,h,typeW,typeH){e.preventDefault();window.addEventListener("mousemove",this.changeCropNow);window.addEventListener("mouseup",this.changeCropEnd);window.addEventListener("touchmove",this.changeCropNow);window.addEventListener("touchend",this.changeCropEnd);this.canChangeX=w;this.canChangeY=h;this.changeCropTypeX=typeW;this.changeCropTypeY=typeH;this.cropX="clientX"in e?e.clientX:e.touches[0].clientX;this.cropY="clientY"in e?e.clientY:e.touches[0].clientY;this.cropOldW=this.cropW;this.cropOldH=this.cropH;this.cropChangeX=this.cropOffsertX;this.cropChangeY=this.cropOffsertY;if(this.fixed){if(this.canChangeX&&this.canChangeY){this.canChangeY=0;}}this.$emit("change-crop-size",{width:this.cropW,height:this.cropH});},changeCropNow:function changeCropNow(e){var _this7=this;e.preventDefault();var nowX="clientX"in e?e.clientX:e.touches?e.touches[0].clientX:0;var nowY="clientY"in e?e.clientY:e.touches?e.touches[0].clientY:0;var wrapperW=this.w;var wrapperH=this.h;var minX=0;var minY=0;if(this.centerBox){var axis=this.getImgAxis();var imgW=axis.x2;var imgH=axis.y2;minX=axis.x1>0?axis.x1:0;minY=axis.y1>0?axis.y1:0;if(wrapperW>imgW){wrapperW=imgW;}if(wrapperH>imgH){wrapperH=imgH;}}this.$nextTick(function(){var fw=nowX-_this7.cropX;var fh=nowY-_this7.cropY;if(_this7.canChangeX){if(_this7.changeCropTypeX===1){if(_this7.cropOldW-fw>0){_this7.cropW=wrapperW-_this7.cropChangeX-fw<=wrapperW-minX?_this7.cropOldW-fw:_this7.cropOldW+_this7.cropChangeX-minX;_this7.cropOffsertX=wrapperW-_this7.cropChangeX-fw<=wrapperW-minX?_this7.cropChangeX+fw:minX;}else{_this7.cropW=Math.abs(fw)+_this7.cropChangeX<=wrapperW?Math.abs(fw)-_this7.cropOldW:wrapperW-_this7.cropOldW-_this7.cropChangeX;_this7.cropOffsertX=_this7.cropChangeX+_this7.cropOldW;}}else if(_this7.changeCropTypeX===2){if(_this7.cropOldW+fw>0){_this7.cropW=_this7.cropOldW+fw+_this7.cropOffsertX<=wrapperW?_this7.cropOldW+fw:wrapperW-_this7.cropOffsertX;_this7.cropOffsertX=_this7.cropChangeX;}else{_this7.cropW=wrapperW-_this7.cropChangeX+Math.abs(fw+_this7.cropOldW)<=wrapperW-minX?Math.abs(fw+_this7.cropOldW):_this7.cropChangeX-minX;_this7.cropOffsertX=wrapperW-_this7.cropChangeX+Math.abs(fw+_this7.cropOldW)<=wrapperW-minX?_this7.cropChangeX-Math.abs(fw+_this7.cropOldW):minX;}}}if(_this7.canChangeY){if(_this7.changeCropTypeY===1){if(_this7.cropOldH-fh>0){_this7.cropH=wrapperH-_this7.cropChangeY-fh<=wrapperH-minY?_this7.cropOldH-fh:_this7.cropOldH+_this7.cropChangeY-minY;_this7.cropOffsertY=wrapperH-_this7.cropChangeY-fh<=wrapperH-minY?_this7.cropChangeY+fh:minY;}else{_this7.cropH=Math.abs(fh)+_this7.cropChangeY<=wrapperH?Math.abs(fh)-_this7.cropOldH:wrapperH-_this7.cropOldH-_this7.cropChangeY;_this7.cropOffsertY=_this7.cropChangeY+_this7.cropOldH;}}else if(_this7.changeCropTypeY===2){if(_this7.cropOldH+fh>0){_this7.cropH=_this7.cropOldH+fh+_this7.cropOffsertY<=wrapperH?_this7.cropOldH+fh:wrapperH-_this7.cropOffsertY;_this7.cropOffsertY=_this7.cropChangeY;}else{_this7.cropH=wrapperH-_this7.cropChangeY+Math.abs(fh+_this7.cropOldH)<=wrapperH-minY?Math.abs(fh+_this7.cropOldH):_this7.cropChangeY-minY;_this7.cropOffsertY=wrapperH-_this7.cropChangeY+Math.abs(fh+_this7.cropOldH)<=wrapperH-minY?_this7.cropChangeY-Math.abs(fh+_this7.cropOldH):minY;}}}if(_this7.canChangeX&&_this7.fixed){var fixedHeight=_this7.cropW/_this7.fixedNumber[0]*_this7.fixedNumber[1];if(fixedHeight+_this7.cropOffsertY>wrapperH){_this7.cropH=wrapperH-_this7.cropOffsertY;_this7.cropW=_this7.cropH/_this7.fixedNumber[1]*_this7.fixedNumber[0];}else{_this7.cropH=fixedHeight;}}if(_this7.canChangeY&&_this7.fixed){var fixedWidth=_this7.cropH/_this7.fixedNumber[1]*_this7.fixedNumber[0];if(fixedWidth+_this7.cropOffsertX>wrapperW){_this7.cropW=wrapperW-_this7.cropOffsertX;_this7.cropH=_this7.cropW/_this7.fixedNumber[0]*_this7.fixedNumber[1];}else{_this7.cropW=fixedWidth;}}});},checkCropLimitSize:function checkCropLimitSize(){var cropW=this.cropW,cropH=this.cropH,limitMinSize=this.limitMinSize;var limitMinNum=new Array();if(!Array.isArray[limitMinSize]){limitMinNum=[limitMinSize,limitMinSize];}else{limitMinNum=limitMinSize;}cropW=parseFloat(limitMinNum[0]);cropH=parseFloat(limitMinNum[1]);return[cropW,cropH];},changeCropEnd:function changeCropEnd(e){window.removeEventListener("mousemove",this.changeCropNow);window.removeEventListener("mouseup",this.changeCropEnd);window.removeEventListener("touchmove",this.changeCropNow);window.removeEventListener("touchend",this.changeCropEnd);},endCrop:function endCrop(){if(this.cropW===0&&this.cropH===0){this.cropping=false;}window.removeEventListener("mousemove",this.createCrop);window.removeEventListener("mouseup",this.endCrop);window.removeEventListener("touchmove",this.createCrop);window.removeEventListener("touchend",this.endCrop);},startCrop:function startCrop(){this.crop=true;},stopCrop:function stopCrop(){this.crop=false;},clearCrop:function clearCrop(){this.cropping=false;this.cropW=0;this.cropH=0;},cropMove:function cropMove(e){e.preventDefault();if(!this.canMoveBox){this.crop=false;this.startMove(e);return false;}if(e.touches&&e.touches.length===2){this.crop=false;this.startMove(e);this.leaveCrop();return false;}window.addEventListener("mousemove",this.moveCrop);window.addEventListener("mouseup",this.leaveCrop);window.addEventListener("touchmove",this.moveCrop);window.addEventListener("touchend",this.leaveCrop);var x="clientX"in e?e.clientX:e.touches[0].clientX;var y="clientY"in e?e.clientY:e.touches[0].clientY;var newX,newY;newX=x-this.cropOffsertX;newY=y-this.cropOffsertY;this.cropX=newX;this.cropY=newY;this.$emit("cropMoving",{moving:true,axis:this.getCropAxis()});this.$emit("crop-moving",{moving:true,axis:this.getCropAxis()});},moveCrop:function moveCrop(e,isMove){var _this8=this;var nowX=0;var nowY=0;if(e){e.preventDefault();nowX="clientX"in e?e.clientX:e.touches[0].clientX;nowY="clientY"in e?e.clientY:e.touches[0].clientY;}this.$nextTick(function(){var cx,cy;var fw=nowX-_this8.cropX;var fh=nowY-_this8.cropY;if(isMove){fw=_this8.cropOffsertX;fh=_this8.cropOffsertY;}if(fw<=0){cx=0;}else if(fw+_this8.cropW>_this8.w){cx=_this8.w-_this8.cropW;}else{cx=fw;}if(fh<=0){cy=0;}else if(fh+_this8.cropH>_this8.h){cy=_this8.h-_this8.cropH;}else{cy=fh;}if(_this8.centerBox){var axis=_this8.getImgAxis();if(cx<=axis.x1){cx=axis.x1;}if(cx+_this8.cropW>axis.x2){cx=axis.x2-_this8.cropW;}if(cy<=axis.y1){cy=axis.y1;}if(cy+_this8.cropH>axis.y2){cy=axis.y2-_this8.cropH;}}_this8.cropOffsertX=cx;_this8.cropOffsertY=cy;_this8.$emit("cropMoving",{moving:true,axis:_this8.getCropAxis()});_this8.$emit("crop-moving",{moving:true,axis:_this8.getCropAxis()});});},getImgAxis:function getImgAxis(x,y,scale){x=x||this.x;y=y||this.y;scale=scale||this.scale;var obj={x1:0,x2:0,y1:0,y2:0};var imgW=this.trueWidth*scale;var imgH=this.trueHeight*scale;switch(this.rotate){case 0:obj.x1=x+this.trueWidth*(1-scale)/2;obj.x2=obj.x1+this.trueWidth*scale;obj.y1=y+this.trueHeight*(1-scale)/2;obj.y2=obj.y1+this.trueHeight*scale;break;case 1:case-1:case 3:case-3:obj.x1=x+this.trueWidth*(1-scale)/2+(imgW-imgH)/2;obj.x2=obj.x1+this.trueHeight*scale;obj.y1=y+this.trueHeight*(1-scale)/2+(imgH-imgW)/2;obj.y2=obj.y1+this.trueWidth*scale;break;default:obj.x1=x+this.trueWidth*(1-scale)/2;obj.x2=obj.x1+this.trueWidth*scale;obj.y1=y+this.trueHeight*(1-scale)/2;obj.y2=obj.y1+this.trueHeight*scale;break;}return obj;},getCropAxis:function getCropAxis(){var obj={x1:0,x2:0,y1:0,y2:0};obj.x1=this.cropOffsertX;obj.x2=obj.x1+this.cropW;obj.y1=this.cropOffsertY;obj.y2=obj.y1+this.cropH;return obj;},leaveCrop:function leaveCrop(e){window.removeEventListener("mousemove",this.moveCrop);window.removeEventListener("mouseup",this.leaveCrop);window.removeEventListener("touchmove",this.moveCrop);window.removeEventListener("touchend",this.leaveCrop);this.$emit("cropMoving",{moving:false,axis:this.getCropAxis()});this.$emit("crop-moving",{moving:false,axis:this.getCropAxis()});},getCropChecked:function getCropChecked(cb){var _this9=this;var canvas=document.createElement("canvas");var img=new Image();var rotate=this.rotate;var trueWidth=this.trueWidth;var trueHeight=this.trueHeight;var cropOffsertX=this.cropOffsertX;var cropOffsertY=this.cropOffsertY;img.onload=function(){if(_this9.cropW!==0){var ctx=canvas.getContext("2d");var dpr=1;if(_this9.high&!_this9.full){dpr=window.devicePixelRatio;}if(_this9.enlarge!==1&!_this9.full){dpr=Math.abs(Number(_this9.enlarge));}var width=_this9.cropW*dpr;var height=_this9.cropH*dpr;var imgW=trueWidth*_this9.scale*dpr;var imgH=trueHeight*_this9.scale*dpr;var dx=(_this9.x-cropOffsertX+_this9.trueWidth*(1-_this9.scale)/2)*dpr;var dy=(_this9.y-cropOffsertY+_this9.trueHeight*(1-_this9.scale)/2)*dpr;setCanvasSize(width,height);ctx.save();switch(rotate){case 0:if(!_this9.full){ctx.drawImage(img,dx,dy,imgW,imgH);}else{setCanvasSize(width/_this9.scale,height/_this9.scale);ctx.drawImage(img,dx/_this9.scale,dy/_this9.scale,imgW/_this9.scale,imgH/_this9.scale);}break;case 1:case-3:if(!_this9.full){dx=dx+(imgW-imgH)/2;dy=dy+(imgH-imgW)/2;ctx.rotate(rotate*90*Math.PI/180);ctx.drawImage(img,dy,-dx-imgH,imgW,imgH);}else{setCanvasSize(width/_this9.scale,height/_this9.scale);dx=dx/_this9.scale+(imgW/_this9.scale-imgH/_this9.scale)/2;dy=dy/_this9.scale+(imgH/_this9.scale-imgW/_this9.scale)/2;ctx.rotate(rotate*90*Math.PI/180);ctx.drawImage(img,dy,-dx-imgH/_this9.scale,imgW/_this9.scale,imgH/_this9.scale);}break;case 2:case-2:if(!_this9.full){ctx.rotate(rotate*90*Math.PI/180);ctx.drawImage(img,-dx-imgW,-dy-imgH,imgW,imgH);}else{setCanvasSize(width/_this9.scale,height/_this9.scale);ctx.rotate(rotate*90*Math.PI/180);dx=dx/_this9.scale;dy=dy/_this9.scale;ctx.drawImage(img,-dx-imgW/_this9.scale,-dy-imgH/_this9.scale,imgW/_this9.scale,imgH/_this9.scale);}break;case 3:case-1:if(!_this9.full){dx=dx+(imgW-imgH)/2;dy=dy+(imgH-imgW)/2;ctx.rotate(rotate*90*Math.PI/180);ctx.drawImage(img,-dy-imgW,dx,imgW,imgH);}else{setCanvasSize(width/_this9.scale,height/_this9.scale);dx=dx/_this9.scale+(imgW/_this9.scale-imgH/_this9.scale)/2;dy=dy/_this9.scale+(imgH/_this9.scale-imgW/_this9.scale)/2;ctx.rotate(rotate*90*Math.PI/180);ctx.drawImage(img,-dy-imgW/_this9.scale,dx,imgW/_this9.scale,imgH/_this9.scale);}break;default:if(!_this9.full){ctx.drawImage(img,dx,dy,imgW,imgH);}else{setCanvasSize(width/_this9.scale,height/_this9.scale);ctx.drawImage(img,dx/_this9.scale,dy/_this9.scale,imgW/_this9.scale,imgH/_this9.scale);}}ctx.restore();}else{var _width=trueWidth*_this9.scale;var _height=trueHeight*_this9.scale;var _ctx2=canvas.getContext("2d");_ctx2.save();switch(rotate){case 0:setCanvasSize(_width,_height);_ctx2.drawImage(img,0,0,_width,_height);break;case 1:case-3:setCanvasSize(_height,_width);_ctx2.rotate(rotate*90*Math.PI/180);_ctx2.drawImage(img,0,-_height,_width,_height);break;case 2:case-2:setCanvasSize(_width,_height);_ctx2.rotate(rotate*90*Math.PI/180);_ctx2.drawImage(img,-_width,-_height,_width,_height);break;case 3:case-1:setCanvasSize(_height,_width);_ctx2.rotate(rotate*90*Math.PI/180);_ctx2.drawImage(img,-_width,0,_width,_height);break;default:setCanvasSize(_width,_height);_ctx2.drawImage(img,0,0,_width,_height);}_ctx2.restore();}cb(canvas);};var s=this.img.substr(0,4);if(s!=="data"){img.crossOrigin="Anonymous";}img.src=this.imgs;function setCanvasSize(width,height){canvas.width=Math.round(width);canvas.height=Math.round(height);}},getCropData:function getCropData(cb){var _this10=this;this.getCropChecked(function(data){cb(data.toDataURL("image/"+_this10.outputType,_this10.outputSize));});},getCropBlob:function getCropBlob(cb){var _this11=this;this.getCropChecked(function(data){data.toBlob(function(blob){return cb(blob);},"image/"+_this11.outputType,_this11.outputSize);});},showPreview:function showPreview(){var _this12=this;if(this.isCanShow){this.isCanShow=false;setTimeout(function(){_this12.isCanShow=true;},16);}else{return false;}var w=this.cropW;var h=this.cropH;var scale=this.scale;var obj={};obj.div={width:"".concat(w,"px"),height:"".concat(h,"px")};var transformX=(this.x-this.cropOffsertX)/scale;var transformY=(this.y-this.cropOffsertY)/scale;var transformZ=0;obj.w=w;obj.h=h;obj.url=this.imgs;obj.img={width:"".concat(this.trueWidth,"px"),height:"".concat(this.trueHeight,"px"),transform:"scale(".concat(scale,")translate3d(").concat(transformX,"px, ").concat(transformY,"px, ").concat(transformZ,"px)rotateZ(").concat(this.rotate*90,"deg)")};obj.html="\n
\n
\n \n
\n
");this.$emit("realTime",obj);this.$emit("real-time",obj);},reload:function reload(){var _this13=this;var img=new Image();img.onload=function(){_this13.w=parseFloat(window.getComputedStyle(_this13.$refs.cropper).width);_this13.h=parseFloat(window.getComputedStyle(_this13.$refs.cropper).height);_this13.trueWidth=img.width;_this13.trueHeight=img.height;if(!_this13.original){_this13.scale=_this13.checkedMode();}else{_this13.scale=1;}_this13.$nextTick(function(){_this13.x=-(_this13.trueWidth-_this13.trueWidth*_this13.scale)/2+(_this13.w-_this13.trueWidth*_this13.scale)/2;_this13.y=-(_this13.trueHeight-_this13.trueHeight*_this13.scale)/2+(_this13.h-_this13.trueHeight*_this13.scale)/2;_this13.loading=false;if(_this13.autoCrop){_this13.goAutoCrop();}_this13.$emit("img-load","success");_this13.$emit("imgLoad","success");setTimeout(function(){_this13.showPreview();},20);});};img.onerror=function(){_this13.$emit("imgLoad","error");_this13.$emit("img-load","error");};img.src=this.imgs;},checkedMode:function checkedMode(){var scale=1;var imgW=this.trueWidth;var imgH=this.trueHeight;var arr=this.mode.split(" ");switch(arr[0]){case"contain":if(this.trueWidth>this.w){scale=this.w/this.trueWidth;}if(this.trueHeight*scale>this.h){scale=this.h/this.trueHeight;}break;case"cover":imgW=this.w;scale=imgW/this.trueWidth;imgH=imgH*scale;if(imgH0;var imgW=(switchWH?this.trueHeight:this.trueWidth)*this.scale;var imgH=(switchWH?this.trueWidth:this.trueHeight)*this.scale;maxWidth=imgWmaxWidth?maxWidth:w;h=h>maxHeight?maxHeight:h;if(this.fixed){h=w/this.fixedNumber[0]*this.fixedNumber[1];}if(h>this.h){h=this.h;w=h/this.fixedNumber[1]*this.fixedNumber[0];}this.changeCrop(w,h);},changeCrop:function changeCrop(w,h){var _this14=this;if(this.centerBox){var axis=this.getImgAxis();if(w>axis.x2-axis.x1){w=axis.x2-axis.x1;h=w/this.fixedNumber[0]*this.fixedNumber[1];}if(h>axis.y2-axis.y1){h=axis.y2-axis.y1;w=h/this.fixedNumber[1]*this.fixedNumber[0];}}this.cropW=w;this.cropH=h;this.checkCropLimitSize();this.$nextTick(function(){_this14.cropOffsertX=(_this14.w-_this14.cropW)/2;_this14.cropOffsertY=(_this14.h-_this14.cropH)/2;if(_this14.centerBox){_this14.moveCrop(null,true);}});},refresh:function refresh(){var _this15=this;this.img;this.imgs="";this.scale=1;this.crop=false;this.rotate=0;this.w=0;this.h=0;this.trueWidth=0;this.trueHeight=0;this.clearCrop();this.$nextTick(function(){_this15.checkedImg();});},rotateLeft:function rotateLeft(){this.rotate=this.rotate<=-3?0:this.rotate-1;},rotateRight:function rotateRight(){this.rotate=this.rotate>=3?0:this.rotate+1;},rotateClear:function rotateClear(){this.rotate=0;},checkoutImgAxis:function checkoutImgAxis(x,y,scale){x=x||this.x;y=y||this.y;scale=scale||this.scale;var canGo=true;if(this.centerBox){var axis=this.getImgAxis(x,y,scale);var cropAxis=this.getCropAxis();if(axis.x1>=cropAxis.x1){canGo=false;}if(axis.x2<=cropAxis.x2){canGo=false;}if(axis.y1>=cropAxis.y1){canGo=false;}if(axis.y2<=cropAxis.y2){canGo=false;}}return canGo;}},mounted:function mounted(){this.support="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";var that=this;var u=navigator.userAgent;this.isIOS=!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);if(!HTMLCanvasElement.prototype.toBlob){Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function value(callback,type,quality){var binStr=atob(this.toDataURL(type,quality).split(",")[1]),len=binStr.length,arr=new Uint8Array(len);for(var i=0;i * * javascript: * this.$refs.cropper.loadFile() * * @param file */loadFile:function loadFile(file){var _this16=this;if(file instanceof File){this.onLoadImg(file).then(function(base64){_this16.img=base64;setTimeout(function(){_this16.config.autoCrop=true;_this16.addSlide();},10);});}else{throw new Error('Arguments file is not File');}},/** * * @param base64 */loadBase64:function loadBase64(base64){var _this17=this;if(typeof base64!=='string'){throw new Error('Arguments base64 is not string');}var base=base64.split(',');if(!/^data:image\/(.*?);base64$/.test(base[0])){throw new Error('Arguments base64 MIME is not image/*');}// Base64 Regex @see https://learnku.com/articles/42295 if(!/^[\/]?([\da-zA-Z]+[\/+]+)*[\da-zA-Z]+([+=]{1,2}|[\/])?$/.test(base[1])){throw new Error('Not standard base64');}this.img=base64;setTimeout(function(){_this17.config.autoCrop=true;_this17.addSlide();},10);},rotating:function rotating(e){this.$refs.cropper.rotateRight();// document.getElementsByClassName("cropper-modal")[0].style = "background-color: rgba(0,0,0,0.5);transition: 0.88s"; },canceltailor:function canceltailor(){this.img='';this.onCancelTailor();},tailoring:function tailoring(){var _this18=this;this.$refs.cropper.getCropData(function(data){_this18.getBase64Data(data);_this18.getBlob(data);_this18.img='';_this18.config.autoCrop=false;})// 获取截图的blob数据 ;this.$refs.cropper.getCropBlob(function(data){_this18.getBase64Data(data);_this18.getBlob(data);// Blob 转 File var suffix={jpeg:'jpg',png:'png',webp:'webp'}[_this18.config.outputType];var time=new Date().getTime();var file=new File([data],"".concat(time,".").concat(suffix),{type:"image/".concat(_this18.config.outputType)});_this18.getFile(file);_this18.img='';_this18.config.autoCrop=false;});},upPhoto:function upPhoto(e){var _this19=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(){var photoUrl;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:photoUrl=e.target.files[0];_this19.$refs.headInput.value=null;if(!(photoUrl!=undefined)){_context.next=9;break;}_this19.imgOriginF(photoUrl);_context.next=6;return _this19.onLoadImg(photoUrl);case 6:_this19.img=_context.sent;_this19.config.autoCrop=true;setTimeout(function(){_this19.addSlide();},20);case 9:case"end":return _context.stop();}}},_callee);}))();},onCropMoving:function onCropMoving(e){// console.log('onCropMoving') },onImgMoving:function onImgMoving(e){// console.log('onCropMoving') }},render:function render(){return createVNode("div",{"class":[styles.upbtn,styles.uploadWarper]},[this.hideInput,!this.hideInput?createVNode("input",{"style":"opacity: 0;","class":styles.upbtn,"type":"file","accept":"image/*","onChange":this.upPhoto,"ref":"headInput"},null):null,this.img!=''?createVNode("div",{"class":styles.bg},[this.config.ceilbutton?createVNode("div",{"class":styles.btndiv},[createVNode("div",{"class":styles.btn,"onClick":this.canceltailor,"style":{backgroundColor:this.config.cancelButtonBackgroundColor,color:this.config.cancelButtonTextColor}},[this.config.cancelButtonText]),createVNode("div",{"class":styles.img,"onClick":this.rotating},null),createVNode("div",{"class":styles.btn,"onClick":this.tailoring,"style":{backgroundColor:this.config.confirmButtonBackgroundColor,color:this.config.confirmButtonTextColor}},[this.config.confirmButtonText])]):null,createVNode("div",{"class":styles.wrapper},[createVNode(VueCropper,{"ref":"cropper","img":this.img,"outputSize":this.config.outputSize,"outputType":this.config.outputType,"info":this.config.info,"canScale":this.config.canScale,"autoCrop":this.config.autoCrop,"autoCropWidth":this.config.autoCropWidth,"autoCropHeight":this.config.autoCropHeight,"fixedBox":this.config.fixedBox,"fixed":this.config.fixed,"fixedNumber":this.config.fixedNumber,"full":this.config.full,"canMove":this.config.canMove,"canMoveBox":this.config.canMoveBox,"original":this.config.original,"centerBox":this.config.centerBox,"high":this.config.high,"infoTrue":this.config.infoTrue,"maxImgSize":this.config.maxImgSize,"enlarge":this.config.enlarge,"mode":this.config.mode,"onCropMoving":this.onCropMoving,"onImgMoving":this.onImgMoving},null)]),!this.config.ceilbutton?createVNode("div",{"class":styles.btndiv},[createVNode("div",{"class":styles.btn,"onClick":this.canceltailor,"style":{backgroundColor:this.config.cancelButtonBackgroundColor,color:this.config.cancelButtonTextColor}},[this.config.cancelButtonText]),createVNode("div",{"class":styles.img,"onClick":this.rotating},null),createVNode("div",{"class":styles.btn,"onClick":this.tailoring,"style":{backgroundColor:this.config.confirmButtonBackgroundColor,color:this.config.confirmButtonTextColor}},[this.config.confirmButtonText])]):null]):null]);}});var iconUploader="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAcCAYAAAAAwr0iAAAAAXNSR0IArs4c6QAABCZJREFUSEu1ll1oXEUUx/9nbjbsRkRFq4l2d+/M3WhwFaukRUpFoT4oluJDG/EDQYr4poK2IOqLbf2IIOJjlWgJgopWiiCCloAifgTFaKOG7L1z65YQIrQS2+wm2TtHJtxdwtps7rpxnu5lzvnPb87HzBD+5xGG4b4oil4XQnw+Pj6+d2hoKFq9JLVav1wuX7O8vHwYQJGIWtpaHWZeYOZ3PM8bqesGQfA7gOvi/5uUUj8nAmBmobWeAHBDu0ESQjzkuu671i8IAg3Atd9dXV3bcrnceCIA3/d3ENFX7SzOzD4RHSei76WU73cEEIbhsDFmfxsAJ4hoFxH1GWM21f2I6GNmvtr+E9EjzPxrPLcopfylkdcwDLcbY+4AcFFs8DCAzUkBmHkrgGuJaBSASOJn4WhsbKzLdd2jzPxAEqe1bNLp9KZKpTJsd9mGznkKguBZAIfacFrLdCiKoknHcUaI6Mq6ETPbKKbi/xkiWow7ZlkIMUxaa5+ZVZsAzMwREXWtyvVsFEV7CoXC16u11u2CIAjswZAkZ5b8CDOPVqvViWKxuKS17jXG7CSipwFsISILdpqIzhljtOd59zQDzM3N/TQ4OLjcAA+CgBPs3h4m9yqlpi5ky8w2ks8AOFjfDBH9JqW8vhkgm81OENFSYgC7IyHEVinlbJw7USqVtqRSqUtrtdrJQqEwVxfTWh9g5ldiu9Oe52V93/+OiLYBMETkLSwszBeLxTOJARzH2Z3P5z+xDrZVoyg6SkSFWMDWwZu1Wu3J/v7+leIKguAbALfab2PMDmY+K4SwKfpCCHHMGHO/53lvJwU4qZS60Rr7vt9PRD8AuLg5DUQ0IqXcFwPsBnA8PnhmmfnxdDo9VqlUXCJ6GcC3SqnnEgEw82ue5z0VCx8B8Oga9WKEEAXXdfXMzEzP4uLiPDM7a9geTgxARE9IKd+wQlrrH5n55hYFu1cp9WEMa+vlqo4BABxQSr0ai34J4La1AIjobinlZ7HtXwAu2QiAUaWUvRNscdlCWoG5wDjT09OT6+3tPV8qlbJCiD9aRCp5CgCcXVpayg8MDPyttU4DOMHM25vEawAeVEp9EKeq0YobEQGr8aJSyt4XKJfLmVqttp+Z9zDzZUQ04TjOS/l8fuX4nZqauiKVStlD6/KNioC9w22vD7mue6yFKGz1V6vVTwHc3soOQFspqGtFzHywu7t7OJvNVpoXmJ6evsVxnLcAtOqSutt/Aqg72/ayrTYhhLAP0M3MvBPAnQkvNKvzL4Ckt+E6kU08fUgp9Xzd2j5ITgHIJXbv0JCIHpNS2lN1ZVAYhi8YYxpEHeqv5z6fyWQKfX19fzYAJicnuzOZzEcAdq3n3eH8OSHEfa7r2k5pjMarWGt9l30VE1H9Vdzheg13w8ynUqnUe7lcbqZZ9B/GxP8H1HlPxgAAAABJRU5ErkJggg==";var ColUpload=exports('C',defineComponent({name:'col-upload',props:{modelValue:String,tips:{type:String,default:'点击上传'},deletable:{type:Boolean,default:true},native:{// 是否原生上传 type:Boolean,default:false},cropper:{// 是否进行裁切 type:Boolean,default:false},options:{// 裁切需要参数 type:Object,default:{}},uploadSize:{// 上传图片大小 type:Number,default:5},onUploadChange:{type:Function,default:function _default(url){}},bucket:{type:String,default:'daya'}},methods:{nativeUpload:function nativeUpload(){var _this20=this;postMessage({api:'chooseFile',content:{type:'img',max:1,bucket:this.bucket}},function(res){console.log(res,'fileUrl');_this20.$emit('update:modelValue',res.fileUrl);});},beforeRead:function beforeRead(file){console.log(file,'beforeRead');var isLt2M=file.size/1024/1024