text: /*!
   * Image Compressor v0.5.2
   * https://github.com/xkeshi/image-compressor
   *
   * Copyright (c) 2017 Xkeshi
   * Released under the MIT license
   *
   * Date: 2017-10-09T02:40:37.129Z
   */
  !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.ImageCompressor=t()}(this,function(){"use strict";function e(e){return s.test(e)}function t(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=e(t)?t.substr(6):"";return"jpeg"===r&&(r="jpg"),r&&n&&(r="."+r),r}function n(e,t,n){var r="",o=void 0;for(n+=t,o=t;o<n;o+=1)r+=f(e.getUint8(o));return r}function r(e,t){var n=new Uint8Array(e),r=n.length,o="",i=void 0;for(i=0;i<r;i+=1)o+=f(n[i]);return"data:"+t+";base64,"+h(o)}function o(e){var t=new DataView(e),r=void 0,o=void 0,i=void 0,a=void 0;if(255===t.getUint8(0)&&216===t.getUint8(1))for(var u=t.byteLength,c=2;c<u;){if(255===t.getUint8(c)&&225===t.getUint8(c+1)){i=c;break}c+=1}if(i){var l=i+10;if("Exif"===n(t,i+4,4)){var s=t.getUint16(l);if(((o=18761===s)||19789===s)&&42===t.getUint16(l+2,o)){var f=t.getUint32(l+4,o);f>=8&&(a=l+f)}}}if(a){var h=t.getUint16(a,o),m=void 0,d=void 0;for(d=0;d<h;d+=1)if(m=a+12*d+2,274===t.getUint16(m,o)){m+=8,r=t.getUint16(m,o),t.setUint16(m,1,o);break}}return r}function i(e){var t=0,n=1,r=1;switch(e){case 2:n=-1;break;case 3:t=-180;break;case 4:r=-1;break;case 5:t=90,r=-1;break;case 6:t=90;break;case 7:t=90,n=-1;break;case 8:t=-90}return{rotate:t,scaleX:n,scaleY:r}}var a=function(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e){!function(t){var n=t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype,r=t.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),o=r&&t.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),i=t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder,a=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,u=(r||i)&&t.atob&&t.ArrayBuffer&&t.Uint8Array&&function(e){var t,n,u,c,l,s,f,h,m;if(!(t=e.match(a)))throw new Error("invalid data URI");for(n=t[2]?t[1]:"text/plain"+(t[3]||";charset=US-ASCII"),u=!!t[4],c=e.slice(t[0].length),l=u?atob(c):decodeURIComponent(c),s=new ArrayBuffer(l.length),f=new Uint8Array(s),h=0;h<l.length;h+=1)f[h]=l.charCodeAt(h);return r?new Blob([o?f:s],{type:n}):((m=new i).append(s),m.getBlob(n))};t.HTMLCanvasElement&&!n.toBlob&&(n.mozGetAsFile?n.toBlob=function(e,t,r){var o=this;setTimeout(function(){e(r&&n.toDataURL&&u?u(o.toDataURL(t,r)):o.mozGetAsFile("blob",t))})}:n.toDataURL&&u&&(n.toBlob=function(e,t,n){var r=this;setTimeout(function(){e(u(r.toDataURL(t,n)))})})),e.exports?e.exports=u:t.dataURLtoBlob=u}(window)}),u=Object.prototype.toString,c=function(e){return e instanceof Blob||"[object Blob]"===u.call(e)},l={checkOrientation:!0,maxWidth:1/0,maxHeight:1/0,minWidth:0,minHeight:0,width:void 0,height:void 0,quality:.8,mimeType:"auto",convertSize:5e6,success:null,error:null},s=/^image\/.+$/,f=String.fromCharCode,h=window.btoa,m=(function(){function e(e){this.value=e}function t(t){function n(o,i){try{var a=t[o](i),u=a.value;u instanceof e?Promise.resolve(u.value).then(function(e){n("next",e)},function(e){n("throw",e)}):r(a.done?"return":"normal",a.value)}catch(e){r("throw",e)}}function r(e,t){switch(e){case"return":o.resolve({value:t,done:!0});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:!1})}(o=o.next)?n(o.key,o.arg):i=null}var o,i;this._invoke=function(e,t){return new Promise(function(r,a){var u={key:e,arg:t,resolve:r,reject:a,next:null};i?i=i.next=u:(o=i=u,n(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}),d=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},b=window,g=b.ArrayBuffer,p=b.FileReader,w=window.URL||window.webkitURL,y=/\.\w+$/;return function(){function n(e,t){m(this,n),this.result=null,e&&this.compress(e,t)}return d(n,[{key:"compress",value:function(n,u){var s=this,f=new Image;return u=v({},l,u),g||(u.checkOrientation=!1),new Promise(function(t,a){if(c(n)){var l=n.type;if(e(l))if(w||p){if(w&&!u.checkOrientation)t(w.createObjectURL(n));else if(p){var s=new p,f=u.checkOrientation&&"image/jpeg"===l;s.onload=function(e){var n=e.target.result;t(f?v({url:r(n,l)},i(o(n))):{url:n})},s.onabort=a,s.onerror=a,f?s.readAsArrayBuffer(n):s.readAsDataURL(n)}}else a(new Error("The current browser does not support image compression."));else a(new Error("The first argument must be an image File or Blob object."))}else a(new Error("The first argument must be a File or Blob object."))}).then(function(e){return new Promise(function(t,r){f.onload=function(){return t(v({},e,{naturalWidth:f.naturalWidth,naturalHeight:f.naturalHeight}))},f.onabort=r,f.onerror=r,f.alt=n.name,f.src=e.url})}).then(function(t){var r=t.naturalWidth,o=t.naturalHeight,i=t.rotate,c=void 0===i?0:i,l=t.scaleX,s=void 0===l?1:l,h=t.scaleY,m=void 0===h?1:h;return new Promise(function(t){var i=document.createElement("canvas"),l=i.getContext("2d"),h=r/o,d=Math.max(u.maxWidth,0)||1/0,v=Math.max(u.maxHeight,0)||1/0,b=Math.max(u.minWidth,0)||0,g=Math.max(u.minHeight,0)||0,p=r,w=o;d<1/0&&v<1/0?v*h>d?v=d/h:d=v*h:d<1/0?v=d/h:v<1/0&&(d=v*h),b>0&&g>0?g*h>b?g=b/h:b=g*h:b>0?g=b/h:g>0&&(b=g*h),u.width>0?w=(p=u.width)/h:u.height>0&&(p=(w=u.height)*h);var y=-(p=Math.min(Math.max(p,b),d))/2,U=-(w=Math.min(Math.max(w,g),v))/2,x=p,B=w;if(Math.abs(c)%180==90){var k={width:w,height:p};p=k.width,w=k.height}i.width=p,i.height=w,l.fillStyle="transparent",l.fillRect(0,0,p,w),l.save(),l.translate(p/2,w/2),l.rotate(c*Math.PI/180),l.scale(s,m),l.drawImage(f,Math.floor(y),Math.floor(U),Math.floor(x),Math.floor(B)),l.restore(),e(u.mimeType)||(u.mimeType=n.type),n.size>u.convertSize&&"image/png"===u.mimeType&&(u.mimeType="image/jpeg"),i.toBlob?i.toBlob(t,u.mimeType,u.quality):t(a(i.toDataURL(u.mimeType,u.quality)))})}).then(function(e){if(w&&w.revokeObjectURL(f.src),e)if(e.size>n.size&&!(u.width>0||u.height>0||u.maxWidth<1/0||u.maxHeight<1/0||u.minWidth>0||u.minHeight>0))e=n;else{var r=new Date;e.lastModified=r.getTime(),e.lastModifiedDate=r,e.name=n.name,e.name&&e.type!==n.type&&(e.name=e.name.replace(y,t(e.type)))}else e=n;return s.result=e,u.success&&u.success(e),Promise.resolve(e)}).catch(function(e){if(!u.error)throw e;u.error(e)})}}]),n}()});