@betterthings/scissors
Version:
handy image cropper with focus point editor
7 lines • 30.9 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("Immutable")):"function"==typeof define&&define.amd?define(["React","Immutable"],t):"object"==typeof exports?exports.Scissors=t(require("React"),require("Immutable")):e.Scissors=t(e.React,e.Immutable)}(window,function(e,t){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(t,r){t.exports=e},function(e,t,r){e.exports=r(3)},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),a=r(1),s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.imageContainer=null,t.focusPoint=null,t.lastDragPosition=null,t.onCropChange=function(e){try{t.props.onChange(t.props.scissors.updateRelativeCrop(e))}catch(e){}},t.onImageLoaded=function(e){t.props.onChange(t.props.scissors.setImage({height:e.naturalHeight,width:e.naturalWidth}))},t.onFocalDragStart=function(e){t.lastDragPosition={x:e.clientX,y:e.clientY},document.addEventListener("mousemove",t.onFocalDrag),document.addEventListener("mouseup",t.onFocalDragEnd)},t.onFocalDrag=function(e){if(t.props.scissors.focus&&t.imageContainer){var r=t.props.scissors.getScale({width:t.imageContainer.clientWidth,height:t.imageContainer.clientHeight});if(r)try{var n=t.lastDragPosition,o=n.x,i=n.y;t.props.onChange(t.props.scissors.setFocus({x:t.props.scissors.focus.x+(e.clientX-o)*r.x,y:t.props.scissors.focus.y+(e.clientY-i)*r.y})),t.lastDragPosition={x:e.clientX,y:e.clientY}}catch(e){}}},t.onFocalDragEnd=function(e){t.lastDragPosition=null,document.removeEventListener("mousemove",t.onFocalDrag),document.removeEventListener("mouseup",t.onFocalDragEnd)},t}return o(t,e),t.prototype.getFocusPointStyle=function(){var e=this.props.scissors.getRelativeFocus();return e?{left:e.x+"%",top:e.y+"%",display:"block"}:{display:"none"}},t.prototype.componentDidMount=function(){this.focusPoint.addEventListener("mousedown",this.onFocalDragStart)},t.prototype.render=function(){var e=this;return i.createElement("div",{className:"bt-scissors"},i.createElement("div",{ref:function(t){e.imageContainer=t},style:{position:"relative"}},i.createElement("div",{className:"bt-scissors__focal-point",style:this.getFocusPointStyle(),ref:function(t){e.focusPoint=t}}),i.createElement(a,{src:this.props.scissors.imageUrl,onImageLoaded:this.onImageLoaded,crop:this.props.scissors.getRelativeCrop(),onChange:this.onCropChange,keepSelection:this.props.keepSelection,disabled:this.props.disabled})))},t}(i.Component);t.Scissors=s},function(e,t,r){var n;"undefined"!=typeof self&&self,n=function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],f=!1,p=-1;function l(){f&&c&&(f=!1,c.length?u=c.concat(u):p=-1,u.length&&d())}function d(){if(!f){var e=s(l);f=!0;for(var t=u.length;t;){for(c=u,u=[];++p<t;)c&&c[p].run();p=-1,t=u.length}c=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function v(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new h(e,t)),1!==u.length||f||s(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){"use strict";function n(e){return function(){return e}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,r){"use strict";(function(t){var r=function(e){};"production"!==t.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=function(e,t,n,o,i,a,s,c){if(r(t),!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[n,o,i,a,s,c],p=0;(u=new Error(t.replace(/%s/g,function(){return f[p++]}))).name="Invariant Violation"}throw u.framesToPop=1,u}}}).call(t,r(0))},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,r){"use strict";(function(t){var n=r(1);if("production"!==t.env.NODE_ENV){n=function(e,t){if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!e){for(var r=arguments.length,n=Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];(function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var o=0,i="Warning: "+e.replace(/%s/g,function(){return r[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}}).apply(void 0,[t].concat(n))}}}e.exports=n}).call(t,r(0))},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i=r(6),a=c(i),s=c(r(7));function c(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var f=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){return f=!0,!0}}))}catch(e){}function p(e){var t=e.getBoundingClientRect(),r=document.documentElement;return{top:t.top+window.pageYOffset-r.clientTop,left:t.left+window.pageXOffset-r.clientLeft}}function l(e){var t=void 0,r=void 0;return e.touches?(t=e.touches[0].pageX,r=e.touches[0].pageY):(t=e.pageX,r=e.pageY),{x:t,y:r}}function d(e,t,r){return Math.min(Math.max(e,t),r)}function h(e){return e&&e.width&&e.height}function v(e){var t=void 0;return"n"===e?t="s":"ne"===e?t="sw":"e"===e?t="w":"se"===e?t="nw":"s"===e?t="n":"sw"===e?t="ne":"w"===e?t="e":"nw"===e&&(t="se"),t}function y(e,t){var r=Math.round(e.naturalWidth*(t.x/100)),n=Math.round(e.naturalHeight*(t.y/100)),o=Math.round(e.naturalWidth*(t.width/100)),i=Math.round(e.naturalHeight*(t.height/100));return{x:r,y:n,width:d(o,0,e.naturalWidth-r),height:d(i,0,e.naturalHeight-n)}}function g(e,t){var r=o({},e),n=!1;r.x+r.width>100?(r.width=e.width+(100-(e.x+e.width)),r.x=e.x+(100-(e.x+r.width)),n=!0):r.x<0&&(r.width=e.x+e.width,r.x=0,n=!0),n&&e.aspect&&(r.height=r.width/e.aspect*t,r.y<e.y&&(r.y=e.y+(e.height-r.height)));var i=!1;return r.y+r.height>100?(r.height=e.height+(100-(e.y+e.height)),r.y=e.y+(100-(e.y+r.height)),i=!0):r.y<0&&(r.height=e.y+e.height,r.y=0,i=!0),i&&e.aspect&&(r.width=r.height*e.aspect/t,r.x<e.x&&(r.x=e.x+(e.width-r.width))),r}var m=function(e){function t(){var e,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];return r=n=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),n.state={},n.onCropMouseTouchDown=function(e){var t=n.props,r=t.crop;if(!t.disabled){e.preventDefault();var o=l(e);n.componentRef.focus({preventScroll:!0});var i=e.target.dataset.ord,a="nw"===i||"w"===i||"sw"===i,s="nw"===i||"n"===i||"ne"===i,c=void 0;r.aspect&&(c=p(n.cropSelectRef)),n.evData={clientStartX:o.x,clientStartY:o.y,cropStartWidth:r.width,cropStartHeight:r.height,cropStartX:a?r.x+r.width:r.x,cropStartY:s?r.y+r.height:r.y,xInversed:a,yInversed:s,xCrossOver:a,yCrossOver:s,startXCrossOver:a,startYCrossOver:s,isResize:e.target!==n.cropSelectRef,ord:i,cropOffset:c},n.mouseDownOnCrop=!0,n.setState({cropIsActive:!0})}},n.onComponentMouseTouchDown=function(e){var t=n.props,r=t.crop,o=t.disabled,i=t.keepSelection,a=t.onChange;if(e.target===n.imageRef&&!(o||i&&h(r))){e.preventDefault();var s=l(e);n.componentRef.focus({preventScroll:!0});var c=p(n.imageRef),u=(s.x-c.left)/n.imageRef.width*100,f=(s.y-c.top)/n.imageRef.height*100,d={aspect:r?r.aspect:void 0,x:u,y:f,width:0,height:0};n.evData={clientStartX:s.x,clientStartY:s.y,cropStartWidth:d.width,cropStartHeight:d.height,cropStartX:d.x,cropStartY:d.y,xInversed:!1,yInversed:!1,xCrossOver:!1,yCrossOver:!1,startXCrossOver:!1,startYCrossOver:!1,isResize:!0,ord:"nw"},n.mouseDownOnCrop=!0,a(d,y(n.imageRef,d)),n.setState({cropIsActive:!0})}},n.onDocMouseTouchMove=function(e){var t=n.props,r=t.crop,o=t.disabled,i=t.onChange;if((0,t.onDragStart)(),!o&&n.mouseDownOnCrop){e.preventDefault();var a=n.evData,s=l(e);a.isResize&&r.aspect&&a.cropOffset&&(s.y=n.straightenYPath(s.x));var c=s.x-a.clientStartX;a.xDiffPc=c/n.imageRef.width*100;var u=s.y-a.clientStartY;a.yDiffPc=u/n.imageRef.height*100;var f=void 0;i(f=a.isResize?n.resizeCrop():n.dragCrop(),y(n.imageRef,f))}},n.onComponentKeyDown=function(e){var r=n.props,o=r.crop,i=r.disabled,a=r.onChange,s=r.onComplete;if(!i){var c=e.which,u=!1;if(h(o)){var f=n.makeNewCrop();c===t.arrowKey.left?(f.x-=t.nudgeStep,u=!0):c===t.arrowKey.right?(f.x+=t.nudgeStep,u=!0):c===t.arrowKey.up?(f.y-=t.nudgeStep,u=!0):c===t.arrowKey.down&&(f.y+=t.nudgeStep,u=!0),u&&(e.preventDefault(),f.x=d(f.x,0,100-f.width),f.y=d(f.y,0,100-f.height),a(f,y(n.imageRef,f)),s(f,y(n.imageRef,f)))}}},n.onDocMouseTouchEnd=function(){var e=n.props,t=e.crop,r=e.disabled,o=e.onComplete;(0,e.onDragEnd)(),r||n.mouseDownOnCrop&&(n.mouseDownOnCrop=!1,o(t,y(n.imageRef,t)),n.setState({cropIsActive:!1}))},u(n,r)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.PureComponent),n(t,[{key:"componentDidMount",value:function(){var e=!!f&&{passive:!1};if(document.addEventListener("mousemove",this.onDocMouseTouchMove,e),document.addEventListener("touchmove",this.onDocMouseTouchMove,e),document.addEventListener("mouseup",this.onDocMouseTouchEnd,e),document.addEventListener("touchend",this.onDocMouseTouchEnd,e),document.addEventListener("touchcancel",this.onDocMouseTouchEnd,e),this.imageRef.complete||this.imageRef.readyState)if(0===this.imageRef.naturalWidth){var t=this.imageRef.src;this.imageRef.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",this.imageRef.src=t}else this.onImageLoad(this.imageRef)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousemove",this.onDocMouseTouchMove),document.removeEventListener("touchmove",this.onDocMouseTouchMove),document.removeEventListener("mouseup",this.onDocMouseTouchEnd),document.removeEventListener("touchend",this.onDocMouseTouchEnd),document.removeEventListener("touchcancel",this.onDocMouseTouchEnd)}},{key:"onImageLoad",value:function(e){this.props.onImageLoaded(e)}},{key:"getCropStyle",value:function(){var e=this.props.crop;return{top:e.y+"%",left:e.x+"%",width:e.width+"%",height:e.height+"%"}}},{key:"getNewSize",value:function(){var e=this.props,t=e.crop,r=e.minWidth,n=e.maxWidth,o=e.minHeight,i=e.maxHeight,a=this.evData,s=this.imageRef.width/this.imageRef.height,c=a.cropStartWidth+a.xDiffPc;a.xCrossOver&&(c=Math.abs(c)),c=d(c,r,n);var u=void 0;return u=t.aspect?c/t.aspect*s:a.cropStartHeight+a.yDiffPc,a.yCrossOver&&(u=Math.min(Math.abs(u),a.cropStartY)),u=d(u,o,i),t.aspect&&(c=d(u*t.aspect/s,0,100)),{width:c,height:u}}},{key:"dragCrop",value:function(){var e=this.makeNewCrop(),t=this.evData;return e.x=d(t.cropStartX+t.xDiffPc,0,100-e.width),e.y=d(t.cropStartY+t.yDiffPc,0,100-e.height),e}},{key:"resizeCrop",value:function(){var e=this.makeNewCrop(),r=this.evData,n=r.ord,o=this.imageRef.width/this.imageRef.height;r.xInversed&&(r.xDiffPc-=2*r.cropStartWidth),r.yInversed&&(r.yDiffPc-=2*r.cropStartHeight);var i=this.getNewSize(),a=r.cropStartX,s=r.cropStartY;r.xCrossOver&&(a=e.x+(e.width-i.width)),r.yCrossOver&&(s=!1===r.lastYCrossover?e.y-i.height:e.y+(e.height-i.height));var c=g({x:a,y:s,width:i.width,height:i.height,aspect:e.aspect},o);return e.aspect||t.xyOrds.indexOf(n)>-1?(e.x=c.x,e.y=c.y,e.width=c.width,e.height=c.height):t.xOrds.indexOf(n)>-1?(e.x=c.x,e.width=c.width):t.yOrds.indexOf(n)>-1&&(e.y=c.y,e.height=c.height),r.lastYCrossover=r.yCrossOver,this.crossOverCheck(),e}},{key:"straightenYPath",value:function(e){var t=this.evData,r=t.ord,n=t.cropOffset,o=t.cropStartWidth/100*this.imageRef.width,i=t.cropStartHeight/100*this.imageRef.height,a=void 0,s=void 0;return"nw"===r||"se"===r?(a=i/o,s=n.top-n.left*a):(a=-i/o,s=n.top+(i-n.left*a)),a*e+s}},{key:"createCropSelection",value:function(){var e=this,t=this.props.disabled,r=this.getCropStyle();return a.default.createElement("div",{ref:function(t){e.cropSelectRef=t},style:r,className:"ReactCrop__crop-selection",onMouseDown:this.onCropMouseTouchDown,onTouchStart:this.onCropMouseTouchDown},!t&&a.default.createElement("div",{className:"ReactCrop__drag-elements"},a.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),a.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),a.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),a.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw"}),a.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w"})))}},{key:"makeNewCrop",value:function(){return o({},t.defaultCrop,this.props.crop)}},{key:"crossOverCheck",value:function(){var e=this.evData;(!e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc>=0||e.xCrossOver&&-Math.abs(e.cropStartWidth)-e.xDiffPc<=0)&&(e.xCrossOver=!e.xCrossOver),(!e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc>=0||e.yCrossOver&&-Math.abs(e.cropStartHeight)-e.yDiffPc<=0)&&(e.yCrossOver=!e.yCrossOver);var t=e.xCrossOver!==e.startXCrossOver,r=e.yCrossOver!==e.startYCrossOver;e.inversedXOrd=!!t&&v(e.ord),e.inversedYOrd=!!r&&v(e.ord)}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,n=t.crossorigin,o=t.crop,i=t.disabled,s=t.imageAlt,c=t.src,u=t.style,f=t.imageStyle,p=this.state.cropIsActive,l=void 0;h(o)&&(l=this.createCropSelection());var d=["ReactCrop"];return p&&d.push("ReactCrop--active"),o&&(o.aspect&&d.push("ReactCrop--fixed-aspect"),!p||o.width&&o.height||d.push("ReactCrop--crop-invisible")),i&&d.push("ReactCrop--disabled"),a.default.createElement("div",{ref:function(t){e.componentRef=t},className:d.join(" "),style:u,onTouchStart:this.onComponentMouseTouchDown,onMouseDown:this.onComponentMouseTouchDown,tabIndex:"1",onKeyDown:this.onComponentKeyDown},a.default.createElement("img",{ref:function(t){e.imageRef=t},crossOrigin:n,className:"ReactCrop__image",style:f,src:c,onLoad:function(t){return e.onImageLoad(t.target)},alt:s}),l,r)}}]),t}();m.xOrds=["e","w"],m.yOrds=["n","s"],m.xyOrds=["nw","ne","se","sw"],m.arrowKey={left:37,up:38,right:39,down:40},m.nudgeStep=.2,m.defaultCrop={x:0,y:0,width:0,height:0},m.propTypes={src:s.default.string.isRequired,crop:s.default.shape({aspect:s.default.number,x:s.default.number,y:s.default.number,width:s.default.number,height:s.default.number}),imageAlt:s.default.string,minWidth:s.default.number,minHeight:s.default.number,maxWidth:s.default.number,maxHeight:s.default.number,keepSelection:s.default.bool,onChange:s.default.func.isRequired,onComplete:s.default.func,onImageLoaded:s.default.func,onDragStart:s.default.func,onDragEnd:s.default.func,disabled:s.default.bool,crossorigin:s.default.string,children:s.default.oneOfType([s.default.arrayOf(s.default.node),s.default.node]),style:s.default.shape({}),imageStyle:s.default.shape({})},m.defaultProps={crop:void 0,crossorigin:void 0,disabled:!1,imageAlt:"",maxWidth:100,maxHeight:100,minWidth:0,minHeight:0,keepSelection:!1,onComplete:function(){},onImageLoaded:function(){},onDragStart:function(){},onDragEnd:function(){},children:void 0,style:void 0,imageStyle:void 0},e.exports=m,e.exports.getPixelCrop=y,e.exports.makeAspectCrop=function(e,t){var r=o({},e);return e.width&&(r.height=e.width/e.aspect*t),e.height&&(r.width=(r.height||e.height)*(e.aspect/t)),e.y+(r.height||e.height)>100&&(r.height=100-e.y,r.width=r.height*e.aspect/t),e.x+(r.width||e.width)>100&&(r.width=100-e.x,r.height=r.width/e.aspect*t),r},e.exports.containCrop=g},function(t,r){t.exports=e},function(e,t,r){(function(t){if("production"!==t.env.NODE_ENV){var n="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=r(8)(function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},!0)}else e.exports=r(11)()}).call(t,r(0))},function(e,t,r){"use strict";(function(t){var n=r(1),o=r(2),i=r(4),a=r(9),s=r(3),c=r(10);e.exports=function(e,r){var u="function"==typeof Symbol&&Symbol.iterator,f="@@iterator";var p="<<anonymous>>",l={array:y("array"),bool:y("boolean"),func:y("function"),number:y("number"),object:y("object"),string:y("string"),symbol:y("symbol"),any:v(n.thatReturnsNull),arrayOf:function(e){return v(function(t,r,n,o,i){if("function"!=typeof e)return new h("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var a=t[r];if(!Array.isArray(a)){var c=m(a);return new h("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected an array.")}for(var u=0;u<a.length;u++){var f=e(a,u,n,o,i+"["+u+"]",s);if(f instanceof Error)return f}return null})},element:function(){return v(function(t,r,n,o,i){var a=t[r];if(!e(a)){var s=m(a);return new h("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+n+"`, expected a single ReactElement.")}return null})}(),instanceOf:function(e){return v(function(t,r,n,o,i){if(!(t[r]instanceof e)){var a=e.name||p,s=function(e){if(!e.constructor||!e.constructor.name)return p;return e.constructor.name}(t[r]);return new h("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+n+"`, expected instance of `"+a+"`.")}return null})},node:function(){return v(function(e,t,r,n,o){if(!g(e[t]))return new h("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.");return null})}(),objectOf:function(e){return v(function(t,r,n,o,i){if("function"!=typeof e)return new h("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside objectOf.");var a=t[r],c=m(a);if("object"!==c)return new h("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected an object.");for(var u in a)if(a.hasOwnProperty(u)){var f=e(a,u,n,o,i+"."+u,s);if(f instanceof Error)return f}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOf, expected an instance of array."),n.thatReturnsNull;return v(function(t,r,n,o,i){for(var a=t[r],s=0;s<e.length;s++)if(d(a,e[s]))return null;var c=JSON.stringify(e);return new h("Invalid "+o+" `"+i+"` of value `"+a+"` supplied to `"+n+"`, expected one of "+c+".")})},oneOfType:function(e){if(!Array.isArray(e))return"production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),n.thatReturnsNull;for(var r=0;r<e.length;r++){var o=e[r];if("function"!=typeof o)return i(!1,"Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.",b(o),r),n.thatReturnsNull}return v(function(t,r,n,o,i){for(var a=0;a<e.length;a++){var c=e[a];if(null==c(t,r,n,o,i,s))return null}return new h("Invalid "+o+" `"+i+"` supplied to `"+n+"`.")})},shape:function(e){return v(function(t,r,n,o,i){var a=t[r],c=m(a);if("object"!==c)return new h("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");for(var u in e){var f=e[u];if(f){var p=f(a,u,n,o,i+"."+u,s);if(p)return p}}return null})},exact:function(e){return v(function(t,r,n,o,i){var c=t[r],u=m(c);if("object"!==u)return new h("Invalid "+o+" `"+i+"` of type `"+u+"` supplied to `"+n+"`, expected `object`.");var f=a({},t[r],e);for(var p in f){var l=e[p];if(!l)return new h("Invalid "+o+" `"+i+"` key `"+p+"` supplied to `"+n+"`.\nBad object: "+JSON.stringify(t[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var d=l(c,p,n,o,i+"."+p,s);if(d)return d}return null})}};function d(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function h(e){this.message=e,this.stack=""}function v(e){if("production"!==t.env.NODE_ENV)var n={},a=0;function c(c,u,f,l,d,v,y){if(l=l||p,v=v||f,y!==s)if(r)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var g=l+":"+f;!n[g]&&a<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",v,l),n[g]=!0,a++)}return null==u[f]?c?null===u[f]?new h("The "+d+" `"+v+"` is marked as required in `"+l+"`, but its value is `null`."):new h("The "+d+" `"+v+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(u,f,l,d,v)}var u=c.bind(null,!1);return u.isRequired=c.bind(null,!0),u}function y(e){return v(function(t,r,n,o,i,a){var s=t[r];return m(s)!==e?new h("Invalid "+o+" `"+i+"` of type `"+w(s)+"` supplied to `"+n+"`, expected `"+e+"`."):null})}function g(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(g);if(null===t||e(t))return!0;var r=function(e){var t=e&&(u&&e[u]||e[f]);if("function"==typeof t)return t}(t);if(!r)return!1;var n,o=r.call(t);if(r!==t.entries){for(;!(n=o.next()).done;)if(!g(n.value))return!1}else for(;!(n=o.next()).done;){var i=n.value;if(i&&!g(i[1]))return!1}return!0;default:return!1}}function m(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||"Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol}(t,e)?"symbol":t}function w(e){if(void 0===e||null===e)return""+e;var t=m(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function b(e){var t=w(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return h.prototype=Error.prototype,l.checkPropTypes=c,l.PropTypes=l,l}}).call(t,r(0))},function(e,t,r){"use strict";
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,a,s=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),c=1;c<arguments.length;c++){for(var u in r=Object(arguments[c]))o.call(r,u)&&(s[u]=r[u]);if(n){a=n(r);for(var f=0;f<a.length;f++)i.call(r,a[f])&&(s[a[f]]=r[a[f]])}}return s}},function(e,t,r){"use strict";(function(t){if("production"!==t.env.NODE_ENV)var n=r(2),o=r(4),i=r(3),a={};e.exports=function(e,r,s,c,u){if("production"!==t.env.NODE_ENV)for(var f in e)if(e.hasOwnProperty(f)){var p;try{n("function"==typeof e[f],"%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.",c||"React class",s,f,typeof e[f]),p=e[f](r,f,c,s,null,i)}catch(e){p=e}if(o(!p||p instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",s,f,typeof p),p instanceof Error&&!(p.message in a)){a[p.message]=!0;var l=u?u():"";o(!1,"Failed %s type: %s%s",s,p.message,null!=l?l:"")}}}}).call(t,r(0))},function(e,t,r){"use strict";var n=r(1),o=r(2),i=r(3);e.exports=function(){function e(e,t,r,n,a,s){s!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=n,r.PropTypes=r,r}}])},e.exports=n(r(0))},function(e,r){e.exports=t},function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var i=r(4),a=r(1),s=function(e){function t(t){return t?e.call(this,t)||this:e.call(this)||this}return o(t,e),t.prototype.isValid=function(){return!this.focus||!this.crop||(e=this.focus,t=this.crop,r=e.x>=t.x&&e.x<=t.x+t.width,n=e.y>=t.y&&e.y<=t.y+t.height,r&&n);var e,t,r,n},t.prototype.setImage=function(e){var t=this.set("image",e);return this.crop||(t=t.setAspect(t.aspect)),t},t.prototype.updateRelativeCrop=function(e){if(!this.image)return this;var t=this.set("crop",{x:e.x*this.image.width/100,y:e.y*this.image.height/100,width:(e.width||0)*this.image.width/100,height:(e.height||0)*this.image.height/100});if(!t.isValid())throw new Error("invalid state");return t},t.prototype.getRelativeCrop=function(){return this.image&&this.crop?{x:this.crop.x/this.image.width*100,y:this.crop.y/this.image.height*100,width:this.crop.width/this.image.width*100,height:this.crop.height/this.image.height*100,aspect:this.aspect}:null},t.prototype.getScale=function(e){return this.image?{x:this.image.width/e.width,y:this.image.height/e.height}:null},t.prototype.getCropCenter=function(){return this.crop?{x:this.crop.x+this.crop.width/2,y:this.crop.y+this.crop.height/2}:null},t.prototype.setFocus=function(e){var t=this.set("focus",e);if(!t.isValid())throw new Error("invalid state");return t},t.prototype.getRelativeFocus=function(){return this.image&&this.focus?{x:this.focus.x/this.image.width*100,y:this.focus.y/this.image.height*100}:null},t.prototype.setImageUrl=function(e){return this.merge({imageUrl:e,image:null,crop:null,focus:null})},t.prototype.setAspect=function(e){var t=this.merge({aspect:e,crop:null,focus:null});if(t.image)if(e)try{t=t.updateRelativeCrop(a.makeAspectCrop({x:0,y:0,width:100,aspect:e},t.image.width/t.image.height))}catch(e){}else t=t.set("crop",{x:0,y:0,height:t.image.height,width:t.image.width});return t},t}(i.Record({imageUrl:"",image:null,crop:null,focus:null,aspect:0}));t.ScissorsState=s},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(5)),n(r(2))}])});
//# sourceMappingURL=scissors.js.map