UNPKG

react-advanced-cropper

Version:

The react cropper library that gives the possibility to create croppers exactly suited for your website design

1 lines 95.1 kB
var ReactAdvancedCropper=function(t,e){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=i(e),r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},r(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var a=function(){return a=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},a.apply(this,arguments)};function s(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(i[n[r]]=t[n[r]])}return i}function c(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))}function l(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function d(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,r,o=i.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return a}function h(t,e,i){if(i||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}function u(t,e){var i,n;return t&&e?(i=""+t+e[0].toUpperCase()+e.slice(1),n=t+"-"+e):(i=t||e,n=t||e),{camelCase:i,snakeCase:n}}function m(t){return/^blob:/.test(t)}function f(t){return/^data:/.test(t)}function p(t){return m(t)||f(t)}function v(t){if(p(t))return!1;var e=window.location,i=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(t)||[],n={protocol:i[1]||"",host:i[2]||"",port:i[3]||""},r=function(t){return t.port||("http"===(t.protocol||e.protocol)?80:433)};return!(!n.protocol&&!n.host&&!n.port||Boolean(n.protocol&&n.protocol==e.protocol&&n.host&&n.host==e.host&&n.host&&r(n)==r(e)))}function g(t){return Array.isArray(t)}function b(t){return"function"==typeof t}function w(t){return void 0===t}var y=function(t){return null!==t&&"object"==typeof t};function A(t,e,i){void 0===i&&(i={});var n={};return y(t)?(Object.keys(e).forEach((function(r){w(t[r])?n[r]=e[r]:y(e[r])?y(t[r])?n[r]=A(t[r],e[r],i[r]):n[r]=t[r]?e[r]:i[r]:!0===e[r]||!1===e[r]?n[r]=Boolean(t[r]):n[r]=t[r]})),n):t?e:i}function C(t){var e=Number(t);return Number.isNaN(e)?t:e}function x(t){return!0===t||!1===t}function S(t){return"number"==typeof t}function M(t){return"string"==typeof t}function E(t){return t!=t}function R(t){return S(t)&&!E(t)||M(t)&&!Number.isNaN(parseFloat(t))&&isFinite(parseFloat(t))}function z(t,e){return Math.sqrt(Math.pow(t.left-e.left,2)+Math.pow(t.top-e.top,2))}function N(t,e,i){return void 0===i&&(i=.001),Math.abs(e-t)<i}function P(t,e,i){return!N(t,e,i)&&t>e}function W(t,e,i){return!N(t,e,i)&&t<e}function I(t){var e=+t;return 0===e||E(e)?e:e>0?1:-1}function H(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))}function T(t){if(!y(t))return t;var e={};return Array.isArray(t)?e=t.map((function(t){return T(t)})):Object.keys(t).forEach((function(i){return e[i]=T(t[i])})),e}function D(t,e,i){if(void 0===i&&(i=.001),S(t)&&S(e)&&N(t,e,i))return!0;if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var n,r=void 0;if(Array.isArray(t)){if((n=t.length)!=e.length)return!1;for(r=n;0!=r--;)if(!D(t[r],e[r],i))return!1;return!0}if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();var o=Object.keys(t);if((n=o.length)!==Object.keys(e).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(e,o[r]))return!1;for(r=n;0!=r--;){var a=o[r];if(!D(t[a],e[a],i))return!1}return!0}return t!=t&&e!=e}function O(){return{left:0,top:0,width:0,height:0}}function _(t){return"west"===t||"south"===t||"north"===t||"east"===t}function L(t,e){var i,n;function r(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=Date.now()-i,c=b(e)?e():e||0;s<c&&s>=0?n=setTimeout((function(){return r.apply(void 0,o)}),c-s):t.apply(void 0,o)}function o(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];i=Date.now(),n=setTimeout((function(){return r.apply(void 0,t)}),b(e)?e():e||0)}return o.clear=function(){clearTimeout(n)},o}var k,B,U,X=["left","right","top","bottom"],j=["left","right"],Y=["top","bottom"];function V(t,e){return{left:t.left-e.left,top:t.top-e.top}}function F(t){return{left:t.left+t.width/2,top:t.top+t.height/2}}function q(t){return{left:"right",top:"bottom",right:"left",bottom:"top"}[t]}function G(t,e){return Math.pow(t.width-e.width,2)+Math.pow(t.height-e.height,2)}function Z(t,e){return{left:t.left-e.left,top:t.top-e.top,width:t.width+e.left+e.right,height:t.height+e.top+e.bottom}}function Q(t){return{left:-t.left,top:-t.top}}function K(t,e){return a(a({},t),{left:t.left+e.left,top:t.top+e.top})}function J(t){return{left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height}}function $(t,e,i,n){if(1!==e){if("left"in t||"top"in t){if(i){var r=F(t);return{width:t.width*e,height:t.height*e,left:t.left+t.width*(1-e)/2+(i.left-r.left)*(n||1-e),top:t.top+t.height*(1-e)/2+(i.top-r.top)*(n||1-e)}}return{width:t.width*e,height:t.height*e,left:t.left+t.width*(1-e)/2,top:t.top+t.height*(1-e)/2}}return{width:t.width*e,height:t.height*e}}return t}function tt(t){return t.width/t.height}function et(t,e){return Math.min(e.maxWidth?e.maxWidth/t.width:1/0,e.maxHeight?e.maxHeight/t.height:1/0)}function it(t,e){return Math.max(e.minWidth?e.minWidth/t.width:0,e.minHeight?e.minHeight/t.height:0)}function nt(t,e){var i;return e.minimum&&W(t,e.minimum)?i=e.minimum:e.maximum&&P(t,e.maximum)&&(i=e.maximum),i}function rt(t,e){var i=tt(t),n=1;return e.minWidth>0&&e.minHeight>0?i>e.minWidth/e.minHeight?t.height<e.minHeight&&(n=e.minHeight/t.height):t.width<e.minWidth&&(n=e.minWidth/t.width):e.minWidth>0?t.width<e.minWidth&&(n=e.minWidth/t.width):e.minHeight>0&&t.height<e.minHeight&&(n=e.minHeight/t.height),e.maxWidth<1/0&&e.maxHeight<1/0?i>e.maxWidth/e.maxHeight?t.width>e.maxWidth&&(n=e.maxWidth/t.width):t.height>e.maxHeight&&(n=e.maxHeight/t.height):e.maxWidth<1/0?t.width>e.maxWidth&&(n=e.maxWidth/t.width):e.maxHeight<1/0&&t.height>e.maxHeight&&(n=e.maxHeight/t.height),n}function ot(t,e){var i={left:0,top:0,right:0,bottom:0};return X.forEach((function(n){var r=e[n],o=J(t)[n];i[n]=void 0!==r&&void 0!==o?"left"===n||"top"===n?Math.max(0,r-o):Math.max(0,o-r):0})),i}function at(t,e){return $(t,rt(t,e))}function st(t,e){var i=e*Math.PI/180;return{width:Math.abs(t.width*Math.cos(i))+Math.abs(t.height*Math.sin(i)),height:Math.abs(t.width*Math.sin(i))+Math.abs(t.height*Math.cos(i))}}function ct(t,e,i){var n=e*Math.PI/180;return i?{left:(t.left-i.left)*Math.cos(n)-(t.top-i.top)*Math.sin(n)+i.left,top:(t.left-i.left)*Math.sin(n)+(t.top-i.top)*Math.cos(n)+i.top}:{left:t.left*Math.cos(n)-t.top*Math.sin(n),top:t.left*Math.sin(n)+t.top*Math.cos(n)}}function lt(t){return{minWidth:0,minHeight:0,maxWidth:void 0!==t.right&&void 0!==t.left?t.right-t.left:1/0,maxHeight:void 0!==t.bottom&&void 0!==t.top?t.bottom-t.top:1/0}}function dt(t,e){var i={};return X.forEach((function(n){var r=t[n],o=e[n];void 0!==r&&void 0!==o?i[n]="left"===n||"top"===n?Math.max(r,o):Math.min(r,o):void 0!==o?i[n]=o:void 0!==r&&(i[n]=r)})),i}function ht(t,e){var i={left:0,top:0},n=ot(t,e);return n.left&&n.left>0?i.left=n.left:n.right&&n.right>0&&(i.left=-n.right),n.top&&n.top>0?i.top=n.top:n.bottom&&n.bottom>0&&(i.top=-n.bottom),i}function ut(t,e){return K(t,ht(t,e))}function mt(t,e){return e?t?{minimum:Math.min(t.maximum,Math.max(t.minimum,e.minimum)),maximum:Math.max(t.minimum,Math.min(t.maximum,e.maximum))}:e:t}function ft(t){return void 0===t&&(t={}),S(t)?{minimum:t,maximum:t}:{minimum:R(t.minimum)?t.minimum:0,maximum:R(t.maximum)?t.maximum:1/0}}function pt(t,e){return(w(e.maxWidth)||!P(t.width,e.maxWidth))&&(w(e.maxHeight)||!P(t.height,e.maxHeight))&&(w(e.minHeight)||!W(t.height,e.minHeight))&&(w(e.minWidth)||!W(t.width,e.minWidth))}function vt(t,e){return(w(e.left)||!W(t.left,e.left))&&(w(e.top)||!W(t.top,e.top))&&(w(e.right)||!P(t.left+t.width,e.right))&&(w(e.bottom)||!P(t.top+t.height,e.bottom))}function gt(t,e,i,n){var r=function(r){return t.reduce((function(t,o){var a=b(i)?i(o):i,s=a.maxHeight,c=a.maxWidth,l=a.minWidth,d=a.minHeight,h=ft(b(n)?n(o):n);return pt(o,r?{maxWidth:c,maxHeight:s}:{maxWidth:c,maxHeight:s,minWidth:l,minHeight:d})&&!nt(tt(o),h)&&o.width&&o.height&&(!t||W(G(o,e),G(t,e)))?o:t}),null)};return r()||r(!0)}function bt(t){return Boolean(t&&t.visibleArea&&t.coordinates)}function wt(t,e){return Ot(t,e)}function yt(t,e){return b(e.areaPositionRestrictions)?e.areaPositionRestrictions(t,e):e.areaPositionRestrictions}function At(t,e){return Dt(t,e)}function Ct(t,e){return b(e.positionRestrictions)?e.positionRestrictions(t,e):e.positionRestrictions}function xt(t){return t.visibleArea?t.visibleArea.width/t.boundary.width:0}function St(t){if(bt(t)){var e=t.coordinates,i=e.width,n=e.height,r=e.left,o=e.top,a=xt(t);return{width:i/a,height:n/a,left:(r-t.visibleArea.left)/a,top:(o-t.visibleArea.top)/a}}return{left:0,top:0,width:0,height:0}}function Mt(t,e){return ft(b(e.aspectRatio)?e.aspectRatio(t,e):e.aspectRatio)}function Et(t,e){return b(e.defaultCoordinates)?e.defaultCoordinates(t,e):e.defaultCoordinates}function Rt(t,e){return b(e.defaultVisibleArea)?e.defaultVisibleArea(t,e):e.defaultVisibleArea}function zt(t,e){var i=a(a({},t.transforms),{flip:a({},t.transforms.flip)});if(e.defaultTransforms){var n=b(e.defaultTransforms)?e.defaultTransforms(t,e):e.defaultTransforms;S(n.rotate)&&(i.rotate=n.rotate),n.flip&&(x(n.flip.horizontal)&&(i.flip.horizontal=n.flip.horizontal),x(n.flip.vertical)&&(i.flip.vertical=n.flip.vertical))}return i}function Nt(t){return t.imageSize&&t.imageSize.width&&t.imageSize.height?st(t.imageSize,t.transforms.rotate):{width:0,height:0}}function Pt(t){return t.coordinates?Math.min(t.coordinates.width,t.coordinates.height,20*xt(t)):1}function Wt(t,e){if(bt(t)){var i=At(t,e),n=Ct(t,e),r={width:Math.round(t.coordinates.width),height:Math.round(t.coordinates.height),left:Math.round(t.coordinates.left),top:Math.round(t.coordinates.top)};return r.width>i.maxWidth?r.width=Math.floor(t.coordinates.width):r.width<i.minWidth&&(r.width=Math.ceil(t.coordinates.width)),r.height>i.maxHeight?r.height=Math.floor(t.coordinates.height):r.height<i.minHeight&&(r.height=Math.ceil(t.coordinates.height)),ut(r,n)}return null}function It(t,e){return!bt(t)||!nt(tt(t.coordinates),Mt(t,e))&&pt(t.visibleArea,wt(t,e))&&pt(t.coordinates,At(t,e))&&vt(t.visibleArea,yt(t,e))&&vt(t.coordinates,Ct(t,e))}function Ht(t){var e=a({},t);return e.minWidth>e.maxWidth&&(e.minWidth=e.maxWidth),e.minHeight>e.maxHeight&&(e.minHeight=e.maxHeight),e}function Tt(t,e){var i=t,n=a({minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0},e);return Ht({maxHeight:Math.min(i.maxHeight,n.maxHeight),minHeight:Math.max(i.minHeight,n.minHeight),maxWidth:Math.min(i.maxWidth,n.maxWidth),minWidth:Math.max(i.minWidth,n.minWidth)})}function Dt(t,e){var i=b(e.sizeRestrictions)?e.sizeRestrictions(t,e):e.sizeRestrictions,n=Ct(t,e),r={minWidth:R(i.minWidth)?C(i.minWidth):0,minHeight:R(i.minHeight)?C(i.minHeight):0,maxWidth:R(i.maxWidth)?C(i.maxWidth):1/0,maxHeight:R(i.maxHeight)?C(i.maxHeight):1/0};return void 0!==n.left&&void 0!==n.right&&(r.maxWidth=Math.min(r.maxWidth,n.right-n.left)),void 0!==n.bottom&&void 0!==n.top&&(r.maxHeight=Math.min(r.maxHeight,n.bottom-n.top)),Ht(r)}function Ot(t,e){var i=b(e.areaSizeRestrictions)?e.areaSizeRestrictions(t,e):e.areaSizeRestrictions;return i.maxWidth<1/0&&i.maxHeight<1/0&&(tt(t.boundary)>i.maxWidth/i.maxHeight?i.maxHeight=i.maxWidth/tt(t.boundary):i.maxWidth=i.maxHeight*tt(t.boundary)),Ht(i)}function _t(t){return T(t)}function Lt(t){var e=t.width,i=t.height,n=t.sizeRestrictions||{minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0},r=ft(t.aspectRatio),o={width:Math.max(n.minWidth,Math.min(n.maxWidth,e)),height:Math.max(n.minHeight,Math.min(n.maxHeight,i))},a=[o];return r&&[r.minimum,r.maximum].forEach((function(t){t&&a.push({width:o.width,height:o.width/t},{width:o.height*t,height:o.height})})),gt(a=a.map((function(t){return at(t,n)})),{width:e,height:i},n,r)}function kt(t,e){var i=_t(t);if(t.visibleArea){var n=wt(t,e);i.visibleArea=a(a({},t.visibleArea),Lt({width:t.visibleArea.width,height:t.visibleArea.height,aspectRatio:{minimum:tt(i.boundary),maximum:tt(i.boundary)},sizeRestrictions:n})),i.visibleArea=K(i.visibleArea,V(F(t.visibleArea),F(i.visibleArea))),i.visibleArea=ut(i.visibleArea,yt(i,e))}return i}function Bt(t,e,i){var n=K(t,e);return i?ut(n,i):n}function Ut(e,i,n,r){void 0===r&&(r=!0);var o=!1===r?t.SetCoordinatesMode.unsafe:!0===r?t.SetCoordinatesMode.zoom:r,s=Mt(e,i),c=At(e,i);e.visibleArea&&o===t.SetCoordinatesMode.limit&&(c=a(a({},c),{minWidth:Math.min(e.visibleArea.width,c.minWidth),minHeight:Math.min(e.visibleArea.height,c.minHeight),maxWidth:Math.min(e.visibleArea.width,c.maxWidth),maxHeight:Math.min(e.visibleArea.height,c.maxHeight)}));var l=Ct(e,i);e.visibleArea&&o===t.SetCoordinatesMode.limit&&(l=dt(l,J(e.visibleArea)));var d=function(t,e){return Bt(t,{left:e.left-(t.left||0),top:e.top-(t.top||0)},l)},h=e.coordinates?a({},e.coordinates):{left:0,top:0,width:0,height:0};(Array.isArray(n)?n:[n]).forEach((function(t){var n;(n="function"==typeof t?t(a(a({},e),{coordinates:h}),i):t)&&(w(n.width)&&w(n.height)||(h=function(t,e){var i=a(a(a({},t),Lt({width:e.width,height:e.height,sizeRestrictions:c,aspectRatio:s})),{left:0,top:0});return d(i,{left:t.left||0,top:t.top||0})}(h,a(a({},h),n))),w(n.left)&&w(n.top)||(h=d(h,a(a({},h),n))))}));var u=a(a({},_t(e)),{coordinates:h});if(u.visibleArea&&o===t.SetCoordinatesMode.zoom){var m=Math.max(0,u.coordinates.width-u.visibleArea.width),f=Math.max(0,u.coordinates.height-u.visibleArea.height),p=wt(e,i),v=m>f?u.coordinates.width/u.visibleArea.width:u.coordinates.height/u.visibleArea.height;return v>1&&(u.visibleArea=$(u.visibleArea,Math.min(v,et(u.visibleArea,p)))),u.visibleArea=K(u.visibleArea,Q(ht(u.coordinates,J(u.visibleArea)))),kt(u,i)}return u}function Xt(t,e){if(t.coordinates){var i=_t(t),n=Mt(t,e),r=At(t,e);return i.coordinates=a(a({},t.coordinates),Lt({width:t.coordinates.width,height:t.coordinates.height,aspectRatio:n,sizeRestrictions:t.visibleArea?{maxWidth:Math.min(t.visibleArea.width,r.maxWidth),maxHeight:Math.min(t.visibleArea.height,r.maxHeight),minHeight:Math.min(t.visibleArea.height,r.minHeight),minWidth:Math.min(t.visibleArea.width,r.minWidth)}:r})),i.coordinates=K(i.coordinates,V(F(t.coordinates),F(i.coordinates))),i.coordinates=ut(i.coordinates,t.visibleArea?dt(J(t.visibleArea),Ct(i,e)):Ct(i,e)),i}return t}function jt(t,e,i,n){void 0===n&&(n=!0);var r=a(a({},_t(t)),{visibleArea:i});return r=kt(r,e),n&&(r=Xt(r,e)),r}function Yt(e,i){var n,r,o,a,s,c=e.boundary,l=e.image,d={boundary:{width:c.width,height:c.height},imageSize:{width:l.width,height:l.height},transforms:{rotate:(null===(n=l.transforms)||void 0===n?void 0:n.rotate)||0,flip:{horizontal:(null===(o=null===(r=l.transforms)||void 0===r?void 0:r.flip)||void 0===o?void 0:o.horizontal)||!1,vertical:(null===(s=null===(a=l.transforms)||void 0===a?void 0:a.flip)||void 0===s?void 0:s.vertical)||!1}},visibleArea:null,coordinates:null};return i.defaultTransforms&&(d.transforms=zt(d,i)),d=i.priority===t.Priority.visibleArea?Ut(d=jt(d,i,Rt(d,i),!1),i,Et(d,i),t.SetCoordinatesMode.limit):jt(d=Ut(d,i,Et(d,i),t.SetCoordinatesMode.unsafe),i,Rt(d,i),!0)}function Vt(t,e,i){if(bt(t)){var n=_t(t);return n.coordinates=K(n.coordinates,i),n.coordinates=ut(n.coordinates,dt(J(n.visibleArea),Ct(n,e))),n}return t}function Ft(t){var e=t.coordinates,i=t.directions,n=t.positionRestrictions,r=t.sizeRestrictions,o=t.preserveRatio,s=t.allowedDirections,c=t.compensate,l=void 0===c||c,d=a({},i),h=Z(e,d).width,u=Z(e,d).height;h<0&&(d.left<0&&d.right<0?(d.left=-(e.width-r.minWidth)/(d.left/d.right),d.right=-(e.width-r.minWidth)/(d.right/d.left)):d.left<0?d.left=-(e.width-r.minWidth):d.right<0&&(d.right=-(e.width-r.minWidth))),u<0&&(d.top<0&&d.bottom<0?(d.top=-(e.height-r.minHeight)/(d.top/d.bottom),d.bottom=-(e.height-r.minHeight)/(d.bottom/d.top)):d.top<0?d.top=-(e.height-r.minHeight):d.bottom<0&&(d.bottom=-(e.height-r.minHeight)));var m=ot(Z(e,d),n),f=X.every((function(t){return!P(m[q(t)],0)||s[t]}));l&&f&&(m.left&&m.left>0&&0===m.right?(d.right+=m.left,d.left-=m.left):m.right&&m.right>0&&0===m.left&&(d.left+=m.right,d.right-=m.right),m.top&&m.top>0&&0===m.bottom?(d.bottom+=m.top,d.top-=m.top):m.bottom&&m.bottom>0&&0===m.top&&(d.top+=m.bottom,d.bottom-=m.bottom),m=ot(Z(e,d),n));var p={width:1/0,height:1/0,left:1/0,right:1/0,top:1/0,bottom:1/0};if(X.forEach((function(t){var e=m[t];e&&d[t]&&(p[t]=Math.max(0,1-e/d[t]))})),o){var v=Math.min.apply(Math,X.map((function(t){return p[t]})));v!==1/0&&X.forEach((function(t){d[t]*=v}))}else X.forEach((function(t){p[t]!==1/0&&(d[t]*=p[t])}));if(h=Z(e,d).width,u=Z(e,d).height,d.right+d.left&&(h>r.maxWidth?p.width=(r.maxWidth-e.width)/(d.right+d.left):h<r.minWidth&&(p.width=(r.minWidth-e.width)/(d.right+d.left))),d.bottom+d.top&&(u>r.maxHeight?p.height=(r.maxHeight-e.height)/(d.bottom+d.top):u<r.minHeight&&(p.height=(r.minHeight-e.height)/(d.bottom+d.top))),o){var g=Math.min(p.width,p.height);g!==1/0&&X.forEach((function(t){d[t]*=g}))}else p.width!==1/0&&j.forEach((function(t){d[t]*=p.width})),p.height!==1/0&&Y.forEach((function(t){d[t]*=p.height}));return d}function qt(t,e,i){return N(e+i,0)?t/2:N(e,0)?0:N(i,0)?t:t*Math.abs(e/(e+i))}function Gt(t,e,i,n){var r=n.aspectRatio,o=n.positionRestrictions,s=n.sizeRestrictions,c=a({},t);e=a({},e);var l=i.allowedDirections||{left:!0,right:!0,bottom:!0,top:!0};t.width<s.minWidth&&(e.left=0,e.right=0),t.height<s.minHeight&&(e.top=0,e.bottom=0),X.forEach((function(t){l[t]||(e[t]=0)}));var d=Z(c,e=Ft({coordinates:c,directions:e,sizeRestrictions:s,positionRestrictions:o,allowedDirections:l})).width,h=Z(c,e).height,u=i.preserveAspectRatio?tt(c):nt(d/h,r);if(u){var m=i.respectDirection;if("width"!==m&&"height"!==m&&(m=c.width>=c.height||1===u?"width":"height"),"width"===m){var f=d/u-c.height;if(l.top&&l.bottom){var p=e.top,v=e.bottom;e.bottom=qt(f,v,p),e.top=qt(f,p,v)}else l.bottom?e.bottom=f:l.top?e.top=f:l.right?e.right=0:l.left&&(e.left=0)}else if("height"===m){var g=c.width-h*u;if(l.left&&l.right){var b=e.left,w=e.right;e.left=-qt(g,b,w),e.right=-qt(g,w,b)}else l.left?e.left=-g:l.right?e.right=-g:l.top?e.top=0:l.bottom&&(e.bottom=0)}e=Ft({directions:e,coordinates:c,sizeRestrictions:s,positionRestrictions:o,preserveRatio:!0,compensate:i.compensate,allowedDirections:l})}return d=Z(c,e).width,h=Z(c,e).height,(u=i.preserveAspectRatio?tt(c):nt(d/h,r))&&P(Math.abs(u-d/h),0)&&X.forEach((function(t){e[t]=0})),Bt({width:t.width+e.right+e.left,height:t.height+e.top+e.bottom,left:t.left,top:t.top},{left:-e.left,top:-e.top},o)}function Zt(t,e){var i=e.toLowerCase();return{left:t.left+t.width*(-1!==i.indexOf("west")?1:-1!==i.indexOf("east")?0:.5),top:t.top+t.height*(-1!==i.indexOf("north")?1:-1!==i.indexOf("south")?0:.5)}}function Qt(t){var e=t.toLowerCase();return{left:-1===e.indexOf("east"),top:-1===e.indexOf("south"),right:-1===e.indexOf("west"),bottom:-1===e.indexOf("north")}}function Kt(t,e){var i=t.toLowerCase(),n={left:-1===i.indexOf("west")?e.left:-e.left,top:-e.top,right:e.left,bottom:e.top};["north","south","center"].every((function(t){return-1===i.indexOf(t)}))&&(n.top=0,n.bottom=0),["west","east","center"].every((function(t){return-1===i.indexOf(t)}))&&(n.left=0,n.right=0);var r=Qt(t);return X.forEach((function(t){r[t]||(n[t]=0)})),n}function Jt(t,e,i,n,r){var o=n.reference,s=Kt(e,i),c=Qt(e),l=Gt(t,s,a(a({},n),{allowedDirections:c}),r);return o&&(l=K(l,V(Zt(o,e),Zt(l,e)))),ut(l,r.positionRestrictions)}function $t(t,e,i,n,r){var o=Pt(t),s=At(t,e);return bt(t)?a(a({},_t(t)),{coordinates:Jt(t.coordinates,i,n,r,{positionRestrictions:dt(Ct(t,e),J(t.visibleArea)),sizeRestrictions:{maxWidth:Math.min(s.maxWidth,t.visibleArea.width),maxHeight:Math.min(s.maxHeight,t.visibleArea.height),minWidth:Math.max(Math.min(s.minWidth,t.visibleArea.width),o),minHeight:Math.max(Math.min(s.minHeight,t.visibleArea.height),o)},aspectRatio:Mt(t,e)})}):t}function te(t,e,i){var n=a(a({},_t(t)),{boundary:i});if(n.visibleArea&&n.coordinates&&t.visibleArea){n.visibleArea.height=n.visibleArea.width/tt(i),n.visibleArea.top+=(t.visibleArea.height-n.visibleArea.height)/2;var r=At(n,e);(Math.max(r.minHeight,n.coordinates.height)-n.visibleArea.height>0||Math.max(r.minWidth,n.coordinates.width)-n.visibleArea.width>0)&&(n.visibleArea=$(n.visibleArea,Math.max(Math.max(r.minHeight,n.coordinates.height)/n.visibleArea.height,Math.max(r.minWidth,n.coordinates.width)/n.visibleArea.width))),n.visibleArea=at(n.visibleArea,wt(n,e));var o=Q(ht(n.coordinates,J(n.visibleArea)));n.visibleArea.width<n.coordinates.width&&(o.left=0),n.visibleArea.height<n.coordinates.height&&(o.top=0),n.visibleArea=K(n.visibleArea,o),n.visibleArea=ut(n.visibleArea,yt(n,e)),n=Xt(n,e)}return n}function ee(t,e,i){if(bt(t)){var n=_t(t),r=S(i)?i:i.angle,o=ct(F(a({left:0,top:0},Nt(t))),r);n.transforms.rotate+=r,n.coordinates=a(a({},Lt({sizeRestrictions:At(n,e),aspectRatio:Mt(n,e),width:n.coordinates.width,height:n.coordinates.height})),ct(F(n.coordinates),r));var s=!S(i)&&i.center?i.center:F(t.coordinates),c=V(F(t.coordinates),ct(F(t.coordinates),r,s)),l=Nt(n);return n.coordinates.left-=o.left-l.width/2+n.coordinates.width/2-c.left,n.coordinates.top-=o.top-l.height/2+n.coordinates.height/2-c.top,n.visibleArea=at(n.visibleArea,Tt(wt(n,e),{minWidth:n.coordinates.width,minHeight:n.coordinates.height})),n.coordinates=ut(n.coordinates,Ct(n,e)),n.visibleArea=K(n.visibleArea,V(F(n.coordinates),F(t.coordinates))),n.visibleArea=ut(n.visibleArea,yt(n,e)),n}return t}function ie(t,e,i,n){if(bt(t)){var r=_t(t),o=t.transforms.rotate,a=Nt(t),s={horizontal:i,vertical:n};if(s.horizontal||s.vertical){var c=ct({left:a.width/2,top:a.height/2},-o),l=ct(F(r.coordinates),-o),d=ct({left:s.horizontal?c.left-(l.left-c.left):l.left,top:s.vertical?c.top-(l.top-c.top):l.top},o);r.coordinates=K(r.coordinates,V(d,F(r.coordinates))),l=ct(F(r.visibleArea),-o),d=ct({left:s.horizontal?c.left-(l.left-c.left):l.left,top:s.vertical?c.top-(l.top-c.top):l.top},o),r.visibleArea=K(r.visibleArea,V(d,F(r.visibleArea))),r.visibleArea=ut(r.visibleArea,yt(r,e))}return s.horizontal&&(r.transforms.flip.horizontal=!t.transforms.flip.horizontal),s.vertical&&(r.transforms.flip.vertical=!t.transforms.flip.vertical),r}return t}function ne(t,e,i){var n,r=i.scale,o=void 0===r?1:r,a=i.move,s=void 0===a?{}:a;if(bt(t)){var c=_t(t),l=1/(S(o)?o:o.factor),d=S(o)?void 0:o.center,h=!N(l,1),u=1,m=1;c.visibleArea=K(c.visibleArea,{left:s.left||0,top:s.top||0});var f=At(c,e),p=Ct(c,e),v=wt(c,e),g={stencil:{minimum:Math.max(f.minWidth?f.minWidth/c.coordinates.width:0,f.minHeight?f.minHeight/c.coordinates.height:0),maximum:Math.min(f.maxWidth?f.maxWidth/c.coordinates.width:1/0,f.maxHeight?f.maxHeight/c.coordinates.height:1/0,et(c.coordinates,lt(p)))},area:{maximum:et(c.visibleArea,v),minimum:it(c.visibleArea,v)}};l&&h&&(l<1?(m=Math.max(l,Math.max(g.area.minimum,g.stencil.minimum)))>1&&(m=1):l>1&&(m=Math.min(l,Math.min(g.area.maximum,g.stencil.maximum)))<1&&(m=1)),m&&(c.visibleArea=$(c.visibleArea,m,d));var b={left:t.coordinates.left-t.visibleArea.left,right:t.visibleArea.width+t.visibleArea.left-(t.coordinates.width+t.coordinates.left),top:t.coordinates.top-t.visibleArea.top,bottom:t.visibleArea.height+t.visibleArea.top-(t.coordinates.height+t.coordinates.top)};return c.visibleArea=ut(c.visibleArea,{left:void 0!==p.left?p.left-b.left*m:void 0,top:void 0!==p.top?p.top-b.top*m:void 0,bottom:void 0!==p.bottom?p.bottom+b.bottom*m:void 0,right:void 0!==p.right?p.right+b.right*m:void 0}),c.visibleArea=ut(c.visibleArea,yt(c,e)),c.coordinates.width=c.coordinates.width*m,c.coordinates.height=c.coordinates.height*m,c.coordinates.left=c.visibleArea.left+b.left*m,c.coordinates.top=c.visibleArea.top+b.top*m,c.coordinates=ut(c.coordinates,dt(J(c.visibleArea),p)),h&&l&&(null===(n=e.transformImage)||void 0===n?void 0:n.adjustStencil)&&(l>1?u=Math.min(g.area.maximum,l)/m:l<1&&(u=Math.max(c.coordinates.height/c.visibleArea.height,c.coordinates.width/c.visibleArea.width,l/m)),1!==u&&(c.visibleArea=$(c.visibleArea,u,l>1?d:F(c.coordinates)),c.visibleArea=ut(c.visibleArea,yt(c,e)),c.visibleArea=K(c.visibleArea,Q(ht(c.coordinates,J(c.visibleArea)))))),c}return t}function re(t,e,i){return i.rotate&&(t=ee(t,e,i.rotate)),i.flip&&(t=ie(t,e,i.flip.horizontal,i.flip.vertical)),(i.move||i.scale)&&(t=ne(t,e,i)),t}function oe(t,e){if(bt(t)){var i=_t(t),n=Mt(t,e),r=At(t,e),o=wt(t,e),s=nt(tt(t.coordinates),n),c=s?{height:t.coordinates.height,width:t.coordinates.height*s}:t.coordinates;i.coordinates=a(a({},i.coordinates),Lt({width:c.width,height:c.height,aspectRatio:n,sizeRestrictions:Tt(o,r)})),i.coordinates=K(i.coordinates,V(F(t.coordinates),F(i.coordinates)));var l=Math.max(i.coordinates.width/i.visibleArea.width,i.coordinates.height/i.visibleArea.height,1);return i.visibleArea=a(a({},t.visibleArea),Lt({width:t.visibleArea.width*l,height:t.visibleArea.height*l,aspectRatio:{minimum:tt(i.boundary),maximum:tt(i.boundary)},sizeRestrictions:o})),i.visibleArea=K(i.visibleArea,V(F(t.visibleArea),F(i.visibleArea))),i.visibleArea=ut(i.visibleArea,yt(i,e)),i.coordinates=ut(i.coordinates,dt(J(i.visibleArea),Ct(i,e))),i}return t}function ae(t,e){var i=xt(t);return{left:S(e.left)?e.left*i:0,top:S(e.top)?e.top*i:0,right:S(e.right)?e.right*i:0,bottom:S(e.bottom)?e.bottom*i:0}}function se(t,e){var i=xt(t);return t.visibleArea?{left:e.left*i+t.visibleArea.left,top:e.top*i+t.visibleArea.top}:e}function ce(t,e){if(t){var i=Math.abs(t.transforms.rotate%180);return i<=45||i>=135?e:{horizontal:e.vertical,vertical:e.horizontal}}return e}function le(t){return{left:S(t.left)?t.left:0,top:S(t.top)?t.top:0}}function de(t){return{left:S(t.left)?t.left:0,top:S(t.top)?t.top:0,right:S(t.right)?t.right:0,bottom:S(t.bottom)?t.bottom:0}}function he(t,e){var i=xt(t);return{left:S(e.left)?e.left*i:0,top:S(e.top)?e.top*i:0}}function ue(t,e){return e.scale&&(e.scale={factor:S(e.scale)?e.scale:e.scale.factor,center:!S(e.scale)&&e.scale.center?se(t,e.scale.center):void 0}),e.rotate&&(e.rotate={angle:S(e.rotate)?e.rotate:e.rotate.angle,center:!S(e.rotate)&&e.rotate.center?se(t,e.rotate.center):void 0}),e.move&&(e.move=he(t,e.move)),e}function me(t,e){var i=e.getBoundingClientRect(),n=i.left,r=i.top,o={left:0,top:0},a=0;return t.forEach((function(e){o.left+=(e.clientX-n)/t.length,o.top+=(e.clientY-r)/t.length})),t.forEach((function(t){a+=z({left:o.left,top:o.top},{left:t.clientX-n,top:t.clientY-r})})),{centerMass:o,spread:a,count:t.length}}function fe(t,e,i,n){var r,o,a;if(void 0===n&&(n={}),1===e.length&&1===t.length)n.move&&(r={left:e[0].clientX-t[0].clientX,top:e[0].clientY-t[0].clientY});else if(t.length>1){var s=me(e,i),c=me(t,i);if(n.rotate&&2===e.length&&2===t.length){var l={left:[t[0].clientX-t[1].clientX,e[0].clientX-e[1].clientX],top:[t[0].clientY-t[1].clientY,e[0].clientY-e[1].clientY]},d=l.left[0]*l.top[1]-l.left[1]*l.top[0],h=l.left[0]*l.left[1]+l.top[0]*l.top[1];if(!N(h,0)&&!N(d,0)){var u=-180*Math.atan2(d,h)/Math.PI;a={center:c.centerMass,angle:u}}}n.move&&(r={left:s.centerMass.left-c.centerMass.left,top:s.centerMass.top-c.centerMass.top}),n.scale&&(o={factor:c.spread/s.spread,center:c.centerMass})}return{move:r,scale:o,rotate:a}}function pe(t,e,i){void 0===i&&(i=.1);var n=e.getBoundingClientRect(),r=n.left,o=n.top;return{scale:{factor:1-i*I(t.deltaY||t.detail||t.wheelDelta),center:{left:t.clientX-r,top:t.clientY-o}}}}function ve(t){return t.moveCoordinates||t.resizeCoordinates||t.transformImage.move||t.transformImage.rotate||t.transformImage.flip||t.transformImage.scale}function ge(){return{moveCoordinates:!1,resizeCoordinates:!1,transformImage:{rotate:!1,move:!1,scale:!1,flip:!1}}}function be(t,e){var i=Nt(t),n={};return e.imageRestriction&&"none"!==e.imageRestriction&&(n={left:0,top:0,right:i.width,bottom:i.height}),n}function we(t,e){var i=t.coordinates,n=t.boundary,r=Nt(t),o=tt(n);if(i){var s={height:Math.max(i.height,r.height),width:Math.max(i.width,r.width)},c={left:0,top:0,width:tt(s)>o?s.width:s.height*o,height:tt(s)>o?s.width/o:s.height};(c=at(c,wt(t,e))).left=i.left+i.width/2-c.width/2,c.top=i.top+i.height/2-c.height/2;var l=ot(i,J(a({left:0,top:0},r))),d={};return!l.left&&!l.right&&c.width<=r.width&&(d.left=0,d.right=r.width),!l.top&&!l.bottom&&c.height<=r.height&&(d.top=0,d.bottom=r.height),ut(c,d)}var h=tt(r),u={height:h<o?r.height:r.width/o,width:h<o?r.height*o:r.width};return{left:r.width/2-u.width/2,top:r.height/2-u.height/2,width:u.width,height:u.height}}function ye(t,e){var i,n=t.imageSize,r=t.visibleArea,o=At(t,e),s=Mt(t,e);if(r)i=r;else{var c=lt(Ct(t,e));i={width:Math.max(c.minWidth,Math.min(c.maxWidth,n.width)),height:Math.max(c.minHeight,Math.min(c.maxHeight,n.height))}}var l=Math.min(s.maximum||1/0,Math.max(s.minimum||0,tt(i))),d=i.width<i.height?{width:.8*i.width,height:.8*i.width/l}:{height:.8*i.height,width:.8*i.height*l};return Lt(a(a({},d),{aspectRatio:s,sizeRestrictions:o}))}function Ae(t){return{minWidth:R(t.minWidth)?C(t.minWidth):0,minHeight:R(t.minHeight)?C(t.minHeight):0,maxWidth:R(t.maxWidth)?C(t.maxWidth):1/0,maxHeight:R(t.maxHeight)?C(t.maxHeight):1/0}}function Ce(t,e){return Ae(e)}function xe(t){var e=t.visibleArea,i=t.coordinates,n=e||Nt(t);return{left:(e?e.left:0)+n.width/2-(i?i.width/2:0),top:(e?e.top:0)+n.height/2-(i?i.height/2:0)}}function Se(e,i){var n=e.visibleArea,r=e.boundary,o=i.imageRestriction,a=Nt(e),s={};return o===t.ImageRestriction.fillArea?s={left:0,top:0,right:a.width,bottom:a.height}:o===t.ImageRestriction.fitArea&&(tt(r)>tt(a)?(s={top:0,bottom:a.height},n&&(n.width>a.width?(s.left=-(n.width-a.width)/2,s.right=a.width-s.left):(s.left=0,s.right=a.width))):(s={left:0,right:a.width},n&&(n.height>a.height?(s.top=-(n.height-a.height)/2,s.bottom=a.height-s.top):(s.top=0,s.bottom=a.height)))),s}function Me(e,i){var n=e.boundary,r=i.imageRestriction,o=Nt(e),a={minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0};return r===t.ImageRestriction.fillArea?(a.maxWidth=o.width,a.maxHeight=o.height):r===t.ImageRestriction.fitArea&&(tt(n)>tt(o)?(a.maxHeight=o.height,a.maxWidth=o.height*tt(n)):(a.maxWidth=o.width,a.maxHeight=o.width/tt(n))),a}function Ee(t){var e=t.getBoundingClientRect();return{width:e.width,height:e.height}}function Re(t,e){return t.aspectRatio?{}:{aspectRatio:ft(b(e.aspectRatio)?e.aspectRatio():e.aspectRatio)}}function ze(t){return function(e,i){var n=b(t)?t(e,i):t;return Tt(Ce(0,i),n)}}function Ne(t){return a(a({},t),{sizeRestrictions:function(e,i){return t.sizeRestrictions?b(t.sizeRestrictions)?t.sizeRestrictions(e,i):t.sizeRestrictions:Ce(0,i)},areaPositionRestrictions:function(e,i){return t.areaPositionRestrictions?b(t.areaPositionRestrictions)?t.areaPositionRestrictions(e,i):t.areaPositionRestrictions:Se(e,i)},areaSizeRestrictions:function(e,i){return t.areaSizeRestrictions?b(t.areaSizeRestrictions)?t.areaSizeRestrictions(e,i):t.areaSizeRestrictions:Me(e,i)},positionRestrictions:function(e,i){return t.positionRestrictions?b(t.positionRestrictions)?t.positionRestrictions(e,i):t.positionRestrictions:be(e,i)},defaultCoordinates:function(e,i){if(t.defaultCoordinates)return b(t.defaultCoordinates)?t.defaultCoordinates(e,i):t.defaultCoordinates;var n=t.defaultSize;n||(n=ye);var r=b(n)?n(e,i):n,o=t.defaultPosition||xe;return[r,function(t){return a({},b(o)?o(t,i):o)}]},defaultVisibleArea:function(e,i){return t.defaultVisibleArea?b(t.defaultVisibleArea)?t.defaultVisibleArea(e,i):t.defaultVisibleArea:we(e,i)},aspectRatio:function(e,i){return ft(b(t.aspectRatio)?t.aspectRatio(e,i):t.aspectRatio)}})}function Pe(t,e){if(t&&e){var i=e();i&&t(i)}}function We(t,e){t.forEach((function(t){Pe(t,e)}))}t.ImageRestriction=void 0,(k=t.ImageRestriction||(t.ImageRestriction={})).fillArea="fillArea",k.fitArea="fitArea",k.stencil="stencil",k.none="none",t.Priority=void 0,(B=t.Priority||(t.Priority={})).coordinates="coordinates",B.visibleArea="visibleArea",t.SetCoordinatesMode=void 0,(U=t.SetCoordinatesMode||(t.SetCoordinatesMode={})).limit="limit",U.zoom="zoom",U.unsafe="unsafe";var Ie=function(){var e=this;this.getTransitions=function(){var t=e.getData(),i=e.getProps().transitions;return a(a({},A(i,{timingFunction:"ease-in-out",duration:350})),{active:t.transitions})},this.getInteractions=function(){return T(e.getData().interactions)},this.hasInteractions=function(){return ve(e.getData().interactions)},this.startTransitions=function(){var t=e.getProps(),i=t.onTransitionsStart,n=t.onUpdate,r=t.getInstance,o=e.getData(),c=o.transitions,l=s(o,["transitions"]);e.setData(a(a({},l),{transitions:!0})),c||We([i,n],r),e.endTransitions()},this.endTransitions=L((function(){var t=e.getProps(),i=t.onTransitionsEnd,n=t.onUpdate,r=t.getInstance;e.setData(a(a({},e.getData()),{transitions:!1})),We([i,n],r)}),(function(){return e.getTransitions().duration})),this.applyPostProcess=function(t,i){var n=e.getProps(),r=n.settings,o=n.postProcess,a=t.name,s=t.interaction,c=void 0!==s&&s,l=t.transitions,d=void 0!==l&&l,h=t.immediately,u={name:a,interaction:c,transitions:d,immediately:void 0!==h&&h};return g(o)?o.reduce((function(t,e){return e(t,r,u)}),i):b(o)?o(i,r,u):i},this.updateState=function(t,i,n){void 0===i&&(i={}),void 0===n&&(n=[]);var r=i.transitions,o=void 0!==r&&r,s=e.getProps(),c=s.onTransitionsStart,l=s.getInstance,d=s.onChange,h=s.onUpdate,u=s.settings,m=e.getData(),f=b(t)?t(m.state,u):t,p=f?.001*xt(f):.001,v=!D(m.state,f,p),g=["coordinates","boundary","visibleArea","imageSize","transforms"].some((function(t){var e;return!D(null===(e=m.state)||void 0===e?void 0:e[t],null==f?void 0:f[t],p)})),w=m;v&&(o&&g&&e.endTransitions(),w=a(a({},w),{state:_t(f),transitions:o&&g}),e.setData(w),Pe(d,l)),w.transitions&&!m.transitions&&Pe(c,l),We(function(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,r++)n[r]=o[a];return n}(n,[h]),l)},this.setInteractions=function(t){var i=e.getProps(),n=i.onInteractionStart,r=i.onInteractionEnd,o=i.getInstance,s=e.getInteractions(),c=a(a({},s),t);if(D(s,c)||e.setData(a(a({},e.getData()),{interactions:c})),ve(s)!==ve(c))if(ve(s)){var l=e.getData().state;e.updateState((function(){return l&&e.applyPostProcess({name:"interactionEnd",immediately:!0,transitions:!0},l)}),{transitions:!0},[r])}else Pe(n,o)},this.resetState=function(t,i){e.updateState(e.createDefaultState(t,i))},this.clear=function(){e.updateState(null)},this.reconcileState=function(t){void 0===t&&(t={});var i=e.getProps(),n=i.reconcileStateAlgorithm,r=i.settings,o=e.getData().state,a=t.transitions,s=void 0!==a&&a;if(o&&!It(o,r)){var c=(n||oe)(o,r);c=e.applyPostProcess({name:"reconcileState",immediately:!0,transitions:s},c),e.updateState(c,{transitions:s})}},this.transformImage=function(t,i){void 0===i&&(i={});var n=i.transitions,r=void 0===n||n,o=i.interaction,a=void 0===o||o,s=i.immediately,c=void 0!==s&&s,l=i.normalize,d=void 0===l||l,h=e.getProps(),u=h.transformImageAlgorithm,m=h.onTransformImage,f=h.onTransformImageEnd,p=h.settings,v=e.getData().state,g=[];if(v){d&&(t=ue(v,t));var b=e.applyPostProcess({name:"transformImage",transitions:r,immediately:c},(u||re)(v,p,t));g.push(m),a?e.setInteractions({transformImage:{rotate:!w(t.rotate),flip:!w(t.flip),scale:!w(t.scale),move:!w(t.move)}}):(b=e.applyPostProcess({name:"transformImageEnd",transitions:r,immediately:!0},b),g.push(f)),e.updateState(b,{transitions:c&&r},g)}},this.transformImageEnd=function(t){void 0===t&&(t={});var i=t.immediately,n=void 0===i||i,r=t.transitions,o=void 0===r||r,a=e.getData().state,s=e.getProps().onTransformImageEnd;e.updateState((function(){return a&&e.applyPostProcess({name:"transformImageEnd",immediately:n,transitions:o},a)}),{transitions:o},[s]),e.setInteractions({transformImage:{rotate:!1,flip:!1,scale:!1,move:!1}})},this.zoomImage=function(t,i){void 0===i&&(i={});var n=i.interaction,r=void 0!==n&&n,o=i.immediately,a=void 0===o||o,s=i.transitions,c=void 0===s||s,l=i.normalize,d=void 0!==l&&l;e.transformImage({scale:t},{interaction:r,immediately:a,transitions:c,normalize:d})},this.moveImage=function(t,i,n){void 0===n&&(n={});var r=n.interaction,o=void 0!==r&&r,a=n.immediately,s=void 0===a||a,c=n.transitions,l=void 0===c||c,d=n.normalize,h=void 0!==d&&d;e.transformImage({move:{left:t,top:i}},{interaction:o,immediately:s,transitions:l,normalize:h})},this.flipImage=function(t,i,n){void 0===n&&(n={});var r=n.interaction,o=void 0!==r&&r,a=n.immediately,s=void 0===a||a,c=n.transitions,l=void 0===c||c,d=n.normalize,h=void 0===d||d,u=e.getState(),m={horizontal:t,vertical:i};e.transformImage({flip:u&&h?ce(u,m):m},{interaction:o,immediately:s,transitions:l})},this.rotateImage=function(t,i){void 0===i&&(i={});var n=i.interaction,r=void 0!==n&&n,o=i.immediately,a=void 0===o||o,s=i.transitions,c=void 0===s||s,l=i.normalize,d=void 0!==l&&l;e.transformImage({rotate:t},{interaction:r,immediately:a,transitions:c,normalize:d})},this.reset=function(t,i){e.resetState(t,i)},this.setState=function(t,i){void 0===i&&(i={});var n=e.getSettings(),r=e.getData().state,o=i.transitions,s=void 0===o||o,c=i.immediately,l=void 0!==c&&c,d=i.interaction,h=void 0!==d&&d,u=i.postprocess,m=void 0!==u&&u,f=t&&(b(t)?t(r,n):a(a({},r),t));e.updateState((function(){return m?f&&e.applyPostProcess({name:"setState",immediately:l,transitions:s,interaction:h},f):f}),{transitions:s})},this.setCoordinates=function(i,n){void 0===n&&(n={});var r=e.getData().state,o=e.getProps(),a=o.setCoordinatesAlgorithm,s=o.settings,c=n.transitions,l=void 0===c||c,d=n.immediately,h=void 0===d||d;e.updateState((function(){return r&&e.applyPostProcess({name:"setCoordinates",immediately:h,transitions:l},(a||Ut)(r,s,i,t.SetCoordinatesMode.zoom))}),{transitions:l})},this.setVisibleArea=function(t,i){void 0===i&&(i={});var n=i.transitions,r=void 0===n||n,o=i.immediately,a=void 0===o||o,s=e.getData().state,c=e.getProps(),l=c.setVisibleAreaAlgorithm,d=c.settings;e.updateState((function(){return s&&e.applyPostProcess({name:"setVisibleArea",immediately:a,transitions:r},(l||jt)(s,d,t))}),{transitions:r})},this.setBoundary=function(t,i){void 0===i&&(i={});var n=e.getData().state,r=e.getProps(),o=r.setBoundaryAlgorithm,a=r.settings,s=i.transitions,c=void 0!==s&&s,l=i.immediately,d=void 0===l||l;t?e.updateState((function(){return n&&e.applyPostProcess({name:"setBoundary",immediately:d,transitions:c},(o||te)(n,a,t))})):e.updateState(null)},this.moveCoordinates=function(t,i){void 0===i&&(i={});var n=e.getData(),r=e.getProps(),o=r.moveCoordinatesAlgorithm,a=r.onMove,s=r.onMoveEnd,c=r.settings,l=i.interaction,d=void 0===l||l,h=i.transitions,u=void 0!==h&&h,m=i.immediately,f=void 0!==m&&m,p=i.normalize,v=void 0===p||p,g=[];if(!n.transitions&&n.state){var b=v?he(n.state,t):le(t),w=e.applyPostProcess({name:"moveCoordinates",interaction:d,immediately:f,transitions:u},(o||Vt)(n.state,c,b));g.push(a),d?e.setInteractions({moveCoordinates:!0}):(w=e.applyPostProcess({name:"moveCoordinatesEnd",interaction:d,immediately:f,transitions:u},w),g.push(s)),e.updateState(w,{transitions:f&&u},g)}},this.moveCoordinatesEnd=function(t){void 0===t&&(t={});var i=e.getData().state,n=e.getProps().onMoveEnd,r=t.transitions,o=void 0===r||r,a=t.immediately,s=void 0!==a&&a;e.updateState((function(){return i&&e.applyPostProcess({name:"moveCoordinatesEnd",transitions:o,immediately:s},i)}),{transitions:o},[n]),e.setInteractions({moveCoordinates:!1})},this.resizeCoordinates=function(t,i,n,r){void 0===r&&(r={});var o=e.getData().state,a=e.getProps(),s=a.resizeCoordinatesAlgorithm,c=a.onResize,l=a.onResizeEnd,d=a.settings,h=r.interaction,u=void 0===h||h,m=r.transitions,f=void 0!==m&&m,p=r.immediately,v=void 0!==p&&p,g=r.normalize,b=void 0===g||g;if(!e.getTransitions().active&&o){var w=[],A=b?ae(o,i):de(i),C=e.applyPostProcess({name:"resizeCoordinates",interaction:u,immediately:v,transitions:f},(s||$t)(o,d,t,A,y(n)?n:{}));w.push(c),u?e.setInteractions({resizeCoordinates:!0}):(C=e.applyPostProcess({name:"resizeCoordinatesEnd",interaction:u,immediately:v,transitions:f},C),w.push(l)),e.updateState(C,{transitions:v&&f},w)}},this.resizeCoordinatesEnd=function(t){void 0===t&&(t={});var i=e.getProps().onResizeEnd,n=e.getData().state,r=t.transitions,o=void 0===r||r,a=t.immediately,s=void 0!==a&&a;e.updateState((function(){return n&&e.applyPostProcess({name:"resizeCoordinatesEnd",transitions:o,immediately:s},n)}),{transitions:o},[i]),e.setInteractions({resizeCoordinates:!1})},this.getStencilCoordinates=function(){return St(e.getData().state)},this.getCoordinates=function(t){void 0===t&&(t={});var i=e.getData().state,n=e.getProps().settings;if(i&&i.coordinates){var r=t.round;return void 0===r||r?Wt(i,n):a({},i.coordinates)}return null},this.getVisibleArea=function(){var t=e.getData().state;return(null==t?void 0:t.visibleArea)?a({},t.visibleArea):null},this.getSettings=function(){var t=e.getProps().settings;return a({},t)},this.getState=function(){return _t(e.getData().state)},this.getTransforms=function(){var t=e.getData().state;return t?T(t.transforms):{rotate:0,flip:{horizontal:!1,vertical:!1}}},this.createDefaultState=function(t,i){var n=e.getProps(),r=n.createStateAlgorithm,o=n.settings;return e.applyPostProcess({name:"createState",immediately:!0,transitions:!1},(r||Yt)({image:i,boundary:t},o))},this.isConsistent=function(){var t=e.getData().state,i=e.getProps().settings;return!t||It(t,i)}},He={linear:function(t){return t},"ease-in":function(t){return Math.pow(t,1.675)},"ease-out":function(t){return 1-Math.pow(1-t,1.675)},"ease-in-out":function(t){return.5*(Math.sin((t-.5)*Math.PI)+1)}},Te=function(){function t(){this.active=!1}return t.prototype.start=function(t){var e;this.onStart=t.onStart,this.onProgress=t.onProgress,this.onStop=t.onStop,this.active||null===(e=this.onStart)||void 0===e||e.call(this),this.id&&window.cancelAnimationFrame(this.id),this.startTime=performance.now(),this.timingFunction=t.timingFunction,this.endTime=this.startTime+t.duration,this.active=!0,this.animate()},t.prototype.animate=function(){var t=this;if(this.startTime&&this.endTime){var e=He[this.timingFunction];e||("production"!==production&&console.warn("[Animation] The timing function '"+e+"' is not supported. Available timing function: 'linear', 'ease-in', 'ease-in-out', 'ease-out'. Reset to 'ease-out'."),e=He["ease-out"]);var i=1-(this.endTime-performance.now())/(this.endTime-this.startTime),n=Math.min(1,e(i));this.onProgress&&this.onProgress(n),i<1?this.id=window.requestAnimationFrame((function(){return t.animate()})):this.stop()}else this.stop()},t.prototype.stop=function(){this.active=!1,this.id&&window.cancelAnimationFrame(this.id),this.onStop&&this.onStop()},t}();function De(t,e,i){var n=i.rotate,r=i.flip,o={width:"naturalWidth"in e?e.naturalWidth:e.width,height:"naturalHeight"in e?e.naturalHeight:e.height},s=st(o,n),c=t.getContext("2d");if(t.height=s.height,t.width=s.width,c){c.save();var l=ct(F(a({left:0,top:0},o)),n);c.translate(-(l.left-s.width/2),-(l.top-s.height/2)),c.rotate(n*Math.PI/180),c.translate(r.horizontal?o.width:0,r.vertical?o.height:0),c.scale(r.horizontal?-1:1,r.vertical?-1:1),c.drawImage(e,0,0,o.width,o.height),c.restore()}return t}function Oe(t,e,i,n,r){t.width=n?n.width:i.width,t.height=n?n.height:i.height;var o=t.getContext("2d");if(o){o.clearRect(0,0,t.width,t.height),r&&(r.imageSmoothingEnabled&&(o.imageSmoothingEnabled=r.imageSmoothingEnabled),r.imageSmoothingQuality&&(o.imageSmoothingQuality=r.imageSmoothingQuality),r.fillColor&&(o.fillStyle=r.fillColor,o.fillRect(0,0,t.width,t.height),o.save()));var a=i.left<0?-i.left:0,s=i.top<0?-i.top:0;o.drawImage(e,i.left+a,i.top+s,i.width,i.height,a*(t.width/i.width),s*(t.height/i.height),t.width,t.height)}return t}function _e(t,e,i,n,r){if(bt(t)){var o=t.transforms,s=t.coordinates,c=0!==o.rotate||o.flip.horizontal||o.flip.vertical?De(n,e,o):e,l=a({minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0,maxArea:1/0,imageSmoothingEnabled:!0,imageSmoothingQuality:"high",fillColor:"transparent"},r),d=function(t){return t.find((function(t){return R(t)}))},h=Lt({sizeRestrictions:{minWidth:d([l.width,l.minWidth])||0,minHeight:d([l.height,l.minHeight])||0,maxWidth:d([l.width,l.maxWidth])||1/0,maxHeight:d([l.height,l.maxHeight])||1/0},width:s.width,height:s.height,aspectRatio:{minimum:s.width/s.height,maximum:s.width/s.height}});if(l.maxArea&&h.width*h.height>l.maxArea){var u=Math.sqrt(l.maxArea/(h.width*h.height));h={width:Math.round(u*h.width),height:Math.round(u*h.height)}}return Oe(i,c,s,h,l)}return null}function Le(t,e,i){e.style.width="0px",e.style.height="0px",e.style.width=Math.max(t.clientWidth,i.width)+"px";var n=i.width/i.height;e.style.height=Math.max(t.clientHeight,e.clientWidth/n)+"px",e.style.width=e.clientHeight*n+"px"}function ke(t,e,i){e.style.width="0px",e.style.height="0px",e.style.width=Math.max(t.getBoundingClientRect().width,i.width)+"px";var n=i.width/i.height;e.style.height=Math.max(t.getBoundingClientRect().height,e.getBoundingClientRect().width/n)+"px",e.style.width=e.getBoundingClientRect().height*n+"px",e.clientWidth/e.clientHeight>t.clientWidth/t.clientHeight?e.clientWidth>t.clientWidth&&(e.style.width=t.clientWidth+"px",e.style.height=t.clientWidth/n+"px"):e.clientHeight>t.clientHeight&&(e.style.height=t.clientHeight+"px",e.style.width=t.clientHeight*n+"px")}function Be(t){return new Promise((function(e,i){try{if(t)if(/^data:/i.test(t))e(function(t){t=t.replace(/^data:([^;]+);base64,/gim,"");for(var e=atob(t),i=e.length,n=new ArrayBuffer(i),r=new Uint8Array(n),o=0;o<i;o++)r[o]=e.charCodeAt(o);return n}(t));else if(/^blob:/i.test(t)){var n=new FileReader;n.onload=function(t){var i;e(null===(i=t.target)||void 0===i?void 0:i.result)},o=t,a=function(t){n.readAsArrayBuffer(t)},(s=new XMLHttpRequest).open("GET",o,!0),s.responseType="blob",s.onload=function(){200!=this.status&&0!==this.status||a(this.response)},s.send()}else{var r=new XMLHttpRequest;r.onreadystatechange=function(){4===r.readyState&&(200===r.status||0===r.status?e(r.response):i("Warning: could not load an image to parse its orientation"))},r.onprogress=function(){"image/jpeg"!==r.getResponseHeader("content-type")&&r.abort()},r.withCredentials=!1,r.open("GET",t,!0),r.responseType="arraybuffer",r.send(null)}else i("Error: the image is empty")}catch(t){i(t)}var o,a,s}))}function Ue(t){var e=t.rotate,i=void 0===e?0:e,n=t.flip,r=void 0===n?{horizontal:!1,vertical:!1}:n,o=t.scale,a=void 0===o?1:o;return" rotate("+i+"deg) scaleX("+a*(r.horizontal?-1:1)+") scaleY("+a*(r.vertical?-1:1)+")"}function Xe(t){try{var e,i=new DataView(t),n=void 0,r=void 0,o=void 0,a=void 0;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var s=i.byteLength,c=2;c+1<s;){if(255===i.getUint8(c)&&225===i.getUint8(c+1)){o=c;break}c++}if(o&&(n=o+10,"Exif"===function(t,e,i){var n,r="";for(n=e,i+=e;n<i;n++)r+=String.fromCharCode(t.getUint8(n));return r}(i,o+4,4))){var l=i.getUint16(n);if(((r=18761===l)||19789===l)&&42===i.getUint16(n+2,r)){var d=i.getUint32(n+4,r);d>=8&&(a=n+d)}}if(a)for(var h=i.getUint16(a,r),u=0;u<h;u++){c=a+12*u+2;if(274===i.getUint16(c,r)){c+=8,e=i.getUint16(c,r),i.setUint16(c,1,r);break}}return e}catch(t){return null}}function je(t){var e=t.src,i=t.arrayBuffer,n=void 0===i?null:i,r=t.orientation,o=void 0===r?null:r,a={src:e,arrayBuffer:n,revoke:!1,transforms:{flip:{horizontal:!1,vertical:!1},rotate:0}};return n&&o&&o>1?m(e)||!p(e)?(a.src=URL.createObjectURL(new Blob([n])),a.revoke=!0):a.src=function(t){for(var e=[],i=new Uint8Array(t);i.length>0;){var n=i.subarray(0,8192);e.push(String.fromCharCode.apply(null,Array.from?Array.from(n):n.slice())),i=i.subarray(8192)}return"data:image/jpeg;base64,"+btoa(e.join(""))}(n):a.src=e,o&&(a.transforms=function(t){var e={flip:{horizontal:!1,vertical:!1},rotate:0};if(t)switch(t){case 2:e.flip.horizontal=!0;break;case 3:e.rotate=-180;break;case 4:e.flip.vertical=!0;break;case 5:e.rotate=90,e.flip.vertical=!0;break;case 6:e.rotate=90;break;case 7:e.rotate=90,e.flip.horizontal=!0;break;case 8:e.rotate=-90}return e}(o)),a}function Ye(t,e){return void 0===e&&(e={}),new Promise((function(i,n){var r=document.createElement("img");e.crossOrigin&&(r.crossOrigin=!0!==e.crossOrigin?e.cro