New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

image-process

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-process - npm Package Compare versions

Comparing version 3.3.7 to 3.3.8

.babelrc

17

build/webpack/_base.js

@@ -26,10 +26,11 @@ /**

// include: path.resolve(__dirname, 'src'),
query: {
presets: [
[
'env',
{ modules: false }
],
'stage-2'
]
},
{
enforce: 'pre',
test: /\.jsx?$/,
loader: 'eslint-loader',
exclude: /node_modules/,
options: {
extensions: ['js', 'vue', 'jsx'],
fix: true
}

@@ -36,0 +37,0 @@ },

/*!
* image-process v3.3.7
* image-process v3.3.8
* https://github.com/capricorncd/image-process-tools
* Copyright © 2017-present, capricorncd
* Released under the MIT License
* Released on: 2019-02-14 00:06:11
* Released on: 2020-09-06 00:33:29
*/
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(window,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){var i=n(1);"string"==typeof i&&(i=[[t.i,i,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(3)(i,r);i.locals&&(t.exports=i.locals)},function(t,e,n){(t.exports=n(2)(!1)).push([t.i,".zx-image-crop-container{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,0.95);}.zx-image-crop-container *{margin:0;padding:0}.zx-image-crop-container .__close{position:absolute;z-index:5;top:0;right:0;width:64px;height:64px;cursor:pointer;transition:all .5s;opacity:.6;-webkit-transform:rotate(45deg);transform:rotate(45deg);}.zx-image-crop-container .__close:before,.zx-image-crop-container .__close:after{content:'';position:absolute;background-color:#fff;border-radius:2px}.zx-image-crop-container .__close:before{top:31px;left:16px;width:32px;height:2px}.zx-image-crop-container .__close:after{top:16px;left:31px;width:2px;height:32px}.zx-image-crop-container .__close:hover{-webkit-transform:rotate(225deg);transform:rotate(225deg);opacity:.8}.zx-image-crop-container .zx-image-crop-wrapper{position:absolute;z-index:2;top:0;left:0;width:100%;height:100%;cursor:move;}.zx-image-crop-container .zx-image-crop-wrapper .crop-line-box{position:absolute;margin:0 auto;border-style:solid;border-color:rgba(0,0,0,0.5);box-sizing:content-box}.zx-image-crop-container .zx-image-target{position:absolute;z-index:1;top:0;left:0;}.zx-image-crop-container .zx-image-target.is-move{transition:-webkit-transform 0s;transition:transform 0s;transition:transform 0s, -webkit-transform 0s}.zx-image-crop-container .zx-crop-btns-wrapper{position:absolute;z-index:3;left:50%;width:100%;text-align:center;-webkit-transform:translateX(-50%);transform:translateX(-50%);}.zx-image-crop-container .zx-crop-btns-wrapper button{display:inline-block;padding:0 20px;height:32px;border-radius:4px;color:#fff;border:0;background-color:#4169e1;cursor:pointer;box-shadow:0 5px 10px rgba(0,0,0,0.5);}.zx-image-crop-container .zx-crop-btns-wrapper button.__submit{margin-left:10px}.zx-image-crop-container .zx-crop-btns-wrapper button.__rotate{margin-right:10px;background-color:#666}",""])},function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",i=t[3];if(!i)return n;if(e&&"function"==typeof btoa){var r=(a=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),o=i.sources.map(function(t){return"/*# sourceURL="+i.sourceRoot+t+" */"});return[n].concat(o).concat([r]).join("\n")}var a;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var i={},r=0;r<this.length;r++){var o=this[r][0];"number"==typeof o&&(i[o]=!0)}for(r=0;r<t.length;r++){var a=t[r];"number"==typeof a[0]&&i[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),e.push(a))}},e}},function(t,e,n){var i,r,o={},a=(i=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===r&&(r=i.apply(this,arguments)),r}),s=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var i=function(t,e){return e?e.querySelector(t):document.querySelector(t)}.call(this,t,n);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}e[t]=i}return e[t]}}(),c=null,l=0,u=[],h=n(4);function d(t,e){for(var n=0;n<t.length;n++){var i=t[n],r=o[i.id];if(r){r.refs++;for(var a=0;a<r.parts.length;a++)r.parts[a](i.parts[a]);for(;a<i.parts.length;a++)r.parts.push(y(i.parts[a],e))}else{var s=[];for(a=0;a<i.parts.length;a++)s.push(y(i.parts[a],e));o[i.id]={id:i.id,refs:1,parts:s}}}}function f(t,e){for(var n=[],i={},r=0;r<t.length;r++){var o=t[r],a=e.base?o[0]+e.base:o[0],s={css:o[1],media:o[2],sourceMap:o[3]};i[a]?i[a].parts.push(s):n.push(i[a]={id:a,parts:[s]})}return n}function p(t,e){var n=s(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var i=u[u.length-1];if("top"===t.insertAt)i?i.nextSibling?n.insertBefore(e,i.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),u.push(e);else if("bottom"===t.insertAt)n.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var r=s(t.insertAt.before,n);n.insertBefore(e,r)}}function g(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=u.indexOf(t);e>=0&&u.splice(e,1)}function v(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var i=function(){0;return n.nc}();i&&(t.attrs.nonce=i)}return m(e,t.attrs),p(t,e),e}function m(t,e){Object.keys(e).forEach(function(n){t.setAttribute(n,e[n])})}function y(t,e){var n,i,r,o;if(e.transform&&t.css){if(!(o="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=o}if(e.singleton){var a=l++;n=c||(c=v(e)),i=x.bind(null,n,a,!1),r=x.bind(null,n,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",m(e,t.attrs),p(t,e),e}(e),i=function(t,e,n){var i=n.css,r=n.sourceMap,o=void 0===e.convertToAbsoluteUrls&&r;(e.convertToAbsoluteUrls||o)&&(i=h(i));r&&(i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([i],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}.bind(null,n,e),r=function(){g(n),n.href&&URL.revokeObjectURL(n.href)}):(n=v(e),i=function(t,e){var n=e.css,i=e.media;i&&t.setAttribute("media",i);if(t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}.bind(null,n),r=function(){g(n)});return i(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;i(t=e)}else r()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=f(t,e);return d(n,e),function(t){for(var i=[],r=0;r<n.length;r++){var a=n[r];(s=o[a.id]).refs--,i.push(s)}t&&d(f(t,e),e);for(r=0;r<i.length;r++){var s;if(0===(s=i[r]).refs){for(var c=0;c<s.parts.length;c++)s.parts[c]();delete o[s.id]}}}};var b,w=(b=[],function(t,e){return b[t]=e,b.filter(Boolean).join("\n")});function x(t,e,n,i){var r=n?"":i.css;if(t.styleSheet)t.styleSheet.cssText=w(e,r);else{var o=document.createTextNode(r),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(o,a[e]):t.appendChild(o)}}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,i=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,e){var r,o=e.trim().replace(/^"(.*)"$/,function(t,e){return e}).replace(/^'(.*)'$/,function(t,e){return e});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(o)?t:(r=0===o.indexOf("//")?o:0===o.indexOf("/")?n+o:i+o.replace(/^\.\//,""),"url("+JSON.stringify(r)+")")})}},function(t,e,n){"use strict";n.r(e);var i={broadcast:{},on:function(t,e){t&&"string"==typeof t&&e&&"function"==typeof e&&(this.broadcast[t]||(this.broadcast[t]=[]),this.broadcast[t].push(e))},emit:function(t){var e=this.broadcast[t];if(e)for(var n=Array.prototype.slice.call(arguments,1),i=0;i<e.length;i++)try{e[i].apply(null,n)}catch(e){this.emit("error",{code:1,msg:"emit("+t+"): "+e.message,data:e})}},off:function(t){this.broadcast[t]&&(this.broadcast[t]=null,delete this.broadcast[t])}},r="undefined"==typeof document?{body:{},addEventListener:function(){},removeEventListener:function(){},activeElement:{blur:function(){},nodeName:""},querySelector:function(){return null},querySelectorAll:function(){return[]},getElementById:function(){return null},createEvent:function(){return{initEvent:function(){}}},createElement:function(){return{children:[],childNodes:[],style:{},setAttribute:function(){},getElementsByTagName:function(){return[]}}},location:{hash:""}}:document,o="undefined"==typeof window?{document:r,navigator:{userAgent:""},location:{},history:{},CustomEvent:function(){return this},addEventListener:function(){},removeEventListener:function(){},getComputedStyle:function(){return{getPropertyValue:function(){return""}}},Image:function(){},Date:function(){},screen:{},setTimeout:function(){},clearTimeout:function(){}}:window,a="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},s=navigator.userAgent,c={bitToKib:function(t){return t/1024},conversion:function(t){var e=c.bitToKib(t);return e>=1024?c.int(e/1024*100)/100+"M":c.int(e)+"KB"},toBlobData:function(t,e){var n=function(t){var e=t.split(","),n="";/data:(\w+\/\w+);base64/.test(e[0])&&(n=RegExp.$1);return{type:n,data:e[1]}}(t),i=o.atob(n.data);e=e||n.type;for(var r=new Uint8Array(i.length),a=0;a<i.length;a++)r[a]=i.charCodeAt(a);return new Blob([r],{type:e})},toBlobUrl:function(t){return(o.URL||o.webkitURL).createObjectURL(t)},ratio:function(t,e){return t/e},int:function(t){var e=parseInt(t);return isNaN(e)?0:e},slice:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t.length&&t[0]?Array.prototype.slice.call(t,e):[]},strToHump:function(t){return t?t.toString().replace(/-(\w)/g,function(t,e){return e.toUpperCase()}):""},isAndroid:function(){return s.toLowerCase().indexOf("android")>=0},isArray:function(t){return Array.isArray(t)},isObject:function(t){return t&&"object"===(void 0===t?"undefined":a(t))&&!c.isArray(t)},randomStr:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"zximageprocess")+"_"+ +new Date}};var l=c,u=r,h={createElm:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",e=arguments[1],n=u.createElement(t);if(e&&e instanceof Object)for(var i in e)e.hasOwnProperty(i)&&n.setAttribute(i,e[i]);return n},createVdom:function(t){if(!t)return null;if("string"==typeof t)return u.createTextNode(t);var e=t.tag,n=t.attrs,i=t.child;if(!e&&!n&&!i)return null;var r=h.createElm(e||"div",n);if(Array.isArray(i)&&i.length){var o=void 0;i.forEach(function(t){(o=h.createVdom(t))&&r.appendChild(o)})}else i&&"string"==typeof i&&r.appendChild(u.createTextNode(i));return r},createCanvas:function(t,e){var n=this.createElm("canvas",{width:e.dw,height:e.dh});return n.getContext("2d").drawImage(t,e.sx,e.sy,e.sw,e.sh,e.dx,e.dy,e.dw,e.dh),n},getStyle:function(t,e){if(!h.isHTMLElement(t))return null;var n=o.getComputedStyle(t,null),i=null;if(e)try{i=n[l.strToHump(e)]}catch(t){}else i=n;return i},maxZIndex:function(){for(var t=u.getElementsByTagName("*"),e=void 0,n=void 0,i=void 0,r=[],o=0;o<t.length;o++)1===(e=t[o]).nodeType&&"static"!==(n=h.getStyle(e)||{}).position&&(i=l.int(n.zIndex))>0&&r.push(i);return l.int(Math.max.apply(null,r))},isHTMLElement:function(t){return t&&t instanceof HTMLElement},query:function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:u).querySelector(t)},lock:function(t){void 0===t&&(t=h.query("body")),h.isHTMLElement(t)&&(t.style.overflow="hidden")},unlock:function(t){void 0===t&&(t=h.query("body")),h.isHTMLElement(t)&&(t.style.overflow="")},addEvent:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t&&e&&n)if(t.length)for(var r=0;r<t.length;r++)d(t[r],e,n,i);else d(t,e,n,i)},removeEvent:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t&&e&&n)if(t.length)for(var r=0;r<t.length;r++)f(t[r],e,n,i);else f(t,e,n,i)}};function d(t,e,n,i){t.addEventListener?t.addEventListener(e,n,i):t.attachEvent?t.attachEvent(e,n):t["on"+e]=n}function f(t,e,n,i){t.removeEventListener?t.removeEventListener(e,n,i):t.detachEvent?t.detachEvent(e,n):t["on"+e]=null}var p=h,g={scaleInfo:function(t,e){var n=l.int(t.width),i=l.int(t.height),r=e.width,o=e.height,a=1;return n>0?(a=l.ratio(r,n),i=Math.floor(n*o/r)):i>0&&(a=l.ratio(o,i),n=Math.floor(i*r/o)),{sw:r,sh:o,scaling:a,dw:n,dh:i}},autoCropInfo:function(t,e,n){var i=l.int(n.width),r=l.int(n.height),o=1,a=0,s=0,c=t,u=e,h=t,d=e;return i>0&&r>0?(c=i,u=r,h=i,d=Math.floor(i*e/t),o=l.ratio(t,i),d>=r?(a=0,s=l.int((d-r)/2*o)):(o=l.ratio(e,r),h=Math.floor(r*t/e),a=l.int((h-i)/2*o),s=0)):i>0?(o=l.ratio(t,i),c=i,u=Math.floor(i*e/t)):r>0&&(o=l.ratio(e,r),c=Math.floor(r*t/e),u=r),{sx:a,sy:s,sw:c*o,sh:u*o,scaling:o,cw:c,ch:u}}},v=o.navigator,m=v.msPointerEnabled,y=v.pointerEnabled,b=!!("ontouchstart"in o||o.DocumentTouch&&document instanceof DocumentTouch),w=["mousedown","mousemove","mouseup"];m&&(w=["MSPointerDown","MSPointerMove","MSPointerUp"]),y&&(w=["pointerdown","pointermove","pointerup"]);var x={start:b?"touchstart":w[0],move:b?"touchmove":w[1],end:b?"touchend":w[2]};function E(t,e){return function(t,e){var n=_(t[0],t[1]);return _(e[0],e[1])/n}(e,(n=t.touches,l.slice(n).map(function(t){return{x:t.pageX,y:t.pageY}})));var n}function _(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)}var z=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();var B={width:750,height:750,submitStyle:"",cancelStyle:"",submitText:"确 定",rotateText:"旋转90度"};var k=function(){function t(e){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.cropRatio=1,this.visible=!1,this.$wrapper=null,this.$img=null,this.cropBoxPos={},this.translate={x:0,y:0},this.angle=0,this.options=Object.assign({},B,e),this._init(this.options),p.addEvent(o,"resize",function(t){n.initCropBosPosition()})}return z(t,[{key:"_init",value:function(t){var e={attrs:{class:"zx-image-crop-container",style:"z-index:"+(p.maxZIndex()+1)+";display:none;"},child:[{attrs:{class:"zx-image-crop-wrapper"},child:[{attrs:{class:"crop-line-box"}}]},{tag:"img",attrs:{class:"zx-image-target"}},{attrs:{class:"zx-crop-btns-wrapper"},child:[{tag:"button",attrs:{class:"__rotate",style:t.cancelStyle},child:t.rotateText},{tag:"button",attrs:{class:"__submit",style:t.submitStyle},child:t.submitText}]},{attrs:{class:"__close"}}]};this.$wrapper=p.createVdom(e),this.$body=p.query("body"),this.$body.appendChild(this.$wrapper),this.$img=p.query(".zx-image-target",this.$wrapper),this._initEvent(this.$img),this.initCropBosPosition(),p.addEvent(this.$wrapper,"selectstart",function(t){t.preventDefault()})}},{key:"initCropBosPosition",value:function(t){t&&(this.options=Object.assign({},this.options,t));var e=this.options,n=o.innerWidth,i=o.innerHeight,r=Math.min(e.width,.8*n),a=e.height/e.width*r;a>.8*i&&(a=.8*i,r=e.width/e.height*a);var s=(i-a)/2,c=(n-r)/2,l=Math.max(s,c);this.cropRatio=e.width/r,this.cropBoxPos={winWidth:n,winHeight:i,width:r,height:a,borderWidth:l,top:s,left:c,bottom:s+a,right:c+r};var u=p.query(".crop-line-box",this.$wrapper);u.style.top=s-l+"px",u.style.left=c-l+"px",u.style.width=r+"px",u.style.height=a+"px",u.style.borderWidth=l+"px",p.query(".zx-crop-btns-wrapper",this.$wrapper).style.top=this.cropBoxPos.bottom+20+"px"}},{key:"_initEvent",value:function(){var t,e,n=this,o=void 0;o=m?r:p.query(".zx-image-crop-wrapper",this.$wrapper),this._move(o),t=o,e=function(t){var e=!!(n.angle%180),i=t.wheelDelta||-t.detail;n._scale(i,e)},p.addEvent(t,"mousewheel",e),p.addEvent(t,"DOMMouseScroll",e);var a=p.query(".__submit",this.$wrapper);p.addEvent(a,"click",function(t){n._submit()});var s=p.query(".__rotate",this.$wrapper);p.addEvent(s,"click",function(t){n._rotate()});var c=p.query(".__close",this.$wrapper);p.addEvent(c,"click",function(t){i.emit("crop-cancel"),n.hide()})}},{key:"_move",value:function(t){var e=this,n=this.$img,i=!1,o=!1,a={},s=0,c=[],u=!1;p.addEvent(t,x.start,function(t){var r,h;if(n.className="zx-image-target is-move",i=!0,o="touchstart"===t.type,u=!!(e.angle%180),o&&(s=t.touches.length),s>1&&(r=t,h=n.getBoundingClientRect(),c=l.slice(r.touches).map(function(t){return{x:t.pageX-h.left,y:t.pageY-h.top}})),!o&&"which"in t&&3===t.which)i=!1;else if(!o||1===t.targetTouches.length){o||l.isAndroid()||(t.preventDefault?t.preventDefault():t.returnValue=!1);var d=o?t.targetTouches[0].pageX:t.pageX||t.clientX,f=o?t.targetTouches[0].pageY:t.pageY||t.clientY,p=n.getBoundingClientRect(),g=e.translate;a={pageX:d,pageY:f,x:d-g.x,y:f-g.y,left:p.left,top:p.top}}}),p.addEvent(r,x.move,function(t){if(i)if(o||l.isAndroid()||(t.preventDefault?t.preventDefault():t.returnValue=!1),s>1){var n=E(t,c);e._scaleHandler(n>1,.02,u)}else e._handleMove(t,a,o,u)}),p.addEvent(r,x.end,function(t){n.className="zx-image-target",i=!1,o&&(s=t.touches.length)})}},{key:"_handleMove",value:function(t,e,n,i){var r=n?t.targetTouches[0].pageX:t.pageX||t.clientX,o=n?t.targetTouches[0].pageY:t.pageY||t.clientY,a={x:r-e.x,y:o-e.y};this._moveBoundary(a,i)}},{key:"_moveBoundary",value:function(t,e){var n=t.x,i=t.y,r=this.cropBoxPos,o=this.$img,a=o.getBoundingClientRect();if(e){var s=(r.winWidth+a.width-a.height-r.width)/2;s<=n&&(n=s);var c=(r.winHeight+a.height-a.width-r.height)/2;c<=i&&(i=c);var l=s+r.width-a.width;n<=l&&(n=l);var u=c+r.height-a.height;i<=u&&(i=u)}else n>r.left&&(n=r.left),n<=r.right-a.width&&(n=r.right-a.width),i>r.top&&(i=r.top),i<=r.bottom-a.height&&(i=r.bottom-a.height);this.translate.x=n,this.translate.y=i,o.style.transform="translateX("+this.translate.x+"px) translateY("+this.translate.y+"px) rotate("+this.angle+"deg)"}},{key:"_scale",value:function(t,e){this._scaleHandler(t>0,.1,e)}},{key:"_rotate",value:function(){var t=this.$img;this.angle+=90;var e=t.getBoundingClientRect(),n=!!(this.angle%180),i=this.cropBoxPos,r=e.height,o=e.width,a=void 0,s=void 0,c=void 0,l=void 0;if(n?(r<i.width&&(a=o*(s=i.width)/r),o<i.height&&(s=r*(a=i.height)/o),c=e.width,l=e.height):(r<i.width&&(s=o*(a=i.width)/r),o<i.height&&(s=r*(a=i.height)/o),c=e.height,l=e.width),a&&s){t.style.width=a+"px",t.style.height=s+"px";var u=c-a,h=l-s,d=this.translate;this.translate={x:d.x+u/2,y:d.y+h/2}}t.style.transform="translate("+this.translate.x+"px, "+this.translate.y+"px) rotate("+this.angle+"deg)"}},{key:"_scaleHandler",value:function(t,e,n){var i=this.$img,r=i.naturalWidth,o=i.width,a=i.height,s=this.cropBoxPos,c=void 0,l=void 0;if(t){if(l=(c=o*(1+e))*a/o,c>=3*r)return}else if(n){if(o<=s.height||a<=s.width)return void this._moveBoundary(this.translate,!0);l=(c=o*(1-e))*a/o,c<=s.height&&(l=(c=s.height)*a/o),l<=s.width&&(c=(l=s.width)*o/a)}else{if(o<=s.width||a<=s.height)return void this._moveBoundary(this.translate,!1);l=(c=o*(1-e))*a/o,c<=s.width&&(l=(c=s.width)*a/o),l<=s.height&&(c=(l=s.height)*o/a)}n?this._scaleByRotate(o,a,c,l):this._scaleByNotRotate(o,a,c,l)}},{key:"_scaleByRotate",value:function(t,e,n,i){var r=this.$img,o=t-n,a=e-i,s=this.translate;this.translate={x:s.x+o/2,y:s.y+a/2},r.style.width=n+"px",r.style.height=i+"px",this._moveBoundary(this.translate,!0)}},{key:"_scaleByNotRotate",value:function(t,e,n,i){var r=this.$img,o=t-n,a=e-i,s=this.translate;this.translate={x:s.x+o/2,y:s.y+a/2},r.style.width=n+"px",r.style.height=i+"px",this._moveBoundary(this.translate,!1)}},{key:"setImageSrc",value:function(t){if(this.$img&&t){if(this.show(),this.$img.src!==t){p.removeEvent(this.$img,"load",r),this.$img.setAttribute("style",""),this.angle=0,this.$img.src=t,p.addEvent(this.$img,"load",r);var e=this,n=e.cropBoxPos}}else i.emit("error",{code:21,message:"Failed to setImageSrc(url)"});function r(){var t=e.$img,i=n.winWidth/n.winHeight,r=t.naturalWidth,o=t.naturalHeight,a=r/o,s=void 0,c=void 0;a>i&&r>n.winWidth?c=o*(s=n.winWidth)/r:a<i&&o>n.winHeight?s=r*(c=n.winHeight)/o:(s=r,c=o);var l=n.width/n.height;a>l&&o<n.height?s=r*(c=n.height)/o:a<l&&r<n.width&&(c=o*(s=n.width)/r),t.style.width=s+"px",t.style.height=c+"px";var u=(n.winWidth-s)/2,h=(n.winHeight-c)/2;t.style.transform="translate("+u+"px, "+h+"px) rotate(0)",e.translate={x:u,y:h}}}},{key:"_submit",value:function(){var t=this.$img,e=this.options,n=this.cropRatio,r=this.cropBoxPos,o=t.getBoundingClientRect(),a=this.angle%360,s=a%180,c={angle:a,naturalWidth:s?t.naturalHeight:t.naturalWidth,naturalHeight:s?t.naturalWidth:t.naturalHeight,currentWidth:l.int(o.width*n),currentHeight:l.int(o.height*n),targetWidth:e.width,targetHeight:e.height,x:l.int((r.left-o.left)*n),y:l.int((r.top-o.top)*n)};i.emit("crop-submit",c),this.hide()}},{key:"show",value:function(){this.visible||(this.visible=!0,this.$wrapper.style.display="",p.lock(this.$body))}},{key:"hide",value:function(){this.visible&&(this.visible=!1,this.$wrapper.style.display="none",p.unlock(this.$body))}}]),t}(),S=null;function C(t,e,n,o){i.on("crop-cancel",function(t){o({code:22,message:"Clipping is cancelled"}),i.off("crop-submit"),i.off("crop-cancel")}),i.on("crop-submit",function(e){!function(t,e,n){var i=void 0;e.angle>0&&(i=function(t,e){var n=r.createElement("canvas"),i=n.getContext("2d"),o=t.width,a=t.height;switch(n.width=o,n.height=a,e){case 90:n.width=a,n.height=o,i.rotate(Math.PI/2),i.drawImage(t,0,-a,o,a);break;case 180:i.rotate(Math.PI),i.drawImage(t,-o,-a,o,a);break;case 270:n.width=a,n.height=o,i.rotate(3*Math.PI/2),i.drawImage(t,-o,0,o,a);break;default:i.drawImage(t,0,0,o,a)}return n}(t.element,e.angle),t.width=e.naturalWidth,t.height=e.naturalHeight,t.element=i);i=function(t,e){var n=g.scaleInfo(e,t),i=t.element,r=void 0,o=n.sw,a=n.sh;if(n.scaling>2){r=n.scaling;do{i=p.createCanvas(i,{dx:0,dy:0,dw:n.dw*r,dh:n.dh*r,sx:0,sy:0,sw:o,sh:a}),o=n.dw*r,a=n.dh*r,r-=1}while(r>2)}return i=p.createCanvas(i,{dx:0,dy:0,dw:n.dw,dh:n.dh,sx:0,sy:0,sw:o,sh:a})}(t,{width:e.currentWidth});var o=p.createCanvas(i,{sx:e.x,sy:e.y,sw:e.targetWidth,sh:e.targetHeight,dx:0,dy:0,dw:e.targetWidth,dh:e.targetHeight}),a=t.type,s=o.toDataURL(a),c=l.toBlobData(s,a);n&&n({element:o,type:a,width:o.width,height:o.height,blob:c,data:c,url:l.toBlobUrl(c),base64:s,size:c.size,raw:t})}(t,e,n),i.off("crop-submit"),i.off("crop-cancel")}),null===S?S=new k(e):S.initCropBosPosition(e),S.setImageSrc(t.base64)}function M(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(n,i){/^data:(.+?);base64/.test(t)?T(t,e,n,i):function(t){var e=new FileReader;return e.readAsDataURL(t),new Promise(function(t,n){e.onload=function(){t(this.result)},e.onerror=function(t){n(t)}})}(t).then(function(t){T(t,e,n,i)}).catch(function(t){i(t)})})}function T(t,e,n,i){var o,a,s=/^data:(.+?);base64/.test(t)?RegExp.$1:"image/jpeg",c=l.toBlobData(t,s),u=(o=t,(a=r.createElement("img")).src=o,a);u.onload=function(){var r={element:u,base64:t,width:u.naturalWidth||u.width,height:u.naturalHeight||u.height,type:c.type,size:c.size},o=e.width>0&&e.height>0;e.auto||!o?function(t,e,n){var i=void 0,r=void 0,o=void 0,a=void 0,s=void 0,c=void 0,u=void 0;if(i=g.autoCropInfo(t.width,t.height,e),r=t.element,o=2,a=i.sw,s=i.sh,c=i.sx,u=i.sy,i.scaling>o){o=i.scaling;do{r=$(r,{cw:i.cw*o,ch:i.ch*o,sx:c,sy:u,sw:a,sh:s}),a=r.width,s=r.height,c=u=0,o-=1}while(o>2)}var h=(r=$(r,{cw:i.cw,ch:i.ch,sx:c,sy:u,sw:a,sh:s})).toDataURL(t.type),d=l.toBlobData(h,t.type);n({element:r,type:d.type,width:i.cw,height:i.ch,blob:d,url:l.toBlobUrl(d),base64:h,size:d.size,raw:t})}(r,e,n):C(r,e,n,i)},u.onerror=function(t){i(t)}}function $(t,e){var n=r.createElement("canvas");return n.width=e.cw,n.height=e.ch,n.getContext("2d").drawImage(t,e.sx,e.sy,e.sw,e.sh,0,0,n.width,n.height),n}function L(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=function(t){var e=r.createElement("video");return e.src=t,e.autoplay=!0,e}(l.toBlobUrl(t));return new Promise(function(i,o){n.onerror=function(t){o(t),n=null},n.oncanplay=function(){var a={videoFile:t,videoWidth:n.videoWidth,videoHeight:n.videoHeight,duration:n.duration},s=function(t){arguments.length>1&&void 0!==arguments[1]&&arguments[1];t.pause();var e=r.createElement("canvas"),n=e.getContext("2d");e.width=t.videoWidth,e.height=t.videoHeight,n.drawImage(t,0,0,e.width,e.height);var i=null,o=null;try{i=e.toDataURL("image/jpeg")}catch(t){o={code:13,message:"截图失败,视频文件所在域与后台系统不同!",data:t}}return{base64:i,err:o}}(n),c=s.base64,l=s.err;if(l)return o(l),void(n=null);M(c,e).then(function(t){i(Object.assign({},a,t))}).catch(function(t){o(t)}),n=null}})}function R(t,e){return new Promise(function(n,i){var r=t.type;/^(image|video)/.test(r)?function(t,e,n,i,r){var o=l.bitToKib(t.size),a=1024*l.int(n.maxSize);if(a&&a<o)return void r({code:12,message:"The file is too large, exceeding the maximum limit of "+n.maxSize+"M."});switch(e){case"image":M(t,n).then(i).catch(r);break;case"video":L(t,n).then(i).catch(r)}}(t,RegExp.$1,e,n,i):i({code:7,message:"Incorrect file type"})})}n(0);n.d(e,"ZxImageProcess",function(){return A}),n.d(e,"handleMediaFile",function(){return R});var j=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();var U={accept:"",auto:!1,width:0,height:0,selector:null,maxSize:50,error:function(){},success:function(){}},I={},A=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=Object.assign({},U,e);i.on("error",function(t){t.msg=t.message,n.error(t)}),i.on("success",function(t){n.success(t)}),this._init(n)}return j(t,[{key:"_init",value:function(t){t.selector&&("string"==typeof t.selector||p.isHTMLElement(t.selector))?(this.options=t,this.id=l.randomStr(),this.$body=p.query("body"),null!==this.$body?function(t,e){var n=e.selector,r=p.isHTMLElement(n)?n:p.query(n);if(null!==r){var o=p.createElm("input",{style:"display:none;",type:"file",accept:e.accept});t.$body.appendChild(o),p.addEvent(o,"click",function(t){o.value=""}),p.addEvent(o,"change",function(n){var r=o.files||[];if(0===r.length)i.emit("error",{code:4,message:"Any file is not selected!"});else{var a=r[0];t.file=a,R(a,e).then(function(t){i.emit("success",t)}).catch(function(t){i.emit("error",t)})}}),p.addEvent(r,"click",function(t){o.click()})}else i.emit("error",{code:3,message:"Element "+n+" is not found in document!"})}(this,t):i.emit("error",{code:2,message:"Failed to initialize, Element body is not found in document!"})):i.emit("error",{code:1,message:'The selector "'+t.selector+'" is not valid in initialization parameter.'})}},{key:"reCrop",value:function(){this.file?I.show():i.emit("error",{code:5,message:"请先选择图片文件"})}}]),t}();A.prototype.toBlobData=l.toBlobData,A.prototype.toBlobUrl=l.toBlobUrl,A.prototype.conversion=l.conversion,A.prototype.handleMediaFile=R}])});
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}t.exports=function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e,n){var i=n(5);"string"==typeof i&&(i=[[t.i,i,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(7)(i,r);i.locals&&(t.exports=i.locals)},function(t,e,n){(t.exports=n(6)(!1)).push([t.i,".zx-image-crop-container{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,0.95)}.zx-image-crop-container *{margin:0;padding:0}.zx-image-crop-container .__close{position:absolute;z-index:5;top:0;right:0;width:64px;height:64px;cursor:pointer;transition:all .5s;opacity:.6;transform:rotate(45deg)}.zx-image-crop-container .__close:before,.zx-image-crop-container .__close:after{content:'';position:absolute;background-color:#fff;border-radius:2px}.zx-image-crop-container .__close:before{top:31px;left:16px;width:32px;height:2px}.zx-image-crop-container .__close:after{top:16px;left:31px;width:2px;height:32px}.zx-image-crop-container .__close:hover{transform:rotate(225deg);opacity:.8}.zx-image-crop-container .zx-image-crop-wrapper{position:absolute;z-index:2;top:0;left:0;width:100%;height:100%;cursor:move}.zx-image-crop-container .zx-image-crop-wrapper .crop-line-box{position:absolute;margin:0 auto;border-style:solid;border-color:rgba(0,0,0,0.5);box-sizing:content-box}.zx-image-crop-container .zx-image-target{position:absolute;z-index:1;top:0;left:0}.zx-image-crop-container .zx-image-target.is-move{transition:transform 0s}.zx-image-crop-container .zx-crop-btns-wrapper{position:absolute;z-index:3;left:50%;width:100%;text-align:center;transform:translateX(-50%)}.zx-image-crop-container .zx-crop-btns-wrapper button{display:inline-block;padding:0 20px;height:32px;border-radius:4px;color:#fff;border:0;background-color:#4169e1;cursor:pointer;box-shadow:0 5px 10px rgba(0,0,0,0.5)}.zx-image-crop-container .zx-crop-btns-wrapper button.__submit{margin-left:10px}.zx-image-crop-container .zx-crop-btns-wrapper button.__rotate{margin-right:10px;background-color:#666}",""])},function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",i=t[3];if(!i)return n;if(e&&"function"==typeof btoa){var r=(a=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),o=i.sources.map((function(t){return"/*# sourceURL="+i.sourceRoot+t+" */"}));return[n].concat(o).concat([r]).join("\n")}var a;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n})).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var i={},r=0;r<this.length;r++){var o=this[r][0];"number"==typeof o&&(i[o]=!0)}for(r=0;r<t.length;r++){var a=t[r];"number"==typeof a[0]&&i[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),e.push(a))}},e}},function(t,e,n){var i,r,o={},a=(i=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===r&&(r=i.apply(this,arguments)),r}),s=function(t,e){return e?e.querySelector(t):document.querySelector(t)},c=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var i=s.call(this,t,n);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}e[t]=i}return e[t]}}(),l=null,u=0,h=[],d=n(8);function f(t,e){for(var n=0;n<t.length;n++){var i=t[n],r=o[i.id];if(r){r.refs++;for(var a=0;a<r.parts.length;a++)r.parts[a](i.parts[a]);for(;a<i.parts.length;a++)r.parts.push(b(i.parts[a],e))}else{var s=[];for(a=0;a<i.parts.length;a++)s.push(b(i.parts[a],e));o[i.id]={id:i.id,refs:1,parts:s}}}}function p(t,e){for(var n=[],i={},r=0;r<t.length;r++){var o=t[r],a=e.base?o[0]+e.base:o[0],s={css:o[1],media:o[2],sourceMap:o[3]};i[a]?i[a].parts.push(s):n.push(i[a]={id:a,parts:[s]})}return n}function g(t,e){var n=c(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var i=h[h.length-1];if("top"===t.insertAt)i?i.nextSibling?n.insertBefore(e,i.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),h.push(e);else if("bottom"===t.insertAt)n.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var r=c(t.insertAt.before,n);n.insertBefore(e,r)}}function v(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=h.indexOf(t);e>=0&&h.splice(e,1)}function m(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var i=function(){0;return n.nc}();i&&(t.attrs.nonce=i)}return y(e,t.attrs),g(t,e),e}function y(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function b(t,e){var n,i,r,o;if(e.transform&&t.css){if(!(o="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=o}if(e.singleton){var a=u++;n=l||(l=m(e)),i=E.bind(null,n,a,!1),r=E.bind(null,n,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",y(e,t.attrs),g(t,e),e}(e),i=z.bind(null,n,e),r=function(){v(n),n.href&&URL.revokeObjectURL(n.href)}):(n=m(e),i=_.bind(null,n),r=function(){v(n)});return i(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;i(t=e)}else r()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=p(t,e);return f(n,e),function(t){for(var i=[],r=0;r<n.length;r++){var a=n[r];(s=o[a.id]).refs--,i.push(s)}t&&f(p(t,e),e);for(r=0;r<i.length;r++){var s;if(0===(s=i[r]).refs){for(var c=0;c<s.parts.length;c++)s.parts[c]();delete o[s.id]}}}};var w,x=(w=[],function(t,e){return w[t]=e,w.filter(Boolean).join("\n")});function E(t,e,n,i){var r=n?"":i.css;if(t.styleSheet)t.styleSheet.cssText=x(e,r);else{var o=document.createTextNode(r),a=t.childNodes;a[e]&&t.removeChild(a[e]),a.length?t.insertBefore(o,a[e]):t.appendChild(o)}}function _(t,e){var n=e.css,i=e.media;if(i&&t.setAttribute("media",i),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function z(t,e,n){var i=n.css,r=n.sourceMap,o=void 0===e.convertToAbsoluteUrls&&r;(e.convertToAbsoluteUrls||o)&&(i=d(i)),r&&(i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([i],{type:"text/css"}),s=t.href;t.href=URL.createObjectURL(a),s&&URL.revokeObjectURL(s)}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,i=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var r,o=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(o)?t:(r=0===o.indexOf("//")?o:0===o.indexOf("/")?n+o:i+o.replace(/^\.\//,""),"url("+JSON.stringify(r)+")")}))}},function(t,e,n){"use strict";n.r(e),n.d(e,"ZxImageProcess",(function(){return F})),n.d(e,"handleMediaFile",(function(){return q}));var i=n(2),r=n.n(i),o=n(0),a=n.n(o),s=n(1),c=n.n(s),l={broadcast:{},on:function(t,e){t&&"string"==typeof t&&e&&"function"==typeof e&&(this.broadcast[t]||(this.broadcast[t]=[]),this.broadcast[t].push(e))},emit:function(t){var e=this.broadcast[t];if(e)for(var n=Array.prototype.slice.call(arguments,1),i=0;i<e.length;i++)try{e[i].apply(null,n)}catch(e){this.emit("error",{code:1,msg:"emit(".concat(t,"): ").concat(e.message),data:e})}},off:function(t){this.broadcast[t]&&(this.broadcast[t]=null,delete this.broadcast[t])}},u=n(3),h=n.n(u),d="undefined"==typeof document?{body:{},addEventListener:function(){},removeEventListener:function(){},activeElement:{blur:function(){},nodeName:""},querySelector:function(){return null},querySelectorAll:function(){return[]},getElementById:function(){return null},createEvent:function(){return{initEvent:function(){}}},createElement:function(){return{children:[],childNodes:[],style:{},setAttribute:function(){},getElementsByTagName:function(){return[]}}},location:{hash:""}}:document,f="undefined"==typeof window?{document:d,navigator:{userAgent:""},location:{},history:{},CustomEvent:function(){return this},addEventListener:function(){},removeEventListener:function(){},getComputedStyle:function(){return{getPropertyValue:function(){return""}}},Image:function(){},Date:function(){},screen:{},setTimeout:function(){},clearTimeout:function(){}}:window,p=navigator.userAgent,g={bitToKib:function(t){return t/1024},conversion:function(t){var e=g.bitToKib(t);return e>=1024?g.int(e/1024*100)/100+"M":g.int(e)+"KB"},toBlobData:function(t,e){var n=function(t){var e=t.split(","),n="";/data:(\w+\/\w+);base64/.test(e[0])&&(n=RegExp.$1);return{type:n,data:e[1]}}(t),i=f.atob(n.data);e=e||n.type;for(var r=new Uint8Array(i.length),o=0;o<i.length;o++)r[o]=i.charCodeAt(o);return new Blob([r],{type:e})},toBlobUrl:function(t){return(f.URL||f.webkitURL).createObjectURL(t)},ratio:function(t,e){return t/e},int:function(t){var e=parseInt(t);return isNaN(e)?0:e},slice:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t.length&&t[0]?Array.prototype.slice.call(t,e):[]},strToHump:function(t){return t?t.toString().replace(/-(\w)/g,(function(t,e){return e.toUpperCase()})):""},isAndroid:function(){return p.toLowerCase().indexOf("android")>=0},isArray:function(t){return Array.isArray(t)},isObject:function(t){return t&&"object"===h()(t)&&!g.isArray(t)},randomStr:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"zximageprocess";return t+"_"+ +new Date},hasOwn:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}};var v=g,m=d,y={createElm:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",e=arguments.length>1?arguments[1]:void 0,n=m.createElement(t);if(e&&e instanceof Object)for(var i in e)v.hasOwn(e,i)&&n.setAttribute(i,e[i]);return n},createVdom:function(t){if(!t)return null;if("string"==typeof t)return m.createTextNode(t);var e=t.tag,n=t.attrs,i=t.child;if(!e&&!n&&!i)return null;var r,o=y.createElm(e||"div",n);Array.isArray(i)&&i.length?i.forEach((function(t){(r=y.createVdom(t))&&o.appendChild(r)})):i&&"string"==typeof i&&o.appendChild(m.createTextNode(i));return o},createCanvas:function(t,e){var n=this.createElm("canvas",{width:e.dw,height:e.dh});return n.getContext("2d").drawImage(t,e.sx,e.sy,e.sw,e.sh,e.dx,e.dy,e.dw,e.dh),n},getStyle:function(t,e){if(!y.isHTMLElement(t))return null;var n=f.getComputedStyle(t,null),i=null;if(e)try{i=n[v.strToHump(e)]}catch(t){}else i=n;return i},maxZIndex:function(){for(var t,e,n,i=m.getElementsByTagName("*"),r=[],o=0;o<i.length;o++)1===(t=i[o]).nodeType&&"static"!==(e=y.getStyle(t)||{}).position&&(n=v.int(e.zIndex))>0&&r.push(n);return v.int(Math.max.apply(null,r))},isHTMLElement:function(t){return t&&t instanceof HTMLElement},query:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m;return e.querySelector(t)},lock:function(t){void 0===t&&(t=y.query("body")),y.isHTMLElement(t)&&(t.style.overflow="hidden")},unlock:function(t){void 0===t&&(t=y.query("body")),y.isHTMLElement(t)&&(t.style.overflow="")},addEvent:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t&&e&&n)if(t.length)for(var r=0;r<t.length;r++)b(t[r],e,n,i);else b(t,e,n,i)},removeEvent:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t&&e&&n)if(t.length)for(var r=0;r<t.length;r++)w(t[r],e,n,i);else w(t,e,n,i)}};function b(t,e,n,i){t.addEventListener?t.addEventListener(e,n,i):t.attachEvent?t.attachEvent(e,n):t["on".concat(e)]=n}function w(t,e,n,i){t.removeEventListener?t.removeEventListener(e,n,i):t.detachEvent?t.detachEvent(e,n):t["on".concat(e)]=null}var x=y,E=function(t,e){var n=v.int(t.width),i=v.int(t.height),r=e.width,o=e.height,a=1;return n>0?(a=v.ratio(r,n),i=Math.floor(n*o/r)):i>0&&(a=v.ratio(o,i),n=Math.floor(i*r/o)),{sw:r,sh:o,scaling:a,dw:n,dh:i}},_=function(t,e,n){var i=v.int(n.width),r=v.int(n.height),o=1,a=0,s=0,c=t,l=e,u=t,h=e;return i>0&&r>0?(c=i,l=r,u=i,h=Math.floor(i*e/t),o=v.ratio(t,i),h>=r?(a=0,s=v.int((h-r)/2*o)):(o=v.ratio(e,r),u=Math.floor(r*t/e),a=v.int((u-i)/2*o),s=0)):i>0?(o=v.ratio(t,i),c=i,l=Math.floor(i*e/t)):r>0&&(o=v.ratio(e,r),c=Math.floor(r*t/e),l=r),{sx:a,sy:s,sw:c*o,sh:l*o,scaling:o,cw:c,ch:l}},z=f.navigator,B=z.msPointerEnabled,O=z.pointerEnabled,j=!!("ontouchstart"in f||f.DocumentTouch&&document instanceof DocumentTouch),S=["mousedown","mousemove","mouseup"];B&&(S=["MSPointerDown","MSPointerMove","MSPointerUp"]),O&&(S=["pointerdown","pointermove","pointerup"]);var M={start:j?"touchstart":S[0],move:j?"touchmove":S[1],end:j?"touchend":S[2]};function k(t,e){return function(t,e){var n=T(t[0],t[1]);return T(e[0],e[1])/n}(e,(n=t.touches,v.slice(n).map((function(t){return{x:t.pageX,y:t.pageY}}))));var n}function T(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)}var $={width:750,height:750,submitStyle:"",cancelStyle:"",submitText:"确 定",rotateText:"旋转90度"};var C=function(){function t(e){var n=this;a()(this,t),this.cropRatio=1,this.visible=!1,this.$wrapper=null,this.$img=null,this.cropBoxPos={},this.translate={x:0,y:0},this.angle=0,this.options=Object.assign({},$,e),this._init(this.options),x.addEvent(f,"resize",(function(t){n.initCropBosPosition()}))}return c()(t,[{key:"_init",value:function(t){var e=x.maxZIndex()+1,n={attrs:{class:"zx-image-crop-container",style:"z-index:".concat(e,";display:none;")},child:[{attrs:{class:"zx-image-crop-wrapper"},child:[{attrs:{class:"crop-line-box"}}]},{tag:"img",attrs:{class:"zx-image-target"}},{attrs:{class:"zx-crop-btns-wrapper"},child:[{tag:"button",attrs:{class:"__rotate",style:t.cancelStyle},child:t.rotateText},{tag:"button",attrs:{class:"__submit",style:t.submitStyle},child:t.submitText}]},{attrs:{class:"__close"}}]};this.$wrapper=x.createVdom(n),this.$body=x.query("body"),this.$body.appendChild(this.$wrapper),this.$img=x.query(".zx-image-target",this.$wrapper),this._initEvent(this.$img),this.initCropBosPosition(),x.addEvent(this.$wrapper,"selectstart",(function(t){t.preventDefault()}))}},{key:"initCropBosPosition",value:function(t){t&&(this.options=Object.assign({},this.options,t));var e=this.options,n=f.innerWidth,i=f.innerHeight,r=Math.min(e.width,.8*n),o=e.height/e.width*r;o>.8*i&&(o=.8*i,r=e.width/e.height*o);var a=(i-o)/2,s=(n-r)/2,c=Math.max(a,s);this.cropRatio=e.width/r,this.cropBoxPos={winWidth:n,winHeight:i,width:r,height:o,borderWidth:c,top:a,left:s,bottom:a+o,right:s+r};var l=x.query(".crop-line-box",this.$wrapper);l.style.top=a-c+"px",l.style.left=s-c+"px",l.style.width=r+"px",l.style.height=o+"px",l.style.borderWidth=c+"px",x.query(".zx-crop-btns-wrapper",this.$wrapper).style.top=this.cropBoxPos.bottom+20+"px"}},{key:"_initEvent",value:function(){var t,e,n,i=this;t=B?d:x.query(".zx-image-crop-wrapper",this.$wrapper),this._move(t),e=t,n=function(t){var e=!!(i.angle%180),n=t.wheelDelta||-t.detail;i._scale(n,e)},x.addEvent(e,"mousewheel",n),x.addEvent(e,"DOMMouseScroll",n);var r=x.query(".__submit",this.$wrapper);x.addEvent(r,"click",(function(t){i._submit()}));var o=x.query(".__rotate",this.$wrapper);x.addEvent(o,"click",(function(t){i._rotate()}));var a=x.query(".__close",this.$wrapper);x.addEvent(a,"click",(function(t){l.emit("crop-cancel"),i.hide()}))}},{key:"_move",value:function(t){var e=this,n=this.$img,i=!1,r=!1,o={},a=0,s=[],c=!1;x.addEvent(t,M.start,(function(t){var l,u;if(n.className="zx-image-target is-move",i=!0,r="touchstart"===t.type,c=!!(e.angle%180),r&&(a=t.touches.length),a>1&&(l=t,u=n.getBoundingClientRect(),s=v.slice(l.touches).map((function(t){return{x:t.pageX-u.left,y:t.pageY-u.top}}))),r||!("which"in t)||3!==t.which){if(!r||1===t.targetTouches.length){r||v.isAndroid()||(t.preventDefault?t.preventDefault():t.returnValue=!1);var h=r?t.targetTouches[0].pageX:t.pageX||t.clientX,d=r?t.targetTouches[0].pageY:t.pageY||t.clientY,f=n.getBoundingClientRect(),p=e.translate;o={pageX:h,pageY:d,x:h-p.x,y:d-p.y,left:f.left,top:f.top}}}else i=!1})),x.addEvent(d,M.move,(function(t){if(i)if(r||v.isAndroid()||(t.preventDefault?t.preventDefault():t.returnValue=!1),a>1){var n=k(t,s);e._scaleHandler(n>1,.02,c)}else e._handleMove(t,o,r,c)})),x.addEvent(d,M.end,(function(t){n.className="zx-image-target",i=!1,r&&(a=t.touches.length)}))}},{key:"_handleMove",value:function(t,e,n,i){var r=n?t.targetTouches[0].pageX:t.pageX||t.clientX,o=n?t.targetTouches[0].pageY:t.pageY||t.clientY,a={x:r-e.x,y:o-e.y};this._moveBoundary(a,i)}},{key:"_moveBoundary",value:function(t,e){var n=t.x,i=t.y,r=this.cropBoxPos,o=this.$img,a=o.getBoundingClientRect();if(e){var s=(r.winWidth+a.width-a.height-r.width)/2;s<=n&&(n=s);var c=(r.winHeight+a.height-a.width-r.height)/2;c<=i&&(i=c);var l=s+r.width-a.width;n<=l&&(n=l);var u=c+r.height-a.height;i<=u&&(i=u)}else n>r.left&&(n=r.left),n<=r.right-a.width&&(n=r.right-a.width),i>r.top&&(i=r.top),i<=r.bottom-a.height&&(i=r.bottom-a.height);this.translate.x=n,this.translate.y=i,o.style.transform="translateX(".concat(this.translate.x,"px) translateY(").concat(this.translate.y,"px) rotate(").concat(this.angle,"deg)")}},{key:"_scale",value:function(t,e){this._scaleHandler(t>0,.1,e)}},{key:"_rotate",value:function(){var t=this.$img;this.angle+=90;var e,n,i,r,o=t.getBoundingClientRect(),a=!!(this.angle%180),s=this.cropBoxPos,c=o.height,l=o.width;if(a?(c<s.width&&(e=l*(n=s.width)/c),l<s.height&&(n=c*(e=s.height)/l),i=o.width,r=o.height):(c<s.width&&(n=l*(e=s.width)/c),l<s.height&&(n=c*(e=s.height)/l),i=o.height,r=o.width),e&&n){t.style.width=e+"px",t.style.height=n+"px";var u=i-e,h=r-n,d=this.translate;this.translate={x:d.x+u/2,y:d.y+h/2}}t.style.transform="translate(".concat(this.translate.x,"px, ").concat(this.translate.y,"px) rotate(").concat(this.angle,"deg)")}},{key:"_scaleHandler",value:function(t,e,n){var i,r,o=this.$img,a=o.naturalWidth,s=o.width,c=o.height,l=this.cropBoxPos;if(t){if(r=(i=s*(1+e))*c/s,i>=3*a)return}else if(n){if(s<=l.height||c<=l.width)return void this._moveBoundary(this.translate,!0);r=(i=s*(1-e))*c/s,i<=l.height&&(r=(i=l.height)*c/s),r<=l.width&&(i=(r=l.width)*s/c)}else{if(s<=l.width||c<=l.height)return void this._moveBoundary(this.translate,!1);r=(i=s*(1-e))*c/s,i<=l.width&&(r=(i=l.width)*c/s),r<=l.height&&(i=(r=l.height)*s/c)}n?this._scaleByRotate(s,c,i,r):this._scaleByNotRotate(s,c,i,r)}},{key:"_scaleByRotate",value:function(t,e,n,i){var r=this.$img,o=t-n,a=e-i,s=this.translate;this.translate={x:s.x+o/2,y:s.y+a/2},r.style.width=n+"px",r.style.height=i+"px",this._moveBoundary(this.translate,!0)}},{key:"_scaleByNotRotate",value:function(t,e,n,i){var r=this.$img,o=t-n,a=e-i,s=this.translate;this.translate={x:s.x+o/2,y:s.y+a/2},r.style.width=n+"px",r.style.height=i+"px",this._moveBoundary(this.translate,!1)}},{key:"setImageSrc",value:function(t){if(this.$img&&t){if(this.show(),this.$img.src!==t){x.removeEvent(this.$img,"load",i),this.$img.setAttribute("style",""),this.angle=0,this.$img.src=t,x.addEvent(this.$img,"load",i);var e=this,n=e.cropBoxPos}}else l.emit("error",{code:21,message:"Failed to setImageSrc(url)"});function i(){var t,i,r=e.$img,o=n.winWidth/n.winHeight,a=r.naturalWidth,s=r.naturalHeight,c=a/s;c>o&&a>n.winWidth?i=s*(t=n.winWidth)/a:c<o&&s>n.winHeight?t=a*(i=n.winHeight)/s:(t=a,i=s);var l=n.width/n.height;c>l&&s<n.height?t=a*(i=n.height)/s:c<l&&a<n.width&&(i=s*(t=n.width)/a),r.style.width=t+"px",r.style.height=i+"px";var u=(n.winWidth-t)/2,h=(n.winHeight-i)/2;r.style.transform="translate(".concat(u,"px, ").concat(h,"px) rotate(0)"),e.translate={x:u,y:h}}}},{key:"_submit",value:function(){var t=this.$img,e=this.options,n=this.cropRatio,i=this.cropBoxPos,r=t.getBoundingClientRect(),o=this.angle%360,a=o%180,s={angle:o,naturalWidth:a?t.naturalHeight:t.naturalWidth,naturalHeight:a?t.naturalWidth:t.naturalHeight,currentWidth:v.int(r.width*n),currentHeight:v.int(r.height*n),targetWidth:e.width,targetHeight:e.height,x:v.int((i.left-r.left)*n),y:v.int((i.top-r.top)*n)};l.emit("crop-submit",s),this.hide()}},{key:"show",value:function(){this.visible||(this.visible=!0,this.$wrapper.style.display="",x.lock(this.$body))}},{key:"hide",value:function(){this.visible&&(this.visible=!1,this.$wrapper.style.display="none",x.unlock(this.$body))}}]),t}(),P=null;function L(t,e,n,i){l.on("crop-cancel",(function(t){i({code:22,message:"Clipping is cancelled"}),l.off("crop-submit"),l.off("crop-cancel")})),l.on("crop-submit",(function(e){!function(t,e,n){var i;e.angle>0&&(i=function(t,e){var n=d.createElement("canvas"),i=n.getContext("2d"),r=t.width,o=t.height;switch(n.width=r,n.height=o,e){case 90:n.width=o,n.height=r,i.rotate(Math.PI/2),i.drawImage(t,0,-o,r,o);break;case 180:i.rotate(Math.PI),i.drawImage(t,-r,-o,r,o);break;case 270:n.width=o,n.height=r,i.rotate(3*Math.PI/2),i.drawImage(t,-r,0,r,o);break;default:i.drawImage(t,0,0,r,o)}return n}(t.element,e.angle),t.width=e.naturalWidth,t.height=e.naturalHeight,t.element=i);i=function(t,e){var n,i=E(e,t),r=t.element,o=i.sw,a=i.sh;if(i.scaling>2){n=i.scaling;do{r=x.createCanvas(r,{dx:0,dy:0,dw:i.dw*n,dh:i.dh*n,sx:0,sy:0,sw:o,sh:a}),o=i.dw*n,a=i.dh*n,n-=1}while(n>2)}return r=x.createCanvas(r,{dx:0,dy:0,dw:i.dw,dh:i.dh,sx:0,sy:0,sw:o,sh:a})}(t,{width:e.currentWidth});var r=x.createCanvas(i,{sx:e.x,sy:e.y,sw:e.targetWidth,sh:e.targetHeight,dx:0,dy:0,dw:e.targetWidth,dh:e.targetHeight}),o=t.type,a=r.toDataURL(o),s=v.toBlobData(a,o);n&&n({element:r,type:o,width:r.width,height:r.height,blob:s,data:s,url:v.toBlobUrl(s),base64:a,size:s.size,raw:t})}(t,e,n),l.off("crop-submit"),l.off("crop-cancel")})),null===P?P=new C(e):P.initCropBosPosition(e),P.setImageSrc(t.base64)}function R(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,i){/^data:(.+?);base64/.test(t)?A(t,e,n,i):U(t).then((function(t){A(t,e,n,i)})).catch((function(t){i(t)}))}))}function U(t){var e=new FileReader;return e.readAsDataURL(t),new Promise((function(t,n){e.onload=function(){t(this.result)},e.onerror=function(t){n(t)}}))}function A(t,e,n,i){var r,o,a=/^data:(.+?);base64/.test(t)?RegExp.$1:"image/jpeg",s=v.toBlobData(t,a),c=(r=t,(o=d.createElement("img")).src=r,o);c.onload=function(){var r={element:c,base64:t,width:c.naturalWidth||c.width,height:c.naturalHeight||c.height,type:s.type,size:s.size,quality:e.quality},o=e.width>0&&e.height>0;e.auto||!o?function(t,e,n){var i,r,o,a,s,c,l=_(t.width,t.height,e);if(i=t.element,r=2,o=l.sw,a=l.sh,s=l.sx,c=l.sy,l.scaling>r){r=l.scaling;do{i=H(i,{cw:l.cw*r,ch:l.ch*r,sx:s,sy:c,sw:o,sh:a}),o=i.width,a=i.height,s=c=0,r-=1}while(r>2)}var u=(i=H(i,{cw:l.cw,ch:l.ch,sx:s,sy:c,sw:o,sh:a})).toDataURL(t.type,t.quality),h=v.toBlobData(u,t.type);n({element:i,type:h.type,width:l.cw,height:l.ch,blob:h,url:v.toBlobUrl(h),base64:u,size:h.size,raw:t})}(r,e,n):L(r,e,n,i)},c.onerror=function(t){i(t)}}function H(t,e){var n=d.createElement("canvas");return n.width=e.cw,n.height=e.ch,n.getContext("2d").drawImage(t,e.sx,e.sy,e.sw,e.sh,0,0,n.width,n.height),n}function I(t){t.pause();var e="image/jpeg",n=d.createElement("canvas"),i=n.getContext("2d");n.width=t.videoWidth,n.height=t.videoHeight,i.drawImage(t,0,0,n.width,n.height);var r=null,o=null;try{r=n.toDataURL(e)}catch(t){o={code:13,message:"截图失败,视频文件所在域与后台系统不同!",data:t}}return{base64:r,err:o}}function D(t){var e=d.createElement("video");return e.src=t,e.autoplay=!0,e}function q(t,e){return new Promise((function(n,i){(!v.hasOwn(e,"quality")||e.quality<=0||e.quality>1)&&(e.quality=.8);var r=t.type;/^(image|video)/.test(r)?function(t,e,n,i,r){var o=v.bitToKib(t.size),a=1024*v.int(n.maxSize);if(a&&a<o)return void r({code:12,message:"The file is too large, exceeding the maximum limit of ".concat(n.maxSize,"M.")});switch(e){case"image":R(t,n).then(i).catch(r);break;case"video":(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=v.toBlobUrl(t),i=D(n);return new Promise((function(n,r){i.onerror=function(t){r(t),i=null},i.oncanplay=function(){var o={videoFile:t,videoWidth:i.videoWidth,videoHeight:i.videoHeight,duration:i.duration},a=I(i),s=a.base64,c=a.err;if(c)return r(c),void(i=null);R(s,e).then((function(t){n(Object.assign({},o,t))})).catch((function(t){r(t)})),i=null}}))})(t,n).then(i).catch(r)}}(t,RegExp.$1,e,n,i):i(new Error({code:7,message:"Incorrect file type"}))}))}n(4);function W(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function N(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?W(Object(n),!0).forEach((function(e){r()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var X={accept:"",auto:!1,width:0,height:0,selector:null,maxSize:50,error:function(){},success:function(){},quality:.8},Y={},F=function(){function t(e){a()(this,t);var n=N(N({},X),e);l.on("error",(function(t){t.msg=t.message,n.error(t)})),l.on("success",(function(t){n.success(t)})),this._init(n)}return c()(t,[{key:"_init",value:function(t){t.selector&&("string"==typeof t.selector||x.isHTMLElement(t.selector))?(this.options=t,this.id=v.randomStr(),this.$body=x.query("body"),null!==this.$body?function(t,e){var n=e.selector,i=x.isHTMLElement(n)?n:x.query(n);if(null!==i){var r=x.createElm("input",{style:"display:none;",type:"file",accept:e.accept});t.$body.appendChild(r),x.addEvent(r,"click",(function(t){r.value=""})),x.addEvent(r,"change",(function(n){var i=r.files||[];if(0===i.length)l.emit("error",{code:4,message:"Any file is not selected!"});else{var o=i[0];t.file=o,q(o,e).then((function(t){l.emit("success",t)})).catch((function(t){l.emit("error",t)}))}})),x.addEvent(i,"click",(function(t){r.click()}))}else l.emit("error",{code:3,message:"Element ".concat(n," is not found in document!")})}(this,t):l.emit("error",{code:2,message:"Failed to initialize, Element body is not found in document!"})):l.emit("error",{code:1,message:'The selector "'.concat(t.selector,'" is not valid in initialization parameter.')})}},{key:"reCrop",value:function(){this.file?Y.show():l.emit("error",{code:5,message:"请先选择图片文件"})}}]),t}();F.prototype.toBlobData=v.toBlobData,F.prototype.toBlobUrl=v.toBlobUrl,F.prototype.conversion=v.conversion,F.prototype.handleMediaFile=q}])}));
{
"name": "image-process",
"version": "3.3.7",
"version": "3.3.8",
"author": "capricorncd",

@@ -29,9 +29,17 @@ "github": "https://github.com/capricorncd",

"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"autoprefixer": "^9.1.5",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"cross-env": "^5.2.0",
"css-loader": "^1.0.0",
"eslint": "^7.8.1",
"eslint-config-standard": "^14.1.1",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"html-webpack-plugin": "^3.2.0",

@@ -38,0 +46,0 @@ "postcss-loader": "^3.0.0",

@@ -17,3 +17,3 @@ # image-process-tools

```
```bash
npm install image-process --save-dev

@@ -26,3 +26,3 @@ ```

```
```javascript
import { ZxImageProcess } from 'image-process'

@@ -51,2 +51,4 @@

maxSize: 50,
// image/jpeg quality,图片压缩质量0-1
quality: 0.8,
success: function (result) {

@@ -66,3 +68,3 @@ // 返回数据

```
```javascript
import { handleMediaFile } from 'image-process'

@@ -78,3 +80,4 @@

// 文件大小限制50M
maxSize: 50
maxSize: 50,
quality: 0.8
}

@@ -81,0 +84,0 @@

@@ -17,6 +17,6 @@ /**

on (notifyName, fn) {
if (!notifyName
|| typeof notifyName !== 'string'
|| !fn
|| typeof fn !== 'function') return
if (!notifyName ||
typeof notifyName !== 'string' ||
!fn ||
typeof fn !== 'function') return
if (!this.broadcast[notifyName]) {

@@ -33,5 +33,5 @@ this.broadcast[notifyName] = []

emit (notifyName) {
let notifyArr = this.broadcast[notifyName]
const notifyArr = this.broadcast[notifyName]
if (!notifyArr) return
let args = Array.prototype.slice.call(arguments, 1)
const args = Array.prototype.slice.call(arguments, 1)
for (let i = 0; i < notifyArr.length; i++) {

@@ -61,2 +61,1 @@ try {

}

@@ -18,4 +18,4 @@ /**

let iw = info.width
let ih = info.height
const iw = info.width
const ih = info.height

@@ -69,4 +69,4 @@ // 提示:图片实际尺寸,小于目标尺寸

// 目标图片尺寸
let targetWidth = util.int(opts.width)
let targetHeight = util.int(opts.height)
const targetWidth = util.int(opts.width)
const targetHeight = util.int(opts.height)

@@ -73,0 +73,0 @@ // 缩放比列

@@ -19,6 +19,6 @@ /**

createElm (tag = 'div', opts) {
let $el = d.createElement(tag)
const $el = d.createElement(tag)
if (opts && opts instanceof Object) {
for (let key in opts) {
if (opts.hasOwnProperty(key)) {
for (const key in opts) {
if (util.hasOwn(opts, key)) {
$el.setAttribute(key, opts[key])

@@ -41,5 +41,5 @@ }

}
let tag = vnode.tag
let attrs = vnode.attrs
let child = vnode.child
const tag = vnode.tag
const attrs = vnode.attrs
const child = vnode.child
if (!tag && !attrs && !child) return null

@@ -103,3 +103,3 @@ // 创建dom

let $el, css, zindex
let arr = []
const arr = []
for (let i = 0; i < $els.length; i++) {

@@ -106,0 +106,0 @@ $el = $els[i]

@@ -62,8 +62,8 @@ /**

function handleBase64 (base64, opts, resolve, reject) {
let type = /^data:(.+?);base64/.test(base64) ? RegExp.$1 : 'image/jpeg'
let blob = util.toBlobData(base64, type)
let $img = craeteImage(base64)
const type = /^data:(.+?);base64/.test(base64) ? RegExp.$1 : 'image/jpeg'
const blob = util.toBlobData(base64, type)
const $img = createImage(base64)
// onload
$img.onload = function () {
let info = {
const info = {
element: $img,

@@ -74,6 +74,7 @@ base64,

type: blob.type,
size: blob.size
size: blob.size,
quality: opts.quality
}
// 是否裁剪图片
let isCrop = opts.width > 0 && opts.height > 0
const isCrop = opts.width > 0 && opts.height > 0
// 自动裁剪或等比缩放

@@ -97,3 +98,3 @@ if (opts.auto || !isCrop) {

*/
function craeteImage (url) {
function createImage (url) {
const $image = document.createElement('img')

@@ -111,5 +112,5 @@ $image.src = url

function autoCropImage (info, opts, resolve) {
let clipInfo, $canvas, scaling, sw, sh, sx, sy
let $canvas, scaling, sw, sh, sx, sy
// 计算图片缩放或裁剪位置、尺寸
clipInfo = calculator.autoCropInfo(info.width, info.height, opts)
const clipInfo = calculator.autoCropInfo(info.width, info.height, opts)
// App.log(clipInfo)

@@ -148,4 +149,4 @@ $canvas = info.element

let base64 = $canvas.toDataURL(info.type)
let blob = util.toBlobData(base64, info.type)
const base64 = $canvas.toDataURL(info.type, info.quality)
const blob = util.toBlobData(base64, info.type)

@@ -152,0 +153,0 @@ resolve({

@@ -18,11 +18,15 @@ /**

return new Promise((resolve, reject) => {
// quality
if (!util.hasOwn(opts, 'quality') || (opts.quality <= 0 || opts.quality > 1)) {
opts.quality = 0.8
}
// check file type
let fileType = file.type
const fileType = file.type
if (/^(image|video)/.test(fileType)) {
_handlerFile(file, RegExp.$1, opts, resolve, reject)
} else {
reject({
reject(new Error({
code: 7,
message: 'Incorrect file type'
})
}))
}

@@ -43,4 +47,4 @@ })

// check file size
let fileSize = util.bitToKib(file.size)
let maxSize = util.int(opts.maxSize) * 1024
const fileSize = util.bitToKib(file.size)
const maxSize = util.int(opts.maxSize) * 1024
if (maxSize && maxSize < fileSize) {

@@ -47,0 +51,0 @@ reject({

@@ -16,3 +16,3 @@ /**

export function handleVideoFile (file, opts = {}) {
let blobUrl = util.toBlobUrl(file)
const blobUrl = util.toBlobUrl(file)
let $video = createVideo(blobUrl)

@@ -25,3 +25,3 @@ return new Promise((resolve, reject) => {

$video.oncanplay = function () {
let info = {
const info = {
videoFile: file,

@@ -32,3 +32,3 @@ videoWidth: $video.videoWidth,

}
let { base64, err } = getVideoCapture($video)
const { base64, err } = getVideoCapture($video)
if (err) {

@@ -63,6 +63,6 @@ reject(err)

// 生成图片类型
let dataType = 'image/jpeg'
const dataType = 'image/jpeg'
// 创建canvas
let $canvas = document.createElement('canvas')
let ctx = $canvas.getContext('2d')
const $canvas = document.createElement('canvas')
const ctx = $canvas.getContext('2d')

@@ -69,0 +69,0 @@ $canvas.width = $video.videoWidth

@@ -8,3 +8,3 @@ /**

import dom from './dom-core'
import util from "./util"
import util from './util'
import { initInput } from './input'

@@ -15,3 +15,3 @@ import { handleMediaFile } from './handler/index'

// default options
const DEFAUTL_OPTIONS = {
const DEFAULT_OPTIONS = {
// image, video

@@ -27,6 +27,8 @@ accept: '',

error () {},
success () {}
success () {},
// image/jpeg quality
quality: 0.8
}
let crop = {}
const crop = {}

@@ -43,3 +45,6 @@ /**

// 参数处理
let options = Object.assign({}, DEFAUTL_OPTIONS, opts)
const options = {
...DEFAULT_OPTIONS,
...opts
}
// error notify

@@ -81,3 +86,3 @@ broadcast.on('error', err => {

code: 2,
message: `Failed to initialize, Element body is not found in document!`
message: 'Failed to initialize, Element body is not found in document!'
})

@@ -84,0 +89,0 @@ return

@@ -14,3 +14,3 @@ /**

export function initInput (_this, opts) {
let selector = opts.selector
const selector = opts.selector
// 触发input[type=file]的按钮

@@ -44,3 +44,3 @@ const $btn = dom.isHTMLElement(selector) ? selector : dom.query(selector)

dom.addEvent($input, 'change', _ => {
let files = $input.files || []
const files = $input.files || []
if (files.length === 0) {

@@ -52,3 +52,3 @@ broadcast.emit('error', {

} else {
let file = files[0]
const file = files[0]
// 重新裁剪时使用

@@ -55,0 +55,0 @@ _this.file = file

@@ -24,3 +24,2 @@ /**

// crop class

@@ -61,3 +60,3 @@ class CropClass {

// let zIndex = 1
let zIndex = dom.maxZIndex() + 1
const zIndex = dom.maxZIndex() + 1

@@ -143,5 +142,5 @@ // 裁剪容器

}
let opts = this.options
let winWidth = window.innerWidth
let winHeight = window.innerHeight
const opts = this.options
const winWidth = window.innerWidth
const winHeight = window.innerHeight
// 宽度取设置宽度和屏幕宽度的最小值

@@ -155,5 +154,5 @@ let width = Math.min(opts.width, winWidth * 0.8)

}
let top = (winHeight - height) / 2
let left = (winWidth - width) / 2
let borderWidth = Math.max(top, left)
const top = (winHeight - height) / 2
const left = (winWidth - width) / 2
const borderWidth = Math.max(top, left)
// 裁剪比例

@@ -200,6 +199,6 @@ this.cropRatio = opts.width / width

mouseWheel($crop, e => {
let isRotate = !!(this.angle % 180)
const isRotate = !!(this.angle % 180)
// 浏览器兼容处理
// 鼠标滚动方向
let wheelDelta = e.wheelDelta || -e.detail
const wheelDelta = e.wheelDelta || -e.detail
this._scale(wheelDelta, isRotate)

@@ -277,6 +276,6 @@ })

let pageX = isTouchEvent ? e.targetTouches[0].pageX : (e.pageX || e.clientX)
let pageY = isTouchEvent ? e.targetTouches[0].pageY : (e.pageY || e.clientY)
let pos = $img.getBoundingClientRect()
let tran = this.translate
const pageX = isTouchEvent ? e.targetTouches[0].pageX : (e.pageX || e.clientX)
const pageY = isTouchEvent ? e.targetTouches[0].pageY : (e.pageY || e.clientY)
const pos = $img.getBoundingClientRect()
const tran = this.translate
moveBeforePostion = {

@@ -307,3 +306,3 @@ pageX,

if (fingers > 1) {
let scale = handleTouches(e, startTouches)
const scale = handleTouches(e, startTouches)
this._scaleHandler(scale > 1, 0.02, isRotate)

@@ -333,6 +332,6 @@ } else {

_handleMove (e, moveBeforePostion, isTouchEvent, isRotate) {
let pageX = isTouchEvent ? e.targetTouches[0].pageX : (e.pageX || e.clientX)
let pageY = isTouchEvent ? e.targetTouches[0].pageY : (e.pageY || e.clientY)
const pageX = isTouchEvent ? e.targetTouches[0].pageX : (e.pageX || e.clientX)
const pageY = isTouchEvent ? e.targetTouches[0].pageY : (e.pageY || e.clientY)
// x、y轴移动的距离
let tran = {
const tran = {
x: pageX - moveBeforePostion.x,

@@ -348,6 +347,6 @@ y: pageY - moveBeforePostion.y

let moveY = tran.y
let box = this.cropBoxPos
let $img = this.$img
const box = this.cropBoxPos
const $img = this.$img
// check image position
let pos = $img.getBoundingClientRect()
const pos = $img.getBoundingClientRect()
// log(pos)

@@ -358,3 +357,3 @@ // log(l, t)

// 左边界
let left = (box.winWidth + pos.width - pos.height - box.width) / 2
const left = (box.winWidth + pos.width - pos.height - box.width) / 2
if (left <= moveX) {

@@ -364,3 +363,3 @@ moveX = left

// 上边界
let top = (box.winHeight + pos.height - pos.width - box.height) / 2
const top = (box.winHeight + pos.height - pos.width - box.height) / 2
if (top <= moveY) {

@@ -370,3 +369,3 @@ moveY = top

// 右边界
let right = left + box.width - pos.width
const right = left + box.width - pos.width
if (moveX <= right) {

@@ -376,3 +375,3 @@ moveX = right

// 下边界
let bottom = top + box.height - pos.height
const bottom = top + box.height - pos.height
if (moveY <= bottom) {

@@ -417,10 +416,10 @@ moveY = bottom

this.angle += 90
let pos = $img.getBoundingClientRect()
const pos = $img.getBoundingClientRect()
// 90/270deg 视为被旋转
let isRotate = !!(this.angle % 180)
let box = this.cropBoxPos
const isRotate = !!(this.angle % 180)
const box = this.cropBoxPos
// 旋转后宽高
let rotatedWidth = pos.height
let rotatedHeight= pos.width
const rotatedWidth = pos.height
const rotatedHeight = pos.width
// 图片新尺寸, 元素尺寸

@@ -458,6 +457,6 @@ let iw, ih, originalWidth, originalHeight

// 增加的尺寸
let increasedWidth = originalWidth - iw
let increasedHeight = originalHeight - ih
const increasedWidth = originalWidth - iw
const increasedHeight = originalHeight - ih
// 重置图片位置
let translate = this.translate
const translate = this.translate
this.translate = {

@@ -480,7 +479,7 @@ x: translate.x + increasedWidth / 2,

const $img = this.$img
let naturalWidth = $img.naturalWidth
const naturalWidth = $img.naturalWidth
// let naturalHeight = $img.naturalHeight
let imgWidth = $img.width
let imgHeight = $img.height
let box = this.cropBoxPos
const imgWidth = $img.width
const imgHeight = $img.height
const box = this.cropBoxPos
let iw, ih

@@ -543,6 +542,6 @@ if (isEnlarge) {

// 增加的尺寸
let increasedWidth = imgWidth - iw
let increasedHeight = imgHeight - ih
const increasedWidth = imgWidth - iw
const increasedHeight = imgHeight - ih
// 重置图片位置
let translate = this.translate
const translate = this.translate
this.translate = {

@@ -570,6 +569,6 @@ x: translate.x + increasedWidth / 2,

// 增加的尺寸
let increasedWidth = imgWidth - iw
let increasedHeight = imgHeight - ih
const increasedWidth = imgWidth - iw
const increasedHeight = imgHeight - ih
// 重置图片位置
let translate = this.translate
const translate = this.translate
this.translate = {

@@ -594,3 +593,3 @@ x: translate.x + increasedWidth / 2,

code: 21,
message: `Failed to setImageSrc(url)`
message: 'Failed to setImageSrc(url)'
})

@@ -608,12 +607,12 @@ return

let _this = this
let box = _this.cropBoxPos
const _this = this
const box = _this.cropBoxPos
function _imageHander () {
let $img = _this.$img
const $img = _this.$img
// window
let winRatio = box.winWidth / box.winHeight
const winRatio = box.winWidth / box.winHeight
// 图片尺寸重置
let imgWidth = $img.naturalWidth
let imgHeight = $img.naturalHeight
let imgRatio = imgWidth / imgHeight
const imgWidth = $img.naturalWidth
const imgHeight = $img.naturalHeight
const imgRatio = imgWidth / imgHeight
let iw, ih

@@ -632,3 +631,3 @@ // 屏幕尺寸限制,保证图片任意边不大于屏幕对应边

// 裁剪框限制,保证图片任意边不小于裁剪框对应边
let boxRatio = box.width / box.height
const boxRatio = box.width / box.height
if (imgRatio > boxRatio && imgHeight < box.height) {

@@ -644,8 +643,8 @@ ih = box.height

$img.style.height = ih + 'px'
let x = (box.winWidth - iw) / 2
let y = (box.winHeight - ih) / 2
const x = (box.winWidth - iw) / 2
const y = (box.winHeight - ih) / 2
$img.style.transform = `translate(${x}px, ${y}px) rotate(0)`
_this.translate = {
x,
y,
y
}

@@ -659,11 +658,11 @@ }

// 缩放比例
let ratio = this.cropRatio
const ratio = this.cropRatio
// 裁剪框位置
let box = this.cropBoxPos
const box = this.cropBoxPos
// 图片位置
let pos = $img.getBoundingClientRect()
const pos = $img.getBoundingClientRect()
// 旋转角度
let angle = this.angle % 360
let isRotate = angle % 180
let result = {
const angle = this.angle % 360
const isRotate = angle % 180
const result = {
angle,

@@ -670,0 +669,0 @@ naturalWidth: isRotate ? $img.naturalHeight : $img.naturalWidth,

@@ -62,3 +62,3 @@ /**

// 等比缩放
$el = handleScale(info, {width: params.currentWidth})
$el = handleScale(info, { width: params.currentWidth })
const $canvas = dom.createCanvas($el, {

@@ -74,5 +74,5 @@ sx: params.x,

})
let dataType = info.type
let base64 = $canvas.toDataURL(dataType)
let blob = util.toBlobData(base64, dataType)
const dataType = info.type
const base64 = $canvas.toDataURL(dataType)
const blob = util.toBlobData(base64, dataType)

@@ -101,3 +101,3 @@ resolve && resolve({

function handleScale (info, opts) {
let res = calculator.scaleInfo(opts, info)
const res = calculator.scaleInfo(opts, info)
// image/canvas 元素

@@ -107,4 +107,4 @@ let $el = info.element

let scaling
let sw = res.sw,
sh = res.sh
let sw = res.sw
let sh = res.sh
// 逐级缩放,防止出现像素锯齿

@@ -151,7 +151,7 @@ if (res.scaling > 2) {

const ctx = $canvas.getContext('2d')
let imgWidth = $img.width
let imgHeight = $img.height
const imgWidth = $img.width
const imgHeight = $img.height
$canvas.width = imgWidth
$canvas.height = imgHeight
switch(angle) {
switch (angle) {
// 旋转90度

@@ -169,4 +169,4 @@ case 90:

ctx.drawImage($img, -imgWidth, -imgHeight, imgWidth, imgHeight)
break;
case 270: // 旋转-90(270)度
break
case 270: // 旋转-90(270)度
$canvas.width = imgHeight

@@ -173,0 +173,0 @@ $canvas.height = imgWidth

@@ -22,3 +22,3 @@ /**

*/
const supportTouch = !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch)
const supportTouch = !!(('ontouchstart' in window) || (window.DocumentTouch && document instanceof DocumentTouch))

@@ -35,5 +35,5 @@ /**

export const touchEvents = {
start : supportTouch ? 'touchstart' : desktopEvents[0],
move : supportTouch ? 'touchmove' : desktopEvents[1],
end : supportTouch ? 'touchend' : desktopEvents[2]
start: supportTouch ? 'touchstart' : desktopEvents[0],
move: supportTouch ? 'touchmove' : desktopEvents[1],
end: supportTouch ? 'touchend' : desktopEvents[2]
}

@@ -23,3 +23,3 @@ /**

export function getTouches (event, $container) {
let position = $container.getBoundingClientRect()
const position = $container.getBoundingClientRect()
return util.slice(event.touches).map(touch => {

@@ -40,4 +40,4 @@ return {

function calculateScale (startTouches, endTouches) {
let startDistance = getDistance(startTouches[0], startTouches[1])
let endDistance = getDistance(endTouches[0], endTouches[1])
const startDistance = getDistance(startTouches[0], startTouches[1])
const endDistance = getDistance(endTouches[0], endTouches[1])
return endDistance / startDistance

@@ -47,4 +47,4 @@ }

function getDistance (a, b) {
let x = a.x - b.x
let y = a.y - b.y
const x = a.x - b.x
const y = a.y - b.y
return Math.sqrt(x * x + y * y)

@@ -51,0 +51,0 @@ }

@@ -24,3 +24,3 @@ /**

// 计算文件大小多少kb
let kb = util.bitToKib(size)
const kb = util.bitToKib(size)
return kb >= 1024 ? util.int(kb / 1024 * 100) / 100 + 'M' : util.int(kb) + 'KB'

@@ -37,7 +37,7 @@ },

// data = data.split(',')[1]
let dataInfo = getBase64Info(base64)
let data = window.atob(dataInfo.data)
const dataInfo = getBase64Info(base64)
const data = window.atob(dataInfo.data)
type = type || dataInfo.type
let ia = new Uint8Array(data.length)
const ia = new Uint8Array(data.length)
for (let i = 0; i < data.length; i++) {

@@ -47,3 +47,3 @@ ia[i] = data.charCodeAt(i)

// canvas.toDataURL 返回的默认格式是 image/png
return new Blob([ia], {type: type})
return new Blob([ia], { type: type })
},

@@ -75,3 +75,3 @@

int (m) {
let n = parseInt(m)
const n = parseInt(m)
return isNaN(n) ? 0 : n

@@ -120,2 +120,6 @@ },

return prefix + '_' + (+new Date())
},
hasOwn(o, key) {
return Object.prototype.hasOwnProperty.call(o, key)
}

@@ -131,3 +135,3 @@ }

// "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAkGB+wgHBgkIBwgKCgkLDRYPDQw//9k="
let arr = data.split(',')
const arr = data.split(',')
let type = ''

@@ -134,0 +138,0 @@ if (/data:(\w+\/\w+);base64/.test(arr[0])) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc