UNPKG

@zklogic/draw.io

Version:

Draw.IO - Graph Editor integration in Angular-cli

1 lines 23.6 kB
!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports=t():e.Croppie=t()}("undefined"!=typeof self?self:this,(function(){"function"!=typeof Promise&&function(e){function t(e,t){return function(){e.apply(t,arguments)}}function n(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=[],l(e,t(o,this),t(r,this))}function i(e){var t=this;return null===this._state?void this._deferreds.push(e):void c((function(){var n=t._state?e.onFulfilled:e.onRejected;if(null!==n){var i;try{i=n(t._value)}catch(n){return void e.reject(n)}e.resolve(i)}else(t._state?e.resolve:e.reject)(t._value)}))}function o(e){try{if(e===this)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if("function"==typeof n)return void l(t(n,e),t(o,this),t(r,this))}this._state=!0,this._value=e,a.call(this)}catch(e){r.call(this,e)}}function r(e){this._state=!1,this._value=e,a.call(this)}function a(){for(var e=0,t=this._deferreds.length;e<t;e++)i.call(this,this._deferreds[e]);this._deferreds=null}function s(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 l(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,c="function"==typeof setImmediate&&setImmediate||function(e){u(e,1)},h=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};n.prototype.catch=function(e){return this.then(null,e)},n.prototype.then=function(e,t){var o=this;return new n((function(n,r){i.call(o,new s(e,t,n,r))}))},n.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&h(arguments[0])?arguments[0]:arguments);return new n((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(a){n(a)}}if(0===e.length)return t([]);for(var o=e.length,r=0;r<e.length;r++)i(r,e[r])}))},n.resolve=function(e){return e&&"object"==typeof e&&e.constructor===n?e:new n((function(t){t(e)}))},n.reject=function(e){return new n((function(t,n){n(e)}))},n.race=function(e){return new n((function(t,n){for(var i=0,o=e.length;i<o;i++)e[i].then(t,n)}))},n._setImmediateFn=function(e){c=e},"undefined"!=typeof module&&module.exports?module.exports=n:e.Promise||(e.Promise=n)}(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 e,t,n,i=["Webkit","Moz","ms"],o=document.createElement("div").style,r=[1,8,3,6],a=[2,7,4,5];function s(e){if(e in o)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=i.length;n--;)if((e=i[n]+t)in o)return e}function l(e,t){for(var n in e=e||{},t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},l(e[n],t[n])):e[n]=t[n];return e}function u(e){return l({},e)}function c(e){if("createEvent"in document){var t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0),e.dispatchEvent(t)}else e.fireEvent("onchange")}function h(e,t,n){if("string"==typeof t){var i=t;(t={})[i]=n}for(var o in t)e.style[o]=t[o]}function p(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function d(e,t){for(var n in t)e.setAttribute(n,t[n])}function m(e){return parseInt(e,10)}function f(e,t){var n=e.naturalWidth,i=e.naturalHeight,o=t||y(e);if(o&&5<=o){var r=n;n=i,i=r}return{width:n,height:i}}t=s("transform"),e=s("transformOrigin"),n=s("userSelect");var v={translate3d:{suffix:", 0px"},translate:{suffix:""}},g=function(e,t,n){this.x=parseFloat(e),this.y=parseFloat(t),this.scale=parseFloat(n)};g.parse=function(e){return e.style?g.parse(e.style[t]):-1<e.indexOf("matrix")||-1<e.indexOf("none")?g.fromMatrix(e):g.fromString(e)},g.fromMatrix=function(e){var t=e.substring(7).split(",");return t.length&&"none"!==e||(t=[1,0,0,1,0,0]),new g(m(t[4]),m(t[5]),parseFloat(t[0]))},g.fromString=function(e){var t=e.split(") "),n=t[0].substring(P.globals.translate.length+1).split(","),i=1<t.length?t[1].substring(6):1,o=1<n.length?n[0]:0,r=1<n.length?n[1]:0;return new g(o,r,i)},g.prototype.toString=function(){var e=v[P.globals.translate].suffix||"";return P.globals.translate+"("+this.x+"px, "+this.y+"px"+e+") scale("+this.scale+")"};var w=function(t){if(!t||!t.style[e])return this.x=0,void(this.y=0);var n=t.style[e].split(" ");this.x=parseFloat(n[0]),this.y=parseFloat(n[1])};function y(e){return e.exifdata&&e.exifdata.Orientation?m(e.exifdata.Orientation):1}function b(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 x(){var i,o,r,a,s,l,u=this,m=u.options.viewport.type?"cr-vp-"+u.options.viewport.type:null;u.options.useCanvas=u.options.enableOrientation||C.call(u),u.data={},u.elements={},i=u.elements.boundary=document.createElement("div"),r=u.elements.viewport=document.createElement("div"),o=u.elements.img=document.createElement("img"),a=u.elements.overlay=document.createElement("div"),u.options.useCanvas?(u.elements.canvas=document.createElement("canvas"),u.elements.preview=u.elements.canvas):u.elements.preview=o,p(i,"cr-boundary"),i.setAttribute("aria-dropeffect","none"),s=u.options.boundary.width,l=u.options.boundary.height,h(i,{width:s+(isNaN(s)?"":"px"),height:l+(isNaN(l)?"":"px")}),p(r,"cr-viewport"),m&&p(r,m),h(r,{width:u.options.viewport.width+"px",height:u.options.viewport.height+"px"}),r.setAttribute("tabindex",0),p(u.elements.preview,"cr-image"),d(u.elements.preview,{alt:"preview","aria-grabbed":"false"}),p(a,"cr-overlay"),u.element.appendChild(i),i.appendChild(u.elements.preview),i.appendChild(r),i.appendChild(a),p(u.element,"croppie-container"),u.options.customClass&&p(u.element,u.options.customClass),function(){var e,i,o,r,a,s=this,l=!1;function u(e,t){var n=s.elements.preview.getBoundingClientRect(),i=a.y+t,o=a.x+e;s.options.enforceBoundary?(r.top>n.top+t&&r.bottom<n.bottom+t&&(a.y=i),r.left>n.left+e&&r.right<n.right+e&&(a.x=o)):(a.y=i,a.x=o)}function p(e){s.elements.preview.setAttribute("aria-grabbed",e),s.elements.boundary.setAttribute("aria-dropeffect",e?"move":"none")}function d(t){if((void 0===t.button||0===t.button)&&(t.preventDefault(),!l)){if(l=!0,e=t.pageX,i=t.pageY,t.touches){var o=t.touches[0];e=o.pageX,i=o.pageY}p(l),a=g.parse(s.elements.preview),window.addEventListener("mousemove",m),window.addEventListener("touchmove",m),window.addEventListener("mouseup",f),window.addEventListener("touchend",f),document.body.style[n]="none",r=s.elements.viewport.getBoundingClientRect()}}function m(n){n.preventDefault();var r=n.pageX,l=n.pageY;if(n.touches){var p=n.touches[0];r=p.pageX,l=p.pageY}var d=r-e,m=l-i,f={};if("touchmove"===n.type&&1<n.touches.length){var v=n.touches[0],g=n.touches[1],w=Math.sqrt((v.pageX-g.pageX)*(v.pageX-g.pageX)+(v.pageY-g.pageY)*(v.pageY-g.pageY));o||(o=w/s._currentZoom);var y=w/o;return E.call(s,y),void c(s.elements.zoomer)}u(d,m),f[t]=a.toString(),h(s.elements.preview,f),_.call(s),i=l,e=r}function f(){p(l=!1),window.removeEventListener("mousemove",m),window.removeEventListener("touchmove",m),window.removeEventListener("mouseup",f),window.removeEventListener("touchend",f),document.body.style[n]="",L.call(s),M.call(s),o=0}s.elements.overlay.addEventListener("mousedown",d),s.elements.viewport.addEventListener("keydown",(function(e){var i,l,c;if(!e.shiftKey||38!==e.keyCode&&40!==e.keyCode){if(s.options.enableKeyMovement&&37<=e.keyCode&&e.keyCode<=40){e.preventDefault();var p=function(e){switch(e){case 37:return[1,0];case 38:return[0,1];case 39:return[-1,0];case 40:return[0,-1]}}(e.keyCode);a=g.parse(s.elements.preview),document.body.style[n]="none",r=s.elements.viewport.getBoundingClientRect(),c={},u((l=p)[0],l[1]),c[t]=a.toString(),h(s.elements.preview,c),_.call(s),document.body.style[n]="",L.call(s),M.call(s),o=0}}else i=38===e.keyCode?parseFloat(s.elements.zoomer.value)+parseFloat(s.elements.zoomer.step):parseFloat(s.elements.zoomer.value)-parseFloat(s.elements.zoomer.step),s.setZoom(i)})),s.elements.overlay.addEventListener("touchstart",d)}.call(this),u.options.enableZoom&&function(){var n=this,i=n.elements.zoomerWrap=document.createElement("div"),o=n.elements.zoomer=document.createElement("input");function r(){(function(n){var i=this,o=n?n.transform:g.parse(i.elements.preview),r=n?n.viewportRect:i.elements.viewport.getBoundingClientRect(),a=n?n.origin:new w(i.elements.preview);function s(){var n={};n[t]=o.toString(),n[e]=a.toString(),h(i.elements.preview,n)}if(i._currentZoom=n?n.value:i._currentZoom,o.scale=i._currentZoom,i.elements.zoomer.setAttribute("aria-valuenow",i._currentZoom),s(),i.options.enforceBoundary){var l=function(e){var t=this._currentZoom,n=e.width,i=e.height,o=this.elements.boundary.clientWidth/2,r=this.elements.boundary.clientHeight/2,a=this.elements.preview.getBoundingClientRect(),s=a.width,l=a.height,u=n/2,c=i/2,h=-1*(u/t-o),p=-1*(c/t-r),d=1/t*u,m=1/t*c;return{translate:{maxX:h,minX:h-(s*(1/t)-n*(1/t)),maxY:p,minY:p-(l*(1/t)-i*(1/t))},origin:{maxX:s*(1/t)-d,minX:d,maxY:l*(1/t)-m,minY:m}}}.call(i,r),u=l.translate,c=l.origin;o.x>=u.maxX&&(a.x=c.minX,o.x=u.maxX),o.x<=u.minX&&(a.x=c.maxX,o.x=u.minX),o.y>=u.maxY&&(a.y=c.minY,o.y=u.maxY),o.y<=u.minY&&(a.y=c.maxY,o.y=u.minY)}s(),z.call(i),M.call(i)}).call(n,{value:parseFloat(o.value),origin:new w(n.elements.preview),viewportRect:n.elements.viewport.getBoundingClientRect(),transform:g.parse(n.elements.preview)})}function a(e){var t,i;if("ctrl"===n.options.mouseWheelZoom&&!0!==e.ctrlKey)return 0;t=e.wheelDelta?e.wheelDelta/1200:e.deltaY?e.deltaY/1060:e.detail?e.detail/-60:0,i=n._currentZoom+t*n._currentZoom,e.preventDefault(),E.call(n,i),r.call(n)}p(i,"cr-slider-wrap"),p(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",r),n.elements.zoomer.addEventListener("change",r),n.options.mouseWheelZoom&&(n.elements.boundary.addEventListener("mousewheel",a),n.elements.boundary.addEventListener("DOMMouseScroll",a))}.call(u),u.options.enableResize&&function(){var e,t,i,o,r,a,s,l=this,u=document.createElement("div"),c=!1;function d(a){if((void 0===a.button||0===a.button)&&(a.preventDefault(),!c)){var s=l.elements.overlay.getBoundingClientRect();if(c=!0,t=a.pageX,i=a.pageY,e=-1!==a.currentTarget.className.indexOf("vertical")?"v":"h",o=s.width,r=s.height,a.touches){var u=a.touches[0];t=u.pageX,i=u.pageY}window.addEventListener("mousemove",m),window.addEventListener("touchmove",m),window.addEventListener("mouseup",f),window.addEventListener("touchend",f),document.body.style[n]="none"}}function m(n){var a=n.pageX,s=n.pageY;if(n.preventDefault(),n.touches){var c=n.touches[0];a=c.pageX,s=c.pageY}var p=a-t,d=s-i,m=l.options.viewport.height+d,f=l.options.viewport.width+p;"v"===e&&50<=m&&m<=r?(h(u,{height:m+"px"}),l.options.boundary.height+=d,h(l.elements.boundary,{height:l.options.boundary.height+"px"}),l.options.viewport.height+=d,h(l.elements.viewport,{height:l.options.viewport.height+"px"})):"h"===e&&50<=f&&f<=o&&(h(u,{width:f+"px"}),l.options.boundary.width+=p,h(l.elements.boundary,{width:l.options.boundary.width+"px"}),l.options.viewport.width+=p,h(l.elements.viewport,{width:l.options.viewport.width+"px"})),_.call(l),X.call(l),L.call(l),M.call(l),i=s,t=a}function f(){c=!1,window.removeEventListener("mousemove",m),window.removeEventListener("touchmove",m),window.removeEventListener("mouseup",f),window.removeEventListener("touchend",f),document.body.style[n]=""}p(u,"cr-resizer"),h(u,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),this.options.resizeControls.height&&(p(a=document.createElement("div"),"cr-resizer-vertical"),u.appendChild(a)),this.options.resizeControls.width&&(p(s=document.createElement("div"),"cr-resizer-horisontal"),u.appendChild(s)),a&&(a.addEventListener("mousedown",d),a.addEventListener("touchstart",d)),s&&(s.addEventListener("mousedown",d),s.addEventListener("touchstart",d)),this.elements.boundary.appendChild(u)}.call(u)}function C(){return this.options.enableExif&&window.EXIF}function E(e){if(this.options.enableZoom){var t=this.elements.zoomer,n=O(e,4);t.value=Math.max(parseFloat(t.min),Math.min(parseFloat(t.max),n)).toString()}}function L(n){var i=this,o=i._currentZoom,r=i.elements.preview.getBoundingClientRect(),a=i.elements.viewport.getBoundingClientRect(),s=g.parse(i.elements.preview.style[t]),l=new w(i.elements.preview),u=a.top-r.top+a.height/2,c=a.left-r.left+a.width/2,p={},d={};if(n){var m=l.x,f=l.y,v=s.x,y=s.y;p.y=m,p.x=f,s.y=v,s.x=y}else p.y=u/o,p.x=c/o,d.y=(p.y-l.y)*(1-o),d.x=(p.x-l.x)*(1-o),s.x-=d.x,s.y-=d.y;var b={};b[e]=p.x+"px "+p.y+"px",b[t]=s.toString(),h(i.elements.preview,b)}function _(){if(this.elements){var e=this.elements.boundary.getBoundingClientRect(),t=this.elements.preview.getBoundingClientRect();h(this.elements.overlay,{width:t.width+"px",height:t.height+"px",top:t.top-e.top+"px",left:t.left-e.left+"px"})}}w.prototype.toString=function(){return this.x+"px "+this.y+"px"};var R,B,Z,z=(R=_,function(){var e=this,t=arguments,n=B;clearTimeout(Z),Z=setTimeout((function(){Z=null,R.apply(e,t)}),500),n&&R.apply(e,t)});function M(){var e,t=this,n=t.get();I.call(t)&&(t.options.update.call(t,n),t.$&&"undefined"==typeof Prototype?t.$(t.element).trigger("update.croppie",n):(window.CustomEvent?e=new CustomEvent("update",{detail:n}):(e=document.createEvent("CustomEvent")).initCustomEvent("update",!0,!0,n),t.element.dispatchEvent(e)))}function I(){return 0<this.elements.preview.offsetHeight&&0<this.elements.preview.offsetWidth}function F(){var n,i=this,o={},r=i.elements.preview,a=new g(0,0,1),s=new w;I.call(i)&&!i.data.bound&&(i.data.bound=!0,o[t]=a.toString(),o[e]=s.toString(),o.opacity=1,h(r,o),n=i.elements.preview.getBoundingClientRect(),i._originalImageWidth=n.width,i._originalImageHeight=n.height,i.data.orientation=y(i.elements.img),i.options.enableZoom?X.call(i,!0):i._currentZoom=1,a.scale=i._currentZoom,o[t]=a.toString(),h(r,o),i.data.points.length?function(n){if(4!==n.length)throw"Croppie - Invalid number of points supplied: "+n;var i=this,o=n[2]-n[0],r=i.elements.viewport.getBoundingClientRect(),a=i.elements.boundary.getBoundingClientRect(),s=r.left-a.left,l=r.top-a.top,u=r.width/o,c=n[1],p=n[0],d=-1*n[1]+l,m=-1*n[0]+s,f={};f[e]=p+"px "+c+"px",f[t]=new g(m,d,u).toString(),h(i.elements.preview,f),E.call(i,u),i._currentZoom=u}.call(i,i.data.points):function(){var e=this,n=e.elements.preview.getBoundingClientRect(),i=e.elements.viewport.getBoundingClientRect(),o=e.elements.boundary.getBoundingClientRect(),r=i.left-o.left,a=i.top-o.top,s=r-(n.width-i.width)/2,l=a-(n.height-i.height)/2,u=new g(s,l,e._currentZoom);h(e.elements.preview,t,u.toString())}.call(i),L.call(i),_.call(i))}function X(e){var t,n,i,o,r=this,a=Math.max(r.options.minZoom,0)||0,s=r.options.maxZoom||1.5,l=r.elements.zoomer,u=parseFloat(l.value),h=r.elements.boundary.getBoundingClientRect(),p=f(r.elements.img,r.data.orientation),d=r.elements.viewport.getBoundingClientRect();r.options.enforceBoundary&&(i=d.width/p.width,o=d.height/p.height,a=Math.max(i,o)),s<=a&&(s=a+1),l.min=O(a,4),l.max=O(s,4),!e&&(u<l.min||u>l.max)?E.call(r,u<l.min?l.min:l.max):e&&(n=Math.max(h.width/p.width,h.height/p.height),t=null!==r.data.boundZoom?r.data.boundZoom:n,E.call(r,t)),c(l)}function Y(e){var t=e.points,n=m(t[0]),i=m(t[1]),o=m(t[2])-n,r=m(t[3])-i,a=e.circle,s=document.createElement("canvas"),l=s.getContext("2d"),u=e.outputWidth||o,c=e.outputHeight||r;s.width=u,s.height=c,e.backgroundColor&&(l.fillStyle=e.backgroundColor,l.fillRect(0,0,u,c));var h=n,p=i,d=o,f=r,v=0,g=0,w=u,y=c;return n<0&&(h=0,v=Math.abs(n)/o*u),d+h>this._originalImageWidth&&(w=(d=this._originalImageWidth-h)/o*u),i<0&&(p=0,g=Math.abs(i)/r*c),f+p>this._originalImageHeight&&(y=(f=this._originalImageHeight-p)/r*c),l.drawImage(this.elements.preview,h,p,d,f,v,g,w,y),a&&(l.fillStyle="#fff",l.globalCompositeOperation="destination-in",l.beginPath(),l.arc(s.width/2,s.height/2,s.width/2,0,2*Math.PI,!0),l.closePath(),l.fill()),s}function W(e,t){var n,i,o,r,a=this,s=[],l=null,u=C.call(a);if("string"==typeof e)n=e,e={};else if(Array.isArray(e))s=e.slice();else{if(void 0===e&&a.data.url)return F.call(a),M.call(a),null;n=e.url,s=e.points||[],l=void 0===e.zoom?null:e.zoom}return a.data.bound=!1,a.data.url=n||a.data.url,a.data.boundZoom=l,(i=n,o=u,r=new Image,r.style.opacity="0",new Promise((function(e,t){function n(){r.style.opacity="1",setTimeout((function(){e(r)}),1)}r.removeAttribute("crossOrigin"),i.match(/^https?:\/\/|^\/\//)&&r.setAttribute("crossOrigin","anonymous"),r.onload=function(){o?EXIF.getData(r,(function(){n()})):n()},r.onerror=function(e){r.style.opacity=1,setTimeout((function(){t(e)}),1)},r.src=i}))).then((function(n){if(function(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}.call(a,n),s.length)a.options.relative&&(s=[s[0]*n.naturalWidth/100,s[1]*n.naturalHeight/100,s[2]*n.naturalWidth/100,s[3]*n.naturalHeight/100]);else{var i,o,r=f(n),l=a.elements.viewport.getBoundingClientRect(),u=l.width/l.height;u<r.width/r.height?i=(o=r.height)*u:(i=r.width,o=r.height/u);var c=(r.width-i)/2,h=(r.height-o)/2,p=c+i,d=h+o;a.data.points=[c,h,p,d]}a.data.points=s.map((function(e){return parseFloat(e)})),a.options.useCanvas&&function(e){var t=this.elements.canvas,n=this.elements.img;t.getContext("2d").clearRect(0,0,t.width,t.height),t.width=n.width,t.height=n.height,b(t,n,this.options.enableOrientation&&e||y(n))}.call(a,e.orientation),F.call(a),M.call(a),t&&t()}))}function O(e,t){return parseFloat(e).toFixed(t||0)}function k(){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,u=e._currentZoom;(u===1/0||isNaN(u))&&(u=1);var c=e.options.enforceBoundary?0:Number.NEGATIVE_INFINITY;return i=Math.max(c,i/u),o=Math.max(c,o/u),s=Math.max(c,s/u),l=Math.max(c,l/u),{points:[O(i),O(o),O(s),O(l)],zoom:u,orientation:e.data.orientation}}var A={type:"canvas",format:"png",quality:1},j=["jpeg","webp","png"];function H(e){var t=this,n=k.call(t),i=l(u(A),u(e)),o="string"==typeof e?e:i.type||"base64",r=i.size||"viewport",a=i.format,s=i.quality,c=i.backgroundColor,d="boolean"==typeof i.circle?i.circle:"circle"===t.options.viewport.type,m=t.elements.viewport.getBoundingClientRect(),f=m.width/m.height;return"viewport"===r?(n.outputWidth=m.width,n.outputHeight=m.height):"object"==typeof r&&(r.width&&r.height?(n.outputWidth=r.width,n.outputHeight=r.height):r.width?(n.outputWidth=r.width,n.outputHeight=r.width/f):r.height&&(n.outputWidth=r.height*f,n.outputHeight=r.height)),-1<j.indexOf(a)&&(n.format="image/"+a,n.quality=s),n.circle=d,n.url=t.data.url,n.backgroundColor=c,new Promise((function(e){switch(o.toLowerCase()){case"rawcanvas":e(Y.call(t,n));break;case"canvas":case"base64":e(function(e){return Y.call(this,e).toDataURL(e.format,e.quality)}.call(t,n));break;case"blob":(function(e){var t=this;return new Promise((function(n){Y.call(t,e).toBlob((function(e){n(e)}),e.format,e.quality)}))}).call(t,n).then(e);break;default:e(function(e){var t=e.points,n=document.createElement("div"),i=document.createElement("img"),o=t[2]-t[0],r=t[3]-t[1];return p(n,"croppie-result"),n.appendChild(i),h(i,{left:-1*t[0]+"px",top:-1*t[1]+"px"}),i.src=e.url,h(n,{width:o+"px",height:r+"px"}),n}.call(t,n))}}))}function N(e){if(!this.options.useCanvas||!this.options.enableOrientation)throw"Croppie: Cannot rotate without enableOrientation && EXIF.js included";var t,n,i,o,s,l=this,u=l.elements.canvas;l.data.orientation=(t=l.data.orientation,n=e,o=(i=-1<r.indexOf(t)?r:a).indexOf(t),s=n/90%i.length,i[(i.length+o+s%i.length)%i.length]),b(u,l.elements.img,l.data.orientation),L.call(l,!0),X.call(l)}if(window.jQuery){var S=window.jQuery;S.fn.croppie=function(e){if("string"!=typeof e)return this.each((function(){var t=new P(this,e);(t.$=S)(this).data("croppie",t)}));var t=Array.prototype.slice.call(arguments,1),n=S(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=S(this).data("croppie");if(n){var i=n[e];if(!S.isFunction(i))throw"Croppie "+e+" method not found";i.apply(n,t),"destroy"===e&&S(this).removeData("croppie")}}))}}function P(e,t){if(-1<e.className.indexOf("croppie-container"))throw new Error("Croppie: Can't initialize croppie more than once");if(this.element=e,this.options=l(u(P.defaults),t),"img"===this.element.tagName.toLowerCase()){var n=this.element;p(n,"cr-original-image"),d(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(x.call(this),this.options.url){var o={url:this.options.url,points:this.options.points};delete this.options.url,delete this.options.points,W.call(this,o)}}return P.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(){}},P.globals={translate:"translate3d"},l(P.prototype,{bind:function(e,t){return W.call(this,e,t)},get:function(){var e=k.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 H.call(this,e)},refresh:function(){return function(){F.call(this)}.call(this)},setZoom:function(e){E.call(this,e),c(this.elements.zoomer)},rotate:function(e){N.call(this,e)},destroy:function(){return function(){var e,t,n=this;n.element.removeChild(n.elements.boundary),t="croppie-container",(e=n.element).classList?e.classList.remove(t):e.className=e.className.replace(t,""),n.options.enableZoom&&n.element.removeChild(n.elements.zoomerWrap),delete n.elements}.call(this)}}),P}));