@idecardo/vue-croppie
Version:
A Croppie wrapper for VueJS 2
2 lines (1 loc) • 30.7 kB
JavaScript
var Croppie=function(e){"use strict";function t(){var e=document.head||document.getElementsByTagName("head")[0],n=t.styles||(t.styles={}),i="undefined"!=typeof navigator&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());return function(t,o){if(!document.querySelector('style[data-vue-ssr-id~="'+t+'"]')){var r=i?o.media||"default":t,a=n[r]||(n[r]={ids:[],parts:[],element:void 0});if(!a.ids.includes(t)){var s=o.source,l=a.ids.length;if(a.ids.push(t),o.map&&(s+="\n/*# sourceURL="+o.map.sources[0]+" */",s+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o.map))))+" */"),i&&(a.element=a.element||document.querySelector("style[data-group="+r+"]")),!a.element){var c=a.element=document.createElement("style");c.type="text/css",o.media&&c.setAttribute("media",o.media),i&&(c.setAttribute("data-group",r),c.setAttribute("data-next-index","0")),e.appendChild(c)}if(i&&(l=parseInt(a.element.getAttribute("data-next-index")),a.element.setAttribute("data-next-index",l+1)),a.element.styleSheet)a.parts.push(s),a.element.styleSheet.cssText=a.parts.filter(Boolean).join("\n");else{var u=document.createTextNode(s),p=a.element.childNodes;p[l]&&a.element.removeChild(p[l]),p.length?a.element.insertBefore(u,p[l]):a.element.appendChild(u)}}}}}function n(e){n.installed||(n.installed=!0,e.component("Croppie",r))}var i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=function(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e,t){!function(e,n){n("string"!=typeof t.nodeName?t:e.commonJsStrict={})}(i,function(t){function n(e){if(e in V)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=K.length;n--;)if((e=K[n]+t)in V)return e}function i(e,t){var n=J.indexOf(e)>-1?J:Q,i=n.indexOf(e),o=t/90%n.length;return n[(n.length+i+o%n.length)%n.length]}function o(e,t){e=e||{};for(var n in t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},o(e[n],t[n])):e[n]=t[n];return e}function r(e){return o({},e)}function a(e){if("createEvent"in document){var t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0),e.dispatchEvent(t)}else e.fireEvent("onchange")}function s(e,t,n){if("string"==typeof t){var i=t;(t={})[i]=n}for(var o in t)e.style[o]=t[o]}function l(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function c(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(t,"")}function u(e,t){for(var n in t)e.setAttribute(n,t[n])}function p(e){return parseInt(e,10)}function d(e,t){var n=new Image;return n.style.opacity=0,new Promise(function(i){function o(){n.style.opacity=1,setTimeout(function(){i(n)},1)}n.removeAttribute("crossOrigin"),e.match(/^https?:\/\/|^\/\//)&&n.setAttribute("crossOrigin","anonymous"),n.onload=function(){t?EXIF.getData(n,function(){o()}):o()},n.src=e})}function h(e,t){var n=e.naturalWidth,i=e.naturalHeight,o=t||m(e);if(o&&o>=5){var r=n;n=i,i=r}return{width:n,height:i}}function m(e){return e.exifdata?e.exifdata.Orientation:1}function f(e,t,n){var i=t.width,o=t.height,r=e.getContext("2d");switch(e.width=t.width,e.height=t.height,r.save(),n){case 2:r.translate(i,0),r.scale(-1,1);break;case 3:r.translate(i,o),r.rotate(180*Math.PI/180);break;case 4:r.translate(0,o),r.scale(1,-1);break;case 5:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.scale(1,-1);break;case 6:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.translate(0,-o);break;case 7:e.width=o,e.height=i,r.rotate(-90*Math.PI/180),r.translate(-i,o),r.scale(1,-1);break;case 8:e.width=o,e.height=i,r.translate(0,i),r.rotate(-90*Math.PI/180)}r.drawImage(t,0,0,i,o),r.restore()}function v(){var e,t,n,i,o,r=this,a=r.options.viewport.type?"cr-vp-"+r.options.viewport.type:null;r.options.useCanvas=r.options.enableOrientation||g.call(r),r.data={},r.elements={},e=r.elements.boundary=document.createElement("div"),t=r.elements.viewport=document.createElement("div"),r.elements.img=document.createElement("img"),n=r.elements.overlay=document.createElement("div"),r.options.useCanvas?(r.elements.canvas=document.createElement("canvas"),r.elements.preview=r.elements.canvas):r.elements.preview=r.elements.img,l(e,"cr-boundary"),e.setAttribute("aria-dropeffect","none"),i=r.options.boundary.width,o=r.options.boundary.height,s(e,{width:i+(isNaN(i)?"":"px"),height:o+(isNaN(o)?"":"px")}),l(t,"cr-viewport"),a&&l(t,a),s(t,{width:r.options.viewport.width+"px",height:r.options.viewport.height+"px"}),t.setAttribute("tabindex",0),l(r.elements.preview,"cr-image"),u(r.elements.preview,{alt:"preview","aria-grabbed":"false"}),l(n,"cr-overlay"),r.element.appendChild(e),e.appendChild(r.elements.preview),e.appendChild(t),e.appendChild(n),l(r.element,"croppie-container"),r.options.customClass&&l(r.element,r.options.customClass),z.call(this),r.options.enableZoom&&y.call(r),r.options.enableResize&&w.call(r)}function g(){return this.options.enableExif&&window.EXIF}function w(){function e(e){if((void 0===e.button||0===e.button)&&(e.preventDefault(),!m)){var s=d.elements.overlay.getBoundingClientRect();if(m=!0,o=e.pageX,r=e.pageY,i=-1!==e.currentTarget.className.indexOf("vertical")?"v":"h",a=s.width,c=s.height,e.touches){var l=e.touches[0];o=l.pageX,r=l.pageY}window.addEventListener("mousemove",t),window.addEventListener("touchmove",t),window.addEventListener("mouseup",n),window.addEventListener("touchend",n),document.body.style[U]="none"}}function t(e){var t=e.pageX,n=e.pageY;if(e.preventDefault(),e.touches){var l=e.touches[0];t=l.pageX,n=l.pageY}var u=t-o,p=n-r,m=d.options.viewport.height+p,v=d.options.viewport.width+u;"v"===i&&m>=f&&m<=c?(s(h,{height:m+"px"}),d.options.boundary.height+=p,s(d.elements.boundary,{height:d.options.boundary.height+"px"}),d.options.viewport.height+=p,s(d.elements.viewport,{height:d.options.viewport.height+"px"})):"h"===i&&v>=f&&v<=a&&(s(h,{width:v+"px"}),d.options.boundary.width+=u,s(d.elements.boundary,{width:d.options.boundary.width+"px"}),d.options.viewport.width+=u,s(d.elements.viewport,{width:d.options.viewport.width+"px"})),k.call(d),_.call(d),E.call(d),B.call(d),r=n,o=t}function n(){m=!1,window.removeEventListener("mousemove",t),window.removeEventListener("touchmove",t),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),document.body.style[U]=""}var i,o,r,a,c,u,p,d=this,h=document.createElement("div"),m=!1,f=50;l(h,"cr-resizer"),s(h,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),this.options.resizeControls.height&&(l(u=document.createElement("div"),"cr-resizer-vertical"),h.appendChild(u)),this.options.resizeControls.width&&(l(p=document.createElement("div"),"cr-resizer-horisontal"),h.appendChild(p)),u&&(u.addEventListener("mousedown",e),u.addEventListener("touchstart",e)),p&&(p.addEventListener("mousedown",e),p.addEventListener("touchstart",e)),this.elements.boundary.appendChild(h)}function b(e){if(this.options.enableZoom){var t=this.elements.zoomer,n=Y(e,4);t.value=Math.max(t.min,Math.min(t.max,n))}}function y(){function e(){x.call(n,{value:parseFloat(o.value),origin:new te(n.elements.preview),viewportRect:n.elements.viewport.getBoundingClientRect(),transform:ee.parse(n.elements.preview)})}function t(t){var i,o;if("ctrl"===n.options.mouseWheelZoom&&!0!==t.ctrlKey)return 0;i=t.wheelDelta?t.wheelDelta/1200:t.deltaY?t.deltaY/1060:t.detail?t.detail/-60:0,o=n._currentZoom+i*n._currentZoom,t.preventDefault(),b.call(n,o),e.call(n)}var n=this,i=n.elements.zoomerWrap=document.createElement("div"),o=n.elements.zoomer=document.createElement("input");l(i,"cr-slider-wrap"),l(o,"cr-slider"),o.type="range",o.step="0.0001",o.value=1,o.style.display=n.options.showZoomer?"":"none",o.setAttribute("aria-label","zoom"),n.element.appendChild(i),i.appendChild(o),n._currentZoom=1,n.elements.zoomer.addEventListener("input",e),n.elements.zoomer.addEventListener("change",e),n.options.mouseWheelZoom&&(n.elements.boundary.addEventListener("mousewheel",t),n.elements.boundary.addEventListener("DOMMouseScroll",t))}function x(e){function t(){var e={};e[$]=i.toString(),e[q]=r.toString(),s(n.elements.preview,e)}var n=this,i=e?e.transform:ee.parse(n.elements.preview),o=e?e.viewportRect:n.elements.viewport.getBoundingClientRect(),r=e?e.origin:new te(n.elements.preview);if(n._currentZoom=e?e.value:n._currentZoom,i.scale=n._currentZoom,n.elements.zoomer.setAttribute("aria-valuenow",n._currentZoom),t(),n.options.enforceBoundary){var a=C.call(n,o),l=a.translate,c=a.origin;i.x>=l.maxX&&(r.x=c.minX,i.x=l.maxX),i.x<=l.minX&&(r.x=c.maxX,i.x=l.minX),i.y>=l.maxY&&(r.y=c.minY,i.y=l.maxY),i.y<=l.minY&&(r.y=c.maxY,i.y=l.minY)}t(),ne.call(n),B.call(n)}function C(e){var t=this,n=t._currentZoom,i=e.width,o=e.height,r=t.elements.boundary.clientWidth/2,a=t.elements.boundary.clientHeight/2,s=t.elements.preview.getBoundingClientRect(),l=s.width,c=s.height,u=i/2,p=o/2,d=-1*(u/n-r),h=-1*(p/n-a),m=1/n*u,f=1/n*p;return{translate:{maxX:d,minX:d-(l*(1/n)-i*(1/n)),maxY:h,minY:h-(c*(1/n)-o*(1/n))},origin:{maxX:l*(1/n)-m,minX:m,maxY:c*(1/n)-f,minY:f}}}function E(){var e=this,t=e._currentZoom,n=e.elements.preview.getBoundingClientRect(),i=e.elements.viewport.getBoundingClientRect(),o=ee.parse(e.elements.preview.style[$]),r=new te(e.elements.preview),a=i.top-n.top+i.height/2,l=i.left-n.left+i.width/2,c={},u={};c.y=a/t,c.x=l/t,u.y=(c.y-r.y)*(1-t),u.x=(c.x-r.x)*(1-t),o.x-=u.x,o.y-=u.y;var p={};p[q]=c.x+"px "+c.y+"px",p[$]=o.toString(),s(e.elements.preview,p)}function z(){function e(e,t){var n=m.elements.preview.getBoundingClientRect(),i=h.y+t,o=h.x+e;m.options.enforceBoundary?(d.top>n.top+t&&d.bottom<n.bottom+t&&(h.y=i),d.left>n.left+e&&d.right<n.right+e&&(h.x=o)):(h.y=i,h.x=o)}function t(e){m.elements.preview.setAttribute("aria-grabbed",e),m.elements.boundary.setAttribute("aria-dropeffect",e?"move":"none")}function n(e){var t=37,n=38,o=39,r=40;if(!e.shiftKey||e.keyCode!==n&&e.keyCode!==r){if(m.options.enableKeyMovement&&e.keyCode>=37&&e.keyCode<=40){e.preventDefault();var a=function(e){switch(e){case t:return[1,0];case n:return[0,1];case o:return[-1,0];case r:return[0,-1]}}(e.keyCode);h=ee.parse(m.elements.preview),document.body.style[U]="none",d=m.elements.viewport.getBoundingClientRect(),i(a)}}else{var s=0;s=e.keyCode===n?parseFloat(m.elements.zoomer.value,10)+parseFloat(m.elements.zoomer.step,10):parseFloat(m.elements.zoomer.value,10)-parseFloat(m.elements.zoomer.step,10),m.setZoom(s)}}function i(t){var n={};e(t[0],t[1]),n[$]=h.toString(),s(m.elements.preview,n),k.call(m),document.body.style[U]="",E.call(m),B.call(m),p=0}function o(e){if((void 0===e.button||0===e.button)&&(e.preventDefault(),!f)){if(f=!0,c=e.pageX,u=e.pageY,e.touches){var n=e.touches[0];c=n.pageX,u=n.pageY}t(f),h=ee.parse(m.elements.preview),window.addEventListener("mousemove",r),window.addEventListener("touchmove",r),window.addEventListener("mouseup",l),window.addEventListener("touchend",l),document.body.style[U]="none",d=m.elements.viewport.getBoundingClientRect()}}function r(t){t.preventDefault();var n=t.pageX,i=t.pageY;if(t.touches){var o=t.touches[0];n=o.pageX,i=o.pageY}var r=n-c,l=i-u,d={};if("touchmove"===t.type&&t.touches.length>1){var f=t.touches[0],v=t.touches[1],g=Math.sqrt((f.pageX-v.pageX)*(f.pageX-v.pageX)+(f.pageY-v.pageY)*(f.pageY-v.pageY));p||(p=g/m._currentZoom);var w=g/p;return b.call(m,w),void a(m.elements.zoomer)}e(r,l),d[$]=h.toString(),s(m.elements.preview,d),k.call(m),u=i,c=n}function l(){t(f=!1),window.removeEventListener("mousemove",r),window.removeEventListener("touchmove",r),window.removeEventListener("mouseup",l),window.removeEventListener("touchend",l),document.body.style[U]="",E.call(m),B.call(m),p=0}var c,u,p,d,h,m=this,f=!1;m.elements.overlay.addEventListener("mousedown",o),m.elements.viewport.addEventListener("keydown",n),m.elements.overlay.addEventListener("touchstart",o)}function k(){if(this.elements){var e=this,t=e.elements.boundary.getBoundingClientRect(),n=e.elements.preview.getBoundingClientRect();s(e.elements.overlay,{width:n.width+"px",height:n.height+"px",top:n.top-t.top+"px",left:n.left-t.left+"px"})}}function B(){var e=this,t=e.get();if(L.call(e))if(e.options.update.call(e,t),e.$&&"undefined"==typeof Prototype)e.$(e.element).trigger("update.croppie",t);else{var n;window.CustomEvent?n=new CustomEvent("update",{detail:t}):(n=document.createEvent("CustomEvent")).initCustomEvent("update",!0,!0,t),e.element.dispatchEvent(n)}}function L(){return this.elements.preview.offsetHeight>0&&this.elements.preview.offsetWidth>0}function Z(){var e=this,t={},n=e.elements.preview,i=null,o=new ee(0,0,1),r=new te;L.call(e)&&!e.data.bound&&(e.data.bound=!0,t[$]=o.toString(),t[q]=r.toString(),t.opacity=1,s(n,t),i=e.elements.preview.getBoundingClientRect(),e._originalImageWidth=i.width,e._originalImageHeight=i.height,e.data.orientation=m(e.elements.img),e.options.enableZoom?_.call(e,!0):e._currentZoom=1,o.scale=e._currentZoom,t[$]=o.toString(),s(n,t),e.data.points.length?R.call(e,e.data.points):S.call(e),E.call(e),k.call(e))}function _(e){var t,n,i,o,r=this,s=0,l=r.options.maxZoom||1.5,c=r.elements.zoomer,u=parseFloat(c.value),p=r.elements.boundary.getBoundingClientRect(),d=h(r.elements.img,r.data.orientation),m=r.elements.viewport.getBoundingClientRect();r.options.enforceBoundary&&(i=m.width/d.width,o=m.height/d.height,s=Math.max(i,o)),s>=l&&(l=s+1),c.min=Y(s,4),c.max=Y(l,4),!e&&(u<c.min||u>c.max)?b.call(r,u<c.min?c.min:c.max):e&&(n=Math.max(p.width/d.width,p.height/d.height),t=null!==r.data.boundZoom?r.data.boundZoom:n,b.call(r,t)),a(c)}function R(e){if(4!==e.length)throw"Croppie - Invalid number of points supplied: "+e;var t=this,n=e[2]-e[0],i=t.elements.viewport.getBoundingClientRect(),o=t.elements.boundary.getBoundingClientRect(),r={left:i.left-o.left,top:i.top-o.top},a=i.width/n,l=e[1],c=e[0],u=-1*e[1]+r.top,p=-1*e[0]+r.left,d={};d[q]=c+"px "+l+"px",d[$]=new ee(p,u,a).toString(),s(t.elements.preview,d),b.call(t,a),t._currentZoom=a}function S(){var e=this,t=e.elements.preview.getBoundingClientRect(),n=e.elements.viewport.getBoundingClientRect(),i=e.elements.boundary.getBoundingClientRect(),o=n.left-i.left,r=n.top-i.top,a=o-(t.width-n.width)/2,l=r-(t.height-n.height)/2,c=new ee(a,l,e._currentZoom);s(e.elements.preview,$,c.toString())}function I(e){var t=this,n=t.elements.canvas,i=t.elements.img,o=n.getContext("2d"),r=g.call(t),e=t.options.enableOrientation&&e;o.clearRect(0,0,n.width,n.height),n.width=i.width,n.height=i.height,r&&!e?f(n,i,p(m(i)||0,10)):e&&f(n,i,e)}function M(e){var t=this,n=e.points,i=p(n[0]),o=p(n[1]),r=p(n[2])-i,a=p(n[3])-o,s=e.circle,l=document.createElement("canvas"),c=l.getContext("2d"),u=e.outputWidth||r,d=e.outputHeight||a;e.outputWidth&&e.outputHeight;return l.width=u,l.height=d,e.backgroundColor&&(c.fillStyle=e.backgroundColor,c.fillRect(0,0,u,d)),!1!==t.options.enforceBoundary&&(r=Math.min(r,t._originalImageWidth),a=Math.min(a,t._originalImageHeight)),c.drawImage(this.elements.preview,i,o,r,a,0,0,u,d),s&&(c.fillStyle="#fff",c.globalCompositeOperation="destination-in",c.beginPath(),c.arc(l.width/2,l.height/2,l.width/2,0,2*Math.PI,!0),c.closePath(),c.fill()),l}function A(e){var t=e.points,n=document.createElement("div"),i=document.createElement("img"),o=t[2]-t[0],r=t[3]-t[1];return l(n,"croppie-result"),n.appendChild(i),s(i,{left:-1*t[0]+"px",top:-1*t[1]+"px"}),i.src=e.url,s(n,{width:o+"px",height:r+"px"}),n}function O(e){return M.call(this,e).toDataURL(e.format,e.quality)}function j(e){var t=this;return new Promise(function(n,i){M.call(t,e).toBlob(function(e){n(e)},e.format,e.quality)})}function F(e){this.elements.img.parentNode&&(Array.prototype.forEach.call(this.elements.img.classList,function(t){e.classList.add(t)}),this.elements.img.parentNode.replaceChild(e,this.elements.img),this.elements.preview=e),this.elements.img=e}function X(e,t){var n,i=this,o=[],r=null,a=g.call(i);if("string"==typeof e)n=e,e={};else if(Array.isArray(e))o=e.slice();else{if(void 0===e&&i.data.url)return Z.call(i),B.call(i),null;n=e.url,o=e.points||[],r=void 0===e.zoom?null:e.zoom}return i.data.bound=!1,i.data.url=n||i.data.url,i.data.boundZoom=r,d(n,a).then(function(n){if(F.call(i,n),o.length)i.options.relative&&(o=[o[0]*n.naturalWidth/100,o[1]*n.naturalHeight/100,o[2]*n.naturalWidth/100,o[3]*n.naturalHeight/100]);else{var r,a,s=h(n),l=i.elements.viewport.getBoundingClientRect(),c=l.width/l.height;s.width/s.height>c?r=(a=s.height)*c:(r=s.width,a=s.height/c);var u=(s.width-r)/2,p=(s.height-a)/2,d=u+r,m=p+a;i.data.points=[u,p,d,m]}i.data.points=o.map(function(e){return parseFloat(e)}),i.options.useCanvas&&I.call(i,e.orientation||1),Z.call(i),B.call(i),t&&t()}).catch(function(e){console.error("Croppie:"+e)})}function Y(e,t){return parseFloat(e).toFixed(t||0)}function N(){var e=this,t=e.elements.preview.getBoundingClientRect(),n=e.elements.viewport.getBoundingClientRect(),i=n.left-t.left,o=n.top-t.top,r=(n.width-e.elements.viewport.offsetWidth)/2,a=(n.height-e.elements.viewport.offsetHeight)/2,s=i+e.elements.viewport.offsetWidth+r,l=o+e.elements.viewport.offsetHeight+a,c=e._currentZoom;(c===1/0||isNaN(c))&&(c=1);var u=e.options.enforceBoundary?0:Number.NEGATIVE_INFINITY;return i=Math.max(u,i/c),o=Math.max(u,o/c),s=Math.max(u,s/c),l=Math.max(u,l/c),{points:[Y(i),Y(o),Y(s),Y(l)],zoom:c,orientation:e.data.orientation}}function W(e){var t=this,n=N.call(t),i=o(r(ie),r(e)),a="string"==typeof e?e:i.type||"base64",s=i.size||"viewport",l=i.format,c=i.quality,u=i.backgroundColor,p="boolean"==typeof i.circle?i.circle:"circle"===t.options.viewport.type,d=t.elements.viewport.getBoundingClientRect(),h=d.width/d.height;return"viewport"===s?(n.outputWidth=d.width,n.outputHeight=d.height):"object"==typeof s&&(s.width&&s.height?(n.outputWidth=s.width,n.outputHeight=s.height):s.width?(n.outputWidth=s.width,n.outputHeight=s.width/h):s.height&&(n.outputWidth=s.height*h,n.outputHeight=s.height)),oe.indexOf(l)>-1&&(n.format="image/"+l,n.quality=c),n.circle=p,n.url=t.data.url,n.backgroundColor=u,new Promise(function(e,i){switch(a.toLowerCase()){case"rawcanvas":e(M.call(t,n));break;case"canvas":case"base64":e(O.call(t,n));break;case"blob":j.call(t,n).then(e);break;default:e(A.call(t,n))}})}function H(){Z.call(this)}function P(e){if(!this.options.useCanvas||!this.options.enableOrientation)throw"Croppie: Cannot rotate without enableOrientation && EXIF.js included";var t=this,n=t.elements.canvas;t.data.orientation=i(t.data.orientation,e),f(n,t.elements.img,t.data.orientation),_.call(t),x.call(t),copy=null}function T(){var e=this;e.element.removeChild(e.elements.boundary),c(e.element,"croppie-container"),e.options.enableZoom&&e.element.removeChild(e.elements.zoomerWrap),delete e.elements}function D(e,t){if(e.className.indexOf("croppie-container")>-1)throw new Error("Croppie: Can't initialize croppie more than once");if(this.element=e,this.options=o(r(D.defaults),t),"img"===this.element.tagName.toLowerCase()){var n=this.element;l(n,"cr-original-image"),u(n,{"aria-hidden":"true",alt:""});var i=document.createElement("div");this.element.parentNode.appendChild(i),i.appendChild(n),this.element=i,this.options.url=this.options.url||n.src}if(v.call(this),this.options.url){var a={url:this.options.url,points:this.options.points};delete this.options.url,delete this.options.points,X.call(this,a)}}"function"!=typeof Promise&&function(t){function n(e,t){return function(){e.apply(t,arguments)}}function i(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],c(e,n(r,this),n(a,this))}function o(e){var t=this;return null===this._state?void this._deferreds.push(e):void p(function(){var n=t._state?e.onFulfilled:e.onRejected;if(null===n)return void(t._state?e.resolve:e.reject)(t._value);var i;try{i=n(t._value)}catch(t){return void e.reject(t)}e.resolve(i)})}function r(e){try{if(e===this)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if("function"==typeof t)return void c(n(t,e),n(r,this),n(a,this))}this._state=!0,this._value=e,s.call(this)}catch(e){a.call(this,e)}}function a(e){this._state=!1,this._value=e,s.call(this)}function s(){for(var e=0,t=this._deferreds.length;t>e;e++)o.call(this,this._deferreds[e]);this._deferreds=null}function l(e,t,n,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=i}function c(e,t,n){var i=!1;try{e(function(e){i||(i=!0,t(e))},function(e){i||(i=!0,n(e))})}catch(e){if(i)return;i=!0,n(e)}}var u=setTimeout,p="function"==typeof setImmediate&&setImmediate||function(e){u(e,1)},d=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};i.prototype.catch=function(e){return this.then(null,e)},i.prototype.then=function(e,t){var n=this;return new i(function(i,r){o.call(n,new l(e,t,i,r))})},i.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&d(arguments[0])?arguments[0]:arguments);return new i(function(t,n){function i(r,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){i(r,e)},n)}e[r]=a,0==--o&&t(e)}catch(e){n(e)}}if(0===e.length)return t([]);for(var o=e.length,r=0;r<e.length;r++)i(r,e[r])})},i.resolve=function(e){return e&&"object"==typeof e&&e.constructor===i?e:new i(function(t){t(e)})},i.reject=function(e){return new i(function(t,n){n(e)})},i.race=function(e){return new i(function(t,n){for(var i=0,o=e.length;o>i;i++)e[i].then(t,n)})},i._setImmediateFn=function(e){p=e},e.exports?e.exports=i:t.Promise||(t.Promise=i)}(this),"function"!=typeof window.CustomEvent&&function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,n){for(var i=atob(this.toDataURL(t,n).split(",")[1]),o=i.length,r=new Uint8Array(o),a=0;a<o;a++)r[a]=i.charCodeAt(a);e(new Blob([r],{type:t||"image/png"}))}});var q,$,U,K=["Webkit","Moz","ms"],V=document.createElement("div").style,J=[1,8,3,6],Q=[2,7,4,5];$=n("transform"),q=n("transformOrigin"),U=n("userSelect");var G={translate3d:{suffix:", 0px"},translate:{suffix:""}},ee=function(e,t,n){this.x=parseFloat(e),this.y=parseFloat(t),this.scale=parseFloat(n)};ee.parse=function(e){return e.style?ee.parse(e.style[$]):e.indexOf("matrix")>-1||e.indexOf("none")>-1?ee.fromMatrix(e):ee.fromString(e)},ee.fromMatrix=function(e){var t=e.substring(7).split(",");return t.length&&"none"!==e||(t=[1,0,0,1,0,0]),new ee(p(t[4]),p(t[5]),parseFloat(t[0]))},ee.fromString=function(e){var t=e.split(") "),n=t[0].substring(D.globals.translate.length+1).split(","),i=t.length>1?t[1].substring(6):1,o=n.length>1?n[0]:0,r=n.length>1?n[1]:0;return new ee(o,r,i)},ee.prototype.toString=function(){var e=G[D.globals.translate].suffix||"";return D.globals.translate+"("+this.x+"px, "+this.y+"px"+e+") scale("+this.scale+")"};var te=function(e){if(!e||!e.style[q])return this.x=0,void(this.y=0);var t=e.style[q].split(" ");this.x=parseFloat(t[0]),this.y=parseFloat(t[1])};te.prototype.toString=function(){return this.x+"px "+this.y+"px"};var ne=function(e,t,n){var i;return function(){var o=this,r=arguments,a=function(){i=null,n||e.apply(o,r)},s=n&&!i;clearTimeout(i),i=setTimeout(a,t),s&&e.apply(o,r)}}(k,500),ie={type:"canvas",format:"png",quality:1},oe=["jpeg","webp","png"];if(window.jQuery){var re=window.jQuery;re.fn.croppie=function(e){if("string"===typeof e){var t=Array.prototype.slice.call(arguments,1),n=re(this).data("croppie");return"get"===e?n.get():"result"===e?n.result.apply(n,t):"bind"===e?n.bind.apply(n,t):this.each(function(){var n=re(this).data("croppie");if(n){var i=n[e];if(!re.isFunction(i))throw"Croppie "+e+" method not found";i.apply(n,t),"destroy"===e&&re(this).removeData("croppie")}})}return this.each(function(){var t=new D(this,e);t.$=re,re(this).data("croppie",t)})}}D.defaults={viewport:{width:100,height:100,type:"square"},boundary:{},orientationControls:{enabled:!0,leftClass:"",rightClass:""},resizeControls:{width:!0,height:!0},customClass:"",showZoomer:!0,enableZoom:!0,enableResize:!1,mouseWheelZoom:!0,enableExif:!1,enforceBoundary:!0,enableOrientation:!1,enableKeyMovement:!0,update:function(){}},D.globals={translate:"translate3d"},o(D.prototype,{bind:function(e,t){return X.call(this,e,t)},get:function(){var e=N.call(this),t=e.points;return this.options.relative&&(t[0]/=this.elements.img.naturalWidth/100,t[1]/=this.elements.img.naturalHeight/100,t[2]/=this.elements.img.naturalWidth/100,t[3]/=this.elements.img.naturalHeight/100),e},result:function(e){return W.call(this,e)},refresh:function(){return H.call(this)},setZoom:function(e){b.call(this,e),a(this.elements.zoomer)},rotate:function(e){P.call(this,e)},destroy:function(){return T.call(this)}}),t.Croppie=window.Croppie=D})}).Croppie,r=function(e,t,n,i,o,r,a,s){var l=("function"==typeof n?n.options:n)||{};l.__file="main.vue",l.render||(l.render=e.render,l.staticRenderFns=e.staticRenderFns,l._compiled=!0,o&&(l.functional=!0)),l._scopeId=i;var c=void 0;if(t&&(c=function(e){t.call(this,a(e))}),void 0!==c)if(l.functional){var u=l.render;l.render=function(e,t){return c.call(t),u(e,t)}}else{var p=l.beforeCreate;l.beforeCreate=p?[].concat(p,c):[c]}return l}({},function(e){e&&e("data-v-38a30a3a_0",{source:"\n.croppie-container{width:100%;height:100%\n}\n.croppie-container .cr-image{z-index:-1;position:absolute;top:0;left:0;transform-origin:0 0;max-height:none;max-width:none\n}\n.croppie-container .cr-boundary{position:relative;overflow:hidden;margin:0 auto;z-index:1;width:100%;height:100%\n}\n.croppie-container .cr-resizer,.croppie-container .cr-viewport{position:absolute;border:2px solid #fff;margin:auto;top:0;bottom:0;right:0;left:0;box-shadow:0 0 2000px 2000px rgba(0,0,0,.5);z-index:0\n}\n.croppie-container .cr-resizer{z-index:2;box-shadow:none;pointer-events:none\n}\n.croppie-container .cr-resizer-horisontal,.croppie-container .cr-resizer-vertical{position:absolute;pointer-events:all\n}\n.croppie-container .cr-resizer-horisontal::after,.croppie-container .cr-resizer-vertical::after{display:block;position:absolute;box-sizing:border-box;border:1px solid #000;background:#fff;width:10px;height:10px;content:''\n}\n.croppie-container .cr-resizer-vertical{bottom:-5px;cursor:row-resize;width:100%;height:10px\n}\n.croppie-container .cr-resizer-vertical::after{left:50%;margin-left:-5px\n}\n.croppie-container .cr-resizer-horisontal{right:-5px;cursor:col-resize;width:10px;height:100%\n}\n.croppie-container .cr-resizer-horisontal::after{top:50%;margin-top:-5px\n}\n.croppie-container .cr-original-image{display:none\n}\n.croppie-container .cr-vp-circle{border-radius:50%\n}\n.croppie-container .cr-overlay{z-index:1;position:absolute;cursor:move;touch-action:none\n}\n.croppie-container .cr-slider-wrap{width:75%;margin:15px auto;text-align:center\n}\n.croppie-result{position:relative;overflow:hidden\n}\n.croppie-result img{position:absolute\n}\n.croppie-container .cr-image,.croppie-container .cr-overlay,.croppie-container .cr-viewport{-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-ms-transform:translateZ(0);transform:translateZ(0)\n}\n.cr-slider{-webkit-appearance:none;width:300px;max-width:100%;padding-top:8px;padding-bottom:8px;background-color:transparent\n}\n.cr-slider::-webkit-slider-runnable-track{width:100%;height:3px;background:rgba(0,0,0,.5);border:0;border-radius:3px\n}\n.cr-slider::-webkit-slider-thumb{-webkit-appearance:none;border:none;height:16px;width:16px;border-radius:50%;background:#ddd;margin-top:-6px\n}\n.cr-slider:focus{outline:0\n}\n.cr-slider::-moz-range-track{width:100%;height:3px;background:rgba(0,0,0,.5);border:0;border-radius:3px\n}\n.cr-slider::-moz-range-thumb{border:none;height:16px;width:16px;border-radius:50%;background:#ddd;margin-top:-6px\n}\n.cr-slider:-moz-focusring{outline:1px solid #fff;outline-offset:-1px\n}\n.cr-slider::-ms-track{width:100%;height:5px;background:0 0;border-color:transparent;border-width:6px 0;color:transparent\n}\n.cr-slider::-ms-fill-lower{background:rgba(0,0,0,.5);border-radius:10px\n}\n.cr-slider::-ms-fill-upper{background:rgba(0,0,0,.5);border-radius:10px\n}\n.cr-slider::-ms-thumb{border:none;height:16px;width:16px;border-radius:50%;background:#ddd;margin-top:1px\n}\n.cr-slider:focus::-ms-fill-lower{background:rgba(0,0,0,.5)\n}\n.cr-slider:focus::-ms-fill-upper{background:rgba(0,0,0,.5)\n}\n.cr-rotate-controls{position:absolute;bottom:5px;left:5px;z-index:1\n}\n.cr-rotate-controls button{border:0;background:0 0\n}\n.cr-rotate-controls i:before{display:inline-block;font-style:normal;font-weight:900;font-size:22px\n}\n.cr-rotate-l i:before{content:'↺'\n}\n.cr-rotate-r i:before{content:'↻'\n}",map:void 0,media:void 0})},{props:{boundary:{type:Object,default:function(){return{width:210,height:210}}},customClass:{type:String,default:""},enableExif:{type:Boolean,default:!1},enableOrientation:{type:Boolean,default:!0},enableResize:{type:Boolean,default:!1},enableZoom:{type:Boolean,default:!0},enforceBoundary:{type:Boolean,default:!0},mouseWheelZoom:{type:Boolean,default:!0},showZoomer:{type:Boolean,default:!0},viewport:{type:Object,default:function(){return{width:200,height:200,type:"square"}}}},data:function(){return{croppie:null}},mounted:function(){this.init()},destroyed:function(){this.destroy()},methods:{bind:function(e){return this.croppie.bind(e)},destroy:function(){this.croppie&&this.croppie.destroy(),this.croppie=null},get:function(e){if(!e)return this.croppie.get();e(this.croppie.get())},init:function(){var e=this,t=this.$el.querySelector('[data-croppie="container"]')||this.$el;t.addEventListener("update",function(t){e.$emit("update",t.detail)}),this.croppie=new o(t,this.options)},reset:function(){this.destroy(),this.init()},result:function(e,t){var n=this;return this.croppie.result(Object.assign({type:"base64"},e)).then(function(e){if(!t)return n.$emit("result",e),e;t(e)})},rotate:function(e){this.croppie.rotate(e)},setZoom:function(e){this.croppie.setZoom(e)}},computed:{options:function(){return Object.assign({},this.$props)}},render:function(e){var t={attrs:{"data-croppie":"container"}};return void 0!==this.$scopedSlots.default&&(t=[this.$scopedSlots.default({bind:this.bind,destroy:this.destroy,get:this.get,init:this.init,reset:this.reset,result:this.result,rotate:this.rotate,setZoom:this.setZoom})]),e("div",t)}},void 0,void 0,void 0,t,void 0),a={install:n},s=null;return"undefined"!=typeof window?s=window.Vue:"undefined"!=typeof global&&(s=global.Vue),s&&s.use(a),e.install=n,e.default=r,e}({});