@syncfusion/ej2-image-editor 22.1.36 → 22.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/ej2-image-editor.umd.min.js +2 -2
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +351 -278
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +353 -279
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +11 -11
- package/src/image-editor/action/crop.d.ts +2 -0
- package/src/image-editor/action/crop.js +89 -97
- package/src/image-editor/action/draw.js +88 -71
- package/src/image-editor/action/export.js +49 -66
- package/src/image-editor/action/freehand-draw.js +25 -1
- package/src/image-editor/action/selection.d.ts +1 -0
- package/src/image-editor/action/selection.js +26 -7
- package/src/image-editor/action/shape.d.ts +2 -0
- package/src/image-editor/action/shape.js +51 -22
- package/src/image-editor/action/transform.js +10 -0
- package/src/image-editor/action/undo-redo.js +4 -2
- package/src/image-editor/base/image-editor.js +8 -8
- package/src/image-editor/base/interface.d.ts +6 -2
- package/src/image-editor/renderer/toolbar.js +4 -5
- package/styles/bootstrap-dark.css +20 -8
- package/styles/bootstrap.css +20 -8
- package/styles/bootstrap4.css +20 -8
- package/styles/bootstrap5-dark.css +20 -8
- package/styles/bootstrap5.css +20 -8
- package/styles/fabric-dark.css +20 -8
- package/styles/fabric.css +20 -8
- package/styles/fluent-dark.css +20 -8
- package/styles/fluent.css +20 -8
- package/styles/highcontrast-light.css +20 -8
- package/styles/highcontrast.css +20 -8
- package/styles/image-editor/_layout.scss +20 -2
- package/styles/image-editor/bootstrap-dark.css +20 -8
- package/styles/image-editor/bootstrap.css +20 -8
- package/styles/image-editor/bootstrap4.css +20 -8
- package/styles/image-editor/bootstrap5-dark.css +20 -8
- package/styles/image-editor/bootstrap5.css +20 -8
- package/styles/image-editor/fabric-dark.css +20 -8
- package/styles/image-editor/fabric.css +20 -8
- package/styles/image-editor/fluent-dark.css +20 -8
- package/styles/image-editor/fluent.css +20 -8
- package/styles/image-editor/highcontrast-light.css +20 -8
- package/styles/image-editor/highcontrast.css +20 -8
- package/styles/image-editor/material-dark.css +20 -8
- package/styles/image-editor/material.css +20 -8
- package/styles/image-editor/material3-dark.css +20 -8
- package/styles/image-editor/material3.css +20 -8
- package/styles/image-editor/tailwind-dark.css +20 -8
- package/styles/image-editor/tailwind.css +20 -8
- package/styles/material-dark.css +20 -8
- package/styles/material.css +20 -8
- package/styles/material3-dark.css +20 -8
- package/styles/material3.css +20 -8
- package/styles/tailwind-dark.css +20 -8
- package/styles/tailwind.css +20 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: ej2-image-editor.min.js
|
|
3
|
-
* version : 22.1.
|
|
3
|
+
* version : 22.1.38
|
|
4
4
|
* Copyright Syncfusion Inc. 2001 - 2020. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
|
7
7
|
* licensing@syncfusion.com. Any infringement will be prosecuted under
|
|
8
8
|
* applicable laws.
|
|
9
9
|
*/
|
|
10
|
-
this.ej=this.ej||{},this.ej.imageeditor=function(t,e,i,o,r,a){"use strict";var n=function(){function t(t){this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1,this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("crop",this.cropping,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("crop",this.crop),this.parent.off("destroyed",this.destroy)},t.prototype.cropping=function(t){switch(this.updateCropPvtVar(),t.prop){case"cropImg":this.cropImg(t.value.isRotateCrop);break;case"cropCircle":this.cropCircle(t.value.context,t.value.isSave,t.value.isFlip);break;case"setCurrSelPoints":this.setCurrSelPoints(t.value.isSetDimension);break;case"updateRotatePan":this.updateRotatePan();break;case"crop":this.crop(t.value.obj);break;case"calcRatio":this.calcRatio(t.value.obj);break;case"isObjInImage":this.isObjInImage(t.value.obj,t.value.object);break;case"getCurrFlipState":this.getCurrFlipState(t.value.panObj);break;case"setPreviousCropCurrentObj":this.prevCropCurrObj=t.value.obj;break;case"setCropDestPoints":this.cropDestPoints=t.value.point;break;case"getTempFlipPanPoint":t.value.obj.point=this.tempFlipPanPoint;break;case"setTempFlipPanPoint":e.isNullOrUndefined(t.value.isAdd)?this.tempFlipPanPoint=t.value.point:(this.tempFlipPanPoint.x+=t.value.point.x,this.tempFlipPanPoint.y+=t.value.point.y);break;case"getPreventScaling":t.value.obj.bool=this.isPreventScaling;break;case"reset":this.reset()}},t.prototype.getModuleName=function(){return"crop"},t.prototype.updateCropPvtVar=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d"))},t.prototype.reset=function(){this.prevCropCurrObj=null,this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1},t.prototype.cropImg=function(t){var i=this.parent,o=e.isNullOrUndefined(t),r=i.activeObj.activePoint;if(i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),o&&(this.croppedDegree=i.transform.degree),o&&0!==i.transform.degree){this.updateCropObj();n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:n}}),this.rotateCrop()}else if(o&&""!==i.transform.currFlipState){this.updateCropObj();n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:n}}),this.flipCrop()}else{i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}});var a=this.calcRatio();if(o||!t){this.updateCropObj(),i.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1});var n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:n}}),i.currSelectionPoint=e.extend({},i.activeObj,{},!0),this.cropDestPoints={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight}}var s={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:r.width*a.width,height:r.height*a.height,obj:s}});var l=s;this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.img.srcLeft=r.startX*a.width-i.img.destLeft*a.width,i.img.srcTop=r.startY*a.height-i.img.destTop*a.height,i.img.srcWidth=r.width*a.width,i.img.srcHeight=r.height*a.height,i.img.destLeft=(i.lowerCanvas.clientWidth-l.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-l.height)/2,i.img.destWidth=l.width,i.img.destHeight=l.height;var p=this.lowerContext.filter;i.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,i.img.destLeft,i.img.destTop,i.img.destWidth,i.img.destHeight),this.lowerContext.filter="none";var h=e.extend({},i.activeObj,{},!0);this.cropObjColl(),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}});for(var c=0,d=i.objColl.length;c<d;c++)this.isObjInImage(i.objColl[c])&&(i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:i.objColl[c].shape,obj:i.objColl[c],canvas:null}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}));i.activeObj=h,this.cropFreehandDrawColl(),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),"crop-circle"===i.currSelectionPoint.shape?this.cropCircle(this.lowerContext):i.isCircleCrop=!1,this.lowerContext.filter=p,i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.currObjType.isCustomCrop=!1,i.pan(!1),i.transform.defaultZoomFactor=0}},t.prototype.updateCropObj=function(){this.parent.afterCropActions=[];var t={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:t}});var i=t.currObj;this.parent.cropObj=e.extend({},i,{},!0)},t.prototype.rotateCrop=function(){var t=this.parent,i=t.activeObj.shape||"",o=t.transform.degree;t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.currSelectionPoint=e.extend({},t.activeObj,{},!0),t.objColl.push(t.activeObj),t.activeObj=e.extend({},t.objColl[t.objColl.length-1],{},!0),this.lowerContext.setTransform(1,0,0,1,0,0),t.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}}),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.transform.degree=0;var r=this.lowerContext.filter;t.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=r;var a=0;90===o||-270===o?a=3:180===o||-180===o?a=2:270!==o&&-90!==o||(a=1);for(s=0;s<a;s++)t.notify("shape",{prop:"rotateObjColl",onPropertyChange:!1}),t.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});var n=e.extend({},t.objColl[t.objColl.length-1],{},!0);if(""!==t.transform.currFlipState){for(var s=0,l=t.objColl.length;s<l;s++)t.objColl[s].shapeFlip="";for(s=0;s<t.freehandCounter;s++)t.pointColl[s].shapeFlip="";t.transform.degree=o;p=this.getCurrCropState("initial");t.transform.degree=0,t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:p}}),t.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:p}})}t.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),n=e.extend({},t.objColl[t.objColl.length-1],{},!0),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:n}}),t.objColl.pop(),t.transform.degree=0,this.cropImg(!0),t.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),this.lowerContext.setTransform(1,0,0,1,0,0),t.transform.degree=o,t.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),t.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=r,t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),a=0,90===o||-270===o?a=1:180===o||-180===o?a=2:270!==o&&-90!==o||(a=3);for(s=0;s<a;s++)t.notify("shape",{prop:"rotateObjColl",onPropertyChange:!1}),t.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});if(""!==this.getCurrFlipState()){for(var s=0,l=t.objColl.length;s<l;s++)t.objColl[s].shapeFlip="";for(s=0;s<t.freehandCounter;s++)t.pointColl[s].shapeFlip="";var p=this.getCurrCropState("reverse");t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:p}}),t.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:p}})}t.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!1}}),this.lowerContext.filter="none";for(var s=0,l=t.objColl.length;s<l;s++)this.isObjInImage(t.objColl[s])&&(t.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:t.objColl[s].shape,obj:t.objColl[s],canvas:null}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}));t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=r,t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),"crop-circle"===i&&this.cropCircle(this.lowerContext),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})},t.prototype.flipCrop=function(){var t=this.parent;t.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),t.panPoint.totalPannedPoint.x+=this.tempFlipPanPoint.x,t.panPoint.totalPannedPoint.y+=this.tempFlipPanPoint.y;var i=t.transform.currFlipState,o={flipColl:null};t.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:o}});var r=o.flipColl;if(t.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:[]}}),t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.objColl.push(t.activeObj),t.transform.zoomFactor>0){for(var a=t.transform.zoomFactor,n=t.isUndoRedo,s=0;s<10*a;s++)t.isUndoRedo=!0,t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}});t.isUndoRedo=n,t.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})}t.currSelectionPoint=e.extend({},t.objColl[t.objColl.length-1],{},!0),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height);var l=this.lowerContext.filter;t.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight);for(var s=0,p=t.objColl.length;s<p;s++)t.objColl[s].shapeFlip="";for(s=0;s<t.freehandCounter;s++)t.pointColl[s].shapeFlip="";t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),t.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),t.activeObj=e.extend({},t.objColl[t.objColl.length-1],{},!0),t.objColl.pop(),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.cropImg(!0),t.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),this.lowerContext.setTransform(1,0,0,1,0,0),t.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),t.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=l,t.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),t.transform.currFlipState=i,t.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:r}}),this.lowerContext.filter="none";for(var s=0,p=t.objColl.length;s<p;s++)t.objColl[s].shapeFlip="";for(s=0;s<t.freehandCounter;s++)t.pointColl[s].shapeFlip="";t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),t.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),t.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=l,(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&this.cropCircle(this.lowerContext),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}}),t.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),this.tempFlipPanPoint={x:0,y:0}},t.prototype.cropObjColl=function(){var t,e,i,o=this.parent;if(o.objColl.length>0)for(var r=0,a=o.objColl.length;r<a;r++){t=o.objColl[r].activePoint,e=o.activeObj.activePoint,i=o.objColl[r].shape,o.objColl[r].imageRatio={startX:(t.startX-e.startX)/e.width,startY:(t.startY-e.startY)/e.height,endX:(t.endX-e.startX)/e.width,endY:(t.endY-e.startY)/e.height,width:e.width/t.width,height:e.height/t.height};var n=void 0,s=void 0;switch(i){case"text":s=0===(n=0===o.objColl[r].shapeDegree?this.parent.transform.degree:this.parent.transform.degree-o.objColl[r].shapeDegree)||180===Math.abs(n)?t.width:t.height,o.objColl[r].textSettings.fontRatio=s/o.objColl[r].textSettings.fontSize;break;case"line":case"arrow":this.cropPointCollection(r),"arrow"===i&&o.notify("shape",{prop:"updateArrowRatio",onPropertyChange:!1,value:{obj:o.objColl[r]}});break;case"path":this.cropPointCollection(r)}}},t.prototype.cropPointCollection=function(t){var e,i,o,r,a=this.parent,n=a.objColl[t].shape,s=a.activeObj.activePoint;"path"===n?(e=s.startX,i=s.startY,o=s.width,r=s.height):(e=a.img.destLeft,i=a.img.destTop,o=a.img.destWidth,r=a.img.destHeight);for(var l=a.objColl[t],p=0,h=l.pointColl.length;p<h;p++)l.pointColl[p].ratioX=(l.pointColl[p].x-e)/o,l.pointColl[p].ratioY=(l.pointColl[p].y-i)/r},t.prototype.cropFreehandDrawColl=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++){t.points=e.extend([],t.pointColl[i].points,[]),t.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var o=t.points.length,r=0;r<o;r++)t.points[r].ratioX=(t.points[r].x-t.activeObj.activePoint.startX)/t.activeObj.activePoint.width,t.points[r].ratioY=(t.points[r].y-t.activeObj.activePoint.startY)/t.activeObj.activePoint.height}t.notify("freehand-draw",{prop:"updateCropPtsForSel",onPropertyChange:!1})},t.prototype.setCurrSelPoints=function(t){var i=this.parent,o=this.cropDestPoints;if(i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImg.width,i.img.srcHeight=i.baseImg.height,i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),t&&i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),0===this.croppedDegree&&0===i.transform.degree&&i.currSelectionPoint&&"crop-circle"!==i.currSelectionPoint.shape&&"crop-square"!==i.currSelectionPoint.shape&&(i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height),0===i.transform.degree&&(i.img.destLeft+=i.panPoint.totalPannedInternalPoint.x,i.img.destTop+=i.panPoint.totalPannedInternalPoint.y),i.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,i.img.destLeft,i.img.destTop,i.img.destWidth,i.img.destHeight),i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:!0}}),i.cropObj.activeObj.shape){var r={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.currSelectionPoint&&i.currSelectionPoint.activePoint&&(i.img.destLeft=i.currSelectionPoint.activePoint.startX,i.img.destTop=i.currSelectionPoint.activePoint.startY,i.img.destWidth=i.currSelectionPoint.activePoint.width,i.img.destHeight=i.currSelectionPoint.activePoint.height),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=r.startX,i.img.destTop=r.startY,i.img.destWidth=r.width,i.img.destHeight=r.height,i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var a=e.extend([],i.objColl,null,!0),n=e.extend([],i.pointColl,null,!0);i.objColl=[],i.pointColl=[],i.freehandCounter=0;var s={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}});var l=s.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.cropObj.filter=this.lowerContext.filter,i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:null}});var p=e.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.objColl=a,i.pointColl=n,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:l}}}),i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.currSelectionPoint=null,0===i.transform.degree&&i.notify("transform",{prop:"drawPannImage",onPropertyChange:!1,value:{point:{x:0,y:0}}}),i.activeObj=p,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}})}else{var h=this.lowerContext.filter;this.lowerContext.filter="none",i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=h,i.currSelectionPoint=null}},t.prototype.cropCircle=function(t,i,o){var r=this.parent;o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:t,value:r.transform.currFlipState,isReverse:null}}),t.globalCompositeOperation="destination-in",t.beginPath();var a=e.isNullOrUndefined(i)?r.img.destLeft+r.img.destWidth/2:r.img.destWidth/2,n=e.isNullOrUndefined(i)?r.img.destTop+r.img.destHeight/2:r.img.destHeight/2,s=r.img.destWidth/2;t.arc(a,n,s,0,2*Math.PI),t.closePath(),t.fill(),t.restore(),t.globalCompositeOperation="source-over",r.currObjType.isActiveObj=r.isCircleCrop=!0,o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:t,value:r.transform.currFlipState,isReverse:null}})},t.prototype.getCurrCropState=function(t,e){var i=this.parent,o="",r=[],a={flipColl:null};if(i.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:a}}),"initial"===t)if(180===Math.abs(i.transform.degree))o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState;else{for(var n=0,s=i.rotateFlipColl.length;n<s;n++)"number"==typeof i.rotateFlipColl[n]?r.push("number"):"string"==typeof i.rotateFlipColl[n]&&r.push("string");r.length>1&&"string"===r[r.length-1]&&"number"===r[r.length-2]?"horizontal"===i.transform.currFlipState?o="vertical":"vertical"===i.transform.currFlipState&&(o="horizontal"):r.length>1&&"number"===r[r.length-1]&&"string"===r[r.length-2]&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState)}else o=this.getCurrFlipState(),!e&&this.isInitialRotate()||-90!==i.transform.degree&&-270!==i.transform.degree||("horizontal"===o?o="vertical":"vertical"===o&&(o="horizontal"));return""===o&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState),o},t.prototype.isInitialRotate=function(){var t=!1;return this.parent.rotateFlipColl.length>0&&"number"==typeof this.parent.rotateFlipColl[0]&&(t=!0),t},t.prototype.updateRotatePan=function(){var t=this.parent;if(!e.isNullOrUndefined(t.panPoint.currentPannedPoint)){var i="";i=t.rotateFlipColl.length>0&&"number"==typeof t.rotateFlipColl[0]&&t.transform.degree<0?this.getCurrCropState("reverse",!0):this.getCurrFlipState(),t.transform.degree%90==0&&t.transform.degree%180!=0?90===t.transform.degree||-90===t.transform.degree&&("horizontal"===i||"vertical"===i)||-270===t.transform.degree&&(""===i||"verticalHorizontal"===i||"horizontalVertical"===i)?("horizontal"===i||""===i?t.img.destLeft+=t.panPoint.currentPannedPoint.y:t.img.destLeft-=t.panPoint.currentPannedPoint.y,""===i||"vertical"===i?t.img.destTop-=t.panPoint.currentPannedPoint.x:t.img.destTop+=t.panPoint.currentPannedPoint.x):270!==t.transform.degree&&(-270!==t.transform.degree||"horizontal"!==i&&"vertical"!==i)&&(-90!==t.transform.degree||""!==i&&"verticalHorizontal"!==i&&"horizontalVertical"!==i)||(""===i||"horizontal"===i?t.img.destLeft-=t.panPoint.currentPannedPoint.y:t.img.destLeft+=t.panPoint.currentPannedPoint.y,""===i||"vertical"===i?t.img.destTop+=t.panPoint.currentPannedPoint.x:t.img.destTop-=t.panPoint.currentPannedPoint.x):180!==t.transform.degree&&-180!==t.transform.degree||(""===i||"vertical"===i?t.img.destLeft-=t.panPoint.currentPannedPoint.x:t.img.destLeft+=t.panPoint.currentPannedPoint.x,""===i||"horizontal"===i?t.img.destTop-=t.panPoint.currentPannedPoint.y:t.img.destTop+=t.panPoint.currentPannedPoint.y)}},t.prototype.crop=function(t){var i=this,o=this.parent;if(!o.disabled&&o.isImageLoaded){var r={isCropToolbar:o.isCropToolbar};o.currObjType.isUndoAction&&!r.isCropToolbar&&o.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}});var a={cancel:!1,startPoint:{x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY},endPoint:{x:o.activeObj.activePoint.endX,y:o.activeObj.activePoint.endY},preventScaling:!1};!r.isCropToolbar&&e.isBlazor()&&o.events&&!0===o.events.cropping.hasDelegate?o.dotNetRef.invokeMethodAsync("CropEventAsync","OnCrop",a).then(function(e){i.cropEvent(e,t,r)}):(r.isCropToolbar||o.trigger("cropping",a),this.cropEvent(a,t,r))}},t.prototype.cropEvent=function(t,i,o){var r,a=this.parent;if(!t.cancel&&(r=a.activeObj.shape?a.activeObj.shape.split("-"):[],!a.disabled&&a.activeObj.horTopLine&&(a.currObjType.isCustomCrop||r.length>0&&"crop"===r[0]))){i.isCrop=!0;var n=e.extend({},a.cropObj,{},!0),s=e.extend({},this.prevCropCurrObj,{},!0);t.preventScaling?this.isPreventScaling=!0:this.isPreventScaling=!1,this.cropImg(),a.transform.zoomFactor=0,a.zoomSettings.zoomFactor=1,a.setProperties({zoomSettings:{zoomFactor:1}},!0),a.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:a.zoomSettings.zoomFactor}});var l={prevCurrSelectionPoint:this.parent.prevCurrSelectionPoint};s.currSelectionPoint=e.extend({},l.prevCurrSelectionPoint,{},!0),a.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"crop",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:n,previousText:null,currentText:null,previousFilter:null,isCircleCrop:a.isCircleCrop}}),o.isCropToolbar||a.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),a.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:a.cropObj.destPoints.width,height:a.cropObj.destPoints.height}}),e.isBlazor()||o.isCropToolbar?o.isCropToolbar||this.parent.updateToolbar(this.parent.element,"imageLoaded"):a.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}})}},t.prototype.calcRatio=function(t){var e,i,o=this.parent;return 0===o.transform.degree||o.transform.degree%180==0?(e=o.baseImg.width/o.img.destWidth,i=o.baseImg.height/o.img.destHeight):(e=o.baseImg.height/o.img.destWidth,i=o.baseImg.width/o.img.destHeight),t&&(t.width=e,t.height=i),{width:e,height:i}},t.prototype.isObjInImage=function(t,e){var i=this.parent,o=!1,r=t.activePoint.startX,a=t.activePoint.endX,n=t.activePoint.startY,s=t.activePoint.endY;return(r>=i.img.destLeft&&a<=i.img.destLeft+i.img.destWidth||r<=i.img.destLeft&&a>=i.img.destLeft||r<=i.img.destLeft+i.img.destWidth&&a>=i.img.destLeft+i.img.destWidth||n>=i.img.destTop&&s<=i.img.destTop+i.img.destHeight||n<=i.img.destTop&&s>=i.img.destTop||n<=i.img.destTop+i.img.destHeight&&s>=i.img.destTop+i.img.destHeight)&&(o=!0),e&&(e.isInside=o),o},t.prototype.getCurrFlipState=function(t){var e=this.parent,i={panRegion:""},o={collection:e.rotateFlipColl};e.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:e.rotateFlipColl,isRotateFlipCollection:!0,obj:o}}),e.rotateFlipColl=o.collection;for(var r=0,a=e.rotateFlipColl.length;r<a;r++)e.notify("transform",{prop:"setCurrPanRegion",onPropertyChange:!1,value:{region:i.panRegion,type:e.rotateFlipColl[r],obj:i}});return t&&(t.panRegion=i.panRegion),i.panRegion},t}(),s=function(){function t(t){this.cancelObjColl=[],this.cancelPointColl=[],this.isInitialLoading=!1,this.fileName="",this.isErrorImage=!1,this.isShapeTextInserted=!1,this.isRotateZoom=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempAdjValue="",this.tempFilter="",this.tempUndoRedoStep=0,this.tempFreehandCounter=0,this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.zoomCrop={width:0,height:0},this.isImageEdited=!1,this.isFileChanged=!1,this.isNewPath=!1,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}},this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("draw",this.draw),this.parent.off("destroyed",this.destroy)},t.prototype.draw=function(t){switch(this.updatePrivateVariables(),t.prop){case"drawObject":this.drawObject(t.value.canvas,t.value.obj,t.value.isCropRatio,t.value.points,t.value.isPreventDrag,t.value.saveContext,t.value.isPreventSelection);break;case"updateActiveObject":this.updateActiveObject(t.value.actPoint,t.value.obj,t.value.isMouseMove,t.value.x,t.value.y);break;case"clearOuterCanvas":this.clearOuterCanvas(t.value.context);break;case"setDestPoints":this.setDestPoints();break;case"updateCurrTransState":this.updateCurrTransState(t.value.type,t.value.isPreventDestination,t.value.isRotatePan);break;case"currTransState":this.currTransState(t.value.type,t.value.isPreventDestination,t.value.context,t.value.isPreventCircleCrop);break;case"setTransform":this.setTransform(t.value.context,t.value.value,t.value.isReverse);break;case"render-image":this.renderImage(t.value.isMouseWheel);break;case"draw-image-to-canvas":this.drawImgToCanvas(t.value.dimension);break;case"update-canvas":this.updateCanvas();break;case"performCancel":this.performCancel(t.value.isContextualToolbar);break;case"updateFlipPan":this.updateFlipPan(t.value.tempSelectionObj);break;case"select":this.select(t.value.type,t.value.startX,t.value.startY,t.value.width,t.value.height);break;case"callUpdateCurrTransState":this.callUpdateCurrTransState();break;case"resetPanPoints":this.resetPanPoints();break;case"setClientTransDim":this.setClientTransDim(t.value.isPreventDimension);break;case"redrawImgWithObj":this.redrawImgWithObj();break;case"setCurrentObj":this.setCurrentObj(t.value.obj);break;case"performPointZoom":this.performPointZoom(t.value.x,t.value.y,t.value.type);break;case"open":this.open(t.value.data);break;case"isInitialLoading":this.isInitialLoading=t.value.isInitialLoading;break;case"isInitialLoaded":this.getInitialLoaded(t.value.object);break;case"fileSelect":this.fileSelect(t.value.inputElement,t.value.args);break;case"getFileName":t.value.obj.fileName=this.fileName,t.value.obj.fileType=this.fileType;break;case"getErrorImage":t.value.obj.isErrorImage=this.isErrorImage;break;case"getInitialZoomValue":t.value.obj.initialZoomValue=this.initZoomValue;break;case"setShapeTextInsert":this.isShapeTextInserted=t.value.bool;break;case"resetCurrentSelectionPoint":this.currSelPoint=null;break;case"setRotateZoom":this.isRotateZoom=t.value.isRotateZoom;break;case"setTempStrokeSettings":this.tempStrokeSettings=t.value.tempStrokeSettings;break;case"setTempTextSettings":this.tempTextSettings=t.value.tempTextSettings;break;case"setTempAdjustmentValue":this.tempAdjValue=t.value.tempAdjustmentValue;break;case"getTempAdjustmentValue":t.value.obj.value=this.tempAdjValue;break;case"setTempFilter":this.tempFilter=t.value.tempFilter;break;case"setTempUndoRedoStep":this.tempUndoRedoStep=t.value.tempUndoRedoStep;break;case"setTempFreehandCounter":this.tempFreehandCounter=t.value.tempFreehandCounter;break;case"setTempCurrentFreehandDrawIndex":this.tempCurrFhdIndex=t.value.tempCurrentFreehandDrawIndex;break;case"setTempZoomFactor":this.tempZoomFactor=t.value.tempZoomFactor;break;case"setCancelAction":this.isCancelAction=t.value.bool;break;case"getRotatedFlipCropSelection":t.value.bool.isSelected=this.rotatedFlipCropSel;break;case"getPrevActObj":t.value.obj.prevActObj=this.prevActObj;break;case"setPrevActObj":this.prevActObj=t.value.prevActObj;break;case"setZoomCropWidth":this.zoomCrop.width=t.value.width,this.zoomCrop.height=t.value.height;break;case"setImageEdited":this.isImageEdited=!0;break;case"reset":this.reset();break;case"dlgBtnClick":this.dlgBtnClick();break;case"dlgCloseBtnClick":this.dlgCloseBtnClick();break;case"setNewPath":this.isNewPath=t.value.bool;break;case"getNewPath":t.value.obj.isNewPath=this.isNewPath;break;case"getArrowDimension":t.value.obj.arrowDimension=this.arrowDimension;break;case"setArrowDimension":this.arrowDimension=t.value.arrowDimension;break;case"moveToSelectionRange":this.moveToSelectionRange(t.value.type,t.value.activeObj)}},t.prototype.getModuleName=function(){return"draw"},t.prototype.updatePrivateVariables=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d")),e.isNullOrUndefined(this.tempZoomFactor)&&(this.tempZoomFactor=t.transform.zoomFactor)},t.prototype.reset=function(){this.isInitialLoading=this.isErrorImage=this.isNewPath=!1,this.cancelObjColl=this.cancelPointColl=[],this.isShapeTextInserted=!1,this.initZoomValue=null,this.tempFilter="",this.currSelPoint=null,this.isRotateZoom=!1,this.tempAdjValue="",this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempUndoRedoStep=this.tempFreehandCounter=this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.prevActObj=null,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}}},t.prototype.drawObject=function(t,i,o,r,a,n,s){var l=this.parent,p=l.activeObj.activePoint;this.upperContext.clearRect(0,0,l.upperCanvas.width,l.upperCanvas.height);var h;if("original"===t.toLowerCase()?h=this.lowerContext:"duplicate"===t.toLowerCase()?h=this.upperContext:n&&(h=n),!a&&l.activeObj.shape&&this.setDragLimit(),l.currObjType.shape&&"crop"===l.currObjType.shape.split("-")[0].toLowerCase()&&o&&this.drawCropRatio(),r&&(p.startX=r.startX,p.startY=r.startY,p.endX=r.endX,p.endY=r.endY,p.width=r.width,p.height=r.height),e.isNullOrUndefined(l.activeObj.strokeSettings)){var c={strokeSettings:{}};l.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:c}}),l.activeObj.strokeSettings=c.strokeSettings}if(e.isNullOrUndefined(l.activeObj.strokeSettings.strokeWidth)&&(l.activeObj.strokeSettings.strokeWidth=2),i&&(l.activeObj=e.extend({},i,{},!0)),this.updateActiveObject(),l.currObjType.isText){var d={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:d}}),l.activeObj.keyHistory=d.keyHistory}if("original"!==t.toLowerCase()){var v=!1;l.activeObj.shape&&"crop"===l.activeObj.shape.split("-")[0]&&(v=!0),v&&(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,l.lowerCanvas.width,l.lowerCanvas.height),this.upperContext.clearRect(p.startX,p.startY,p.width,p.height)),!e.isNullOrUndefined(s)||h!==this.lowerContext&&h!==this.upperContext||(this.rotateContext("initial",h),this.drawOuterSelection(h),this.rotateContext("reverse",h))}l.currObjType.isActiveObj=!0;var u={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:u}}),i?this.drawShapeObj(t,i.shape,n,s):""!==u.keyHistory&&l.currObjType.isText?this.drawShapeObj(t,"text",n,s):l.activeObj.shape?this.drawShapeObj(t,l.activeObj.shape,n,s):this.drawShapeObj(t,void 0,n,s)},t.prototype.rotateContext=function(t,i){var o=this.parent,r=e.extend({},o.activeObj.activePoint,{},!0);if("line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape){var a="initial"===t?o.activeObj.rotatedAngle:-o.activeObj.rotatedAngle;i.translate(r.startX+r.width/2,r.startY+r.height/2),i.rotate(a),i.translate(-(r.startX+r.width/2),-(r.startY+r.height/2))}},t.prototype.setDragLimit=function(){var t=this.parent,e=t.activeObj.activePoint;e&&0===t.activeObj.rotatedAngle&&(e.startX<t.img.destLeft?(e.startX=t.img.destLeft,e.endX=e.startX+e.width):e.endX>t.img.destLeft+t.img.destWidth&&(e.endX=t.img.destLeft+t.img.destWidth,e.startX=e.endX-e.width),e.startY<t.img.destTop?e.startY=t.img.destTop:e.endY>t.img.destTop+t.img.destHeight&&(e.endY=t.img.destTop+t.img.destHeight,e.startY=e.endY-e.height),t.activeObj=this.updateWidthHeight(t.activeObj))},t.prototype.drawCropRatio=function(){var t,i,o,r,a=this.parent,n=a.activeObj.activePoint;if(a.transform.zoomFactor>0&&this.currSelPoint){var s=e.extend({},a.activeObj,{},!0);this.drawCustomSelection("crop-custom",null,null,null,null),a.transform.degree%90==0&&a.transform.degree%180!=0?r=o=a.activeObj.activePoint.width<a.activeObj.activePoint.height?a.activeObj.activePoint.width:a.activeObj.activePoint.height:(o=a.img.destLeft+a.img.destLeft+a.img.destWidth<=a.lowerCanvas.clientWidth?n.width:a.lowerCanvas.clientWidth-a.img.destLeft,r=a.img.destTop+a.img.destTop+a.img.destHeight<=a.lowerCanvas.clientHeight?n.height:a.lowerCanvas.clientHeight-a.img.destTop),a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),a.activeObj=s,a.currObjType.shape=s.shape,this.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.currObjType.isCustomCrop=!1}else o=a.img.destWidth,r=a.img.destHeight,a.img.destLeft<0&&(o+=a.img.destLeft),a.img.destTop<0&&(r+=a.img.destTop),"crop-square"!==a.currObjType.shape.toLowerCase()&&"crop-circle"!==a.currObjType.shape.toLowerCase()&&(a.img.destLeft+a.img.destWidth>a.lowerCanvas.width&&(o-=a.img.destLeft+a.img.destWidth-a.lowerCanvas.width),a.img.destTop+a.img.destHeight>a.lowerCanvas.height&&(r-=a.img.destTop+a.img.destHeight-a.lowerCanvas.height));switch(a.currObjType.shape.toLowerCase()){case"crop-square":case"crop-circle":a.notify("selection",{prop:"setDragDirection",onPropertyChange:!1,value:{width:o,height:r}}),n=a.activeObj.activePoint,a.lowerCanvas.width<n.endX-n.startX&&(n.startX=7.5,n.endX=a.lowerCanvas.width-7.5),a.lowerCanvas.height<n.endY-n.startY&&(n.startY=7.5,n.endY=a.lowerCanvas.height-7.5),o===a.img.destWidth&&r===a.img.destHeight&&(n.startX+=a.img.destLeft,n.startY+=a.img.destTop,n.endX+=a.img.destLeft,n.endY+=a.img.destTop),a.lowerCanvas.width>a.lowerCanvas.height?(n.height=n.endY-n.startY,n.width=n.height,n.endX=n.startX+n.width):(n.width=n.endX-n.startX,n.height=n.width,n.endY=n.startY+n.height);break;case"crop-3:2":t=3,i=2;break;case"crop-4:3":t=4,i=3;break;case"crop-5:4":t=5,i=4;break;case"crop-7:5":t=7,i=5;break;case"crop-16:9":t=16,i=9}if(void 0!==t&&void 0!==i&&(a.notify("selection",{prop:"calcShapeRatio",onPropertyChange:!1,value:{x:t,y:i,imgWidth:o,imgHeight:r}}),o===a.img.destWidth&&r===a.img.destHeight&&this.updatePoints(),n=a.activeObj.activePoint),n.startX<a.img.destLeft){l=a.img.destLeft-n.startX+7.5;n.startX+=l,n.endX+=l}if(n.startY<a.img.destTop){var l=a.img.destTop-n.startY+7.5;n.startY+=l,n.endY+=l}a.activeObj=this.updateWidthHeight(a.activeObj),this.adjToCenter()},t.prototype.adjToCenter=function(){var t=this.parent,e=t.lowerCanvas.width/2-(t.activeObj.activePoint.endX-t.activeObj.activePoint.width/2),i=t.lowerCanvas.height/2-(t.activeObj.activePoint.endY-t.activeObj.activePoint.height/2);if(t.activeObj.activePoint.startX+=e,t.activeObj.activePoint.endX+=e,t.activeObj.activePoint.startY+=i,t.activeObj.activePoint.endY+=i,t.activeObj.activePoint.startX<(t.img.destLeft>=7.5?t.img.destLeft:7.5)){o=(t.img.destLeft>=7.5?t.img.destLeft:0)-t.activeObj.activePoint.startX+7.5;t.activeObj.activePoint.startX+=o,t.activeObj.activePoint.endX+=o}else if(t.activeObj.activePoint.endX>t.img.destLeft+t.img.destWidth){o=t.activeObj.activePoint.endX-(t.img.destLeft+t.img.destWidth)+7.5;t.activeObj.activePoint.startX-=o,t.activeObj.activePoint.endX-=o}if(t.activeObj.activePoint.startY<(t.img.destTop>7.5?t.img.destTop:7.5)){o=(t.img.destTop>7.5?t.img.destTop:0)-t.activeObj.activePoint.startY+7.5;t.activeObj.activePoint.startY+=o,t.activeObj.activePoint.endY+=o}else if(t.activeObj.activePoint.endY>t.img.destTop+t.img.destHeight){var o=t.activeObj.activePoint.endY-(t.img.destTop+t.img.destHeight)+7.5;t.activeObj.activePoint.startY-=o,t.activeObj.activePoint.endY-=o}},t.prototype.updateActiveObject=function(t,i,o,r,a){t=t||e.extend({},this.parent.activeObj.activePoint,{},!0),i=i||e.extend({},this.parent.activeObj,{},!0),t.width=t.endX-t.startX,t.height=t.endY-t.startY,r=r||0,a=a||0;var n=t.width/2,s=t.height/2;i.horTopLine={startX:t.startX+r,startY:t.startY-a,endX:t.endX+r,endY:t.endY+a},i.horBottomLine={startX:t.startX-r,startY:t.endY-a,endX:t.endX-r,endY:t.endY+a},i.verLeftLine={startX:t.startX+r,startY:t.startY-a,endX:t.startX-a,endY:t.endY-a},i.verRightLine={startX:t.endX+r,startY:t.startY+a,endX:t.endX-r,endY:t.endY+a},i.topLeftCircle={startX:t.startX,startY:t.startY,radius:i.horTopLine.endX?7.5:0},i.topCenterCircle={startX:t.startX+n,startY:t.startY,radius:i.horTopLine.endX?7.5:0},i.topRightCircle={startX:t.endX,startY:t.startY,radius:i.horTopLine.endX?7.5:0},i.centerLeftCircle={startX:t.startX,startY:t.startY+s,radius:i.horTopLine.endX?7.5:0},i.centerRightCircle={startX:t.endX,startY:t.startY+s,radius:i.horTopLine.endX?7.5:0},i.bottomLeftCircle={startX:t.startX,startY:t.endY,radius:i.horTopLine.endX?7.5:0},i.bottomCenterCircle={startX:t.startX+n,startY:t.endY,radius:i.horTopLine.endX?7.5:0},i.bottomRightCircle={startX:t.endX,startY:t.endY,radius:i.horTopLine.endX?7.5:0},0===i.rotatedAngle&&(i.rotationCirclePoint={x:i.bottomCenterCircle.startX,y:i.bottomCenterCircle.startY+25},i.rotationCirclePoint.ratioX=(i.rotationCirclePoint.x-this.parent.img.destLeft)/this.parent.img.destWidth,i.rotationCirclePoint.ratioY=(i.rotationCirclePoint.y-this.parent.img.destTop)/this.parent.img.destHeight),i.activePoint=t,e.isNullOrUndefined(o)&&(this.parent.activeObj=e.extend({},i,{},!0))},t.prototype.drawOuterSelection=function(t,i){var o,r=this.parent,a=r.activeObj.activePoint;t.lineWidth=.5,void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-"));var n=e.extend({},r.activeObj,{},!0);void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-")),(void 0===o||"crop"!==o[0])&&void 0!==r.activeObj.shape||i||(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.upperContext.clearRect(a.startX,a.startY,a.width,a.height)),t.strokeStyle=r.themeColl[r.theme].primaryColor,t.fillStyle=r.themeColl[r.theme].secondaryColor;var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),"arrow"===r.activeObj.shape||"line"===r.activeObj.shape)t.beginPath(),t.moveTo(a.startX,a.startY),t.lineTo(a.endX,a.endY),t.stroke();else if("path"===r.activeObj.shape){t.beginPath();var l=e.extend({},r.activeObj,{},!0);if(t.moveTo(l.pointColl[0].x,l.pointColl[0].y),l.pointColl.length>1)for(var p=1,h=l.pointColl.length;p<h;p++)a.endX=l.pointColl[p].x,a.endY=l.pointColl[p].y,t.lineTo(a.endX,a.endY);var c={shape:null};r.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:c}}),"path"===c.shape&&(r.activeObj=l),t.lineTo(a.endX,a.endY),t.stroke()}else if(t.beginPath(),t.rect(n.activePoint.startX,n.activePoint.startY,n.activePoint.width,n.activePoint.height),t.stroke(),t.closePath(),r.selectionSettings.showCircle){var d=t.strokeStyle,v=t.fillStyle;t.strokeStyle=r.selectionSettings.strokeColor,t.fillStyle=r.selectionSettings.fillColor,t.lineWidth*=2,t.beginPath(),t.moveTo(n.topLeftCircle.startX,n.topLeftCircle.startY),t.arc(n.topLeftCircle.startX,n.topLeftCircle.startY,n.topLeftCircle.radius,0,2*Math.PI),t.moveTo(n.topRightCircle.startX,n.topRightCircle.startY),t.arc(n.topRightCircle.startX,n.topRightCircle.startY,n.topRightCircle.radius,0,2*Math.PI),t.moveTo(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY),t.arc(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY,n.bottomLeftCircle.radius,0,2*Math.PI),t.moveTo(n.bottomRightCircle.startX,n.bottomRightCircle.startY),t.arc(n.bottomRightCircle.startX,n.bottomRightCircle.startY,n.bottomRightCircle.radius,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),t.lineWidth/=2,t.strokeStyle=d,t.fillStyle=v}if(r.selectionSettings.showCircle&&(void 0===o||"crop"!==o[0])){var d=t.strokeStyle,v=t.fillStyle;t.strokeStyle=r.selectionSettings.strokeColor,t.fillStyle=r.selectionSettings.fillColor,"text"===r.activeObj.shape||this.drawCenterCircles(t),t.strokeStyle=d,t.fillStyle=v}n.rotationCircleLine=r.activeObj.rotationCircleLine,r.activeObj=e.extend({},n,{},!0)},t.prototype.drawArrowHead=function(t,e){switch(e?this.parent.activeObj.start:this.parent.activeObj.end){case"arrowSolid":e?this.arrowSolid(t,!0):this.arrowSolid(t,!1);break;case"arrow":e?this.arrow(t,!0):this.arrow(t,!1);break;case"circleSolid":e?this.arrowCircleSolid(t,!0):this.arrowCircleSolid(t,!1);break;case"circle":e?this.arrowCircle(t,!0):this.arrowCircle(t,!1);break;case"bar":e?this.arrowBar(t,!0):this.arrowBar(t,!1);break;case"square":case"squareSolid":e?this.arrowSquareStart(t):this.arrowSquareEnd(t)}},t.prototype.drawShapeObj=function(t,i,o,r){var a=this.parent,n=a.activeObj.activePoint,s=void 0!==i?i:a.currObjType.shape;a.currObjType.shape=s;var l;"original"===t.toLowerCase()?l=this.lowerContext:"duplicate"===t.toLowerCase()?l=this.upperContext:o&&(l=o),"rectangle"!==a.currObjType.shape.toLowerCase()&&"ellipse"!==a.currObjType.shape.toLowerCase()&&"line"!==a.currObjType.shape.toLowerCase()&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape||(a.activeObj.shape=a.currObjType.shape),l.strokeStyle=a.activeObj.strokeSettings.strokeColor,l.fillStyle="text"===i||"freehanddraw"===i?a.activeObj.strokeSettings.strokeColor:a.activeObj.strokeSettings.fillColor;var p=n.width/3,h=n.height/3,c=n.endX-n.startX,d=n.endY-n.startY;this.rotateContext("initial",l);var v,u,g=l.fillStyle;switch(a.currObjType.shape.toLowerCase()){case"rectangle":this.drawSquareLines(l),e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"ellipse":c=Math.abs(c),d=Math.abs(d),l.beginPath(),l.ellipse(n.startX+c/2,n.startY+d/2,c/2,d/2,0,0,2*Math.PI,!1),""!==a.activeObj.strokeSettings.fillColor&&(l.fillStyle=a.activeObj.strokeSettings.fillColor,l.fill()),l.ellipse(n.startX+c/2,n.startY+d/2,Math.abs(c/2-a.activeObj.strokeSettings.strokeWidth),Math.abs(d/2-a.activeObj.strokeSettings.strokeWidth),0,0,2*Math.PI,!1),l.fillStyle=a.activeObj.strokeSettings.strokeColor,l.fill("evenodd"),l.closePath(),e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"crop-circle":l===this.lowerContext&&(l=this.upperContext),this.shapeCircle(l,c,d);break;case"line":this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"arrow":(v=0===a.activeObj.shapeDegree?a.transform.degree:a.transform.degree-a.activeObj.shapeDegree)<0&&(v=360+v),l.fillStyle=l.strokeStyle,e.isNullOrUndefined(a.activeObj.triangleDirection)&&(a.activeObj.triangleDirection="right"),e.isNullOrUndefined(a.activeObj.start)&&(a.activeObj.start="none"),e.isNullOrUndefined(a.activeObj.end)&&(a.activeObj.end="arrowSolid"),this.drawArrowHead(l,!0),this.drawArrowHead(l,!1),"none"===a.activeObj.end&&this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),l.fillStyle=g,e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"path":if((u=e.extend({},a.activeObj,{},!0)).pointColl.length>1){var b={shape:null};if(a.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:b}}),"path"===b.shape)for(var C={x:0,y:0},f=0,m=u.pointColl.length;f<m;f++)e.isNullOrUndefined(u.pointColl[f+1])?(C.x=u.activePoint.endX,C.y=u.activePoint.endY):(C.x=u.pointColl[f+1].x,C.y=u.pointColl[f+1].y),n.startX=u.pointColl[f].x,n.startY=u.pointColl[f].y,n.endX=C.x,n.endY=C.y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);else for(var f=1,m=u.pointColl.length;f<m;f++)n.startX=u.pointColl[f-1].x,n.startY=u.pointColl[f-1].y,n.endX=u.pointColl[f].x,n.endY=u.pointColl[f].y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);a.activeObj=u}else this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);l===this.upperContext&&this.drawOuterSelection(l);break;case"text":this.shapeText(l);break;case"crop-square":case"crop-3:4":case"crop-4:3":case"crop-6:9":case"crop-9:6":case"crop-9:16":case"crop-16:9":l===this.lowerContext&&(l=this.upperContext),this.drawSelection(p,h),a.currObjType.shape="";break;default:this.drawSelection(p,h)}this.rotateContext("reverse",l)},t.prototype.updatePoints=function(){var t=this.parent;t.activeObj.activePoint.startX+=t.img.destLeft,t.activeObj.activePoint.startY+=t.img.destTop,t.activeObj.activePoint.endX+=t.img.destLeft,t.activeObj.activePoint.endY+=t.img.destTop,t.activeObj=this.updateWidthHeight(t.activeObj)},t.prototype.updateWidthHeight=function(t){return t.activePoint.width=t.activePoint.endX-t.activePoint.startX,t.activePoint.height=t.activePoint.endY-t.activePoint.startY,t},t.prototype.drawCenterCircles=function(t){var i=this.parent,o=i.activeObj.activePoint;if(t.lineWidth*=2,t.beginPath(),"arrow"===i.activeObj.shape||"line"===i.activeObj.shape)t.moveTo(o.startX,o.startY),t.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),t.moveTo(o.endX,o.endY),t.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);else if("path"===i.activeObj.shape){var r=e.extend({},i.activeObj,{},!0);if(r.pointColl.length>1)for(var a=1,n=r.pointColl.length;a<n;a++)o.startX=r.pointColl[a-1].x,o.startY=r.pointColl[a-1].y,o.endX=r.pointColl[a].x,o.endY=r.pointColl[a].y,t.moveTo(o.startX,o.startY),t.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),t.moveTo(o.endX,o.endY),t.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"===s.shape&&(i.activeObj=r),t.moveTo(o.startX,o.startY),t.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),t.moveTo(o.endX,o.endY),t.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI)}else this.drawRotationArcLine(t),t.lineTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y);t.stroke(),t.fill(),t.closePath(),"arrow"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"path"!==i.activeObj.shape&&(t.beginPath(),t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y),t.arc(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI),t.stroke(),t.fill(),t.closePath()),t.lineWidth/=2},t.prototype.drawRotationArcLine=function(t){var i=this.parent;e.isNullOrUndefined(i.activeObj.rotationCircleLine)&&(i.activeObj.rotationCircleLine=22.5);var o,r=!1,a=!1;(o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o);for(var n=0,s=i.activeObj.flipObjColl.length;n<s;n++)"horizontal"===i.activeObj.flipObjColl[n].toLowerCase()?r=!0:"vertical"===i.activeObj.flipObjColl[n].toLowerCase()&&(a=!0);switch(o){case 0:case 360:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine));break;case 90:case-270:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y));break;case 180:case-180:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine));break;case 270:case-90:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y))}},t.prototype.drawSquareLines=function(t){var e,i=this.parent,o=i.activeObj.activePoint;void 0!==i.activeObj.shape&&(e=i.activeObj.shape.split("-")),"crop"===e[0]?t.strokeStyle="#fff":t.strokeStyle=i.activeObj.strokeSettings.strokeColor,t.beginPath(),t.rect(o.startX,o.startY,o.width,o.height),""!==i.activeObj.strokeSettings.fillColor&&(t.fillStyle=i.activeObj.strokeSettings.fillColor,t.fill()),t.rect(o.startX+i.activeObj.strokeSettings.strokeWidth,o.startY+i.activeObj.strokeSettings.strokeWidth,o.width-2*i.activeObj.strokeSettings.strokeWidth,o.height-2*i.activeObj.strokeSettings.strokeWidth),t.fillStyle=i.activeObj.strokeSettings.strokeColor,t.fill("evenodd"),t.closePath()},t.prototype.drawSelection=function(t,e){var i=this.parent,o=i.activeObj.activePoint;this.upperContext.strokeStyle=i.themeColl[i.theme].primaryColor,this.upperContext.beginPath(),i.activeObj.horTopInnerLine={startX:o.startX,startY:o.startY+e,endX:o.endX,endY:o.endY+e},i.activeObj.horBottomInnerLine={startX:o.startX,startY:o.startY+2*e,endX:o.endX,endY:o.endY+2*e},i.activeObj.verLeftInnerLine={startX:o.startX+t,startY:o.startY,endX:o.startX+t,endY:o.endY},i.activeObj.verRightInnerLine={startX:o.startX+2*t,startY:o.startY,endX:o.startX+2*t,endY:o.endY},this.upperContext.moveTo(i.activeObj.horTopInnerLine.startX,i.activeObj.horTopInnerLine.startY),this.upperContext.lineTo(i.activeObj.horTopInnerLine.endX,i.activeObj.horTopInnerLine.startY),this.upperContext.moveTo(i.activeObj.horBottomInnerLine.startX,i.activeObj.horBottomInnerLine.startY),this.upperContext.lineTo(i.activeObj.horBottomInnerLine.endX,i.activeObj.horBottomInnerLine.startY),this.upperContext.moveTo(i.activeObj.verLeftInnerLine.startX,i.activeObj.verLeftInnerLine.startY),this.upperContext.lineTo(i.activeObj.verLeftInnerLine.endX,i.activeObj.verLeftInnerLine.endY),this.upperContext.moveTo(i.activeObj.verRightInnerLine.startX,i.activeObj.verRightInnerLine.startY),this.upperContext.lineTo(i.activeObj.verRightInnerLine.endX,i.activeObj.verRightInnerLine.endY),this.upperContext.stroke(),this.upperContext.closePath()},t.prototype.shapeCircle=function(t,e,i){var o=this.parent,r=o.activeObj.activePoint;t.strokeStyle=o.themeColl[o.theme].primaryColor,t.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),t.fillStyle="rgb(0, 0, 0, 0.25)",t.fillRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var a=t.lineWidth;t.lineWidth=2,t.beginPath(),t.ellipse(o.activeObj.horTopLine.startX+e/2,o.activeObj.horTopLine.startY+i/2,e/2,i/2,0,0,2*Math.PI,!1),t.stroke(),t.closePath(),t.save(),t.beginPath(),t.arc((r.endX-r.startX)/2+r.startX,(r.endY-r.startY)/2+r.startY,r.width/2,0,2*Math.PI),t.closePath(),t.clip(),t.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),t.restore(),t.lineWidth=a,this.drawOuterSelection(t,!0),o.currObjType.shape=""},t.prototype.shapeLine=function(t,e,i,o,r){var a=t.lineWidth;t.lineWidth=this.parent.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.moveTo(e,i),t.lineTo(o,r),t.stroke(),t.lineWidth=a},t.prototype.arrow=function(t,e){var i=this.parent,o=i.activeObj.activePoint;t.lineWidth=i.activeObj.strokeSettings.strokeWidth;var r=this.arrowDimension.arrow.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.arrow.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,t.fillStyle=i.activeObj.strokeSettings.strokeColor;var n=Math.atan2(this.dy,this.dx);(e&&("left"===i.activeObj.triangleDirection||"right"===i.activeObj.triangleDirection)&&"arrow"===i.activeObj.start&&"none"===i.activeObj.end||"arrow"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&("arrow"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY),e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection?(t.translate(o.endX,o.endY),t.rotate(n),this.shapeLine(t,0,0,-r,a/2),this.shapeLine(t,0,0,-r,-a/2),t.rotate(-n),t.translate(-o.endX,-o.endY)):(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection)&&(t.translate(o.startX,o.startY),t.rotate(n),this.shapeLine(t,0,0,r,a/2),this.shapeLine(t,0,0,r,-a/2),t.rotate(-n),t.translate(-o.startX,-o.startY))},t.prototype.arrowSolid=function(t,e){var i=this.parent,o=i.activeObj.activePoint,r=this.arrowDimension.arrowSolid.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.arrowSolid.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var n=Math.atan2(this.dy,this.dx);(e&&"arrowSolid"===i.activeObj.start&&"none"===i.activeObj.end||"arrowSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&("arrowSolid"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY),e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection?(t.translate(o.endX,o.endY),t.rotate(n),t.beginPath(),t.moveTo(i.activeObj.strokeSettings.strokeWidth,0),t.lineTo(a/2-r,a/2),t.lineTo(a/2-r,-a/2),t.closePath(),t.fill(),t.rotate(-n),t.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=n):(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection)&&(t.translate(o.startX,o.startY),t.rotate(n),t.beginPath(),t.moveTo(0-i.activeObj.strokeSettings.strokeWidth,0),t.lineTo(r-a/2,a/2),t.lineTo(r-a/2,-a/2),t.closePath(),t.fill(),t.rotate(-n),t.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=n)},t.prototype.arrowSquareStart=function(t){var e=this.parent,i=e.activeObj.activePoint;("square"===e.activeObj.start&&"none"===e.activeObj.end||"square"===e.activeObj.start&&"circle"!==e.activeObj.end&&"square"!==e.activeObj.start||"squareSolid"===e.activeObj.start&&"circleSolid"===e.activeObj.end)&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY),t.lineWidth=e.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=e.activeObj.strokeSettings.strokeColor;var o=this.arrowDimension.square.width+e.activeObj.strokeSettings.strokeWidth,r=this.arrowDimension.square.height+e.activeObj.strokeSettings.strokeWidth;this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var a=Math.atan2(this.dy,this.dx);"left"===e.activeObj.triangleDirection?(t.translate(i.endX,i.endY),t.rotate(a),"squareSolid"===e.activeObj.start&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.endX,-i.endY),this.squareStartIntersectX1=i.endX-r/2*Math.cos(a),this.squareStartIntersectY1=i.endY-r/2*Math.sin(a),"square"===e.activeObj.start&&"square"!==e.activeObj.end&&"circle"!==e.activeObj.end&&"square"!==e.activeObj.end&&this.shapeLine(t,i.startX,i.startY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===e.activeObj.start&&"circle"===e.activeObj.end&&this.shapeLine(t,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1),"squareSolid"===e.activeObj.start&&"squareSolid"===e.activeObj.end&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY)):"right"===e.activeObj.triangleDirection&&(t.lineWidth=e.activeObj.strokeSettings.strokeWidth,t.fillStyle=e.activeObj.strokeSettings.strokeColor,"squareSolid"===e.activeObj.start&&"squareSolid"===e.activeObj.end&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY),t.translate(i.startX,i.startY),t.rotate(a),"squareSolid"===e.activeObj.start&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.startX,-i.startY),e.activeObj.rotatedAngle=a,this.squareStartIntersectX1=i.startX+r/2*Math.cos(a),this.squareStartIntersectY1=i.startY+r/2*Math.sin(a),"square"===e.activeObj.start&&"square"!==e.activeObj.end&&"circle"!==e.activeObj.end&&"square"!==e.activeObj.end&&this.shapeLine(t,i.endX,i.endY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===e.activeObj.start&&"circle"===e.activeObj.end&&this.shapeLine(t,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},t.prototype.arrowSquareEnd=function(t){var e=this.parent,i=e.activeObj.activePoint,o=this.arrowDimension.square.width+e.activeObj.strokeSettings.strokeWidth,r=this.arrowDimension.square.height+e.activeObj.strokeSettings.strokeWidth;this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var a=Math.atan2(this.dy,this.dx);t.lineWidth=e.activeObj.strokeSettings.strokeWidth,"right"===e.activeObj.triangleDirection?(t.fillStyle=e.activeObj.strokeSettings.strokeColor,"squareSolid"===e.activeObj.end&&"none"===e.activeObj.start&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY),t.translate(i.endX,i.endY),t.rotate(a),"squareSolid"===e.activeObj.end&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.endX,-i.endY),e.activeObj.rotatedAngle=a,this.squareEndIntersectX1=i.endX-r/2*Math.cos(a),this.squareEndIntersectY1=i.endY-r/2*Math.sin(a),"square"===e.activeObj.end&&"square"!==e.activeObj.start&&"circle"!==e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,i.startX,i.startY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===e.activeObj.start&&"square"===e.activeObj.end&&this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1)):"left"===e.activeObj.triangleDirection&&(t.translate(i.startX,i.startY),t.rotate(a),"squareSolid"===e.activeObj.end&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.startX,-i.startY),e.activeObj.rotatedAngle=a,this.squareEndIntersectX1=i.startX+r/2*Math.cos(a),this.squareEndIntersectY1=i.startY+r/2*Math.sin(a),"square"===e.activeObj.end&&"square"!==e.activeObj.start&&"circle"!==e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,i.endX,i.endY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===e.activeObj.start&&"square"===e.activeObj.end&&this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},t.prototype.arrowCircle=function(t,e){var i=this.parent,o=i.activeObj.activePoint;if(e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth;s=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;t.beginPath(),t.arc(o.endX,o.endY,s,0,2*Math.PI),t.stroke(),t.closePath(),this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;l=this.dx*this.dx+this.dy*this.dy;if((c=(p=2*(this.dx*(o.startX-o.endX)+this.dy*(o.startY-o.endY)))*p-4*l*(h=(o.startX-o.endX)*(o.startX-o.endX)+(o.startY-o.endY)*(o.startY-o.endY)-s*s))>=0){t.fillStyle=i.activeObj.strokeSettings.strokeColor;var r=(-p-Math.sqrt(c))/(2*l),a=o.startX+this.dx*r,n=o.startY+this.dy*r;e?(this.startCircleIntersectX1=a,this.startCircleIntersectY1=n,t.beginPath(),t.fill(),t.beginPath(),"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(t,this.startCircleIntersectX1,this.startCircleIntersectY1,this.endCircleIntersectX1,this.endCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(t,o.startX,o.startY,this.startCircleIntersectX1,this.startCircleIntersectY1),t.stroke(),t.closePath()):(this.endCircleIntersectX1=a,this.endCircleIntersectY1=n,"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(t,o.startX,o.startY,this.endCircleIntersectX1,this.endCircleIntersectY1))}d=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=d}else if(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth;var s=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;t.beginPath(),t.arc(o.startX,o.startY,s,0,2*Math.PI),t.stroke(),t.closePath(),this.dx=o.startX-o.endX,this.dy=o.startY-o.endY;var l=this.dx*this.dx+this.dy*this.dy,p=2*(this.dx*(o.endX-o.startX)+this.dy*(o.endY-o.startY)),h=(o.endX-o.startX)*(o.endX-o.startX)+(o.endY-o.startY)*(o.endY-o.startY)-s*s,c=p*p-4*l*h;if(c>=0){t.fillStyle=i.activeObj.strokeSettings.strokeColor;var r=(-p-Math.sqrt(c))/(2*l),a=o.endX+this.dx*r,n=o.endY+this.dy*r;e?(this.startCircleIntersectX1=a,this.startCircleIntersectY1=n,"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(t,this.endCircleIntersectX1,this.endCircleIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(t,o.endX,o.endY,this.startCircleIntersectX1,this.startCircleIntersectY1)):(this.endCircleIntersectX1=a,this.endCircleIntersectY1=n,t.beginPath(),t.fill(),t.beginPath(),"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(t,o.endX,o.endY,this.endCircleIntersectX1,this.endCircleIntersectY1))}var d=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=d}},t.prototype.arrowCircleSolid=function(t,e){var i=this.parent,o=i.activeObj.activePoint;if(e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);r=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,t.save(),t.beginPath(),t.arc(o.endX,o.endY,r,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}else if(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,t.save(),t.beginPath(),t.arc(o.startX,o.startY,r,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}},t.prototype.arrowBar=function(t,e){var i=this.parent,o=i.activeObj.activePoint;if(e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&("bar"===i.activeObj.end&&"none"===i.activeObj.start||"bar"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.bar.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.bar.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;n=Math.atan2(this.dy,this.dx);t.translate(o.endX,o.endY),t.rotate(n),t.fillRect(a/4-r,-a/2,r,a),t.rotate(-n),t.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=n}else if(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&"bar"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.bar.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.bar.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var n=Math.atan2(this.dy,this.dx);t.translate(o.startX,o.startY),t.rotate(n),t.fillRect(a/4-r,-a/2,r,a),t.rotate(-n),t.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=n}},t.prototype.shapeText=function(t){for(var e=this.parent,i=e.activeObj.activePoint,o=e.activeObj.keyHistory.split("\n"),r=((e.activeObj.textSettings.fontSize+.25*e.activeObj.textSettings.fontSize)*o.length-e.activeObj.textSettings.fontSize*o.length)/o.length,a=0;a<o.length;a++){var n=o[a],s=(a+1)*e.activeObj.textSettings.fontSize*.85+a*r;-360===e.transform.degree&&(e.transform.degree=0),0===e.transform.degree||180===e.transform.degree?e.activeObj.textSettings.fontSize>i.height&&(e.activeObj.textSettings.fontSize=i.height-.1*i.height):e.activeObj.textSettings.fontSize>i.width&&(e.activeObj.textSettings.fontSize=i.width-.1*i.width),t.strokeStyle=e.activeObj.strokeSettings.strokeColor,t.fillStyle=e.activeObj.strokeSettings.strokeColor;var l="";e.activeObj.textSettings.bold&&(l="bold "),e.activeObj.textSettings.italic&&(l="italic "),e.activeObj.textSettings.bold&&e.activeObj.textSettings.italic&&(l="italic bold "),t.font=l+e.activeObj.textSettings.fontSize+"px "+e.activeObj.textSettings.fontFamily,4===e.activeObj.flipObjColl.length&&(e.activeObj.flipObjColl=[]);for(var p=0,h=e.activeObj.flipObjColl.length;p<h;p++)"horizontal"===e.activeObj.flipObjColl[p].toLowerCase()?(t.translate(t.canvas.width,0),t.scale(-1,1),this.updateActPoint("horizontal",t)):"vertical"===e.activeObj.flipObjColl[p].toLowerCase()&&(t.translate(0,t.canvas.height),t.scale(1,-1),this.updateActPoint("vertical",t));e.activeObj.shapeDegree!==e.transform.degree?this.rotateText(t):t.fillText(n,i.startX+.1*e.activeObj.textSettings.fontSize,i.startY+s);for(var c=0,h=e.activeObj.flipObjColl.length;c<h;c++)"horizontal"===e.activeObj.flipObjColl[c].toLowerCase()?(t.translate(t.canvas.width,0),t.scale(-1,1),this.updateActPoint("horizontal",t)):"vertical"===e.activeObj.flipObjColl[c].toLowerCase()&&(t.translate(0,t.canvas.height),t.scale(1,-1),this.updateActPoint("vertical",t))}e.currObjType.isText=!1},t.prototype.updateActPoint=function(t,e){var i=this.parent,o=i.activeObj.activePoint;"horizontal"===t.toLowerCase()?o.startX<=e.canvas.width/2?(o.startX=e.canvas.width/2+(e.canvas.width/2-o.endX),o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):o.startX>=e.canvas.width/2&&(o.startX=e.canvas.width-o.endX,o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):"vertical"===t.toLowerCase()&&(o.startY<=e.canvas.height/2?(o.startY=e.canvas.height/2+(e.canvas.height/2-o.endY),o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj)):o.startY>=e.canvas.height/2&&(o.startY=e.canvas.height-o.endY,o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj)))},t.prototype.rotateText=function(t){var e,i=this.parent,o=i.activeObj.activePoint.startX,r=i.activeObj.activePoint.startY,a=i.activeObj.activePoint;if((e=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(e=360+e),e%360!=0||-360===i.transform.degree&&""!==i.transform.currFlipState)e%90==0&&e%180!=0?(t.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),t.rotate(Math.PI/180*e),t.translate(-i.lowerCanvas.height/2,-i.lowerCanvas.width/2),e%90==0&&e%270!=0?(r=i.lowerCanvas.width-a.endX+.4*i.activeObj.textSettings.fontSize,o=a.startY):e%270==0&&(o=i.lowerCanvas.height-a.endY,r=a.startX+.4*i.activeObj.textSettings.fontSize),this.textFlipDegree(t,o,r),t.translate(i.lowerCanvas.height/2,i.lowerCanvas.width/2),t.rotate(Math.PI/180*-e),t.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):(t.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),t.rotate(Math.PI/180*e),o=i.lowerCanvas.width-a.endX,r=i.lowerCanvas.height-a.endY+.4*i.activeObj.textSettings.fontSize,t.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2),this.textFlipDegree(t,o,r),t.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),t.rotate(Math.PI/180*-e),t.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2));else{o=a.startX+.15*i.activeObj.textSettings.fontSize,r=a.startY+(a.endY-a.startY);for(var n=i.activeObj.keyHistory.split("\n"),s=0;s<n.length;s++)r=a.startY+(s*i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize),t.fillText(n[s],o,r)}360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},t.prototype.textFlipDegree=function(t,e,i){for(var o=this.parent,r=o.activeObj.keyHistory.split("\n"),a=(o.activeObj.textSettings.fontSize*r.length-o.activeObj.textSettings.fontSize*r.length)/r.length,n=.85*o.activeObj.textSettings.fontSize+a,s=0;s<r.length;s++){var l=r[s];s>0&&(1===s&&(n-=.85*o.activeObj.textSettings.fontSize),n+=o.activeObj.textSettings.fontSize+.15*o.activeObj.textSettings.fontSize),t.fillText(l,e+.15*o.activeObj.textSettings.fontSize,i+n+(s>0?.25*o.activeObj.textSettings.fontSize:.35*-o.activeObj.textSettings.fontSize))}},t.prototype.clearOuterCanvas=function(t){var e=this.parent,i=e.img.destLeft,o=e.img.destTop;if(e.img.destWidth<e.lowerCanvas.width){var r=e.img.destLeft>0?e.img.destLeft:0;t.clearRect(0,0,r,e.lowerCanvas.height),t.clearRect(e.img.destLeft+e.img.destWidth,0,r,e.lowerCanvas.height)}if(e.img.destHeight<e.lowerCanvas.height){var a=e.img.destTop>0?e.img.destTop:0;t.clearRect(0,0,e.lowerCanvas.width,a),t.clearRect(0,e.img.destTop+e.img.destHeight,e.lowerCanvas.width,a)}""!==e.transform.currFlipState&&(e.img.destLeft=i,e.img.destTop=o)},t.prototype.setDestPoints=function(){var t,e=this.parent;if(e.transform.degree%90==0&&e.transform.degree%180!=0){i={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.img.srcHeight,height:e.img.srcWidth,obj:i}}),t=i,this.isRotateZoom&&(t.width+=t.width*e.transform.zoomFactor,t.height+=t.height*e.transform.zoomFactor,e.img.destWidth=t.height,e.img.destHeight=t.width),e.img.destLeft=(e.lowerCanvas.clientWidth-t.height)/2,e.img.destTop=(e.lowerCanvas.clientHeight-t.width)/2,e.img.destWidth=t.height,e.img.destHeight=t.width}else{var i={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.img.srcWidth,height:e.img.srcHeight,obj:i}}),t=i,this.isRotateZoom&&(t.width+=t.width*e.transform.zoomFactor,t.height+=t.height*e.transform.zoomFactor,e.img.destWidth=t.width,e.img.destHeight=t.height),e.img.destLeft=(e.lowerCanvas.clientWidth-t.width)/2,e.img.destTop=(e.lowerCanvas.clientHeight-t.height)/2,e.img.destWidth=t.width,e.img.destHeight=t.height}},t.prototype.updateCurrTransState=function(t,i,o){var r=this.parent,a=r.img.destLeft,n=r.img.destTop;"initial"===t&&(this.lowerContext.setTransform(1,0,0,1,0,0),e.isNullOrUndefined(i)&&this.setDestPoints()),this.currTransState(t,null,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&(r.img.destLeft=a,r.img.destTop=n),(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&(o&&(r.img.destLeft+=r.panPoint.totalPannedClientPoint.x,r.img.destTop+=r.panPoint.totalPannedClientPoint.y),r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o&&(r.img.destLeft-=r.panPoint.totalPannedClientPoint.x,r.img.destTop-=r.panPoint.totalPannedClientPoint.y))},t.prototype.currTransState=function(t,i,o,r){var a=this.parent;o=o||this.lowerContext,"initial"===t?this.setTransformColl(o,t):"reverse"===t&&(this.setTransformColl(o,t),this.setClientTransDim(i),(a.isCircleCrop||a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape&&e.isNullOrUndefined(r))&&(r&&(a.img.destLeft+=a.panPoint.totalPannedClientPoint.x,a.img.destTop+=a.panPoint.totalPannedClientPoint.y),a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r&&(a.img.destLeft-=a.panPoint.totalPannedClientPoint.x,a.img.destTop-=a.panPoint.totalPannedClientPoint.y)))},t.prototype.setTransformColl=function(t,e){var i=this.parent;if("initial"===e)for(var o=0,r=i.rotateFlipColl.length;o<r;o++)this.setTransform(t,i.rotateFlipColl[o]);else if("reverse"===e)for(o=i.rotateFlipColl.length-1;o>=0;o--)this.setTransform(t,i.rotateFlipColl[o],!0)},t.prototype.setTransform=function(t,i,o){var r=this.parent;switch(o&&90===i?i=-90:o&&-90===i&&(i=90),"horizontal"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0?i="vertical":"vertical"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0&&(i="horizontal"),r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),e.isNullOrUndefined(o)&&t.clearRect(0,0,t.canvas.width,t.canvas.height),i){case 90:case-90:t.translate(t.canvas.width/2,t.canvas.height/2),t.rotate(Math.PI/180*i),t.translate(-t.canvas.width/2,-t.canvas.height/2);break;case"horizontal":t.translate(t.canvas.width,0),t.scale(-1,1);break;case"vertical":t.translate(0,t.canvas.height),t.scale(1,-1)}r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!1}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}})},t.prototype.drawImgToCanvas=function(t){var e=this.parent;this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.img.destWidth=t.width,e.img.destHeight=t.height,this.isInitialLoading&&(e.notify("filter",{prop:"initFilter",onPropertyChange:!1}),this.isInitialLoading=!1);var i=this.lowerContext.filter;e.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.lowerContext.drawImage(e.baseImg,e.img.srcLeft,e.img.srcTop,e.img.srcWidth,e.img.srcHeight,e.img.destLeft,e.img.destTop,e.img.destWidth,e.img.destHeight),(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.lowerContext.filter=i},t.prototype.renderImage=function(t){var e=this.parent,i=this.lowerContext.filter;e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),this.upperContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),t?this.setTransformColl(this.lowerContext,"initial"):(e.transform.zoomFactor>0&&(this.isRotateZoom=!0),this.updateCurrTransState("initial")),e.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),e.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.lowerContext.drawImage(e.baseImg,e.img.srcLeft,e.img.srcTop,e.img.srcWidth,e.img.srcHeight,e.img.destLeft,e.img.destTop,e.img.destWidth,e.img.destHeight),e.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),t?this.setTransformColl(this.lowerContext,"reverse"):(this.updateCurrTransState("reverse"),this.isRotateZoom=!1),this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),e.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=i,(e.isCircleCrop||e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},t.prototype.imageOnLoad=function(t){var o=this,r=this.parent,a=this;r.baseImg.src=t,r.baseImg.onload=function(){if(r.notify("filter",{prop:"update-finetunes",onPropertyChange:!1}),a.lowerContext.drawImage(r.baseImg,0,0,a.parent.lowerCanvas.width,a.parent.lowerCanvas.height),i.hideSpinner(r.element),r.element.style.opacity="1",a.updateCanvas(),r.currObjType.isUndoZoom&&(r.currObjType.isUndoZoom=!1,a.parent.lowerCanvas.style.display="block"),r.isUndoRedo=o.isErrorImage=!1,e.isBlazor())r.updateToolbar(r.element,"imageLoaded","initial"),e.Browser.isDevice&&(r.element.querySelector(".e-bottom-toolbar-area").style.display="block",r.element.querySelector(".e-canvas-wrapper").style.height=r.element.offsetHeight-2*r.toolbarHeight-3+"px");else if(e.Browser.isDevice){r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),r.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1});t={isApplyBtn:!1,isDevice:e.Browser.isDevice,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:t}),r.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1})}else{r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1});var t={isApplyBtn:!1,isDevice:!1,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:t})}},r.baseImg.onerror=function(){i.hideSpinner(r.element),a.isErrorImage=!0,a.errorLoading()}},t.prototype.errorLoading=function(){var t=this.parent,i={fileName:null,fileType:null,isValidImage:!1};e.isBlazor()&&t.events&&!0===t.events.fileOpened.hasDelegate?t.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):t.trigger("fileOpened",i)},t.prototype.updateCanvas=function(){var t=this.parent,i={fileName:this.fileName,fileType:this.fileType,isValidImage:!0};t.img.srcWidth=t.baseImg.width,t.img.srcHeight=t.baseImg.height;var o={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcWidth,height:t.img.srcHeight,obj:o}});var r=o;t.img.destLeft=(t.lowerCanvas.clientWidth-r.width)/2,t.img.destTop=(t.lowerCanvas.clientHeight-r.height)/2,this.drawImgToCanvas(r),this.zoomCrop.width=t.img.destWidth,this.zoomCrop.height=t.img.destHeight,t.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:t.img.destWidth,height:t.img.destHeight}});var a={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};t.notify("crop",{prop:"setCropDestPoints",onPropertyChange:!1,value:{point:a}});var n=this.lowerContext.filter;this.lowerContext.filter="none",t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n,t.img.destWidth>0&&t.img.destHeight>0&&(t.isImageLoaded=!0),t.isUndoRedo&&""!==t.transform.currFlipState&&t.notify("transform",{prop:"flipImage",onPropertyChange:!1,value:{direction:t.toPascalCase(t.transform.currFlipState)}}),t.disabled&&t.element.setAttribute("class","e-disabled"),t.isImageLoaded&&"0.5"!==t.element.style.opacity&&(e.isBlazor()&&t.events&&!0===t.events.fileOpened.hasDelegate?t.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):t.trigger("fileOpened",i)),(1!==t.zoomSettings.zoomFactor||t.zoomSettings.zoomPoint)&&t.zoom(t.zoomSettings.zoomFactor,t.zoomSettings.zoomPoint),e.isNullOrUndefined(this.initZoomValue)&&(this.initZoomValue=t.zoomSettings.zoomFactor),this.isImageEdited=!1},t.prototype.performCancel=function(t){var i=this.parent;t=t||!1;var o={bool:!1};if(i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:o}}),o.bool)i.notify("freehand-draw",{prop:"cancelFhd",onPropertyChange:!1}),e.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}});else if("block"===i.textArea.style.display)i.textArea.style.display="none",i.textArea.value="",i.textArea.style.transform="",this.prevActObj?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.activeObj.strokeSettings=this.tempStrokeSettings,i.activeObj.textSettings=this.tempTextSettings),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),this.isShapeTextInserted&&i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(!e.isBlazor()&&document.querySelector("#"+i.element.id+"_sliderWrapper")||e.isBlazor()&&!i.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||i.currObjType.isFiltered){this.lowerContext.filter=this.tempAdjValue,i.canvasFilter=this.tempAdjValue,i.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.tempAdjValue}}),i.initialAdjustmentValue=this.tempAdjValue,this.lowerContext.filter.split(" ").length>1&&"1"===this.lowerContext.filter.split(" ")[0].split("(")[1].split(")")[0]&&i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:!1}}),i.currentFilter=this.tempFilter,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.redrawImgWithObj(),i.currObjType.isFiltered=!1;var r={tempAdjustmentLevel:null};i.notify("filter",{prop:"getTempAdjustmentLevel",onPropertyChange:!1,value:{obj:r}}),i.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:e.extend({},r.tempAdjustmentLevel,{},!0)}}),i.notify("undo-redo",{prop:"setUndoRedoStep",onPropertyChange:!1,value:{step:this.tempUndoRedoStep}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.clearOuterCanvas(this.lowerContext),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}});a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})}else if(t){var a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})}else this.cancelItems(),i.togglePan=!1,i.notify("selection",{prop:"setDragCanvas",value:{bool:!1}});this.isShapeTextInserted=!1,this.isNewPath=!1,e.isBlazor()||(i.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}))},t.prototype.cancelItems=function(){var t,i=this.parent,o=!1,r=["rectangle","ellipse","line","arrow","path"];void 0!==i.activeObj.shape&&(t=i.activeObj.shape.split("-")),void 0===t&&i.currObjType.isCustomCrop?o=!0:void 0!==t&&"crop"===t[0]&&(o=!0),o&&i.isCropTab&&(i.isCropTab=!1,i.transform.zoomFactor=i.transform.defaultZoomFactor),i.togglePen?this.cancelPen():"text"===i.activeObj.shape?this.cancelText(o):-1!==r.indexOf(i.activeObj.shape)?this.cancelShape():o?this.cancelSelection():(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})),i.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null};var a={type:"main",isApplyBtn:null,isCropping:!1,isZooming:null};e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})},t.prototype.cancelPen=function(){var t=this.parent;this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.togglePen=!1,t.upperCanvas.style.cursor=t.cursor="default";var i=e.extend([],t.pointColl,[],!0);t.pointColl={};for(var o=0;o<this.tempFreehandCounter;o++)t.pointColl[o]=i[o];t.freehandCounter=this.tempFreehandCounter,t.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:this.tempCurrFhdIndex}}),t.activeObj.strokeSettings=this.tempStrokeSettings,t.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:t.activeObj.strokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),t.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},t.prototype.cancelText=function(t){var i=this.parent;if(i.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:this.tempTextSettings,fontFamily:null,fontSize:null}}),i.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),e.isNullOrUndefined(i.activeObj.currIndex))i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height);else{var o={appliedUndoRedoColl:[]};i.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:o}});var r=o.appliedUndoRedoColl.length;this.prevActObj&&o.appliedUndoRedoColl[r-1]&&o.appliedUndoRedoColl[r-1].currentObjColl[o.appliedUndoRedoColl[r-1].currentObjColl.length-1].currIndex===this.prevActObj.currIndex?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height)),i.activeObj.shape&&"Enter Text"===i.activeObj.keyHistory?(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"draw-shape-text"}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):i.activeObj.shape&&(i.notify("shape",{prop:"redraw-text"}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.activeObj}}),t||void 0===i.activeObj.topLeftCircle||i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),i.clearSelection())}e.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1}},t.prototype.cancelShape=function(){var t=this.parent;if(t.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),e.isNullOrUndefined(t.activeObj.currIndex))t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height);else if(this.isNewPath)t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.renderImage();else{var i={appliedUndoRedoColl:[]};t.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:i}});var o=i.appliedUndoRedoColl.length;this.prevActObj&&i.appliedUndoRedoColl[o-1]&&i.appliedUndoRedoColl[o-1].currentObjColl[i.appliedUndoRedoColl[o-1].currentObjColl.length-1].currIndex===this.prevActObj.currIndex?(t.activeObj=this.prevActObj,this.prevActObj=null,t.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:t.activeObj}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):(t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height))}t.currObjType.isDragging=!1,e.isBlazor()?t.updateToolbar(t.element,"destroyQuickAccessToolbar"):t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})},t.prototype.cancelSelection=function(){var t=this.parent;t.cancelCropSelection&&(t.cropObj=e.extend({},t.cancelCropSelection.previousCropObj,{},!0),t.afterCropActions=t.cancelCropSelection.previousObj.afterCropActions,t.notify("undo-redo",{prop:"undoDefault",onPropertyChange:!1,value:{obj:t.cancelCropSelection}}),t.currSelectionPoint=e.extend({},t.cancelCropSelection.previousCropObj.activeObj,!0),t.currSelectionPoint&&e.isNullOrUndefined(t.currSelectionPoint.shape)&&(t.currSelectionPoint=null),this.clearOuterCanvas(this.lowerContext),(t.isCircleCrop||t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}))},t.prototype.updateFlipPan=function(t){var e=this.parent;if(""!==e.transform.currFlipState){var i=this.lowerContext.filter;e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("transform",{prop:"rotatedFlip",onPropertyChange:!1}),this.lowerContext.filter="none",e.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=i,this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),t&&this.drawObject("duplicate",t)}},t.prototype.select=function(t,i,o,r,a){var n=this.parent;if(!n.disabled&&n.isImageLoaded){var s={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=e.extend([],n.objColl,[],!0),l.pointColl=e.extend([],n.pointColl,[],!0),l.afterCropActions=n.afterCropActions;var p={selPointColl:null};n.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=e.extend([],p.selPointColl,[],!0),n.notify("crop",{prop:"setPreviousCropCurrentObj",onPropertyChange:!1,value:{obj:l}}),n.transform.zoomFactor>0&&n.activeObj.shape&&"crop"===n.activeObj.shape.split("-")[0]&&e.isNullOrUndefined(this.currSelPoint)&&(this.currSelPoint=e.extend({},n.activeObj,{},!0));var h=!1,c=void 0;void 0!==n.activeObj.shape&&(c=n.activeObj.shape.split("-")),void 0===c&&n.currObjType.isCustomCrop?h=!0:void 0!==c&&"crop"===c[0]&&(h=!0);var d={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:d}});var v=d.currObj;if(v.objColl=e.extend([],n.objColl,[],!0),v.pointColl=e.extend([],n.pointColl,[],!0),v.afterCropActions=e.extend([],n.afterCropActions,[],!0),n.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),n.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.upperCanvas.style.display="block",n.currSelectionPoint||0!==n.transform.defaultZoomFactor||0!==n.transform.degree&&0!==n.panPoint.totalPannedInternalPoint.x&&0!==n.panPoint.totalPannedInternalPoint.y&&!h){if(n.isCircleCrop=!1,0!==n.transform.defaultZoomFactor){var u=n.isCropTab;n.isCropTab=!1,n.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),n.isCropTab=u,this.resetPanPoints()}this.cancelObjColl=e.extend([],n.objColl,[],!0),this.cancelPointColl=e.extend([],n.pointColl,[],!0),n.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),n.isCropTab=!0,n.isCircleCrop=!1,n.notify("crop",{prop:"setCurrSelPoints",onPropertyChange:!1,value:{isSetDimension:!0}}),n.transform.zoomFactor=n.transform.cropZoomFactor,e.isNullOrUndefined(n.cropObj.activeObj.shape)&&(n.currObjType.shape="crop-"+t.toLowerCase(),this.drawNewSelection(t,i,o,r,a))}else"custom"===t&&(n.currObjType.shape=""),this.drawNewSelection(t,i,o,r,a)}},t.prototype.drawNewSelection=function(t,e,i,o,r){var a,n=this.parent,s="crop-"+t;"crop-custom"===s.toLowerCase()?""!==n.currObjType.shape&&"crop-custom"!==n.currObjType.shape||this.drawCustomSelection("crop-custom",e,i,o,r):"crop-canvas"===s.toLowerCase()?(n.upperCanvas.style.display="block",n.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(n.currObjType.isCustomCrop=!1,n.currObjType.shape=s.toLowerCase(),o&&r?a={startX:e,startY:i,endX:e+o,endY:i+r,width:o,height:r}:o&&"crop-circle"===s&&(a={startX:e,startY:i,endX:e+o,endY:i+o,width:o,height:o}),n.activeObj.shape=s.toLowerCase(),this.updateSelectionInsert(a))},t.prototype.updateSelectionInsert=function(t){var i=this,o=this.parent,r=o.activeObj.activePoint,a={shapeSettingsObj:{}};o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n={type:o.getSelectionType(a.shapeSettingsObj.type),startX:a.shapeSettingsObj.startX,startY:a.shapeSettingsObj.startY,width:a.shapeSettingsObj.width,height:a.shapeSettingsObj.height},s={action:"insert",previousSelectionSettings:n,currentSelectionSettings:n};e.isBlazor()&&o.events&&!0===o.events.onSelectionResizeStart.hasDelegate?o.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(e){o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:e.currentSelectionSettings}}),"Custom"===e.currentSelectionSettings.type?i.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(t={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),i.drawObject("duplicate",null,!0,t))}):(o.trigger("selectionChanging",s),o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}),"Custom"===s.currentSelectionSettings.type?this.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(t={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),this.drawObject("duplicate",null,!0,t)))},t.prototype.drawCustomSelection=function(t,i,o,r,a){var n=this.parent,s=n.activeObj.activePoint;if(n.currObjType.isCustomCrop=!0,this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.currObjType.shape=n.activeObj.shape=t.toLowerCase(),e.isNullOrUndefined(i)||e.isNullOrUndefined(o)||e.isNullOrUndefined(r)||e.isNullOrUndefined(a)){if(e.isNullOrUndefined(n.transform.zoomFactor)||0===n.transform.zoomFactor){var l=n.img.destLeft,p=n.img.destTop,h=n.img.destWidth,c=n.img.destHeight,d=n.lowerCanvas.width,v=n.lowerCanvas.height,u=s;l>=0&&p>=0?(u.startX=l,u.startY=p,u.endX=l+h,u.endY=p+c):l>=0?(u.startX=l,u.startY=7.5,u.endX=l+h,u.endY=v-15):p>=0?(u.startX=7.5,u.startY=p,u.endX=d-15,u.endY=p+c):(u.startX=7.5,u.startY=7.5,u.endX=d-15,u.endY=v-15)}else{var g=n.img.destLeft,b=n.img.destTop,C=n.img.destWidth,f=n.img.destHeight,m=n.lowerCanvas.width,y=n.lowerCanvas.height,P=s;P.startX=Math.max(g>0?g:7.5,g),P.startY=Math.max(b>0?b:7.5,b),P.endX=Math.min(g+C+15<m?g+C-15:m-15,g+C),P.endY=Math.min(b+f+15<y?b+f-15:y-15,b+f)}var j=n.img.destLeft,O=n.img.destTop,x=n.img.destWidth,w=n.img.destHeight,S=n.lowerCanvas.clientWidth,T=n.lowerCanvas.clientHeight,k=s;k.startX=Math.max(k.startX,j),k.startY=Math.max(k.startY,O),k.endX=Math.min(k.endX,j+x),k.endY=Math.min(k.endY,O+w),k.startX===j&&j+x>S&&(k.endX=S-15),k.startY===O&&O+w>T&&(k.endY=T-15),n.activeObj=this.updateWidthHeight(n.activeObj),this.updateActiveObject(s,n.activeObj)}else s.startX=i,s.startY=o,s.endX=i+r,s.endY=o+a,s.width=r,s.height=a;this.updateSelectionInsert()},t.prototype.callUpdateCurrTransState=function(){var t=this.parent,i=e.extend([],t.objColl,[],!0),o=e.extend({},t.activeObj,{},!0);t.objColl=[],t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isRotateZoom=!0,this.updateCurrTransState("initial"),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),0===t.transform.degree&&t.rotateFlipColl.length>0&&(t.img.destLeft+=t.panPoint.totalPannedPoint.x,t.img.destTop+=t.panPoint.totalPannedPoint.y),t.img.destLeft+=t.panPoint.totalPannedInternalPoint.x,t.img.destTop+=t.panPoint.totalPannedInternalPoint.y;var r=this.lowerContext.filter;0===t.transform.degree&&t.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),t.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.updateCurrTransState("reverse"),0===t.transform.degree&&t.rotateFlipColl.length>0&&(t.img.destLeft+=t.panPoint.totalPannedPoint.x,t.img.destTop+=t.panPoint.totalPannedPoint.y),this.isRotateZoom=!1,t.objColl=i;var a=t.togglePen;t.togglePen=!1,this.lowerContext.filter="none",t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),t.img.destLeft+=t.panPoint.totalPannedInternalPoint.x,t.img.destTop+=t.panPoint.totalPannedInternalPoint.y,t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),t.img.destLeft-=t.panPoint.totalPannedInternalPoint.x,t.img.destTop-=t.panPoint.totalPannedInternalPoint.y,t.togglePen=a,this.lowerContext.filter=r,t.activeObj=o},t.prototype.resetPanPoints=function(){this.parent.panPoint.totalPannedPoint={x:0,y:0},this.parent.panPoint.totalPannedClientPoint={x:0,y:0},this.parent.panPoint.totalPannedInternalPoint={x:0,y:0}},t.prototype.setClientTransDim=function(t){var i=this.parent;if(i.transform.degree%90==0&&i.transform.degree%180!=0){i.img.destLeft=(i.lowerCanvas.width-i.img.destHeight)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destWidth)/2;var o=i.img.destWidth;i.img.destWidth=i.img.destHeight,i.img.destHeight=o}else e.isNullOrUndefined(t)&&(i.img.destLeft=(i.lowerCanvas.width-i.img.destWidth)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destHeight)/2)},t.prototype.redrawImgWithObj=function(){var t=this.parent,i={canvasFilter:t.canvasFilter};if(this.lowerContext.filter=i.canvasFilter,0!==t.rotateFlipColl.length){var o=e.extend({},t.panPoint.totalPannedInternalPoint,{},!0),r={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};this.callUpdateCurrTransState(),t.panPoint.totalPannedInternalPoint=o,t.img.destLeft=r.startX,t.img.destTop=r.startY,t.img.destWidth=r.width,t.img.destHeight=r.height}else this.callUpdateCurrTransState();t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}});var a=this.lowerContext.filter;this.lowerContext.filter=t.getDefaultFilter(),t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=a},t.prototype.setCurrentObj=function(t){var i=this.parent,o=!!t;t=t||i.cropObj,i.transform.cropZoomFactor=t.cropZoom,i.transform.defaultZoomFactor=t.defaultZoom,o?t.activeObj.shape&&"crop"===t.activeObj.shape.split("-")[0]?i.transform.zoomFactor=t.cropZoom:i.transform.zoomFactor=t.defaultZoom:i.transform.zoomFactor=t.cropZoom,i.setProperties({zoomSettings:{zoomFactor:t.zoomFactor}},!0),i.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:t.previousZoomValue}}),i.panPoint.totalPannedPoint=e.extend({},t.totalPannedPoint,{},!0),i.panPoint.totalPannedClientPoint=e.extend({},t.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=e.extend({},t.totalPannedInternalPoint,{},!0);var r=e.extend({},t.tempFlipPanPoint,{},!0);i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:r}}),i.rotateFlipColl=e.extend([],t.rotateFlipColl,[],!0),i.transform.degree=t.degree,i.transform.currFlipState=t.currFlipState,i.img.destLeft=t.destPoints.startX,i.img.destTop=t.destPoints.startY,i.img.destWidth=t.destPoints.width,i.img.destHeight=t.destPoints.height,i.img.srcLeft=t.srcPoints.startX,i.img.srcTop=t.srcPoints.startY,i.img.srcWidth=t.srcPoints.width,i.img.srcHeight=t.srcPoints.height,t.afterCropActions&&(i.afterCropActions=t.afterCropActions),this.lowerContext.filter=t.filter,i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:!1}});var a,n=i.isCircleCrop;e.isNullOrUndefined(i.currSelectionPoint)?a=null:(a=e.extend({},i.currSelectionPoint,{},!0),i.currSelectionPoint=null),i.isCircleCrop=!1,this.drawCropSelectionImage(t,!1),0!==i.transform.degree&&(""===i.transform.currFlipState?i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}):i.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),i.img.destLeft=t.destPoints.startX,i.img.destTop=t.destPoints.startY,i.panPoint.totalPannedClientPoint=e.extend({},t.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=e.extend({},t.totalPannedInternalPoint,{},!0)),i.activeObj=e.extend({},t.activeObj,{},!0),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0);var s=e.extend({},t.activeObj,{},!0),l=!1;if(i.afterCropActions.length>0){var p={collection:i.afterCropActions};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.afterCropActions,isRotateFlipCollection:null,obj:p}}),i.afterCropActions=p.collection}var h=e.extend([],i.afterCropActions,[],!0);if(!o&&h.length>0){l=!0;for(var c=0;c<h.length;c++)"horizontalflip"!==h[c]&&"verticalflip"!==h[c]||(i.activeObj=e.extend({},a,{},!0),this.rotatedFlipCropSel=!0),i.notify("transform",{prop:"updateTransform",onPropertyChange:!1,value:{text:h[c]}});s=e.extend({},i.activeObj,{},!0),this.resetPanPoints(),i.activeObj=s,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0),t.degree!==i.transform.degree&&(i.transform.cropZoomFactor=null,i.transform.zoomFactor=0),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.rotatedFlipCropSel&&(this.rotatedFlipCropSel=!1)}i.afterCropActions=h,this.isCancelAction||l||(i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=t.destPoints.startX,i.img.destTop=t.destPoints.startY),i.activeObj=s,i.isCircleCrop=n,e.isNullOrUndefined(a)?i.currSelectionPoint=null:(i.currSelectionPoint=e.extend({},a,{},!0),i.currSelectionPoint&&e.isNullOrUndefined(i.currSelectionPoint.shape)&&(i.currSelectionPoint=null))},t.prototype.drawCropSelectionImage=function(t,i){var o=this.parent,r=this.lowerContext.filter;o.clearContext(this.lowerContext),o.clearContext(this.upperContext),this.lowerContext.setTransform(1,0,0,1,0,0),i?this.updateCurrTransState("initial"):this.setTransformColl(this.lowerContext,"initial"),o.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.lowerContext.drawImage(o.baseImg,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,o.img.destLeft,o.img.destTop,o.img.destWidth,o.img.destHeight),i?this.updateCurrTransState("reverse"):this.setTransformColl(this.lowerContext,"reverse"),o.img.destLeft=o.cropObj.destPoints.startX,o.img.destTop=o.cropObj.destPoints.startY;var a=e.extend({},t.activeObj,{},!0);if(this.lowerContext.filter="none",this.isCancelAction)o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}});else{o.img.destLeft=t.destPoints.startX,o.img.destTop=t.destPoints.startY,o.img.destWidth=t.destPoints.width,o.img.destHeight=t.destPoints.height,o.img.srcLeft=t.srcPoints.startX,o.img.srcTop=t.srcPoints.startY,o.img.srcWidth=t.srcPoints.width,o.img.srcHeight=t.srcPoints.height;var n={startX:o.img.destLeft,startY:o.img.destTop,width:o.img.destWidth,height:o.img.destHeight};o.img.destLeft=t.activeObj.activePoint.startX,o.img.destTop=t.activeObj.activePoint.startY,o.img.destWidth=t.activeObj.activePoint.width,o.img.destHeight=t.activeObj.activePoint.height,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.img.destLeft=n.startX,o.img.destTop=n.startY,o.img.destWidth=n.width,o.img.destHeight=n.height}o.activeObj=a,this.lowerContext.filter=r},t.prototype.performPointZoom=function(t,i,o){var r=this.parent,a=(t-r.img.destLeft)/r.img.destWidth,n=(i-r.img.destTop)/r.img.destHeight,s=r.isUndoRedo;if(r.isUndoRedo=!0,r.setProperties({zoomSettings:{zoomPoint:{x:t,y:i}}},!0),"zoomIn"===o?r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}}):"zoomOut"===o&&r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}}),r.isUndoRedo=s,r.transform.zoomFactor>0){var l=r.img.destLeft,p=r.img.destTop,h=e.extend({},r.activeObj,{},!0);if(0===r.transform.degree)r.img.destLeft=t-a*r.img.destWidth,r.img.destTop=i-n*r.img.destHeight,this.drawZoomPanImage(r.img.destLeft-l,r.img.destTop-p);else{var c=r.isCropTab;r.isCropTab=!0;var d=e.extend([],r.objColl,[],!0),v=e.extend([],r.pointColl,[],!0);r.objColl=[],r.pointColl=[],r.freehandCounter=0;var u={selPointColl:null};r.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:u}});var g=u.selPointColl;r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),r.panPoint.currentPannedPoint={x:t-a*r.img.destWidth-l,y:i-n*r.img.destHeight-p},r.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),r.isCropTab=c,r.objColl=d,r.pointColl=v,r.freehandCounter=r.pointColl.length,r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:g}}}),r.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}}),r.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}})}this.adjustPanning(h),r.activeObj=h,0!==r.activeObj.activePoint.width&&0!==r.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0)}},t.prototype.adjustPanning=function(t){var i=this.parent;if(0!==t.activePoint.width&&0!==t.activePoint.height){var o=i.img.destLeft,r=i.img.destTop,a={x:0,y:0};if(i.img.destLeft>t.activePoint.startX?a.x=i.img.destLeft-t.activePoint.startX:i.img.destLeft+i.img.destWidth<t.activePoint.startX+t.activePoint.width&&(a.x=i.img.destLeft+i.img.destWidth-(t.activePoint.startX+t.activePoint.width)),i.img.destTop>t.activePoint.startY?a.y=i.img.destTop-t.activePoint.startY:i.img.destTop+i.img.destHeight<t.activePoint.startY+t.activePoint.height&&(a.y=i.img.destTop+i.img.destHeight-(t.activePoint.startY+t.activePoint.height)),0===i.transform.degree)i.img.destLeft-=a.x,i.img.destTop-=a.y,this.drawZoomPanImage(i.img.destLeft-o,i.img.destTop-r);else{var n=i.isCropTab;i.isCropTab=!0;var s=e.extend([],i.objColl,[],!0),l=e.extend([],i.pointColl,[],!0);i.objColl=[],i.pointColl=[],i.freehandCounter=0;var p={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}});var h=p.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.img.destLeft-=a.x,i.img.destTop-=a.y,i.panPoint.currentPannedPoint={x:i.img.destLeft-o,y:i.img.destTop-r},i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),i.isCropTab=n,i.objColl=s,i.pointColl=l,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:h}}}),i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}})}}},t.prototype.drawZoomPanImage=function(t,e){var i=this.parent;i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:t,yDiff:e,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:t,yDiff:e,panRegion:""}}),this.renderImage(!0);var o={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i.img.srcWidth,height:i.img.srcHeight,obj:o}});var r=o;r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.panPoint.totalPannedPoint.x+=t,i.panPoint.totalPannedPoint.y+=e,i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:{x:0,y:0}}})},t.prototype.openNewImage=function(){var t=this.parent,o=t.inMemoryCanvas.getContext("2d");i.showSpinner(t.element),t.element.style.opacity="0.5";var r=document.querySelector("#"+t.element.id+"_currPos");r&&(r.style.display="none");var a={defToolbarItems:null};if(e.isBlazor())t.element.querySelector("#"+t.element.id+"_toolbar")?t.toolbarHeight=t.element.querySelector("#"+t.element.id+"_toolbar").clientHeight:t.toolbarHeight=0;else if(t.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:a}}),0===a.defToolbarItems.length&&e.isNullOrUndefined(document.getElementById(t.element.id+"_toolbar"))){var n=t.element.querySelector("#"+t.element.id+"_toolbarArea").clientHeight;t.notify("toolbar",{prop:"setToolbarHeight",value:{height:n}})}if(t.reset(),t.update(),t.transform.degree=0,t.transform.zoomFactor=0,t.isImageLoaded=!1,t.currSelectionPoint=null,"string"===typeof this.openURL){var s=this.openURL.split(".");if(s.length>1?(s=s[s.length-2].split("/"),this.fileName=s[s.length-1]):this.fileName="ImageEditor",this.fileType=this.getFileExtensionFromURL(this.openURL),this.fileType){this.fileType=t.toPascalCase(this.fileType);var l=this.fileType.toLowerCase();"jpg"!==l&&"jpeg"!==l||(this.fileType="Jpeg",l="jpeg"),"jpeg"!==l&&"png"!==l&&"svg"!==l&&(this.fileType=null)}this.imageOnLoad(this.openURL)}else this.fileName="ImageEditor",this.fileType=null,t.lowerCanvas=document.querySelector("#"+t.element.id+"_lowerCanvas"),t.upperCanvas=document.querySelector("#"+t.element.id+"_upperCanvas"),this.lowerContext=t.lowerCanvas.getContext("2d"),this.upperContext=t.upperCanvas.getContext("2d"),t.clearContext(this.lowerContext),t.clearContext(this.upperContext),t.clearContext(o),t.inMemoryCanvas.width=t.baseImg.width=this.openURL.width,t.inMemoryCanvas.height=t.baseImg.height=this.openURL.height,o.putImageData(this.openURL,0,0),t.baseImg.src=t.inMemoryCanvas.toDataURL()},t.prototype.dlgBtnClick=function(){var t=this.parent;t.export(),this.isFileChanged?(t.isImageLoaded=this.isFileChanged=!1,t.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),e.isBlazor()||e.getComponent(document.getElementById(t.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},t.prototype.dlgCloseBtnClick=function(){var t=this.parent;this.baseImgSrc=t.baseImg.src,this.isFileChanged?(t.isImageLoaded=this.isFileChanged=!1,t.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),e.isBlazor()||e.getComponent(document.getElementById(t.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},t.prototype.showDialogPopup=function(){this.parent.element.querySelector("#"+this.parent.element.id+"_dialog").style.display="block",new i.Dialog({header:"Confirm Save Changes",closeOnEscape:!0,content:"<span>Do you want to save the changes you made to the image?</span>",target:document.getElementById("target"),width:"285px",isModal:!0,animationSettings:{effect:"Zoom"},close:this.dlgCloseBtnClick.bind(this),buttons:[{click:this.dlgCloseBtnClick.bind(this),buttonModel:{content:"No",iconCss:"e-icons e-close"}},{click:this.dlgBtnClick.bind(this),buttonModel:{content:"Yes",isPrimary:!0,iconCss:"e-icons e-check"}}]}).appendTo("#"+this.parent.element.id+"_dialog")},t.prototype.restoreOldImage=function(){this.parent.isImageLoaded?(this.reset(),this.openNewImage()):this.openNewImage()},t.prototype.open=function(t){this.parent.disabled||(this.openURL=t,this.restoreOldImage())},t.prototype.getInitialLoaded=function(t){t.isInitialLoaded=this.isInitialLoading},t.prototype.getFileExtensionFromURL=function(t){var e=t.lastIndexOf(".");return-1!==e?t.slice(e+1).toLowerCase():null},t.prototype.fileSelect=function(t,o){var r=this.parent;if(!r.disabled){var a=o.target.files[0],n=a,s=n.name&&n.name.split(".")[1].toLowerCase();if(s&&-1===["jpg","jpeg","png","svg"].indexOf(s))return void this.errorLoading();if(i.showSpinner(r.element),r.element.style.opacity="0.5",this.inputElem=t,s=n.name&&n.name.split(".")[1]){var l=r.toPascalCase(s);this.fileType="JPG"===l||"Jpg"===l?"Jpeg":l}else this.fileType=null;var p=window.URL.createObjectURL(a);this.openURL=p,r.isImageLoaded&&(this.isImageEdited||r.pointColl.length>0||r.objColl.length>0)?(this.isFileChanged=!0,e.isBlazor()?r.dotNetRef.invokeMethodAsync("UpdateDialog"):this.showDialogPopup()):this.checkToolbarTemplate(t,p)}},t.prototype.checkToolbarTemplate=function(t,i){var o=this.parent;e.isNullOrUndefined(o.toolbarTemplate)&&(o.reset(),o.update()),this.fileName=t.value.split("\\")[t.value.split("\\").length-1],this.fileName=this.fileName.split(".")[0],this.imageOnLoad(i.toString()),t.value=""},t.prototype.moveToSelectionRange=function(t,i){var o=this.parent;if(o.activeObj.shape&&("rotateleft"===t||"rotateright"===t)){var r=o.transform.zoomFactor;if(o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.transform.degree%90==0&&o.transform.degree%180!=0)if(o.objColl[o.objColl.length-1].activePoint.width<i.activePoint.height)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(r)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}});break}r+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:r,zoomPoint:null}})}else for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(r)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}});break}r-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:r,zoomPoint:null}})}else if(o.objColl[o.objColl.length-1].activePoint.height<i.activePoint.width)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(r)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}});break}r+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:r,zoomPoint:null}})}else for(var a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(r)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}});break}r-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:r,zoomPoint:null}})}var n=o.lowerCanvas.clientWidth/2-(o.objColl[o.objColl.length-1].activePoint.startX+o.objColl[o.objColl.length-1].activePoint.width/2),s=o.lowerCanvas.clientHeight/2-(o.objColl[o.objColl.length-1].activePoint.startY+o.objColl[o.objColl.length-1].activePoint.height/2);0===o.transform.degree?(o.img.destLeft+=n,o.img.destTop+=s,o.notify("transform",{prop:"drawPannImage",value:{point:{x:n,y:s}}})):(o.panPoint.currentPannedPoint={x:n,y:s},o.notify("transform",{prop:"drawPannedImage",value:{xDiff:n,yDiff:s}}),o.panPoint.currentPannedPoint={x:0,y:0}),o.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),o.activeObj=e.extend({},o.objColl[o.objColl.length-1]),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})}},t.prototype.isSelectionBiggerThanCanvas=function(t){var e=!1;return(t.activePoint.startX<=this.parent.img.destLeft||t.activePoint.startY<=this.parent.img.destTop||t.activePoint.endX>=this.parent.img.destLeft+this.parent.img.destWidth||t.activePoint.endY>=this.parent.img.destTop+this.parent.img.destHeight)&&(e=!0),e},t.prototype.isSelectionOutsideCanvas=function(t){var e=!1;return(t.activePoint.height<this.parent.lowerCanvas.height-this.parent.toolbarHeight||t.activePoint.width<this.parent.lowerCanvas.width)&&(e=!0),e},t}(),l=function(){function t(t){this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("export",this.export,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("export",this.export),this.parent.off("destroyed",this.destroy)},t.prototype.export=function(t){if(e.isBlazor()){var i={shape:""};this.parent.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:i}}),""!==i.shape&&(this.parent.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),this.parent.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}else this.parent.notify("toolbar",{prop:"refreshShapeDrawing",onPropertyChange:!1});switch(this.updatePvtVar(),t.prop){case"export":this.exportImg(t.value.type,t.value.fileName);break;case"exportToCanvas":this.exportToCanvas(t.value.object)}},t.prototype.getModuleName=function(){return"export"},t.prototype.updatePvtVar=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d"))},t.prototype.exportImg=function(t,i){var o=this,r=this.parent,a={fileName:""};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n=a.fileName;if(!r.disabled&&r.isImageLoaded){var s={bool:!1};r.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool&&r.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),r.togglePen&&(r.currObjType.isZoomed=!0,r.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}})),"block"===r.textArea.style.display&&r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}});var l={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=l.canvasFilter,t=t||"Png",r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}});var p={cancel:!1,fileName:i||n,fileType:t};e.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",p).then(function(e){o.beforeSaveEvent(e,t,i,n)}):(r.trigger("beforeSave",p),this.beforeSaveEvent(p,t,i,n))}},t.prototype.beforeSaveEvent=function(t,i,o,r){var a=this.parent;if(!t.cancel){a.currObjType.isSave=!0,o=t.fileName?t.fileName:o;var n=i.toLowerCase();o=o||r,"svg"===n?this.toSVGImg(o):this.toBlobFn(o,n);var s={fileName:o||r,fileType:i};a.trigger("saved",s),e.isBlazor()||a.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),a.lowerCanvas.style.left=a.upperCanvas.style.left="",a.lowerCanvas.style.top=a.upperCanvas.style.top="",a.lowerCanvas.style.maxWidth=a.upperCanvas.style.maxWidth="",a.lowerCanvas.style.maxHeight=a.upperCanvas.style.maxHeight=""}},t.prototype.toSVGImg=function(t){var e=this.parent;i.showSpinner(e.element),e.element.style.opacity="0.5";var o=this.exportToCanvas(),r=o.toDataURL();i.hideSpinner(e.element),e.element.style.opacity="1";var a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("width",o.style.maxWidth),a.setAttribute("height",o.style.maxHeight);var n=document.createElementNS("http://www.w3.org/2000/svg","image");n.setAttributeNS(null,"height",o.height.toString()),n.setAttributeNS(null,"width",o.width.toString()),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),a.appendChild(n);var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+o.width+'" height="'+o.height+'">'+a.innerHTML+"</svg>",l="data:image/svg+xml;base64,"+btoa(s);return null===t?l:(this.downloadImg(l,t+".svg"),null)},t.prototype.toBlobFn=function(t,e){var o=this,r=this.parent;i.showSpinner(r.element),r.element.style.opacity="0.5",this.exportToCanvas().toBlob(function(a){var n=URL.createObjectURL(a);o.downloadImg(n,t+"."+e),i.hideSpinner(r.element),r.element.style.opacity="1"},"image/png")},t.prototype.exportToCanvas=function(t){var i=this.parent,o={width:0,height:0};i.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:o}});var r=o,a=this.lowerContext.filter;if("none"!==this.lowerContext.filter){var n=this.lowerContext.filter.split(" "),s=parseFloat(n[5].split("(")[1]);s*=(r.width+r.height)/2,n[5]="blur("+s+"px)",this.lowerContext.filter=n.join(" ")}var l,p=i.createElement("canvas",{id:i.element.id+"_tempCanvas",attrs:{name:"canvasImage"}}),h=p.getContext("2d");if(h.filter=this.lowerContext.filter,i.currSelectionPoint){p.width=i.img.destWidth,p.height=i.img.destHeight,h.filter=this.lowerContext.filter;d=this.lowerContext.filter;i.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),h.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,0,0,i.img.destWidth,i.img.destHeight),this.lowerContext.filter=d}else{p.width=i.baseImg.width,p.height=i.baseImg.height;var c={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i.baseImg.width,height:i.baseImg.height,obj:c}}),l=c,p.style.maxWidth=l.width+"px",p.style.maxHeight=l.height+"px",h.filter=this.lowerContext.filter;d=this.lowerContext.filter;i.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),h.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,0,0,i.baseImg.width,i.baseImg.height),this.lowerContext.filter=d}if(0===i.transform.degree&&""===i.transform.currFlipState||(this.updateSaveContext(h),this.exportTransformedImage(h)),i.objColl.length>0){var d=h.filter;h.filter="none";for(var v=e.extend([],i.objColl,[],!0),u=0,g=i.objColl.length;u<g;u++){var b=i.objColl[u].activePoint;b.startX-=i.img.destLeft,b.startY-=i.img.destTop,b.endX-=i.img.destLeft,b.endY-=i.img.destTop,b.width=b.endX-b.startX,b.height=b.endY-b.startY,e.isNullOrUndefined(i.currSelectionPoint)&&(b.startX*=r.width,b.startY*=r.height,b.endX*=r.width,b.endY*=r.height,b.width=b.endX-b.startX,b.height=b.endY-b.startY,i.objColl[u].strokeSettings.strokeWidth*=(r.width+r.height)/2,"text"===i.objColl[u].shape&&(i.objColl[u].textSettings.fontSize*=(r.width+r.height)/2)),i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"saveContext",obj:i.objColl[u],isCropRatio:null,points:null,isPreventDrag:!0,saveContext:h,isPreventSelection:null}})}h.filter=d,i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.objColl=v}if(i.freehandCounter>0){for(var C=e.extend({},i.pointColl,{},!0),f=0;f<i.freehandCounter;f++){i.points=e.extend([],i.pointColl[f].points,[]),i.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});g=i.points.length;if(i.currSelectionPoint)for(m=0;m<g;m++)i.points[m].x-=i.img.destLeft,i.points[m].y-=i.img.destTop;else{i.pointColl[f].strokeWidth*=(r.width+r.height)/2;for(var m=0;m<g;m++)i.points[m].x=(i.points[m].x-i.img.destLeft)*r.width,i.points[m].y=(i.points[m].y-i.img.destTop)*r.height}}i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:h,points:null}}),i.pointColl=C}return i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:h,isSave:!0,isFlip:null}}),this.lowerContext.filter=a,t&&(t.canvas=p),p},t.prototype.downloadImg=function(t,e){var i=document.createElement("a");i.href=t,i.target="_parent",i.download=e,(document.body||document.documentElement).appendChild(i),i.click(),i.parentNode.removeChild(i)},t.prototype.exportTransformedImage=function(t){for(var e=this.parent,i=e.transform.degree,o=0,r=e.rotateFlipColl.length;o<r;o++){var a=e.rotateFlipColl[o];"number"==typeof a?this.exportRotate(t,a):"horizontal"===a?this.exportFlip(t,!0,!1):"vertical"===a&&this.exportFlip(t,!1,!0)}e.transform.degree=i},t.prototype.exportRotate=function(t,i){var o=this.parent;e.isNullOrUndefined(o.currSelectionPoint)?(this.setMaxDim(o.transform.degree,t.canvas),t.translate(t.canvas.width/2,t.canvas.height/2),t.rotate(Math.PI/180*i),t.drawImage(o.inMemoryCanvas,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,-t.canvas.height/2,-t.canvas.width/2,t.canvas.height,t.canvas.width)):(t.translate(t.canvas.width/2,t.canvas.height/2),t.rotate(Math.PI/180*i),t.drawImage(o.inMemoryCanvas,-t.canvas.height/2,-t.canvas.width/2,t.canvas.height,t.canvas.width)),this.updateSaveContext(t)},t.prototype.exportFlip=function(t,e,i){e&&(t.translate(t.canvas.width,0),t.scale(-1,1)),i&&(t.translate(0,t.canvas.height),t.scale(1,-1)),t.drawImage(this.parent.inMemoryCanvas,0,0),this.updateSaveContext(t)},t.prototype.updateSaveContext=function(t){var e=this.parent.inMemoryCanvas.getContext("2d");t.setTransform(1,0,0,1,0,0);var i=t.getImageData(0,0,t.canvas.width,t.canvas.height);this.parent.inMemoryCanvas.width=i.width,this.parent.inMemoryCanvas.height=i.height,e.putImageData(i,0,0)},t.prototype.setMaxDim=function(t,e){var i,o;t%90==0&&t%180!=0?(i=this.parent.baseImg.height,o=this.parent.baseImg.width):t%180!=0&&0!==t||(i=this.parent.baseImg.width,o=this.parent.baseImg.height),e.width=i,e.height=o;var r={width:0,height:0};this.parent.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i,height:o,obj:r}});var a=r;e.style.maxWidth=a.width+"px",e.style.maxHeight=a.height+"px"},t}(),p=function(){function t(t){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.adjustmentValue="",this.isBrightnessAdjusted=!1,this.appliedFilter="",this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("filter",this.filter,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("filter",this.filter),this.parent.off("destroyed",this.destroy)},t.prototype.filter=function(t){switch(this.updatePrivateVariables(),t.prop){case"finetuneImage":this.finetuneImage(t.value.option,t.value.value);break;case"applyImageFilter":this.setFilter(t.value.option);break;case"update-finetunes":this.updateFinetunes();break;case"updateBrightFilter":this.updateBrightFilter();break;case"set-adjustment":this.setAdjustment(t.value.operation);break;case"update-filter":this.updateFilter(t.value.operation,t.value.filter);break;case"initFilter":this.initFilter();break;case"setCurrAdjValue":this.setCurrAdjValue(t.value.type,t.value.value);break;case"updateAdj":this.updateAdj(t.value.type,t.value.value,t.value.isPreview,t.value.ctx);break;case"getCurrentObj":this.getCurrentObj(t.value.object);break;case"getAdjustmentLevel":t.value.obj.adjustmentLevel=this.adjustmentLevel;break;case"setAdjustmentLevel":this.adjustmentLevel=t.value.adjustmentLevel;break;case"getTempAdjustmentLevel":t.value.obj.tempAdjustmentLevel=this.tempAdjustmentLevel;break;case"setTempAdjustmentLevel":this.tempAdjustmentLevel=t.value.tempAdjustmentLevel;break;case"setAdjustmentValue":this.adjustmentValue=t.value.adjustmentValue;break;case"getBrightnessAdjusted":t.value.obj.isBrightnessAdjusted=this.isBrightnessAdjusted;break;case"setBrightnessAdjusted":this.isBrightnessAdjusted=t.value.isBrightnessAdjusted,this.parent.currentFilter.split("_")&&"cold"===this.parent.currentFilter.split("_")[1]&&(this.isBrightnessAdjusted=!1);break;case"reset":this.reset()}},t.prototype.updatePrivateVariables=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d"))},t.prototype.getModuleName=function(){return"filter"},t.prototype.updateBrightFilter=function(){var t=this.lowerContext.filter.split(" ");if(this.isBrightnessAdjusted&&t.length>0&&!e.isNullOrUndefined(t[4])){var i=parseFloat(t[4].split("(")[1]);t[4]="opacity("+(i-.3)+")",this.lowerContext.filter=t.join(" ")}},t.prototype.reset=function(){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.adjustmentValue=this.parent.getDefaultFilter(),this.isBrightnessAdjusted=!1,this.appliedFilter=""},t.prototype.updateFinetunes=function(){var t=this.parent,e=t.finetuneSettings;e&&(e.brightness&&(this.adjustmentLevel.brightness=e.brightness.defaultValue,this.tempAdjustmentLevel.brightness=e.brightness.defaultValue),e.contrast&&(this.adjustmentLevel.contrast=e.contrast.defaultValue,this.tempAdjustmentLevel.contrast=e.contrast.defaultValue),e.hue&&(this.adjustmentLevel.hue=e.hue.defaultValue,this.tempAdjustmentLevel.hue=e.hue.defaultValue),e.saturation&&(this.adjustmentLevel.saturation=e.saturation.defaultValue,this.tempAdjustmentLevel.saturation=e.saturation.defaultValue),e.exposure&&(this.adjustmentLevel.exposure=e.exposure.defaultValue,this.tempAdjustmentLevel.exposure=e.exposure.defaultValue),e.opacity&&(this.adjustmentLevel.opacity=e.opacity.defaultValue,this.tempAdjustmentLevel.opacity=e.opacity.defaultValue),e.blur&&(this.adjustmentLevel.blur=e.blur.defaultValue,this.tempAdjustmentLevel.blur=e.blur.defaultValue),t.notify("draw",{prop:"isInitialLoading",onPropertyChange:!1,value:{isInitialLoading:!0}}))},t.prototype.initFilter=function(){this.setFilterAdj("brightness",this.adjustmentLevel.brightness),this.setFilterAdj("contrast",this.adjustmentLevel.contrast),this.setFilterAdj("hue",this.adjustmentLevel.hue),this.setFilterAdj("saturation",this.adjustmentLevel.saturation),this.setFilterAdj("exposure",this.adjustmentLevel.exposure),this.setFilterAdj("opacity",this.adjustmentLevel.opacity),this.setFilterAdj("blur",this.adjustmentLevel.blur)},t.prototype.updateAdj=function(t,i,o,r){var a=this.parent;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height);var n,s,l=this.lowerContext.filter.split(" "),p=[];l[4]&&(n=parseFloat(l[4].split("(")[1])),l[0]&&(s=parseFloat(l[0].split("(")[1]));var h=this.getFilterValue(this.adjustmentLevel.brightness),c=this.getFilterValue(this.adjustmentLevel.saturation);if(-1===["brightness","contrast","hue","saturation","exposure","opacity","blur"].indexOf(t)&&e.isNullOrUndefined(o)&&(this.adjustmentLevel.sharpen||this.adjustmentLevel.bw)){a.isUndoRedo=!0;var d=this.lowerContext.filter;this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=d,a.isUndoRedo=!1}1!==h&&(l[4]="opacity("+(n-.3)+")");var v,u,g,b,C;switch(t){case"brightness":100!==parseFloat(l[3].split("(")[1])&&(i+=.1),l[0]="brightness("+i+")",this.adjustmentValue=l.join(" ");break;case"contrast":l[1]="contrast("+i+"%)",this.adjustmentValue=l.join(" ");break;case"hue":l[2]="hue-rotate("+i+"deg)",this.adjustmentValue=l.join(" ");break;case"saturation":l[3]="saturate("+i+"%)",1!==c&&(l[0]="brightness("+(s+.09)+")"),this.adjustmentValue=l.join(" ");break;case"opacity":1!==parseFloat(l[0].split("(")[1])&&(i-=.2),l[4]="opacity("+i+")",this.adjustmentValue=l.join(" ");break;case"blur":l[5]="blur("+i+"px)",this.adjustmentValue=l.join(" ");break;case"exposure":1!==h&&(l[4]="opacity("+(n-.3)+")"),i>1?(i-=1,i+=h):i<1&&(i=h-(i=1-i)),l[0]="brightness("+i+")",this.adjustmentValue=l.join(" ");break;case"chrome":v=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(v*=100)+.4*v,l[3]="saturate("+i+"%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"cold":u=this.getFilterValue(this.adjustmentLevel.brightness),i=.9*(u*=100),i*=.01,l[0]="brightness("+i+")",b=this.getFilterValue(this.adjustmentLevel.contrast),i=(b*=100)+.5*b,l[1]="contrast("+i+"%)",C=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=C*=100,l[3]="saturate("+i+"%)",p=this.adjustmentValue.split(" "),l[2]=p[2],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"warm":g=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(g*=100)+.4*g,l[3]="saturate("+i+"%)",l[6]="sepia(25%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[4]=p[4],l[5]=p[5],l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"grayscale":l[7]="grayscale(100%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[3]=p[3],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[8]="invert(0%)";break;case"sepia":l[6]="sepia(100%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[3]=p[3],l[4]=p[4],l[5]=p[5],l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"invert":l[8]="invert(100%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[3]=p[3],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[7]="grayscale(0%)"}if("sharpen"!==t&&"blackandwhite"!==t){e.isNullOrUndefined(o)&&("default"===t&&(l=this.getDefaultCurrentFilter(l)),this.lowerContext.filter=l.join(" ")),l=this.setTempFilterValue(h,o,l,t),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.appliedFilter=this.lowerContext.filter,this.lowerContext.drawImage(a.baseImg,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,a.img.destLeft,a.img.destTop,a.img.destWidth,a.img.destHeight),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),1!==h?l[4]="opacity("+n+")":1!==c&&(l[0]="brightness("+s+")"),("exposure"===t&&1!==h||"saturation"===t&&1!==c)&&(l[0]="brightness("+s+")"),l=this.setTempFilterValue(h,o,l,t),e.isNullOrUndefined(o)&&(this.lowerContext.filter=l.join(" ")),a.initialAdjustmentValue=l.join(" ");var f=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=f,a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.isBrightnessAdjusted=1!==h}var m=l.join(" ");r&&(r.filter=m)},t.prototype.setTempFilterValue=function(t,e,i,o){if(e)if("default"===o)i=this.getDefaultCurrentFilter(i);else if(1!==t){var r=this.lowerContext.filter.split(" ");r[4]=i[4],this.lowerContext.filter=r.join(" ")}return i},t.prototype.getDefaultCurrentFilter=function(t){var e=this.adjustmentValue.split(" ");return[e[0],e[1],e[2],e[3],e[4],e[5],"sepia(0%)","grayscale(0%)","invert(0%)"]},t.prototype.getFilterValue=function(t){return 0===t?1:1+.5*t/100},t.prototype.getSaturationFilterValue=function(t){return 0===t?1:1+t/100},t.prototype.setFilterAdj=function(t,i){var o=this.parent;switch(o.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1}),this.adjustmentLevel[""+t]=i,t){case"brightness":case"contrast":case"exposure":i=this.getFilterValue(i),"contrast"===t&&(i*=100);break;case"hue":i*=3;break;case"saturation":i=100*this.getSaturationFilterValue(i);break;case"opacity":i>=50?i/=100:40===i?i=.45:30===i?i=.4:20===i?i=.35:10===i?i=.3:0===i&&(i=.25);break;case"blur":0!==i&&(i/=20,i+=.5)}var r=e.extend({},o.cropObj,{},!0),a=this.getCurrentObj();a.objColl=e.extend([],o.objColl,[],!0),a.pointColl=e.extend([],o.pointColl,[],!0),a.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.updateAdj(t,i);var s=this.lowerContext.filter;this.lowerContext.filter=this.appliedFilter,o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:t,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.lowerContext.filter=s},t.prototype.setFilter=function(t){var i=this.parent;t=t.toLowerCase(),i.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1});var o={currentFilter:this.parent.currentFilter}.currentFilter,r=e.extend({},i.cropObj,{},!0),a=this.getCurrentObj();a.objColl=e.extend([],i.objColl,[],!0),a.pointColl=e.extend([],i.pointColl,[],!0),a.afterCropActions=e.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.updateAdj(t,null);var s=this.lowerContext.filter;this.lowerContext.filter=this.appliedFilter,i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:t,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:o,isCircleCrop:null}}),this.lowerContext.filter=s},t.prototype.setAdjustment=function(t){var e,i,o=this.lowerContext.filter.split(" ");switch(t){case"brightness":i=o[0].split("("),e=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.brightness=this.setFilterValue(e);break;case"contrast":i=o[1].split("("),e=parseFloat(i[1].split(")")[0]),e/=100,this.adjustmentLevel.contrast=this.setFilterValue(e);break;case"hue":i=o[2].split("("),e=parseFloat(i[1].split(")")[0]),e/=3,this.adjustmentLevel.hue=e;break;case"saturation":i=o[3].split("("),e=parseFloat(i[1].split(")")[0]),e/=100,this.adjustmentLevel.saturation=this.setSaturationFilterValue(e);break;case"opacity":i=o[4].split("("),.45===(e=parseFloat(i[1].split(")")[0]))?e=40:.4===e?e=30:.35===e?e=20:.3===e?e=10:.25===e?e=0:e*=100,this.adjustmentLevel.opacity=e;break;case"blur":i=o[5].split("("),e=parseFloat(i[1].split(")")[0]),e*=20,this.adjustmentLevel.blur=e;break;case"exposure":i=o[0].split("("),e=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.exposure=this.setFilterValue(e)}},t.prototype.setFilterValue=function(t){return Math.round(1===t?0:100*(t-1)/.5)},t.prototype.setSaturationFilterValue=function(t){return Math.round(1===t?0:100*(t-1))},t.prototype.updateFilter=function(t,e){var i=this.parent;if(-1!==["default","chrome","cold","warm","grayscale","blackandwhite","sepia","invert","sharpen"].indexOf(t)){var o=i.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");o&&o.classList.remove("e-selected");var r=document.getElementById(i.element.id+"_"+t+"Canvas");r&&r.parentElement.classList.add("e-selected"),this.parent.currentFilter=e||i.element.id+"_"+t}},t.prototype.finetuneImage=function(t,e){var i=this.parent;if(!i.disabled&&i.isImageLoaded){switch(t.toLowerCase()){case"brightness":this.setFilterAdj("brightness",e);break;case"contrast":this.setFilterAdj("contrast",e);break;case"hue":this.setFilterAdj("hue",e);break;case"saturation":this.setFilterAdj("saturation",e);break;case"opacity":this.setFilterAdj("opacity",e);break;case"blur":this.setFilterAdj("blur",e);break;case"exposure":this.setFilterAdj("exposure",e)}this.parent.canvasFilter=this.lowerContext.filter,i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},t.prototype.setCurrAdjValue=function(t,e){switch(this.parent.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),t){case"brightness":this.setFilterAdj("brightness",e);break;case"contrast":this.setFilterAdj("contrast",e);break;case"hue":this.setFilterAdj("hue",e);break;case"saturation":this.setFilterAdj("saturation",e);break;case"opacity":this.setFilterAdj("opacity",e);break;case"blur":this.setFilterAdj("blur",e);break;case"exposure":this.setFilterAdj("exposure",e)}},t.prototype.getCurrentObj=function(t){var i=this.parent,o={point:null};i.notify("crop",{prop:"getTempFlipPanPoint",value:{obj:o}});var r={previousZoomValue:null};i.notify("transform",{prop:"getPreviousZoomValue",value:{obj:r}});var a={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:""};return a.cropZoom=i.transform.cropZoomFactor,a.defaultZoom=i.transform.defaultZoomFactor,a.zoomFactor=i.zoomSettings.zoomFactor,a.previousZoomValue=r.previousZoomValue,a.totalPannedPoint=e.extend({},i.panPoint.totalPannedPoint,{},!0),a.totalPannedClientPoint=e.extend({},i.panPoint.totalPannedClientPoint,{},!0),a.totalPannedInternalPoint=e.extend({},i.panPoint.totalPannedInternalPoint,{},!0),a.tempFlipPanPoint=e.extend({},o.point,{},!0),a.activeObj=e.extend({},i.activeObj,{},!0),a.rotateFlipColl=e.extend([],i.rotateFlipColl,[],!0),a.degree=i.transform.degree,a.currFlipState=i.transform.currFlipState,a.destPoints={startX:i.img.destLeft,startY:i.img.destTop,endX:0,endY:0,width:i.img.destWidth,height:i.img.destHeight},a.srcPoints={startX:i.img.srcLeft,startY:i.img.srcTop,endX:0,endY:0,width:i.img.srcWidth,height:i.img.srcHeight},a.filter=this.lowerContext.filter,t&&(t.currObj=a),a},t}(),h=function(){function t(t){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=!1,this.freehandDownPoint={x:0,y:0},this.isFreehandPointMoved=!1,this.pointCounter=0,this.selPointColl={},this.currFHDIdx=0,this.selPoints=[],this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null},this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("freehand-draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("freehand-draw",this.draw),this.parent.off("destroyed",this.destroy)},t.prototype.draw=function(t){switch(this.updateFhdPvtVar(),t.prop){case"hoverFhd":this.hoverFhd(t.value.strokeColor,t.value.strokeWidth);break;case"freehandDownHandler":this.freehandDownHandler(t.value.e,t.value.canvas);break;case"freehandUpHandler":this.freehandUpHandler(t.value.e,t.value.canvas,t.value.context);break;case"handle-freehand-draw":i=parseInt(t.value.id.split("_")[1],10)-1;this.isFHDIdx(i)&&this.deleteFhd(i,!0);break;case"freehandRedraw":this.freehandRedraw(t.value.context,t.value.points);break;case"deleteFhd":i=parseInt(t.value.id.split("_")[1],10)-1;this.deleteFhd(i,!0);break;case"selectFhd":var i=null;t.value.id&&(i=parseInt(t.value.id.split("_")[1],10)-1),this.selectFhd(i);break;case"applyFhd":this.applyFhd();break;case"cancelFhd":this.cancelFhd();break;case"updateFHDCurPts":this.updateFHDCurPts();break;case"rotateFhdColl":this.rotateFhdColl();break;case"flipFHDColl":this.flipFHDColl(t.value.value);break;case"panFHDColl":this.panFHDColl(t.value.xDiff,t.value.yDiff,t.value.panRegion);break;case"updateFHDColl":this.updateFHDColl();break;case"zoomFHDColl":this.zoomFHDColl(t.value.isPreventApply);break;case"apply-pen-draw":this.applyPenDraw();break;case"freeHandDraw":this.freeHandDraw(t.value.value);break;case"isFHDIdx":this.isFHDIdx(t.value.index,t.value.obj);break;case"getSqPtFD":this.getSqPtFD(t.value.idx,t.value.obj);break;case"getSelPointColl":t.value.obj.selPointColl=e.extend([],this.selPointColl);break;case"setSelPointColl":this.selPointColl=e.extend([],t.value.obj.selPointColl);break;case"setFreehandDrawHoveredIndex":this.fhdHovIdx=t.value.index;break;case"getFreehandDrawHoveredIndex":t.value.obj.index=this.fhdHovIdx;break;case"setPointCounter":this.pointCounter=t.value.value;break;case"getPenStrokeWidth":t.value.obj.penStrokeWidth=this.penStrokeWidth;break;case"setPenStrokeWidth":this.penStrokeWidth=t.value.value;break;case"getCurrentFreehandDrawIndex":t.value.obj.currentFreehandDrawIndex=this.currFHDIdx;break;case"setCurrentFreehandDrawIndex":this.currFHDIdx=t.value.value;break;case"updateCropPtsForSel":this.updateCropPtsForSel();break;case"getFreehandDrawSelectedId":t.value.obj.freehandDrawSelectedId=this.fhdSelID;break;case"resetFreehandDrawSelectedId":this.fhdSelID=null;break;case"getTempFreeHandDrawEditingStyles":t.value.obj.tempFreeHandDrawEditingStyles=this.tempFHDStyles;break;case"setFreehandSelectedIndex":this.fhdSelIdx=t.value.index;break;case"getFreehandSelectedIndex":t.value.obj.freehandSelectedIndex=this.fhdSelIdx;break;case"reset":this.reset()}},t.prototype.updateFhdPvtVar=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d"))},t.prototype.reset=function(){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=this.isFreehandPointMoved=!1,this.selPoints=[],this.freehandDownPoint={x:0,y:0},this.selPointColl={},this.fhdHovIdx=null,this.pointCounter=0,this.fhdSelID=null,this.penStrokeWidth=void 0,this.currFHDIdx=0,this.fhdSelIdx=null,this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null}},t.prototype.getModuleName=function(){return"freehand-draw"},t.prototype.hoverFhd=function(t,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=this.upperContext,a=-1;a=this.fhdHovIdx>-1?this.fhdHovIdx:this.fhdSelIdx,o.points=e.extend([],o.pointColl[a].points),this.pointCounter=0;var n,s,l,p,h=o.points.length,c=0,d=0;r.fillStyle=t||o.pointColl[a].strokeColor,r.strokeStyle=r.fillStyle,c=d=this.penStrokeWidth=i||o.pointColl[a].strokeWidth,1===h&&(n=s=l=p=o.points[0],this.startDraw(r,n,s,l,p,c,d));for(var v=0;v<h-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(n=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,s=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,l=o.points[v+1],p=o.points[v+2],this.startDraw(r,n,s,l,p,c,d));r.closePath();var u=this.getSqPtFD(a),g=r.lineWidth;r.lineWidth=2,r.strokeStyle=o.themeColl[o.theme].primaryColor,r.beginPath(),r.rect(u.startX,u.startY,u.width,u.height),r.stroke(),r.closePath(),r.lineWidth=g},t.prototype.freehandDownHandler=function(t,i){this.parent.lowerCanvas=document.querySelector("#"+this.parent.element.id+"_lowerCanvas"),this.lowerContext=this.parent.lowerCanvas.getContext("2d"),this.parent.upperCanvas=document.querySelector("#"+this.parent.element.id+"_upperCanvas"),this.upperContext=this.parent.upperCanvas.getContext("2d"),this.fhdObj.time=(new Date).getTime(),this.isFreehandDrawing=!0,"mousedown"===t.type?this.freehandDownPoint={x:t.clientX,y:t.clientY}:this.freehandDownPoint={x:t.touches[0].clientX,y:t.touches[0].clientY},this.isFreehandPointMoved=!1,e.EventHandler.add(i,"mousemove touchmove",this.freehandMoveHandler,this)},t.prototype.freehandUpHandler=function(t,i,o){var r=i.getBoundingClientRect(),a=this.parent;e.EventHandler.remove(i,"mousemove touchmove",this.freehandMoveHandler),0===a.points.length&&("mouseup"===t.type?this.processPoint(t.clientX-r.left,t.clientY-r.top,!0,o):this.isFreehandPointMoved||this.processPoint(this.freehandDownPoint.x-r.left,this.freehandDownPoint.y-r.top,!0,o)),o.closePath();var n=e.extend({},a.cropObj,{},!0),s={currObj:{}};a.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=e.extend([],a.objColl,[],!0),l.pointColl=e.extend([],a.pointColl,[],!0),l.afterCropActions=e.extend([],a.afterCropActions,[],!0);var p={selPointColl:null};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=e.extend([],p.selPointColl,[],!0);var h=a.freehandCounter;a.pointColl[h]={},a.pointColl[h].points=e.extend([],a.points),a.pointColl[h].strokeColor=a.activeObj.strokeSettings.strokeColor,a.pointColl[h].strokeWidth=this.penStrokeWidth,a.pointColl[h].flipState=a.transform.currFlipState,a.pointColl[h].id="pen_"+(this.currFHDIdx+1),a.points=[],this.selPointColl[h]={},this.selPointColl[h].points=e.extend([],this.selPoints),this.selPoints=[],this.pointCounter=0,a.freehandCounter++,this.currFHDIdx++,this.isFreehandDrawing=!1,a.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehand-draw",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:n,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})},t.prototype.freehandMoveHandler=function(t){this.isFreehandPointMoved=!0;var e,i,o=this.parent.upperCanvas.getBoundingClientRect();"mousemove"===t.type?(e=t.clientX-o.left,i=t.clientY-o.top):(e=t.touches[0].clientX-o.left,i=t.touches[0].clientY-o.top),this.isFreehandDrawing&&this.processPoint(e,i,!1,this.upperContext)},t.prototype.processPoint=function(t,i,o,r){var a,n,s,l,p=this.parent,h=this.point(t,i,(new Date).getTime()),c=!!(h=p.points.length>0&&p.points[p.points.length-1])&&this.distanceTo(h)<=5;if(this.selPoints.push({x:t,y:i,ratioX:(t-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),!h||!h||!c||o){if(this.fhdObj.time=(new Date).getTime(),p.points.push({x:t,y:i,ratioX:(t-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),p.points.length>3){var d=p.points[this.pointCounter],v=p.points[this.pointCounter+1],u=p.points[this.pointCounter+2],g=p.points[this.pointCounter+3];a=this.calcCurveCP(d,v,u).controlPoint2,n=this.calcCurveCP(v,u,g).controlPoint1,s=p.points[this.pointCounter+1],l=p.points[this.pointCounter+2];var b=.5,C=5;e.isNullOrUndefined(this.penStrokeWidth)||(b=C=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,C),this.pointCounter++}if(o){a=n=s=l={x:t,y:i,time:(new Date).getTime()};var b=.5,C=5;e.isNullOrUndefined(this.penStrokeWidth)||(b=C=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,C)}}},t.prototype.calcCurveCP=function(t,e,i){e||(e=t),i||(i=e);var o=t.x-e.x,r=t.y-e.y,a=e.x-i.x,n=e.y-i.y,s={x:(t.x+e.x)/2,y:(t.y+e.y)/2},l={x:(e.x+i.x)/2,y:(e.y+i.y)/2},p=Math.sqrt(o*o+r*r),h=Math.sqrt(a*a+n*n),c=s.x-l.x,d=s.y-l.y,v=h/(p+h),u={x:l.x+c*v,y:l.y+d*v},g=e.x-u.x,b=e.y-u.y;return{controlPoint1:this.point(s.x+g,s.y+b,0),controlPoint2:this.point(l.x+g,l.y+b,0)}},t.prototype.point=function(t,e,i){return this.fhdObj.pointX=t,this.fhdObj.pointY=e,{x:this.fhdObj.pointX,y:this.fhdObj.pointY,time:i}},t.prototype.startDraw=function(t,e,i,o,r,a,n){var s;s=.7*(s=this.pointVelocity(o))+(1-.7)*this.fhdObj.lastVelocity;var l=Math.max(n/1.7,a);this.drawCurve(this.fhdObj.time,l,t,e,i,o,r,n),this.fhdObj.lastVelocity=s,this.fhdObj.time=l},t.prototype.pointVelocity=function(t){return this.fhdObj.time!==t.time?this.distanceTo(t)/(this.fhdObj.time-t.time):0},t.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.fhdObj.pointX-t.x,2)+Math.pow(this.fhdObj.pointY-t.y,2))},t.prototype.drawCurve=function(t,e,i,o,r,a,n,s){var l,p,h,c,d,v,u,g,b,C,f=e-t,m=this.bezierLength(o,r,a,n),y=2*Math.ceil(m);for(i.beginPath(),p=0;p<y;p++)d=(c=(h=p/y)*h)*h,b=(g=(u=(v=1-h)*v)*v)*a.x,b+=3*u*h*o.x,b+=3*v*c*r.x,b+=d*n.x,C=g*a.y,C+=3*u*h*o.y,C+=3*v*c*r.y,C+=d*n.y,l=Math.min(t+d*f,s),this.drawArc(b,C,l,i);i.closePath(),i.fill()},t.prototype.bezierLength=function(t,e,i,o){var r,a,n,s,l,p,h,c,d=0;for(r=0;r<=10;r++)a=r/10,n=this.bezierPoint(a,i.x,t.x,e.x,o.x),s=this.bezierPoint(a,i.y,t.y,e.y,o.y),r>0&&(h=n-l,c=s-p,d+=Math.sqrt(h*h+c*c)),l=n,p=s;return d},t.prototype.bezierPoint=function(t,e,i,o,r){return e*(1-t)*(1-t)*(1-t)+3*i*(1-t)*(1-t)*t+3*o*(1-t)*t*t+r*t*t*t},t.prototype.drawArc=function(t,e,i,o){(t>this.parent.img.destLeft&&e>this.parent.img.destTop&&t<this.parent.img.destLeft+this.parent.img.destWidth&&e<this.parent.img.destTop+this.parent.img.destHeight||o!==this.lowerContext&&o!==this.upperContext)&&(o.moveTo(t,e),o.arc(t,e,i,0,2*Math.PI,!1))},t.prototype.freehandRedraw=function(t,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=t.filter;t.filter="none",i&&(o.pointColl[o.freehandCounter]={},o.pointColl[o.freehandCounter].points=i,o.pointColl[o.freehandCounter].strokeColor=o.activeObj.strokeSettings.strokeColor,o.pointColl[o.freehandCounter].strokeWidth=this.penStrokeWidth,o.pointColl[o.freehandCounter].flipState=o.transform.currFlipState,o.freehandCounter++);for(var a=0;a<o.freehandCounter;a++){o.points=e.extend([],o.pointColl[a].points),this.pointCounter=0;var n=o.points.length,s=void 0,l=void 0,p=void 0,h=void 0,c=void 0,d=void 0;n>0&&(t.fillStyle=o.pointColl[a].strokeColor,c=d=this.penStrokeWidth=o.pointColl[a].strokeWidth),1===n&&(s=l=p=h=o.points[0],this.startDraw(t,s,l,p,h,c,d));for(var v=0;v<n-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(s=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,l=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,p=o.points[v+1],h=o.points[v+2],this.startDraw(t,s,l,p,h,c,d));t.closePath()}t.filter=r},t.prototype.getSqPtFD=function(t,i){var o={startX:0,startY:0,endX:0,endY:0,width:0,height:0},r=e.extend([],this.selPointColl[t].points,[]);this.parent.points=e.extend([],this.parent.pointColl[t].points),this.pointCounter=0;for(var a=r.length,n=0;n<a;n++)0===o.startX&&0===o.startY&&0===o.endX&&0===o.endY?(o.startX=r[n].x,o.startY=r[n].y,o.endX=r[n].x,o.endY=r[n].y):(o.startX=Math.min(o.startX,r[n].x),o.startY=Math.min(o.startY,r[n].y),o.endX=Math.max(o.endX,r[n].x),o.endY=Math.max(o.endY,r[n].y));return o.startX-=this.penStrokeWidth,o.startY-=this.penStrokeWidth,o.endX+=this.penStrokeWidth,o.endY+=this.penStrokeWidth,o.width=o.endX-o.startX,o.height=o.endY-o.startY,i&&(i.activePoint=o),o},t.prototype.applyPenDraw=function(){var t=this.parent;"freehanddraw"===t.currObjType.shape&&(t.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),t.upperCanvas.style.cursor=t.cursor="default",t.currObjType.shape=""),t.notify("shape",{prop:"clearActObj"})},t.prototype.applyFhd=function(){var t=this.parent,i=t.pointColl[this.fhdSelIdx];"#42a5f5"===i.strokeColor&&(i.strokeColor=this.tempFHDStyles.strokeColor),e.isBlazor()||t.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.isBlazor()||t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i&&(i.isSelected=!1),t.notify("selection",{prop:"resetFreehandDrawVariables"}),this.fhdHovIdx=this.fhdSelIdx=null},t.prototype.cancelFhd=function(){var t=this.parent;e.isBlazor()||t.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.pointCounter=0,t.pointColl[this.fhdSelIdx]&&(t.pointColl[this.fhdSelIdx].strokeColor=this.tempFHDStyles.strokeColor,t.pointColl[this.fhdSelIdx].strokeWidth=this.tempFHDStyles.strokeWidth,t.pointColl[this.fhdSelIdx].isSelected=!1),this.fhdHovIdx=this.fhdSelIdx=this.fhdSelID=null,t.notify("selection",{prop:"resetFreehandDrawVariables"}),t.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor,t.activeObj.strokeSettings.strokeWidth=this.penStrokeWidth=this.tempFHDStyles.strokeWidth,this.tempFHDStyles={strokeColor:null,strokeWidth:null,fillColor:null},e.isBlazor()||t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},t.prototype.selectFhd=function(t){var i=this.parent;if(i.notify("selection",{prop:"setFreehandDrawEditing",onPropertyChange:!1,value:{bool:!0}}),t||0===t){if(!this.isFHDIdx(t))return;this.fhdSelIdx=this.fhdHovIdx=t,this.hoverFhd(),i.upperCanvas.style.cursor=i.cursor="pointer"}this.fhdSelIdx=this.fhdHovIdx,i.pointColl[this.fhdSelIdx].isSelected=!0,this.fhdSelID=i.pointColl[this.fhdSelIdx].id,"#42a5f5"!==i.pointColl[this.fhdHovIdx].strokeColor&&(i.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor=i.pointColl[this.fhdHovIdx].strokeColor),i.activeObj.strokeSettings.strokeWidth=this.tempFHDStyles.strokeWidth=i.pointColl[this.fhdHovIdx].strokeWidth;var o={bool:!1};i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:o}}),o.bool?e.isBlazor()||i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):i.okBtn()},t.prototype.deleteFhd=function(t,i){var o=this.parent;if(this.isFHDIdx(t)){this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);var r=e.extend({},o.pointColl,{},!0),a=e.extend({},this.selPointColl,{},!0);o.pointColl={},this.selPointColl={};var n=0;if(e.isNullOrUndefined(i))for(s=0;s<o.freehandCounter;s++)s!==t&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);else for(var s=0;s<o.freehandCounter;s++)parseInt(r[s].id.split("_")[1],10)-1!==t&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);o.freehandCounter-=1,this.fhdHovIdx=this.fhdSelIdx=null,o.notify("selection",{prop:"resetFreehandDrawVariables"}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}}),e.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},t.prototype.zoomX=function(t){return t*this.parent.img.destWidth+this.parent.img.destLeft},t.prototype.zoomY=function(t){return t*this.parent.img.destHeight+this.parent.img.destTop},t.prototype.zoomFHDColl=function(t){for(var i=this.parent,o=0;o<i.freehandCounter;o++){i.points=e.extend([],i.pointColl[o].points,[]),this.pointCounter=0;for(var r=i.points.length,a=0;a<r;a++)i.points[a].x=this.zoomX(i.points[a].ratioX),i.points[a].y=this.zoomY(i.points[a].ratioY)}this.updateFHDCurPts(),e.isNullOrUndefined(t)&&this.freehandRedraw(this.lowerContext,null)},t.prototype.updateFHDCurPts=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x=this.zoomX(this.selPoints[r].ratioX),this.selPoints[r].y=this.zoomY(this.selPoints[r].ratioY)}},t.prototype.rotateFhdColl=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++){t.points=e.extend([],t.pointColl[i].points,[]),this.pointCounter=0;for(var o=t.points.length,r=0;r<o;r++)t.points[r].y=t.img.destTop+t.img.destHeight*t.points[r].ratioX,t.points[r].x=t.img.destLeft+t.img.destWidth-t.img.destWidth*t.points[r].ratioY,t.points[r].ratioX=(t.points[r].x-t.img.destLeft)/t.img.destWidth,t.points[r].ratioY=(t.points[r].y-t.img.destTop)/t.img.destHeight}for(i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y=t.img.destTop+t.img.destHeight*this.selPoints[r].ratioX,this.selPoints[r].x=t.img.destLeft+t.img.destWidth-t.img.destWidth*this.selPoints[r].ratioY,this.selPoints[r].ratioX=(this.selPoints[r].x-t.img.destLeft)/t.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-t.img.destTop)/t.img.destHeight}this.updateFHDCurPts()},t.prototype.flipFHDColl=function(t){var e=t.toLowerCase();if("horizontal"===e)this.pointsHorizontalFlip();else if("vertical"===e)this.pointsVerticalFlip();else{this.pointsHorizontalFlip();for(var i=0;i<this.parent.freehandCounter;i++)this.parent.pointColl[i].shapeFlip="";this.pointsVerticalFlip()}},t.prototype.pointsHorizontalFlip=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++)if(t.pointColl[i].shapeFlip!==t.transform.currFlipState){t.points=e.extend([],t.pointColl[i].points,[]),this.pointCounter=0;for(var o=t.points.length,r=0;r<o;r++)t.points[r].x<=t.img.destLeft+t.img.destWidth/2?t.points[r].x=t.img.destLeft+t.img.destWidth-(t.points[r].x-t.img.destLeft):t.points[r].x>=t.img.destLeft+t.img.destWidth/2&&(t.points[r].x=t.img.destLeft+(t.img.destLeft+t.img.destWidth-t.points[r].x)),t.points[r].ratioX=(t.points[r].x-t.img.destLeft)/t.img.destWidth,t.points[r].ratioY=(t.points[r].y-t.img.destTop)/t.img.destHeight;t.pointColl[i].shapeFlip=t.transform.currFlipState}for(i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==t.transform.currFlipState){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x<=t.img.destLeft+t.img.destWidth/2?this.selPoints[r].x=t.img.destLeft+t.img.destWidth-(this.selPoints[r].x-t.img.destLeft):this.selPoints[r].x>=t.img.destLeft+t.img.destWidth/2&&(this.selPoints[r].x=t.img.destLeft+(t.img.destLeft+t.img.destWidth-this.selPoints[r].x)),this.selPoints[r].ratioX=(this.selPoints[r].x-t.img.destLeft)/t.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-t.img.destTop)/t.img.destHeight}this.updateFHDCurPts()},t.prototype.pointsVerticalFlip=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++)if(t.pointColl[i].shapeFlip!==t.transform.currFlipState){t.points=e.extend([],t.pointColl[i].points,[]),this.pointCounter=0;for(var o=t.points.length,r=0;r<o;r++)t.points[r].y<=t.img.destTop+t.img.destHeight/2?t.points[r].y=t.img.destTop+t.img.destHeight-(t.points[r].y-t.img.destTop):t.points[r].y>=t.img.destTop+t.img.destHeight/2&&(t.points[r].y=t.img.destTop+(t.img.destTop+t.img.destHeight-t.points[r].y)),t.points[r].ratioX=(t.points[r].x-t.img.destLeft)/t.img.destWidth,t.points[r].ratioY=(t.points[r].y-t.img.destTop)/t.img.destHeight;t.pointColl[i].shapeFlip=t.transform.currFlipState}for(i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==t.transform.currFlipState){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y<=t.img.destTop+t.img.destHeight/2?this.selPoints[r].y=t.img.destTop+t.img.destHeight-(this.selPoints[r].y-t.img.destTop):this.selPoints[r].y>=t.img.destTop+t.img.destHeight/2&&(this.selPoints[r].y=t.img.destTop+(t.img.destTop+t.img.destHeight-this.selPoints[r].y)),this.selPoints[r].ratioX=(this.selPoints[r].x-t.img.destLeft)/t.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-t.img.destTop)/t.img.destHeight}this.updateFHDCurPts()},t.prototype.updateFHDColl=function(){for(var t=this.parent,i=0;i<t.objColl.length;i++){if(t.objColl[i].imageRatio={startX:(t.objColl[i].activePoint.startX-t.img.destLeft)/t.img.destWidth,startY:(t.objColl[i].activePoint.startY-t.img.destTop)/t.img.destHeight,endX:(t.objColl[i].activePoint.endX-t.img.destLeft)/t.img.destWidth,endY:(t.objColl[i].activePoint.endY-t.img.destTop)/t.img.destHeight,width:t.img.destWidth/t.objColl[i].activePoint.width,height:t.img.destHeight/t.objColl[i].activePoint.height},"path"===t.objColl[i].shape)for(var o=0;o<t.objColl[i].pointColl.length;o++)t.objColl[i].pointColl[o].ratioX=(t.objColl[i].pointColl[o].x-t.img.destLeft)/t.img.destWidth,t.objColl[i].pointColl[o].ratioY=(t.objColl[i].pointColl[o].y-t.img.destTop)/t.img.destHeight;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})}for(n=0;n<t.freehandCounter;n++){t.points=e.extend([],t.pointColl[n].points,[]),this.pointCounter=0;for(var r=t.points.length,a=0;a<r;a++)t.points[a].ratioX=(t.points[a].x-t.img.destLeft)/t.img.destWidth,t.points[a].ratioY=(t.points[a].y-t.img.destTop)/t.img.destHeight}for(var n=0;n<t.freehandCounter;n++)if(this.selPointColl[n]){this.selPoints=e.extend([],this.selPointColl[n].points,[]),this.pointCounter=0;for(var r=this.selPoints.length,a=0;a<r;a++)this.selPoints[a].ratioX=(this.selPoints[a].x-t.img.destLeft)/t.img.destWidth,this.selPoints[a].ratioY=(this.selPoints[a].y-t.img.destTop)/t.img.destHeight}},t.prototype.panFHDColl=function(t,i,o){for(var r=this.parent,a=0;a<r.freehandCounter;a++){r.points=e.extend([],r.pointColl[a].points,[]),this.pointCounter=0;for(var n=r.points.length,s=0;s<n;s++)""===o||"vertical"===o?r.points[s].x+=t:r.points[s].x-=t,""===o||"horizontal"===o?r.points[s].y+=i:r.points[s].y-=i}for(a=0;a<r.freehandCounter;a++)if(this.selPointColl[a]){this.selPoints=e.extend([],this.selPointColl[a].points,[]),this.pointCounter=0;for(var n=this.selPoints.length,s=0;s<n;s++)""===o||"vertical"===o?this.selPoints[s].x+=t:this.selPoints[s].x-=t,""===o||"horizontal"===o?this.selPoints[s].y+=i:this.selPoints[s].y-=i}this.freehandRedraw(this.lowerContext,null)},t.prototype.freeHandDraw=function(t){var i=this.parent;if(t){if(i.points=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.togglePen=!0,i.upperCanvas.style.cursor=i.cursor="crosshair",i.upperCanvas.style.display="block",e.isNullOrUndefined(i.activeObj.strokeSettings)){var o={strokeSettings:{}};i.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:o}}),i.activeObj.strokeSettings=o.strokeSettings}e.isNullOrUndefined(i.activeObj.strokeSettings.strokeWidth)&&(i.activeObj.strokeSettings.strokeWidth=4),e.isBlazor()?i.updateToolbar(i.element,"pen"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}else i.upperCanvas.style.cursor=i.cursor="default",i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}})),i.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},t.prototype.isFHDIdx=function(t,e){for(var i=!1,o=0;o<this.parent.freehandCounter;o++)if(this.parent.pointColl[o].id&&parseInt(this.parent.pointColl[o].id.split("_")[1],10)-1===t){i=!0;break}return e&&(e.isIndex=i),i},t.prototype.updateCropPtsForSel=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++){var o={selPointColl:e.extend([],this.selPointColl)};if(o.selPointColl[i]){this.selPoints=e.extend([],o.selPointColl[i].points,[]),this.pointCounter=0;for(var r=this.selPoints.length,a=0;a<r;a++)this.selPoints[a].ratioX=(this.selPoints[a].x-t.activeObj.activePoint.startX)/t.activeObj.activePoint.width,this.selPoints[a].ratioY=(this.selPoints[a].y-t.activeObj.activePoint.startY)/t.activeObj.activePoint.height}}},t}(),c=function(){function i(t){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=!1,this.isObjSelected=!1,this.isFhdPoint=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.isShapeInserted=!1,this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.cursorTargetId="",this.isPreventDragging=!1,this.dragElement="",this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.isFhdEditing=!1,this.currentDrawingShape="",this.initialPrevObj={},this.touchTime=0,this.resizedElement="",this.parent=t,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("selection",this.selection,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("selection",this.selection),this.parent.off("destroyed",this.destroy)},i.prototype.selection=function(t){var e=this;switch(this.updatePrivateVariables(),t.prop){case"mouse-up":this.selMouseUpEvent();break;case"setCursor":this.setCursor(t.value.x,t.value.y);break;case"updateActivePoint":this.updateActivePoint(t.value.x,t.value.y,t.value.isCropSelection);break;case"updateCursorStyles":this.updateCursorStyles(t.value.x,t.value.y,t.value.type);break;case"setTextSelection":this.setTextSelection(t.value.width,t.value.height);break;case"setActivePoint":this.setActivePoint(t.value.startX,t.value.startY);break;case"clearSelection":this.clearSelection();break;case"calcShapeRatio":this.calcShapeRatio(t.value.x,t.value.y,t.value.imgWidth,t.value.imgHeight);break;case"applyCurrShape":this.applyCurrShape(t.value.isShapeClick);break;case"tab":this.performTabAction();break;case"setDragDirection":this.setDragDirection(t.value.width,t.value.height);break;case"clearUpperCanvas":this.isTouch&&setTimeout(function(){e.parent.upperCanvas.getContext("2d").clearRect(0,0,e.parent.upperCanvas.width,e.parent.upperCanvas.height)},550);break;case"resetFreehandDrawVariables":this.isFhdEditing=this.isFhdPoint=!1;break;case"isShapeInserted":this.isShapeInserted=t.value.bool;break;case"redrawShape":this.redrawShape(t.value.obj);break;case"setTextBoxStylesToActObj":this.setTextBoxStylesToActObj();break;case"mouseDownEventHandler":this.mouseDownEventHandler(t.value.e);break;case"mouseMoveEventHandler":this.mouseMoveEventHandler(t.value.e);break;case"mouseUpEventHandler":this.mouseUpEventHandler(t.value.e);break;case"canvasMouseDownHandler":this.canvasMouseDownHandler(t.value.e);break;case"canvasMouseMoveHandler":this.canvasMouseMoveHandler(t.value.e);break;case"canvasMouseUpHandler":this.canvasMouseUpHandler(t.value.e);break;case"touchStartHandler":this.touchStartHandler(t.value.e);break;case"keyDownEventHandler":this.keyDownEventHandler(t.value.e);break;case"handleScroll":this.handleScroll(t.value.e);break;case"textKeyDown":setTimeout(this.textKeyDown.bind(this),1,t.value.e);break;case"deleteItem":this.deleteItem();break;case"updatePrevShapeSettings":this.updatePrevShapeSettings(t.value.obj);break;case"getZoomType":t.value.obj.zoomType=this.zoomType;break;case"setZoomType":this.zoomType=t.value.zoomType;break;case"setInitialTextEdit":this.isInitialTextEdited=t.value.bool;break;case"setDragCanvas":this.dragCanvas=t.value.bool;break;case"setFreehandDrawCustomized":this.isFhdCustomized=t.value.isFreehandDrawCustomized;break;case"setTouchEndPoint":this.touchEndPoint.x=t.value.x,this.touchEndPoint.y=t.value.y;break;case"getPanDown":t.value.obj.panDown=this.panDown;break;case"setPanDown":this.panDown=t.value.panDown;break;case"getFreehandDrawEditing":t.value.obj.bool=this.isFhdEditing;break;case"setFreehandDrawEditing":this.isFhdEditing=t.value.bool;break;case"getTempActObj":t.value.obj.tempObj=this.tempActiveObj;break;case"setTempActObj":this.tempActiveObj=t.value.obj;break;case"isInside":this.isInside(t.value.x,t.value.y,t.value.z1,t.value.z2,t.value.z3,t.value.z4);break;case"setDragElement":this.dragElement=t.value.value;break;case"setObjSelected":this.isObjSelected=t.value.bool;break;case"adjustActObjForLineArrow":this.adjustActObjForLineArrow(t.value.obj);break;case"findTarget":this.findTarget(t.value.x,t.value.y,t.value.type);break;case"getCurrentFlipState":this.getCurrentFlipState();break;case"setDragWidth":this.setDragWidth(t.value.width);break;case"setDragHeight":this.setDragHeight(t.value.setDragHeight);break;case"annotate":this.currentDrawingShape=t.value.shape,"text"===t.value.shape?(this.parent.activeObj.textSettings.fontSize=100,this.parent.activeObj.keyHistory="Enter Text",this.parent.notify("shape",{prop:"initializeTextShape",onPropertyChange:!1,value:{text:null,fontFamily:null,fontSize:null,bold:null,italic:null,strokeColor:null}})):"path"===t.value.shape&&(this.parent.activeObj.pointColl=[]);break;case"getCurrentDrawingShape":t.value.obj.shape=this.currentDrawingShape;break;case"setCurrentDrawingShape":this.currentDrawingShape=t.value.value;break;case"getTransRotationPoint":this.getTransRotationPoint(t.value.obj,t.value.object);break;case"adjustNEPoints":this.adjustNEPoints(t.value.rectangle,t.value.x,t.value.y,t.value.angle);break;case"adjustRotationPoints":this.adjustRotationPoints(t.value.rectangle,t.value.x,t.value.y,t.value.angle);break;case"getResizeDirection":this.getResizeDirection(t.value.rectangle,t.value.x,t.value.y,t.value.angle);break;case"setResizedElement":this.resizedElement=t.value.value;break;case"reset":this.reset()}},i.prototype.getModuleName=function(){return"selection"},i.prototype.updatePrivateVariables=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=this.isObjSelected=this.isFhdPoint=this.isShapeInserted=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.cursorTargetId=this.dragElement="",this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.isPreventDragging=!1,this.timer=void 0,this.tempObjColl=void 0,this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.panDown=null,this.isFhdEditing=!1,this.pathAdjustedIndex=null,this.touchTime=0,this.currentDrawingShape="",this.initialPrevObj={},this.resizedElement=""},i.prototype.performTabAction=function(){if("block"===this.parent.textArea.style.display){var t=this.applyCurrShape(!1);this.parent.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t&&this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},i.prototype.selMouseUpEvent=function(){this.oldPoint.x=void 0,this.oldPoint.y=void 0},i.prototype.getMouseCursor=function(t,e,i,o,r){var a=this.getTransRotationPoint(t),n=r?0:2*t.topLeftCircle.radius;return e>=t.topLeftCircle.startX-n&&e<=t.topLeftCircle.startX+n&&i>=t.topLeftCircle.startY-n&&i<=t.topLeftCircle.startY+n?"nw-resize":e>=t.topLeftCircle.startX-n&&e<=t.topRightCircle.startX-n&&i>=t.topCenterCircle.startY-n&&i<=t.topCenterCircle.startY+n?"n-resize":e>=t.topRightCircle.startX-n&&e<=t.topRightCircle.startX+n&&i>=t.topRightCircle.startY-n&&i<=t.topRightCircle.startY+n?"ne-resize":e>=t.centerLeftCircle.startX-n&&e<=t.centerLeftCircle.startX+n&&i>=t.topLeftCircle.startY-n&&i<=t.bottomLeftCircle.startY-n?"w-resize":e>=t.centerRightCircle.startX-n&&e<=t.centerRightCircle.startX+n&&i>=t.topRightCircle.startY-n&&i<=t.bottomRightCircle.startY-n?"e-resize":e>=t.bottomLeftCircle.startX-n&&e<=t.bottomLeftCircle.startX+n&&i>=t.bottomLeftCircle.startY-n&&i<=t.bottomLeftCircle.startY+n?"sw-resize":e>=t.bottomLeftCircle.startX-n&&e<=t.bottomRightCircle.startX-n&&i>=t.bottomCenterCircle.startY-n&&i<=t.bottomCenterCircle.startY+n?"s-resize":e>=t.bottomRightCircle.startX-n&&e<=t.bottomRightCircle.startX+n&&i>=t.bottomRightCircle.startY-n&&i<=t.bottomRightCircle.startY+n?"se-resize":e>=t.activePoint.startX&&e<=t.activePoint.endX&&i>=t.activePoint.startY&&i<=t.activePoint.endY?o?"grab":"move":a&&!r&&e>=a.x-(t.bottomCenterCircle.radius+2)&&e<=a.x+(t.bottomCenterCircle.radius+2)&&i>=a.y-(t.bottomCenterCircle.radius+2)&&i<=a.y+(t.bottomCenterCircle.radius+2)?"grabbing":"default"},i.prototype.setCursor=function(t,i){var o,r=this.parent,a=document.querySelector("#"+r.element.id+"_lowerCanvas"),n=document.querySelector("#"+r.element.id+"_upperCanvas"),s=!1;if(""!==this.currentDrawingShape)return void(n.style.cursor=r.cursor="crosshair");if(r.currObjType.isDragging)return void(""===this.dragElement?n.style.cursor=r.cursor="move":n.style.cursor=r.cursor=this.dragElement);if(void 0!==r.activeObj.horTopLine){void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-")),void 0===o&&r.currObjType.isCustomCrop?s=!0:void 0!==o&&"crop"===o[0]&&(s=!0),!s&&r.togglePan&&(a.style.cursor=n.style.cursor=r.cursor="grab");var l=n.style.cursor,p=e.extend({},r.activeObj,{},!0);this.cursorTargetId=p.currIndex;var h=void 0;(h=0===p.shapeDegree?r.transform.degree:r.transform.degree-p.shapeDegree)<0&&(h=360+h),"line"===p.shape||"arrow"===p.shape?this.setCursorForLineArrow(p,t,i,n):"path"===p.shape?this.setCursorForPath(p,t,i,n):e.isNullOrUndefined(p.rotatedAngle)||0===p.rotatedAngle?(n.style.cursor=r.cursor=this.getMouseCursor(p,t,i,s,!1),"text"!==p.shape||"n-resize"!==r.cursor&&"s-resize"!==r.cursor&&"e-resize"!==r.cursor&&"w-resize"!==r.cursor||(n.style.cursor=r.cursor="move")):this.setCursorForRotatedObject(p,t,i,n),"default"===l&&"default"===r.cursor&&s&&(n.style.cursor=r.cursor="grab"),"grab"===l&&"default"===r.cursor&&(n.style.cursor=r.cursor="grab")}else r.togglePan&&!r.togglePen?a.style.cursor=n.style.cursor=r.cursor="grab":r.currObjType.isCustomCrop||r.togglePen?n.style.cursor=r.cursor="crosshair":n.style.cursor=r.cursor="default";if("default"===r.cursor||"grab"===r.cursor){l=n.style.cursor;r.objColl.length>0&&("grab"!==r.cursor||!s)&&this.setCursorFromObj(t,i,r.objColl,n,s),"grab"===l&&"default"===r.cursor&&(n.style.cursor=r.cursor="grab")}"default"!==r.cursor&&"grab"!==r.cursor||!r.pointColl[0]||"grab"===r.cursor&&s||r.currObjType.isDragging||r.currObjType.isResize||this.setCursorForFreehandDrawing(t,i,n)},i.prototype.setCursorForPath=function(t,i,o,r){this.setCursorForLineArrow(t,i,o,r);var a=this.parent;if("default"===a.cursor)for(var n=e.extend({},t,null,!0),s=!1,l=1;l<t.pointColl.length&&!s;l++){n.activePoint.startX=t.pointColl[l-1].x,n.activePoint.startY=t.pointColl[l-1].y,n.activePoint.endX=t.pointColl[l].x,n.activePoint.endY=t.pointColl[l].y,a.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:n}});for(var p=0;p<n.pointColl.length;p++){var h=n.pointColl[p];if(!e.isNullOrUndefined(h.x-2*t.topLeftCircle.radius)&&!e.isNullOrUndefined(h.x+2*t.topLeftCircle.radius)&&!e.isNullOrUndefined(h.y-2*t.topLeftCircle.radius)&&!e.isNullOrUndefined(h.y+2*t.topLeftCircle.radius)&&i>=h.x-2*t.topLeftCircle.radius&&i<=h.x+2*t.topLeftCircle.radius&&o>=h.y-2*t.topLeftCircle.radius&&o<=h.y+2*t.topLeftCircle.radius){r.style.cursor=a.cursor="move",s=!0;break}r.style.cursor=a.cursor="default"}}return a.cursor},i.prototype.setCursorForLineArrow=function(t,e,i,o){for(var r,a=0;a<t.pointColl.length;a++){var n=t.pointColl[a];if(e>=n.x-2*t.topLeftCircle.radius&&e<=n.x+2*t.topLeftCircle.radius&&i>=n.y-2*t.topLeftCircle.radius&&i<=n.y+2*t.topLeftCircle.radius){o.style.cursor=this.parent.cursor="move",r=a;break}o.style.cursor=this.parent.cursor="default"}return r},i.prototype.setCursorForRotatedObject=function(t,e,i,o){this.resizedElement="";var r=this.parent;if(e>=t.horTopLinePointColl[0].x-(t.bottomCenterCircle.radius+2)&&e<=t.horTopLinePointColl[0].x+(t.bottomCenterCircle.radius+2)&&i>=t.horTopLinePointColl[0].y-(t.bottomCenterCircle.radius+2)&&i<=t.horTopLinePointColl[0].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="nw-resize":e>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].x-5&&e<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].x+5&&i>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].y-5&&i<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="n-resize":e>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].x-(t.bottomCenterCircle.radius+2)&&e<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].x+(t.bottomCenterCircle.radius+2)&&i>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].y-(t.bottomCenterCircle.radius+2)&&i<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="ne-resize":e>=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].x-5&&e<=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].x+5&&i>=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].y-5&&i<=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="w-resize":e>=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].x-5&&e<=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].x+5&&i>=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].y-5&&i<=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="e-resize":e>=t.horBottomLinePointColl[0].x-(t.bottomCenterCircle.radius+2)&&e<=t.horBottomLinePointColl[0].x+(t.bottomCenterCircle.radius+2)&&i>=t.horBottomLinePointColl[0].y-(t.bottomCenterCircle.radius+2)&&i<=t.horBottomLinePointColl[0].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="sw-resize":e>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].x-5&&e<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].x+5&&i>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].y-5&&i<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="s-resize":e>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].x-(t.bottomCenterCircle.radius+2)&&e<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].x+(t.bottomCenterCircle.radius+2)&&i>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].y-(t.bottomCenterCircle.radius+2)&&i<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="se-resize":t.rotationCirclePointColl&&e>=t.rotationCirclePointColl.x-(t.bottomCenterCircle.radius+2)&&e<=t.rotationCirclePointColl.x+(t.bottomCenterCircle.radius+2)&&i>=t.rotationCirclePointColl.y-(t.bottomCenterCircle.radius+2)&&i<=t.rotationCirclePointColl.y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="grabbing":(o.style.cursor=r.cursor="default",this.getRectanglePoints(t.activePoint.startX,t.activePoint.startY,t.activePoint.width,t.activePoint.height,t.rotatedAngle*(180/Math.PI),e,i)&&(o.style.cursor=r.cursor="move")),"default"===r.cursor)for(var a=0,n=t.horTopLinePointColl.length;a<n;a++)if(e>=t.horTopLinePointColl[a].x-5&&e<=t.horTopLinePointColl[a].x+5&&i>=t.horTopLinePointColl[a].y-5&&i<=t.horTopLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="n-resize";break}if("default"===r.cursor)for(var a=0,n=t.horBottomLinePointColl.length;a<n;a++)if(e>=t.horBottomLinePointColl[a].x-5&&e<=t.horBottomLinePointColl[a].x+5&&i>=t.horBottomLinePointColl[a].y-5&&i<=t.horBottomLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="s-resize";break}if("default"===r.cursor)for(var a=0,n=t.verLeftLinePointColl.length;a<n;a++)if(e>=t.verLeftLinePointColl[a].x-5&&e<=t.verLeftLinePointColl[a].x+5&&i>=t.verLeftLinePointColl[a].y-5&&i<=t.verLeftLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="w-resize";break}if("default"===r.cursor)for(var a=0,n=t.verRightLinePointColl.length;a<n;a++)if(e>=t.verRightLinePointColl[a].x-5&&e<=t.verRightLinePointColl[a].x+5&&i>=t.verRightLinePointColl[a].y-5&&i<=t.verRightLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="e-resize";break}return this.adjustCursorStylesForRotatedState(t),r.cursor},i.prototype.adjustCursorStylesForRotatedState=function(t){var e=this.parent,i=t.rotatedAngle*(180/Math.PI);if((i=i>0?Math.floor(i):Math.ceil(i))>=92&&i<=182||i>=-178&&i<=-88){var o={"nw-resize":"ne-resize","n-resize":"s-resize","ne-resize":"nw-resize","w-resize":"e-resize","e-resize":"w-resize","sw-resize":"se-resize","s-resize":"n-resize","se-resize":"sw-resize"};e.cursor in o&&(e.cursor=o[e.cursor])}return e.upperCanvas.style.cursor=this.getResizeElement(t.rotatedAngle*(180/Math.PI),e.cursor),e.cursor},i.prototype.getResizeElement=function(t,e){var i=[];"nw-resize"===e?i=[[337.5,22.5,"nw-resize"],[22.5,67.5,"n-resize"],[67.5,112.5,"ne-resize"],[112.5,157.5,"e-resize"],[157.5,202.5,"se-resize"],[202.5,247.5,"s-resize"],[247.5,292.5,"sw-resize"],[292.5,337.5,"w-resize"]]:"n-resize"===e?i=[[337.5,22.5,"n-resize"],[22.5,67.5,"ne-resize"],[67.5,112.5,"e-resize"],[112.5,157.5,"se-resize"],[157.5,202.5,"s-resize"],[202.5,247.5,"sw-resize"],[247.5,292.5,"w-resize"],[292.5,337.5,"nw-resize"]]:"ne-resize"===e?i=[[337.5,22.5,"ne-resize"],[22.5,67.5,"e-resize"],[67.5,112.5,"se-resize"],[112.5,157.5,"s-resize"],[157.5,202.5,"sw-resize"],[202.5,247.5,"w-resize"],[247.5,292.5,"nw-resize"],[292.5,337.5,"n-resize"]]:"e-resize"===e?i=[[337.5,22.5,"e-resize"],[22.5,67.5,"se-resize"],[67.5,112.5,"s-resize"],[112.5,157.5,"sw-resize"],[157.5,202.5,"w-resize"],[202.5,247.5,"nw-resize"],[247.5,292.5,"n-resize"],[292.5,337.5,"ne-resize"]]:"se-resize"===e?i=[[337.5,22.5,"se-resize"],[22.5,67.5,"s-resize"],[67.5,112.5,"sw-resize"],[112.5,157.5,"w-resize"],[157.5,202.5,"nw-resize"],[202.5,247.5,"n-resize"],[247.5,292.5,"ne-resize"],[292.5,337.5,"e-resize"]]:"s-resize"===e?i=[[337.5,22.5,"s-resize"],[22.5,67.5,"sw-resize"],[67.5,112.5,"w-resize"],[112.5,157.5,"nw-resize"],[157.5,202.5,"n-resize"],[202.5,247.5,"ne-resize"],[247.5,292.5,"e-resize"],[292.5,337.5,"se-resize"]]:"sw-resize"===e?i=[[337.5,22.5,"sw-resize"],[22.5,67.5,"w-resize"],[67.5,112.5,"nw-resize"],[112.5,157.5,"n-resize"],[157.5,202.5,"ne-resize"],[202.5,247.5,"e-resize"],[247.5,292.5,"se-resize"],[292.5,337.5,"s-resize"]]:"w-resize"===e&&(i=[[337.5,22.5,"w-resize"],[22.5,67.5,"nw-resize"],[67.5,112.5,"n-resize"],[112.5,157.5,"ne-resize"],[157.5,202.5,"e-resize"],[202.5,247.5,"se-resize"],[247.5,292.5,"s-resize"],[292.5,337.5,"sw-resize"]]);for(var o=t<0?360-Math.abs(t):t,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return e},i.prototype.setCursorForFreehandDrawing=function(t,i,o){var r=o.getContext("2d"),a=this.parent,n=document.querySelector("#"+a.element.id+"_textArea"),s=!1;a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:-1}});for(var l,p=0;p<a.freehandCounter;p++){var h={selPointColl:{}};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),l=e.extend([],h.selPointColl[p].points,[]),a.points=e.extend([],a.pointColl[p].points,[]),a.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var c=l.length,d=0;d<c;d++)if(0!==d){var v=!1;if(l[d-1]&&l[d]&&(v=this.isInside(t,i,l[d-1].x,l[d-1].y,l[d].x,l[d].y)),v){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}else a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:null}});this.isFhdPoint=!1}}else{if(t>a.points[d].x-a.pointColl[p].strokeWidth&&t<a.points[d].x+a.pointColl[p].strokeWidth&&i>a.points[d].y-a.pointColl[p].strokeWidth&&i<a.points[d].y+a.pointColl[p].strokeWidth){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){var u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}this.isFhdPoint=!1}}if(s)break}},i.prototype.setCursorFromObj=function(t,i,o,r,a){for(var n=this.parent,s=0,l=o.length;s<l;s++){if("move"===n.cursor)return;var p=e.extend({},o[s],{},!0);this.cursorTargetId=p.currIndex,"line"===p.shape||"arrow"===p.shape?this.setCursorForLineArrow(p,t,i,r):"path"===p.shape?this.setCursorForPath(p,t,i,r):e.isNullOrUndefined(p.rotatedAngle)||0===p.rotatedAngle?r.style.cursor=n.cursor=this.getMouseCursor(p,t,i,a,!0):this.setCursorForRotatedObject(p,t,i,r)}},i.prototype.isInside=function(t,e,i,o,r,a){var n=Math.min(i,r),s=Math.max(i,r),l=Math.min(o,a),p=Math.max(o,a);return n<=t&&t<=s&&l<=e&&e<=p},i.prototype.updateActivePoint=function(t,i,o){var r=this.parent,a={width:0,height:0};r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:r.activeObj.activePoint.width,height:r.activeObj.activePoint.height,obj:a}});var n=a,s=this.updatePrevShapeSettings(),l={action:"resize",previousShapeSettings:s},p={action:"move",previousShapeSettings:s};e.isNullOrUndefined(this.shapeResizingArgs)&&(this.shapeResizingArgs=l),e.isNullOrUndefined(this.shapeMovingArgs)&&(this.shapeMovingArgs=p),"text"===r.activeObj.shape&&""!==this.dragElement&&r.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:r.activeObj,isTextArea:null}}),""===this.currentDrawingShape||""!==this.dragElement&&"move"!==this.dragElement||("line"===r.activeObj.shape||"arrow"===r.activeObj.shape||"path"===r.activeObj.shape?this.dragElement="e-resize":t>r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="se-resize":t<r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="sw-resize":t>r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY?this.dragElement="ne-resize":t<r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY&&(this.dragElement="nw-resize")),"arrow"===r.activeObj.shape&&(Math.atan2(t-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)>0?r.activeObj.rotatedAngle=-Math.atan2(t-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2):r.activeObj.rotatedAngle=Math.abs(Math.atan2(t-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)));var h,c=!1,d=!1;switch(this.dragElement.toLowerCase()){case"nw-resize":this.updateNWPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"n-resize":this.updateNPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"ne-resize":this.updateNEPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"w-resize":this.updateWPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"e-resize":this.updateEPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"sw-resize":this.updateSWPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"s-resize":this.updateSPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"se-resize":this.updateSEPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"grabbing":Math.atan2(t-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))>0?r.activeObj.rotatedAngle=-Math.atan2(t-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2)):r.activeObj.rotatedAngle=Math.abs(Math.atan2(t-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))),(h=0===r.activeObj.shapeDegree?r.transform.degree:r.transform.degree-r.activeObj.shapeDegree)<0&&(h=360+h);for(var v=0,u=r.activeObj.flipObjColl.length;v<u;v++)"horizontal"===r.activeObj.flipObjColl[v].toLowerCase()?c=!0:"vertical"===r.activeObj.flipObjColl[v].toLowerCase()&&(d=!0);r.activeObj.rotatedAngle-=h*(Math.PI/180),0===h||360===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):90===h||-270===h?c&&(r.activeObj.rotatedAngle-=Math.PI/180*180):180===h||-180===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):270!==h&&-90!==h||c&&(r.activeObj.rotatedAngle-=Math.PI/180*180);break;case"pathdrag":e.isNullOrUndefined(this.pathAdjustedIndex)||(r.activeObj.pointColl[this.pathAdjustedIndex].x=t,r.activeObj.pointColl[this.pathAdjustedIndex].y=i);break;default:if(!o&&!r.currObjType.isCustomCrop){if(this.dragPoint.startX){var g=this.dragPoint.endX-this.previousPoint.x,b=this.dragPoint.endY-this.previousPoint.y;if(r.activeObj.activePoint.startX+=g,r.activeObj.activePoint.endX+=g,r.activeObj.activePoint.startY+=b,r.activeObj.activePoint.endY+=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x+=g,r.activeObj.rotationCirclePointColl.y+=b,r.activeObj.rotationCirclePoint.x+=g,r.activeObj.rotationCirclePoint.y+=b),"path"===r.activeObj.shape)for(var v=0,u=r.activeObj.pointColl.length;v<u;v++)r.activeObj.pointColl[v].x+=g,r.activeObj.pointColl[v].y+=b;!this.isPreventDragging&&(r.activeObj.activePoint.startX<r.img.destLeft||r.activeObj.activePoint.startY<r.img.destTop||r.activeObj.activePoint.endX>r.img.destLeft+r.img.destWidth||r.activeObj.activePoint.endY>r.img.destTop+r.img.destHeight)&&(r.activeObj.activePoint.startX-=g,r.activeObj.activePoint.endX-=g,r.activeObj.activePoint.startY-=b,r.activeObj.activePoint.endY-=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x-=g,r.activeObj.rotationCirclePointColl.y-=b,r.activeObj.rotationCirclePoint.x-=g,r.activeObj.rotationCirclePoint.y-=b),this.setDragWidth(g),this.setDragHeight(b))}else r.activeObj.activePoint.startX=t<this.mouseDownPoint.x?t:this.mouseDownPoint.x,r.activeObj.activePoint.startY=i<this.mouseDownPoint.y?i:this.mouseDownPoint.y,t=t<this.mouseDownPoint.x?this.mouseDownPoint.x:t,i=i<this.mouseDownPoint.y?this.mouseDownPoint.y:i,r.activeObj.activePoint.endX=t,r.activeObj.activePoint.endY=i;this.triggerShapeChange(l,p,"move")}}},i.prototype.triggerShapeChange=function(t,i,o){var r=this.parent;r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY;var a=this.updatePrevShapeSettings();if(t.currentShapeSettings=a,i.currentShapeSettings=a,"resize"===o){this.isCropSelection=!1;var n=void 0;if(void 0!==r.activeObj.shape&&(n=r.activeObj.shape.split("-")),void 0!==n&&"crop"===n[0]&&(this.isCropSelection=!0),!this.isCropSelection&&"resize"!==this.parent.eventType&&e.isBlazor()&&r.events&&!0===this.parent.events.onShapeResizeStart.hasDelegate)t.action="resize-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeStart",t).then(function(t){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})});else if(this.isCropSelection){var s={action:t.action,previousSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:t.previousShapeSettings.startX,startY:t.previousShapeSettings.startY,width:t.previousShapeSettings.width,height:t.previousShapeSettings.height},currentSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:t.currentShapeSettings.startX,startY:t.currentShapeSettings.startY,width:t.currentShapeSettings.width,height:t.currentShapeSettings.height}};e.isNullOrUndefined(this.selectionResizingArgs)&&(this.selectionResizingArgs=s),e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onSelectionResizeStart.hasDelegate?(s.action="resize-start",r.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(t){r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:t.currentSelectionSettings}})})):(r.trigger("selectionChanging",s),r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}))}else r.trigger("shapeChanging",t),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})}else e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onShapeDragStart.hasDelegate?(i.action="drag-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragStart",i).then(function(t){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})})):(r.trigger("shapeChanging",i),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:i.currentShapeSettings}}));this.parent.eventType=o},i.prototype.setDragWidth=function(t){var e=this.parent,i=t;if(i>=0)for(o=0;o<i&&(t=i-o,e.activeObj.activePoint.startX+=t,e.activeObj.activePoint.endX+=t,!(e.activeObj.activePoint.startX>=e.img.destLeft&&e.activeObj.activePoint.endX<=e.img.destLeft+e.img.destWidth));o++)e.activeObj.activePoint.startX-=t,e.activeObj.activePoint.endX-=t;else for(var o=1;o<Math.abs(i)&&(t=i+o,e.activeObj.activePoint.startX+=t,e.activeObj.activePoint.endX+=t,!(e.activeObj.activePoint.startX>=e.img.destLeft&&e.activeObj.activePoint.endX<=e.img.destLeft+e.img.destWidth));o++)e.activeObj.activePoint.startX-=t,e.activeObj.activePoint.endX-=t},i.prototype.setDragHeight=function(t){var e=this.parent,i=t;if(i>=0)for(o=1;o<i&&(t=i-o,e.activeObj.activePoint.startY+=t,e.activeObj.activePoint.endY+=t,!(e.activeObj.activePoint.startY>=e.img.destTop&&e.activeObj.activePoint.endY<=e.img.destTop+e.img.destHeight));o++)e.activeObj.activePoint.startY-=t,e.activeObj.activePoint.endY-=t;else for(var o=0;o<Math.abs(i)&&(t=i+o,e.activeObj.activePoint.startY+=t,e.activeObj.activePoint.endY+=t,!(e.activeObj.activePoint.startY>=e.img.destTop&&e.activeObj.activePoint.endY<=e.img.destTop+e.img.destHeight));o++)e.activeObj.activePoint.startY-=t,e.activeObj.activePoint.endY-=t},i.prototype.limitDrag=function(t){var e=this.parent,i=t?e.activeObj.activePoint.startX:e.activeObj.activePoint.endX,o=t?e.activeObj.activePoint.startY:e.activeObj.activePoint.endY,r=t?e.activeObj.activePoint.endX:e.activeObj.activePoint.startX,a=t?e.activeObj.activePoint.endY:e.activeObj.activePoint.startY;i<e.img.destLeft&&(i=e.img.destLeft),o<e.img.destTop&&(o=e.img.destTop),r>e.img.destLeft+e.img.destWidth&&(r=e.img.destLeft+e.img.destWidth),a>e.img.destTop+e.img.destHeight&&(a=e.img.destTop+e.img.destHeight),t?(e.activeObj.activePoint.startX=i,e.activeObj.activePoint.startY=o,e.activeObj.activePoint.endX=r,e.activeObj.activePoint.endY=a):(e.activeObj.activePoint.startX=r,e.activeObj.activePoint.startY=a,e.activeObj.activePoint.endX=i,e.activeObj.activePoint.endY=o)},i.prototype.preventDraggingInvertly=function(){var t=this.parent;this.isPreventDragging||0!==t.activeObj.rotatedAngle||(this.limitDrag(!0),"line"!==t.activeObj.shape&&"arrow"!==t.activeObj.shape&&"path"!==t.activeObj.shape||this.limitDrag(!1))},i.prototype.preventTextDraggingInvertly=function(){var t=this.parent,e=!1;return this.isPreventDragging||(t.activeObj.activePoint.startX<t.img.destLeft||t.activeObj.activePoint.startY<t.img.destTop||t.activeObj.activePoint.endX>t.img.destLeft+t.img.destWidth||t.activeObj.activePoint.endY>t.img.destTop+t.img.destHeight)&&(e=!0),e},i.prototype.preventInverseResize=function(t){var e=this.parent;e.activeObj.activePoint.width<0&&(e.activeObj.activePoint.width=0,e.activeObj.activePoint.startX=t.activePoint.startX,e.activeObj.activePoint.endX=t.activePoint.endX),e.activeObj.activePoint.height<0&&(e.activeObj.activePoint.height=0,e.activeObj.activePoint.startY=t.activePoint.startY,e.activeObj.activePoint.endY=t.activePoint.endY)},i.prototype.getScaleRatio=function(t){var e=this.parent,i={x:t,y:t};if(e.activeObj.shape&&"crop-custom"!==e.activeObj.shape&&"crop-circle"!==e.activeObj.shape&&"crop-square"!==e.activeObj.shape){var o=e.activeObj.shape.split("-");if(o.length>1){o=o[1].split(":");var r=t/parseInt(o[1],10);i.x=r*parseInt(o[0],10),i.y=r*parseInt(o[1],10)}}return i},i.prototype.updateNWPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=l.activeObj.activePoint.startX-t,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=this.oldPoint.x-t,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustNWPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){var v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<t&&l.activeObj.activePoint.startY<i){r=t-l.activeObj.activePoint.startX,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.startY+=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,g=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.startY<g)&&(l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.startY-=b.y)}else{r=l.activeObj.activePoint.startX-t,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.startY-=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,C=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.startY<C)&&(l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.startY+=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateNPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.startY>a.activeObj.activePoint.endY){var s=a.activeObj.activePoint.startY;a.activeObj.activePoint.startY=a.activeObj.activePoint.endY,a.activeObj.activePoint.endY=s,this.dragElement=this.resizedElement="s-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>t&&a.activeObj.activePoint.startY<e){i=a.activeObj.activePoint.endX-t,o=e-a.activeObj.activePoint.startY,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y)}else{i=t-a.activeObj.activePoint.endX,o=a.activeObj.activePoint.startY-e,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateNEPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=t-l.activeObj.activePoint.endX,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=t-this.oldPoint.x,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustNEPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){v=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){var v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>t&&l.activeObj.activePoint.startY<i){r=l.activeObj.activePoint.endX-t,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.startY+=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.startY<g)&&(l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.startY-=b.y)}else{r=t-l.activeObj.activePoint.endX,a=l.activeObj.activePoint.startY-i,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.startY-=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.startY<g)&&(l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.startY+=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateWPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startX=t,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.startY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="e-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.startX>a.activeObj.activePoint.endX){var s=a.activeObj.activePoint.startX;a.activeObj.activePoint.startX=a.activeObj.activePoint.endX,a.activeObj.activePoint.endX=s,this.dragElement=this.resizedElement="e-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.startX<t&&a.activeObj.activePoint.endY>e){i=t-a.activeObj.activePoint.startX,o=a.activeObj.activePoint.endY-e,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=a.activeObj.activePoint.startX-t,o=e-a.activeObj.activePoint.endY,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateEPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endX=t,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.endY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="w-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.endX<a.activeObj.activePoint.startX){var s=a.activeObj.activePoint.endX;a.activeObj.activePoint.endX=a.activeObj.activePoint.startX,a.activeObj.activePoint.startX=s,this.dragElement=this.resizedElement="w-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>t&&a.activeObj.activePoint.endY>e){i=a.activeObj.activePoint.endX-t,o=a.activeObj.activePoint.endY-e,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=t-a.activeObj.activePoint.endX,o=e-a.activeObj.activePoint.endY,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSWPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)e.isNullOrUndefined(this.oldPoint.x)&&e.isNullOrUndefined(this.oldPoint.y)?(this.diffPoint.x=l.activeObj.activePoint.startX-t,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=this.oldPoint.x-t,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.endY+=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.endY-=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustSWPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){var v=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<t&&l.activeObj.activePoint.endY>i){r=t-l.activeObj.activePoint.startX,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.endY-=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.endY+=b.y)}else{r=l.activeObj.activePoint.startX-t,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.endY+=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.endY-=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateSPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.endY<a.activeObj.activePoint.startY){var s=a.activeObj.activePoint.endY;a.activeObj.activePoint.endY=a.activeObj.activePoint.startY,a.activeObj.activePoint.startY=s,this.dragElement=this.resizedElement="n-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>t&&a.activeObj.activePoint.endY>e){i=a.activeObj.activePoint.endX-t,o=a.activeObj.activePoint.endY-e,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=t-a.activeObj.activePoint.endX,o=e-a.activeObj.activePoint.endY,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.x,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSEPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=t-l.activeObj.activePoint.endX,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=t-this.oldPoint.x,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x>=p&&this.diffPoint.y>=h?Math.max(this.diffPoint.x,this.diffPoint.y):Math.min(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/50*s,l.activeObj.activePoint.endY+=o.height/50*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/50*s,l.activeObj.activePoint.endY-=o.height/50*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustSEPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){v=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){var v=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>t&&l.activeObj.activePoint.endY>i){r=l.activeObj.activePoint.endX-t,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.endY-=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.endY+=b.y)}else{r=t-l.activeObj.activePoint.endX,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.endY+=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.endY-=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.adjustNWPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.endX,t.endY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.endX=l[0],t.endY=l[1],t.startY=p[1],t.startX=p[0],t.width=t.endX-t.startX,t.height=t.endY-t.startY,t},i.prototype.adjustNEPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.startX,t.endY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.startX=l[0],t.endY=l[1],t.width=p[0]-l[0],t.height=l[1]-p[1],t.endX=t.startX+t.width,t.startY=t.endY-t.height,t},i.prototype.adjustSWPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.endX,t.startY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.endX=l[0],t.startY=l[1],t.startX=p[0],t.endY=p[1],t.width=t.endX-t.startX,t.height=t.endY-t.startY,t},i.prototype.adjustSEPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.startX,t.startY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.startX=l[0],t.startY=l[1],t.width=p[0]-l[0],t.height=p[1]-l[1],t.endX=t.startX+t.width,t.endY=t.startY+t.height,t},i.prototype.adjustRotationPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2;this.getResizeDirection(t,e,i,o);var n=this.rotatePoints(t.startX,t.startY,r,a,o),s=this.rotatePoints(t.endX,t.startY,r,a,o),l=this.rotatePoints(t.endX,t.endY,r,a,o),p=this.rotatePoints(t.startX,t.endY,r,a,o),h=[(n[0]+l[0])/2,(n[1]+l[1])/2],c=this.rotatePoints(n[0],n[1],h[0],h[1],-o),d=this.rotatePoints(p[0],p[1],h[0],h[1],-o),v=this.rotatePoints(s[0],s[1],h[0],h[1],-o);return t.startX=c[0],t.startY=c[1],t.endX=v[0],t.endY=d[1],t.width=t.endX-t.startX,t.height=t.endY-t.startY,t},i.prototype.rotatePoints=function(t,e,i,o,r){return[(t-i)*Math.cos(r)-(e-o)*Math.sin(r)+i,(t-i)*Math.sin(r)+(e-o)*Math.cos(r)+o]},i.prototype.setResizedValue=function(t,e,i,o){switch(t){case"x":e+=i;break;case"y":e+=o;break;case"abs-x":e+=i>0?-i:Math.abs(i);break;case"abs-y":e+=o>0?-o:Math.abs(o);break;case"y-abs-x":e+=o+(i>0?-i:Math.abs(i))/2;break;case"abs-x-abs-y":e+=(i>0?-i:Math.abs(i))+(o>0?-o:Math.abs(o))/2;break;case"abs-y-x":e+=(o>0?-o:Math.abs(o))+i/2;break;case"x-y":e+=i+o/2}return e},i.prototype.getResizeDirection=function(t,e,i,o){var r=o*(180/Math.PI),a=this.getResizedElement(r,this.resizedElement);"e-resize"===this.resizedElement?(t.width=this.setResizedValue(a,t.width,e,i),t.endX=t.width+t.startX):"n-resize"===this.resizedElement?(t.startY=this.setResizedValue(a,t.startY,e,i),t.height=t.endY-t.startY):"w-resize"===this.resizedElement?(t.startX=this.setResizedValue(a,t.startX,e,i),t.width=t.startX+t.endX):"s-resize"===this.resizedElement&&(t.height=this.setResizedValue(a,t.height,e,i),t.endY=t.height+t.startY)},i.prototype.getResizedElement=function(t,e){var i=[];"n-resize"===e?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"e-resize"===e?i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]:"s-resize"===e?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"w-resize"===e&&(i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]);for(var o=t<0?360-Math.abs(t):t,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return e},i.prototype.updateCursorStyles=function(t,i,o){var r=this.parent,a=!1;""===r.activeObj.keyHistory||void 0!==r.activeObj.shape||r.currObjType.isCustomCrop||r.currObjType.isLine||!r.currObjType.isText||(r.activeObj.shape="text");var n=e.extend({},r.activeObj,{},!0);if(!e.isNullOrUndefined(n.topLeftCircle)){var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),this.isObjSelected)if("line"===n.shape||"arrow"===n.shape)a=this.updateCursorStylesForLineArrow(t,i,n);else if("path"===n.shape)a=this.updateCursorStylesForPath(t,i,n);else if(n.rotatedAngle)this.setCursorForRotatedObject(n,t,i,r.upperCanvas),"grabbing"===r.cursor?(r.upperCanvas.style.cursor=this.parent.cursor="grabbing",this.dragElement=r.cursor):"move"===r.cursor?(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i):"default"!==r.cursor&&(a=!0,this.dragElement=r.cursor,r.currObjType.isResize=!0);else{var l=this.getTransRotationPoint(n);t>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.topLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.topLeftCircle.startY+2*n.topLeftCircle.radius&&"nw-resize"!==this.dragElement?(n.topLeftCircle.startX=n.topLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="nw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.topRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.topCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.topCenterCircle.startY+2*n.topLeftCircle.radius&&"n-resize"!==this.dragElement?(n.topCenterCircle.startX=n.topCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="n-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.topRightCircle.startX-2*n.topLeftCircle.radius&&t<=n.topRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.topRightCircle.startY+2*n.topLeftCircle.radius&&"ne-resize"!==this.dragElement?(n.topRightCircle.startX=n.topRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="ne-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.centerLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.centerLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&"w-resize"!==this.dragElement?(n.centerLeftCircle.startX=n.centerLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="w-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.centerRightCircle.startX-2*n.topLeftCircle.radius&&t<=n.centerRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&"e-resize"!==this.dragElement?(n.centerRightCircle.startX=n.centerRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="e-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.bottomLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY+2*n.topLeftCircle.radius&&"sw-resize"!==this.dragElement?(n.bottomLeftCircle.startX=n.bottomLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="sw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.bottomCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomCenterCircle.startY+2*n.topLeftCircle.radius&&"s-resize"!==this.dragElement?(n.bottomCenterCircle.startX=n.bottomCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="s-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&t<=n.bottomRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY+2*n.topLeftCircle.radius&&"se-resize"!==this.dragElement?(n.bottomRightCircle.startX=n.bottomRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="se-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):l&&t>=l.x-2*n.topLeftCircle.radius&&t<=l.x+2*n.topLeftCircle.radius&&i>=l.y-2*n.topLeftCircle.radius&&i<=l.y+2*n.topLeftCircle.radius&&"grabbing"!==this.dragElement?(r.upperCanvas.style.cursor=r.cursor="grabbing",this.dragElement=r.upperCanvas.style.cursor):(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i),"text"!==n.shape||"n-resize"!==r.cursor&&"s-resize"!==r.cursor&&"e-resize"!==r.cursor&&"w-resize"!==r.cursor||(r.upperCanvas.style.cursor=r.cursor="move",this.dragElement="",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}else this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i;this.previousPoint.x=this.previousPoint.y=this.diffPoint.x=this.diffPoint.y=0,"touchstart"===o?a||t>=n.activePoint.startX&&t<=n.activePoint.endX&&i>=n.activePoint.startY&&i<=n.activePoint.endY||"grabbing"===this.dragElement?r.currObjType.isDragging=!0:"line"===n.shape||"arrow"===n.shape?(this.setCursorForLineArrow(n,t,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):"path"===n.shape&&(this.setCursorForPath(n,t,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):r.currObjType.isDragging=!0,0===n.rotatedAngle||"e-resize"!==this.dragElement&&"w-resize"!==this.dragElement&&"n-resize"!==this.dragElement&&"s-resize"!==this.dragElement||(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}},i.prototype.updateCursorStylesForLineArrow=function(t,e,i){for(var o,r=!1,a=this.parent,n=0;n<5;n++)if(o=i.pointColl[n],t>=o.x-2*i.topLeftCircle.radius&&t<=o.x+2*i.topLeftCircle.radius&&e>=o.y-2*i.topLeftCircle.radius&&e<=o.y+2*i.topLeftCircle.radius){i.centerLeftCircle.startX=i.centerLeftCircle.startY=0,this.dragElement="w-resize",r=!0;break}if(!r)for(n=1;n<6;n++)if(o=i.pointColl[i.pointColl.length-n],t>=o.x-2*i.topLeftCircle.radius&&t<=o.x+2*i.topLeftCircle.radius&&e>=o.y-2*i.topLeftCircle.radius&&e<=o.y+2*i.topLeftCircle.radius){i.centerRightCircle.startX=i.centerRightCircle.startY=0,this.dragElement="e-resize",r=!0;break}if(!r)for(n=0;n<i.pointColl.length;n++){if(o=i.pointColl[n],t>=o.x-2*i.topLeftCircle.radius&&t<=o.x+2*i.topLeftCircle.radius&&e>=o.y-2*i.topLeftCircle.radius&&e<=o.y+2*i.topLeftCircle.radius){a.upperCanvas.style.cursor=a.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=e;break}a.upperCanvas.style.cursor=a.cursor="default"}return r},i.prototype.updateCursorStylesForPath=function(t,e,i){var o=!1;return this.pathAdjustedIndex=this.setCursorForLineArrow(i,t,e,this.parent.upperCanvas),"move"===this.parent.cursor&&(o=!0,this.dragElement="pathDrag"),o||(this.parent.upperCanvas.style.cursor=this.parent.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=e),o},i.prototype.setTextSelection=function(t,e){var i=this.parent,o=i.transform.degree;(o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o);for(var r=0,a=i.activeObj.flipObjColl.length;r<a;r++){var n=i.activeObj.flipObjColl[r].toLowerCase();switch(o){case 0:switch(n){case"horizontal":i.activeObj.activePoint={startX:i.activeObj.activePoint.endX-t,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)};break;case"vertical":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(t||0),endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(t||0),endY:i.activeObj.activePoint.startY+(e||0)}}break;case 90:switch(n){case"horizontal":i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)};break;case"vertical":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-t,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)}}break;case 180:switch(n){case"horizontal":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+t,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+e,i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(t||0),startY:i.activeObj.activePoint.startY};break;default:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(t||0),startY:i.activeObj.activePoint.endY-(e||0)}}break;case 270:switch(n){case"horizontal":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(t||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+e,endY:i.activeObj.activePoint.startY+(t||0)};break;default:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(t||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}}}if(0===i.activeObj.flipObjColl.length)switch(o){case 0:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(t||0),endY:i.activeObj.activePoint.startY+(e||0)};break;case 90:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)};break;case 180:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(t||0),startY:i.activeObj.activePoint.endY-(e||0)};break;case 270:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(t||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}i.activeObj.activePoint.width=i.activeObj.activePoint.endX-i.activeObj.activePoint.startX,i.activeObj.activePoint.height=i.activeObj.activePoint.endY-i.activeObj.activePoint.startY,360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},i.prototype.setActivePoint=function(t,i){var o=this.parent;if(!e.isNullOrUndefined(o.activeObj.activePoint))if(o.currObjType.isText){var r=t||0,a=i||o.activeObj.textSettings.fontSize;void 0===o.activeObj.textSettings.fontSize&&(o.activeObj.textSettings.fontSize=.1*Math.abs(o.baseImg.width-o.baseImg.height)),this.setTextSelection(r,a),this.mouseDownPoint.x=o.activeObj.activePoint.endX,this.mouseDownPoint.y=o.activeObj.activePoint.endY,void 0!==o.activeObj.horTopLine&&(o.activeObj.activePoint=e.extend({},o.activeObj.activePoint,{},!0)),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})}else if(t&&i)o.activeObj.activePoint.startX=this.mouseDownPoint.x=t,o.activeObj.activePoint.startY=this.mouseDownPoint.y=i,o.currObjType.isDragging=!0;else{var n=o.activeObj;o.activeObj.activePoint={startX:n.horTopLine.startX,startY:n.horTopLine.startY,endX:n.horTopLine.endX,endY:n.horTopLine.endY},o.activeObj.activePoint.width=o.activeObj.activePoint.endX-o.activeObj.activePoint.startX,o.activeObj.activePoint.height=o.activeObj.activePoint.endY-o.activeObj.activePoint.startY}},i.prototype.mouseDownEventHandler=function(t){var i=this,o=this.parent;if("touchstart"===t.type?this.isTouch=!0:this.isTouch=!1,"touchstart"!==t.type||t.currentTarget!==o.lowerCanvas||o.isImageLoaded){this.isCropSelection=!1,this.isPan=!0;var r;void 0!==o.activeObj.shape&&(r=o.activeObj.shape.split("-")),void 0!==r&&"crop"===r[0]&&(this.isCropSelection=!0),this.isCropSelection&&(this.dragCanvas=o.togglePan=!0);var a={point:this.setXYPoints(t)};e.isBlazor()&&o.events&&!0===o.events.clicked.hasDelegate?o.dotNetRef.invokeMethodAsync("ClickEventAsync","click",a).then(function(e){i.clickEvent(e,t)}):(o.trigger("click",a),this.clickEvent(a,t))}},i.prototype.getImagePoints=function(t,e){var i=this.parent;return t<i.img.destLeft?t=i.img.destLeft:t>i.img.destLeft+i.img.destWidth&&(t=i.img.destLeft+i.img.destWidth),e<i.img.destTop?e=i.img.destTop:e>i.img.destTop+i.img.destHeight&&(e=i.img.destTop+i.img.destHeight),{x:t,y:e}},i.prototype.clickEvent=function(t,i){var o=this.parent,r=t.point.x,a=t.point.y,n=o.activeObj.shape&&"text"===o.activeObj.shape?o.cursor:"default";if(""!==this.currentDrawingShape){var s={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),this.initialPrevObj=s.currObj,this.initialPrevObj.objColl=e.extend([],o.objColl,[],!0),this.initialPrevObj.pointColl=e.extend([],o.pointColl,[],!0),this.initialPrevObj.afterCropActions=e.extend([],o.afterCropActions,[],!0);var l={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),this.initialPrevObj.selPointColl=e.extend([],l.selPointColl,[],!0),this.setActivePoint(r,a),"path"===this.currentDrawingShape){var p=this.getImagePoints(r,a);o.activeObj.pointColl.push({x:p.x,y:p.y}),0!==o.activeObj.activePoint.width&&0!==o.activeObj.activePoint.height&&(o.activeObj.activePoint.width=0,o.activeObj.activePoint.height=0,o.activeObj.activePoint.startX=o.activeObj.pointColl[o.activeObj.pointColl.length-1].x,o.activeObj.activePoint.startY=o.activeObj.pointColl[o.activeObj.pointColl.length-1].y)}return o.activeObj.activePoint.endX=o.activeObj.activePoint.startX,o.activeObj.activePoint.endY=o.activeObj.activePoint.startY,void(o.currObjType.isDragging=!0)}this.isCropSelection&&this.dragCanvas&&(this.setCursor(r,a),"move"!==o.cursor&&"crosshair"!==o.cursor&&"default"!==o.cursor&&"grab"!==o.cursor&&(this.isPan=!1)),o.activeObj.shape?this.isObjSelected=!0:this.isObjSelected=!1;var h={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:h}});var c=h.currObj,d=e.extend({},o.activeObj,null,!0),v=this.isShapeTouch(i,this.isCropSelection),u=this.isFreehandDrawTouch(i,this.isCropSelection),g=v||this.isShapeClick(i,this.isCropSelection),b=this.applyCurrShape(g);if(this.isTouch&&!v&&d.shape&&!this.isCropSelection){this.applyObj(r,a)&&(o.okBtn(!0),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}));var C=e.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:c,previousObjColl:c.objColl,previousPointColl:c.pointColl,previousSelPointColl:c.selPointColl,previousCropObj:C,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),b&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}if(v||o.togglePen||this.isCropSelection||(e.isBlazor()?o.isImageLoaded&&o.updateToolbar(o.element,"imageLoaded","okBtnClick"):(o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}))),!this.dragCanvas||!this.isPan||"grab"!==o.cursor&&!this.isTouch||v||u||o.togglePen){var f=!1;!o.activeObj.shape||"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||(f=!0);var m=this.setXYPoints(i),y=m.x,P=m.y;this.applyObj(y,P)&&(o.okBtn(!0),b&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:y,y:P,isMouseDown:!0}});var j={index:null};o.notify("freehand-draw",{prop:"getFreehandDrawHoveredIndex",onPropertyChange:!1,value:{obj:j}});var O={freehandSelectedIndex:null};if(o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:O}}),this.isFhdPoint||this.isFhdCustomized&&!o.togglePen){if(!e.isNullOrUndefined(O.freehandSelectedIndex)&&O.freehandSelectedIndex!==j.index){var x=j.index;if(o.okBtn(),this.isFhdCustomized=!1,o.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:x}}),j.index>-1){w=o.pointColl[j.index].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:w,strokeWidth:o.pointColl[j.index].strokeWidth}})}}if(O.freehandSelectedIndex=null,o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:O}}),!e.isNullOrUndefined(j.index)&&j.index>-1)o.notify("freehand-draw",{prop:"selectFhd",value:{type:"ok"}}),e.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}});else if(O.freehandSelectedIndex){o.okBtn();var w=o.pointColl[O.freehandSelectedIndex].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:w,strokeWidth:o.pointColl[O.freehandSelectedIndex].strokeWidth}})}}else{if(this.isFhdEditing&&(o.notify("freehand-draw",{prop:"cancelFhd",value:{type:"ok"}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none")),e.isBlazor()||o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),this.isFhdEditing=!1,f?this.setCursor(y,P):"default"!==n&&(o.upperCanvas.style.cursor=o.cursor=n),"crosshair"===o.cursor||e.Browser.isDevice&&o.togglePen){if(o.togglePen){if(e.isNullOrUndefined(o.activeObj.strokeSettings)){var S={strokeSettings:{}};o.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:S}}),o.activeObj.strokeSettings=S.strokeSettings}var T={penStrokeWidth:null};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:T}}),e.isNullOrUndefined(T.penStrokeWidth)&&o.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:2}}),this.upperContext.strokeStyle=o.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=o.activeObj.strokeSettings.strokeColor,o.notify("freehand-draw",{prop:"freehandDownHandler",onPropertyChange:!1,value:{e:i,canvas:o.upperCanvas}})}else o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);o.currObjType.isActiveObj=!1,this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0}"crosshair"!==o.cursor&&"touchstart"===i.type.toLowerCase()||o.currObjType.isActiveObj&&"default"!==o.cursor&&!o.togglePen?(o.currObjType.isUndoAction&&o.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}}),this.findTarget(y,P,i.type)):""!==o.currObjType.shape&&!o.currObjType.isCustomCrop||o.togglePen||"default"===o.cursor||this.setActivePoint(y,P)}}else this.applyObj(r,a)&&(o.okBtn(!0),b&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),this.isFhdEditing&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.isFhdCustomized=!1,e.isBlazor()||o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),!o.activeObj.shape||"rectangle"!==o.activeObj.shape&&"ellipse"!==o.activeObj.shape&&"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape&&"path"!==o.activeObj.shape&&"text"!==o.activeObj.shape||(o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isBlazor()?o.updateToolbar(o.element,"imageLoaded"):(o.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}),o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}))),this.canvasMouseDownHandler(i);this.isShapeInserted=!1,this.tempActiveObj=e.extend({},o.activeObj,{},!0)},i.prototype.mouseMoveEventHandler=function(i){var o=this.parent,r=o.cursor,a=o.upperCanvas.style.cursor;i.preventDefault();var n=o.lowerCanvas.getBoundingClientRect();if("touchmove"===i.type&&2===i.touches.length){if(this.isFirstMove)this.startTouches=this.targetTouches(i.touches),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft-n.left,y:(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top}),this.tempTouches.push({x:(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,y:(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top});else{var s=(i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft)-n.left,l=(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top,p=(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,h=(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top,c={x:s<p?p-(p-s)/2:s-(s-p)/2,y:l<h?h-(h-l)/2:l-(l-h)/2};if(this.currMousePoint.x!==c.x&&this.currMousePoint.y!==c.y){var d="";if("touchmove"===i.type&&(o.zoomSettings.zoomTrigger&t.ZoomTrigger.Pinch)===t.ZoomTrigger.Pinch){this.zoomType="Pinch";var v=this.calculateScale(this.startTouches,this.targetTouches(i.touches));this.startTouches=this.targetTouches(i.touches),v>1?d="zoomIn":v<1&&(d="zoomOut")}""!==d&&o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:c.x,y:c.y,type:d}}),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft,y:i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop}),this.tempTouches.push({x:i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft,y:i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop}),this.currMousePoint.x=c.x,this.currMousePoint.y=c.y}}return void(this.isFirstMove=!1)}var u,g;"mousemove"===i.type?(u=i.clientX,g=i.clientY):(this.touchEndPoint.x=u=i.touches[0].clientX,this.touchEndPoint.y=g=i.touches[0].clientY),u-=n.left,g-=n.top,this.canvasMouseMoveHandler(i);var b,C=!1;void 0!==o.activeObj.shape&&(b=o.activeObj.shape.split("-")),void 0!==b&&"crop"===b[0]&&(C=!0),C&&o.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),o.upperCanvas.style.cursor=a,o.cursor=r,(o.currObjType.isActiveObj&&(void 0!==o.activeObj.activePoint||o.objColl.length>0)&&!this.dragCanvas||void 0!==o.activeObj.activePoint)&&""===this.dragElement&&(this.setCursor(u,g),o.activeObj.activePoint&&(0===o.activeObj.activePoint.width||!e.isNullOrUndefined(o.activeObj.currIndex)&&this.cursorTargetId!==o.activeObj.currIndex)&&"default"!==o.cursor&&"move"!==o.cursor&&"crosshair"!==o.cursor&&"grab"!==o.cursor&&"pointer"!==o.cursor&&(o.upperCanvas.style.cursor=o.cursor="move"),this.findTarget(u,g,i.type)),o.currObjType.isDragging&&(this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.updateActivePoint(u,g,C),o.notify("shape",{prop:"updateTrianglePoints",onPropertyChange:!1,value:{obj:o.activeObj}}),this.isPreventDragging?(o.activeObj.activePoint.startX>o.img.destLeft&&o.activeObj.activePoint.endX<o.img.destLeft+o.img.destWidth&&o.activeObj.activePoint.startY>o.img.destTop&&o.activeObj.activePoint.endY<o.img.destTop+o.img.destHeight&&(this.isPreventDragging=!1),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:null,saveContext:null,isPreventSelection:null}}),C&&(this.dragCanvas=o.togglePan=!0))},i.prototype.mouseUpEventHandler=function(t){var i=this,o=this.parent;"touchstart"===t.type?this.isTouch=!1:"touchend"===t.type&&t.stopImmediatePropagation(),t.preventDefault(),o.togglePan&&this.canvasMouseUpHandler(t);var r,a;"mouseup"===t.type?(r=t.clientX,a=t.clientY):(r=this.touchEndPoint.x,a=this.touchEndPoint.y);var n=o.lowerCanvas.getBoundingClientRect();r-=n.left,a-=n.top,"touchend"===t.type&&(this.startTouches=this.tempTouches=[],this.isFirstMove=!1,"none"===o.textArea.style.display&&(this.timer=0));var s,l=!1;if(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),e.isBlazor()&&this.parent.eventType){if("pan"===this.parent.eventType)o.events&&!0===o.events.onPanEnd.hasDelegate&&o.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanEnd",this.parent.panEventArgs);else if("resize"===this.parent.eventType){if(!this.isCropSelection&&this.parent.events&&!0===this.parent.events.onShapeResizeEnd.hasDelegate)this.shapeResizingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeResizingArgs.action="resize-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeEnd",this.shapeResizingArgs).then(function(t){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})});else if(this.shapeResizingArgs&&this.selectionResizingArgs&&this.parent.events&&!0===this.parent.events.onSelectionResizeEnd.hasDelegate){var p={type:this.parent.activeObj.shape,startX:this.shapeResizingArgs.currentShapeSettings.startX,startY:this.shapeResizingArgs.currentShapeSettings.startY,width:this.shapeResizingArgs.currentShapeSettings.width,height:this.shapeResizingArgs.currentShapeSettings.height};this.selectionResizingArgs.currentSelectionSettings=p,this.selectionResizingArgs.action="resize-end",this.parent.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeEnd",this.selectionResizingArgs).then(function(t){i.parent.notify("shape",{prop:"updateSelectionChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:t.currentSelectionSettings}})})}}else this.shapeMovingArgs&&this.parent.events&&!0===this.parent.events.onShapeDragEnd.hasDelegate&&(this.shapeMovingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeMovingArgs.action="drag-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragEnd",this.shapeMovingArgs).then(function(t){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})}));this.shapeResizingArgs=null,this.shapeMovingArgs=null,this.parent.panEventArgs=null,this.parent.eventType=null}if("path"!==this.currentDrawingShape){if(t.currentTarget===o.upperCanvas){if(this.pathAdjustedIndex=null,""!==this.currentDrawingShape){if("text"===this.currentDrawingShape){var h=e.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.initialPrevObj,previousObjColl:this.initialPrevObj.objColl,previousPointColl:this.initialPrevObj.pointColl,previousSelPointColl:this.initialPrevObj.selPointColl,previousCropObj:h,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:this.initialPrevObj.objColl}});this.isShapeInserted=!0,this.currentDrawingShape="",0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&o.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}})}this.adjustActObjForLineArrow(),this.updPtCollForShpRot(),o.currObjType.shape=o.currObjType.shape.toLowerCase();var c=e.extend({},o.cropObj,{},!0),d={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:d}});var v=d.currObj;v.objColl=e.extend([],o.objColl,[],!0),v.pointColl=e.extend([],o.pointColl,[],!0),v.afterCropActions=e.extend([],o.afterCropActions,[],!0);var u={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:u}}),v.selPointColl=e.extend([],u.selPointColl,[],!0),o.togglePen||l||(this.tempObjColl&&0!==o.activeObj.activePoint.width&&(o.objColl.push(o.activeObj),JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(this.tempActiveObj.activePoint)&&o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:v,previousObjColl:this.tempObjColl,previousPointColl:v.pointColl,previousSelPointColl:v.selPointColl,previousCropObj:c,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.redrawShape(o.objColl[o.objColl.length-1],!0),this.tempObjColl=void 0),this.isFhdEditing||(this.applyCurrActObj(r,a),o.currObjType.isResize=!1)),o.activeObj){var g,b=!1;if(void 0!==o.activeObj.shape&&(g=o.activeObj.shape.split("-")),void 0===g&&(o.currObjType.isCustomCrop||o.togglePen)?b=!0:void 0!==g&&"crop"===g[0]&&(b=!0),e.isBlazor())"rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape?o.updateToolbar(o.element,o.activeObj.shape):"text"===o.activeObj.shape&&o.updateToolbar(o.element,"text");else{if("rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if("text"===o.activeObj.shape)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(this.isFhdEditing)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(!b){var C={type:"main",isApplyBtn:null,isCropping:!1,isZooming:null};o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:C})}o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})}}}void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),o.activeObj.shape&&!l&&t.currentTarget===o.upperCanvas&&"none"===o.textArea.style.display&&("text"===o.activeObj.shape?e.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):e.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),e.isBlazor()?o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape):(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),o.togglePen&&t.currentTarget===o.upperCanvas?o.notify("freehand-draw",{prop:"freehandUpHandler",onPropertyChange:!1,value:{e:t,canvas:o.upperCanvas,context:this.upperContext}}):o.currObjType.shape="",this.dragElement="",o.currObjType.isInitialLine=o.currObjType.isDragging=!1,this.selMouseUpEvent()}},i.prototype.adjustActObjForLineArrow=function(t){var e=!1,i=this.parent;if((t=t||i.activeObj).shape&&("line"===t.shape||"arrow"===i.activeObj.shape)){var o=void 0;if(("e-resize"===this.dragElement&&t.activePoint.endX<t.activePoint.startX||"w-resize"===this.dragElement&&t.activePoint.startX>t.activePoint.endX)&&(e=!0,o=t.activePoint.startX,t.activePoint.startX=t.activePoint.endX,t.activePoint.endX=o,o=t.activePoint.startY,t.activePoint.startY=t.activePoint.endY,t.activePoint.endY=o),t.activePoint.width=Math.abs(t.activePoint.endX-t.activePoint.startX),t.activePoint.height=Math.abs(t.activePoint.endY-t.activePoint.startY),"path"!==i.activeObj.shape){i.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:t}});for(var r=0;r<t.pointColl.length;r++)t.pointColl[r].ratioX=(t.pointColl[r].x-i.img.destLeft)/i.img.destWidth,t.pointColl[r].ratioY=(t.pointColl[r].y-i.img.destTop)/i.img.destHeight}}return e},i.prototype.updPtCollForShpRot=function(t){var e=this.parent;if((t=t||e.activeObj).shape&&0!==t.rotatedAngle){e.notify("shape",{prop:"setPointCollForShapeRotation",onPropertyChange:!1,value:{obj:t}});for(i=0;i<t.horTopLinePointColl.length;i++)t.horTopLinePointColl[i].ratioX=(t.horTopLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.horTopLinePointColl[i].ratioY=(t.horTopLinePointColl[i].y-e.img.destTop)/e.img.destHeight;for(i=0;i<t.horBottomLinePointColl.length;i++)t.horBottomLinePointColl[i].ratioX=(t.horBottomLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.horBottomLinePointColl[i].ratioY=(t.horBottomLinePointColl[i].y-e.img.destTop)/e.img.destHeight;for(i=0;i<t.verLeftLinePointColl.length;i++)t.verLeftLinePointColl[i].ratioX=(t.verLeftLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.verLeftLinePointColl[i].ratioY=(t.verLeftLinePointColl[i].y-e.img.destTop)/e.img.destHeight;for(var i=0;i<t.verRightLinePointColl.length;i++)t.verRightLinePointColl[i].ratioX=(t.verRightLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.verRightLinePointColl[i].ratioY=(t.verRightLinePointColl[i].y-e.img.destTop)/e.img.destHeight}},i.prototype.setXYPoints=function(t){t.preventDefault();var e,i;"mousedown"===t.type?(e=t.clientX,i=t.clientY):(this.touchEndPoint.x=e=t.touches[0].clientX,this.touchEndPoint.y=i=t.touches[0].clientY);var o=this.parent.lowerCanvas.getBoundingClientRect();return e-=o.left,i-=o.top,{x:e,y:i}},i.prototype.getCurrentIndex=function(){for(var t,e=this.parent,i=0;i<e.objColl.length;i++)if(e.activeObj.currIndex===e.objColl[i].currIndex){t=i;break}return t},i.prototype.isShapeClick=function(t,i){var o=this.parent,r=!1;if(o.togglePen)return r;if(o.activeObj.shape&&"text"===o.activeObj.shape&&this.isShapeInserted){var a="block"===o.textArea.style.display,n=e.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(t),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;h=this.getCurrentIndex();e.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;var h=this.getCurrentIndex();e.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?e.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1)}}return r},i.prototype.isShapeTouch=function(t,i){var o=this.parent,r=!1;if("touchstart"===t.type&&!o.togglePen){o.activeObj&&"text"===o.activeObj.shape&&(this.timer=setTimeout(this.setTimer.bind(this),1e3,t));var a="block"===o.textArea.style.display,n=e.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(t),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;h=this.getCurrentIndex();e.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;var h=this.getCurrentIndex();i||(e.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?e.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.isFreehandDrawTouch=function(t,i){var o=this.parent,r=!1;if("touchstart"===t.type&&!i&&!o.togglePen){var a="block"===o.textArea.style.display,n=e.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(t),l=s.x,p=s.y;if(this.setCursor(l,p),this.isFhdPoint&&(r=!0),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;h=this.getCurrentIndex();e.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(n.shape){o.activeObj=n;var h=this.getCurrentIndex();i||(e.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?e.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.applyObj=function(t,e){var i=this.parent,o=!1;return!i.activeObj.shape||"rectangle"!==i.activeObj.shape&&"ellipse"!==i.activeObj.shape&&"text"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"arrow"!==i.activeObj.shape&&"path"!==i.activeObj.shape||(o=!(t>=i.activeObj.activePoint.startX-2*i.activeObj.topLeftCircle.radius&&t<=i.activeObj.activePoint.endX+2*i.activeObj.topLeftCircle.radius&&e>=i.activeObj.activePoint.startY-2*i.activeObj.topLeftCircle.radius&&e<=i.activeObj.activePoint.endY+2*i.activeObj.topLeftCircle.radius)&&("default"===i.upperCanvas.style.cursor||"grab"===i.upperCanvas.style.cursor||"crosshair"===i.upperCanvas.style.cursor||"pointer"===i.upperCanvas.style.cursor)),o},i.prototype.applyCurrShape=function(t){var i=this.parent,o=!1;if(i.togglePen)return o;var r=e.extend({},i.activeObj,null,!0);if(this.isShapeInserted&&"text"===i.activeObj.shape&&t&&(this.isInitialTextEdited=!0,i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}})),"block"===i.textArea.style.display){var a=e.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r=e.extend({},i.objColl[i.objColl.length-1],null,!0),i.objColl.pop(),i.activeObj=e.extend({},a,null,!0),i.textArea.value=r.keyHistory,i.textArea.style.display="block";var n="rgb"===r.strokeSettings.strokeColor.split("(")[0]?this.rgbToHex(parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[0]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[1]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[2])):r.strokeSettings.strokeColor;"#ffffff"===n&&(n="#fff"),"#ffffff"===this.tempActiveObj.strokeSettings.strokeColor&&(this.tempActiveObj.strokeSettings.strokeColor="#fff"),r.keyHistory===this.tempActiveObj.keyHistory&&n===this.tempActiveObj.strokeSettings.strokeColor&&r.textSettings.fontFamily===this.tempActiveObj.textSettings.fontFamily&&Math.round(r.textSettings.fontSize)===Math.round(this.tempActiveObj.textSettings.fontSize)&&Math.round(r.textSettings.fontRatio)===Math.round(this.tempActiveObj.textSettings.fontRatio)&&r.textSettings.bold===this.tempActiveObj.textSettings.bold&&r.textSettings.italic===this.tempActiveObj.textSettings.italic&&r.textSettings.underline===this.tempActiveObj.textSettings.underline||(o=!0),this.isInitialTextEdited&&!o&&(o=!0,this.isInitialTextEdited=!1)}else this.tempActiveObj.activePoint.height=Math.abs(this.tempActiveObj.activePoint.height),o=JSON.stringify(r)!==JSON.stringify(this.tempActiveObj);return o},i.prototype.canvasMouseDownHandler=function(t){var i=this.parent;t.preventDefault();var o,r;"mousedown"===t.type?(o=t.offsetX||t.pageX-i.lowerCanvas.offsetLeft,r=t.offsetY||t.pageY-i.lowerCanvas.offsetTop):(o=t.touches[0].clientX||t.touches[0].pageX-i.lowerCanvas.offsetLeft,r=t.touches[0].clientY||t.touches[0].pageY-i.lowerCanvas.offsetTop);var a=i.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top,this.panDown={x:o,y:r};var n={tempPanMove:null};i.notify("transform",{prop:"getTempPanMove",onPropertyChange:!1,value:{obj:n}}),e.isNullOrUndefined(n.tempPanMove)&&i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:{x:o,y:r}}})},i.prototype.canvasMouseMoveHandler=function(t){var e=this.parent;this.dragCanvas?e.lowerCanvas.style.cursor="grab":(this.dragCanvas=e.togglePan=!1,e.lowerCanvas.style.cursor=e.upperCanvas.style.cursor=e.cursor="default");var i,o;"mousemove"===t.type?(i=t.offsetX,o=t.offsetY):(i=t.touches[0].clientX||t.touches[0].pageX-e.lowerCanvas.offsetLeft,o=t.touches[0].clientY||t.touches[0].pageY-e.lowerCanvas.offsetTop);var r=e.lowerCanvas.getBoundingClientRect(),a={x:i-=r.left,y:o-=r.top};e.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:{x:i,y:o}}}),this.panDown&&a&&e.togglePan&&this.dragCanvas&&e.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:null,yDiff:null}})},i.prototype.canvasMouseUpHandler=function(t){var e=this.parent;t.preventDefault();var i={panMove:null};e.notify("transform",{prop:"getPanMove",onPropertyChange:!1,value:{obj:i}}),e.togglePan&&this.panDown&&i.panMove&&e.togglePan&&this.dragCanvas&&(this.panDown=null,e.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:null}}),e.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}})),"path"!==this.currentDrawingShape&&(e.currObjType.isDragging=!1)},i.prototype.touchStartHandler=function(t){t.preventDefault(),0===this.touchTime?this.touchTime=(new Date).getTime():(new Date).getTime()-this.touchTime<400?(this.parent.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e:t}}),this.touchTime=0):this.touchTime=(new Date).getTime(),2===t.touches.length?this.isFirstMove=!0:this.mouseDownEventHandler(t),e.EventHandler.add(this.parent.lowerCanvas,"touchend",this.mouseUpEventHandler,this),e.EventHandler.add(this.parent.lowerCanvas,"touchmove",this.mouseMoveEventHandler,this),e.EventHandler.add(this.parent.upperCanvas,"touchend",this.mouseUpEventHandler,this),e.EventHandler.add(this.parent.upperCanvas,"touchmove",this.mouseMoveEventHandler,this)},i.prototype.keyDownEventHandler=function(i){var o=this,r=this.parent;!i.ctrlKey||"+"!==i.key&&"-"!==i.key||i.preventDefault();var a={fileName:"",fileType:null};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n,s={fileName:a.fileName,fileType:a.fileType,cancel:!1};switch(i.key){case i.ctrlKey&&"s":e.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",s).then(function(t){o.beforeSaveEvent(t,i)}):(r.trigger("beforeSave",s),this.beforeSaveEvent(s,i));break;case i.ctrlKey&&"z":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-undo"});break;case i.ctrlKey&&"y":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-redo"});break;case i.ctrlKey&&"+":(r.zoomSettings.zoomTrigger&t.ZoomTrigger.Commands)===t.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}}));break;case i.ctrlKey&&"-":(r.zoomSettings.zoomTrigger&t.ZoomTrigger.Commands)===t.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}}));break;case"Delete":this.deleteItem();break;case"Escape":r.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});break;case"Enter":r.activeObj.shape&&(n=r.activeObj.shape.split("-")),this.isKeyBoardCrop(i)&&r.activeObj.horTopLine&&r.activeObj.shape&&"crop"===n[0]&&r.crop();break;case"Tab":this.performTabAction();break;default:e.Browser.isDevice&&"block"===r.textArea.style.display&&setTimeout(this.textKeyDown.bind(this),1,i)}},i.prototype.isKeyBoardCrop=function(t){var i=!1,o=t.target;return o.id!==this.parent.element.id+"_ok"&&""!==o.id||e.isBlazor()||(i=!0),i},i.prototype.beforeSaveEvent=function(t,e){var i=this.parent;t.cancel||i.notify("export",{prop:"export",onPropertyChange:!1,value:{type:t.fileType,fileName:t.fileName}}),e.preventDefault(),e.stopImmediatePropagation()},i.prototype.handleScroll=function(i){var o,r,a=this.parent,n=!1;"mousewheel"===i.type&&(o=i.clientX,r=i.clientY);var s=a.lowerCanvas.getBoundingClientRect();if(o-=s.left,r-=s.top,o>a.img.destLeft&&o<a.img.destLeft+a.img.destWidth&&r>a.img.destTop&&r<a.img.destTop+a.img.destHeight&&(n=!0),i.stopPropagation(),!0===i.ctrlKey&&n){i.preventDefault(),!a.isCropTab&&a.activeObj.shape&&"crop"!==a.activeObj.shape.split("-")[0]&&(a.okBtn(),e.isBlazor()||a.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}));var l="";"mousewheel"===i.type&&(a.zoomSettings.zoomTrigger&t.ZoomTrigger.MouseWheel)===t.ZoomTrigger.MouseWheel&&(this.zoomType="MouseWheel",l=i.wheelDelta>0?"zoomIn":"zoomOut"),""!==l&&a.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:o,y:r,type:l}})}},i.prototype.textKeyDown=function(t){var i=this.parent;"\r"===String.fromCharCode(t.which)&&(this.textRow+=1),i.textArea.setAttribute("rows",this.textRow.toString()),i.textArea.style.height="auto",i.textArea.style.height=i.textArea.scrollHeight+"px",i.notify("shape",{prop:"setTextBoxWidth",onPropertyChange:!1,value:{e:t}}),e.Browser.isDevice&&(i.textArea.style.width=parseFloat(i.textArea.style.width)+i.textArea.style.fontSize+"px");var o=i.textArea.value.split("\n");this.textRow=o.length,i.textArea.setAttribute("rows",this.textRow.toString()),this.isInitialTextEdited=!1},i.prototype.clearSelection=function(){var t=this.parent;!t.disabled&&t.isImageLoaded&&(t.togglePen=!1,t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0,t.currObjType.shape="",this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.currObjType.isActiveObj=!0,t.currObjType.isCustomCrop=!1,t.upperCanvas.style.cursor=t.cursor="default")},i.prototype.setDragDirection=function(t,e){var i=this.parent;i.img.destWidth>i.img.destHeight?(i.activeObj.activePoint.startX=this.dragPoint.startX=t/2-e/2+7.5,i.activeObj.activePoint.startY=this.dragPoint.startY=e/2-e/2+7.5,i.activeObj.activePoint.endX=t/2+e/2-7.5,i.activeObj.activePoint.endY=e/2+e/2-7.5):(i.activeObj.activePoint.startY=this.dragPoint.startX=e/2-t/2+7.5,i.activeObj.activePoint.endY=e/2+t/2-7.5,i.activeObj.activePoint.startX=this.dragPoint.startX=7.5,i.activeObj.activePoint.endX=t-7.5)},i.prototype.calcShapeRatio=function(t,e,i,o){for(var r=this.parent,a=i,n=o,s=t/e,l=a>=n?a:n,p=l*s,h=l,c=this.getScale(p,a),d=[],v=0;v<2;v++)0===v?d.push(p*c):d.push(h*c);p=d[0],h=d[1];for(var u=this.getScale(h,n),g=[],v=0;v<2;v++)0===v?g.push(p*u):g.push(h*u);p=g[0],h=g[1],r.activeObj.activePoint.width=p,r.activeObj.activePoint.height=h,r.activeObj.activePoint.startX=7.5+(this.dragPoint.startX=(a-p)/2),r.activeObj.activePoint.startY=7.5+(this.dragPoint.startY=(n-h)/2),r.activeObj.activePoint.endX=(a-p)/2+p-7.5,r.activeObj.activePoint.endY=(n-h)/2+h-7.5,r.activeObj.activePoint.startX<r.img.destLeft&&r.img.destLeft+r.img.destWidth>r.lowerCanvas.clientWidth&&(r.activeObj.activePoint.startX=r.img.destLeft,r.activeObj.activePoint.endX=r.activeObj.activePoint.startX+p-7.5),r.activeObj.activePoint.startY<r.img.destTop&&r.img.destTop+r.img.destHeight>r.lowerCanvas.clientHeight&&(r.activeObj.activePoint.startY=r.img.destTop,r.activeObj.activePoint.endY=r.activeObj.activePoint.startY+h-7.5),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY},i.prototype.getScale=function(t,e){return t>e?e/t:1},i.prototype.findTarget=function(t,e,i){var o=this.parent;if("mousedown"===i.toLowerCase()||"touchstart"===i.toLowerCase()){var r=!1;o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]&&(r=!0),this.findTargetObj(t,e,r),this.updateCursorStyles(t,e,i)}else switch(this.dragElement.toLowerCase()){case"nw-resize":o.activeObj.topLeftCircle.startX=t,o.activeObj.topLeftCircle.startY=e;break;case"n-resize":o.activeObj.topCenterCircle.startX=t,o.activeObj.topCenterCircle.startY=e;break;case"ne-resize":o.activeObj.topRightCircle.startX=t,o.activeObj.topRightCircle.startY=e;break;case"w-resize":o.activeObj.centerLeftCircle.startX=t,o.activeObj.centerLeftCircle.startY=e;break;case"e-resize":o.activeObj.centerRightCircle.startX=t,o.activeObj.centerRightCircle.startY=e;break;case"sw-resize":o.activeObj.bottomLeftCircle.startX=t,o.activeObj.bottomLeftCircle.startY=e;break;case"s-resize":o.activeObj.bottomCenterCircle.startX=t,o.activeObj.bottomCenterCircle.startY=e;break;case"se-resize":o.activeObj.bottomRightCircle.startX=t,o.activeObj.bottomRightCircle.startY=e;break;default:this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e)}},i.prototype.findTargetObj=function(t,i,o){var r=this,a=this.parent,n=!1;if(0!==a.objColl.length&&!a.currObjType.isCustomCrop&&!o){for(var s=0,l=void 0,p=0;p<a.objColl.length;p++){var h=a.upperCanvas.style.cursor;this.setCursor(t,i);var c=e.extend({},a.objColl[p],{},!0);if("line"===c.shape||"arrow"===c.shape){for(var d=0;d<c.pointColl.length;d++)if(t>=c.pointColl[d].x-2*c.topLeftCircle.radius&&t<=c.pointColl[d].x+2*c.topLeftCircle.radius&&i>=c.pointColl[d].y-2*c.topLeftCircle.radius&&i<=c.pointColl[d].y+2*c.topLeftCircle.radius){this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p);break}}else if("path"===c.shape){var v=this.setCursorForPath(c,t,i,a.upperCanvas);"default"!==v&&"grab"!==v&&(this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p))}else if(0!==c.rotatedAngle){var u=this.setCursorForRotatedObject(c,t,i,a.upperCanvas);"default"!==u&&"grab"!==u&&(this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p))}else{var g=this.getTransRotationPoint(c);(t>=c.activePoint.startX-2*c.topLeftCircle.radius&&t<=c.activePoint.endX+2*c.topLeftCircle.radius&&i>=c.activePoint.startY-2*c.topLeftCircle.radius&&i<=c.activePoint.endY+2*c.topLeftCircle.radius||g&&t>=g.x-2*c.topLeftCircle.radius&&t<=g.x+2*c.topLeftCircle.radius&&i>=g.y-2*c.topLeftCircle.radius&&i<=g.y+2*c.topLeftCircle.radius)&&(this.isTouch||"move"===h||"grabbing"===h||this.isShapeInserted||"move"===a.cursor||"grabbing"===a.cursor?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p))}}if(e.isNullOrUndefined(l))a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n=!1;else{this.tempObjColl=e.extend([],a.objColl,[],!0),a.currObjType.isCustomCrop=!1,a.activeObj=e.extend({},a.objColl[l],{},!0);var b=e.extend({},a.objColl[l],{},!0);if(a.objColl.splice(l,1),0===a.transform.degree){var C=this.lowerContext.filter;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height),a.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(a.baseImg,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,a.img.destLeft,a.img.destTop,a.img.destWidth,a.img.destHeight),this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.activeObj=e.extend({},C,{},!0),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=C,this.getCurrentFlipState()}else a.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}});a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.setActivePoint(),a.activeObj=e.extend({},b,{},!0);var f=e.extend({},a.activeObj.strokeSettings,{},!0);a.notify("draw",{prop:"setTempStrokeSettings",onPropertyChange:!1,value:{tempStrokeSettings:f}});var m=e.extend({},a.activeObj.textSettings,{},!0);a.notify("draw",{prop:"setTempTextSettings",onPropertyChange:!1,value:{tempTextSettings:m}});var y=this.updatePrevShapeSettings(),P={action:"select",previousShapeSettings:y,currentShapeSettings:y};"line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape||(P.currentShapeSettings.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,P.currentShapeSettings.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),this.isCropSelection=!1;var j=void 0;if(void 0!==a.activeObj.shape&&(j=a.activeObj.shape.split("-")),void 0!==j&&"crop"===j[0]&&(this.isCropSelection=!0),!this.isCropSelection&&e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&a.events&&!0===a.events.shapeChanging.hasDelegate)a.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",P).then(function(t){r.shapeEvent(t)});else if(this.isCropSelection){var O={action:P.action,previousSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:P.previousShapeSettings.startX,startY:P.previousShapeSettings.startY,width:P.previousShapeSettings.width,height:P.previousShapeSettings.height},currentSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:P.currentShapeSettings.startX,startY:P.currentShapeSettings.startY,width:P.currentShapeSettings.width,height:P.currentShapeSettings.height}};e.isBlazor()&&a.events&&!0===a.events.onSelectionResizeStart.hasDelegate?a.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",O).then(function(t){P.currentShapeSettings.startX=t.currentSelectionSettings.startX,P.currentShapeSettings.startY=t.currentSelectionSettings.startY,P.currentShapeSettings.width=t.currentSelectionSettings.width,P.currentShapeSettings.height=t.currentSelectionSettings.height,r.shapeEvent(P)}):(a.trigger("selectionChanging",O),P.currentShapeSettings.startX=O.currentSelectionSettings.startX,P.currentShapeSettings.startY=O.currentSelectionSettings.startY,P.currentShapeSettings.width=O.currentSelectionSettings.width,P.currentShapeSettings.height=O.currentSelectionSettings.height,this.shapeEvent(P))}else a.trigger("shapeChanging",P),this.shapeEvent(P);n=!0}}return n},i.prototype.shapeEvent=function(t){var i=this.parent;if(i.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}}),i.activeObj.activePoint){var o={prevActObj:null};i.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:o}}),e.isNullOrUndefined(o.prevActObj)&&i.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:e.extend({},i.activeObj,{},!0)}}),i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}}),this.isShapeInserted||(i.activeObj.activePoint.startX<i.img.destLeft?this.isPreventDragging=!0:i.activeObj.activePoint.endX>i.img.destLeft+i.img.destWidth?this.isPreventDragging=!0:i.activeObj.activePoint.startY<i.img.destTop?this.isPreventDragging=!0:i.activeObj.activePoint.endY>i.img.destTop+i.img.destHeight&&(this.isPreventDragging=!0))}},i.prototype.targetTouches=function(t){var e=this.parent.lowerCanvas.getBoundingClientRect();return[{x:t[0].pageX-e.left,y:t[0].pageY-e.top},{x:t[1].pageX-e.left,y:t[1].pageY-e.top}]},i.prototype.calculateScale=function(t,e){var i=this.getDistance(t[0],t[1]);return this.getDistance(e[0],e[1])/i},i.prototype.getDistance=function(t,e){var i=0,o=0;return t&&e&&(i=t.x-e.x,o=t.y-e.y),Math.sqrt(i*i+o*o)},i.prototype.redrawShape=function(t,e){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++)if(JSON.stringify(t)===JSON.stringify(i.objColl[o])){i.objColl.splice(o,1);break}this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.isPreventDragging?(i.activeObj.activePoint.startX>i.img.destLeft&&(this.isPreventDragging=!1),e&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):(e&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}))},i.prototype.setTimer=function(t){this.timer>10&&(clearTimeout(this.timer),this.timer=0,this.parent.notify("shape",{prop:"findTextTarget",onPropertyChange:!1,value:{e:t}}),e.Browser.isDevice&&this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height))},i.prototype.applyCurrActObj=function(t,i){var o=this.parent,r=!1,a=e.extend({},o.activeObj,{},!0);if(!e.isNullOrUndefined(a.activePoint)){if(t>=Math.floor(a.activePoint.startX)&&t<=Math.ceil(a.activePoint.endX)&&i>=Math.floor(a.activePoint.startY)&&i<=Math.ceil(a.activePoint.endY))r=!0;else if("text"===a.shape&&""!==this.dragElement)r=!0;else if("line"===a.shape||"arrow"===a.shape){var n={x:a.activePoint.startX<a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY<a.activePoint.endY?a.activePoint.startY:a.activePoint.endY},s={x:a.activePoint.startX>a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY>a.activePoint.endY?a.activePoint.startY:a.activePoint.endY};t>=Math.floor(n.x)-5&&t<=Math.ceil(s.x)+5&&i>=Math.floor(n.y)-5&&i<=Math.ceil(s.y)+5&&(r=!0)}else if("path"===a.shape)"move"===(l=this.setCursorForPath(a,t,i,o.upperCanvas))&&(r=!0);else if("grabbing"===this.dragElement)r=!0;else if(0!==a.rotatedAngle){var l=this.setCursorForRotatedObject(a,t,i,o.upperCanvas);("default"!==l&&"grab"!==l||"n-resize"===this.dragElement||"e-resize"===this.dragElement||"s-resize"===this.dragElement||"w-resize"===this.dragElement)&&(r=!0)}if(!r){if(e.isNullOrUndefined(o.activeObj.currIndex)&&(o.activeObj.currIndex="shape_"+(o.objColl.length+1)),o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),void 0===o.activeObj.horTopLine||0===o.activeObj.horTopLine.startX||0===o.activeObj.horTopLine.endX||o.currObjType.isCustomCrop||""===o.currObjType.shape||o.objColl.push(e.extend({},o.activeObj,{},!0)),"text"===o.activeObj.shape||"ellipse"===o.currObjType.shape||"rectangle"===o.currObjType.shape||"line"===o.currObjType.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape){var p=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var h=0;h<o.objColl.length;h++){var c={isInside:!1};o.notify("crop",{prop:"isObjInImage",onPropertyChange:!1,value:{obj:o.objColl[h],object:c}}),c.isInside&&(o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:o.objColl[h].shape,obj:o.objColl[h],canvas:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=p,o.activeObj.shape&&o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})}e.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}}},i.prototype.getCurrentFlipState=function(){var t=this.parent;if(0!==t.rotateFlipColl.length){var i=e.extend({},t.panPoint.totalPannedInternalPoint,{},!0);t.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),t.panPoint.totalPannedInternalPoint=i}else t.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1})},i.prototype.setTextBoxStylesToActObj=function(){var t=this.parent;t.activeObj.textSettings.fontFamily=t.textArea.style.fontFamily,t.activeObj.strokeSettings.strokeColor=""!==t.textArea.style.color?this.rgbToHex(parseFloat(t.textArea.style.color.split("(")[1].split(",")[0]),parseFloat(t.textArea.style.color.split("(")[1].split(",")[1]),parseFloat(t.textArea.style.color.split("(")[1].split(",")[2])):t.textArea.style.color,"bold"===t.textArea.style.fontWeight?t.activeObj.textSettings.bold=!0:t.activeObj.textSettings.bold=!1,"italic"===t.textArea.style.fontStyle?t.activeObj.textSettings.italic=!0:t.activeObj.textSettings.italic=!1,t.activeObj.textSettings.fontSize=parseFloat(t.textArea.style.fontSize)},i.prototype.rgbToHex=function(t,e,i){return"#"+this.componentToHex(t)+this.componentToHex(e)+this.componentToHex(i)},i.prototype.componentToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},i.prototype.deleteItem=function(){var t=this.parent,i={};if(this.isFhdEditing){this.updateFreehandDrawColorChange();var o=e.extend({},t.cropObj,{},!0),r={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),(p=r.currObj).objColl=e.extend([],t.objColl,[],!0),p.pointColl=e.extend([],t.pointColl,[],!0),p.afterCropActions=e.extend([],t.afterCropActions,[],!0);h={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),p.selPointColl=e.extend([],h.selPointColl,[],!0);a={freehandDrawSelectedId:null};t.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:a}}),t.notify("freehand-draw",{prop:"deleteFhd",value:{id:a.freehandDrawSelectedId}}),t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteFreehandDrawing",previousObj:p,previousObjColl:this.tempObjColl,previousPointColl:p.pointColl,previousSelPointColl:p.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),t.notify("freehand-draw",{prop:"resetFreehandDrawSelectedId"})}else if("none"===t.textArea.style.display){var a={prevActObj:null};if(t.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:a}}),a.prevActObj&&(a.prevActObj.activePoint.width=Math.abs(a.prevActObj.activePoint.width),a.prevActObj.activePoint.height=Math.abs(a.prevActObj.activePoint.height)),a.prevActObj&&JSON.stringify(a.prevActObj)!==JSON.stringify(t.activeObj)){var n=t.activeObj.currIndex;t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});for(var s=0;s<t.objColl.length;s++)if(t.objColl[s].currIndex===n){t.objColl.splice(s,1),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null}});break}}r={isNewPath:null};if(t.notify("draw",{prop:"getNewPath",value:{obj:r}}),r.isNewPath)t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.isBlazor()?t.updateToolbar(t.element,"imageLoaded"):t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(t.activeObj.shape){t.objColl.push(t.activeObj);var o=e.extend({},t.cropObj,{},!0),l={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:l}});var p=l.currObj;p.objColl=e.extend([],t.objColl,[],!0),p.pointColl=e.extend([],t.pointColl,[],!0),p.afterCropActions=e.extend([],t.afterCropActions,[],!0);var h={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),p.selPointColl=e.extend([],h.selPointColl,[],!0),t.objColl.pop(),i={action:"delete",previousShapeSettings:this.updatePrevShapeSettings(),currentShapeSettings:null},t.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),t.clearSelection(),e.isBlazor()&&t.events&&!0===t.events.shapeChanging.hasDelegate?t.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",i):(t.trigger("shapeChanging",i),e.isBlazor()||t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})),e.isNullOrUndefined(p.objColl[p.objColl.length-1].currIndex)||(t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteObj",previousObj:p,previousObjColl:this.tempObjColl,previousPointColl:p.pointColl,previousSelPointColl:p.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))}t.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})}document.getElementById(t.element.id+"_quickAccessToolbarArea")&&(document.getElementById(t.element.id+"_quickAccessToolbarArea").style.display="none")},i.prototype.updateFreehandDrawColorChange=function(){var t=this.parent,i={freehandSelectedIndex:null};if(t.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:i}}),!e.isNullOrUndefined(i.freehandSelectedIndex)&&!e.isNullOrUndefined(t.pointColl[i.freehandSelectedIndex])&&"#42a5f5"===t.pointColl[i.freehandSelectedIndex].strokeColor){var o={tempFreeHandDrawEditingStyles:null};t.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:o}}),t.pointColl[i.freehandSelectedIndex].strokeColor=o.tempFreeHandDrawEditingStyles.strokeColor}},i.prototype.updatePrevShapeSettings=function(t){var i=this.parent,o=[];"text"===i.activeObj.shape&&i.activeObj.textSettings&&(i.activeObj.textSettings.bold&&o.push("bold"),i.activeObj.textSettings.italic&&o.push("italic"),i.activeObj.textSettings.underline&&o.push("underline"));var r={id:e.isNullOrUndefined(i.activeObj.currIndex)?null:i.activeObj.currIndex,type:i.toPascalCase(i.activeObj.shape),startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,width:i.activeObj.activePoint.width,height:i.activeObj.activePoint.height,strokeColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null,strokeWidth:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeWidth:null,fillColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.fillColor:null,radius:"ellipse"===i.activeObj.shape?i.activeObj.activePoint.width/2:null,length:"line"===i.activeObj.shape||"arrow"===i.activeObj.shape?i.activeObj.activePoint.width:null,text:"text"===i.activeObj.shape&&i.activeObj.keyHistory?i.activeObj.keyHistory:null,fontSize:"text"===i.activeObj.shape&&i.activeObj.textSettings?i.activeObj.textSettings.fontSize:null,fontStyle:"text"===i.activeObj.shape?o:null,color:"text"===i.activeObj.shape&&i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null};return t&&(t.shapeSettingsObj=r),r},i.prototype.getRectanglePoints=function(t,e,i,o,r,a,n){var s=t+i/2,l=e+o/2,p=r*(Math.PI/180),h=Math.cos(p),c=Math.sin(p),d=a-s,v=n-l,u=d*h+v*c,g=-d*c+v*h,b=i/2,C=o/2;return u>=-b&&u<=b&&g>=-C&&g<=C},i.prototype.getTransRotationPoint=function(t,e){var i,o,r=!1,a=!1;(o=0===t.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-t.shapeDegree)<0&&(o=360+o);for(var n=0;n<t.flipObjColl.length;n++)"horizontal"===t.flipObjColl[n].toLowerCase()?r=!0:"vertical"===t.flipObjColl[n].toLowerCase()&&(a=!0);return 0===o||360===o?i=a?{x:t.topCenterCircle.startX,y:t.topCenterCircle.startY-t.rotationCircleLine}:{x:t.bottomCenterCircle.startX,y:t.bottomCenterCircle.startY+t.rotationCircleLine}:90===o||-270===o?i=r?{x:t.centerRightCircle.startX+t.rotationCircleLine,y:t.centerLeftCircle.startY}:{x:t.centerLeftCircle.startX-t.rotationCircleLine,y:t.centerLeftCircle.startY}:180===o||-180===o?i=a?{x:t.bottomCenterCircle.startX,y:t.bottomCenterCircle.startY+t.rotationCircleLine}:{x:t.topCenterCircle.startX,y:t.topCenterCircle.startY-t.rotationCircleLine}:270!==o&&-90!==o||(i=r?{x:t.centerLeftCircle.startX-t.rotationCircleLine,y:t.centerLeftCircle.startY}:{x:t.centerRightCircle.startX+t.rotationCircleLine,y:t.centerLeftCircle.startY}),e&&(e.rotationCirclePoint=i),i},i}(),d=function(){function i(t){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.keyHistory="",this.parent=t,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("shape",this.shape,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("shape",this.shape),this.parent.off("destroyed",this.destroy)},i.prototype.shape=function(t){switch(this.initShapePvtProps(),t.prop){case"drawEllipse":this.drawEllipse(t.value.x,t.value.y,t.value.radiusX,t.value.radiusY,t.value.strokeWidth,t.value.strokeColor,t.value.fillColor);break;case"drawLine":this.drawLine(t.value.startX,t.value.startY,t.value.endX,t.value.endY,t.value.strokeWidth,t.value.strokeColor);break;case"drawArrow":this.drawArrow(t.value.startX,t.value.startY,t.value.endX,t.value.endY,t.value.strokeWidth,t.value.strokeColor,t.value.arrowStart,t.value.arrowEnd);break;case"drawPath":this.drawPath(t.value.pointColl,t.value.strokeWidth,t.value.strokeColor);break;case"drawRectangle":this.drawRectangle(t.value.x,t.value.y,t.value.width,t.value.height,t.value.strokeWidt,t.value.strokeColor,t.value.fillColor);break;case"drawText":this.drawText(t.value.x,t.value.y,t.value.text,t.value.fontFamily,t.value.fontSize,t.value.bold,t.value.italic,t.value.color);break;case"redrawActObj":this.redrawActObj(t.value.x,t.value.y,t.value.isMouseDown);break;case"apply":this.apply(t.value.shape,t.value.obj,t.value.canvas);break;case"updateShapeChangeEventArgs":this.updateShapeChangeEventArgs(t.value.shapeSettings);break;case"updSelChangeEventArgs":this.updSelChangeEventArgs(t.value.selectionSettings);break;case"iterateObjColl":this.iterateObjColl();break;case"updImgRatioForActObj":this.updImgRatioForActObj();break;case"zoomObjColl":this.zoomObjColl(t.value.isPreventApply);break;case"redrawObj":this.redrawObj(t.value.degree);break;case"rotateObjColl":this.rotateObjColl();break;case"draw-shape-text":this.drawShapeText();break;case"redraw-text":this.redrawText();break;case"draw-shape":this.drawShape(t.value.obj,t.value.strokeWidth,t.value.strokeColor,t.value.fillColor,t.value.start,t.value.width,t.value.height);break;case"renderTextArea":this.renderTextArea(t.value.x,t.value.y,t.value.actObj);break;case"setTextBoxWidth":this.setTextBoxWidth(t.value.e);break;case"findTextTarget":this.findTextTarget(t.value.e);break;case"panObjColl":this.panObjColl(t.value.xDiff,t.value.yDiff,t.value.panRegion);break;case"updateFontStyles":this.updateFontStyles(t.value.isTextBox);break;case"applyFontStyle":this.applyFontStyle(t.value.item);break;case"updateFontRatio":this.updateFontRatio(t.value.obj,t.value.isTextArea);break;case"updateFontSize":this.updateFontSize(t.value.obj);break;case"updateObjColl":this.updateObjColl(t.value.item,t.value.objColl);break;case"pushActItemIntoObj":this.pushActItemIntoObj();break;case"clearActObj":this.clearActObj();break;case"refreshActiveObj":this.refreshActiveObj();break;case"applyActObj":this.applyActObj(t.value.isMouseDown);break;case"wireEvent":e.EventHandler.add(this.parent.upperCanvas,"dblclick",this.findTextTarget,this),e.EventHandler.add(this.parent.textArea,"mousedown",this.findTextTarget,this);break;case"unWireEvent":e.EventHandler.remove(this.parent.upperCanvas,"dblclick",this.findTextTarget),e.EventHandler.remove(this.parent.textArea,"mousedown",this.findTextTarget);break;case"getShapeSetting":this.getShapeSetting(t.value.id,t.value.obj);break;case"getShapeSettings":this.getShapeSettings(t.value.obj);break;case"isPointsInRange":this.isPointsInRange(t.value.x,t.value.y,t.value.obj);break;case"alignRotateFlipColl":this.alignRotateFlipColl(t.value.collection,t.value.isRotateFlipCollection,t.value.obj);break;case"selectShape":this.selectShape(t.value.id,t.value.obj);break;case"deleteShape":this.deleteShape(t.value.id);break;case"getMaxText":this.getMaxText(t.value.isTextBox,t.value.text,t.value.obj);break;case"setPointCollForLineArrow":t.value.obj.pointColl=this.getLinePoints(t.value.obj.activePoint.startX,t.value.obj.activePoint.startY,t.value.obj.activePoint.endX,t.value.obj.activePoint.endY);break;case"setPointCollForShapeRotation":this.setPointCollForShapeRotation(t.value.obj);break;case"setTextSettings":t.value.textSettings?this.textSettings=t.value.textSettings:t.value.fontFamily?this.textSettings.fontFamily=t.value.fontFamily:t.value.fontSize&&(this.textSettings.fontSize=t.value.fontSize);break;case"setStrokeSettings":t.value.strokeSettings?this.strokeSettings=t.value.strokeSettings:t.value.strokeColor?this.strokeSettings.strokeColor=t.value.strokeColor:t.value.fillColor?this.strokeSettings.fillColor=t.value.fillColor:t.value.strokeWidth&&(this.strokeSettings.strokeWidth=t.value.strokeWidth);break;case"getStrokeSettings":t.value.obj.strokeSettings=this.strokeSettings;break;case"setKeyHistory":this.keyHistory=t.value.keyHistory;break;case"getKeyHistory":t.value.obj.keyHistory=this.keyHistory;break;case"setTextBoxPos":this.setTextBoxPos(t.value.actObj,t.value.degree,t.value.flip,t.value.x,t.value.y);break;case"setTextBoxPoints":this.setTextBoxPoints(t.value.actObj,t.value.degree,t.value.flip,t.value.x,t.value.y);break;case"alignTextAreaIntoCanvas":this.alignTextAreaIntoCanvas();break;case"initializeTextShape":this.initializeTextShape(t.value.text,t.value.fontFamily,t.value.fontSize,t.value.bold,t.value.italic,t.value.strokeColor);break;case"stopPathDrawing":this.stopPathDrawing(t.value.e);break;case"updateArrowRatio":this.updateArrowRatio(t.value.obj);break;case"getSquarePointForRotatedShape":this.getSquarePointForRotatedShape(t.value.obj,t.value.object);break;case"reset":this.reset()}},i.prototype.getModuleName=function(){return"shape"},i.prototype.initShapePvtProps=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null}},i.prototype.drawEllipse=function(t,e,i,o,r,a,n){this.initializeShape("ellipse");var s=t&&e?{x:t,y:e}:null;this.drawShape("ellipse",r,a,n,s,i,o)},i.prototype.drawLine=function(t,e,i,o,r,a){this.initializeShape("line");var n=t&&e?{x:t,y:e}:null,s=i-t,l=o-e;this.drawShape("line",r,a,null,n,s,l)},i.prototype.drawPath=function(t,i,o){if(this.initializeShape("path"),t)this.drawShape("path",i,o,null,null,null,null,t);else{this.drawShape("line",i,o,null,null,null,null);var r=e.extend({},this.parent.objColl[this.parent.objColl.length-1],null,!0);r.shape="path",r.lineDraw=null,r.pointColl=[{x:r.activePoint.startX,y:r.activePoint.startY},{x:r.activePoint.endX,y:r.activePoint.endY}],this.parent.objColl[this.parent.objColl.length-1]=r}},i.prototype.drawArrow=function(t,e,i,o,r,a,n,s){this.initializeShape("arrow");var l=t&&e?{x:t,y:e}:null,p=i-t,h=o-e;this.drawShape("arrow",r,a,null,l,p,h,null,n,s)},i.prototype.drawRectangle=function(t,e,i,o,r,a,n){this.initializeShape("rectangle");var s=t&&e?{x:t,y:e}:null;this.drawShape("rectangle",r,a,n,s,i,o)},i.prototype.drawText=function(t,e,i,o,r,a,n,s){this.drawShapeText(i,o,r,a,n,s,t,e)},i.prototype.initializeShape=function(t){this.redrawActObj(),this.parent.activeObj.shape=t,"freehanddraw"===this.parent.currObjType.shape&&(this.apply(),this.parent.upperCanvas.style.cursor=this.parent.cursor="default",this.parent.currObjType.shape=""),this.parent.currObjType.isCustomCrop=!1},i.prototype.updateWidthHeight=function(t){return t.activePoint.width=t.activePoint.endX-t.activePoint.startX,t.activePoint.height=t.activePoint.endY-t.activePoint.startY,t},i.prototype.setDimension=function(t,e){t&&e&&(this.parent.activeObj.activePoint.width=t,this.parent.activeObj.activePoint.height=e,"ellipse"===this.parent.currObjType.shape.toLowerCase()&&(this.parent.activeObj.activePoint.width=2*t,this.parent.activeObj.activePoint.height=2*e))},i.prototype.getArrowType=function(t){var e=t;return t&&(e={None:"none",Arrow:"arrow",SolidArrow:"arrowSolid",Circle:"circle",SolidCircle:"circleSolid",Square:"square",SolidSquare:"squareSolid",Bar:"bar"}[""+t]),e},i.prototype.drawShape=function(t,i,o,r,a,n,s,l,p,h){var c=this,d=this.parent;if(!d.disabled&&d.isImageLoaded){d.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.redrawActObj();var v=e.extend([],d.objColl,[],!0);if(d.togglePen=!1,this.keyHistory="",this.parent.upperCanvas.style.display="block",this.refreshActiveObj(),d.currObjType.shape=t,"path"===d.currObjType.shape.toLowerCase()&&e.isNullOrUndefined(l))d.activeObj.shape=d.currObjType.shape.toLowerCase(),d.activeObj.pointColl=[],d.upperCanvas.style.cursor=this.parent.cursor="crosshair",d.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:"path"}}),e.isBlazor()||(d.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),d.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}));else if("freehanddraw"!==d.currObjType.shape.toLowerCase()&&""!==d.currObjType.shape.toLowerCase()){d.activeObj.shape=d.currObjType.shape.toLowerCase(),this.upperContext.clearRect(0,0,d.upperCanvas.width,d.upperCanvas.height),e.isNullOrUndefined(d.activeObj.strokeSettings)&&(d.activeObj.strokeSettings=this.strokeSettings),"path"===d.currObjType.shape.toLowerCase()&&l&&(d.activeObj.pointColl=l),d.activeObj.strokeSettings.strokeWidth=i||d.activeObj.strokeSettings.strokeWidth,d.activeObj.strokeSettings.strokeColor=o||d.activeObj.strokeSettings.strokeColor,d.activeObj.strokeSettings.fillColor=r||d.activeObj.strokeSettings.fillColor;var u=d.img.destWidth>100?100:d.img.destWidth/2,g=d.img.destHeight>100?100:d.img.destHeight/2;d.activeObj.activePoint.width=u,d.activeObj.activePoint.height=g,"line"===d.currObjType.shape.toLowerCase()||"arrow"===d.currObjType.shape.toLowerCase()?(d.activeObj.lineDraw="horizontal",d.activeObj.activePoint.height=0,"arrow"===d.currObjType.shape.toLowerCase()&&(d.activeObj.activePoint.width+=50,d.activeObj.start=this.getArrowType(p),d.activeObj.end=this.getArrowType(h))):"rectangle"===d.currObjType.shape.toLowerCase()&&(d.activeObj.activePoint.width+=d.activeObj.activePoint.width/2),this.setDimension(n,s),a?(d.activeObj.activePoint.startX=a.x,d.activeObj.activePoint.startY=a.y,d.activeObj.activePoint.endX=d.activeObj.activePoint.startX+d.activeObj.activePoint.width,d.activeObj.activePoint.endY=d.activeObj.activePoint.startY+d.activeObj.activePoint.height):this.setCenterPoints(),this.setPointCollForLineAndArrow(),"arrow"===d.currObjType.shape.toLowerCase()&&(d.activeObj.triangleDirection="right"),d.currObjType.isDragging=d.currObjType.isCustomCrop=!1,d.activeObj.shapeDegree=d.transform.degree,d.activeObj.shapeFlip=d.transform.currFlipState,d.activeObj.textFlip=d.transform.currFlipState,d.activeObj.flipObjColl=[];var b={shapeSettingsObj:{}};d.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:b}});var C=b.shapeSettingsObj,f={action:"insert",previousShapeSettings:C,currentShapeSettings:C};e.isBlazor()&&d.events&&!0===d.events.shapeChanging.hasDelegate?this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",f).then(function(t){c.updateShapeChangeEventArgs(t.currentShapeSettings),c.setDimension(n,s),d.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),d.updateToolbar(d.element,"quickAccessToolbar","shape"),d.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),d.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:v}}),d.isPublicMethod&&d.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),d.isPublicMethod=!1}):(d.trigger("shapeChanging",f),this.updateShapeChangeEventArgs(f.currentShapeSettings),this.setDimension(n,s),d.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),e.isBlazor()?d.updateToolbar(d.element,"quickAccessToolbar","shape"):d.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),d.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),d.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:v}}),d.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),d.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),d.isPublicMethod&&d.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),d.isPublicMethod=!1)}}},i.prototype.setPointCollForLineAndArrow=function(){var t=this.parent;if(("line"===t.activeObj.shape||"arrow"===t.activeObj.shape)&&(t.activeObj.pointColl=this.getLinePoints(t.activeObj.activePoint.startX,t.activeObj.activePoint.startY,t.activeObj.activePoint.endX,t.activeObj.activePoint.endY),t.activeObj.pointColl))for(var e=0,i=t.activeObj.pointColl.length;e<i;e++)t.activeObj.pointColl[e].ratioX=(t.activeObj.pointColl[e].x-t.img.destLeft)/t.img.destWidth,t.activeObj.pointColl[e].ratioY=(t.activeObj.pointColl[e].y-t.img.destTop)/t.img.destHeight},i.prototype.drawShapeText=function(t,i,o,r,a,n,s,l){var p=this,h=this.parent;if(!h.disabled&&h.isImageLoaded){"freehanddraw"===h.currObjType.shape&&(this.apply(),h.upperCanvas.style.cursor=h.cursor="default",h.currObjType.shape=""),h.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),h.togglePen=!1,this.redrawActObj();var c={currObj:{}};h.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:c}}),this.prevObj=c.currObj,this.prevObj.objColl=e.extend([],h.objColl,[],!0),this.prevObj.pointColl=e.extend([],h.pointColl,[],!0),this.prevObj.afterCropActions=e.extend([],h.afterCropActions,[],!0);var d={selPointColl:null};h.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:d}}),this.prevObj.selPointColl=e.extend([],d.selPointColl,[],!0),this.refreshActiveObj(),h.activeObj.shape=h.currObjType.shape="text",h.currObjType.isCustomCrop=!1,this.initializeTextShape(t,i,o,r,a,n),h.currObjType.isText=h.currObjType.isInitialText=!0,e.isNullOrUndefined(h.activeObj.textSettings.fontSize)&&(h.img.destWidth>h.img.destHeight?h.activeObj.textSettings.fontSize=h.img.destWidth/15:h.activeObj.textSettings.fontSize=h.img.destHeight/15,h.activeObj.textSettings.fontSize<20&&(h.activeObj.textSettings.fontSize=20)),h.img.destWidth<100?h.activeObj.textSettings.fontSize=Math.floor(h.img.destWidth/20):h.img.destHeight<100&&(h.activeObj.textSettings.fontSize=Math.floor(h.img.destHeight/20)),h.activeObj.shapeDegree=h.transform.degree,h.activeObj.shapeFlip=h.transform.currFlipState,h.activeObj.flipObjColl=[],this.updateFontStyles();var v=this.upperContext.measureText(h.activeObj.textSettings.text).width+.5*h.activeObj.textSettings.fontSize,u=h.activeObj.textSettings.fontSize+.25*h.activeObj.textSettings.fontSize;e.isNullOrUndefined(s)||e.isNullOrUndefined(l)?this.setCenterPoints(!0,v,u):(h.activeObj.activePoint.startX=s,h.activeObj.activePoint.startY=l,h.activeObj.activePoint.endX=h.activeObj.activePoint.startX+v,h.activeObj.activePoint.endY=h.activeObj.activePoint.startY+u);var g={shapeSettingsObj:{}};h.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:g}});var b=g.shapeSettingsObj,C={action:"insert",previousShapeSettings:b,currentShapeSettings:b};e.isBlazor()&&h.events&&!0===h.events.shapeChanging.hasDelegate?h.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",C).then(function(t){p.drawShapeTextEvent(t),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1}):(h.trigger("shapeChanging",C),this.drawShapeTextEvent(C),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1)}},i.prototype.drawShapeTextEvent=function(t){var i=this.parent;this.updateShapeChangeEventArgs(t.currentShapeSettings),this.addLetter(i.activeObj.textSettings.text),i.activeObj.textFlip=i.transform.currFlipState,this.updateFontRatio(i.activeObj),i.objColl.push(i.activeObj);var o=e.extend({},i.cropObj,{},!0);i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}}),e.isBlazor()?i.updateToolbar(i.element,"quickAccessToolbar","text"):i.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),i.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),e.isBlazor()||(i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))},i.prototype.initializeTextShape=function(t,i,o,r,a,n){var s=this.parent;this.keyHistory="",s.upperCanvas.style.display="block",e.isNullOrUndefined(s.activeObj.textSettings)&&(s.activeObj.textSettings=this.textSettings),e.isNullOrUndefined(s.activeObj.strokeSettings)&&(s.activeObj.strokeSettings=this.strokeSettings),s.activeObj.strokeSettings.strokeColor=n||s.activeObj.strokeSettings.strokeColor,s.activeObj.textSettings.text=t||s.activeObj.textSettings.text,s.activeObj.textSettings.fontFamily=i||s.activeObj.textSettings.fontFamily,s.activeObj.textSettings.fontSize=o||s.activeObj.textSettings.fontSize,s.activeObj.textSettings.bold=r||s.activeObj.textSettings.bold,s.activeObj.textSettings.italic=a||s.activeObj.textSettings.italic},i.prototype.redrawActObj=function(t,e,i){var o,r=this.parent;r.activeObj.shape&&(o=r.activeObj.shape.split("-")),r.activeObj.horTopLine&&r.activeObj.shape&&"crop"!==o[0]&&("block"===r.textArea.style.display?(r.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.updateFontRatio(r.activeObj,!0),t&&e?t!==r.activeObj.activePoint.startX&&e!==r.activeObj.activePoint.startY&&(this.updateTextFromTextArea(),this.applyActObj()):(this.updateTextFromTextArea(),this.apply(r.activeObj.shape,r.activeObj),r.objColl.push(r.activeObj),this.refreshActiveObj(),r.textArea.style.transform="",r.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}))):this.applyActObj(i))},i.prototype.apply=function(t,i,o){var r=this.parent;if(!r.disabled)if(r.togglePen&&!r.currObjType.isCustomCrop){var a=r.img.destLeft,n=r.img.destTop,s=r.img.destWidth,l=r.img.destHeight;r.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1});var p=this.lowerContext.filter;this.lowerContext.filter="none",r.togglePen=!1,this.iterateObjColl(),r.notify("freehandDraw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),r.togglePen=!1,(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r.img.destLeft=a,r.img.destTop=n,r.img.destWidth=s,r.img.destHeight=l,this.lowerContext.filter=p}else o=o||"original",e.isNullOrUndefined(r.activeObj.shape)&&e.isNullOrUndefined(t)?r.currObjType.shape="":r.currObjType.shape=t||r.currObjType.shape,""!==r.currObjType.shape&&(this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),"text"===r.activeObj.shape?(r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),r.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}})):r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i}}),r.activeObj.shape=r.currObjType.shape.toLowerCase(),t||""===r.currObjType.shape||r.currObjType.isCustomCrop||r.objColl.push(e.extend({},r.activeObj,{},!0)),this.keyHistory="")},i.prototype.setCenterPoints=function(t,e,i){var o,r,a=this.parent;t&&e&&i?(o=e,r=i):(o=a.activeObj.activePoint.width,r=a.activeObj.activePoint.height),a.activeObj.activePoint.startX=a.lowerCanvas.width/2-o/2,a.activeObj.activePoint.startY=a.lowerCanvas.height/2-r/2,a.activeObj.activePoint.endX=a.lowerCanvas.width/2+o/2,a.activeObj.activePoint.endY=a.lowerCanvas.height/2+r/2},i.prototype.updSelChangeEventArgs=function(t){var e=this.parent;e.activeObj.activePoint.startX=t.startX,e.activeObj.activePoint.startY=t.startY,e.activeObj.activePoint.width=t.width,e.activeObj.activePoint.height=t.height,e.activeObj.activePoint.endX=e.activeObj.activePoint.startX+e.activeObj.activePoint.width,e.activeObj.activePoint.endY=e.activeObj.activePoint.startY+e.activeObj.activePoint.height},i.prototype.updateShapeChangeEventArgs=function(t){var e=this.parent;switch(e.activeObj.currIndex=t.id,e.activeObj.activePoint.startX=t.startX,e.activeObj.activePoint.startY=t.startY,e.activeObj.activePoint.width=t.width,e.activeObj.activePoint.height=t.height,e.activeObj.activePoint.endX=e.activeObj.activePoint.startX+e.activeObj.activePoint.width,e.activeObj.activePoint.endY=e.activeObj.activePoint.startY+e.activeObj.activePoint.height,e.activeObj.strokeSettings.strokeColor=t.strokeColor,e.activeObj.strokeSettings.fillColor=t.fillColor,e.activeObj.shape){case"ellipse":e.activeObj.activePoint.width=t.radius/2;break;case"line":case"arrow":e.activeObj.activePoint.width=t.length;break;case"text":e.activeObj.keyHistory=t.text,e.activeObj.textSettings.fontSize=t.fontSize,e.activeObj.strokeSettings.strokeColor=t.color}if("text"===e.activeObj.shape&&e.activeObj.textSettings)for(var i=0;i<t.fontStyle.length;i++)switch(t.fontStyle[i]){case"bold":e.activeObj.textSettings.bold=!0;break;case"italic":e.activeObj.textSettings.italic=!0;break;case"underline":e.activeObj.textSettings.underline=!0}},i.prototype.addLetter=function(t){var e=this.parent;if("none"===e.textArea.style.display&&(e.currObjType.isText||"text"===e.activeObj.shape)){"Backspace"===t?this.keyHistory=this.keyHistory.slice(0,-1):this.keyHistory+=t,this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.updateFontStyles();var i=this.upperContext.measureText(this.keyHistory).width+.5*e.activeObj.textSettings.fontSize,o=e.activeObj.textSettings.fontSize+.25*e.activeObj.textSettings.fontSize;this.upperContext.fillText(this.keyHistory,e.activeObj.activePoint.startX,e.activeObj.activePoint.startY+e.activeObj.textSettings.fontSize),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.currObjType.isText=!0,e.notify("selection",{prop:"setActivePoint",onPropertyChange:!1,value:{startX:i,startY:o}})}},i.prototype.redrawText=function(){var t=this.parent,e="";t.activeObj.textSettings.bold&&(e+="bold "),t.activeObj.textSettings.italic&&(e+="italic "),this.upperContext.font=e+t.activeObj.textSettings.fontSize+"px "+t.activeObj.textSettings.fontFamily;var i=t.activeObj.keyHistory.split("\n"),o="block"===t.textArea.style.display?this.getMaxText(!0):this.getMaxText(),r=this.upperContext.measureText(o).width+.5*t.activeObj.textSettings.fontSize,a=i.length*(t.activeObj.textSettings.fontSize+.25*t.activeObj.textSettings.fontSize);t.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:r,height:a}}),t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.activeObj.activePoint,obj:t.activeObj,isMouseMove:null,x:null,y:null}}),t.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:t.activeObj}})},i.prototype.updateTextFromTextArea=function(){var t=this.parent;if(t.activeObj.keyHistory!==t.textArea.value){var i=e.extend({},t.cropObj,{},!0),o={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],t.objColl,[],!0),r.pointColl=e.extend([],t.pointColl,[],!0),r.afterCropActions=e.extend([],this.parent.afterCropActions,[],!0);var a={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"text",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:t.activeObj.keyHistory,currentText:t.textArea.value,previousFilter:null,isCircleCrop:null}})}t.activeObj.keyHistory=t.textArea.value,t.textArea.style.display="none",t.textArea.value="",this.updateFontStyles();var n=this.upperContext.measureText(t.activeObj.keyHistory).width+.5*t.activeObj.textSettings.fontSize,s=t.activeObj.textSettings.fontSize+.25*this.parent.activeObj.textSettings.fontSize,l=t.activeObj.keyHistory.split("\n");if(l.length>1){s*=l.length;for(var p=[],h=0,c=l.length;h<c;h++)p.push(this.upperContext.measureText(l[h]).width+.5*t.activeObj.textSettings.fontSize);n=Math.max.apply(Math,p)}t.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:n,height:s}}),t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.activeObj.activePoint,obj:t.activeObj,isMouseMove:null,x:null,y:null}}),this.updImgRatioForActObj()},i.prototype.iterateObjColl=function(){for(var t=this.parent,e=0,i=t.objColl.length;e<i;e++)this.apply(t.objColl[e].shape,t.objColl[e]),this.refreshActiveObj()},i.prototype.updImgRatioForActObj=function(){var t=this.parent;t.activeObj.imageRatio={startX:(t.activeObj.activePoint.startX-t.img.destLeft)/t.img.destWidth,startY:(t.activeObj.activePoint.startY-t.img.destTop)/t.img.destHeight,endX:(t.activeObj.activePoint.endX-t.img.destLeft)/t.img.destWidth,endY:(t.activeObj.activePoint.endY-t.img.destTop)/t.img.destHeight,width:t.img.destWidth/t.activeObj.activePoint.width,height:t.img.destHeight/t.activeObj.activePoint.height},t.activeObj.rotationCirclePointColl&&(t.activeObj.rotationCirclePointColl.ratioX=(t.activeObj.rotationCirclePointColl.x-t.img.destLeft)/t.img.destWidth,t.activeObj.rotationCirclePointColl.ratioY=(t.activeObj.rotationCirclePointColl.y-t.img.destTop)/t.img.destHeight),"path"===t.activeObj.shape?this.updatePathRatio(t.activeObj):"arrow"===t.activeObj.shape&&this.updateArrowRatio(t.activeObj)},i.prototype.zoomObjColl=function(t){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++){var a=i.objColl[o];if(a.activePoint.startX=a.imageRatio.startX*i.img.destWidth+i.img.destLeft,a.activePoint.startY=a.imageRatio.startY*i.img.destHeight+i.img.destTop,a.activePoint.endX=a.imageRatio.endX*i.img.destWidth+i.img.destLeft,a.activePoint.endY=a.imageRatio.endY*i.img.destHeight+i.img.destTop,"text"===(a=this.updateWidthHeight(a)).shape)this.updateFontSize(a);else if("line"===a.shape||"arrow"===a.shape){a.pointColl=this.getLinePoints(a.activePoint.startX,a.activePoint.startY,a.activePoint.endX,a.activePoint.endY);for(var n=0,s=a.pointColl.length;n<s;n++)a.pointColl[n].ratioX=(a.pointColl[n].x-i.img.destLeft)/i.img.destWidth,a.pointColl[n].ratioY=(a.pointColl[n].y-i.img.destTop)/i.img.destHeight;"arrow"===a.shape&&this.updateArrowSize(a)}else if("path"===a.shape){for(var l=0,p=a.pointColl.length;l<p;l++)a.pointColl[l].x=a.pointColl[l].ratioX*i.img.destWidth+i.img.destLeft,a.pointColl[l].y=a.pointColl[l].ratioY*i.img.destHeight+i.img.destTop;this.updatePathRatio(a)}if(i.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:a.activePoint,obj:a}}),e.isNullOrUndefined(t)){var h=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(a.shape,a),this.refreshActiveObj(),this.lowerContext.filter=h}"line"!==a.shape&&"arrow"!==a.shape&&"path"!==a.shape&&0!==a.rotatedAngle&&(this.setPointCollForShapeRotation(a),a.rotationCirclePoint.x=a.rotationCirclePoint.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePoint.y=a.rotationCirclePoint.ratioY*i.img.destHeight+i.img.destTop,a.rotationCirclePointColl.x=a.rotationCirclePointColl.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePointColl.y=a.rotationCirclePointColl.ratioY*i.img.destHeight+i.img.destTop)}},i.prototype.redrawObj=function(t){var e=this.parent;if(this.parent.objColl.length>0)if("horizontal"===t||"vertical"===t||"Horizontal"===t||"Vertical"===t||"horizontalVertical"===t||"verticalHorizontal"===t)this.updateCurrentActiveObjPoint(t.toLowerCase());else if("number"==typeof t){this.updateCurrentActiveObjPoint(t);var i=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var o=0,r=e.objColl.length;o<r;o++)"crop"!==e.objColl[o].shape.split("-")[0]&&this.apply(e.objColl[o].shape,e.objColl[o]);this.lowerContext.filter=i}},i.prototype.updateCurrentActiveObjPoint=function(t){for(var i,o=this.parent,r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(o.activeObj.shape===n.shape&&o.activeObj.activePoint.startX===n.activePoint.startX&&o.activeObj.activePoint.startY===n.activePoint.startY&&o.activeObj.activePoint.endX===n.activePoint.endX&&o.activeObj.activePoint.endY===n.activePoint.endY&&o.activeObj.currIndex===n.currIndex){i=r;break}}if("horizontal"===t||"vertical"===t||"Horizontal"===t||"Vertical"===t||"horizontalvertical"===t||"verticalhorizontal"===t){if("horizontal"===t||"Horizontal"===t)for(var s=0,a=o.objColl.length;s<a;s++)(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"horizontal"):0!==n.rotatedAngle&&(n.rotatedAngle=n.rotatedAngle+2*(Math.PI-n.rotatedAngle),n.rotationCirclePointColl.x<=o.img.destLeft+o.img.destWidth/2?n.rotationCirclePointColl.x=o.img.destLeft+o.img.destWidth-(n.rotationCirclePointColl.x-o.img.destLeft):n.rotationCirclePointColl.x>=o.img.destLeft+o.img.destWidth/2&&(n.rotationCirclePointColl.x=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.rotationCirclePointColl.x)),n.rotationCirclePointColl.ratioX=(n.rotationCirclePointColl.x-o.img.destLeft)/o.img.destWidth),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height});else if("vertical"===t||"Vertical"===t)for(s=0;s<o.objColl.length;s++)(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"vertical"):0!==n.rotatedAngle&&(n.rotatedAngle=-n.rotatedAngle,n.rotationCirclePointColl.y<=o.img.destTop+o.img.destHeight/2?n.rotationCirclePointColl.y=o.img.destTop+o.img.destHeight-(n.rotationCirclePointColl.y-o.img.destTop):n.rotationCirclePointColl.y>=o.img.destTop+o.img.destHeight/2&&(n.rotationCirclePointColl.y=o.img.destTop+(o.img.destTop+o.img.destHeight-n.rotationCirclePointColl.y)),n.rotationCirclePointColl.ratioY=(n.rotationCirclePointColl.y-o.img.destTop)/o.img.destHeight),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height});else if("verticalhorizontal"===t||"horizontalvertical"===t)for(var s=0,a=o.objColl.length;s<a;s++)(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"!==n.shape&&"arrow"!==n.shape&&"path"!==n.shape||this.flipLineArrowObj(n,t),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height});void 0!==i&&(o.activeObj=e.extend({},o.objColl[i],{},!0))}else if(90===t)this.rotateObjColl();else if(-90===t)for(s=0;s<3;s++)this.rotateObjColl();else if("number"==typeof t)if(t>0)this.rotateObjColl();else for(s=0;s<3;s++)this.rotateObjColl()},i.prototype.rotateObjColl=function(){for(var t=this.parent,e=0,i=t.objColl.length;e<i;e++)(o=t.objColl[e]).activePoint.startY=t.img.destTop+t.img.destHeight*o.imageRatio.startX,o.activePoint.endY=t.img.destTop+t.img.destHeight*o.imageRatio.endX,o.activePoint.startX=t.img.destLeft+t.img.destWidth-t.img.destWidth*o.imageRatio.endY,o.activePoint.endX=t.img.destLeft+t.img.destWidth-t.img.destWidth*o.imageRatio.startY,o=this.updateWidthHeight(t.objColl[e]),this.updateFontSize(o),"line"===o.shape||"arrow"===o.shape||"path"===o.shape?(this.rotateLineArrowObj(o),"arrow"===o.shape&&this.updateArrowSize(o)):0!==o.rotatedAngle&&(o.rotationCirclePointColl.y=t.img.destTop+t.img.destHeight*o.rotationCirclePointColl.ratioX,o.rotationCirclePointColl.x=t.img.destLeft+t.img.destWidth-t.img.destWidth*o.rotationCirclePointColl.ratioY,o.rotationCirclePointColl.ratioX=(o.rotationCirclePointColl.x-t.img.destLeft)/t.img.destWidth,o.rotationCirclePointColl.ratioY=(o.rotationCirclePointColl.y-t.img.destTop)/t.img.destHeight);for(var e=0,i=t.objColl.length;e<i;e++)t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.objColl[e].activePoint,obj:t.objColl[e]}});for(var e=0,i=t.objColl.length;e<i;e++){var o=t.objColl[e];o.imageRatio={startX:(o.activePoint.startX-t.img.destLeft)/t.img.destWidth,startY:(o.activePoint.startY-t.img.destTop)/t.img.destHeight,endX:(o.activePoint.endX-t.img.destLeft)/t.img.destWidth,endY:(o.activePoint.endY-t.img.destTop)/t.img.destHeight,width:t.img.destWidth/o.activePoint.width,height:t.img.destHeight/o.activePoint.height}}},i.prototype.rotateLineArrowObj=function(t){if(!e.isNullOrUndefined(t.pointColl)){var i=this.parent;if(t.pointColl.length>0){for(o=0;o<t.pointColl.length;o++)t.pointColl[o].y=i.img.destTop+i.img.destHeight*t.pointColl[o].ratioX,t.pointColl[o].x=i.img.destLeft+i.img.destWidth-i.img.destWidth*t.pointColl[o].ratioY;for(var o=0;o<t.pointColl.length;o++)t.pointColl[o].ratioX=(t.pointColl[o].x-i.img.destLeft)/i.img.destWidth,t.pointColl[o].ratioY=(t.pointColl[o].y-i.img.destTop)/i.img.destHeight;var r=void 0;r=e.isNullOrUndefined(t.pointColl[t.pointColl.length-2])?{x:0,y:0}:{x:t.pointColl[t.pointColl.length-2].x,y:t.pointColl[t.pointColl.length-2].y};var a=t.pointColl[t.pointColl.length-1].x-r.x,n=t.pointColl[t.pointColl.length-1].y-r.y;t.activePoint.startX=t.pointColl[0].x,t.activePoint.startY=t.pointColl[0].y,t.activePoint.endX=t.pointColl[t.pointColl.length-1].x+a/2,t.activePoint.endY=t.pointColl[t.pointColl.length-1].y+n/2,t=this.updateWidthHeight(t)}}},i.prototype.flipLineArrowObj=function(t,i){if(!e.isNullOrUndefined(t.pointColl)&&("horizontal"===i.toLowerCase()?this.lineArrowHorizontalFlip(t):"vertical"===i.toLowerCase()?this.lineArrowVerticalFlip(t):(this.lineArrowHorizontalFlip(t),t.shapeFlip="",this.lineArrowVerticalFlip(t)),t.activePoint.startX=t.pointColl[0].x,t.activePoint.startY=t.pointColl[0].y,t.activePoint.endX=t.pointColl[t.pointColl.length-1].x,t.activePoint.endY=t.pointColl[t.pointColl.length-1].y,t.activePoint.startX>t.activePoint.endX)){var o=t.activePoint.startX;t.activePoint.startX=t.activePoint.endX,t.activePoint.endX=o,o=t.activePoint.startY,t.activePoint.startY=t.activePoint.endY,t.activePoint.endY=o}},i.prototype.lineArrowHorizontalFlip=function(t){var e=this.parent;if(t.shapeFlip!==e.transform.currFlipState){for(var i=0,o=t.pointColl.length;i<o;i++){var r=t.pointColl[i];r.x<=e.img.destLeft+e.img.destWidth/2?r.x=e.img.destLeft+e.img.destWidth-(r.x-e.img.destLeft):r.x>=e.img.destLeft+e.img.destWidth/2&&(r.x=e.img.destLeft+(e.img.destLeft+e.img.destWidth-r.x)),r.ratioX=(r.x-e.img.destLeft)/e.img.destWidth,r.ratioY=(r.y-e.img.destTop)/e.img.destHeight}if("arrow"===t.shape){var a=t.start;t.start=t.end,t.end=a}t.shapeFlip=e.transform.currFlipState}},i.prototype.lineArrowVerticalFlip=function(t){var e=this.parent;if(t.shapeFlip!==e.transform.currFlipState){for(var i=0,o=t.pointColl.length;i<o;i++){var r=t.pointColl[i];r.y<=e.img.destTop+e.img.destHeight/2?r.y=e.img.destTop+e.img.destHeight-(r.y-e.img.destTop):r.y>=e.img.destTop+e.img.destHeight/2&&(r.y=e.img.destTop+(e.img.destTop+e.img.destHeight-r.y)),r.ratioX=(r.x-e.img.destLeft)/e.img.destWidth,r.ratioY=(r.y-e.img.destTop)/e.img.destHeight}t.shapeFlip=e.transform.currFlipState}},i.prototype.getRotDegOfShape=function(t){var e;return(e=0===t.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-t.shapeDegree)<0&&(e=360+e),e},i.prototype.renderTextArea=function(t,i,o){var r=this.parent,a=this.getRotDegOfShape(r.activeObj);this.transformTextArea(),e.isBlazor()?r.updateToolbar(r.element,"destroyQuickAccessToolbar"):r.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),r.element.querySelector("#"+r.element.id+"_duplicate")&&r.element.querySelector("#"+r.element.id+"_duplicate").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_remove")&&r.element.querySelector("#"+r.element.id+"_remove").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_editText")&&r.element.querySelector("#"+r.element.id+"_editText").classList.add("e-disabled"),r.textArea.style.display="block",r.textArea.style.left=t+"px",r.textArea.style.top=i+"px",r.textArea.style.fontFamily=o.textSettings.fontFamily,r.textArea.style.fontSize=o.textSettings.fontSize+"px",r.textArea.style.color=o.strokeSettings.strokeColor,r.textArea.style.fontWeight=o.textSettings.bold?"bold":"normal",r.textArea.style.fontStyle=o.textSettings.italic?"italic":"normal",r.textArea.style.border="2px solid "+r.themeColl[r.theme].primaryColor,r.textArea.value=o.keyHistory,r.textArea.style.overflow="hidden",r.textArea.style.width="auto",r.textArea.style.height="auto",r.textArea.focus();r.transform.zoomFactor;var n=o.activePoint,s=n.width,l=n.height;a%90==0&&a%180!=0&&0!==a?(r.textArea.style.width=l+"px",r.textArea.style.height=s+"px"):(r.textArea.style.width=s+"px",r.textArea.style.height=l+"px"),this.setTextBoxWidth();var p={flipColl:null};r.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:p}}),p.flipColl.length<=1&&this.setTextBoxHeight(),a%90==0&&a%180!=0?parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destTop+r.img.destHeight&&this.alignTextAreaIntoCanvas():parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destLeft+r.img.destWidth&&this.alignTextAreaIntoCanvas(),r.notify("selection",{prop:"clearUpperCanvas",onPropertyChange:!1})},i.prototype.setTextBoxWidth=function(t){var i=this.parent,o=this.getMaxText(!0);"block"===i.textArea.style.display?this.updateFontStyles(!0):this.updateFontStyles();var r=this.upperContext.measureText(o).width+parseFloat(i.textArea.style.fontSize)/2,a=t?this.upperContext.measureText(String.fromCharCode(t.which)).width:0,n=e.extend({},i.activeObj,{},!0),s="",l=this.getRotDegOfShape(n);if(s=n.shapeFlip!==i.transform.currFlipState?"":i.transform.currFlipState,t&&parseFloat(i.textArea.style.width)<r+a||e.isNullOrUndefined(t))if(0===l)"horizontal"===s.toLowerCase()?parseFloat(i.textArea.style.left)-i.img.destLeft-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)>r+a&&(i.textArea.style.width=r+a+"px");else if(90===l)"vertical"===s.toLowerCase()?parseFloat(i.textArea.style.top)-i.img.destTop-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destHeight-(parseFloat(i.textArea.style.top)-i.img.destTop)>r+a&&(i.textArea.style.width=r+a+"px");else if(180===l){var p=parseFloat(i.textArea.style.left),h=i.img.destLeft;"horizontal"===s.toLowerCase()?i.img.destWidth-(p-h)>r+a&&(i.textArea.style.width=r+a+"px"):p-h-r-a>0&&(i.textArea.style.width=r+a+"px")}else if(270===l){var c=parseFloat(i.textArea.style.top),d=i.img.destTop;"vertical"===s.toLowerCase()?i.img.destHeight-(c-d)>r+a&&(i.textArea.style.width=r+a+"px"):c-d-r-a>0&&(i.textArea.style.width=r+a+"px")}},i.prototype.setTextBoxHeight=function(){var t,i=this.parent,o=e.extend({},i.activeObj,{},!0),r="",a=this.getRotDegOfShape(o);switch(r=o.textFlip===i.transform.currFlipState?"":""===o.textFlip?i.transform.currFlipState:o.textFlip,a){case 0:"vertical"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destHeight-(i.img.destHeight-parseFloat(i.textArea.style.top))+"px":(t=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-t+"px");break;case 90:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px":i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px";break;case 180:"vertical"===r.toLowerCase()?(t=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-t+"px"):i.textArea.style.maxHeight=parseFloat(i.textArea.style.top)-i.img.destTop+"px";break;case 270:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px":i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px"}},i.prototype.updatePathRatio=function(t){for(var e=this.parent,i=0,o=t.pointColl.length;i<o;i++){var r=t.pointColl[i];r.ratioX=(r.x-e.img.destLeft)/e.img.destWidth,r.ratioY=(r.y-e.img.destTop)/e.img.destHeight}},i.prototype.stopPathDrawing=function(t){var i=this.parent;if("path"===i.activeObj.shape){var o={shape:null};if(i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:o}}),"path"===o.shape){var r=e.extend({},this.parent.cropObj,{},!0),a={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=e.extend([],this.parent.objColl,[],!0),n.pointColl=e.extend([],this.parent.pointColl,[],!0),n.afterCropActions=e.extend([],this.parent.afterCropActions,[],!0);var s={selPointColl:null};this.parent.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=e.extend([],s.selPointColl,[],!0),i.notify("selection",{prop:"setCurrentDrawingShape",value:{value:""}}),i.currObjType.isDragging=!1,"touchstart"!==t.type&&i.activeObj.pointColl.pop(),this.updatePathRatio(i.activeObj),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("selection",{prop:"mouseUpEventHandler",value:{e:t}}),i.notify("draw",{prop:"setNewPath",value:{bool:!0}}),i.objColl[i.objColl.length-1]&&i.selectShape(i.objColl[i.objColl.length-1].currIndex),e.isBlazor()?i.updateToolbar(i.element,"quickAccessToolbar",i.activeObj.shape):i.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})}}},i.prototype.findTextTarget=function(t){var i=this.parent;if("text"!==i.activeObj.shape)return void this.stopPathDrawing(t);var o,r;if("dblclick"===t.type?(o=t.clientX,r=t.clientY):"touchstart"===t.type&&(o=t.touches[0].clientX,r=t.touches[0].clientY,i.notify("selection",{prop:"setTouchEndPoint",onPropertyChange:!1,value:{x:t.touches[0].clientX,y:t.touches[0].clientY}})),i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!0}}),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!1}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),e.isNullOrUndefined(o)||e.isNullOrUndefined(r))if("block"===i.textArea.style.display&&""!==this.selectedText()&&"mousedown"===t.type){l=i.textArea.value;i.textArea.value+="a",i.textArea.value=l}else"none"===i.textArea.style.display&&(i.textArea.style.display="block");else{var a=this.parent.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top;var n="",s=this.getRotDegOfShape(i.activeObj);n=""===i.activeObj.textFlip?i.activeObj.textFlip===i.transform.currFlipState?"":i.transform.currFlipState:i.activeObj.textFlip===i.transform.currFlipState?"":""===i.transform.currFlipState?i.activeObj.textFlip:i.transform.currFlipState;var l=void 0;if("none"===i.textArea.style.display){l=e.extend({},i.activeObj,{},!0);for(var p=0;p<i.objColl.length;p++)JSON.stringify(i.activeObj)===JSON.stringify(i.objColl[p])&&i.objColl.splice(p,1);this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),this.lowerContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.activeObj=l,this.updateFontStyles();var h=e.extend({},i.activeObj,{},!0);if(o>=h.activePoint.startX-2*h.topLeftCircle.radius&&o<=h.activePoint.endX+2*h.topLeftCircle.radius&&r>=h.activePoint.startY-2*h.topLeftCircle.radius&&r<=h.activePoint.endY+2*h.topLeftCircle.radius){if(this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),4===h.flipObjColl.length&&(h.flipObjColl=[],n=""),""===n&&h.flipObjColl.length>1&&(n=h.flipObjColl[h.flipObjColl.length-1]),h.flipObjColl.length<=1)o=(c=this.setTextBoxPos(h,s,n,o,r)).x,r=c.y;else{var c=this.setTextBoxPoints(h,s,n,o,r);o=c.x,r=c.y}0!==i.activeObj.rotatedAngle&&(o=i.activeObj.horTopLinePointColl[0].x,r=i.activeObj.horTopLinePointColl[0].y),this.renderTextArea(o,r,h)}else this.applyActObj()}}},i.prototype.setTextBoxPos=function(t,e,i,o,r){var a={x:o,y:r};switch(e){case 0:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.endY):(a.x=t.activePoint.startX,a.y=t.activePoint.startY);break;case 90:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):(a.x=t.activePoint.endX,a.y=t.activePoint.startY);break;case 180:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.startY):(a.x=t.activePoint.endX,a.y=t.activePoint.endY);break;case 270:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):(a.x=t.activePoint.startX,a.y=t.activePoint.endY)}return a},i.prototype.setTextBoxPoints=function(t,e,i,o,r){var a={x:o,y:r};switch(e){case 0:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.startY);break;case 90:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.startY);break;case 180:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.endY);break;case 270:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.endY)}return a},i.prototype.selectedText=function(){var t=this.parent.textArea.selectionStart,e=this.parent.textArea.selectionEnd;return this.parent.textArea.value.substring(t,e)},i.prototype.panObjColl=function(t,e,i){for(var o=this.parent,r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(""===i||"vertical"===i){if(n.activePoint.startX+=t,n.activePoint.endX+=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x+=t),"path"===n.shape)for(var s=0,l=n.pointColl.length;s<l;s++)n.pointColl[s].x+=t}else if(n.activePoint.startX-=t,n.activePoint.endX-=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x-=t),"path"===n.shape)for(var s=0,p=n.pointColl.length;s<p;s++)n.pointColl[s].x-=t;if(""===i||"horizontal"===i){if(n.activePoint.startY+=e,n.activePoint.endY+=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y+=e),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y+=e}else if(n.activePoint.startY-=e,n.activePoint.endY-=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y-=e),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y-=e;if(n=this.updateWidthHeight(n),o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}}),"line"===n.shape||"arrow"===n.shape){n.pointColl=this.getLinePoints(n.activePoint.startX,n.activePoint.startY,n.activePoint.endX,n.activePoint.endY);for(var h=0,c=n.pointColl.length;h<c;h++)n.pointColl[h].ratioX=(n.pointColl[h].x-o.img.destLeft)/o.img.destWidth,n.pointColl[h].ratioY=(n.pointColl[h].y-o.img.destTop)/o.img.destHeight}var d=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(n.shape,n),this.lowerContext.filter=d,this.refreshActiveObj()}},i.prototype.updateFontStyles=function(t){var e=this.parent;this.upperContext.strokeStyle=e.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=e.activeObj.strokeSettings.strokeColor;var i="";e.activeObj.textSettings.bold&&(i="bold "),e.activeObj.textSettings.italic&&(i="italic "),e.activeObj.textSettings.bold&&e.activeObj.textSettings.italic&&(i="italic bold ");var o=t?parseFloat(e.textArea.style.fontSize):e.activeObj.textSettings.fontSize,r="block"===e.textArea.style.display?e.textArea.style.fontFamily:e.activeObj.textSettings.fontFamily;this.upperContext.font=i+o+"px "+r},i.prototype.applyFontStyle=function(t){var i=this.parent;this.pushActItemIntoObj();var o=e.extend([],i.objColl,[],!0);switch(i.objColl.pop(),"none"===i.textArea.style.display?this.updateFontRatio(i.activeObj):this.updateFontRatio(i.activeObj,!0),t){case"default":this.updateFontStyle(t,o,"normal","normal");break;case"bold":this.updateFontStyle(t,o,"bold","normal");break;case"italic":this.updateFontStyle(t,o,"normal","italic");break;case"bolditalic":this.updateFontStyle(t,o,"bold","italic")}},i.prototype.updateFontStyle=function(t,e,i,o){var r=this.parent;if("block"===r.textArea.style.display){var a=this.getTextAreaWidth(t);r.textArea.style.width=a+"px",r.textArea.style.fontWeight=i,r.textArea.style.fontStyle=o,this.updateObjColl(t,e)}else this.textSettings.bold=r.activeObj.textSettings.bold="normal"!==i,this.textSettings.italic=r.activeObj.textSettings.italic="normal"!==o,this.redrawText(),r.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:e}})},i.prototype.updateArrowRatio=function(t){var e={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:e}});var i,o=this.getRotDegOfShape(t);i=0===o||180===o||-180===o?Math.abs(t.activePoint.width):Math.abs(t.activePoint.height);for(var r,a=0,n=["bar","arrow","arrowSolid","circle","square"];a<n.length;a++){r=n[a];var s=i/e.arrowDimension[r].width,l=i/e.arrowDimension[r].height;e.arrowDimension[r].ratioX=s,e.arrowDimension[r].ratioY=l}},i.prototype.updateArrowSize=function(t){var e={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:e}});var i,o=this.getRotDegOfShape(t);i=0===o||180===o||-180===o?Math.abs(t.activePoint.width):Math.abs(t.activePoint.height);for(var r,a=0,n=["bar","arrow","arrowSolid","circle","square"];a<n.length;a++){r=n[a];var s=e.arrowDimension[r].ratioX,l=e.arrowDimension[r].ratioY;e.arrowDimension[r].width=i/s,e.arrowDimension[r].height=i/l}},i.prototype.updateFontRatio=function(t,i){var o=this.parent,r=this.getMaxText(i),a=this.upperContext.measureText(r).width+.5*o.activeObj.textSettings.fontSize,n=o.activeObj.textSettings.fontSize+.25*o.activeObj.textSettings.fontSize,s=this.getRotDegOfShape(t);e.isNullOrUndefined(i)?0===s||180===Math.abs(s)?t.textSettings.fontRatio=a/t.textSettings.fontSize:t.textSettings.fontRatio=n/t.textSettings.fontSize:i&&(t.textSettings.fontRatio=a/parseFloat(o.textArea.style.fontSize))},i.prototype.updateFontSize=function(t){var e=this.getRotDegOfShape(t);0===e||180===Math.abs(e)?t.textSettings.fontSize=t.activePoint.width/t.textSettings.fontRatio:t.textSettings.fontSize=t.activePoint.height/t.textSettings.fontRatio},i.prototype.updateObjColl=function(t,i){var o=this.parent,r=e.extend({},o.cropObj,{},!0),a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=i,n.pointColl=e.extend([],o.pointColl,[],!0),n.afterCropActions=e.extend([],o.afterCropActions,[],!0);var s={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=e.extend([],s.selPointColl,[],!0);var l=o.activeObj.textSettings.bold,p=o.activeObj.textSettings.italic;switch(t){case"default":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!1;break;case"bold":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!1;break;case"italic":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!0;break;case"bolditalic":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!0}o.objColl.push(o.activeObj),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.objColl.pop(),o.activeObj.textSettings.bold=l,o.activeObj.textSettings.italic=p},i.prototype.pushActItemIntoObj=function(){if("none"===this.parent.textArea.style.display)this.parent.objColl.push(this.parent.activeObj);else{var t=e.extend({},this.parent.activeObj,{},!0);this.parent.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.parent.objColl.push(this.parent.activeObj),this.parent.activeObj=t}},i.prototype.clearActObj=function(){"none"===this.parent.textArea.style.display&&(this.refreshActiveObj(),this.applyActObj(),this.refreshActiveObj(),this.parent.currObjType.isCustomCrop=!1)},i.prototype.refreshActiveObj=function(){this.parent.activeObj={},this.parent.activeObj.activePoint={startX:0,startY:0,endX:0,endY:0,width:0,height:0},this.parent.activeObj.triangle=[],this.parent.activeObj.triangleRatio=[],this.parent.activeObj.flipObjColl=[],this.parent.activeObj.strokeSettings=this.strokeSettings,this.parent.activeObj.textSettings=this.textSettings,this.parent.activeObj.rotatedAngle=0},i.prototype.applyActObj=function(t){var i=!1;if(void 0!==this.parent.activeObj.shape&&"text"===this.parent.activeObj.shape&&""===this.parent.activeObj.keyHistory)this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height);else{var o=void 0,r=!1;if(void 0!==this.parent.activeObj.shape&&(o=this.parent.activeObj.shape.split("-")),void 0===o&&this.parent.currObjType.isCustomCrop?r=!0:void 0!==o&&"crop"===o[0]&&(r=!0),this.parent.activeObj.shape&&!r&&"shape"!==this.parent.activeObj.shape){for(s=0;s<this.parent.objColl.length;s++)if(JSON.stringify(this.parent.activeObj)===JSON.stringify(this.parent.objColl[s])){i=!0;break}if(!i){e.isNullOrUndefined(this.parent.activeObj.currIndex)&&(this.parent.activeObj.currIndex="shape_"+(this.parent.objColl.length+1)),this.updImgRatioForActObj();var a=this.parent.activeObj.currIndex.split("_"),n=this.parent.objColl.splice(0,parseInt(a[1],10)-1);n.push(e.extend({},this.parent.activeObj,{},!0));for(var s=0;s<this.parent.objColl.length;s++)n.push(this.parent.objColl[s]);this.parent.objColl=n,n=[],this.refreshActiveObj(),this.lowerContext.clearRect(0,0,this.parent.lowerCanvas.width,this.parent.lowerCanvas.height),this.parent.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.parent.currObjType.shape="",this.refreshActiveObj(),this.parent.isCircleCrop&&this.parent.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),e.isBlazor()?this.parent.updateToolbar(this.parent.element,"destroyQuickAccessToolbar"):this.parent.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),e.isNullOrUndefined(t)&&(this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.parent.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}))}}}},i.prototype.alignTextAreaIntoCanvas=function(){var t=this.parent,e=t.textArea.value;t.textArea.value="";for(var i=0,o=e.length;i<o;i++)t.textArea.value+=e[i],t.textArea.style.height="auto",t.textArea.style.height=t.textArea.scrollHeight+"px",this.setTextBoxWidth()},i.prototype.transformTextArea=function(){var t=this.parent;if("text"===t.activeObj.shape){t.textArea.style.transformOrigin="0 0";var e=t.activeObj.rotatedAngle*(180/Math.PI),i="",o=this.getRotDegOfShape(t.activeObj);if(t.activeObj.flipObjColl.length>0)for(var r=0;r<t.activeObj.flipObjColl.length;r++)i+=0!==o&&o%90==0&&180!==o?"horizontal"===t.activeObj.flipObjColl[r].toLowerCase()?"scale(1, -1)":"scale(-1, 1)":"horizontal"===t.activeObj.flipObjColl[r].toLowerCase()?"scale(-1, 1)":"scale(1, -1)",o+=e,"horizontal"===t.activeObj.flipObjColl[r].toLowerCase()?t.textArea.style.transform="rotate("+o+"deg)"+i:"vertical"===t.activeObj.flipObjColl[r].toLowerCase()&&(t.textArea.style.transform="rotate("+o+"deg)"+i);else o+=e,t.textArea.style.transform="rotate("+o+"deg)"}},i.prototype.getTextAreaWidth=function(t){var e=this.parent,i=e.activeObj.textSettings.bold,o=e.activeObj.textSettings.italic;switch(t){case"default":e.activeObj.textSettings.bold=!1,e.activeObj.textSettings.italic=!1;break;case"bold":e.activeObj.textSettings.bold=!0,e.activeObj.textSettings.italic=!1;break;case"italic":e.activeObj.textSettings.bold=!1,e.activeObj.textSettings.italic=!0;break;case"bolditalic":e.activeObj.textSettings.bold=!0,e.activeObj.textSettings.italic=!0}this.updateFontStyles();var r;return r="none"===e.textArea.style.display?this.upperContext.measureText(e.activeObj.keyHistory).width+.5*e.activeObj.textSettings.fontSize:this.upperContext.measureText(e.textArea.value).width+.5*e.activeObj.textSettings.fontSize,e.activeObj.textSettings.bold=i,e.activeObj.textSettings.italic=o,r},i.prototype.getObjDetails=function(t){var e=this.parent,i={};switch(i.id=t.currIndex,i.type=e.toPascalCase(t.shape),i.startX=t.activePoint.startX,i.startY=t.activePoint.startY,t.shape){case"rectangle":i.width=t.activePoint.width,i.height=t.activePoint.height,i.strokeColor=t.strokeSettings.strokeColor,i.fillColor=t.strokeSettings.fillColor,i.strokeWidth=t.strokeSettings.strokeWidth;break;case"ellipse":i.radius=t.activePoint.width/2,i.strokeColor=t.strokeSettings.strokeColor,i.fillColor=t.strokeSettings.fillColor,i.strokeWidth=t.strokeSettings.strokeWidth;break;case"line":case"arrow":i.length=t.activePoint.width,i.strokeColor=t.strokeSettings.strokeColor,i.strokeWidth=t.strokeSettings.strokeWidth;break;case"text":i.text=t.keyHistory,i.fontSize=t.textSettings.fontSize,i.color=t.strokeSettings.strokeColor,i.fontStyle=[],t.textSettings.bold&&i.fontStyle.push("bold"),t.textSettings.italic&&i.fontStyle.push("italic")}return i},i.prototype.getFreehandDrawDetails=function(i){var o=this.parent,r={};return r.id=o.pointColl[i].id,r.type=t.ShapeType.FreehandDraw,r.points=e.extend([],o.pointColl[i].points),r.strokeColor=o.pointColl[i].strokeColor,r.strokeWidth=o.pointColl[i].strokeWidth,r},i.prototype.getShapeSetting=function(t,i){var o,r=this.parent;if(!r.disabled&&r.isImageLoaded)if(this.applyActObj(),"shape"===t.split("_")[0]){for(var a,n=0,s=r.objColl.length;n<s;n++)if(r.objColl[n].currIndex===t){a=e.extend({},r.objColl[n],{},!0);break}o=this.getObjDetails(a)}else"pen"===t.split("_")[0]&&(o=this.getFreehandDrawDetails(parseInt(t.split("_")[1],10)-1));i.shapeDetails=o},i.prototype.getShapeSettings=function(t){var e=this.parent,i=[];if(!e.disabled&&e.isImageLoaded){this.applyActObj();for(var o=0,r=e.objColl.length;o<r;o++){a=this.getObjDetails(e.objColl[o]);i.push(a)}for(o=0;o<e.freehandCounter;o++){var a=this.getFreehandDrawDetails(o);i.push(a)}}t.shapeDetailsColl=i},i.prototype.isPointsInRange=function(t,i,o){var r=!1;!e.isNullOrUndefined(t)&&!e.isNullOrUndefined(i)&&t>=this.parent.img.destLeft&&i>=this.parent.img.destTop&&t<=this.parent.img.destLeft+this.parent.img.destWidth&&i<=this.parent.img.destTop+this.parent.img.destHeight&&(r=!0),o.inRange=r},i.prototype.alignRotateFlipColl=function(t,e,i){return t=this.popForDefaultTransformedState(t),t=this.popForDefaultFlipState(t),0===(t=this.popForDefaultRotateState(t)).length&&e&&(this.parent.transform.degree=0,this.parent.transform.currFlipState=""),i.collection=t,t},i.prototype.popForDefaultTransformedState=function(t){for(var e=0,i=0,o=0,r=0,a=0;a<t.length;a++)90===t[a]||"rotateRight"===t[a]?(i=0,o=0,r=0,4===++e&&(t.pop(),t.pop(),t.pop(),t.pop())):-90===t[a]||"rotateLeft"===t[a]?(e=0,o=0,r=0,4===++i&&(t.pop(),t.pop(),t.pop(),t.pop())):"horizontal"===t[a]||"Horizontal"===t[a]||"horizontalflip"===t[a]?(i=0,e=0,r=0,2===++o&&(t.pop(),t.pop())):"vertical"!==t[a]&&"Vertical"!==t[a]&&"verticalflip"!==t[a]||(o=0,i=0,e=0,2===++r&&(t.pop(),t.pop()));return t},i.prototype.popForDefaultFlipState=function(t){for(var i=0;i<t.length;i++)e.isNullOrUndefined(t[i+3])||("horizontal"!==t[i]&&"Horizontal"!==t[i]&&"horizontalFlip"!==t[i]||"vertical"!==t[i+1]&&"Vertical"!==t[i+1]&&"verticalFlip"!==t[i]||"horizontal"!==t[i+2]&&"Horizontal"!==t[i+2]&&"horizontalFlip"!==t[i]||"vertical"!==t[i+3]&&"Vertical"!==t[i+3]&&"verticalFlip"!==t[i]?"vertical"!==t[i]&&"Vertical"!==t[i]&&"verticalFlip"!==t[i]||"horizontal"!==t[i+1]&&"Horizontal"!==t[i+1]&&"horizontalFlip"!==t[i+1]||"vertical"!==t[i+2]&&"Vertical"!==t[i+2]&&"verticalFlip"!==t[i]||"horizontal"!==t[i+3]&&"Horizontal"!==t[i+3]&&"horizontalFlip"!==t[i]||(t.pop(),t.pop(),t.pop(),t.pop()):(t.pop(),t.pop(),t.pop(),t.pop()));return t},i.prototype.popForDefaultRotateState=function(t){for(var i=0;i<t.length;i++)e.isNullOrUndefined(t[i+1])||(90!==t[i]&&"rotateRight"!==t[i]||-90!==t[i+1]&&"rotateLeft"!==t[i]?-90!==t[i]&&"rotateLeft"!==t[i]||90!==t[i+1]&&"rotateRight"!==t[i]||(t.pop(),t.pop()):(t.pop(),t.pop()));return t},i.prototype.selectShape=function(t,i){var o=this.parent,r=!1;if(!o.disabled&&o.isImageLoaded)if(this.applyActObj(),"shape"===t.split("_")[0]){for(var a,n=0,s=o.objColl.length;n<s;n++)if(o.objColl[n].currIndex===t){a=e.extend({},o.objColl[n],{},!0);break}if(e.isNullOrUndefined(a))r=!1;else{r=!0,o.activeObj=a;l={canvasFilter:null};o.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:l}}),this.lowerContext.filter=l.canvasFilter,o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.activeObj}}),e.isBlazor()?(o.updateToolbar(o.element,o.activeObj.shape),"path"===o.activeObj.shape?o.updateToolbar(this.parent.element,"path","pathQuickAccessToolbar"):o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape)):("text"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):"pen"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))}}else if("pen"===t.split("_")[0]){var l={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:l}}),l.bool&&o.okBtn();var p={isIndex:!1};o.notify("freehand-draw",{prop:"isFHDIdx",value:{index:parseInt(t.split("_")[1],10)-1,obj:p}}),p.isIndex?(r=!0,o.notify("freehand-draw",{prop:"selectFhd",value:{id:t}}),e.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):(o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))):r=!1}i.isSelected=r},i.prototype.deleteShape=function(t){var e=this.parent;if(!e.disabled&&e.isImageLoaded){if(this.applyActObj(),"shape"===t.split("_")[0]){for(var i=0,o=e.objColl.length;i<o;i++)if(e.objColl[i].currIndex===t){e.objColl.splice(i,1);break}}else"pen"===t.split("_")[0]&&e.notify("freehand-draw",{prop:"handle-freehand-draw",value:{id:t}});var r={canvasFilter:null};e.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:r}}),this.lowerContext.filter=r.canvasFilter,this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},i.prototype.getMaxText=function(t,i,o){e.isNullOrUndefined(i)&&(i=t?this.parent.textArea.value:this.parent.activeObj.keyHistory);for(var r,a=i.split("\n"),n=a[0].length,s=a[0],l=1;l<a.length;l++)(r=a[l].length)>n&&(s=a[l],n=r);return o&&(o.maxText=s),s},i.prototype.getLinePoints=function(t,i,o,r){var a,n,s=[];if(t===o){i<r?(a=[t,i],n=[o,r]):(n=[t,i],a=[o,r]);for(var l=this.getSlope(a,n,!0),p=this.getIntercept(a,l),h=a[1];h<=n[1];h++){c=l*h+p;s.push({x:c,y:h})}}else{t<o?(a=[t,i],n=[o,r]):(n=[t,i],a=[o,r]);for(var l=this.getSlope(a,n,!1),p=this.getIntercept(a,l),c=a[0];c<=n[0];c++){h=l*c+p;s.push({x:c,y:h})}}if(Math.floor(t)===Math.floor(o)||s.length<10&&(r-i>10||i-r>10)){s=[];for(var d=Math.min(i,r),v=0;v<Math.abs(Math.floor(r)-Math.floor(i));v++)s.push({x:t,y:d+v});if(s.length>1){f=void 0;f=e.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];var u=s[s.length-1].x-f.x,g=s[s.length-1].y-f.y;s.push({x:s[s.length-1].x+u/2,y:s[s.length-1].y+g/2})}}else if(Math.floor(i)===Math.floor(r)||s.length<10&&(o-t>10||t-o>10)){s=[];for(var b=Math.min(t,o),C=0;C<Math.abs(Math.floor(o)-Math.floor(t));C++)s.push({x:b+C,y:i});if(s.length>1){var f=void 0;f=e.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];var u=s[s.length-1].x-f.x,g=s[s.length-1].y-f.y;s.push({x:s[s.length-1].x+u/2,y:s[s.length-1].y+g/2})}}return s},i.prototype.getSlope=function(t,e,i){var o;if(i){if(t[1]===e[1])return null;o=(e[0]-t[0])/(e[1]-t[1])}else{if(t[0]===e[0])return null;o=(e[1]-t[1])/(e[0]-t[0])}return o},i.prototype.getIntercept=function(t,e){return null===e?t[0]:t[1]-e*t[0]},i.prototype.setPointCollForShapeRotation=function(t){var e={x:t.activePoint.startX+t.activePoint.width/2,y:t.activePoint.startY+t.activePoint.height/2},i={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.y},o={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.y},r={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.y},a={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.y};t.horTopLinePointColl=this.getLinePoints(i.x,i.y,o.x,o.y),t.horBottomLinePointColl=this.getLinePoints(r.x,r.y,a.x,a.y),t.verLeftLinePointColl=this.getLinePoints(i.x,i.y,r.x,r.y),t.verRightLinePointColl=this.getLinePoints(o.x,o.y,a.x,a.y),t.verLeftLinePointColl.reverse(),t.verRightLinePointColl.reverse();for(n=0;n<t.horTopLinePointColl.length;n++)t.horTopLinePointColl[n].ratioX=(t.horTopLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.horTopLinePointColl[n].ratioY=(t.horTopLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;for(n=0;n<t.horBottomLinePointColl.length;n++)t.horBottomLinePointColl[n].ratioX=(t.horBottomLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.horBottomLinePointColl[n].ratioY=(t.horBottomLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;for(n=0;n<t.verLeftLinePointColl.length;n++)t.verLeftLinePointColl[n].ratioX=(t.verLeftLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.verLeftLinePointColl[n].ratioY=(t.verLeftLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;for(var n=0;n<t.verRightLinePointColl.length;n++)t.verRightLinePointColl[n].ratioX=(t.verRightLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.verRightLinePointColl[n].ratioY=(t.verRightLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;if("move"!==this.parent.upperCanvas.style.cursor){var s={rotationCirclePoint:null};this.parent.notify("selection",{prop:"getTransRotationPoint",value:{obj:t,object:s}});var l=s.rotationCirclePoint;l&&(t.rotationCirclePointColl={x:Math.cos(t.rotatedAngle)*(l.x-e.x)-Math.sin(t.rotatedAngle)*(l.y-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(l.x-e.x)+Math.cos(t.rotatedAngle)*(l.y-e.y)+e.y},t.rotationCirclePointColl.ratioX=(t.rotationCirclePointColl.x-this.parent.img.destLeft)/this.parent.img.destWidth,t.rotationCirclePointColl.ratioY=(t.rotationCirclePointColl.y-this.parent.img.destTop)/this.parent.img.destHeight)}},i.prototype.getSquarePointForRotatedShape=function(t,e){var i={startX:0,startY:0,endX:0,endY:0,width:0,height:0},o={x:t.activePoint.startX+t.activePoint.width/2,y:t.activePoint.startY+t.activePoint.height/2},r={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.y},a={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.y},n={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.y},s={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.y};return i.startX=r.x,i.startY=r.y,i.endX=r.x,i.endY=r.y,i.startX>a.x&&(i.startX=a.x),i.startX>n.x&&(i.startX=n.x),i.startX>s.x&&(i.startX=s.x),i.startY>a.y&&(i.startY=a.y),i.startY>n.y&&(i.startY=n.y),i.startY>s.y&&(i.startY=s.y),i.endX<a.x&&(i.endX=a.x),i.endX<n.x&&(i.endX=n.x),i.endX<s.x&&(i.endX=s.x),i.endY<a.y&&(i.endY=a.y),i.endY<n.y&&(i.endY=n.y),i.endY<s.y&&(i.endY=s.y),i.width=i.endX-i.startX,i.height=i.endY-i.startY,e&&(e.activePoint=i),i},i}(),v=function(){function o(t){this.isReverseFlip=!1,this.disablePan=!1,this.isReverseRotate=!1,this.flipColl=[],this.prevZoomValue=1,this.cropDimension={width:0,height:0},this.isPreventSelect=!1,this.parent=t,this.addEventListener()}return o.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},o.prototype.addEventListener=function(){this.parent.on("transform",this.transform,this),this.parent.on("destroyed",this.destroy,this)},o.prototype.removeEventListener=function(){this.parent.off("transform",this.transform),this.parent.off("destroyed",this.destroy)},o.prototype.transform=function(t){switch(this.initTransformPvtVar(),t.prop){case"rotateImage":this.rotateImage(t.value.degree);break;case"flipImage":this.flipImage(t.value.direction);break;case"setDestPointsForFlipState":this.setDestPointsForFlipState();break;case"zoomAction":this.zoomAction(t.value.zoomFactor,t.value.zoomPoint);break;case"disableZoomOutBtn":this.disableZoomOutBtn(t.value.isZoomOut);break;case"rotatedFlip":this.rotatedFlip();break;case"drawPannedImage":this.drawPannedImage(t.value.xDiff,t.value.yDiff);break;case"drawPannImage":this.drawPannImage(t.value.point);break;case"performTransformation":this.performTransformation(t.value.text);break;case"updateTransform":this.updateTransform(t.value.text);break;case"rotatePan":this.rotatePan(t.value.isCropSelection,t.value.isDefaultZoom);break;case"drawRotatedImage":this.drawRotatedImage(t.value.degree);break;case"limitPan":this.limitPan();break;case"updateFlipActiveObj":this.updateFlipActiveObj(t.value.panRegion);break;case"resetZoom":this.resetZoom();break;case"pan":this.pan(t.value.value);break;case"zoom":this.zoom(t.value.zoomFactor,t.value.zoomPoint);break;case"setCurrPanRegion":this.setCurrPanRegion(t.value.region,t.value.type,t.value.obj);break;case"rotate":this.rotate(t.value.degree,t.value.obj);break;case"flip":this.flip(t.value.direction);break;case"update":this.update();break;case"calcMaxDimension":this.calcMaxDimension(t.value.width,t.value.height,t.value.obj);break;case"updatePanPoints":this.updatePanPoints(t.value.panRegion,t.value.obj);break;case"getPanMove":t.value.obj.panMove=this.panMove;break;case"setPanMove":this.panMove=t.value.point;break;case"getTempPanMove":t.value.obj.tempPanMove=this.tempPanMove;break;case"setTempPanMove":this.tempPanMove=t.value.point;break;case"setReverseFlip":this.isReverseFlip=t.value.isReverseFlip;break;case"setDisablePan":this.disablePan=t.value.bool;break;case"setCurrDestinationPoint":this.currDestPoint=t.value.point,this.currDestPoint.startX-=this.parent.cropObj.totalPannedPoint.x,this.currDestPoint.startY-=this.parent.cropObj.totalPannedPoint.y;break;case"setReverseRotate":this.isReverseRotate=t.value.bool;break;case"getFlipColl":t.value.obj.flipColl=this.flipColl;break;case"setFlipColl":this.flipColl=t.value.flipColl;break;case"getPreviousZoomValue":t.value.obj.previousZoomValue=this.prevZoomValue;break;case"setPreviousZoomValue":this.prevZoomValue=t.value.previousZoomValue;break;case"getCropDimension":t.value.obj.cropDimension=this.cropDimension;break;case"setCropDimension":this.cropDimension.width=t.value.width,this.cropDimension.height=t.value.height;break;case"reset":this.reset()}},o.prototype.getModuleName=function(){return"transform"},o.prototype.initTransformPvtVar=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},o.prototype.reset=function(){this.zoomBtnHold=null,this.tempPanMove=null,this.panMove=null,this.disablePan=!1,this.currDestPoint=null,this.isReverseRotate=!1,this.flipColl=[],this.transCurrObj=null,this.prevZoomValue=1,this.isPreventSelect=!1},o.prototype.rotateImage=function(t){var i=this,o=this.parent,r={cancel:!1,previousDegree:o.transform.degree,currentDegree:360===Math.abs(o.transform.degree+t)?0:o.transform.degree+t};!this.isPreventSelect&&e.isBlazor()&&o.events&&!0===o.events.rotating.hasDelegate?o.dotNetRef.invokeMethodAsync("RotateEventAsync","OnRotate",r).then(function(e){i.rotateEvent(e,t)}):(this.isPreventSelect||o.trigger("rotating",r),this.rotateEvent(r,t))},o.prototype.rotateEvent=function(t,i){var o=this.parent;if(!t.cancel){var r=void 0;if(e.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=e.extend([],o.objColl,null,!0),r.pointColl=e.extend({},o.pointColl,null,!0),r.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=e.extend([],n.selPointColl,[],!0)}o.afterCropActions.push(90===i?"rotateRight":"rotateLeft");var s=[],l=void 0;o.activeObj.activePoint&&o.activeObj.shape&&(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===s[0])&&(l=o.currObjType.isCustomCrop?"custom":s[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.drawRotatedImage(i),o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),l&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=e.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})),o.isUndoRedo=!1;var p={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:p}}),o.rotateFlipColl=p.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.select("custom"),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.drawRotatedImage=function(t){var i=this.parent;0===t?i.transform.degree=0:i.transform.degree+=t,360===Math.abs(i.transform.degree)&&(i.transform.degree=0),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var o=e.extend([],i.objColl,[],!0),r=e.extend({},i.activeObj,{},!0);if(i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseRotate||i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.rotateDegree(t),this.isReverseRotate||(i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.rotateFlipColl.push(t)),i.objColl=e.extend([],o,[],!0),i.activeObj=e.extend({},r,{},!0),i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:t}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t>0)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});else for(var a=0;a<3;a++)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.updateCurrSelectionPoint(t)},o.prototype.rotateDegree=function(t){var e=this.parent;this.lowerContext.save(),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.lowerContext.translate(e.lowerCanvas.width/2,e.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*t),this.lowerContext.translate(-e.lowerCanvas.width/2,-e.lowerCanvas.height/2);var i=this.lowerContext.filter;this.parent.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(this.parent.baseImg,this.parent.img.srcLeft,this.parent.img.srcTop,this.parent.img.srcWidth,this.parent.img.srcHeight,this.parent.img.destLeft,this.parent.img.destTop,this.parent.img.destWidth,this.parent.img.destHeight),this.lowerContext.filter=i,this.lowerContext.translate(e.lowerCanvas.width/2,e.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*-t),this.lowerContext.translate(-e.lowerCanvas.width/2,-e.lowerCanvas.height/2),this.lowerContext.restore()},o.prototype.updateCurrSelectionPoint=function(t){var i=this.parent;if(i.currSelectionPoint&&this.currDestPoint){var o=e.extend({},i.activeObj,{},!0),r=e.extend([],i.objColl,[],!0),a={startX:i.img.srcLeft,startY:i.img.srcTop,width:i.img.srcWidth,height:i.img.srcHeight},n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.objColl=[],i.objColl.push(e.extend({},i.currSelectionPoint,{},!0)),e.isNullOrUndefined(i.objColl[0].imageRatio)&&(i.activeObj=i.objColl[0],i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),i.objColl[0]=i.activeObj),i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImg.width,i.img.srcHeight=i.baseImg.height,i.img.destLeft=this.currDestPoint.startX,i.img.destTop=this.currDestPoint.startY,i.img.destWidth=this.currDestPoint.width,i.img.destHeight=this.currDestPoint.height,"number"==typeof t&&(i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}})),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:t}}),i.currSelectionPoint=e.extend({},i.objColl[0],{},!0),this.currDestPoint={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight},i.objColl=r,i.activeObj=o,i.img.srcLeft=a.startX,i.img.srcTop=a.startY,i.img.srcWidth=a.width,i.img.srcHeight=a.height,i.img.destLeft=n.startX,i.img.destTop=n.startY,i.img.destWidth=n.width,i.img.destHeight=n.height}},o.prototype.flipImage=function(t){var i=this,o=this.parent,r={direction:t,cancel:!1,previousDirection:o.toPascalCase(o.transform.currFlipState)};!this.isPreventSelect&&e.isBlazor()&&o.events&&!0===o.events.flipping.hasDelegate?o.dotNetRef.invokeMethodAsync("FlipEventAsync","OnFlip",r).then(function(e){i.flipEvent(e,t)}):(this.isPreventSelect||o.trigger("flipping",r),this.flipEvent(r,t))},o.prototype.flipEvent=function(t,i){var o=this.parent;if(!t.cancel){var r;if(e.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=e.extend([],o.objColl,null,!0),r.pointColl=e.extend({},o.pointColl,null,!0),r.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=e.extend([],n.selPointColl,[],!0)}o.afterCropActions.push("horizontal"===i.toLowerCase()?"horizontalflip":"verticalflip");var s,l=[];o.activeObj.activePoint&&(void 0!==o.activeObj.shape&&(l=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===l[0])&&(s=o.currObjType.isCustomCrop?"custom":l[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.clearContext(this.lowerContext),o.clearContext(this.upperContext);var p=e.extend([],o.objColl,[],!0),h=e.extend({},o.activeObj,{},!0);o.objColl=[],o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseFlip||o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var c=i.toLowerCase();this.updateFlipState(c),o.transform.currFlipState="horizontal"===c?"horizontal"===o.transform.currFlipState.toLowerCase()?"":"horizontal":"vertical"===o.transform.currFlipState.toLowerCase()?"":"vertical";var d={isSelected:null};o.notify("draw",{prop:"getRotatedFlipCropSelection",onPropertyChange:!1,value:{bool:d}}),d.isSelected&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y);var v=this.lowerContext.filter;if(o.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(o.baseImg,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,o.img.destLeft,o.img.destTop,o.img.destWidth,o.img.destHeight),this.lowerContext.filter=v,o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.updateFlipState(i.toLowerCase()),this.isReverseFlip||(o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),this.updateFlipColl(i.toLocaleLowerCase()),o.rotateFlipColl.push(i.toLowerCase())),1===o.rotateFlipColl.length){var u={panRegion:""};o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:u}}),""===u.panRegion?o.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}}):this.setDestPointsForFlipState()}o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.objColl=e.extend([],p,[],!0),o.activeObj=e.extend({},h,{},!0);for(var g=0,b=o.objColl.length;g<b;g++){var C=o.objColl[g].flipObjColl;0===C.length?C.push(i):C[C.length-1]===i?C.pop():C.push(i)}o.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:i.toLowerCase()}});var f=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),"horizontal"===i.toLowerCase()||"vertical"===i.toLowerCase()?(o.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:i.toLowerCase()}}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}})):o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=f,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.updateCurrSelectionPoint(i.toLowerCase()),o.isUndoRedo=!1,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),s&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=e.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}));var m={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:m}}),o.rotateFlipColl=m.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.select("custom"),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.updateFlipState=function(t){var e=this.parent.transform.degree;"horizontal"===t?e%90==0&&e%180!=0?this.verticalFlip():this.horizontalFlip():"vertical"===t&&(e%90==0&&e%180!=0?this.horizontalFlip():this.verticalFlip())},o.prototype.horizontalFlip=function(){this.lowerContext.translate(this.lowerContext.canvas.width,0),this.lowerContext.scale(-1,1),this.upperContext.translate(this.upperContext.canvas.width,0),this.upperContext.scale(-1,1)},o.prototype.verticalFlip=function(){this.lowerContext.translate(0,this.lowerContext.canvas.height),this.lowerContext.scale(1,-1),this.upperContext.translate(0,this.upperContext.canvas.height),this.upperContext.scale(1,-1)},o.prototype.updateFlipColl=function(t){if(!this.isPreventSelect&&(0===this.flipColl.length||this.flipColl[this.flipColl.length-1]!==t?this.flipColl.push(t):this.flipColl.pop(),this.flipColl.length>=4)){var e=this.flipColl.slice(-4);("horizontal"===e[0]&&"vertical"===e[1]&&"horizontal"===e[2]&&"vertical"===e[3]||"vertical"===e[0]&&"horizontal"===e[1]&&"vertical"===e[2]&&"horizontal"===e[3])&&this.flipColl.splice(-4)}},o.prototype.setDestPointsForFlipState=function(){var t=this.parent,e={panRegion:""};t.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:e}}),""!==e.panRegion&&("horizontal"===e.panRegion?t.img.destLeft=t.lowerCanvas.clientWidth-(t.img.destWidth+t.img.destLeft):"vertical"===e.panRegion?t.img.destTop=t.lowerCanvas.clientHeight-(t.img.destHeight+t.img.destTop):(t.img.destLeft=t.lowerCanvas.clientWidth-(t.img.destWidth+t.img.destLeft),t.img.destTop=t.lowerCanvas.clientHeight-(t.img.destHeight+t.img.destTop)))},o.prototype.zoomAction=function(t,i){var o=this,r=this.parent;if(!r.disabled&&r.isImageLoaded){if(r.zoomSettings.zoomFactor>=r.zoomSettings.maxZoomFactor&&t>0||r.zoomSettings.zoomFactor>r.zoomSettings.minZoomFactor&&t<0&&this.disableZoomOutBtn(!0)||r.zoomSettings.zoomFactor<=r.zoomSettings.minZoomFactor&&t<0)return void(e.isBlazor()||r.notify("toolbar",{prop:"zoom-up-handler",onPropertyChange:!1}));r.notify("draw",{prop:"setImageEdited",onPropertyChange:!1});var a=t;t=a>0?.1:-.1;for(var n=0;n<Math.abs(a/.1);n++)if(1===this.prevZoomValue)this.prevZoomValue+=t>0?10*t:10*t/10;else if(this.prevZoomValue>1)this.prevZoomValue+=10*t;else if(this.prevZoomValue<1){this.prevZoomValue+=10*t/10;var s=Math.pow(10,1);this.prevZoomValue=Math.round(this.prevZoomValue*s)/s}t=a,r.setProperties({zoomSettings:{zoomFactor:this.prevZoomValue}},!0);var l=void 0;this.tempActiveObj=null,this.isShape=!1,void 0!==r.activeObj.shape&&("shape"===r.activeObj.shape?r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}):l=r.activeObj.shape.split("-")),void 0!==l&&"crop"===l[0]?(this.tempActiveObj=e.extend({},r.activeObj,{},!0),r.isCropTab=!0):r.activeObj.shape&&"crop"!==l[0]&&(this.isShape=!0);var p={zoomType:null};r.notify("selection",{prop:"getZoomType",onPropertyChange:!1,value:{obj:p}}),e.isNullOrUndefined(i)&&(i=r.isCropTab&&this.tempActiveObj?{x:r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2,y:r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2}:{x:r.lowerCanvas.clientWidth/2,y:r.lowerCanvas.clientHeight/2},"MouseWheel"!==p.zoomType&&"Pinch"!==p.zoomType||(i={x:r.zoomSettings.zoomPoint.x,y:r.zoomSettings.zoomPoint.y}));var h={zoomPoint:i,cancel:!1,previousZoomFactor:r.zoomSettings.zoomFactor-10*t,currentZoomFactor:r.zoomSettings.zoomFactor,zoomTrigger:p.zoomType};!r.isCropToolbar&&e.isBlazor()&&r.events&&!0===r.events.zooming.hasDelegate?r.dotNetRef.invokeMethodAsync("ZoomEventAsync","OnZoom",h).then(function(e){o.zoomEvent(e,t)}):(r.isCropToolbar||r.trigger("zooming",h),this.zoomEvent(h,t))}},o.prototype.zoomEvent=function(t,i){var o=this.parent;if(!t.cancel){e.isBlazor()?o.element.querySelector(".e-contextual-toolbar-wrapper")&&!o.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hidden")&&o.updateToolbar(o.element,"closeContextualToolbar"):o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var r={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=r.canvasFilter,o.upperCanvas.style.cursor=o.cursor="default";var a=e.extend([],o.objColl,[],!0);if(o.isCropTab||(0!==o.transform.degree?(o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.panPoint.currentPannedPoint={x:0,y:0},this.rotatePan(!0,!0)):""!==o.transform.currFlipState&&(o.panPoint.totalPannedPoint={x:0,y:0}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})),0===o.transform.degree){this.drawZoomImgToCanvas(i,this.tempActiveObj);var n={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:n}}),""!==n.panRegion){o.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:o.panPoint.totalPannedPoint,isAdd:!0}}),a=e.extend([],o.objColl,[],!0),o.objColl=[];var s=o.img.destLeft,l=o.img.destTop;this.setDestPointsForFlipState(),this.rotatedFlip(),o.img.destLeft=s,o.img.destTop=l,o.objColl=a,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})}o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&!o.isCropTab&&(o.panPoint.totalPannedPoint={x:0,y:0})}else{o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),o.panPoint.totalPannedClientPoint={x:0,y:0},o.panPoint.totalPannedInternalPoint={x:0,y:0},this.rotateZoom(i);var p={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:p}}),""!==p.panRegion){d=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=d}}var h=Math.pow(10,1);(o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor||Math.round(o.transform.zoomFactor*h)/h==2)&&(clearInterval(this.zoomBtnHold),this.zoomBtnHold=0);var c={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:c}}),""===c.panRegion){var d=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=d}(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.tempActiveObj&&(o.activeObj=e.extend({},this.tempActiveObj,{},!0),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}),o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&(o.currSelectionPoint=null)),o.isUndoRedo=!1;var v;e.isBlazor()?(v=o.element.querySelector("#zoomout"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?v.classList.add("e-overlay"):v&&v.classList.remove("e-overlay"):(v=document.querySelector("#"+o.element.id+"_zoomOut"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?(v.classList.add("e-disabled"),v.parentElement.classList.add("e-overlay")):v&&(v.classList.remove("e-disabled"),v.parentElement.classList.remove("e-overlay")),this.autoEnablePan(),this.tempActiveObj&&(o.activeObj=e.extend({},this.tempActiveObj,{},!0)),"crop-custom"===o.activeObj.shape&&(o.currObjType.isCustomCrop=!0);var u=o.element.querySelector(".e-img-pan .e-btn");u&&o.togglePan?u.classList.add("e-selected-btn"):u&&u.classList.remove("e-selected-btn"),this.isShape&&(o.activeObj=e.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),e.isBlazor()||(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),e.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}),o.notify("selection",{prop:"setZoomType",onPropertyChange:!1,value:{zoomType:"Toolbar"}})}},o.prototype.disableZoomOutBtn=function(t){var i,o=this.parent,r=!1;e.isNullOrUndefined(t)||(o.transform.zoomFactor-=.1),i=e.isBlazor()?this.parent.element.querySelector("#zoomout"):document.querySelector("#"+o.element.id+"_zoomOut");var a=o.img.destLeft,n=o.img.destTop,s=o.img.destWidth,l=o.img.destHeight;return o.activeObj.shape?(this.setZoomDimension(-.1,o.activeObj),e.isNullOrUndefined(i)||(o.img.destLeft>o.activeObj.activePoint.startX||o.img.destTop>o.activeObj.activePoint.startY||o.img.destLeft+o.img.destWidth<o.activeObj.activePoint.endX||o.img.destTop+o.img.destHeight<o.activeObj.activePoint.endY||o.zoomSettings.zoomFactor===o.zoomSettings.minZoomFactor?(e.isBlazor()?i.classList.add("e-overlay"):(i.classList.add("e-disabled"),i.parentElement.classList.add("e-overlay")),r=!0):(e.isBlazor()?i.classList.remove("e-overlay"):(i.classList.remove("e-disabled"),i.parentElement.classList.remove("e-overlay")),r=!1))):this.setZoomDimension(-.1,null),e.isNullOrUndefined(t)||(o.transform.zoomFactor+=.1),o.img.destLeft=a,o.img.destTop=n,o.img.destWidth=s,o.img.destHeight=l,r},o.prototype.drawZoomImgToCanvas=function(t,e){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===t?i.transform.zoomFactor=0:i.transform.zoomFactor+=t,i.transform[i.isCropTab?"cropZoomFactor":"defaultZoomFactor"]=i.transform.zoomFactor;var r={width:0,height:0};i.isCropTab?r=this.cropZoom(t,e):((r=this.calcMaxDimension(i.img.srcWidth,i.img.srcHeight)).width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.img.destLeft=(i.lowerCanvas.clientWidth-r.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-r.height)/2),i.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:r}}),r.width=this.cropDimension.width,r.height=this.cropDimension.height,r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:r.width,height:r.height}})},o.prototype.rotatedFlip=function(){var t=this.parent;this.isReverseFlip=!0;var i=t.transform.currFlipState,o=this.flipColl,r=e.extend([],t.objColl,[],!0),a=e.extend({},t.activeObj,{},!0);this.flipColl=[],t.objColl=[],t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}});var n=this.lowerContext.filter;t.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=n,t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,context:null,isPreventCircleCrop:null}}),""===i&&""!==t.transform.currFlipState&&(i=t.transform.currFlipState),t.transform.currFlipState=i,this.flipColl=o,t.objColl=e.extend([],r,[],!0),this.lowerContext.filter="none",t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=n,0!==a.activePoint.width&&(t.activeObj=e.extend({},a,{},!0)),this.isReverseFlip=!1},o.prototype.rotateZoom=function(t){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===t?i.transform.zoomFactor=0:i.transform.zoomFactor+=t,i.isCropTab?i.transform.cropZoomFactor=i.transform.zoomFactor:i.transform.defaultZoomFactor=i.transform.zoomFactor;var r=e.extend([],i.objColl,[],!0),a=e.extend({},i.activeObj,{},!0);i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var n=this.lowerContext.filter;i.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,i.img.destLeft,i.img.destTop,i.img.destWidth,i.img.destHeight),this.lowerContext.filter=n,i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.objColl=r,i.activeObj=a;var s={width:this.cropDimension.width,height:this.cropDimension.height};s.width+=s.width*i.transform.zoomFactor,s.height+=s.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:s.width,height:s.height}})},o.prototype.autoEnablePan=function(){this.parent.transform.zoomFactor<=0?(this.parent.togglePan=!1,this.parent.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),this.parent.pan(!1),this.disablePan=!1):this.parent.pan(!this.disablePan)},o.prototype.cropZoom=function(t,i){var o=this.parent,r=o.img.destLeft,a=o.img.destTop,n={width:0,height:0};return 0===o.img.srcLeft||0===o.img.srcTop?n=e.isNullOrUndefined(i)?this.setZoomDimension(t,null):this.setZoomDimension(t,i):((n=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight)).width+=n.width*o.transform.zoomFactor,n.height+=n.height*o.transform.zoomFactor),o.img.destLeft=r-(n.width-o.img.destWidth)/2,o.img.destTop=a-(n.height-o.img.destHeight)/2,r=o.img.destLeft,a=o.img.destTop,i&&(o.img.destLeft>i.activePoint.startX&&(o.img.destLeft=i.activePoint.startX,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop>i.activePoint.startY&&(o.img.destTop=i.activePoint.startY,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop)),o.img.destLeft+n.width<i.activePoint.endX&&(o.img.destLeft=i.activePoint.endX-n.width,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop+n.height<i.activePoint.endY&&(o.img.destTop=i.activePoint.endY-n.height,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop))),n},o.prototype.setZoomDimension=function(t,i){var o=this.parent,r={width:0,height:0};if(r=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight),r.width+=r.width*o.transform.zoomFactor,r.height+=r.height*o.transform.zoomFactor,o.img.destLeft+=(o.img.destWidth-r.width)/2,o.img.destTop+=(o.img.destHeight-r.height)/2,t<0&&i){var a=i.activePoint.startX,n=i.activePoint.startY,s=i.activePoint.width,l=i.activePoint.height,p=o.img.destLeft+r.width,h=o.img.destTop+r.height;o.img.destLeft>a&&(o.img.destLeft=a),o.img.destTop>n&&(o.img.destTop=n),p<a+s&&(o.img.destLeft=a+s-r.width),h<n+l&&(o.img.destTop=n+l-r.height)}else t<0&&e.isNullOrUndefined(i)&&(o.img.destLeft>0&&(o.img.destLeft=0),o.img.destTop>0&&(o.img.destTop=0),o.img.destLeft+r.width<o.lowerCanvas.width&&(o.img.destLeft=o.lowerCanvas.width-o.img.destWidth),o.img.destTop+r.height<o.lowerCanvas.height&&(o.img.destTop=o.lowerCanvas.height-o.img.destHeight));return r},o.prototype.drawPannedImage=function(t,i){var o=this,r=this.parent,a={panDown:null};r.notify("selection",{prop:"getPanDown",onPropertyChange:!1,value:{obj:a}});var n={startPoint:a.panDown,endPoint:this.panMove,cancel:!1};e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onPanStart.hasDelegate?(this.parent.eventType="pan",this.parent.panEventArgs=n,r.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanStart",n).then(function(e){o.panEvent(e,t,i)})):(r.trigger("panning",n),this.panEvent(n,t,i))},o.prototype.panEvent=function(t,i,o){if(!t.cancel){var r=this.parent,a=!1;if(r.activeObj.shape&&"shape"===r.activeObj.shape&&r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isNullOrUndefined(r.activeObj.shape)){a=!0,r.activeObj.activePoint={startX:r.img.destLeft,startY:r.img.destTop,endX:r.img.destLeft+r.img.destWidth,endY:r.img.destTop+r.img.destHeight};var n=r.activeObj.activePoint.startX,s=r.activeObj.activePoint.startY,l=r.activeObj.activePoint.endX,p=r.activeObj.activePoint.endY;n<0&&(r.activeObj.activePoint.startX=0),s<0&&(r.activeObj.activePoint.startY=0),l>r.lowerCanvas.width&&(r.activeObj.activePoint.endX=r.lowerCanvas.width),p>r.lowerCanvas.height&&(r.activeObj.activePoint.endY=r.lowerCanvas.height),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY,r.activeObj.shape="crop-custom";var h={strokeSettings:{}};r.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:h}}),r.activeObj.strokeSettings=h.strokeSettings,r.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:r.activeObj.activePoint,obj:r.activeObj,isMouseMove:null,x:null,y:null}}),r.isCropTab=!0}if(0===r.transform.degree){var c=void 0;c=e.isNullOrUndefined(i)&&e.isNullOrUndefined(o)?this.updatePanPoints(""):{x:i,y:o},r.panPoint.totalPannedPoint.x+=c.x,r.panPoint.totalPannedPoint.y+=c.y;var d=e.extend({},r.activeObj,{},!0),v=this.lowerContext.filter;this.drawPannImage(c),this.lowerContext.filter=v,this.tempPanMove=e.extend({},this.panMove,{},!0),r.activeObj=e.extend({},d,{},!0),this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),r.activeObj.shape&&r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:r.activeObj}})}else{var u=r.transform.currFlipState;r.isCropTab=!0,e.isNullOrUndefined(i)&&e.isNullOrUndefined(o)?r.panPoint.currentPannedPoint=this.updatePanPoints(""):r.panPoint.currentPannedPoint={x:i,y:o},r.transform.currFlipState=u,this.rotatePan(),r.isCropTab=!1,this.tempPanMove=e.extend({},this.panMove,{},!0)}a&&(r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),r.isCropTab=!1,this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height))}},o.prototype.drawPannImage=function(t){var e=this.parent,i={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),e.img.destLeft=i.startX,e.img.destTop=i.startY,e.img.destWidth=i.width,e.img.destHeight=i.height,this.setDestPointsForFlipState(),e.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(e.baseImg,e.img.srcLeft,e.img.srcTop,e.img.srcWidth,e.img.srcHeight,e.img.destLeft,e.img.destTop,e.img.destWidth,e.img.destHeight),(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}}),e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),e.img.destLeft=i.startX,e.img.destTop=i.startY,e.img.destWidth=i.width,e.img.destHeight=i.height;var o=this.lowerContext.filter;this.lowerContext.filter="none",e.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:t.x,yDiff:t.y,panRegion:""}}),e.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:t.x,yDiff:t.y,panRegion:""}}),this.lowerContext.filter=o,e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}})},o.prototype.resetZoom=function(){var t=this.parent;if(0!==t.transform.defaultZoomFactor){var i=t.isUndoRedo,o={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),this.transCurrObj=o.currObj,this.transCurrObj.objColl=e.extend([],t.objColl,null,!0),this.transCurrObj.pointColl=e.extend({},t.pointColl,null,!0),this.transCurrObj.afterCropActions=e.extend([],t.afterCropActions,[],!0);var r={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:r}}),this.transCurrObj.selPointColl=e.extend([],r.selPointColl,[],!0),t.isUndoRedo=t.isCropToolbar=!0,t.transform.defaultZoomFactor>0?this.zoomAction(-t.transform.defaultZoomFactor):this.zoomAction(Math.abs(t.transform.defaultZoomFactor)),t.isCropToolbar=!1,t.isUndoRedo=i}},o.prototype.performTransformation=function(t){var i=this.parent,o=i.transform.defaultZoomFactor,r=i.isUndoRedo,a=e.extend({},i.cropObj,{},!0);this.resetZoom(),this.updateTransform(t);for(var n=0,s=i.objColl.length;n<s;n++)if(i.objColl[n].flipObjColl.length>0){var l={collection:i.objColl[n].flipObjColl};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.objColl[n].flipObjColl,isRotateFlipCollection:null,obj:l}}),i.objColl[n].flipObjColl=l.collection}if(0!==o){i.isUndoRedo=!0,this.zoomAction(o),i.isUndoRedo=r;var p="";"rotateleft"===t||"rotateright"===t?p="rotate":"horizontalflip"!==t&&"verticalflip"!==t||(p="flip"),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:p,previousObj:this.transCurrObj,previousObjColl:this.transCurrObj.objColl,previousPointColl:this.transCurrObj.pointColl,previousSelPointColl:this.transCurrObj.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.transCurrObj=null}},o.prototype.updateTransform=function(e){switch(e.toLowerCase()){case"rotateleft":this.rotateImage(-90);break;case"rotateright":this.rotateImage(90);break;case"horizontalflip":this.flipImage(t.Direction.Horizontal);break;case"verticalflip":this.flipImage(t.Direction.Vertical)}},o.prototype.rotatePan=function(t,i){var o=this.parent;this.isReverseRotate=!0;var r,a=o.transform.degree,n={selPointColl:null};o.activeObj.activePoint&&o.activeObj.shape&&(r=e.extend({},o.activeObj,{},!0));var s=e.extend([],o.objColl,[],!0),l=e.extend([],o.pointColl,[],!0);o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}});var p=n.selPointColl;o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var h=o.img.destLeft,c=o.img.destTop;o.isCropTab&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y),o.notify("crop",{prop:"updateRotatePan",onPropertyChange:!1}),o.isCropTab&&(o.panPoint.totalPannedInternalPoint.x=o.img.destLeft-h,o.panPoint.totalPannedInternalPoint.y=o.img.destTop-c);var d=this.lowerContext.filter;o.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(o.baseImg,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,o.img.destLeft,o.img.destTop,o.img.destWidth,o.img.destHeight),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,isRotatePan:!0}});var v=o.img.destLeft,u=o.img.destTop;o.img.destLeft+=o.panPoint.totalPannedClientPoint.x,o.img.destTop+=o.panPoint.totalPannedClientPoint.y,o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y,o.panPoint.totalPannedClientPoint.x=o.img.destLeft-v,o.panPoint.totalPannedClientPoint.y=o.img.destTop-u,o.objColl=s,o.pointColl=l,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:p}}}),o.transform.degree=a,this.lowerContext.filter="none",t&&(i?(o.panPoint.totalPannedClientPoint.x=-o.panPoint.totalPannedClientPoint.x,o.panPoint.totalPannedClientPoint.y=-o.panPoint.totalPannedClientPoint.y,o.panPoint.currentPannedPoint=e.extend({},o.panPoint.totalPannedClientPoint,{},!0),o.panPoint.totalPannedClientPoint={x:0,y:0},o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y):o.panPoint.currentPannedPoint=e.extend({},o.panPoint.totalPannedClientPoint,{},!0)),o.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),o.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),this.lowerContext.filter=d,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=e.extend({},r,{},!0),o.activeObj.activePoint&&o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),this.isReverseRotate=!1},o.prototype.limitPan=function(){var t=this.parent;t.activeObj.activePoint&&(t.img.destLeft>t.activeObj.activePoint.startX&&(t.img.destLeft=t.activeObj.activePoint.startX),t.img.destTop>t.activeObj.activePoint.startY&&(t.img.destTop=t.activeObj.activePoint.startY),t.img.destLeft+t.img.destWidth<t.activeObj.activePoint.endX&&(t.img.destLeft=t.activeObj.activePoint.endX-t.img.destWidth),t.img.destTop+t.img.destHeight<t.activeObj.activePoint.endY&&(t.img.destTop=t.activeObj.activePoint.endY-t.img.destHeight))},o.prototype.updateFlipActiveObj=function(t){var e=this.parent;"horizontal"===t?(e.activeObj.activePoint.startX>e.lowerCanvas.width/2?e.activeObj.activePoint.endX=e.lowerCanvas.width/2-(e.activeObj.activePoint.startX-e.lowerCanvas.width/2):e.activeObj.activePoint.endX=e.lowerCanvas.width/2+(e.lowerCanvas.width/2-e.activeObj.activePoint.startX),e.activeObj.activePoint.startX=e.activeObj.activePoint.endX-e.activeObj.activePoint.width):"vertical"===t?(e.activeObj.activePoint.startX>e.lowerCanvas.width/2?e.activeObj.activePoint.endY=e.lowerCanvas.height/2-(e.activeObj.activePoint.startY-e.lowerCanvas.height/2):e.activeObj.activePoint.endY=e.lowerCanvas.height/2+(e.lowerCanvas.height/2-e.activeObj.activePoint.startY),e.activeObj.activePoint.startY=e.activeObj.activePoint.endY-e.activeObj.activePoint.height):"verticalHorizontal"!==t&&"horizontalVertical"!==t||(e.activeObj.activePoint.startX>e.lowerCanvas.width/2?(e.activeObj.activePoint.endX=e.lowerCanvas.width/2-(e.activeObj.activePoint.startX-e.lowerCanvas.width/2),e.activeObj.activePoint.endY=e.lowerCanvas.height/2-(e.activeObj.activePoint.startY-e.lowerCanvas.height/2)):(e.activeObj.activePoint.endX=e.lowerCanvas.width/2+(e.lowerCanvas.width/2-e.activeObj.activePoint.startX),e.activeObj.activePoint.endY=e.lowerCanvas.height/2+(e.lowerCanvas.height/2-e.activeObj.activePoint.startY)),e.activeObj.activePoint.startX=e.activeObj.activePoint.endX-e.activeObj.activePoint.width,e.activeObj.activePoint.startY=e.activeObj.activePoint.endY-e.activeObj.activePoint.height),e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}})},o.prototype.pan=function(t){var e=this.parent;!e.disabled&&e.isImageLoaded&&(t?(e.togglePan=!0,e.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),e.lowerCanvas.style.cursor=e.upperCanvas.style.cursor=e.cursor="grab",e.notify("selection",{prop:"setPanDown",onPropertyChange:!1,value:{panDown:null}})):(e.togglePan=e.currObjType.isCustomCrop=!1,e.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),e.lowerCanvas.style.cursor=e.upperCanvas.style.cursor=e.cursor="default"))},o.prototype.zoom=function(t,i){var o=this.parent;if(!o.disabled&&o.isImageLoaded){var r=this.getCurrentZoomFactor(t);if(e.isNullOrUndefined(i))this.zoomAction(r,i);else for(var a=r>0?"zoomIn":"zoomOut",n=0;n<10*Math.abs(r);n++)o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:i.x,y:i.y,type:a}})}},o.prototype.getCurrentZoomFactor=function(t){return.1*(t-this.prevZoomValue)},o.prototype.setCurrPanRegion=function(t,e,i){var o=t;""===t?"horizontal"===e?o="horizontal":"vertical"===e&&(o="vertical"):"horizontal"===t?"horizontal"===e?o="horizontalVertical":"vertical"===e?o="verticalHorizontal":90===e?o="vertical":-90===e&&(o="horizontal"):"vertical"===t?"horizontal"===e?o="horizontalVertical":"vertical"===e?o="verticalHorizontal":90===e?o="horizontal":-90===e&&(o="vertical"):"horizontal"===e?o="vertical":"vertical"===e&&(o="horizontal"),i.panRegion=o},o.prototype.rotate=function(t,e){var i=this.parent;!i.disabled&&i.isImageLoaded&&t%90==0&&this.rotateImage(t),e.isRotate=!1},o.prototype.flip=function(t){var e=this.parent;!e.disabled&&e.isImageLoaded&&this.flipImage(t)},o.prototype.update=function(){var t=this.parent,o=0,r=!1,a={bool:!1};t.isImageLoaded&&((t.element.querySelector("#"+t.element.id+"_contextualToolbar")&&!t.element.querySelector("#"+t.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||t.element.querySelector("#"+t.element.id+"_headWrapper")&&!t.element.querySelector("#"+t.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.okBtn(),e.isBlazor()?t.updateToolbar(t.element,"imageLoaded"):(t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))),t.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(e.isBlazor()?t.updateToolbar(t.element,"destroyQuickAccessToolbar"):t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),void 0!==t.activeObj.shape&&(r=!0,"block"===t.textArea.style.display?(t.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e.isBlazor()?t.updateToolbar(t.element,"destroyQuickAccessToolbar"):t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})):(t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.objColl.push(t.activeObj)),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})));var n=this.lowerContext.filter,s=document.querySelector("#"+t.element.id+"_canvasWrapper");if(s&&(s.style.width=t.element.offsetWidth-2+"px"),t.lowerCanvas.width=t.upperCanvas.width=t.element.offsetWidth-2,t.toolbarTemplate?o=t.element.querySelector("#"+t.element.id+"_toolbarArea").clientHeight:t.element.querySelector("#"+t.element.id+"_toolbar")&&(o=t.element.querySelector("#"+t.element.id+"_toolbar").clientHeight),t.notify("toolbar",{prop:"setToolbarHeight",value:{height:o}}),e.Browser.isDevice?(s&&(s.style.height=t.element.offsetHeight-2*o-5+"px"),t.lowerCanvas.height=t.upperCanvas.height=t.element.offsetHeight-2*o-5):(s&&(s.style.height=t.element.offsetHeight-o-3+"px"),t.lowerCanvas.height=t.upperCanvas.height=t.element.offsetHeight-o-3),this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",t.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),t.canvasFilter=this.lowerContext.filter,this.parent.initialAdjustmentValue=this.lowerContext.filter,t.clearContext(this.lowerContext),this.parent.clearContext(this.upperContext),t.isImageLoaded){if(t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.lowerContext.filter=n,t.initialAdjustmentValue=n,t.isImageLoaded&&(i.showSpinner(t.element),t.element.style.opacity="0.5"),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),s){s.style.width=t.element.offsetWidth-2+"px",s.style.height=t.element.offsetHeight+"px";var l={toolbarHeight:e.isBlazor()?t.toolbarHeight:0};e.isBlazor()||t.notify("toolbar",{prop:"getToolbarHeight",value:{obj:l}}),e.Browser.isDevice?s.style.height=parseFloat(s.style.height)-2*l.toolbarHeight-3+"px":s.style.height=parseFloat(s.style.height)-l.toolbarHeight-3+"px"}var p={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcWidth,height:t.img.srcHeight,obj:p}});var h=p;if(t.transform.defaultZoomFactor>0&&(h.width+=h.width*t.transform.defaultZoomFactor,h.height+=h.height*t.transform.defaultZoomFactor),t.img.destLeft=(t.lowerCanvas.clientWidth-h.width)/2,t.img.destTop=(t.lowerCanvas.clientHeight-h.height)/2,0===t.transform.degree&&""===t.transform.currFlipState)t.transform.defaultZoomFactor>0&&(t.img.destLeft+=t.panPoint.totalPannedPoint.x,t.img.destTop+=t.panPoint.totalPannedPoint.y),t.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:h}});else{t.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:h}}),t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var c=this.lowerContext.filter;t.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=c,t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}})}t.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.hideSpinner(t.element),t.element.style.opacity="1";var d={defToolbarItems:null};if(e.isBlazor()||(t.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:d}}),d.defToolbarItems&&d.defToolbarItems.length>0&&document.getElementById(t.element.id+"_toolbar")&&(e.getComponent(t.element.id+"_toolbar","toolbar").refreshOverflow(),t.element.querySelector(".e-contextual-toolbar-wrapper")&&t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"))),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),r&&(t.activeObj=e.extend({},t.objColl[t.objColl.length-1],null,!0),t.objColl.pop(),0!==t.activeObj.activePoint.width&&0!==t.activeObj.activePoint.height&&(t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:t.activeObj}}),"rectangle"!==t.activeObj.shape&&"ellipse"!==t.activeObj.shape&&"text"!==t.activeObj.shape&&"line"!==t.activeObj.shape&&"arrow"!==t.activeObj.shape&&"path"!==t.activeObj.shape||(e.isBlazor()?t.updateToolbar(t.element,"quickAccessToolbar",t.activeObj.shape):t.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})))),a.bool&&(e.isBlazor()?t.updateToolbar(t.element,"quickAccessToolbar","pen"):t.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}})),(0!==t.transform.degree||""!==t.transform.currFlipState)&&t.transform.defaultZoomFactor>0){var v=e.extend({},t.panPoint.totalPannedPoint,null,!0),u=e.extend({},t.panPoint.totalPannedInternalPoint,null,!0),g=e.extend({},t.panPoint.totalPannedClientPoint,null,!0);t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}}),t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}}),0===t.transform.degree?(t.img.destLeft+=v.x,t.img.destTop+=v.y,t.panPoint.totalPannedPoint=v,t.notify("draw",{prop:"updateFlipPan",value:{tempSelectionObj:null}})):(t.panPoint.totalPannedInternalPoint=u,t.panPoint.totalPannedClientPoint=g,t.panPoint.currentPannedPoint={x:0,y:0},t.isCropTab=!0,t.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),t.isCropTab=!1)}else 0!==t.transform.degree&&t.transform.cropZoomFactor>0&&(t.transform.zoomFactor=0,t.transform.cropZoomFactor=null,e.isBlazor()?t.updateToolbar(t.element,"enableDisableToolbarBtn"):t.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}))}},o.prototype.calcMaxDimension=function(t,i,o){var r={toolbarHeight:0};e.isBlazor()?r.toolbarHeight=this.parent.toolbarHeight:this.parent.notify("toolbar",{prop:"getToolbarHeight",value:{obj:r}});var a=this.parent.element.clientWidth,n=this.parent.element.clientHeight-r.toolbarHeight;n=e.Browser.isDevice?n-r.toolbarHeight:n,a>30&&(a-=30),n>30&&(n-=30);var s=a/t,l=n/i,p=Math.min(t,a),h=Math.min(i,n);s<1&&s<l?(p=t*s,h=i*s):l<1&&l<s&&(p=t*l,h=i*l);var c={bool:null};return this.parent.notify("crop",{prop:"getPreventScaling",onPropertyChange:!1,value:{obj:c}}),c.bool&&this.parent.cropObj.activeObj.activePoint&&0!==this.parent.cropObj.activeObj.activePoint.width&&0!==this.parent.cropObj.activeObj.activePoint.height&&(p=this.parent.cropObj.activeObj.activePoint.width,h=this.parent.cropObj.activeObj.activePoint.height),o&&(o.width=p,o.height=h),{width:p,height:h}},o.prototype.updatePanPoints=function(t,i){var o=this.parent,r=e.extend({},o.activeObj,{},!0),a=o.img.destLeft,n=o.img.destTop;e.isNullOrUndefined(this.tempPanMove)&&(this.tempPanMove={x:this.panMove.x,y:this.panMove.y});var s=this.panMove.x-this.tempPanMove.x,l=this.panMove.y-this.tempPanMove.y;switch(t){case"":o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontal":this.updateFlipActiveObj(t),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop+=l;break;case"vertical":this.updateFlipActiveObj(t),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontalVertical":this.updateFlipActiveObj(t),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop-=l;break;case"verticalHorizontal":this.updateFlipActiveObj(t),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft-=s,o.img.destTop+=l}return this.limitPan(),o.activeObj=r,i&&(i.x=o.img.destLeft-a,i.y=o.img.destTop-n),{x:o.img.destLeft-a,y:o.img.destTop-n}},o}(),u=function(){function t(t){this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("undo-redo",this.undoRedo,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("undo-redo",this.undoRedo),this.parent.off("destroyed",this.destroy)},t.prototype.initializeUrPvtProp=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},t.prototype.undoRedo=function(t){switch(this.initializeUrPvtProp(),t.prop){case"updateUndoRedoColl":this.updateUrc(t.value.operation,t.value.previousObj,t.value.previousObjColl,t.value.previousPointColl,t.value.previousSelPointColl,t.value.previousCropObj,t.value.previousText,t.value.currentText,t.value.previousFilter,t.value.isCircleCrop);break;case"refreshUrc":this.refreshUrc(t.value.bool);break;case"updateCurrUrc":this.updateCurrUrc(t.value.type);break;case"call-undo":this.callUndo();break;case"call-redo":this.callRedo();break;case"undo":this.undo();break;case"redo":this.redo();break;case"updateUrObj":this.updateUrObj(t.value.objColl);break;case"updateUndoRedo":this.updateUndoRedo();break;case"getAppliedUndoRedoColl":t.value.obj.appliedUndoRedoColl=this.appliedUndoRedoColl;break;case"getUndoRedoStep":t.value.obj.undoRedoStep=this.undoRedoStep;break;case"setUndoRedoStep":this.undoRedoStep=t.value.step;break;case"undoDefault":this.undoDefault(t.value.obj);break;case"reset":this.reset()}},t.prototype.getModuleName=function(){return"undo-redo"},t.prototype.reset=function(){this.tempCurrSelPoint=null,this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempActObj=null,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0},t.prototype.refreshUrc=function(t){var i=this.parent;(t=t||!1)?(e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!0}}),this.tempUndoRedoColl=e.extend([],this.appliedUndoRedoColl,[],!0),this.tempUndoRedoStep=this.undoRedoStep):e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),this.undoRedoColl=this.undoRedoColl.slice(0,this.undoRedoStep),this.appliedUndoRedoColl=this.appliedUndoRedoColl.slice(0,this.undoRedoStep),i.isUndoRedo=i.currObjType.isUndoAction=!1,e.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})},t.prototype.updateCurrUrc=function(t){var i=this.parent;if(e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),"ok"===t){i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!1}});var o=this.tempUndoRedoColl.length>0?e.extend([],this.tempUndoRedoColl,[],!0):e.extend([],this.undoRedoColl,[],!0),r=this.undoRedoColl[this.undoRedoColl.length-1];if(e.isNullOrUndefined(this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1])?this.undoRedoColl[0]&&(r.previousCropObj=o[0].previousCropObj,r.previousObj=o[0].previousObj,r.previousObjColl=o[0].previousObjColl,r.previousPointColl=o[0].previousPointColl,r.previousText=o[0].previousText):(r.previousCropObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentCropObj,r.previousObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObj,r.previousObjColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObjColl,r.previousPointColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentPointColl,r.previousText=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentText),r){var a=this.getZeroZoomObjPointValue(r.currentObjColl,r.currentPointColl);r.currentObjColl=a.obj,r.currentPointColl=a.point,this.appliedUndoRedoColl.push(r)}this.tempUndoRedoColl=[],this.tempUndoRedoStep=0}else this.tempUndoRedoColl.length>0&&(this.appliedUndoRedoColl=e.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0);this.appliedUndoRedoColl.length>16&&this.appliedUndoRedoColl.splice(0,1),this.undoRedoColl=[],this.undoRedoColl=e.extend([],this.appliedUndoRedoColl,[],!0),"ok"===t&&(this.undoRedoStep=this.undoRedoColl.length,e.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})),i.transform.zoomFactor>0&&(i.togglePan=!0,i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}))},t.prototype.cancelCropSelection=function(){var t,i=this.parent,o=!1;i.activeObj.shape&&(t=i.activeObj.shape.split("-")),(i.currObjType.isCustomCrop||t&&"crop"===t[0])&&(o=!0),o&&i.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),0===this.tempUndoRedoColl.length&&0===this.tempUndoRedoStep||(this.appliedUndoRedoColl=e.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoColl=e.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}))},t.prototype.refreshToolbarActions=function(){var t=this.parent;e.isBlazor()?e.isNullOrUndefined(t.activeObj.shape)&&t.updateToolbar(t.element,"imageLoaded"):t.activeObj.shape?(t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})):t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},t.prototype.applyCurrentChanges=function(){var t=this.parent;t.currObjType.isFiltered=!1,0===t.transform.zoomFactor&&(t.togglePan=!1,t.notify("selection",{prop:"setDragCanvas",value:{bool:!1}})),t.element.querySelector(".e-contextual-toolbar-wrapper")&&!e.isBlazor()&&t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.togglePen&&(t.togglePen=!1,t.upperCanvas.style.cursor=t.cursor="default",this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height)),this.appliedUndoRedoColl.length>0&&(this.undoRedoColl=e.extend([],this.appliedUndoRedoColl,[],!0))},t.prototype.callUndo=function(){this.applyCurrentChanges(),this.undo()},t.prototype.callRedo=function(){this.applyCurrentChanges(),this.redo()},t.prototype.undo=function(){var t=this.parent;if(this.cancelCropSelection(),!t.disabled&&t.isImageLoaded&&this.undoRedoStep>0){this.refreshToolbarActions(),t.activeObj.activePoint&&0!==t.activeObj.activePoint.width&&(this.tempActObj=t.activeObj),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.undoRedoStep--,e.isBlazor()?t.updateToolbar(t.element,"enableDisableToolbarBtn"):(t.notify("toolbar",{prop:"enable-disable-btns"}),t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),t.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep];this.undoRedoColl.length===this.undoRedoStep?t.currObjType.isUndoAction=!1:t.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===t.textArea.style.display&&(t.textArea.style.display="none"),t.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}});switch(t.cropObj=e.extend({},i.previousCropObj,{},!0),t.afterCropActions=i.previousObj.afterCropActions,this.lowerContext.filter=i.previousObj.filter,t.canvasFilter=this.lowerContext.filter,i.operation){case"shapeTransform":this.shapeTransform(i.previousObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.previousPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.previousPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.previousObjColl,i.previousPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(void 0,i.previousObjColl);break;case"text":this.updateText(i.previousObjColl,!0);break;default:this.undoDefault(i),t.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),t.notify("filter",{prop:"update-filter",value:{operation:i.operation,filter:i.filter}})}"crop"===i.operation&&(i.previousObj.currSelectionPoint&&(t.currSelectionPoint=e.extend({},i.previousObj.currSelectionPoint,{},!0),t.currSelectionPoint&&e.isNullOrUndefined(t.currSelectionPoint.shape)&&(t.currSelectionPoint=null)),t.updateCropTransformItems(),t.select("custom"),t.isCircleCrop&&(t.isCircleCrop=!1,this.tempCurrSelPoint=e.extend({},t.currSelectionPoint,{},!0),t.currSelectionPoint=null),t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}})),this.undoRedoColl[this.undoRedoStep-1]&&this.undoRedoColl[this.undoRedoStep-1].isCircleCrop&&(t.isCircleCrop=!0,t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})),this.endUndoRedo(i.operation,!0)}},t.prototype.redo=function(){var t=this.parent;if(this.cancelCropSelection(),!t.disabled&&t.isImageLoaded&&this.undoRedoStep<this.appliedUndoRedoColl.length){this.refreshToolbarActions(),this.undoRedoStep++,e.isBlazor()?t.updateToolbar(t.element,"enableDisableToolbarBtn"):t.notify("toolbar",{prop:"enable-disable-btns"}),t.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep-1];this.undoRedoColl.length===this.undoRedoStep?t.currObjType.isUndoAction=!1:t.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===t.textArea.style.display&&(t.textArea.style.display="none"),t.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}}),t.cropObj=e.extend({},i.currentCropObj,{},!0),t.afterCropActions=i.currentObj.afterCropActions,this.lowerContext.filter=i.currentObj.filter,e.isBlazor()||t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.canvasFilter=this.lowerContext.filter;var o=void 0;switch(i.operation){case"shapeTransform":this.shapeTransform(i.currentObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.currentPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.currentPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.currentObjColl,i.currentPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(o,i.currentObjColl);break;case"text":this.updateText(i.currentObjColl,!1);break;default:t.objColl=[],t.pointColl=[],t.freehandCounter=0,t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),t.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:i.currentObj}}),t.img.destLeft=i.currentObj.destPoints.startX,t.img.destTop=i.currentObj.destPoints.startY,o=e.extend({},t.activeObj,{},!0),t.objColl=e.extend([],i.currentObjColl,[],!0),t.pointColl=e.extend([],i.currentPointColl,[],!0),t.freehandCounter=t.pointColl.length,t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:e.extend([],i.currentSelPointColl,[],!0)}}}),this.lowerContext.filter="none",t.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=i.currentObj.filter,t.activeObj=o,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),0!==t.activeObj.activePoint.width&&0!==t.activeObj.activePoint.height&&t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),t.notify("filter",{prop:"update-filter",value:{operation:i.operation}})}"crop"===i.operation&&i.isCircleCrop&&(t.isCircleCrop=!0,t.currSelectionPoint=e.extend({},this.tempCurrSelPoint,{},!0),this.tempCurrSelPoint=null),"crop"!==i.operation||i.isCircleCrop||(t.isCircleCrop=!1),"crop"===i.operation&&i.currentObj.currSelectionPoint&&(t.currSelectionPoint=e.extend({},i.currentObj.currSelectionPoint,{},!0)),t.currSelectionPoint&&e.isNullOrUndefined(t.currSelectionPoint.shape)&&(t.currSelectionPoint=null),this.endUndoRedo(i.operation,!1)}},t.prototype.shapeTransform=function(t){var i=this.parent;i.objColl=e.extend([],t,[],!0),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.isUndoRedo=!0,i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},t.prototype.updateFreehandDraw=function(t){var e=this.parent;e.pointColl=t,e.freehandCounter=e.pointColl.length,e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.isUndoRedo=!0,e.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},t.prototype.updateFreehandDrawCustomized=function(t){var e=this.parent;e.pointColl=t,e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.isUndoRedo=!0,e.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},t.prototype.updateDelete=function(t,e,i){var o=this.parent;"deleteFreehandDrawing"===t?(o.pointColl=i,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})):"deleteObj"===t&&(o.objColl=e,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}})),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},t.prototype.updateTextAreaCustomization=function(t,i){var o=this.parent;o.objColl=e.extend([],i,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1});for(var r=0,a=i.length;r<a;r++){if(!this.tempActObj){t=e.extend({},i[i.length-1],{},!0),o.objColl.splice(r,1);break}if(this.tempActObj.currIndex===i[r].currIndex){t=e.extend({},i[r],{},!0),o.objColl.splice(r,1);break}}t&&this.updateTextBox(t),"block"===o.textArea.style.display&&o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}})},t.prototype.updateText=function(t,i){var o=this.parent;if(this.tempActObj&&(o.activeObj=e.extend({},this.tempActObj,{},!0)),0===t.length&&1===o.objColl.length)this.tempActObj=e.extend({},o.objColl[0],{},!0);else for(var r=0;r<o.objColl.length;r++){if(o.objColl[r]&&e.isNullOrUndefined(t[r])){this.tempActObj=e.extend({},o.objColl[r],{},!0);break}if(t[r].currIndex!==o.objColl[r].currIndex){this.tempActObj=e.extend({},o.objColl[r],{},!0);break}}i&&(o.activeObj=e.extend({},this.tempActObj,{},!0)),o.objColl=e.extend([],t,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},t.prototype.updateTextBox=function(t){var i=this.parent;this.upperContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),e.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.textArea.style.display="block",i.textArea.style.fontFamily=t.textSettings.fontFamily,i.textArea.style.fontSize=t.textSettings.fontSize+"px",i.textArea.style.color=t.strokeSettings.strokeColor,i.textArea.style.fontWeight=t.textSettings.bold?"bold":"normal",i.textArea.style.fontStyle=t.textSettings.italic?"italic":"normal",i.textArea.style.border="2px solid "+i.themeColl[i.theme].primaryColor,i.textArea.value=t.keyHistory,i.activeObj=e.extend({},t,{},!0),i.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}}),i.textArea.style.width=i.activeObj.activePoint.width+"px"},t.prototype.undoDefault=function(t){this.lowerContext.filter=t.previousObj.filter;var i=this.parent;i.objColl=[],i.pointColl=[],i.freehandCounter=0,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:t.previousObj}}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.img.destLeft=t.previousObj.destPoints.startX,i.img.destTop=t.previousObj.destPoints.startY;var o=e.extend({},i.activeObj,{},!0);i.objColl=e.extend([],t.previousObjColl,[],!0),i.pointColl=e.extend([],t.previousPointColl,[],!0),i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:e.extend([],t.previousSelPointColl,[],!0)}}}),this.lowerContext.filter="none",i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=t.previousObj.filter,i.activeObj=o,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})},t.prototype.endUndoRedo=function(t,i){var o=this.parent;o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.isCircleCrop&&(i&&"crop"!==t||!i)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.transform.zoomFactor>0&&o.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),o.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!1}}),e.isBlazor()?(e.isNullOrUndefined(o.activeObj.shape)||"crop"!==o.activeObj.shape.split("-")[0])&&(o.updateToolbar(o.element,"imageLoaded"),o.updateToolbar(o.element,"enableDisableToolbarBtn")):(o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!0,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"enable-disable-btns"})),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"),e.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns"}),0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}}),o.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),o.currObjType.isCustomCrop=!1},t.prototype.updateUrc=function(t,i,o,r,a,n,s,l,p,h){var c=this.parent,d={isInitialLoaded:!1};if(c.currObjType.isUndoAction&&this.refreshUrc(!0),c.notify("draw",{prop:"isInitialLoaded",onPropertyChange:!1,value:{object:d}}),!d.isInitialLoaded&&c.allowUndoRedo){var v={currObj:{}};c.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:v}});var u=v.currObj;u.objColl=e.extend([],c.objColl,[],!0),u.pointColl=e.extend([],c.pointColl,[],!0),u.afterCropActions=e.extend([],c.afterCropActions,[],!0);var g={selPointColl:null};c.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:g}}),u.selPointColl=e.extend([],g.selPointColl,[],!0),"crop"===t&&(u.currSelectionPoint=e.extend({},c.currSelectionPoint,{},!0)),this.undoRedoColl.push({operation:t,previousObj:i,currentObj:u,previousObjColl:o,currentObjColl:u.objColl,previousPointColl:r,currentPointColl:u.pointColl,previousSelPointColl:a,currentSelPointColl:u.selPointColl,previousCropObj:n,currentCropObj:e.extend({},c.cropObj,{},!0),previousText:s,currentText:l,filter:p,isCircleCrop:h}),e.isBlazor()?c.updateToolbar(c.element,"enableDisableToolbarBtn"):c.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1})}},t.prototype.updateUrObj=function(t){var i=this.parent;if(i.allowUndoRedo){i.currObjType.isUndoAction&&this.refreshUrc(!0),i.objColl.push(i.activeObj);var o=e.extend({},i.cropObj,{},!0),r={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],i.objColl,[],!0),a.pointColl=e.extend([],i.pointColl,[],!0),a.afterCropActions=e.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.undoRedoColl.push({operation:"shapeTransform",previousObj:a,currentObj:a,previousObjColl:t,currentObjColl:a.objColl,previousPointColl:a.pointColl,currentPointColl:a.pointColl,previousSelPointColl:a.selPointColl,currentSelPointColl:a.selPointColl,previousCropObj:o,currentCropObj:o}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}})}},t.prototype.updateUndoRedo=function(){var t=this.parent,i=e.extend({},t.cropObj,{},!0),o={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],t.objColl,[],!0),r.pointColl=e.extend([],t.pointColl,[],!0),r.afterCropActions=e.extend([],t.afterCropActions,[],!0);var a={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),t.objColl.push(t.activeObj),this.updateUrc("shapeTransform",r,r.objColl,r.pointColl,r.selPointColl,i),t.objColl.pop(),t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isBlazor()?t.updateToolbar(t.element,"imageLoaded"):(t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))},t.prototype.getZeroZoomObjPointValue=function(t,i){var o=this.parent,r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],o.objColl,[],!0),a.pointColl=e.extend([],o.pointColl,[],!0),a.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0);var s={cropDimension:null};o.notify("transform",{prop:"getCropDimension",onPropertyChange:!1,value:{obj:s}});var l=e.extend([],o.objColl,[],!0),p=e.extend([],o.pointColl,[],!0),h={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:h}});var c=e.extend({},h.arrowDimension,{},!0);if(o.transform.zoomFactor>0&&(t.length>0||i.length>0)){o.objColl=t,o.pointColl=i;var d=o.isUndoRedo;if(0!==o.transform.zoomFactor){o.isUndoRedo=o.isCropTab=!0,o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var v=e.extend({},o.zoomSettings,null,!0);o.transform.zoomFactor>0?o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-o.transform.zoomFactor,zoomPoint:null}}):o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(o.transform.zoomFactor),zoomPoint:null}}),o.zoomSettings=v,o.isCropTab=!1,o.isUndoRedo=d,l=e.extend([],o.objColl,[],!0),p=e.extend([],o.pointColl,[],!0),o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:s.cropDimension.width,height:s.cropDimension.height}});var u={width:s.cropDimension.width,height:s.cropDimension.height};u.width+=u.width*a.defaultZoom,u.height+=u.height*a.defaultZoom,o.notify("draw",{prop:"setZoomCropWidth",value:{width:u.width,height:u.height}}),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:a}}),o.img.destLeft=a.destPoints.startX,o.img.destTop=a.destPoints.startY,o.panPoint.totalPannedPoint=a.totalPannedPoint,o.panPoint.totalPannedClientPoint=a.totalPannedClientPoint,o.panPoint.totalPannedInternalPoint=a.totalPannedInternalPoint,o.objColl=e.extend([],a.objColl,[],!0),o.pointColl=e.extend([],a.pointColl,[],!0),o.freehandCounter=o.pointColl.length,o.notify("draw",{prop:"setArrowDimension",onPropertyChange:!1,value:{arrowDimension:c}}),o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:e.extend([],a.selPointColl,[],!0)}}}),this.lowerContext.filter="none",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),o.notify("freehand-draw",{prop:"updateFHDCurPts",onPropertyChange:!1}),this.lowerContext.filter=a.filter,0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}})}}return{obj:l,point:p}},t}(),g=function(){var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(e,i)};return function(e,i){function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),b=function(t,e,i,o){var r,a=arguments.length,n=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(n=(a<3?r(n):a>3?r(e,i,n):r(e,i))||n);return a>3&&n&&Object.defineProperty(e,i,n),n},C=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return g(i,t),b([e.Property(null)],i.prototype,"brightness",void 0),b([e.Property(null)],i.prototype,"contrast",void 0),b([e.Property(null)],i.prototype,"hue",void 0),b([e.Property(null)],i.prototype,"saturation",void 0),b([e.Property(null)],i.prototype,"exposure",void 0),b([e.Property(null)],i.prototype,"opacity",void 0),b([e.Property(null)],i.prototype,"blur",void 0),i}(e.ChildProperty),f=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return g(i,t),b([e.Property(null)],i.prototype,"zoomTrigger",void 0),b([e.Property(1)],i.prototype,"minZoomFactor",void 0),b([e.Property(10)],i.prototype,"maxZoomFactor",void 0),b([e.Property(1)],i.prototype,"zoomFactor",void 0),b([e.Property(null)],i.prototype,"zoomPoint",void 0),i}(e.ChildProperty),m=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return g(i,t),b([e.Property(!0)],i.prototype,"showCircle",void 0),b([e.Property(null)],i.prototype,"strokeColor",void 0),b([e.Property(null)],i.prototype,"fillColor",void 0),i}(e.ChildProperty),y=function(o){function r(t,i){var r=o.call(this,t)||this;return r.isImageLoaded=!1,r.activeObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[],rotatedAngle:0},r.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},r.objColl=[],r.pointColl={},r.freehandCounter=0,r.points=[],r.togglePen=!1,r.togglePan=!1,r.img={destLeft:0,destTop:0,destWidth:0,destHeight:0,srcLeft:0,srcTop:0,srcWidth:0,srcHeight:0},r.rotateFlipColl=[],r.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",zoomFactor:0,previousZoomValue:0},r.afterCropActions=[],r.transform={degree:0,currFlipState:"",zoomFactor:0,cropZoomFactor:null,defaultZoomFactor:0},r.panPoint={currentPannedPoint:{x:0,y:0},totalPannedPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0}},r.isUndoRedo=!1,r.isCropTab=!1,r.isCircleCrop=!1,r.fontSizeColl=[],r.initialAdjustmentValue="",r.currentFilter="",r.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",r.toolbarHeight=0,r.isPublicMethod=!1,r.isCropToolbar=!1,r.cursor="default",e.isBlazor()?(new n(r),new s(r),new p(r),new h(r),new c(r),new d(r),new v(r),new u(r),new l(r)):(a.Inject(n,s,c,v,l,P),a.Inject(u),a.Inject(p),a.Inject(d),a.Inject(h),i&&r.appendTo(i)),r}g(r,o),a=r,r.prototype.requiredModules=function(){var t=[];return t.push({member:"crop",args:[this]}),t.push({member:"draw",args:[this]}),t.push({member:"selection",args:[this]}),t.push({member:"transform",args:[this]}),t.push({member:"export",args:[this]}),t.push({member:"toolbar-module",args:[this]}),t.push({member:"undo-redo",args:[this]}),t.push({member:"filter",args:[this]}),t.push({member:"shape",args:[this]}),t.push({member:"freehand-draw",args:[this]}),t},r.prototype.preRender=function(){this.element.id=this.element.id||e.getUniqueID("ej2-image-editor"),e.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},r.prototype.render=function(){this.initialize()},r.prototype.getModuleName=function(){return"image-editor"},r.prototype.getPersistData=function(){return this.addOnPersist([])},r.prototype.onPropertyChanged=function(i,o){for(var r=0,a=Object.keys(i);r<a.length;r++)switch(a[r]){case"cssClass":o.cssClass&&e.removeClass([this.element],o.cssClass.replace(/\s+/g," ").trim().split(" ")),i.cssClass&&e.addClass([this.element],i.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"disabled":i.disabled?(this.element.classList.add("e-disabled"),this.unwireEvent()):(this.element.classList.remove("e-disabled"),this.wireEvent());break;case"height":this.element.style.height=i.height;break;case"width":this.element.style.width=i.width;break;case"theme":i.theme&&(this.theme&&""!==this.theme?this.theme=this.toPascalCase(this.theme):this.theme="Bootstrap5",this.upperContext.strokeStyle=this.themeColl[this.theme].primaryColor,this.upperContext.fillStyle=this.themeColl[this.theme].secondaryColor);break;case"finetuneSettings":i.finetuneSettings&&(this.finetuneSettings=i.finetuneSettings,this.notify("filter",{prop:"update-finetunes"}));break;case"locale":i.locale&&(this.notify("toolbar",{prop:"setLocale",onPropertyChange:!1,value:{locale:i.locale}}),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"allowUndoRedo":i.allowUndoRedo?this.allowUndoRedo=!0:this.allowUndoRedo=!1,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"showQuickAccessToolbar":i.showQuickAccessToolbar?(this.showQuickAccessToolbar=!0,this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})):(this.showQuickAccessToolbar=!1,this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}));break;case"zoomSettings":i.zoomSettings&&(this.zoomSettings.zoomTrigger=i.zoomSettings.zoomTrigger),e.isNullOrUndefined(this.zoomSettings.zoomTrigger)?(this.zoomSettings.zoomTrigger=t.ZoomTrigger.MouseWheel|t.ZoomTrigger.Pinch|t.ZoomTrigger.Toolbar|t.ZoomTrigger.Commands,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})):(i.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)===t.ZoomTrigger.Toolbar&&this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"selectionSettings":i.selectionSettings&&(this.selectionSettings=i.selectionSettings,this.activeObj.shape&&(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})))}},r.prototype.destroy=function(){var t=[];this.element.removeAttribute("tabindex"),this.cssClass&&(t=t.concat(this.cssClass.replace(/\s+/g," ").trim().split(" "))),e.removeClass([this.element],t),this.element.getAttribute("class")||this.element.removeAttribute("class"),e.isBlazor()?this.element.classList.remove("e-image-editor"):(this.notify("toolbar",{prop:"destroySubComponents",onPropertyChange:!1}),this.notify("destroyed",null),o.prototype.destroy.call(this)),this.unwireEvent(),this.element.innerHTML=""},r.prototype.initialize=function(){if(this.toolbarTemplate?(this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplateFn()):(this.notify("toolbar",{prop:"create-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"create-contextual-toolbar",onPropertyChange:!1})),this.createCanvas(),this.showQuickAccessToolbar){document.querySelector("#"+this.element.id+"_canvasWrapper").appendChild(this.createElement("div",{id:this.element.id+"_quickAccessToolbarArea",className:"e-quick-access-toolbar-area"}));var t=document.getElementById(this.element.id+"_quickAccessToolbarArea");t.style.position="absolute",t.style.display="none",this.activeObj&&(t.style.left=this.activeObj.activePoint.startX+"px",t.style.top=this.activeObj.activePoint.startY+"px"),t.style.width="100%"}this.quickAccessToolbarTemplate?this.quickAccessToolbarTemplateFn():this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),this.wireEvent(),this.lowerContext=this.lowerCanvas.getContext("2d"),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.notify("toolbar",{prop:"setCanvasFilter",onPropertyChange:!1,value:{filter:this.lowerContext.filter}}),this.notify("toolbar",{prop:"setInitialAdjustmentValue",onPropertyChange:!1,value:{value:this.lowerContext.filter}}),this.cssClass&&e.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},r.prototype.wireEvent=function(){e.EventHandler.add(document,"keydown",this.keyDownEventHandler,this),e.EventHandler.add(document,"keypress",this.keyUpEventHandler,this),e.EventHandler.add(this.upperCanvas,"mousedown",this.mouseDownEventHandler,this),e.EventHandler.add(this.upperCanvas,"mousemove",this.mouseMoveEventHandler,this),e.EventHandler.add(this.upperCanvas,"mouseup",this.mouseUpEventHandler,this),e.EventHandler.add(document,"mouseup",this.mouseUpEventHandler,this),e.EventHandler.add(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler,this),e.EventHandler.add(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler,this),e.EventHandler.add(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler,this),e.EventHandler.add(document,"mouseup",this.canvasMouseUpHandler,this),e.EventHandler.add(this.upperCanvas,"touchstart",this.touchStartHandler,this),e.EventHandler.add(this.lowerCanvas,"touchstart",this.touchStartHandler,this),e.EventHandler.add(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),e.EventHandler.add(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),window.addEventListener("resize",this.windowResizeHandler.bind(this)),e.Browser.isIos||"safari"===e.Browser.info.name||screen.orientation.addEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"wireEvent",onPropertyChange:!1})},r.prototype.unwireEvent=function(){e.EventHandler.remove(document,"keydown",this.keyDownEventHandler),e.EventHandler.remove(document,"keypress",this.keyUpEventHandler),e.EventHandler.remove(this.upperCanvas,"mousedown",this.mouseDownEventHandler),e.EventHandler.remove(this.upperCanvas,"mousemove",this.mouseMoveEventHandler),e.EventHandler.remove(this.upperCanvas,"mouseup",this.mouseUpEventHandler),e.EventHandler.remove(document,"mouseup",this.mouseUpEventHandler),e.EventHandler.remove(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler),e.EventHandler.remove(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler),e.EventHandler.remove(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler),e.EventHandler.remove(document,"mouseup",this.canvasMouseUpHandler),e.EventHandler.remove(this.upperCanvas,"touchstart",this.touchStartHandler),e.EventHandler.remove(this.lowerCanvas,"touchstart",this.touchStartHandler),e.EventHandler.remove(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll),e.EventHandler.remove(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll),window.removeEventListener("resize",this.windowResizeHandler.bind(this)),e.Browser.isIos||"safari"===e.Browser.info.name||screen.orientation.removeEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"unWireEvent",onPropertyChange:!1})},r.prototype.createCanvas=function(){this.element.style.boxSizing="border-box";var t={toolbarHeight:0};this.notify("toolbar",{prop:"getToolbarHeight",value:{obj:t}});var e=t.toolbarHeight;this.element.style.width=this.width,this.element.style.height=this.height;var i=this.element.appendChild(this.createElement("div",{id:this.element.id+"_canvasWrapper",className:"e-canvas-wrapper",attrs:{style:"height:"+(this.element.offsetHeight-e-2)+"px; width:"+(this.element.offsetWidth-2)+"px; position: relative; overflow: hidden; margin: 0 auto;"}}));this.lowerCanvas=i.appendChild(this.createElement("canvas",{id:this.element.id+"_lowerCanvas",attrs:{name:"canvasImage"}})),this.upperCanvas=i.appendChild(this.createElement("canvas",{id:this.element.id+"_upperCanvas",attrs:{name:"canvasImage"}})),this.inMemoryCanvas=this.createElement("canvas",{id:this.element.id+"_inMemoryCanvas",attrs:{name:"canvasImage"}}),this.textArea=i.appendChild(this.createElement("textarea",{id:this.element.id+"_textArea",className:"e-textarea",attrs:{name:"textArea"}})),this.element.appendChild(this.createElement("div",{id:this.element.id+"_dialog",className:"e-dialog"})).style.display="none",this.textArea.setAttribute("spellcheck","false"),this.textArea.style.lineHeight="normal",this.lowerCanvas.style.width=this.upperCanvas.style.width=this.inMemoryCanvas.style.width="100%",this.lowerCanvas.style.height=this.upperCanvas.style.height=this.inMemoryCanvas.style.height="100%",this.upperCanvas.style.position=this.lowerCanvas.style.position=this.textArea.style.position="absolute",this.textArea.style.backgroundColor="transparent",this.textArea.style.display="none",this.textArea.style.resize="none",this.lowerContext=this.lowerCanvas.getContext("2d"),this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.upperCanvas.style.cursor=this.cursor="default",this.upperCanvas.style.display="block",this.upperContext=this.upperCanvas.getContext("2d")},r.prototype.touchStartHandler=function(t){this.notify("selection",{prop:"touchStartHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.mouseDownEventHandler=function(t){this.notify("selection",{prop:"mouseDownEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.mouseMoveEventHandler=function(t){this.notify("selection",{prop:"mouseMoveEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.mouseUpEventHandler=function(t){this.notify("selection",{prop:"mouseUpEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.keyDownEventHandler=function(t){this.notify("selection",{prop:"keyDownEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.keyUpEventHandler=function(t){"block"===this.textArea.style.display&&t.target.id===this.element.id+"_textArea"&&this.notify("selection",{prop:"textKeyDown",value:{e:t}})},r.prototype.canvasMouseDownHandler=function(t){this.notify("selection",{prop:"canvasMouseDownHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.canvasMouseMoveHandler=function(t){this.notify("selection",{prop:"canvasMouseMoveHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.canvasMouseUpHandler=function(t){this.notify("selection",{prop:"canvasMouseUpHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.handleScroll=function(t){this.notify("selection",{prop:"handleScroll",onPropertyChange:!1,value:{e:t}})},r.prototype.adjustToScreen=function(){this.update()},r.prototype.screenOrientation=function(){e.Browser.isDevice&&setTimeout(this.adjustToScreen.bind(this),100)},r.prototype.windowResizeHandler=function(){!e.Browser.isDevice&&this.element.classList.contains("e-image-editor")&&this.adjustToScreen()},r.prototype.notifyResetForAllModules=function(){for(var t=this.requiredModules(),e=0;e<t.length;e++)this.notify(t[e].member,{prop:"reset",onPropertyChange:!1})},r.prototype.allowShape=function(t,e){this.isPublicMethod=!0;var i={inRange:!1};return this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:t,y:e,obj:i}}),i.inRange},r.prototype.clearSelection=function(){this.notify("selection",{prop:"clearSelection",onPropertyChange:!1})},r.prototype.crop=function(){var t={isCrop:!1};return this.notify("crop",{prop:"crop",onPropertyChange:!1,value:{obj:t}}),t.isCrop},r.prototype.flip=function(t){this.notify("transform",{prop:"flip",value:{direction:t}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},r.prototype.getImageData=function(){var t={canvas:null};return this.notify("export",{prop:"exportToCanvas",value:{object:t}}),t.canvas.getContext("2d").getImageData(0,0,t.canvas.width,t.canvas.height)},r.prototype.open=function(t){this.notify("draw",{prop:"open",value:{data:t}})},r.prototype.reset=function(){var t={isErrorImage:!1};if(this.notify("draw",{prop:"getErrorImage",value:{obj:t}}),!this.disabled&&!t.isErrorImage){this.clearContext(this.inMemoryContext),this.clearContext(this.lowerContext),this.clearContext(this.upperContext),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isBlazor()||(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),e.Browser.isDevice&&document.getElementById(this.element.id+"_bottomToolbar")&&(e.getComponent(document.getElementById(this.element.id+"_bottomToolbar"),"toolbar").destroy(),this.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1}))),this.currObjType.isUndoAction=this.isUndoRedo=this.togglePan=this.togglePen=this.isImageLoaded=!1,this.isCircleCrop=this.isCropTab=!1,this.objColl=[],this.transform.degree=0,this.upperCanvas.style.display="block",this.transform.currFlipState="",this.upperCanvas.style.cursor=this.cursor=this.lowerCanvas.style.cursor="default",this.lowerContext.lineWidth=this.upperContext.lineWidth=void 0,this.textArea.value=this.textArea.textContent="",this.textArea.style.display="none",this.lowerContext.filter=this.canvasFilter=this.getDefaultFilter(),this.img.destLeft=this.img.destTop=this.img.srcLeft=this.img.srcTop=0,this.img.destWidth=this.img.destHeight=this.img.srcWidth=this.img.srcHeight=null,this.currSelectionPoint=null,this.panPoint.currentPannedPoint={x:0,y:0},this.rotateFlipColl=[],this.points=[],this.pointColl={},this.freehandCounter=0,this.notify("draw",{prop:"resetPanPoints"}),this.lowerCanvas.style.left=this.upperCanvas.style.left="",this.fontSizeColl=[],this.lowerCanvas.style.top=this.upperCanvas.style.top="",this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth="",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight="",this.transform.defaultZoomFactor=this.transform.zoomFactor=0,this.transform.cropZoomFactor=null,this.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},this.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:""},this.afterCropActions=[],this.currentFilter="";var i={initialZoomValue:!1};this.notify("draw",{prop:"getInitialZoomValue",onPropertyChange:!1,value:{obj:i}}),i.initialZoomValue&&this.setProperties({zoomSettings:{zoomFactor:i.initialZoomValue}},!0),document.getElementById(this.element.id+"_quickAccessToolbarArea")&&(document.getElementById(this.element.id+"_quickAccessToolbarArea").style.display="none"),this.notifyResetForAllModules(),this.notify("filter",{prop:"update-finetunes"}),this.isImageLoaded=!1,this.notify("draw",{prop:"update-canvas",onPropertyChange:!1}),this.isImageLoaded=!0,e.isBlazor()||(this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),this.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),this.notify("toolbar",{prop:"enable-disable-btns"}))}},r.prototype.rotate=function(t){var e={isRotate:!1};return this.notify("transform",{prop:"rotate",value:{degree:t,obj:e}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),e.isRotate},r.prototype.export=function(t,e){this.notify("export",{prop:"export",onPropertyChange:!1,value:{type:t,fileName:e}})},r.prototype.select=function(t,e,i,o,r){this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:t,startX:e,startY:i,width:o,height:r}})},r.prototype.freeHandDraw=function(t){this.notify("freehand-draw",{prop:"freeHandDraw",onPropertyChange:!1,value:{value:t}})},r.prototype.freehandDraw=function(t){!this.disabled&&this.isImageLoaded&&this.freeHandDraw(t)},r.prototype.pan=function(t){this.notify("transform",{prop:"pan",onPropertyChange:!1,value:{value:t}})},r.prototype.zoom=function(t,e){this.notify("transform",{prop:"zoom",onPropertyChange:!1,value:{zoomFactor:t,zoomPoint:e}})},r.prototype.drawEllipse=function(t,i,o,r,a,n,s){var l=!1,p=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(p||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(l=!0,this.notify("shape",{prop:"drawEllipse",onPropertyChange:!1,value:{x:t,y:i,radiusX:o,radiusY:r,strokeWidth:a,strokeColor:n,fillColor:s}})),l},r.prototype.drawLine=function(t,i,o,r,a,n){var s=!1,l=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(l||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(s=!0,this.notify("shape",{prop:"drawLine",onPropertyChange:!1,value:{startX:t,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n}})),s},r.prototype.drawArrow=function(t,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(h||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawArrow",onPropertyChange:!1,value:{startX:t,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n,arrowStart:s,arrowEnd:l}})),p},r.prototype.drawPath=function(t,i,o){this.isPublicMethod=!0;var r={inRange:!1},a=!1;if(t&&t.length>0)for(var n=0;n<t.length&&!r.inRange;n++)this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:t[n].x,y:t[n].y,obj:r}});return!this.disabled&&this.isImageLoaded&&(r.inRange||e.isNullOrUndefined(t))&&(a=!0,this.notify("shape",{prop:"drawPath",onPropertyChange:!1,value:{pointColl:t,strokeWidth:i,strokeColor:o}})),a},r.prototype.drawRectangle=function(t,i,o,r,a,n,s){var l=!1,p=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(p||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(l=!0,this.notify("shape",{prop:"drawRectangle",onPropertyChange:!1,value:{x:t,y:i,width:o,height:r,strokeWidth:a,strokeColor:n,fillColor:s}})),l},r.prototype.drawText=function(t,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(h||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawText",onPropertyChange:!1,value:{x:t,y:i,text:o,fontFamily:r,fontSize:a,bold:n,italic:s,color:l}})),p},r.prototype.selectShape=function(t){var e={isSelected:!1};return this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:t,obj:e}}),e.isSelected},r.prototype.deleteShape=function(t){this.notify("shape",{prop:"deleteShape",onPropertyChange:!1,value:{id:t}})},r.prototype.getShapeSetting=function(t){var e={};return this.notify("shape",{prop:"getShapeSetting",onPropertyChange:!1,value:{id:t,obj:e}}),e},r.prototype.getShapeSettings=function(){var t={shapeDetailsColl:[]};return this.notify("shape",{prop:"getShapeSettings",onPropertyChange:!1,value:{obj:t}}),t.shapeDetailsColl},r.prototype.update=function(){this.notify("transform",{prop:"update"})},r.prototype.finetuneImage=function(t,e){!this.disabled&&this.isImageLoaded&&this.notify("filter",{prop:"finetuneImage",value:{value:e,option:t}})},r.prototype.applyImageFilter=function(t){!this.disabled&&this.isImageLoaded&&(this.notify("filter",{prop:"applyImageFilter",value:{option:t.toString()}}),this.canvasFilter=this.lowerContext.filter,this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))},r.prototype.undo=function(){this.notify("undo-redo",{prop:"undo",onPropertyChange:!1})},r.prototype.redo=function(){this.notify("undo-redo",{prop:"redo",onPropertyChange:!1})},r.prototype.getImageDimension=function(){return{x:this.img.destLeft,y:this.img.destTop,width:this.img.destWidth,height:this.img.destHeight}},r.prototype.toolbarTemplateFn=function(){var t,e=this.element.id+"_toolbar",i=this.element.querySelector("#"+this.element.id+"_toolbarArea");if(this.toolbarTemplate){if(this.toolbarFn=this.templateParser(this.toolbarTemplate),this.isReact)t=this.toolbarFn({type:"toolbar"},this,"Template",e)[0];else if(this.isAngular){var o=this.toolbarFn({type:"toolbar"},this,"Template",e);t=3===o[0].nodeType?o[1]:o[0]}else t=this.toolbarFn({type:"toolbar"},this,"Template",e)[0];i.appendChild(t),this.toolbarHeight=i.clientHeight,this.notify("toolbar",{prop:"setToolbarHeight",value:{height:this.toolbarHeight}}),this.renderReactTemplates()}},r.prototype.quickAccessToolbarTemplateFn=function(){var t,e=this.element.id+"_quickAccessToolbar",i=this.element.querySelector("#"+this.element.id+"_quickAccessToolbarArea");if(this.quickAccessToolbarTemplate){if(this.qatFn=this.templateParser(this.quickAccessToolbarTemplate),this.isReact)t=this.qatFn({type:"toolbar"},this,"Template",e)[0];else if(this.isAngular){var o=this.qatFn({type:"toolbar"},this,"Template",e);t=3===o[0].nodeType?o[1]:o[0]}else t=this.qatFn({type:"toolbar"},this,"Template",e)[0];i.appendChild(t),this.renderReactTemplates()}},r.prototype.templateParser=function(t){if(t)try{return"function"!=typeof t&&document.querySelectorAll(t).length?e.compile(document.querySelector(t).innerHTML.trim()):e.compile(t)}catch(i){return e.compile(t)}},r.prototype.getTextFromId=function(t){return{1:"none",2:"bar",3:"arrow",4:"arrowSolid",5:"circle",6:"circleSolid",7:"square",8:"squareSolid"}[""+t]},r.prototype.getFinetuneOption=function(e){return{brightness:t.ImageFinetuneOption.Brightness,contrast:t.ImageFinetuneOption.Contrast,hue:t.ImageFinetuneOption.Hue,saturation:t.ImageFinetuneOption.Saturation,opacity:t.ImageFinetuneOption.Opacity,blur:t.ImageFinetuneOption.Blur,exposure:t.ImageFinetuneOption.Exposure}[""+e]},r.prototype.setPenStroke=function(t){this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:parseInt(t,10)}})},r.prototype.updateFreehandDrawColorChange=function(){var t={tempFreeHandDrawEditingStyles:null};this.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:t}}),this.notify("freehand-draw",{prop:"color-change",value:{color:t.tempFreeHandDrawEditingStyles.strokeColor}})},r.prototype.setInitialZoomState=function(){this.objColl.push(this.activeObj),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1});var t=this.isUndoRedo;this.isCropTab=!1,this.isUndoRedo=!0,this.transform.cropZoomFactor&&this.transform.cropZoomFactor>0?this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.cropZoomFactor,zoomPoint:null}}):this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(this.transform.cropZoomFactor),zoomPoint:null}}),this.isUndoRedo=t,this.panPoint.totalPannedPoint={x:0,y:0},this.transform.cropZoomFactor=0,this.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.activeObj=e.extend({},this.objColl[this.objColl.length-1],{},!0),this.objColl.pop(),this.isCropTab=!0,this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})},r.prototype.updateCropTransformItems=function(){this.prevCurrSelectionPoint=e.extend({},this.currSelectionPoint,{},!0);var t={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:t}});var i=t.currObj;i.objColl=e.extend([],this.objColl,[],!0),i.pointColl=e.extend([],this.pointColl,[],!0),i.afterCropActions=e.extend([],this.afterCropActions,[],!0);var o={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),i.selPointColl=e.extend([],o.selPointColl,[],!0),this.cancelCropSelection={operation:"cropTransform",previousObj:i,currentObj:i,previousObjColl:i.objColl,currentObjColl:i.objColl,previousPointColl:i.pointColl,currentPointColl:i.pointColl,previousSelPointColl:i.selPointColl,currentSelPointColl:i.selPointColl,previousCropObj:e.extend({},this.cropObj,{},!0),currentCropObj:e.extend({},this.cropObj,{},!0),previousText:null,currentText:null,filter:null,isCircleCrop:this.isCircleCrop}},r.prototype.toPascalCase=function(t,i){var o=[];e.isNullOrUndefined(t)||(o=t.toLowerCase().split("-"));for(var r=0;r<o.length;r++)o[r]=o[r].charAt(0).toUpperCase()+o[r].slice(1);return i&&(i.maxText=o.join("")),o.join("")},r.prototype.getFontSizes=function(){var t=[];this.fontSizeColl=[];var e;e=0===this.transform.degree||this.transform.degree%180==0?this.img.destWidth/25:this.img.destHeight/25;for(var i=1;i<=10;i++)this.fontSizeColl.push({text:(i*Math.round(e/2)).toString()}),t.push({text:i.toString()});return t},r.prototype.okBtn=function(t){var i,o=!1;void 0!==this.activeObj.shape&&(i=this.activeObj.shape.split("-")),void 0===i&&this.currObjType.isCustomCrop?o=!0:void 0!==i&&"crop"===i[0]&&(o=!0);var r=this.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected"),a={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),r&&(this.currentFilter=r.children[0].children[0].id.replace("Canvas","")),o)this.crop();else if(this.togglePen)this.freeHandDraw(!1),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if("block"===this.textArea.style.display)this.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e.isNullOrUndefined(t)&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if(!e.isBlazor()&&document.querySelector("#"+this.element.id+"_sliderWrapper")||e.isBlazor()&&!this.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||this.currObjType.isFiltered){this.initialAdjustmentValue=this.canvasFilter=this.lowerContext.filter,this.currObjType.isFiltered=!1;var n={value:null};this.notify("draw",{prop:"getTempAdjustmentValue",value:{obj:n}}),n.value!==this.lowerContext.filter&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}else a.bool?(this.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}}),e.isBlazor()?this.updateToolbar(this.element,"destroyQuickAccessToolbar"):this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})):(0!==this.activeObj.activePoint.width&&0!==this.activeObj.activePoint.height||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)&&this.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:t}});e.isBlazor()||a.isCropToolbar||this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}}),this.notify("draw",{prop:"setNewPath",value:{bool:!1}}),this.isCropTab=!1,this.transform.zoomFactor=this.transform.defaultZoomFactor,this.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}})},r.prototype.setTempFilterProperties=function(){this.upperCanvas.style.display="block",this.cropSelectedState();var t={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:t}}),this.lowerContext.filter=this.initialAdjustmentValue,this.notify("draw",{prop:"setTempAdjustmentValue",value:{tempAdjustmentValue:this.lowerContext.filter}}),this.notify("filter",{prop:"setTempAdjustmentLevel",onPropertyChange:!1,value:{tempAdjustmentLevel:e.extend({},t.adjustmentLevel,{},!0)}}),this.notify("draw",{prop:"setTempFilter",value:{tempFilter:this.currentFilter}});var i={undoRedoStep:null};this.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}}),this.notify("draw",{prop:"setTempUndoRedoStep",value:{tempUndoRedoStep:i.undoRedoStep}})},r.prototype.cropSelectedState=function(){this.activeObj.shape&&"crop"===this.activeObj.shape.split("-")[0]&&this.okBtn()},r.prototype.getCurrentCanvasData=function(){var t=this.lowerContext.filter;this.lowerContext.filter=this.canvasFilter="none";var i=e.extend([],this.objColl,null,!0),o=e.extend([],this.pointColl,null,!0);this.objColl=[],this.pointColl=[],this.freehandCounter=0,this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}});var r=this.getImageData();return e.isBlazor()||(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!1}}),this.element.querySelector("#"+this.element.id+"_contextualToolbarArea").classList.remove("e-hide")),this.objColl=i,this.pointColl=o,this.freehandCounter=o.length,this.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=this.canvasFilter=t,r},r.prototype.setCurrAdjustmentValue=function(t,i){var o=this,r={finetune:this.getFinetuneOption(t),value:i,cancel:!1};if(e.isBlazor()&&this.events&&!0===this.events.finetuneValueChanging.hasDelegate)this.dotNetRef.invokeMethodAsync("OnFinetuneValueChangeAsync",r).then(function(e){e.cancel||o.notify("filter",{prop:"setCurrAdjValue",value:{type:t.toLowerCase(),value:i}})});else{if(this.trigger("finetuneValueChanging",r),r.cancel)return;this.notify("filter",{prop:"setCurrAdjValue",value:{type:t.toLowerCase(),value:i}})}},r.prototype.getSquarePointForPath=function(t){var e={startX:0,startY:0,endX:0,endY:0,width:0,height:0};if(t.pointColl.length>0){e={startX:t.pointColl[0].x,startY:t.pointColl[0].y,endX:t.pointColl[0].x,endY:t.pointColl[0].y};for(var i=1;i<t.pointColl.length;i++)t.pointColl[i].x<e.startX&&(e.startX=t.pointColl[i].x),t.pointColl[i].y<e.startY&&(e.startY=t.pointColl[i].y),t.pointColl[i].x>e.endX&&(e.endX=t.pointColl[i].x),t.pointColl[i].y>e.endY&&(e.endY=t.pointColl[i].y);e.width=e.endX-e.startX,e.height=e.endY-e.startY}return e},r.prototype.getSelectionType=function(t){return{CropCustom:"Custom",CropSquare:"Square",CropCircle:"Circle","Crop3:2":"3:2","Crop4:3":"4:3","Crop5:4":"5:4","Crop7:5":"7:5","Crop16:9":"16:9"}[""+t]},r.prototype.clearContext=function(t){t.clearRect(0,0,t.canvas.width,t.canvas.height),t.clearRect(0,0,t.canvas.height,t.canvas.width)},r.prototype.updateArrow=function(t,i){this.notify("shape",{prop:"pushActItemIntoObj"});var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0),this.objColl.pop(),"startArrow"===t?this.activeObj.start=this.getTextFromId(i):"endArrow"===t&&(this.activeObj.end=this.getTextFromId(i)),this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}),e.isBlazor()||(e.Browser.isDevice?document.getElementById(this.element.id+"_bottomToolbar")&&e.getComponent(this.element.id+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(this.element.id+"_toolbar")&&e.getComponent(this.element.id+"_toolbar","toolbar").refreshOverflow())},r.prototype.updateFontFamily=function(t){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend([],this.objColl,[],!0),o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var s=this.activeObj.textSettings.fontFamily;this.activeObj.textSettings.fontFamily=this.toPascalCase(t),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);var l=this.activeObj.activePoint.width+.25*this.activeObj.textSettings.fontSize;this.textArea.style.width=l+"px",this.textArea.style.fontFamily=this.toPascalCase(t),this.activeObj.textSettings.fontFamily=s,this.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}})}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var p=this.activeObj.textSettings.fontFamily=this.toPascalCase(t);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:p,fontSize:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:a,previousObjColl:i,previousPointColl:e.extend([],this.pointColl,[],!0),previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}},r.prototype.updateFontSize=function(t){var i=t;this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var s=this.activeObj.textSettings.fontSize;this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop();var l="";"bold"===this.textArea.style.fontWeight&&(l="bold "),"italic"===this.textArea.style.fontStyle&&(l="italic "),"bold"===this.textArea.style.fontWeight&&"italic"===this.textArea.style.fontStyle&&(l="italic bold "),this.upperContext.font=l+this.activeObj.textSettings.fontSize+"px "+this.textArea.style.fontFamily;var p=this.textArea.value.split("\n"),h={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:!0,text:null,obj:h}});var c=h.maxText,d=this.upperContext.measureText(c).width+.5*this.activeObj.textSettings.fontSize;this.textArea.style.width=d+"px",this.textArea.style.height=p.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize)+"px",this.activeObj.textSettings.fontSize=s,this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily,this.textArea.style.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10)+"px","georgia"===this.textArea.style.fontFamily&&(this.textArea.style.width=parseFloat(this.textArea.style.width)+parseFloat(this.textArea.style.fontSize)+"px")}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var v=this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:null,fontSize:v}}),this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily;var p=this.activeObj.keyHistory.split("\n"),h={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:null,text:null,obj:h}});var u=h.maxText,d=this.upperContext.measureText(u).width+.5*this.activeObj.textSettings.fontSize,g=p.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize);this.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:d,height:g}}),this.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:this.activeObj.activePoint,obj:this.activeObj,isMouseMove:null,x:null,y:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}},r.prototype.updateFontColor=function(t){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),"none"===this.textArea.style.display)this.activeObj.strokeSettings.strokeColor=t,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));else if("block"===this.textArea.style.display){this.textArea.style.color=t;var n=this.activeObj.strokeSettings.strokeColor;this.activeObj.strokeSettings.strokeColor=t,this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=n}else this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},r.prototype.updatePenStrokeWidth=function(t){var i=e.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.pointColl=i,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.setPenStroke(t);var s={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool){var l={penStrokeWidth:null};this.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:l}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:l.penStrokeWidth}});var p={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:p}}),this.pointColl[p.freehandSelectedIndex].strokeWidth=l.penStrokeWidth,this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}},r.prototype.updatePenStrokeColor=function(t){var i=e.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.pointColl=i,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.activeObj.strokeSettings.strokeColor=t;var s={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool){var l={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:l}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.pointColl[l.freehandSelectedIndex].strokeColor=t,this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:t}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else this.togglePen||this.notify("selection",{prop:"redrawShape",value:{obj:this.activeObj}})},r.prototype.updateStrokeWidth=function(t){this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeWidth=parseInt(t,10),this.activeObj.strokeSettings.strokeWidth*=2,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})},r.prototype.updateStrokeColor=function(t){this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=t,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},r.prototype.updateFillColor=function(t){this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.fillColor=t,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:this.activeObj.strokeSettings.fillColor,strokeWidth:null}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})},r.prototype.pascalToSplitWords=function(t){var i=(t=t.charAt(0).toUpperCase()+t.slice(1)).match(/[A-Z][a-z]+/g);return e.isNullOrUndefined(i)?t:i.map(function(t){return t.charAt(0).toUpperCase()+t.slice(1)}).join(" ")},r.prototype.getCurrAdjustmentValue=function(t){var e={adjustmentLevel:null};return this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:e}}),{brightness:e.adjustmentLevel.brightness,contrast:e.adjustmentLevel.contrast,hue:e.adjustmentLevel.hue,saturation:e.adjustmentLevel.saturation,opacity:e.adjustmentLevel.opacity,blur:e.adjustmentLevel.blur,exposure:e.adjustmentLevel.exposure}[""+t]},r.prototype.transformSelect=function(t){this.isCropToolbar=!0,this.setInitialZoomState();var i=e.extend({},this.activeObj,{},!0);this.cropSelectedState(),this.notify("draw",{prop:"resetCurrentSelectionPoint"}),this.notify("transform",{prop:"performTransformation",value:{text:t}}),this.notify("draw",{prop:"moveToSelectionRange",value:{type:t,activeObj:i}}),this.isCropToolbar=!1},r.prototype.getDefaultFilter=function(){return"brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},r.prototype.initializeImageEditor=function(t,o){this.element=t;var r=this.element.querySelector(".e-canvas-wrapper");this.element.querySelector("#"+this.element.id+"_toolbar")?this.toolbarHeight=this.element.querySelector("#"+this.element.id+"_toolbar").clientHeight:this.toolbarHeight=0,r.style.height=this.element.offsetHeight-this.toolbarHeight-2+"px",r.style.width=this.element.offsetWidth-2+"px",this.lowerCanvas=this.element.querySelector(".e-lower-canvas"),this.upperCanvas=this.element.querySelector(".e-upper-canvas"),this.lowerCanvas.id=this.element.id+"_lowerCanvas",this.upperCanvas.id=this.element.id+"_upperCanvas",this.textArea=this.element.querySelector(".e-textbox"),this.inMemoryCanvas=this.createElement("canvas",{id:this.element.id+"_inMemoryCanvas",attrs:{name:"canvasImage"}}),this.upperCanvas.width=this.lowerCanvas.width=this.inMemoryCanvas.width=this.element.offsetWidth,this.upperCanvas.height=this.lowerCanvas.height=this.inMemoryCanvas.height=this.element.offsetHeight-this.toolbarHeight,this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.lowerContext=this.lowerCanvas.getContext("2d"),this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),o&&(this.dotNetRef=o),this.prerender(),this.wireEvent(),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.canvasFilter=this.initialAdjustmentValue=this.lowerContext.filter,this.cssClass&&e.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},r.prototype.prerender=function(){this.element.id=this.element.id||e.getUniqueID("ej2-image-editor"),e.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},r.prototype.initializeZoomSettings=function(){e.isNullOrUndefined(this.zoomSettings.zoomTrigger)&&(this.zoomSettings.zoomTrigger=t.ZoomTrigger.MouseWheel|t.ZoomTrigger.Pinch|t.ZoomTrigger.Toolbar|t.ZoomTrigger.Commands),e.isNullOrUndefined(this.selectionSettings.strokeColor)&&(this.selectionSettings.strokeColor=this.themeColl[this.theme].primaryColor),e.isNullOrUndefined(this.selectionSettings.fillColor)&&(this.selectionSettings.fillColor=this.themeColl[this.theme].secondaryColor)},r.prototype.initializeThemeColl=function(){this.themeColl={Bootstrap5:{primaryColor:"#0d6efd",secondaryColor:"#fff"},Bootstrap5Dark:{primaryColor:"#0d6efd",secondaryColor:"#fff"},Tailwind:{primaryColor:"#4f46e5",secondaryColor:"#fff"},TailwindDark:{primaryColor:"#22d3ee",secondaryColor:"#fff"},Fluent:{primaryColor:"#0078d4",secondaryColor:"#fff"},FluentDark:{primaryColor:"#0078d4",secondaryColor:"#fff"},Bootstrap4:{primaryColor:"#007bff",secondaryColor:"#fff"},Bootstrap:{primaryColor:"#317ab9",secondaryColor:"#fff"},BootstrapDark:{primaryColor:"#317ab9",secondaryColor:"#fff"},Material:{primaryColor:"#e3165b",secondaryColor:"#fff"},MaterialDark:{primaryColor:"#00b0ff",secondaryColor:"#fff"},Fabric:{primaryColor:"#0078d6",secondaryColor:"#fff"},FabricDark:{primaryColor:"#0074cc",secondaryColor:"#fff"},Highcontrast:{primaryColor:"#000000",secondaryColor:"#fff"},Material3:{primaryColor:"#6750a4",secondaryColor:"#fff"},Material3Dark:{primaryColor:"#d0bcff",secondaryColor:"#fff"}}},r.prototype.updateToolbar=function(t,e,i){};var a;return b([e.Property("")],r.prototype,"cssClass",void 0),b([e.Property(!1)],r.prototype,"disabled",void 0),b([e.Property("100%")],r.prototype,"height",void 0),b([e.Property("Bootstrap5")],r.prototype,"theme",void 0),b([e.Property()],r.prototype,"toolbar",void 0),b([e.Property()],r.prototype,"toolbarTemplate",void 0),b([e.Property("100%")],r.prototype,"width",void 0),b([e.Property(!0)],r.prototype,"allowUndoRedo",void 0),b([e.Property(!0)],r.prototype,"showQuickAccessToolbar",void 0),b([e.Property()],r.prototype,"quickAccessToolbarTemplate",void 0),b([e.Property(!1)],r.prototype,"isReadOnly",void 0),b([e.Property(!1)],r.prototype,"enableRtl",void 0),b([e.Property(!1)],r.prototype,"enablePersistence",void 0),b([e.Complex({},C)],r.prototype,"finetuneSettings",void 0),b([e.Complex({},f)],r.prototype,"zoomSettings",void 0),b([e.Complex({},m)],r.prototype,"selectionSettings",void 0),b([e.Event()],r.prototype,"beforeSave",void 0),b([e.Event()],r.prototype,"created",void 0),b([e.Event()],r.prototype,"destroyed",void 0),b([e.Event()],r.prototype,"zooming",void 0),b([e.Event()],r.prototype,"panning",void 0),b([e.Event()],r.prototype,"cropping",void 0),b([e.Event()],r.prototype,"rotating",void 0),b([e.Event()],r.prototype,"flipping",void 0),b([e.Event()],r.prototype,"shapeChanging",void 0),b([e.Event()],r.prototype,"selectionChanging",void 0),b([e.Event()],r.prototype,"fileOpened",void 0),b([e.Event()],r.prototype,"saved",void 0),b([e.Event()],r.prototype,"toolbarCreated",void 0),b([e.Event()],r.prototype,"toolbarUpdating",void 0),b([e.Event()],r.prototype,"toolbarItemClicked",void 0),b([e.Event()],r.prototype,"imageFiltering",void 0),b([e.Event()],r.prototype,"finetuneValueChanging",void 0),b([e.Event()],r.prototype,"click",void 0),b([e.Event()],r.prototype,"quickAccessToolbarOpen",void 0),b([e.Event()],r.prototype,"quickAccessToolbarItemClick",void 0),r=a=b([e.NotifyPropertyChanges],r)}(e.Component);!function(t){t.Png="Png",t.Jpeg="Jpeg",t.Svg="Svg"}(t.FileType||(t.FileType={})),function(t){t.Horizontal="Horizontal",t.Vertical="Vertical"}(t.Direction||(t.Direction={})),function(t){t.Rectangle="Rectangle",t.Ellipse="Ellipse",t.Line="Line",t.Arrow="Arrow",t.Path="Path",t.Text="Text",t.FreehandDraw="FreehandDraw"}(t.ShapeType||(t.ShapeType={})),function(t){t[t.MouseWheel=1]="MouseWheel",t[t.Pinch=2]="Pinch",t[t.Commands=4]="Commands",t[t.Toolbar=8]="Toolbar"}(t.ZoomTrigger||(t.ZoomTrigger={})),function(t){t.Bootstrap5="Bootstrap5",t.Bootstrap5Dark="Bootstrap5Dark",t.Tailwind="Tailwind",t.TailwindDark="TailwindDark",t.Fluent="Fluent",t.FluentDark="FluentDark",t.Bootstrap4="Bootstrap4",t.Bootstrap="Bootstrap",t.BootstrapDark="BootstrapDark",t.Material="Material",t.MaterialDark="MaterialDark",t.Fabric="Fabric",t.FabricDark="FabricDark",t.Highcontrast="Highcontrast"}(t.Theme||(t.Theme={})),function(t){t.Crop="Crop",t.Transform="Transform",t.Annotate="Annotate",t.ZoomIn="ZoomIn",t.ZoomOut="ZoomOut",t.Open="Open",t.Reset="Reset",t.Save="Save",t.Pan="Pan",t.Move="Move",t.Pen="Pen",t.Line="Line",t.Arrow="Arrow",t.Path="Path",t.Rectangle="Rectangle",t.Ellipse="Ellipse",t.Text="Text",t.CustomSelection="CustomSelection",t.CircleSelection="CircleSelection",t.SquareSelection="SquareSelection",t.RatioSelection="RatioSelection",t.RotateLeft="RotateLeft",t.RotateRight="RotateRight",t.FlipHorizontal="FlipHorizontal",t.FlipVertical="FlipVertical"}(t.ImageEditorCommand||(t.ImageEditorCommand={})),function(t){t.Default="Default",t.Chrome="Chrome",t.Cold="Cold",t.Warm="Warm",t.Grayscale="Grayscale",t.Sepia="Sepia",t.Invert="Invert"}(t.ImageFilterOption||(t.ImageFilterOption={})),function(t){t.Brightness="Brightness",t.Contrast="Contrast",t.Hue="Hue",t.Saturation="Saturation",t.Exposure="Exposure",t.Opacity="Opacity",t.Blur="Blur"}(t.ImageFinetuneOption||(t.ImageFinetuneOption={})),function(t){t.None="None",t.Arrow="Arrow",t.SolidArrow="SolidArrow",t.Circle="Circle",t.SolidCircle="SolidCircle",t.Square="Square",t.SolidSquare="SolidSquare",t.Bar="Bar"}(t.ArrowheadType||(t.ArrowheadType={}));var P=function(){function n(t){this.defToolbarItems=[],this.toolbarHeight=46,this.currToolbar="",this.preventZoomBtn=!1,this.currentToolbar="main",this.selFhdColor="#42a5f5",this.preventEnableDisableUr=!1,this.parent=t,this.addEventListener(),this.initLocale()}return n.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},n.prototype.addEventListener=function(){this.parent.on("toolbar",this.toolbar,this),this.parent.on("destroyed",this.destroy,this)},n.prototype.removeEventListener=function(){this.parent.off("toolbar",this.toolbar),this.parent.off("destroyed",this.destroy)},n.prototype.initLocale=function(){this.defaultLocale={Crop:"Crop",ZoomIn:"Zoom In",ZoomOut:"Zoom Out",Undo:"Undo",Redo:"Redo",Transform:"Transform",Annotation:"Annotation",Finetune:"Finetune",Brightness:"Brightness",Contrast:"Contrast",Hue:"Hue",Saturation:"Saturation",Opacity:"Opacity",Blur:"Blur",Sharpen:"Sharpen",Exposure:"Exposure",Filter:"Filter",Default:"Default",Chrome:"Chrome",Cold:"Cold",Warm:"Warm",Grayscale:"Grayscale",BlackAndWhite:"Black and White",Sepia:"Sepia",Invert:"Invert",Text:"Add Text",Pen:"Pen",Reset:"Reset",Save:"Save",Select:"Select",RotateLeft:"Rotate Left",RotateRight:"Rotate Right",HorizontalFlip:"Horizontal Flip",VerticalFlip:"Vertical Flip",OK:"OK",Cancel:"Cancel",FillColor:"Fill Color",StrokeColor:"Stroke Color",StrokeWidth:"Stroke Width",FontFamily:"Font Family",FontStyle:"Font Style",FontSize:"Font Size",FontColor:"Font Color",Pan:"Pan",Move:"Move",Load:"Load",Custom:"Custom",Square:"Square",Circle:"Circle",Ellipse:"Ellipse",Rectangle:"Rectangle",Line:"Line",Arrow:"Arrow",Path:"Path",Bold:"Bold",Italic:"Italic",BoldItalic:"Bold Italic",XSmall:"X-Small",Small:"Small",Medium:"Medium",Large:"Large",XLarge:"X-Large",ABC:"ABC",Browse:"Browse",Duplicate:"Duplicate",Remove:"Remove",EditText:"Edit Text",Start:"Start",End:"End",Bar:"Bar",ArrowSolid:"Arrow Solid",CircleSolid:"Circle Solid",SquareSolid:"Square Solid",None:"None",CropAndTransform:"Crop and Transform",CropSelection:"Crop Selection"},this.l10n=new e.L10n("image-editor",this.defaultLocale,this.parent.locale)},n.prototype.toolbar=function(t){var e=this.parent;switch(this.updatePrivateVariables(),t.prop){case"create-toolbar":this.createToolbar();break;case"create-contextual-toolbar":this.createContextualToolbar();break;case"update-toolbar-items":this.updateToolbarItems();break;case"refresh-toolbar":this.refreshToolbar(t.value.type,t.value.isApplyBtn,t.value.isCropping,t.value.isZooming,t.value.cType);break;case"renderQAT":this.renderQAT(t.value.isPenEdit);break;case"enable-disable-btns":this.enableDisableTbrBtn();break;case"init-main-toolbar":this.initMainToolbar(t.value.isApplyBtn,t.value.isDevice,t.value.isOkBtn);break;case"create-bottom-toolbar":this.createBottomToolbar();break;case"refresh-main-toolbar":this.refreshMainToolbar();break;case"create-qa-toolbar":this.createQuickAccessToolbar();break;case"destroy-qa-toolbar":this.destroyQuickAccessToolbar();break;case"zoom-up-handler":this.zoomBtnMouseUpHandler();break;case"refresh-dropdown-btn":this.refreshDropDownBtn(t.value.isDisabled);break;case"close-contextual-toolbar":this.closeContextualToolbar();break;case"destroy-bottom-toolbar":this.destroyBottomToolbar();break;case"destroy-top-toolbar":this.destroyTopToolbar();break;case"destroySubComponents":this.destroySubComponents();break;case"setLocale":this.l10n.setLocale(t.value.locale);break;case"setPreventZoomBtn":this.preventZoomBtn=t.value.isPrevent;break;case"getToolbarHeight":t.value.obj.toolbarHeight=this.toolbarHeight;break;case"setToolbarHeight":this.toolbarHeight=t.value.height;break;case"setCurrentToolbar":this.currentToolbar=t.value.type;break;case"setSelectedFreehandColor":this.selFhdColor=t.value.color;break;case"getCurrentFilter":t.value.obj.currentFilter=e.currentFilter;break;case"setCurrentFilter":e.currentFilter=t.value.filter;break;case"setInitialAdjustmentValue":e.initialAdjustmentValue=t.value.value;break;case"getCanvasFilter":t.value.obj.canvasFilter=e.canvasFilter;break;case"setCanvasFilter":e.canvasFilter=t.value.filter;break;case"getDefToolbarItems":t.value.obj.defToolbarItems=this.defToolbarItems;break;case"getPenStroke":this.getPenStroke(t.value.value);break;case"performDefToolbarClickAction":this.performDefTbrClick(t.value.type,t.value.isContextualToolbar,t.value.isDisabledAdjustment,t.value.isDisabledFilter,t.value.isFilterFinetune);break;case"setTempFilterProperties":e.setTempFilterProperties();break;case"refreshSlider":this.refreshSlider();break;case"renderSlider":this.renderSlider(t.value.type);break;case"getCurrAdjustmentValue":e.getCurrAdjustmentValue(t.value.type);break;case"setCurrAdjustmentValue":e.setCurrAdjustmentValue(t.value.type,t.value.value);break;case"refreshShapeDrawing":this.refreshShapeDrawing();break;case"getCropToolbar":t.value.obj.isCropToolbar=e.isCropToolbar;break;case"getPrevCurrSelectionPoint":t.value.obj.prevCurrSelectionPoint=e.prevCurrSelectionPoint;break;case"setPrevCurrSelectionPoint":e.prevCurrSelectionPoint=t.value.point;break;case"updateCropTransformItems":e.updateCropTransformItems();break;case"setEnableDisableUndoRedo":this.preventEnableDisableUr=t.value.isPrevent;break;case"reset":this.reset()}},n.prototype.updatePrivateVariables=function(){var t=this.parent;this.inMemoryCanvas=t.inMemoryCanvas,t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d")),this.inMemoryCanvas&&(this.inMemoryContext=this.inMemoryCanvas.getContext("2d"))},n.prototype.reset=function(){var t=this.parent;this.defToolbarItems=[],this.toolbarHeight=46,t.prevCurrSelectionPoint=null,this.zoomBtnHold=null,this.currToolbar="",this.currentToolbar="main",this.selFhdColor="#42a5f5",t.currentFilter="",this.preventZoomBtn=t.isCropToolbar=this.preventEnableDisableUr=!1,t.initialAdjustmentValue=t.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},n.prototype.destroyTopToolbar=function(){var t=this.parent,i=document.getElementById(t.element.id+"_toolbar");this.isToolbar()&&i&&i.classList.contains("e-control")&&e.getComponent(document.getElementById(t.element.id+"_toolbar"),"toolbar").destroy()},n.prototype.destroyBottomToolbar=function(){var t=this.parent,i=document.getElementById(t.element.id+"_bottomToolbar");i&&i.classList.contains("e-control")&&e.getComponent(document.getElementById(t.element.id+"_bottomToolbar"),"toolbar").destroy()},n.prototype.isToolbar=function(){var t=this.parent;return e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.length>0||!e.isNullOrUndefined(t.toolbarTemplate)},n.prototype.createToolbar=function(){var t=this,i=this.parent;if(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){i.element.appendChild(i.createElement("div",{id:i.element.id+"_toolbarArea",className:"e-toolbar-area"}));var r={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg"})};e.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(r);var n=document.getElementById(i.element.id+"_toolbarArea"),s=i.createElement("div",{id:i.element.id+"_toolbar"});n.appendChild(s);var l=[{cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",selected:function(){i.disabled||(e.Browser.isDevice?(t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(document.getElementById(i.element.id+"_bottomToolbar"),"toolbar").destroy(),t.initMainToolbar(!1,e.Browser.isDevice,null),t.createBottomToolbar()):(t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),t.initMainToolbar(!1,!1,null)))}})}];new o.Toolbar({items:l,width:"100%",created:function(){i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_toolbar"),this.createLeftToolbarControls(),document.getElementById(i.element.id+"_toolbar")&&(this.toolbarHeight=document.getElementById(i.element.id+"_toolbar").clientHeight)}else this.toolbarHeight=0},n.prototype.createContextualToolbar=function(){var t=this.parent;if(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.length>0){t.element.appendChild(t.createElement("div",{id:t.element.id+"_contextualToolbarArea",className:"e-contextual-toolbar-wrapper e-hide",attrs:{style:"position: absolute;"}}));var i=document.getElementById(t.element.id+"_contextualToolbarArea"),o=t.createElement("div",{id:t.element.id+"_contextualToolbar"});i.appendChild(o)}},n.prototype.createBottomToolbar=function(){var t=this.parent;if(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.length>0){if(t.element.appendChild(t.createElement("div",{id:t.element.id+"_bottomToolbarArea",className:"e-bottom-toolbar"})),!t.toolbarTemplate){document.getElementById(t.element.id+"_canvasWrapper").style.height=t.element.offsetHeight-2*this.toolbarHeight-3+"px";var i=document.getElementById(t.element.id+"_bottomToolbarArea"),o=t.createElement("div",{id:t.element.id+"_bottomToolbar"});i.appendChild(o)}this.initBottomToolbar()}},n.prototype.createQuickAccessToolbar=function(){var t=this.parent;if(t.showQuickAccessToolbar){var i={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg"})};e.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(i);var r=document.getElementById(t.element.id+"_quickAccessToolbarArea"),n=t.createElement("div",{id:t.element.id+"_quickAccessToolbar"});r.appendChild(n),new o.Toolbar({clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+t.element.id+"_quickAccessToolbar")}},n.prototype.initMainToolbar=function(t,i,r){var a=this,n=this.parent;if(this.isToolbar()){var s=this.getLeftToolbarItem(r),l=this.getRightToolbarItem(r),p=this.getMainToolbarItem(t),h=this.getZoomToolbarItem();this.defToolbarItems=i?s.concat(l):s.concat(p,l,h),new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i||a.renderAnnotationBtn(),a.wireZoomBtnEvents(),a.renderSaveBtn(),n.trigger("toolbarCreated",{toolbarType:"main"})}}).appendTo("#"+n.element.id+"_toolbar"),this.createLeftToolbarControls(),this.enableDisableTbrBtn(),this.isToolbar()&&document.getElementById(n.element.id+"_toolbar")&&e.getComponent(n.element.id+"_toolbar","toolbar").refreshOverflow()}},n.prototype.initBottomToolbar=function(){var t=this,i=this.parent;if(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){var r=this.getMainToolbarItem();new o.Toolbar({items:r,width:"100%",created:function(){t.renderAnnotationBtn(),t.renderCropBtn(),t.renderTransformBtn(),i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_bottomToolbar"),this.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}},n.prototype.getLeftToolbarItem=function(i){var o=this.parent,r=[];i||(r.push({id:o.element.id+"_upload",cssClass:"e-image-upload",align:"Left",type:"Input",template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg"})}),r.push({visible:!1,cssClass:"e-image-position e-btn e-flat",tooltipText:this.l10n.getConstant("Browse"),align:"Left"})),o.allowUndoRedo&&((e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Undo")>-1)&&r.push({id:o.element.id+"_undo",prefixIcon:"e-icons e-undo",cssClass:"top-icon e-undo",tooltipText:this.l10n.getConstant("Undo"),align:"Left"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Redo")>-1)&&r.push({id:o.element.id+"_redo",prefixIcon:"e-icons e-redo",cssClass:"top-icon e-redo",tooltipText:this.l10n.getConstant("Redo"),align:"Left"})),this.preventZoomBtn||(o.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)!==t.ZoomTrigger.Toolbar||((e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("ZoomOut")>-1)&&r.push({id:o.element.id+"_zoomOut",prefixIcon:"e-icons e-zoom-out",cssClass:"top-icon e-dec-zoom",tooltipText:this.l10n.getConstant("ZoomOut"),align:"Left"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("ZoomIn")>-1)&&r.push({id:o.element.id+"_zoomIn",prefixIcon:"e-icons e-zoom-in",cssClass:"top-icon e-inc-zoom",tooltipText:this.l10n.getConstant("ZoomIn"),align:"Left"}));for(var n=this.processToolbar("left"),s=0,l=n.length;s<l;s++)r.push(n[s]);return r},n.prototype.getRightToolbarItem=function(t){var i=this.parent,o=[];t&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Reset")>-1)&&o.push({id:i.element.id+"_reset",prefixIcon:"e-icons e-btn-reset",cssClass:"top-icon e-img-reset",tooltipText:this.l10n.getConstant("Reset"),align:"Right"}),t||(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Save")>-1)&&o.push({id:i.element.id+"_save",prefixIcon:"e-icons e-btn-save",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Save"),align:"Right",template:'<button id="'+i.element.id+'_saveBtn"></button>'});for(var r=this.processToolbar("right"),a=0,n=r.length;a<n;a++)o.push(r[a]);return o},n.prototype.getMainToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Crop")>-1)&&o.push({id:i.element.id+"_cropTransform",prefixIcon:"e-icons e-crop",cssClass:"top-icon e-crop",tooltipText:this.l10n.getConstant("CropAndTransform"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Annotate")>-1)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Finetune")>-1)&&o.push({id:i.element.id+"_adjustment",prefixIcon:"e-icons e-adjustment",cssClass:"top-icon e-adjustment",tooltipText:this.l10n.getConstant("Finetune"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Filter")>-1)&&o.push({id:i.element.id+"_filter",prefixIcon:"e-icons e-filters",cssClass:"top-icon e-filters",tooltipText:this.l10n.getConstant("Filter"),align:"Center"});for(var r=this.processToolbar("center"),a=0,n=r.length;a<n;a++)o.push(r[a]);return t&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.getZoomToolbarItem=function(){return[]},n.prototype.updateContextualToolbar=function(t,i){var o=this.parent,r=o.element.querySelector("#"+o.element.id+"_toolbarArea"),a=o.element.querySelector("#"+o.element.id+"_contextualToolbarArea");if(a.classList.remove("e-hide"),a.style.left=r.offsetLeft+"px","filter"===t?(document.getElementById(o.element.id+"_toolbar")&&this.defToolbarItems.length>0&&e.getComponent(document.getElementById(o.element.id+"_toolbar"),"toolbar").destroy(),e.Browser.isDevice?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!0,null,null),this.refreshSlider(),this.initFilterToolbarItem()):(document.querySelector("#"+o.element.id+"_contextualToolbar").classList.contains("e-control")&&e.getComponent(document.getElementById(o.element.id+"_contextualToolbar"),"toolbar").destroy(),this.refreshSlider(),this.renderSlider(i)),e.Browser.isDevice){var n=a.offsetHeight,s=o.element.querySelector("#"+o.element.id+"_canvasWrapper").offsetHeight;a.style.top=this.toolbarHeight+s-n+"px"}else a.style.top=this.toolbarHeight+"px"},n.prototype.processToolbar=function(t){var i=this.parent,o=[];if(i.toolbar)for(var r=0,a=i.toolbar.length;r<a;r++)"object"==typeof i.toolbar[r]&&(e.isNullOrUndefined(i.toolbar[r].align)?"left"===t&&o.push(i.toolbar[r]):i.toolbar[r].align.toLowerCase()===t&&o.push(i.toolbar[r]));return o},n.prototype.processSubToolbar=function(t){var e=[];if(t)for(var i=0,o=t.length;i<o;i++)"object"==typeof t[i]&&(t[i].align="Center",e.push(t[i]));return e},n.prototype.wireZoomBtnEvents=function(){var t=document.querySelector("#"+this.parent.element.id+"_zoomIn"),e=document.querySelector("#"+this.parent.element.id+"_zoomOut");t&&(t.addEventListener("mousedown",this.zoomInBtnMouseDownHandler.bind(this)),t.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),t.addEventListener("click",this.zoomInBtnClickHandler.bind(this)),t.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this))),e&&(e.addEventListener("mousedown",this.zoomOutBtnMouseDownHandler.bind(this)),e.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),e.addEventListener("click",this.zoomOutBtnClickHandler.bind(this)),t.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this)))},n.prototype.enableDisableTbrBtn=function(){var t=this.parent;if(!this.preventEnableDisableUr){var e={appliedUndoRedoColl:[]};t.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:e}});var i={undoRedoStep:null};t.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}});var o=document.querySelector("#"+t.element.id+"_undo");o&&0===i.undoRedoStep?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):o&&i.undoRedoStep>0&&(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay"));var r=document.querySelector("#"+t.element.id+"_redo");r&&i.undoRedoStep===e.appliedUndoRedoColl.length?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):r&&0===i.undoRedoStep&&e.appliedUndoRedoColl.length>0?(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")):r&&i.undoRedoStep>0&&(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay"))}var a=document.querySelector("#"+t.element.id+"_zoomIn");a&&t.zoomSettings.zoomFactor>=t.zoomSettings.maxZoomFactor?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):a&&(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay"));var n=document.querySelector("#"+t.element.id+"_zoomOut");n&&t.zoomSettings.zoomFactor<=t.zoomSettings.minZoomFactor?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):n&&(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay"));var s=document.querySelector("#"+t.element.id+"_pan");s&&t.zoomSettings.zoomFactor<=t.zoomSettings.minZoomFactor?s.style.display="none":s&&(s.style.display="block")},n.prototype.createLeftToolbarControls=function(){var t=this.parent;if(void 0!==this.defToolbarItems&&this.defToolbarItems.length>0&&document.getElementById(t.element.id+"_toolbar")){var e=document.getElementById(t.element.id+"_toolbar").querySelector(".e-image-upload");if(e){var i=e.getElementsByTagName("input")[0],o=e.getElementsByTagName("button")[0];o.className="e-tbar-btn e-tbtn-txt top-icon",o.innerHTML="",o.appendChild(t.createElement("span",{className:"e-btn-icon e-icons e-upload-icon e-icon-left"})),i.onchange=this.fileSelect.bind(this,i)}}},n.prototype.fileSelect=function(t,e){this.parent.notify("draw",{prop:"fileSelect",value:{inputElement:t,args:e}})},n.prototype.renderAnnotationBtn=function(t){var i=this,o=this.parent,a=[];(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Pen")>-1)&&a.push({text:this.l10n.getConstant("Pen"),id:"pen",iconCss:"e-icons e-free-pen"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Line")>-1)&&a.push({text:this.l10n.getConstant("Line"),id:"line",iconCss:"e-icons e-line"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Rectangle")>-1)&&a.push({text:this.l10n.getConstant("Rectangle"),id:"rectangle",iconCss:"e-icons e-rectangle"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Ellipse")>-1)&&a.push({text:this.l10n.getConstant("Ellipse"),id:"ellipse",iconCss:"e-icons e-circle"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Arrow")>-1)&&a.push({text:this.l10n.getConstant("Arrow"),id:"arrow",iconCss:"e-icons e-arrow-right-up"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Path")>-1)&&a.push({text:this.l10n.getConstant("Path"),id:"path",iconCss:"e-icons e-critical-path"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Text")>-1)&&a.push({text:this.l10n.getConstant("Text"),id:"text",iconCss:"e-icons e-add-text"});var n={freehandDrawSelectedId:null};o.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:n}});var s=document.querySelector("#"+o.element.id+"_duplicate"),l=document.querySelector("#"+o.element.id+"_remove"),p=document.querySelector("#"+o.element.id+"_editText");0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&(e.isNullOrUndefined(o.activeObj.pointColl)||o.activeObj.pointColl&&0===o.activeObj.pointColl.length)&&e.isNullOrUndefined(n.freehandDrawSelectedId)?(s&&s.classList.add("e-disabled"),l&&l.classList.add("e-disabled"),p&&p.classList.add("e-disabled")):(s&&s.classList.remove("e-disabled"),l&&l.classList.remove("e-disabled"),p&&p.classList.remove("e-disabled"));var h=t?this.getCurrentShapeIcon(o.activeObj.shape):"e-annotation",c=new r.DropDownButton({items:a,iconCss:"e-icons "+h,cssClass:"e-image-popup",open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=c.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px"),o.activeObj.shape?document.getElementById(o.activeObj.shape).classList.add("e-selected"):o.togglePen&&document.getElementById("pen").classList.add("e-selected")},select:function(t){o.okBtn();var e,r=!1;void 0!==o.activeObj.shape&&(e=o.activeObj.shape.split("-")),void 0===e&&o.currObjType.isCustomCrop?r=!0:void 0!==e&&"crop"===e[0]&&(r=!0),o.currObjType.isCustomCrop=!1,(r||o.togglePan)&&(o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),i.refreshToolbar("main"));var a={currentFreehandDrawIndex:null};switch(o.notify("freehand-draw",{prop:"getCurrentFreehandDrawIndex",value:{obj:a}}),c.iconCss="e-icons "+i.getCurrentShapeIcon(t.item.id),t.item.id){case"pen":o.notify("draw",{prop:"setTempFreehandCounter",value:{tempFreehandCounter:o.freehandCounter}}),o.notify("draw",{prop:"setTempCurrentFreehandDrawIndex",value:{tempCurrentFreehandDrawIndex:a.currentFreehandDrawIndex}}),i.currentToolbar="pen",o.freeHandDraw(!0);break;case"text":i.currentToolbar="text",o.notify("shape",{prop:"draw-shape-text"});break;default:i.currentToolbar="shapes",i.setInitialShapeSettings(t),o.notify("selection",{prop:"annotate",value:{shape:t.item.id}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}i.updateToolbarItems()}});c.appendTo("#"+o.element.id+"_annotationBtn")},n.prototype.renderCropBtn=function(){var t=this,i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("CustomSelection")>-1)&&o.push({text:this.l10n.getConstant("Custom"),id:"custom",iconCss:"e-icons e-custom"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("CircleSelection")>-1)&&o.push({text:this.l10n.getConstant("Circle"),id:"circle",iconCss:"e-icons e-circle"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("SquareSelection")>-1)&&o.push({text:this.l10n.getConstant("Square"),id:"square",iconCss:"e-icons e-square"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("RatioSelection")>-1)&&(o.push({text:"3:2",id:"3:2",iconCss:"e-icons e-custom-a"}),o.push({text:"4:3",id:"4:3",iconCss:"e-icons e-custom-b"}),o.push({text:"5:4",id:"5:4",iconCss:"e-icons e-custom-c"}),o.push({text:"7:5",id:"7:5",iconCss:"e-icons e-custom-d"}),o.push({text:"16:9",id:"16:9",iconCss:"e-icons e-custom-e"}));var a,n;i.activeObj.shape?(a=this.getCurrentShapeIcon(i.activeObj.shape),n=i.activeObj.shape):i.currSelectionPoint?(a=this.getCurrentShapeIcon(i.currSelectionPoint.shape),n=i.currSelectionPoint.shape):(a="e-custom",n="custom");var s=new r.DropDownButton({open:function(o){i.togglePan&&t.cancelPan(),e.Browser.isDevice&&(o.element.parentElement.style.top=s.element.getBoundingClientRect().top-o.element.parentElement.offsetHeight+"px"),i.activeObj.shape&&i.activeObj.shape.split("-").length>1&&document.getElementById(i.activeObj.shape.split("-")[1]).classList.add("e-selected"),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},items:o,select:function(e){t.cropSelect(e),s.iconCss="e-icons "+t.getCurrentShapeIcon("crop-"+e.item.id),s.content=i.toPascalCase(e.item.id)},iconCss:"e-icons "+a,cssClass:"e-image-popup",content:i.toPascalCase(n.replace("crop-",""))});s.appendTo("#"+i.element.id+"_cropBtn")},n.prototype.renderTransformBtn=function(){var t=this.parent,i=[];(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("RotateLeft")>-1)&&i.push({text:this.l10n.getConstant("RotateLeft"),id:"rotateleft",iconCss:"e-icons e-anti-clock-wise"}),(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("RotateRight")>-1)&&i.push({text:this.l10n.getConstant("RotateRight"),id:"rotateright",iconCss:"e-icons e-clock-wise"}),(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("FlipHorizontal")>-1)&&i.push({text:this.l10n.getConstant("HorizontalFlip"),id:"horizontalflip",iconCss:"e-icons e-horizontal-flip"}),(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("FlipVertical")>-1)&&i.push({text:this.l10n.getConstant("VerticalFlip"),id:"verticalflip",iconCss:"e-icons e-vertical-flip"});var o=new r.DropDownButton({open:function(t){if(e.Browser.isDevice){var i=t.element.parentElement.offsetHeight;t.element.parentElement.style.display="none",t.element.parentElement.style.top=o.element.getBoundingClientRect().top-i+"px",t.element.parentElement.style.display="block"}},items:i,select:t.transformSelect.bind(this),iconCss:"e-icons e-transform",cssClass:"e-image-popup"});o.appendTo("#"+t.element.id+"_transformBtn")},n.prototype.renderSaveBtn=function(){var t=this.parent,e=[{text:"JPEG",id:"jpeg"},{text:"PNG",id:"png"},{text:"SVG",id:"svg"}];document.getElementById(t.element.id+"_saveBtn")&&new r.DropDownButton({items:e,cssClass:"e-caret-hide e-image-popup",iconCss:"e-icons e-save",select:function(e){t.export(e.item.text)}}).appendTo("#"+t.element.id+"_saveBtn")},n.prototype.getCropTransformToolbarItem=function(){var t=this.parent,i=[];return i.push({id:t.element.id+"_crop",tooltipText:this.l10n.getConstant("CropSelection"),align:"Center",template:'<button id="'+t.element.id+'_cropBtn"></button>'}),i.push({align:"Center",type:"Separator"}),i.push({id:t.element.id+"_rotateLeft",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),i.push({id:t.element.id+"_rotateRight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),i.push({align:"Center",type:"Separator"}),i.push({id:t.element.id+"_horizontalFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),i.push({id:t.element.id+"_verticalFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"}),e.Browser.isDevice||(i.push({id:t.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:t.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},n.prototype.getShapesToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),t.indexOf("fillColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_fillcolor",cssClass:"top-icon e-fill",tooltipText:this.l10n.getConstant("FillColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fillColorBtn"></button>'}),t.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_strokecolor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderColorBtn"></button>'}),t.indexOf("strokeWidth")>-1&&o.push({id:i.element.id+"_strokeWidth",cssClass:"top-icon e-size",tooltipText:"Stroke Width",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderWidthBtn"></button>'}),t.indexOf("start")>-1&&o.push({id:i.element.id+"_start",cssClass:"top-icon e-size",tooltipText:"Start",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_startBtn"></button>'}),t.indexOf("end")>-1&&o.push({id:i.element.id+"_end",cssClass:"top-icon e-size",tooltipText:"End",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_endBtn"></button>'}),o.push({align:"Center",type:"Separator"}),t.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),t.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"}),t.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center"});for(var r=this.processSubToolbar(t),a=0,n=r.length;a<n;a++)o.push(r[a]);if(!e.Browser.isDevice){var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"!==s.shape&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"}))}return o},n.prototype.initCropTransformToolbar=function(){var t=this,i=this.parent,r=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),n=this.getCropTransformToolbarItem(),s=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=r.concat(s,n,a);var l=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.renderCropBtn(),t.wireZoomBtnEvents(),e.Browser.isDevice||t.renderSaveBtn(),i.trigger("toolbarCreated",{toolbarType:"shapes"}),e.Browser.isDevice?t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&(l.refreshOverflow(),l.refreshOverflow(),l.refreshOverflow()):(t.createLeftToolbarControls(),t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow()),i.select("custom")}});e.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.getCurrentShapeIcon=function(t){var e="";switch(t){case"rectangle":e="e-rectangle";break;case"ellipse":e="e-circle";break;case"line":e="e-line";break;case"arrow":e="e-arrow-right-up";break;case"path":e="e-critical-path";break;case"text":e="e-add-text";break;case"pen":e="e-free-pen";break;case"crop-custom":e="e-custom";break;case"crop-circle":e="e-circle";break;case"crop-square":e="e-square";break;case"crop-3:2":e="e-custom-a";break;case"crop-4:3":e="e-custom-b";break;case"crop-5:4":e="e-custom-c";break;case"crop-7:5":e="e-custom-d";break;case"crop-16:9":e="e-custom-e";break;default:e="e-free-pen"}return e},n.prototype.initShapesToolbarItem=function(t){var i=this,r=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getShapesToolbarItem(t),l=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createShapeColor(t),i.createShapeBtn(t),"arrow"===r.activeObj.shape&&(i.createStartBtn(),i.createEndBtn()),i.wireZoomBtnEvents(),e.Browser.isDevice||i.renderSaveBtn(),r.trigger("toolbarCreated",{toolbarType:"shapes"}),e.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&p.refreshOverflow())}});e.Browser.isDevice?p.appendTo("#"+r.element.id+"_bottomToolbar"):p.appendTo("#"+r.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createShapeColor=function(t){var i=this.parent;if(t.indexOf("fillColor")>-1){i.element.querySelector(".e-template.e-fill").appendChild(i.createElement("input",{id:i.element.id+"_shape_fill"}));var o=new a.ColorPicker({modeSwitcher:!1,noColor:!0,value:"",showButtons:!1,mode:"Palette",cssClass:"e-shape-fill-color",change:function(t){i.updateFillColor(t.currentValue.hex),""===t.currentValue.rgba?n.element.children[0].classList.add("e-nocolor-item"):(n.element.children[0].classList.remove("e-nocolor-item"),n.element.children[0].style.backgroundColor=t.currentValue.rgba),n.toggle()}},"#"+i.element.id+"_shape_fill"),n=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fillColorBtn");o.inline=!0,i.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item")}if(t.indexOf("strokeColor")>-1){i.element.querySelector(".e-template.e-stroke").appendChild(i.createElement("input",{id:i.element.id+"_shape_stroke"}));var s=new a.ColorPicker({modeSwitcher:!1,noColor:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-shape-stroke-color",change:function(t){i.updateStrokeColor(t.currentValue.hex),l.element.children[0].style.backgroundColor=t.currentValue.rgba,l.toggle()}},"#"+i.element.id+"_shape_stroke"),l=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=l.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-stroke-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_borderColorBtn");s.inline=!0,i.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createShapeBtn=function(t){var i=this.parent,o=[{id:"1",text:this.l10n.getConstant("XSmall")},{id:"2",text:this.l10n.getConstant("Small")},{id:"3",text:this.l10n.getConstant("Medium")},{id:"4",text:this.l10n.getConstant("Large")},{id:"5",text:this.l10n.getConstant("XLarge")}];if(t.indexOf("strokeWidth")>-1){var a=document.getElementById(i.element.id+"_borderWidthBtn"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant("XSmall"),n.className="e-shape-stroke-width",a.appendChild(n);var s=new r.DropDownButton({items:o,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=s.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=n.innerHTML;""!==i&&t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){n.textContent=t.item.text,i.updateStrokeWidth(t.item.id),e.Browser.isDevice?document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i.element.id+"_toolbar")&&e.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}});s.appendTo("#"+i.element.id+"_borderWidthBtn")}},n.prototype.createStartBtn=function(){var t=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(t.element.id+"_startBtn"),a=document.createElement("span");e.isNullOrUndefined(t.activeObj.start)&&(t.activeObj.start="none"),a.innerHTML=t.pascalToSplitWords(t.activeObj.start),a.className="e-shape-start",o.appendChild(a);var n=new r.DropDownButton({items:i,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=a.innerHTML;""!==i&&t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){a.textContent=e.item.text,t.updateArrow("startArrow",e.item.id)}});n.appendTo("#"+t.element.id+"_startBtn")},n.prototype.createEndBtn=function(){var t=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(t.element.id+"_endBtn"),a=document.createElement("span");e.isNullOrUndefined(t.activeObj.end)&&(t.activeObj.end="arrowSolid"),a.innerHTML=t.pascalToSplitWords(t.activeObj.end),a.className="e-shape-end",o.appendChild(a);var n=new r.DropDownButton({items:i,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=a.innerHTML;""!==i&&t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){a.textContent=e.item.text,t.updateArrow("endArrow",e.item.id)}});n.appendTo("#"+t.element.id+"_endBtn")},n.prototype.getTextToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),t.indexOf("fontFamily")>-1&&o.push({id:i.element.id+"_fontFamily",cssClass:"top-icon e-img-font-family",tooltipText:this.l10n.getConstant("FontFamily"),align:"Center",template:'<button id="'+i.element.id+'_fontFamilyBtn"></button>'}),t.indexOf("fontSize")>-1&&o.push({id:i.element.id+"_fontSize",cssClass:"top-icon e-img-font-size",tooltipText:this.l10n.getConstant("FontSize"),align:"Center",template:'<button id="'+i.element.id+'_fontSizeBtn"></button>'}),t.indexOf("fontColor")>-1&&o.push({cssClass:"top-icon e-text-font-color",id:i.element.id+"_text_strokecolor",tooltipText:this.l10n.getConstant("FontColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fontColorBtn"></button>'}),t.indexOf("bold")>-1&&o.push({id:i.element.id+"_bold",prefixIcon:"e-icons e-bold",cssClass:"top-icon e-bold",tooltipText:this.l10n.getConstant("Bold"),align:"Center"}),t.indexOf("italic")>-1&&o.push({id:i.element.id+"_italic",prefixIcon:"e-icons e-italic",cssClass:"top-icon e-italic",tooltipText:this.l10n.getConstant("Italic"),align:"Center"}),o.push({align:"Center",type:"Separator"}),t.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),t.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"}),t.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center"});for(var r=this.processSubToolbar(t),a=0,n=r.length;a<n;a++)o.push(r[a]);return e.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.getFontFamilyItems=function(){return e.Browser.isDevice?[{id:"arial",text:"ABC"},{id:"calibri",text:"ABC"},{id:"georgia",text:"ABC"},{id:"roboto",text:"ABC"},{id:"tahoma",text:"ABC"}]:[{id:"arial",text:"Arial"},{id:"calibri",text:"Calibri"},{id:"georgia",text:"Georgia"},{id:"roboto",text:"Roboto"},{id:"tahoma",text:"Tahoma"}]},n.prototype.initTextToolbarItem=function(t){var i=this,r=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getTextToolbarItem(t),l=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createTextColor(t),i.createTextBtn(t),i.wireZoomBtnEvents(),e.Browser.isDevice||i.renderSaveBtn(),r.trigger("toolbarCreated",{toolbarType:"text"}),e.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&p.refreshOverflow())}});e.Browser.isDevice?p.appendTo("#"+r.element.id+"_bottomToolbar"):p.appendTo("#"+r.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createTextColor=function(t){var i=this.parent;if(t.indexOf("fontColor")>-1&&i.element.querySelector(".e-template.e-text-font-color")){i.element.querySelector(".e-template.e-text-font-color").appendChild(i.createElement("input",{id:i.element.id+"_text_font"}));var o=new a.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",change:function(t){i.updateFontColor(t.currentValue.hex),n.element.children[0].style.backgroundColor=t.currentValue.rgba,n.toggle()}},"#"+i.element.id+"_text_font"),n=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fontColorBtn");o.inline=!0,i.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createTextBtn=function(t){var i=this.parent;if(t.indexOf("fontFamily")>-1){var o=document.getElementById(i.element.id+"_fontFamilyBtn"),a=document.createElement("span");e.Browser.isDevice?(a.innerHTML="ABC",a.setAttribute("style","font-family: arial")):a.innerHTML="Arial",a.className="e-text-font-family",o&&o.appendChild(a);var n=new r.DropDownButton({items:this.getFontFamilyItems(),cssClass:"e-font-family",createPopupOnClick:!0,beforeItemRender:function(t){t.element.setAttribute("style","font-family:"+t.element.id)},open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var o;o="block"===i.textArea.style.display?i.textArea.style.fontFamily:i.activeObj.textSettings.fontFamily,t.element.querySelector('[id *= "'+o.toLowerCase()+'"]').classList.add("e-selected-btn")},select:function(t){a.textContent=t.item.text,e.Browser.isDevice&&a.setAttribute("style","font-family:"+t.item.id),i.updateFontFamily(t.item.id)}});n.appendTo("#"+i.element.id+"_fontFamilyBtn")}if(t.indexOf("fontSize")>-1){var s=document.getElementById(i.element.id+"_fontSizeBtn"),l=document.createElement("span"),p=i.getFontSizes();l.innerHTML=p[0].text,l.className="e-text-font-size",s.appendChild(l);var h=new r.DropDownButton({cssClass:"e-font-size",items:p,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=h.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=l.innerHTML;t.element.querySelector('[aria-label *= "'+i+'"]').classList.add("e-selected-btn")},select:function(t){l.textContent=t.item.text,i.updateFontSize(t.item.text)}});h.appendTo("#"+i.element.id+"_fontSizeBtn")}},n.prototype.refreshToolbar=function(t,i,o,r,a){var n=this.parent;if(n.isImageLoaded&&!n.isCropToolbar){var s={toolbarType:t};switch("filter"!==t&&"color"!==t&&(document.getElementById(n.element.id+"_toolbar")&&this.defToolbarItems.length>0&&(e.getComponent(document.getElementById(n.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_toolbar").innerHTML=""),document.getElementById(n.element.id+"_bottomToolbar")&&this.defToolbarItems.length>0&&document.getElementById(n.element.id+"_bottomToolbar").className.indexOf("e-control")>-1&&(e.getComponent(document.getElementById(n.element.id+"_bottomToolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_bottomToolbar").innerHTML="")),this.refreshSlider(),n.isCropTab=!1,t){case"main":e.Browser.isDevice?o?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!1,!0,null):e.Browser.isDevice&&!r||this.initMainToolbar(i,e.Browser.isDevice,null),e.Browser.isDevice&&this.initBottomToolbar();break;case"shapes":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),"line"===n.activeObj.shape||"path"===n.activeObj.shape?s.toolbarItems=["strokeColor","strokeWidth","duplicate","remove"]:"arrow"===n.activeObj.shape?s.toolbarItems=["strokeColor","strokeWidth","start","end","duplicate","remove"]:s.toolbarItems=["fillColor","strokeColor","strokeWidth","duplicate","remove"],n.trigger("toolbarUpdating",s),this.initShapesToolbarItem(s.toolbarItems);break;case"text":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),s.toolbarItems=["fontFamily","fontSize","fontColor","bold","italic","duplicate","remove","text"],n.trigger("toolbarUpdating",s),this.initTextToolbarItem(s.toolbarItems);break;case"pen":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),s.toolbarItems=["strokeColor","strokeWidth","remove"],n.trigger("toolbarUpdating",s),this.initPenToolbarItem(s.toolbarItems);break;case"adjustment":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),this.initAdjustmentToolbarItem();break;case"filter":this.updateContextualToolbar(t);break;case"color":this.updateContextualToolbar(t,a);break;case"croptransform":n.isCropTab=!0,e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),n.updateCropTransformItems(),this.initCropTransformToolbar()}this.currToolbar=t,this.refreshDropDownBtn(o)}},n.prototype.getAdjustmentToolbarItem=function(){var t=[],i=this.parent;(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Brightness")>-1)&&t.push({id:i.element.id+"_brightness",prefixIcon:"e-icons e-brightness",cssClass:"top-icon e-brightness",tooltipText:this.l10n.getConstant("Brightness"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Contrast")>-1)&&t.push({id:i.element.id+"_contrast",prefixIcon:"e-icons e-contrast",cssClass:"top-icon e-contrast",tooltipText:this.l10n.getConstant("Contrast"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Hue")>-1)&&t.push({id:i.element.id+"_hue",prefixIcon:"e-icons e-fade",cssClass:"top-icon e-fade",tooltipText:this.l10n.getConstant("Hue"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Saturation")>-1)&&t.push({id:i.element.id+"_saturation",prefixIcon:"e-icons e-saturation",cssClass:"top-icon e-saturation",tooltipText:this.l10n.getConstant("Saturation"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Exposure")>-1)&&t.push({id:i.element.id+"_exposure",prefixIcon:"e-icons e-grain",cssClass:"top-icon e-grain",tooltipText:this.l10n.getConstant("Exposure"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Opacity")>-1)&&t.push({id:i.element.id+"_opacity",prefixIcon:"e-icons e-opacity",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Opacity"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Blur")>-1)&&t.push({id:i.element.id+"_blur",prefixIcon:"e-icons e-tint",cssClass:"top-icon e-tint",tooltipText:this.l10n.getConstant("Blur"),align:"Center"});for(var o=this.processToolbar("center"),r=0,a=o.length;r<a;r++)t.push(o[r]);return e.Browser.isDevice||(t.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),t.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),t},n.prototype.getFilterToolbarItem=function(){var t=[],i=this.parent;(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Default")>-1)&&t.push({id:i.element.id+"_default",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Default"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_defaultCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Default")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Chrome")>-1)&&t.push({id:i.element.id+"_chrome",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Chrome"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_chromeCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Chrome")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Cold")>-1)&&t.push({id:i.element.id+"_cold",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Cold"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_coldCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Cold")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Warm")>-1)&&t.push({id:i.element.id+"_warm",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Warm"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_warmCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Warm")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Grayscale")>-1)&&t.push({id:i.element.id+"_grayscale",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Grayscale"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_grayscaleCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Grayscale")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Sepia")>-1)&&t.push({id:i.element.id+"_sepia",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Sepia"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_sepiaCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Sepia")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Invert")>-1)&&t.push({id:i.element.id+"_invert",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Invert"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_invertCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Invert")+"</span></div></div>"});for(var o=this.processToolbar("center"),r=0,a=o.length;r<a;r++)t.push(o[r]);return t},n.prototype.getPenToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),t.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_pen_strokecolor",cssClass:"top-icon e-pen-stroke-color",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penColorBtn"></button>'}),t.indexOf("strokeWidth")>-1&&o.push({prefixIcon:"e-icons e-copy",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("StrokeWidth"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penStrokeWidth"></button>'}),o.push({align:"Center",type:"Separator"}),t.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"});for(var r=this.processSubToolbar(t),a=0,n=r.length;a<n;a++)o.push(r[a]);return e.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.initPenToolbarItem=function(t){var i=this,r=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getPenToolbarItem(t),l=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createPenColor(t),i.createPenBtn(t),i.wireZoomBtnEvents(),e.Browser.isDevice||i.renderSaveBtn(),r.trigger("toolbarCreated",{toolbarType:"pen"}),e.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&(p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&p.refreshOverflow())}});e.Browser.isDevice?p.appendTo("#"+r.element.id+"_bottomToolbar"):p.appendTo("#"+r.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createPenColor=function(t){var i=this,o=this.parent;if(t.indexOf("strokeColor")>-1){o.element.querySelector(".e-template.e-pen-stroke-color").appendChild(o.createElement("input",{id:o.element.id+"_pen_stroke"}));var n=new a.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-pen-color",change:function(t){o.updatePenStrokeColor(t.currentValue.hex),i.selFhdColor=t.currentValue.hex,s.element.children[0].style.backgroundColor=t.currentValue.rgba,s.toggle()}},"#"+o.element.id+"_pen_stroke"),s=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=s.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=o.element.offsetLeft+"px")},target:".e-pen-color",iconCss:"e-dropdownbtn-preview"},"#"+o.element.id+"_penColorBtn");n.inline=!0;var l={tempFreeHandDrawEditingStyles:null};o.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:l}});var p={freehandSelectedIndex:null};o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:p}}),!e.isNullOrUndefined(p.freehandSelectedIndex)&&p.freehandSelectedIndex>-1?o.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#42a5f5"===this.selFhdColor?l.tempFreeHandDrawEditingStyles.strokeColor:o.pointColl[p.freehandSelectedIndex].strokeColor:o.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createPenBtn=function(t){var i=this.parent,o=[{id:"1",text:this.l10n.getConstant("XSmall")},{id:"2",text:this.l10n.getConstant("Small")},{id:"3",text:this.l10n.getConstant("Medium")},{id:"4",text:this.l10n.getConstant("Large")},{id:"5",text:this.l10n.getConstant("XLarge")}];if(t.indexOf("strokeWidth")>-1){var a=document.getElementById(i.element.id+"_penStrokeWidth"),n=document.createElement("span"),s={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:s}}),!e.isNullOrUndefined(s.freehandSelectedIndex)&&s.freehandSelectedIndex>-1?n.innerHTML=this.getPenStroke(i.pointColl[s.freehandSelectedIndex].strokeWidth):n.innerHTML=this.l10n.getConstant("Small"),n.className="e-pen-stroke-width",a.appendChild(n);var l=new r.DropDownButton({items:o,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=l.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=n.innerHTML;t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){n.textContent=t.item.text,i.updatePenStrokeWidth(t.item.id),e.Browser.isDevice?document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i.element.id+"_toolbar")&&e.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+i.element.id+"_penStrokeWidth")}},n.prototype.getPenStroke=function(t){var e="",i={1:this.l10n.getConstant("XSmall"),2:this.l10n.getConstant("Small"),3:this.l10n.getConstant("Medium"),4:this.l10n.getConstant("Large"),5:this.l10n.getConstant("XLarge")};return t>=1&&t<=5&&(e=i[t]),e},n.prototype.initAdjustmentToolbarItem=function(){var t=this,i=this.parent,r=this.getLeftToolbarItem(null),a=this.getRightToolbarItem(),n=this.getAdjustmentToolbarItem(),s=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=r.concat(s,n,a);var l=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.wireZoomBtnEvents(),e.Browser.isDevice||t.renderSaveBtn(),e.Browser.isDevice?t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow():(t.createLeftToolbarControls(),t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow())}});e.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.initFilterToolbarItem=function(){var t=this,i=this.parent,r=this.getFilterToolbarItem();document.querySelector("#"+i.element.id+"_contextualToolbar").classList.contains("e-control")&&e.getComponent(document.getElementById(i.element.id+"_contextualToolbar"),"toolbar").destroy();var a=new o.Toolbar({width:"100%",items:r,clicked:this.contextualToolbarClicked.bind(this),created:function(){t.updatePrivateVariables(),t.createCanvasFilter(),""===i.currentFilter&&(i.currentFilter=i.element.id+"_default");var e=document.querySelector("#"+i.element.id+"_headWrapper");e&&(e.style.display="none"),document.getElementById(i.currentFilter+"Canvas").parentElement.parentElement.classList.add("e-selected"),t.enableDisableTbrBtn(),a.refreshOverflow()}});a.appendTo("#"+i.element.id+"_contextualToolbar")},n.prototype.createCanvasFilter=function(){var t=this.parent;i.showSpinner(t.element),t.element.style.opacity="0.5";var e=t.getCurrentCanvasData();this.inMemoryCanvas.width=e.width,this.inMemoryCanvas.height=e.height,this.inMemoryContext.putImageData(e,0,0),this.updateFilterCanvas("_defaultCanvas","default"),this.updateFilterCanvas("_chromeCanvas","chrome"),this.updateFilterCanvas("_coldCanvas","cold"),this.updateFilterCanvas("_warmCanvas","warm"),this.updateFilterCanvas("_grayscaleCanvas","grayscale"),this.updateFilterCanvas("_sepiaCanvas","sepia"),this.updateFilterCanvas("_invertCanvas","invert"),i.hideSpinner(t.element),t.element.style.opacity="1",t.initialAdjustmentValue=this.lowerContext.filter},n.prototype.updateFilterCanvas=function(t,e){var i=this.parent,o=i.element.querySelector("#"+i.element.id+t);if(o){var r=o.getContext("2d");r=o.getContext("2d"),o.style.width="100px",o.style.height="100px",i.notify("filter",{prop:"updateAdj",value:{type:e,value:null,isPreview:!0,ctx:r}}),r.drawImage(this.inMemoryCanvas,0,0,300,150)}},n.prototype.getQuickAccessToolbarItem=function(t){var i=this.parent,o={cancel:!1,toolbarItems:[]},r=[];e.isNullOrUndefined(t)?(r.push("Clone"),r.push("Delete"),"text"===i.activeObj.shape&&r.push("EditText"),o.shape=i.toPascalCase(i.activeObj.shape)):t&&(r.push("Delete"),o.shape="Freehand draw"),o.toolbarItems=e.extend([],r,null,!0),i.trigger("quickAccessToolbarOpen",o);var a=[];if(o.cancel)a=[];else for(var n=0;n<o.toolbarItems.length;n++)switch(o.toolbarItems[n]){case"Clone":a.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Left"});break;case"Delete":a.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Left"});break;case"EditText":a.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Left"});break;default:a.push(o.toolbarItems[n])}return a},n.prototype.renderQAT=function(t){var i=this.parent;if(i.activeObj&&i.showQuickAccessToolbar){var r=document.getElementById(i.element.id+"_quickAccessToolbarArea");r&&(this.destroyQuickAccessToolbar(),r.style.display="block");var a=this.getQuickAccessToolbarItem(t);if(0===a.length)return;if(e.isNullOrUndefined(i.quickAccessToolbarTemplate)&&new o.Toolbar({items:a,clicked:this.quickAccessToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_quickAccessToolbar"),e.isNullOrUndefined(t)){r.style.width="auto",i.activeObj.activePoint.width=Math.abs(i.activeObj.activePoint.width),i.activeObj.activePoint.height=Math.abs(i.activeObj.activePoint.height);var n=i.activeObj.activePoint.startX<i.activeObj.activePoint.endX?i.activeObj.activePoint.startX:i.activeObj.activePoint.endX,s=i.activeObj.activePoint.startY<i.activeObj.activePoint.endY?i.activeObj.activePoint.startY:i.activeObj.activePoint.endY,l=i.activeObj.activePoint.width;if(0!==i.activeObj.rotatedAngle&&"arrow"!==i.activeObj.shape){var p={activePoint:null};i.notify("shape",{prop:"getSquarePointForRotatedShape",onPropertyChange:!1,value:{obj:i.activeObj,object:p}}),n=(v=p.activePoint).startX,s=v.startY,l=v.width}else if("path"===i.activeObj.shape){var h=i.getSquarePointForPath(i.activeObj);n=h.startX,s=h.startY,l=h.width}r.style.left=n+l/2-25*a.length+"px",s-60<i.img.destTop?r.style.top=i.img.destTop+"px":r.style.top=s-60+"px"}else if(t){var c={activePoint:null},d={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:d}}),i.notify("freehand-draw",{prop:"getSqPtFD",value:{idx:d.freehandSelectedIndex,obj:c}});var v=c.activePoint;r.style.width="auto",r.style.left=v.startX+v.width/2-27*a.length+"px",v.startY-60<i.img.destTop?r.style.top=i.img.destTop+"px":r.style.top=v.startY-60+"px"}}},n.prototype.refreshDropDownBtn=function(t){if(!e.isNullOrUndefined(t)){var i=this.parent,o=document.querySelector("#"+i.element.id+"_annotationBtn");o&&(t?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay")),e.getComponent(o,"dropdown-btn").disabled=t);var r=document.querySelector("#"+i.element.id+"_transformBtn");r&&(t?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")),e.getComponent(r,"dropdown-btn").disabled=t);var a=document.querySelector("#"+i.element.id+"_adjustment");a&&(t?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay")),e.getComponent(a,"btn").disabled=t);var n=document.querySelector("#"+i.element.id+"_filter");n&&(t?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay")),e.getComponent(n,"btn").disabled=t)}},n.prototype.cropSelect=function(t){var i=this.parent;i.isCropTab=!0,e.isNullOrUndefined(i.transform.cropZoomFactor)&&(i.transform.cropZoomFactor=i.transform.zoomFactor,i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}})),i.transform.zoomFactor=i.transform.cropZoomFactor;var o=t.item.id;this.currentToolbar="crop",i.currSelectionPoint=null,i.select(o),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.quickAccessToolbarClicked=function(t,i){var o=this.parent,r={x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY};if(t.item){var a=void 0,n=void 0,s=null,l={prevActObj:null},p={tempObj:null};o.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:l}}),o.notify("selection",{prop:"getTempActObj",onPropertyChange:!1,value:{obj:p}}),p.tempObj.activePoint.height=Math.abs(p.tempObj.activePoint.height);var h={isNewPath:null};switch(o.notify("draw",{prop:"getNewPath",value:{obj:h}}),t.item.id.replace(o.element.id+"_","").toLowerCase()){case"duplicate":if(!o.element.querySelector("#"+o.element.id+"_duplicate").classList.contains("e-disabled")){if(h.isNewPath||JSON.stringify(p.tempObj)!==JSON.stringify(o.activeObj)||(s=!0),a=e.extend({},o.activeObj,{},!0),e.isNullOrUndefined(o.activeObj.currIndex)?o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}}):l.prevActObj?(o.activeObj.currIndex=null,a.currIndex=null,o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}})):o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),h.isNewPath&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),n=e.extend([],o.objColl,[],!0),a.activePoint.startX+=10,a.activePoint.startY-=10,a.activePoint.endX+=10,a.activePoint.endY-=10,"path"===a.shape)for(var c=0;c<a.pointColl.length;c++)a.pointColl[c].x+=10,a.pointColl[c].y-=10;o.activeObj=a,"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||o.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:o.activeObj}}),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:n}}),this.renderQAT()}break;case"remove":o.element.querySelector("#"+o.element.id+"_remove").classList.contains("e-disabled")||o.notify("selection",{prop:"deleteItem",onPropertyChange:!1});break;case"edittext":o.element.querySelector("#"+o.element.id+"_editText").classList.contains("e-disabled")||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:e.extend({},o.activeObj,{},!0)}}),o.notify("selection",{prop:"setInitialTextEdit",onPropertyChange:!1,value:{bool:!0}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:e.extend({},o.activeObj,{},!0)}}),0!==o.activeObj.rotatedAngle&&(r.x=o.activeObj.horTopLinePointColl[0].x,r.y=o.activeObj.horTopLinePointColl[0].y),o.notify("shape",{prop:"renderTextArea",onPropertyChange:!1,value:{x:r.x,y:r.y,actObj:o.activeObj}}),e.isNullOrUndefined(o.activeObj.currIndex)?o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}):l.prevActObj&&o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"))}}e.isNullOrUndefined(i)&&o.trigger("quickAccessToolbarItemClick",t)},n.prototype.defToolbarClicked=function(t){var e=this.parent,i=!1,o=!1;if(e.element.querySelector(".e-contextual-toolbar-wrapper")&&(e.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(i=o=!0),e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),t.item){var r=t.item.id.replace(e.element.id+"_","").toLowerCase();if("duplicate"===r||"remove"===r||"edittext"===r)this.quickAccessToolbarClicked(t,!0),e.trigger("toolbarItemClicked",t);else{var a=!1,n=!1,s=document.querySelector("#"+e.element.id+"_adjustment");s&&s.classList.contains("e-disabled")&&(n=!0);var l=document.querySelector("#"+e.element.id+"_filter");l&&l.classList.contains("e-disabled")&&(a=!0),this.enableDisableTbrBtn(),this.performDefTbrClick(r,i,n,a,o),e.trigger("toolbarItemClicked",t)}}},n.prototype.performDefTbrClick=function(t,e,o,r,a){var n,s,l=this.parent,p=l.element.querySelector("#"+l.element.id+"_zoomIn"),h=!1;if(void 0!==l.activeObj.shape&&(s=l.activeObj.shape.split("-")),void 0===s&&l.currObjType.isCustomCrop?h=!0:void 0!==s&&"crop"===s[0]&&(h=!0),!l.disabled)switch(t){case"pan":l.currObjType.isCustomCrop=l.currObjType.isFiltered=!1,l.currObjType.isUndoAction&&l.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}}),h&&(l.currObjType.isCustomCrop=!1,l.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,l.upperCanvas.width,l.upperCanvas.height),this.refreshToolbar("main")),l.togglePan?(this.cancelPan(),l.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!0}}),"pen"===this.currentToolbar&&l.freehandDraw(!0)):((n=l.element.querySelector(".e-img-pan .e-btn"))&&n.classList.add("e-selected-btn"),l.pan(!0),l.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!1}})),p&&l.zoomSettings.zoomFactor>=l.zoomSettings.maxZoomFactor?(p.classList.add("e-disabled"),p.parentElement.classList.add("e-overlay")):p&&(p.classList.remove("e-disabled"),p.parentElement.classList.remove("e-overlay")),this.refreshToolbar("main");break;case"cancel":l.notify("draw",{prop:"performCancel",value:{isContextualToolbar:e}});break;case"ok":l.okBtn(),this.refreshDropDownBtn(!1),this.currentToolbar="main";break;case"crop":l.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"reset":l.reset(),this.currentToolbar="main";break;case"undo":l.notify("undo-redo",{prop:"call-undo"});break;case"redo":l.notify("undo-redo",{prop:"call-redo"});break;case"adjustment":o||(l.currObjType.isFiltered&&l.okBtn(),this.refreshToolbar("adjustment"),l.setTempFilterProperties(),this.openSlider("brightness"));break;case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":this.openSlider(t);break;case"filter":r||(i.showSpinner(l.element),this.refreshToolbar("filter"),l.setTempFilterProperties(),i.hideSpinner(l.element));break;case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":l.currObjType.isFiltered=!0,l.notify("filter",{prop:"applyImageFilter",value:{option:t}});break;case"upload":a&&l.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-hide");break;case"bold":l.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}):l.activeObj.textSettings.bold&&!l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):!l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):l.activeObj.textSettings.bold||l.activeObj.textSettings.italic||l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}),l.element.querySelector("#"+l.element.id+"_bold").classList.contains("e-selected-btn")?l.element.querySelector("#"+l.element.id+"_bold").classList.remove("e-selected-btn"):l.element.querySelector("#"+l.element.id+"_bold").classList.add("e-selected-btn");break;case"italic":l.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}):l.activeObj.textSettings.bold&&!l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):!l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):l.activeObj.textSettings.bold||l.activeObj.textSettings.italic||l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}),l.element.querySelector("#"+l.element.id+"_italic").classList.contains("e-selected-btn")?l.element.querySelector("#"+l.element.id+"_italic").classList.remove("e-selected-btn"):l.element.querySelector("#"+l.element.id+"_italic").classList.add("e-selected-btn");break;case"croptransform":this.refreshToolbar("croptransform");break;case"rotateleft":case"rotateright":case"horizontalflip":case"verticalflip":l.transformSelect(t),l.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"save":if(l.element.querySelector("#"+l.element.id+"_saveBtn").classList.contains("e-hide")){l.element.querySelector("#"+l.element.id+"_saveBtn").classList.remove("e-hide");break}l.okBtn(),l.element.querySelector("#"+l.element.id+"_saveBtn").classList.add("e-hide"),l.element.querySelector("#"+l.element.id+"_saveBtn").click()}},n.prototype.contextualToolbarClicked=function(t){var e=this.parent,i=e.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");i&&i.classList.remove("e-selected");var o=t.item.id.replace(e.element.id,"").split("_")[1],r={filter:e.toPascalCase(o),cancel:!1};e.trigger("imageFiltering",r),r.cancel||(document.getElementById(t.item.id+"Canvas").parentElement.parentElement.classList.add("e-selected"),e.currObjType.isFiltered=!0,e.notify("filter",{prop:"applyImageFilter",value:{option:o.toLowerCase()}}),e.currentFilter=t.item.id,this.enableDisableTbrBtn())},n.prototype.refreshShapeDrawing=function(){var t=this.parent,e={shape:""};t.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:e}}),""!==e.shape&&(t.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.refreshToolbar("main",!1))},n.prototype.zoomInBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)===t.ZoomTrigger.Toolbar){if(this.refreshShapeDrawing(),e.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomIn");e.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}})}},n.prototype.zoomOutBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)===t.ZoomTrigger.Toolbar){if(this.refreshShapeDrawing(),e.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomOut");e.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}})}},n.prototype.zoomInBtnMouseDownHandler=function(t){t.preventDefault(),this.zoomBtnHold=setInterval(this.zoomInBtnClickHandler.bind(this),250)},n.prototype.zoomOutBtnMouseDownHandler=function(t){t.preventDefault(),this.zoomBtnHold=setInterval(this.zoomOutBtnClickHandler.bind(this),250)},n.prototype.zoomBtnMouseUpHandler=function(){clearInterval(this.zoomBtnHold),this.zoomBtnHold=0},n.prototype.closeContextualToolbar=function(){var t=this.parent,e=!1;return(t.element.querySelector("#"+t.element.id+"_contextualToolbar")&&!t.element.querySelector("#"+t.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||t.element.querySelector("#"+t.element.id+"_headWrapper")&&!t.element.querySelector("#"+t.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.okBtn(),this.refreshMainToolbar(),e=!0),e},n.prototype.destroyQuickAccessToolbar=function(){var t=this.parent,i=document.getElementById(t.element.id+"_quickAccessToolbar");i&&i.classList.contains("e-control")&&e.getComponent(i,"toolbar").destroy();var o=document.getElementById(t.element.id+"_quickAccessToolbarArea");o&&(o.style.display="none")},n.prototype.renderSlider=function(t){var i=this.parent,o=document.querySelector("#"+i.element.id+"_contextualToolbarArea"),r=document.querySelector("#"+i.element.id+"_headWrapper"),a=document.querySelector("#"+i.element.id+"_labelWrapper");r?r.style.display="block":a=(r=o.appendChild(i.createElement("div",{id:i.element.id+"_headWrapper",styles:"position: relative"}))).appendChild(i.createElement("label",{id:i.element.id+"_labelWrapper",styles:e.Browser.isDevice?"position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;":"position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;"})),a.textContent=this.l10n.getConstant(i.toPascalCase(t));var n,s,l,p=r.appendChild(i.createElement("div",{id:i.element.id+"_sliderWrapper",styles:"position: absolute"})),h=i.getCurrAdjustmentValue(t);"brightness"===t||"contrast"===t||"saturation"===t||"exposure"===t?(i.finetuneSettings?"brightness"===t&&i.finetuneSettings.brightness?(n=i.finetuneSettings.brightness.min,s=i.finetuneSettings.brightness.max):"contrast"===t&&i.finetuneSettings.contrast?(n=i.finetuneSettings.contrast.min,s=i.finetuneSettings.contrast.max):"saturation"===t&&i.finetuneSettings.saturation?(n=i.finetuneSettings.saturation.min,s=i.finetuneSettings.saturation.max):"exposure"===t&&i.finetuneSettings.exposure?(n=i.finetuneSettings.exposure.min,s=i.finetuneSettings.exposure.max):(n=-100,s=100):(n=-100,s=100),l=this.createSlider(n,s,h,t)):"hue"!==t&&"blur"!==t&&"opacity"!==t||(i.finetuneSettings?"hue"===t&&i.finetuneSettings.hue?(n=i.finetuneSettings.hue.min,s=i.finetuneSettings.hue.max):"blur"===t&&i.finetuneSettings.blur?(n=i.finetuneSettings.blur.min,s=i.finetuneSettings.blur.max):"opacity"===t&&i.finetuneSettings.opacity?(n=i.finetuneSettings.opacity.min,s=i.finetuneSettings.opacity.max):(n=0,s=100):(n=0,s=100),l=this.createSlider(n,s,h,t)),l.appendTo("#"+i.element.id+"_sliderWrapper"),p.style.left=(parseFloat(o.style.width)-parseFloat(l.width))/2+"px"},n.prototype.createSlider=function(t,i,o,r){var n=this,s=this.parent;return new a.Slider({value:o,tooltip:{isVisible:!0,placement:"Before",showOn:"Always"},type:"MinRange",min:t,max:i,step:10,width:e.Browser.isDevice?"200px":"300px",cssClass:"e-slider",change:function(t){s.setCurrAdjustmentValue(r,t.value),n.enableDisableTbrBtn()}})},n.prototype.applyPreviewFilter=function(){var t=this.parent;(document.querySelector("#"+t.element.id+"_sliderWrapper")||t.currObjType.isFiltered)&&(t.initialAdjustmentValue=t.canvasFilter=this.lowerContext.filter,t.currObjType.isFiltered=!1)},n.prototype.unselectBtn=function(){for(var t=this.parent,e=0,i=["#"+t.element.id+"_brightness","#"+t.element.id+"_contrast","#"+t.element.id+"_hue","#"+t.element.id+"_saturation","#"+t.element.id+"_opacity","#"+t.element.id+"_blur","#"+t.element.id+"_exposure"];e<i.length;e++){var o=i[e],r=document.querySelector(o);if(r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},n.prototype.openSlider=function(t){this.unselectBtn(),this.parent.currObjType.isFiltered=!0,this.refreshToolbar("color",null,null,null,t),document.getElementById(this.parent.element.id+"_"+t).classList.add("e-selected-btn")},n.prototype.refreshSlider=function(){var t=document.querySelector("#"+this.parent.element.id+"_sliderWrapper"),e=document.querySelector(".e-slider"),i=document.querySelector("#"+this.parent.element.id+"_headWrapper");i&&(i.style.display="none"),t&&e&&(e.ej2_instances[0].destroy(),t.remove())},n.prototype.updateToolbarItems=function(){var t=this.parent,i=t.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview"),o=t.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview"),r=t.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview"),a=t.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview"),n=t.element.querySelector(".e-shape-stroke-width"),s=t.element.querySelector(".e-text-font-family"),l=t.element.querySelector(".e-text-font-size"),p=t.element.querySelector("#"+t.element.id+"_bold"),h=t.element.querySelector("#"+t.element.id+"_italic");if(e.isNullOrUndefined(t.activeObj.strokeSettings.strokeWidth)&&(t.activeObj.strokeSettings.strokeWidth=2),i&&(""===t.activeObj.strokeSettings.fillColor?i.classList.add("e-nocolor-item"):(i.classList.remove("e-nocolor-item"),i.style.background=t.activeObj.strokeSettings.fillColor),e.getComponent(t.element.id+"_shape_fill","colorpicker").value=t.activeObj.strokeSettings.fillColor+"ff"),o&&(o.style.background=t.activeObj.strokeSettings.strokeColor,e.getComponent(t.element.id+"_shape_stroke","colorpicker").value=t.activeObj.strokeSettings.strokeColor+"ff"),r&&(r.style.background=t.activeObj.strokeSettings.strokeColor,e.getComponent(t.element.id+"_text_font","colorpicker").value=t.activeObj.strokeSettings.strokeColor+"ff"),a&&(a.style.background=t.activeObj.strokeSettings.strokeColor,e.getComponent(t.element.id+"_pen_stroke","colorpicker").value=t.activeObj.strokeSettings.strokeColor+"ff"),s&&(e.Browser.isDevice?s.setAttribute("style","font-family:"+t.activeObj.textSettings.fontFamily.toLowerCase()):s.textContent=t.activeObj.textSettings.fontFamily),l)for(var c=0;c<t.fontSizeColl.length;c++)if(parseInt(t.fontSizeColl[c].text,10)>=Math.round(t.activeObj.textSettings.fontSize)){l.textContent=(c+1).toString();break}if(p&&(t.activeObj.textSettings.bold?p.classList.add("e-selected-btn"):p.classList.remove("e-selected-btn")),h&&(t.activeObj.textSettings.italic?h.classList.add("e-selected-btn"):h.classList.remove("e-selected-btn")),n){var d=Math.round(t.activeObj.strokeSettings.strokeWidth).toString();n.textContent=this.getStrokeWidth(d)}},n.prototype.getStrokeWidth=function(t){var e;switch(parseInt(t,10)/2){case 1:e=this.l10n.getConstant("XSmall");break;case 2:e=this.l10n.getConstant("Small");break;case 3:e=this.l10n.getConstant("Medium");break;case 4:e=this.l10n.getConstant("Large");break;case 5:e=this.l10n.getConstant("XLarge")}return e},n.prototype.cancelPan=function(){var t=this.parent;t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}});var e=t.element.querySelector(".e-img-pan .e-btn");e&&e.classList.remove("e-selected-btn"),t.pan(!1)},n.prototype.refreshMainToolbar=function(){"main"!==this.currToolbar&&this.refreshToolbar("main")},n.prototype.destroySubComponents=function(){for(var t=this.parent,i=t.element.querySelectorAll("input.e-control"),o=t.element.querySelectorAll("button.e-control"),r=0,a=i.length;r<a;r++)i[r].classList.contains("e-color-picker")&&(e.getComponent(i[r],"color-picker").destroy(),e.detach(e.select("input#"+i[r].id,t.element)));for(var r=0,a=o.length;r<a;r++)o[r].classList.contains("e-dropdown-btn")?(e.getComponent(o[r],"dropdown-btn").destroy(),e.detach(e.select("button#"+o[r].id,t.element))):o[r].classList.contains("e-btn")&&(e.getComponent(o[r],"btn").destroy(),e.detach(e.select("button#"+o[r].id,t.element)))},n.prototype.setInitialShapeSettings=function(t){var e=this.parent;e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.currObjType.shape=t.item.id,e.activeObj.shape=e.currObjType.shape.toLowerCase(),e.currObjType.isDragging=e.currObjType.isCustomCrop=!1,e.activeObj.shapeDegree=e.transform.degree,e.activeObj.shapeFlip=e.transform.currFlipState,e.activeObj.textFlip=e.transform.currFlipState,e.activeObj.flipObjColl=[]},n.prototype.getModuleName=function(){return"toolbar-module"},n}();return t.Crop=n,t.Draw=s,t.Export=l,t.Filter=p,t.FreehandDrawing=h,t.Selection=c,t.Shape=d,t.Transform=v,t.UndoRedo=u,t.FinetuneSettings=C,t.ZoomSettings=f,t.SelectionSettings=m,t.ImageEditor=y,t.ToolbarModule=P,t}({},ej.base,ej.popups,ej.navigations,ej.splitbuttons,ej.inputs),this.ejs=ej;
|
|
10
|
+
this.ej=this.ej||{},this.ej.imageeditor=function(t,e,i,o,r,a){"use strict";var n=function(){function t(t){this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1,this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("crop",this.cropping,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("crop",this.crop),this.parent.off("destroyed",this.destroy)},t.prototype.cropping=function(t){switch(this.updateCropPvtVar(),t.prop){case"cropImg":this.cropImg(t.value.isRotateCrop);break;case"cropCircle":this.cropCircle(t.value.context,t.value.isSave,t.value.isFlip);break;case"setCurrSelPoints":this.setCurrSelPoints(t.value.isSetDimension);break;case"updateRotatePan":this.updateRotatePan();break;case"crop":this.crop(t.value.obj);break;case"calcRatio":this.calcRatio(t.value.obj,t.value.dimension);break;case"isObjInImage":this.isObjInImage(t.value.obj,t.value.object);break;case"getCurrFlipState":this.getCurrFlipState(t.value.panObj);break;case"setPreviousCropCurrentObj":this.prevCropCurrObj=t.value.obj;break;case"setCropDestPoints":this.cropDestPoints=t.value.point;break;case"getTempFlipPanPoint":t.value.obj.point=this.tempFlipPanPoint;break;case"setTempFlipPanPoint":e.isNullOrUndefined(t.value.isAdd)?this.tempFlipPanPoint=t.value.point:(this.tempFlipPanPoint.x+=t.value.point.x,this.tempFlipPanPoint.y+=t.value.point.y);break;case"getPreventScaling":t.value.obj.bool=this.isPreventScaling;break;case"reset":this.reset()}},t.prototype.getModuleName=function(){return"crop"},t.prototype.updateCropPvtVar=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d"))},t.prototype.reset=function(){this.prevCropCurrObj=null,this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1},t.prototype.cropImg=function(t){var i=this.parent,o=e.isNullOrUndefined(t),r=i.activeObj.activePoint;if(i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),o&&(this.croppedDegree=i.transform.degree),o&&0!==i.transform.degree){this.updateCropObj();n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:n}}),this.rotateCrop()}else if(o&&""!==i.transform.currFlipState){this.updateCropObj();n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:n}}),this.flipCrop()}else{i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}});var a=this.calcRatio();if(o||!t){this.updateCropObj(),i.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1});var n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:n}}),i.currSelectionPoint=e.extend({},i.activeObj,{},!0),this.cropDestPoints={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight}}var s={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:r.width*a.width,height:r.height*a.height,obj:s}});var l=s;this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.img.srcLeft=r.startX*a.width-i.img.destLeft*a.width,i.img.srcTop=r.startY*a.height-i.img.destTop*a.height,i.img.srcWidth=r.width*a.width,i.img.srcHeight=r.height*a.height,i.img.destLeft=(i.lowerCanvas.clientWidth-l.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-l.height)/2,i.img.destWidth=l.width,i.img.destHeight=l.height;var p=this.lowerContext.filter;i.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,i.img.destLeft,i.img.destTop,i.img.destWidth,i.img.destHeight),this.lowerContext.filter="none";var h=e.extend({},i.activeObj,{},!0);this.cropObjColl(),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}});for(var c=0,d=i.objColl.length;c<d;c++)this.isObjInImage(i.objColl[c])&&(i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:i.objColl[c].shape,obj:i.objColl[c],canvas:null}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}));i.activeObj=h,this.cropFreehandDrawColl(),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),"crop-circle"===i.currSelectionPoint.shape?this.cropCircle(this.lowerContext):i.isCircleCrop=!1,this.lowerContext.filter=p,i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.currObjType.isCustomCrop=!1,i.pan(!1),i.transform.defaultZoomFactor=0}},t.prototype.updateCropObj=function(){this.parent.afterCropActions=[];var t={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:t}});var i=t.currObj;this.parent.cropObj=e.extend({},i,{},!0)},t.prototype.rotateCrop=function(){var t=this.parent,i=t.activeObj.shape||"";t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.currSelectionPoint=e.extend({},t.activeObj,{},!0),t.objColl.push(t.activeObj),t.activeObj=e.extend({},t.objColl[t.objColl.length-1],{},!0);var o=e.extend({},t.objColl[t.objColl.length-1],{},!0),r=e.extend({},t.currSelectionPoint,{},!0),a={bool:null};t.notify("transform",{prop:"getPreventSelect",onPropertyChange:!1,value:{obj:a}}),t.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:!0}});var n=e.extend([],t.rotateFlipColl,[],!0);this.panToSelRangle(!0),this.revertTransform("initial",n),o=e.extend({},t.objColl[t.objColl.length-1],{},!0),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o}}),t.objColl.pop(),t.transform.degree=0,this.cropImg(!0),this.revertTransform("reverse",n),t.currSelectionPoint=r,t.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:a.bool}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),"crop-circle"===i&&this.cropCircle(this.lowerContext),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})},t.prototype.revertTransform=function(t,e){var i=this.parent,o={isRotate:!1};if("initial"===t)for(r=e.length-1;r>=0;r--)switch(e[r]){case 90:i.notify("transform",{prop:"rotate",value:{degree:-90,obj:o}});break;case-90:i.notify("transform",{prop:"rotate",value:{degree:90,obj:o}});break;default:i.notify("transform",{prop:"flipImage",value:{direction:i.toPascalCase(e[r])}})}else{for(var r=0,a=i.objColl.length;r<a;r++)i.objColl[r].shapeFlip="";for(r=0;r<i.freehandCounter;r++)i.pointColl[r].shapeFlip="";for(var r=0,a=e.length;r<a;r++)switch(e[r]){case 90:i.notify("transform",{prop:"rotate",value:{degree:90,obj:o}});break;case-90:i.notify("transform",{prop:"rotate",value:{degree:-90,obj:o}});break;default:i.notify("transform",{prop:"flipImage",value:{direction:i.toPascalCase(e[r])}})}}},t.prototype.flipCrop=function(){var t=this.parent;t.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),t.panPoint.totalPannedPoint.x+=this.tempFlipPanPoint.x,t.panPoint.totalPannedPoint.y+=this.tempFlipPanPoint.y;var i=t.transform.currFlipState,o={flipColl:null};t.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:o}});var r=o.flipColl;if(t.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:[]}}),t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.objColl.push(t.activeObj),t.transform.zoomFactor>0){for(var a=t.transform.zoomFactor,n=t.isUndoRedo,s=0;s<10*a;s++)t.isUndoRedo=!0,t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}});t.isUndoRedo=n,t.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})}t.currSelectionPoint=e.extend({},t.objColl[t.objColl.length-1],{},!0),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height);var l=this.lowerContext.filter;t.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight);for(var s=0,p=t.objColl.length;s<p;s++)t.objColl[s].shapeFlip="";for(s=0;s<t.freehandCounter;s++)t.pointColl[s].shapeFlip="";t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),t.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),t.activeObj=e.extend({},t.objColl[t.objColl.length-1],{},!0),t.objColl.pop(),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.cropImg(!0),t.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),this.lowerContext.setTransform(1,0,0,1,0,0),t.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),t.notify("finetune",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=l,t.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),t.transform.currFlipState=i,t.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:r}}),this.lowerContext.filter="none";for(var s=0,p=t.objColl.length;s<p;s++)t.objColl[s].shapeFlip="";for(s=0;s<t.freehandCounter;s++)t.pointColl[s].shapeFlip="";t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),t.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),t.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=l,(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&this.cropCircle(this.lowerContext),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}}),t.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),this.tempFlipPanPoint={x:0,y:0}},t.prototype.cropObjColl=function(){var t,e,i,o=this.parent;if(o.objColl.length>0)for(var r=0,a=o.objColl.length;r<a;r++){t=o.objColl[r].activePoint,e=o.activeObj.activePoint,i=o.objColl[r].shape,o.objColl[r].imageRatio={startX:(t.startX-e.startX)/e.width,startY:(t.startY-e.startY)/e.height,endX:(t.endX-e.startX)/e.width,endY:(t.endY-e.startY)/e.height,width:e.width/t.width,height:e.height/t.height};var n=void 0,s=void 0;switch(i){case"text":s=0===(n=0===o.objColl[r].shapeDegree?this.parent.transform.degree:this.parent.transform.degree-o.objColl[r].shapeDegree)||180===Math.abs(n)?t.width:t.height,o.objColl[r].textSettings.fontRatio=s/o.objColl[r].textSettings.fontSize;break;case"line":case"arrow":this.cropPointCollection(r),"arrow"===i&&o.notify("shape",{prop:"updateArrowRatio",onPropertyChange:!1,value:{obj:o.objColl[r]}});break;case"path":this.cropPointCollection(r)}}},t.prototype.cropPointCollection=function(t){var e,i,o,r,a=this.parent,n=a.objColl[t].shape,s=a.activeObj.activePoint;"path"===n?(e=s.startX,i=s.startY,o=s.width,r=s.height):(e=a.img.destLeft,i=a.img.destTop,o=a.img.destWidth,r=a.img.destHeight);for(var l=a.objColl[t],p=0,h=l.pointColl.length;p<h;p++)l.pointColl[p].ratioX=(l.pointColl[p].x-e)/o,l.pointColl[p].ratioY=(l.pointColl[p].y-i)/r},t.prototype.cropFreehandDrawColl=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++){t.points=e.extend([],t.pointColl[i].points,[]),t.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var o=t.points.length,r=0;r<o;r++)t.points[r].ratioX=(t.points[r].x-t.activeObj.activePoint.startX)/t.activeObj.activePoint.width,t.points[r].ratioY=(t.points[r].y-t.activeObj.activePoint.startY)/t.activeObj.activePoint.height}t.notify("freehand-draw",{prop:"updateCropPtsForSel",onPropertyChange:!1})},t.prototype.setCurrSelPoints=function(t){var i=this.parent,o=this.cropDestPoints;i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImg.width,i.img.srcHeight=i.baseImg.height,i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),t&&i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),0===this.croppedDegree&&0===i.transform.degree&&i.currSelectionPoint&&"crop-circle"!==i.currSelectionPoint.shape&&"crop-square"!==i.currSelectionPoint.shape&&(i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height),0===i.transform.degree&&(i.img.destLeft+=i.panPoint.totalPannedInternalPoint.x,i.img.destTop+=i.panPoint.totalPannedInternalPoint.y),i.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,i.img.destLeft,i.img.destTop,i.img.destWidth,i.img.destHeight),i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:!0}});var r=e.extend([],i.objColl,null,!0),a=e.extend([],i.pointColl,null,!0);if(i.objColl=[],i.pointColl=[],i.freehandCounter=0,this.panToSelRangle(),i.objColl=r,i.pointColl=a,i.freehandCounter=i.pointColl.length,i.cropObj.activeObj.shape){var n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.currSelectionPoint&&i.currSelectionPoint.activePoint&&(i.img.destLeft=i.currSelectionPoint.activePoint.startX,i.img.destTop=i.currSelectionPoint.activePoint.startY,i.img.destWidth=i.currSelectionPoint.activePoint.width,i.img.destHeight=i.currSelectionPoint.activePoint.height),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=n.startX,i.img.destTop=n.startY,i.img.destWidth=n.width,i.img.destHeight=n.height,i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),r=e.extend([],i.objColl,null,!0),a=e.extend([],i.pointColl,null,!0),i.objColl=[],i.pointColl=[],i.freehandCounter=0;var s={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}});var l=s.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.cropObj.filter=this.lowerContext.filter;var p=e.extend({},i.currSelectionPoint,null,!0);i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:null}}),i.activeObj=e.extend({},p,null,!0);var h=e.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.panToSelRangle(),i.objColl=r,i.pointColl=a,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:l}}}),i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.currSelectionPoint=null,0===i.transform.degree&&i.notify("transform",{prop:"drawPannImage",onPropertyChange:!1,value:{point:{x:0,y:0}}}),i.activeObj=h,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}})}else{var c=this.lowerContext.filter;this.lowerContext.filter="none",i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=c,i.currSelectionPoint=null}},t.prototype.panToSelRangle=function(t){var e=this.parent,i=0===e.transform.degree?t?-e.cropObj.totalPannedPoint.x:e.cropObj.totalPannedPoint.x:t?-e.cropObj.totalPannedClientPoint.x:e.cropObj.totalPannedClientPoint.x,o=0===e.transform.degree?t?-e.cropObj.totalPannedPoint.y:e.cropObj.totalPannedPoint.y:t?-e.cropObj.totalPannedClientPoint.y:e.cropObj.totalPannedClientPoint.y;0===e.transform.degree?(e.img.destLeft+=i,e.img.destTop+=o,e.notify("transform",{prop:"drawPannImage",value:{point:{x:i,y:o}}})):(e.panPoint.currentPannedPoint={x:i,y:o},e.notify("transform",{prop:"drawPannedImage",value:{xDiff:i,yDiff:o}}),e.panPoint.currentPannedPoint={x:0,y:0})},t.prototype.cropCircle=function(t,i,o){var r=this.parent;o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:t,value:r.transform.currFlipState,isReverse:null}}),t.globalCompositeOperation="destination-in",t.beginPath();var a=e.isNullOrUndefined(i)?r.img.destLeft+r.img.destWidth/2:t.canvas.width/2,n=e.isNullOrUndefined(i)?r.img.destTop+r.img.destHeight/2:t.canvas.height/2,s=i?t.canvas.width/2:r.img.destWidth/2;t.arc(a,n,s,0,2*Math.PI),t.closePath(),t.fill(),t.restore(),t.globalCompositeOperation="source-over",r.currObjType.isActiveObj=r.isCircleCrop=!0,o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:t,value:r.transform.currFlipState,isReverse:null}})},t.prototype.getCurrCropState=function(t,e){var i=this.parent,o="",r=[],a={flipColl:null};if(i.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:a}}),"initial"===t)if(180===Math.abs(i.transform.degree))o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState;else{for(var n=0,s=i.rotateFlipColl.length;n<s;n++)"number"==typeof i.rotateFlipColl[n]?r.push("number"):"string"==typeof i.rotateFlipColl[n]&&r.push("string");r.length>1&&"string"===r[r.length-1]&&"number"===r[r.length-2]?"horizontal"===i.transform.currFlipState?o="vertical":"vertical"===i.transform.currFlipState&&(o="horizontal"):r.length>1&&"number"===r[r.length-1]&&"string"===r[r.length-2]&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState)}else o=this.getCurrFlipState(),!e&&this.isInitialRotate()||-90!==i.transform.degree&&-270!==i.transform.degree||("horizontal"===o?o="vertical":"vertical"===o&&(o="horizontal"));return""===o&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState),o},t.prototype.isInitialRotate=function(){var t=!1;return this.parent.rotateFlipColl.length>0&&"number"==typeof this.parent.rotateFlipColl[0]&&(t=!0),t},t.prototype.updateRotatePan=function(){var t=this.parent;if(!e.isNullOrUndefined(t.panPoint.currentPannedPoint)){var i="";i=t.rotateFlipColl.length>0&&"number"==typeof t.rotateFlipColl[0]&&t.transform.degree<0?this.getCurrCropState("reverse",!0):this.getCurrFlipState(),t.transform.degree%90==0&&t.transform.degree%180!=0?90===t.transform.degree||-90===t.transform.degree&&("horizontal"===i||"vertical"===i)||-270===t.transform.degree&&(""===i||"verticalHorizontal"===i||"horizontalVertical"===i)?("horizontal"===i||""===i?t.img.destLeft+=t.panPoint.currentPannedPoint.y:t.img.destLeft-=t.panPoint.currentPannedPoint.y,""===i||"vertical"===i?t.img.destTop-=t.panPoint.currentPannedPoint.x:t.img.destTop+=t.panPoint.currentPannedPoint.x):270!==t.transform.degree&&(-270!==t.transform.degree||"horizontal"!==i&&"vertical"!==i)&&(-90!==t.transform.degree||""!==i&&"verticalHorizontal"!==i&&"horizontalVertical"!==i)||(""===i||"horizontal"===i?t.img.destLeft-=t.panPoint.currentPannedPoint.y:t.img.destLeft+=t.panPoint.currentPannedPoint.y,""===i||"vertical"===i?t.img.destTop+=t.panPoint.currentPannedPoint.x:t.img.destTop-=t.panPoint.currentPannedPoint.x):180!==t.transform.degree&&-180!==t.transform.degree||(""===i||"vertical"===i?t.img.destLeft-=t.panPoint.currentPannedPoint.x:t.img.destLeft+=t.panPoint.currentPannedPoint.x,""===i||"horizontal"===i?t.img.destTop-=t.panPoint.currentPannedPoint.y:t.img.destTop+=t.panPoint.currentPannedPoint.y)}},t.prototype.crop=function(t){var i=this,o=this.parent;if(!o.disabled&&o.isImageLoaded){var r={isCropToolbar:o.isCropToolbar};o.currObjType.isUndoAction&&!r.isCropToolbar&&o.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}});var a={cancel:!1,startPoint:{x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY},endPoint:{x:o.activeObj.activePoint.endX,y:o.activeObj.activePoint.endY},preventScaling:!1};!r.isCropToolbar&&e.isBlazor()&&o.events&&!0===o.events.cropping.hasDelegate?o.dotNetRef.invokeMethodAsync("CropEventAsync","OnCrop",a).then(function(e){i.cropEvent(e,t,r)}):(r.isCropToolbar||o.trigger("cropping",a),this.cropEvent(a,t,r))}},t.prototype.cropEvent=function(t,i,o){var r,a=this.parent;if(!t.cancel&&(r=a.activeObj.shape?a.activeObj.shape.split("-"):[],!a.disabled&&a.activeObj.horTopLine&&(a.currObjType.isCustomCrop||r.length>0&&"crop"===r[0]))){i.isCrop=!0;var n=e.extend({},a.cropObj,{},!0),s=e.extend({},this.prevCropCurrObj,{},!0);t.preventScaling?this.isPreventScaling=!0:this.isPreventScaling=!1,this.cropImg(),a.transform.zoomFactor=0,a.setProperties({zoomSettings:{zoomFactor:1}},!0),a.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:a.zoomSettings.zoomFactor}});var l={prevCurrSelectionPoint:this.parent.prevCurrSelectionPoint};s.currSelectionPoint=e.extend({},l.prevCurrSelectionPoint,{},!0),a.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"crop",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:n,previousText:null,currentText:null,previousFilter:null,isCircleCrop:a.isCircleCrop}}),o.isCropToolbar||a.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),a.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:a.cropObj.destPoints.width,height:a.cropObj.destPoints.height}}),e.isBlazor()||o.isCropToolbar?o.isCropToolbar||this.parent.updateToolbar(this.parent.element,"imageLoaded"):a.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}})}},t.prototype.calcRatio=function(t,e){var i,o,r=this.parent;return 0===r.transform.degree||r.transform.degree%180==0?(i=(e?e.width:r.baseImg.width)/r.img.destWidth,o=(e?e.height:r.baseImg.height)/r.img.destHeight):(i=(e?e.height:r.baseImg.height)/r.img.destWidth,o=(e?e.width:r.baseImg.width)/r.img.destHeight),t&&(t.width=i,t.height=o),{width:i,height:o}},t.prototype.isObjInImage=function(t,e){var i=this.parent,o=!1,r=t.activePoint.startX,a=t.activePoint.endX,n=t.activePoint.startY,s=t.activePoint.endY;return(r>=i.img.destLeft&&a<=i.img.destLeft+i.img.destWidth||r<=i.img.destLeft&&a>=i.img.destLeft||r<=i.img.destLeft+i.img.destWidth&&a>=i.img.destLeft+i.img.destWidth||n>=i.img.destTop&&s<=i.img.destTop+i.img.destHeight||n<=i.img.destTop&&s>=i.img.destTop||n<=i.img.destTop+i.img.destHeight&&s>=i.img.destTop+i.img.destHeight)&&(o=!0),e&&(e.isInside=o),o},t.prototype.getCurrFlipState=function(t){var e=this.parent,i={panRegion:""},o={collection:e.rotateFlipColl};e.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:e.rotateFlipColl,isRotateFlipCollection:!0,obj:o}}),e.rotateFlipColl=o.collection;for(var r=0,a=e.rotateFlipColl.length;r<a;r++)e.notify("transform",{prop:"setCurrPanRegion",onPropertyChange:!1,value:{region:i.panRegion,type:e.rotateFlipColl[r],obj:i}});return t&&(t.panRegion=i.panRegion),i.panRegion},t}(),s=function(){function t(t){this.cancelObjColl=[],this.cancelPointColl=[],this.isInitialLoading=!1,this.fileName="",this.isErrorImage=!1,this.isShapeTextInserted=!1,this.isRotateZoom=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempAdjValue="",this.tempFilter="",this.tempUndoRedoStep=0,this.tempFreehandCounter=0,this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.zoomCrop={width:0,height:0},this.isImageEdited=!1,this.isFileChanged=!1,this.isNewPath=!1,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}},this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("draw",this.draw),this.parent.off("destroyed",this.destroy)},t.prototype.draw=function(t){switch(this.updatePrivateVariables(),t.prop){case"drawObject":this.drawObject(t.value.canvas,t.value.obj,t.value.isCropRatio,t.value.points,t.value.isPreventDrag,t.value.saveContext,t.value.isPreventSelection);break;case"updateActiveObject":this.updateActiveObject(t.value.actPoint,t.value.obj,t.value.isMouseMove,t.value.x,t.value.y);break;case"clearOuterCanvas":this.clearOuterCanvas(t.value.context);break;case"setDestPoints":this.setDestPoints();break;case"updateCurrTransState":this.updateCurrTransState(t.value.type,t.value.isPreventDestination,t.value.isRotatePan);break;case"currTransState":this.currTransState(t.value.type,t.value.isPreventDestination,t.value.context,t.value.isPreventCircleCrop);break;case"setTransform":this.setTransform(t.value.context,t.value.value,t.value.isReverse);break;case"render-image":this.renderImage(t.value.isMouseWheel);break;case"draw-image-to-canvas":this.drawImgToCanvas(t.value.dimension);break;case"update-canvas":this.updateCanvas();break;case"performCancel":this.performCancel(t.value.isContextualToolbar);break;case"updateFlipPan":this.updateFlipPan(t.value.tempSelectionObj);break;case"select":this.select(t.value.type,t.value.startX,t.value.startY,t.value.width,t.value.height);break;case"callUpdateCurrTransState":this.callUpdateCurrTransState();break;case"resetPanPoints":this.resetPanPoints();break;case"setClientTransDim":this.setClientTransDim(t.value.isPreventDimension);break;case"redrawImgWithObj":this.redrawImgWithObj();break;case"setCurrentObj":this.setCurrentObj(t.value.obj);break;case"performPointZoom":this.performPointZoom(t.value.x,t.value.y,t.value.type);break;case"open":this.open(t.value.data);break;case"isInitialLoading":this.isInitialLoading=t.value.isInitialLoading;break;case"isInitialLoaded":this.getInitialLoaded(t.value.object);break;case"fileSelect":this.fileSelect(t.value.inputElement,t.value.args);break;case"getFileName":t.value.obj.fileName=this.fileName,t.value.obj.fileType=this.fileType;break;case"getErrorImage":t.value.obj.isErrorImage=this.isErrorImage;break;case"getInitialZoomValue":t.value.obj.initialZoomValue=this.initZoomValue;break;case"setShapeTextInsert":this.isShapeTextInserted=t.value.bool;break;case"resetCurrentSelectionPoint":this.currSelPoint=null;break;case"setRotateZoom":this.isRotateZoom=t.value.isRotateZoom;break;case"setTempStrokeSettings":this.tempStrokeSettings=t.value.tempStrokeSettings;break;case"setTempTextSettings":this.tempTextSettings=t.value.tempTextSettings;break;case"setTempAdjustmentValue":this.tempAdjValue=t.value.tempAdjustmentValue;break;case"getTempAdjustmentValue":t.value.obj.value=this.tempAdjValue;break;case"setTempFilter":this.tempFilter=t.value.tempFilter;break;case"setTempUndoRedoStep":this.tempUndoRedoStep=t.value.tempUndoRedoStep;break;case"setTempFreehandCounter":this.tempFreehandCounter=t.value.tempFreehandCounter;break;case"setTempCurrentFreehandDrawIndex":this.tempCurrFhdIndex=t.value.tempCurrentFreehandDrawIndex;break;case"setTempZoomFactor":this.tempZoomFactor=t.value.tempZoomFactor;break;case"setCancelAction":this.isCancelAction=t.value.bool;break;case"getRotatedFlipCropSelection":t.value.bool.isSelected=this.rotatedFlipCropSel;break;case"getPrevActObj":t.value.obj.prevActObj=this.prevActObj;break;case"setPrevActObj":this.prevActObj=t.value.prevActObj;break;case"setZoomCropWidth":this.zoomCrop.width=t.value.width,this.zoomCrop.height=t.value.height;break;case"setImageEdited":this.isImageEdited=!0;break;case"reset":this.reset();break;case"dlgBtnClick":this.dlgBtnClick();break;case"dlgCloseBtnClick":this.dlgCloseBtnClick();break;case"setNewPath":this.isNewPath=t.value.bool;break;case"getNewPath":t.value.obj.isNewPath=this.isNewPath;break;case"getArrowDimension":t.value.obj.arrowDimension=this.arrowDimension;break;case"setArrowDimension":this.arrowDimension=t.value.arrowDimension;break;case"moveToSelectionRange":this.moveToSelectionRange(t.value.type,t.value.activeObj)}},t.prototype.getModuleName=function(){return"draw"},t.prototype.updatePrivateVariables=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d")),e.isNullOrUndefined(this.tempZoomFactor)&&(this.tempZoomFactor=t.transform.zoomFactor)},t.prototype.reset=function(){this.isInitialLoading=this.isErrorImage=this.isNewPath=!1,this.cancelObjColl=this.cancelPointColl=[],this.isShapeTextInserted=!1,this.initZoomValue=null,this.tempFilter="",this.currSelPoint=null,this.isRotateZoom=!1,this.tempAdjValue="",this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempUndoRedoStep=this.tempFreehandCounter=this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.prevActObj=null,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}}},t.prototype.drawObject=function(t,i,o,r,a,n,s){var l=this.parent,p=l.activeObj.activePoint;this.upperContext.clearRect(0,0,l.upperCanvas.width,l.upperCanvas.height);var h;if("original"===t.toLowerCase()?h=this.lowerContext:"duplicate"===t.toLowerCase()?h=this.upperContext:n&&(h=n),!a&&l.activeObj.shape&&this.setDragLimit(),l.currObjType.shape&&"crop"===l.currObjType.shape.split("-")[0].toLowerCase()&&o&&this.drawCropRatio(),r&&(p.startX=r.startX,p.startY=r.startY,p.endX=r.endX,p.endY=r.endY,p.width=r.width,p.height=r.height),e.isNullOrUndefined(l.activeObj.strokeSettings)){var c={strokeSettings:{}};l.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:c}}),l.activeObj.strokeSettings=c.strokeSettings}if(e.isNullOrUndefined(l.activeObj.strokeSettings.strokeWidth)&&(l.activeObj.strokeSettings.strokeWidth=2),i&&(l.activeObj=e.extend({},i,{},!0)),this.updateActiveObject(),!e.isNullOrUndefined(l.activeObj.activePoint.startX)||!e.isNullOrUndefined(l.activeObj.activePoint.startY)){if(l.currObjType.isText){var d={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:d}}),l.activeObj.keyHistory=d.keyHistory}if("original"!==t.toLowerCase()){var v=!1;l.activeObj.shape&&"crop"===l.activeObj.shape.split("-")[0]&&(v=!0),v&&(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,l.lowerCanvas.width,l.lowerCanvas.height),this.upperContext.clearRect(p.startX,p.startY,p.width,p.height)),!e.isNullOrUndefined(s)||h!==this.lowerContext&&h!==this.upperContext||(this.rotateContext("initial",h),this.drawOuterSelection(h),this.rotateContext("reverse",h))}l.currObjType.isActiveObj=!0;var u={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:u}}),i?this.drawShapeObj(t,i.shape,n,s):""!==u.keyHistory&&l.currObjType.isText?this.drawShapeObj(t,"text",n,s):l.activeObj.shape?this.drawShapeObj(t,l.activeObj.shape,n,s):this.drawShapeObj(t,void 0,n,s)}},t.prototype.rotateContext=function(t,i){var o=this.parent,r=e.extend({},o.activeObj.activePoint,{},!0);if("line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape){var a="initial"===t?o.activeObj.rotatedAngle:-o.activeObj.rotatedAngle;i.translate(r.startX+r.width/2,r.startY+r.height/2),i.rotate(a),i.translate(-(r.startX+r.width/2),-(r.startY+r.height/2))}},t.prototype.setDragLimit=function(){var t=this.parent,e=t.activeObj.activePoint;e&&0===t.activeObj.rotatedAngle&&(e.startX<t.img.destLeft?(e.startX=t.img.destLeft,e.endX=e.startX+e.width):e.endX>t.img.destLeft+t.img.destWidth&&(e.endX=t.img.destLeft+t.img.destWidth,e.startX=e.endX-e.width),e.startY<t.img.destTop?e.startY=t.img.destTop:e.endY>t.img.destTop+t.img.destHeight&&(e.endY=t.img.destTop+t.img.destHeight,e.startY=e.endY-e.height),t.activeObj=this.updateWidthHeight(t.activeObj))},t.prototype.drawCropRatio=function(){var t,i,o,r,a=this.parent,n=a.activeObj.activePoint;if(a.transform.zoomFactor>0&&this.currSelPoint){var s=e.extend({},a.activeObj,{},!0);this.drawCustomSelection("crop-custom",null,null,null,null),a.transform.degree%90==0&&a.transform.degree%180!=0?r=o=a.activeObj.activePoint.width<a.activeObj.activePoint.height?a.activeObj.activePoint.width:a.activeObj.activePoint.height:(o=a.img.destLeft+a.img.destLeft+a.img.destWidth<=a.lowerCanvas.clientWidth?n.width:a.lowerCanvas.clientWidth-a.img.destLeft,r=a.img.destTop+a.img.destTop+a.img.destHeight<=a.lowerCanvas.clientHeight?n.height:a.lowerCanvas.clientHeight-a.img.destTop),a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),a.activeObj=s,a.currObjType.shape=s.shape,this.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.currObjType.isCustomCrop=!1}else o=a.img.destWidth,r=a.img.destHeight,a.img.destLeft<0&&(o+=a.img.destLeft),a.img.destTop<0&&(r+=a.img.destTop),"crop-square"!==a.currObjType.shape.toLowerCase()&&"crop-circle"!==a.currObjType.shape.toLowerCase()&&(a.img.destLeft+a.img.destWidth>a.lowerCanvas.width&&(o-=a.img.destLeft+a.img.destWidth-a.lowerCanvas.width),a.img.destTop+a.img.destHeight>a.lowerCanvas.height&&(r-=a.img.destTop+a.img.destHeight-a.lowerCanvas.height));switch(a.currObjType.shape.toLowerCase()){case"crop-square":case"crop-circle":a.notify("selection",{prop:"setDragDirection",onPropertyChange:!1,value:{width:o,height:r}}),n=a.activeObj.activePoint,a.lowerCanvas.width<n.endX-n.startX&&(n.startX=7.5,n.endX=a.lowerCanvas.width-7.5),a.lowerCanvas.height<n.endY-n.startY&&(n.startY=7.5,n.endY=a.lowerCanvas.height-7.5),o===a.img.destWidth&&r===a.img.destHeight&&(n.startX+=a.img.destLeft,n.startY+=a.img.destTop,n.endX+=a.img.destLeft,n.endY+=a.img.destTop),a.lowerCanvas.width>a.lowerCanvas.height?(n.height=n.endY-n.startY,n.width=n.height,n.endX=n.startX+n.width):(n.width=n.endX-n.startX,n.height=n.width,n.endY=n.startY+n.height);break;case"crop-3:2":t=3,i=2;break;case"crop-4:3":t=4,i=3;break;case"crop-5:4":t=5,i=4;break;case"crop-7:5":t=7,i=5;break;case"crop-16:9":t=16,i=9}if(void 0!==t&&void 0!==i&&(a.notify("selection",{prop:"calcShapeRatio",onPropertyChange:!1,value:{x:t,y:i,imgWidth:o,imgHeight:r}}),o===a.img.destWidth&&r===a.img.destHeight&&this.updatePoints(),n=a.activeObj.activePoint),n.startX<a.img.destLeft){l=a.img.destLeft-n.startX+7.5;n.startX+=l,n.endX+=l}if(n.startY<a.img.destTop){var l=a.img.destTop-n.startY+7.5;n.startY+=l,n.endY+=l}a.activeObj=this.updateWidthHeight(a.activeObj),this.adjToCenter()},t.prototype.adjToCenter=function(){var t=this.parent,e=t.lowerCanvas.width/2-(t.activeObj.activePoint.endX-t.activeObj.activePoint.width/2),i=t.lowerCanvas.height/2-(t.activeObj.activePoint.endY-t.activeObj.activePoint.height/2);if(t.activeObj.activePoint.startX+=e,t.activeObj.activePoint.endX+=e,t.activeObj.activePoint.startY+=i,t.activeObj.activePoint.endY+=i,t.activeObj.activePoint.startX<(t.img.destLeft>=7.5?t.img.destLeft:7.5)){o=(t.img.destLeft>=7.5?t.img.destLeft:0)-t.activeObj.activePoint.startX+7.5;t.activeObj.activePoint.startX+=o,t.activeObj.activePoint.endX+=o}else if(t.activeObj.activePoint.endX>t.img.destLeft+t.img.destWidth){o=t.activeObj.activePoint.endX-(t.img.destLeft+t.img.destWidth)+7.5;t.activeObj.activePoint.startX-=o,t.activeObj.activePoint.endX-=o}if(t.activeObj.activePoint.startY<(t.img.destTop>7.5?t.img.destTop:7.5)){o=(t.img.destTop>7.5?t.img.destTop:0)-t.activeObj.activePoint.startY+7.5;t.activeObj.activePoint.startY+=o,t.activeObj.activePoint.endY+=o}else if(t.activeObj.activePoint.endY>t.img.destTop+t.img.destHeight){var o=t.activeObj.activePoint.endY-(t.img.destTop+t.img.destHeight)+7.5;t.activeObj.activePoint.startY-=o,t.activeObj.activePoint.endY-=o}},t.prototype.updateActiveObject=function(t,i,o,r,a){t=t||e.extend({},this.parent.activeObj.activePoint,{},!0),i=i||e.extend({},this.parent.activeObj,{},!0),t.width=t.endX-t.startX,t.height=t.endY-t.startY,r=r||0,a=a||0;var n=t.width/2,s=t.height/2;i.horTopLine={startX:t.startX+r,startY:t.startY-a,endX:t.endX+r,endY:t.endY+a},i.horBottomLine={startX:t.startX-r,startY:t.endY-a,endX:t.endX-r,endY:t.endY+a},i.verLeftLine={startX:t.startX+r,startY:t.startY-a,endX:t.startX-a,endY:t.endY-a},i.verRightLine={startX:t.endX+r,startY:t.startY+a,endX:t.endX-r,endY:t.endY+a},i.topLeftCircle={startX:t.startX,startY:t.startY,radius:i.horTopLine.endX?7.5:0},i.topCenterCircle={startX:t.startX+n,startY:t.startY,radius:i.horTopLine.endX?7.5:0},i.topRightCircle={startX:t.endX,startY:t.startY,radius:i.horTopLine.endX?7.5:0},i.centerLeftCircle={startX:t.startX,startY:t.startY+s,radius:i.horTopLine.endX?7.5:0},i.centerRightCircle={startX:t.endX,startY:t.startY+s,radius:i.horTopLine.endX?7.5:0},i.bottomLeftCircle={startX:t.startX,startY:t.endY,radius:i.horTopLine.endX?7.5:0},i.bottomCenterCircle={startX:t.startX+n,startY:t.endY,radius:i.horTopLine.endX?7.5:0},i.bottomRightCircle={startX:t.endX,startY:t.endY,radius:i.horTopLine.endX?7.5:0},0===i.rotatedAngle&&(i.rotationCirclePoint={x:i.bottomCenterCircle.startX,y:i.bottomCenterCircle.startY+25},i.rotationCirclePoint.ratioX=(i.rotationCirclePoint.x-this.parent.img.destLeft)/this.parent.img.destWidth,i.rotationCirclePoint.ratioY=(i.rotationCirclePoint.y-this.parent.img.destTop)/this.parent.img.destHeight),i.activePoint=t,e.isNullOrUndefined(o)&&(this.parent.activeObj=e.extend({},i,{},!0))},t.prototype.drawOuterSelection=function(t,i){var o,r=this.parent,a=r.activeObj.activePoint;t.lineWidth=.5,void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-"));var n=e.extend({},r.activeObj,{},!0);void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-")),(void 0===o||"crop"!==o[0])&&void 0!==r.activeObj.shape||i||(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.upperContext.clearRect(a.startX,a.startY,a.width,a.height)),t.strokeStyle=r.themeColl[r.theme].primaryColor,t.fillStyle=r.themeColl[r.theme].secondaryColor;var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),"arrow"===r.activeObj.shape||"line"===r.activeObj.shape)t.beginPath(),t.moveTo(a.startX,a.startY),t.lineTo(a.endX,a.endY),t.stroke();else if("path"===r.activeObj.shape){t.beginPath();var l=e.extend({},r.activeObj,{},!0);if(t.moveTo(l.pointColl[0].x,l.pointColl[0].y),l.pointColl.length>1)for(var p=1,h=l.pointColl.length;p<h;p++)a.endX=l.pointColl[p].x,a.endY=l.pointColl[p].y,t.lineTo(a.endX,a.endY);var c={shape:null};r.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:c}}),"path"===c.shape&&(r.activeObj=l),t.lineTo(a.endX,a.endY),t.stroke()}else if(t.beginPath(),t.rect(n.activePoint.startX,n.activePoint.startY,n.activePoint.width,n.activePoint.height),t.stroke(),t.closePath(),r.selectionSettings.showCircle){var d=t.strokeStyle,v=t.fillStyle;t.strokeStyle=r.selectionSettings.strokeColor,t.fillStyle=r.selectionSettings.fillColor,t.lineWidth*=2,t.beginPath(),t.moveTo(n.topLeftCircle.startX,n.topLeftCircle.startY),t.arc(n.topLeftCircle.startX,n.topLeftCircle.startY,n.topLeftCircle.radius,0,2*Math.PI),t.moveTo(n.topRightCircle.startX,n.topRightCircle.startY),t.arc(n.topRightCircle.startX,n.topRightCircle.startY,n.topRightCircle.radius,0,2*Math.PI),t.moveTo(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY),t.arc(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY,n.bottomLeftCircle.radius,0,2*Math.PI),t.moveTo(n.bottomRightCircle.startX,n.bottomRightCircle.startY),t.arc(n.bottomRightCircle.startX,n.bottomRightCircle.startY,n.bottomRightCircle.radius,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),t.lineWidth/=2,t.strokeStyle=d,t.fillStyle=v}if(r.selectionSettings.showCircle&&(void 0===o||"crop"!==o[0])){var d=t.strokeStyle,v=t.fillStyle;t.strokeStyle=r.selectionSettings.strokeColor,t.fillStyle=r.selectionSettings.fillColor,"text"===r.activeObj.shape||this.drawCenterCircles(t),t.strokeStyle=d,t.fillStyle=v}n.rotationCircleLine=r.activeObj.rotationCircleLine,r.activeObj=e.extend({},n,{},!0)},t.prototype.drawArrowHead=function(t,e){switch(e?this.parent.activeObj.start:this.parent.activeObj.end){case"arrowSolid":e?this.arrowSolid(t,!0):this.arrowSolid(t,!1);break;case"arrow":e?this.arrow(t,!0):this.arrow(t,!1);break;case"circleSolid":e?this.arrowCircleSolid(t,!0):this.arrowCircleSolid(t,!1);break;case"circle":e?this.arrowCircle(t,!0):this.arrowCircle(t,!1);break;case"bar":e?this.arrowBar(t,!0):this.arrowBar(t,!1);break;case"square":case"squareSolid":e?this.arrowSquareStart(t):this.arrowSquareEnd(t)}},t.prototype.drawShapeObj=function(t,i,o,r){var a=this.parent,n=a.activeObj.activePoint,s=void 0!==i?i:a.currObjType.shape;a.currObjType.shape=s;var l;"original"===t.toLowerCase()?l=this.lowerContext:"duplicate"===t.toLowerCase()?l=this.upperContext:o&&(l=o),"rectangle"!==a.currObjType.shape.toLowerCase()&&"ellipse"!==a.currObjType.shape.toLowerCase()&&"line"!==a.currObjType.shape.toLowerCase()&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape||(a.activeObj.shape=a.currObjType.shape),l.strokeStyle=a.activeObj.strokeSettings.strokeColor,l.fillStyle="text"===i||"freehanddraw"===i?a.activeObj.strokeSettings.strokeColor:a.activeObj.strokeSettings.fillColor;var p=n.width/3,h=n.height/3,c=n.endX-n.startX,d=n.endY-n.startY;this.rotateContext("initial",l);var v,u,g=l.fillStyle;switch(a.currObjType.shape.toLowerCase()){case"rectangle":this.drawSquareLines(l),e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"ellipse":c=Math.abs(c),d=Math.abs(d),l.beginPath(),l.ellipse(n.startX+c/2,n.startY+d/2,c/2,d/2,0,0,2*Math.PI,!1),""!==a.activeObj.strokeSettings.fillColor&&(l.fillStyle=a.activeObj.strokeSettings.fillColor,l.fill()),l.ellipse(n.startX+c/2,n.startY+d/2,Math.abs(c/2-a.activeObj.strokeSettings.strokeWidth),Math.abs(d/2-a.activeObj.strokeSettings.strokeWidth),0,0,2*Math.PI,!1),l.fillStyle=a.activeObj.strokeSettings.strokeColor,l.fill("evenodd"),l.closePath(),e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"crop-circle":l===this.lowerContext&&(l=this.upperContext),this.shapeCircle(l,c,d);break;case"line":this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"arrow":(v=0===a.activeObj.shapeDegree?a.transform.degree:a.transform.degree-a.activeObj.shapeDegree)<0&&(v=360+v),l.fillStyle=l.strokeStyle,e.isNullOrUndefined(a.activeObj.triangleDirection)&&(a.activeObj.triangleDirection="right"),e.isNullOrUndefined(a.activeObj.start)&&(a.activeObj.start="none"),e.isNullOrUndefined(a.activeObj.end)&&(a.activeObj.end="arrowSolid"),this.drawArrowHead(l,!0),this.drawArrowHead(l,!1),"none"===a.activeObj.end&&this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),l.fillStyle=g,e.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"path":if((u=e.extend({},a.activeObj,{},!0)).pointColl.length>1){var b={shape:null};if(a.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:b}}),"path"===b.shape)for(var C={x:0,y:0},f=0,m=u.pointColl.length;f<m;f++)e.isNullOrUndefined(u.pointColl[f+1])?(C.x=u.activePoint.endX,C.y=u.activePoint.endY):(C.x=u.pointColl[f+1].x,C.y=u.pointColl[f+1].y),n.startX=u.pointColl[f].x,n.startY=u.pointColl[f].y,n.endX=C.x,n.endY=C.y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);else for(var f=1,m=u.pointColl.length;f<m;f++)n.startX=u.pointColl[f-1].x,n.startY=u.pointColl[f-1].y,n.endX=u.pointColl[f].x,n.endY=u.pointColl[f].y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);a.activeObj=u}else this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);l===this.upperContext&&this.drawOuterSelection(l);break;case"text":this.shapeText(l);break;case"crop-square":case"crop-3:4":case"crop-4:3":case"crop-6:9":case"crop-9:6":case"crop-9:16":case"crop-16:9":l===this.lowerContext&&(l=this.upperContext),this.drawSelection(p,h),a.currObjType.shape="";break;default:this.drawSelection(p,h)}this.rotateContext("reverse",l)},t.prototype.updatePoints=function(){var t=this.parent;t.activeObj.activePoint.startX+=t.img.destLeft,t.activeObj.activePoint.startY+=t.img.destTop,t.activeObj.activePoint.endX+=t.img.destLeft,t.activeObj.activePoint.endY+=t.img.destTop,t.activeObj=this.updateWidthHeight(t.activeObj)},t.prototype.updateWidthHeight=function(t){return t.activePoint.width=t.activePoint.endX-t.activePoint.startX,t.activePoint.height=t.activePoint.endY-t.activePoint.startY,t},t.prototype.drawCenterCircles=function(t){var i=this.parent,o=i.activeObj.activePoint;if(t.lineWidth*=2,t.beginPath(),"arrow"===i.activeObj.shape||"line"===i.activeObj.shape)t.moveTo(o.startX,o.startY),t.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),t.moveTo(o.endX,o.endY),t.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);else if("path"===i.activeObj.shape){var r=e.extend({},i.activeObj,{},!0);if(r.pointColl.length>1)for(var a=1,n=r.pointColl.length;a<n;a++)o.startX=r.pointColl[a-1].x,o.startY=r.pointColl[a-1].y,o.endX=r.pointColl[a].x,o.endY=r.pointColl[a].y,t.moveTo(o.startX,o.startY),t.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),t.moveTo(o.endX,o.endY),t.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"===s.shape&&(i.activeObj=r),t.moveTo(o.startX,o.startY),t.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),t.moveTo(o.endX,o.endY),t.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI)}else this.drawRotationArcLine(t),t.lineTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y);t.stroke(),t.fill(),t.closePath(),"arrow"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"path"!==i.activeObj.shape&&(t.beginPath(),t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y),t.arc(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI),t.stroke(),t.fill(),t.closePath()),t.lineWidth/=2},t.prototype.drawRotationArcLine=function(t){var i=this.parent;e.isNullOrUndefined(i.activeObj.rotationCircleLine)&&(i.activeObj.rotationCircleLine=22.5);var o,r=!1,a=!1;if((o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o),i.activeObj.flipObjColl)for(var n=0,s=i.activeObj.flipObjColl.length;n<s;n++)"horizontal"===i.activeObj.flipObjColl[n].toLowerCase()?r=!0:"vertical"===i.activeObj.flipObjColl[n].toLowerCase()&&(a=!0);switch(o){case 0:case 360:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine));break;case 90:case-270:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y));break;case 180:case-180:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},t.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine));break;case 270:case-90:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},t.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y))}},t.prototype.drawSquareLines=function(t){var e,i=this.parent,o=i.activeObj.activePoint;void 0!==i.activeObj.shape&&(e=i.activeObj.shape.split("-")),"crop"===e[0]?t.strokeStyle="#fff":t.strokeStyle=i.activeObj.strokeSettings.strokeColor,t.beginPath(),t.rect(o.startX,o.startY,o.width,o.height),""!==i.activeObj.strokeSettings.fillColor&&(t.fillStyle=i.activeObj.strokeSettings.fillColor,t.fill()),t.rect(o.startX+i.activeObj.strokeSettings.strokeWidth,o.startY+i.activeObj.strokeSettings.strokeWidth,o.width-2*i.activeObj.strokeSettings.strokeWidth,o.height-2*i.activeObj.strokeSettings.strokeWidth),t.fillStyle=i.activeObj.strokeSettings.strokeColor,t.fill("evenodd"),t.closePath()},t.prototype.drawSelection=function(t,e){var i=this.parent,o=i.activeObj.activePoint;this.upperContext.strokeStyle=i.themeColl[i.theme].primaryColor,this.upperContext.beginPath(),i.activeObj.horTopInnerLine={startX:o.startX,startY:o.startY+e,endX:o.endX,endY:o.endY+e},i.activeObj.horBottomInnerLine={startX:o.startX,startY:o.startY+2*e,endX:o.endX,endY:o.endY+2*e},i.activeObj.verLeftInnerLine={startX:o.startX+t,startY:o.startY,endX:o.startX+t,endY:o.endY},i.activeObj.verRightInnerLine={startX:o.startX+2*t,startY:o.startY,endX:o.startX+2*t,endY:o.endY},this.upperContext.moveTo(i.activeObj.horTopInnerLine.startX,i.activeObj.horTopInnerLine.startY),this.upperContext.lineTo(i.activeObj.horTopInnerLine.endX,i.activeObj.horTopInnerLine.startY),this.upperContext.moveTo(i.activeObj.horBottomInnerLine.startX,i.activeObj.horBottomInnerLine.startY),this.upperContext.lineTo(i.activeObj.horBottomInnerLine.endX,i.activeObj.horBottomInnerLine.startY),this.upperContext.moveTo(i.activeObj.verLeftInnerLine.startX,i.activeObj.verLeftInnerLine.startY),this.upperContext.lineTo(i.activeObj.verLeftInnerLine.endX,i.activeObj.verLeftInnerLine.endY),this.upperContext.moveTo(i.activeObj.verRightInnerLine.startX,i.activeObj.verRightInnerLine.startY),this.upperContext.lineTo(i.activeObj.verRightInnerLine.endX,i.activeObj.verRightInnerLine.endY),this.upperContext.stroke(),this.upperContext.closePath()},t.prototype.shapeCircle=function(t,e,i){var o=this.parent,r=o.activeObj.activePoint;t.strokeStyle=o.themeColl[o.theme].primaryColor,t.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),t.fillStyle="rgb(0, 0, 0, 0.25)",t.fillRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var a=t.lineWidth;t.lineWidth=2,t.beginPath(),t.ellipse(o.activeObj.horTopLine.startX+e/2,o.activeObj.horTopLine.startY+i/2,e/2,i/2,0,0,2*Math.PI,!1),t.stroke(),t.closePath(),t.save(),t.beginPath(),t.arc((r.endX-r.startX)/2+r.startX,(r.endY-r.startY)/2+r.startY,r.width/2,0,2*Math.PI),t.closePath(),t.clip(),t.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),t.restore(),t.lineWidth=a,this.drawOuterSelection(t,!0),o.currObjType.shape=""},t.prototype.shapeLine=function(t,e,i,o,r){var a=t.lineWidth;t.lineWidth=this.parent.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.moveTo(e,i),t.lineTo(o,r),t.stroke(),t.lineWidth=a},t.prototype.arrow=function(t,e){var i=this.parent,o=i.activeObj.activePoint;t.lineWidth=i.activeObj.strokeSettings.strokeWidth;var r=this.arrowDimension.arrow.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.arrow.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,t.fillStyle=i.activeObj.strokeSettings.strokeColor;var n=Math.atan2(this.dy,this.dx);(e&&("left"===i.activeObj.triangleDirection||"right"===i.activeObj.triangleDirection)&&"arrow"===i.activeObj.start&&"none"===i.activeObj.end||"arrow"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&("arrow"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY),e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection?(t.translate(o.endX,o.endY),t.rotate(n),this.shapeLine(t,0,0,-r,a/2),this.shapeLine(t,0,0,-r,-a/2),t.rotate(-n),t.translate(-o.endX,-o.endY)):(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection)&&(t.translate(o.startX,o.startY),t.rotate(n),this.shapeLine(t,0,0,r,a/2),this.shapeLine(t,0,0,r,-a/2),t.rotate(-n),t.translate(-o.startX,-o.startY))},t.prototype.arrowSolid=function(t,e){var i=this.parent,o=i.activeObj.activePoint,r=this.arrowDimension.arrowSolid.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.arrowSolid.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var n=Math.atan2(this.dy,this.dx);(e&&"arrowSolid"===i.activeObj.start&&"none"===i.activeObj.end||"arrowSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&("arrowSolid"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY),e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection?(t.translate(o.endX,o.endY),t.rotate(n),t.beginPath(),t.moveTo(i.activeObj.strokeSettings.strokeWidth,0),t.lineTo(a/2-r,a/2),t.lineTo(a/2-r,-a/2),t.closePath(),t.fill(),t.rotate(-n),t.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=n):(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection)&&(t.translate(o.startX,o.startY),t.rotate(n),t.beginPath(),t.moveTo(0-i.activeObj.strokeSettings.strokeWidth,0),t.lineTo(r-a/2,a/2),t.lineTo(r-a/2,-a/2),t.closePath(),t.fill(),t.rotate(-n),t.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=n)},t.prototype.arrowSquareStart=function(t){var e=this.parent,i=e.activeObj.activePoint;("square"===e.activeObj.start&&"none"===e.activeObj.end||"square"===e.activeObj.start&&"circle"!==e.activeObj.end&&"square"!==e.activeObj.start||"squareSolid"===e.activeObj.start&&"circleSolid"===e.activeObj.end)&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY),t.lineWidth=e.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=e.activeObj.strokeSettings.strokeColor;var o=this.arrowDimension.square.width+e.activeObj.strokeSettings.strokeWidth,r=this.arrowDimension.square.height+e.activeObj.strokeSettings.strokeWidth;this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var a=Math.atan2(this.dy,this.dx);"left"===e.activeObj.triangleDirection?(t.translate(i.endX,i.endY),t.rotate(a),"squareSolid"===e.activeObj.start&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.endX,-i.endY),this.squareStartIntersectX1=i.endX-r/2*Math.cos(a),this.squareStartIntersectY1=i.endY-r/2*Math.sin(a),"square"===e.activeObj.start&&"square"!==e.activeObj.end&&"circle"!==e.activeObj.end&&"square"!==e.activeObj.end&&this.shapeLine(t,i.startX,i.startY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===e.activeObj.start&&"circle"===e.activeObj.end&&this.shapeLine(t,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1),"squareSolid"===e.activeObj.start&&"squareSolid"===e.activeObj.end&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY)):"right"===e.activeObj.triangleDirection&&(t.lineWidth=e.activeObj.strokeSettings.strokeWidth,t.fillStyle=e.activeObj.strokeSettings.strokeColor,"squareSolid"===e.activeObj.start&&"squareSolid"===e.activeObj.end&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY),t.translate(i.startX,i.startY),t.rotate(a),"squareSolid"===e.activeObj.start&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.startX,-i.startY),e.activeObj.rotatedAngle=a,this.squareStartIntersectX1=i.startX+r/2*Math.cos(a),this.squareStartIntersectY1=i.startY+r/2*Math.sin(a),"square"===e.activeObj.start&&"square"!==e.activeObj.end&&"circle"!==e.activeObj.end&&"square"!==e.activeObj.end&&this.shapeLine(t,i.endX,i.endY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===e.activeObj.start&&"circle"===e.activeObj.end&&this.shapeLine(t,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},t.prototype.arrowSquareEnd=function(t){var e=this.parent,i=e.activeObj.activePoint,o=this.arrowDimension.square.width+e.activeObj.strokeSettings.strokeWidth,r=this.arrowDimension.square.height+e.activeObj.strokeSettings.strokeWidth;this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var a=Math.atan2(this.dy,this.dx);t.lineWidth=e.activeObj.strokeSettings.strokeWidth,"right"===e.activeObj.triangleDirection?(t.fillStyle=e.activeObj.strokeSettings.strokeColor,"squareSolid"===e.activeObj.end&&"none"===e.activeObj.start&&this.shapeLine(t,i.startX,i.startY,i.endX,i.endY),t.translate(i.endX,i.endY),t.rotate(a),"squareSolid"===e.activeObj.end&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.endX,-i.endY),e.activeObj.rotatedAngle=a,this.squareEndIntersectX1=i.endX-r/2*Math.cos(a),this.squareEndIntersectY1=i.endY-r/2*Math.sin(a),"square"===e.activeObj.end&&"square"!==e.activeObj.start&&"circle"!==e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,i.startX,i.startY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===e.activeObj.start&&"square"===e.activeObj.end&&this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1)):"left"===e.activeObj.triangleDirection&&(t.translate(i.startX,i.startY),t.rotate(a),"squareSolid"===e.activeObj.end&&t.fillRect(r/2-o,-r/2,o,r),t.strokeRect(r/2-o,-r/2,o,r),t.rotate(-a),t.translate(-i.startX,-i.startY),e.activeObj.rotatedAngle=a,this.squareEndIntersectX1=i.startX+r/2*Math.cos(a),this.squareEndIntersectY1=i.startY+r/2*Math.sin(a),"square"===e.activeObj.end&&"square"!==e.activeObj.start&&"circle"!==e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,i.endX,i.endY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===e.activeObj.start&&"square"===e.activeObj.end?this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===e.activeObj.start&&"square"===e.activeObj.end&&this.shapeLine(t,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},t.prototype.arrowCircle=function(t,e){var i=this.parent,o=i.activeObj.activePoint;if(e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth;s=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;t.beginPath(),t.arc(o.endX,o.endY,s,0,2*Math.PI),t.stroke(),t.closePath(),this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;l=this.dx*this.dx+this.dy*this.dy;if((c=(p=2*(this.dx*(o.startX-o.endX)+this.dy*(o.startY-o.endY)))*p-4*l*(h=(o.startX-o.endX)*(o.startX-o.endX)+(o.startY-o.endY)*(o.startY-o.endY)-s*s))>=0){t.fillStyle=i.activeObj.strokeSettings.strokeColor;var r=(-p-Math.sqrt(c))/(2*l),a=o.startX+this.dx*r,n=o.startY+this.dy*r;e?(this.startCircleIntersectX1=a,this.startCircleIntersectY1=n,t.beginPath(),t.fill(),t.beginPath(),"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(t,this.startCircleIntersectX1,this.startCircleIntersectY1,this.endCircleIntersectX1,this.endCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(t,o.startX,o.startY,this.startCircleIntersectX1,this.startCircleIntersectY1),t.stroke(),t.closePath()):(this.endCircleIntersectX1=a,this.endCircleIntersectY1=n,"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(t,o.startX,o.startY,this.endCircleIntersectX1,this.endCircleIntersectY1))}d=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=d}else if(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth;var s=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;t.beginPath(),t.arc(o.startX,o.startY,s,0,2*Math.PI),t.stroke(),t.closePath(),this.dx=o.startX-o.endX,this.dy=o.startY-o.endY;var l=this.dx*this.dx+this.dy*this.dy,p=2*(this.dx*(o.endX-o.startX)+this.dy*(o.endY-o.startY)),h=(o.endX-o.startX)*(o.endX-o.startX)+(o.endY-o.startY)*(o.endY-o.startY)-s*s,c=p*p-4*l*h;if(c>=0){t.fillStyle=i.activeObj.strokeSettings.strokeColor;var r=(-p-Math.sqrt(c))/(2*l),a=o.endX+this.dx*r,n=o.endY+this.dy*r;e?(this.startCircleIntersectX1=a,this.startCircleIntersectY1=n,"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(t,this.endCircleIntersectX1,this.endCircleIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(t,o.endX,o.endY,this.startCircleIntersectX1,this.startCircleIntersectY1)):(this.endCircleIntersectX1=a,this.endCircleIntersectY1=n,t.beginPath(),t.fill(),t.beginPath(),"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(t,o.endX,o.endY,this.endCircleIntersectX1,this.endCircleIntersectY1))}var d=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=d}},t.prototype.arrowCircleSolid=function(t,e){var i=this.parent,o=i.activeObj.activePoint;if(e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);r=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,t.save(),t.beginPath(),t.arc(o.endX,o.endY,r,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}else if(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.circle.width+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,t.save(),t.beginPath(),t.arc(o.startX,o.startY,r,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}},t.prototype.arrowBar=function(t,e){var i=this.parent,o=i.activeObj.activePoint;if(e&&"left"===i.activeObj.triangleDirection||!e&&"right"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&("bar"===i.activeObj.end&&"none"===i.activeObj.start||"bar"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.bar.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.bar.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;n=Math.atan2(this.dy,this.dx);t.translate(o.endX,o.endY),t.rotate(n),t.fillRect(a/4-r,-a/2,r,a),t.rotate(-n),t.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=n}else if(e&&"right"===i.activeObj.triangleDirection||!e&&"left"===i.activeObj.triangleDirection){t.lineWidth=i.activeObj.strokeSettings.strokeWidth,t.beginPath(),t.fillStyle=i.activeObj.strokeSettings.strokeColor,(e&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!e&&"bar"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(t,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.bar.width+i.activeObj.strokeSettings.strokeWidth,a=this.arrowDimension.bar.height+i.activeObj.strokeSettings.strokeWidth;this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var n=Math.atan2(this.dy,this.dx);t.translate(o.startX,o.startY),t.rotate(n),t.fillRect(a/4-r,-a/2,r,a),t.rotate(-n),t.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=n}},t.prototype.shapeText=function(t){for(var e=this.parent,i=e.activeObj.activePoint,o=e.activeObj.keyHistory.split("\n"),r=((e.activeObj.textSettings.fontSize+.25*e.activeObj.textSettings.fontSize)*o.length-e.activeObj.textSettings.fontSize*o.length)/o.length,a=0;a<o.length;a++){var n=o[a],s=(a+1)*e.activeObj.textSettings.fontSize*.85+a*r;-360===e.transform.degree&&(e.transform.degree=0),0===e.transform.degree||180===e.transform.degree?e.activeObj.textSettings.fontSize>i.height&&(e.activeObj.textSettings.fontSize=i.height-.1*i.height):e.activeObj.textSettings.fontSize>i.width&&(e.activeObj.textSettings.fontSize=i.width-.1*i.width),t.strokeStyle=e.activeObj.strokeSettings.strokeColor,t.fillStyle=e.activeObj.strokeSettings.strokeColor;var l="";e.activeObj.textSettings.bold&&(l="bold "),e.activeObj.textSettings.italic&&(l="italic "),e.activeObj.textSettings.bold&&e.activeObj.textSettings.italic&&(l="italic bold "),t.font=l+e.activeObj.textSettings.fontSize+"px "+e.activeObj.textSettings.fontFamily,4===e.activeObj.flipObjColl.length&&(e.activeObj.flipObjColl=[],e.activeObj.shapeFlip="");for(var p=0,h=e.activeObj.flipObjColl.length;p<h;p++)"horizontal"===e.activeObj.flipObjColl[p].toLowerCase()?(t.translate(t.canvas.width,0),t.scale(-1,1),i=this.updateActPoint("horizontal",t)):"vertical"===e.activeObj.flipObjColl[p].toLowerCase()&&(t.translate(0,t.canvas.height),t.scale(1,-1),i=this.updateActPoint("vertical",t));e.activeObj.shapeDegree!==e.transform.degree?this.rotateText(t):t.fillText(n,i.startX+.1*e.activeObj.textSettings.fontSize,i.startY+s);for(var c=0,h=e.activeObj.flipObjColl.length;c<h;c++)"horizontal"===e.activeObj.flipObjColl[c].toLowerCase()?(t.translate(t.canvas.width,0),t.scale(-1,1),i=this.updateActPoint("horizontal",t)):"vertical"===e.activeObj.flipObjColl[c].toLowerCase()&&(t.translate(0,t.canvas.height),t.scale(1,-1),i=this.updateActPoint("vertical",t))}e.currObjType.isText=!1},t.prototype.updateActPoint=function(t,e){var i=this.parent,o=i.activeObj.activePoint;return"horizontal"===t.toLowerCase()?o.startX<=e.canvas.width/2?(o.startX=e.canvas.width/2+(e.canvas.width/2-o.endX),o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):o.startX>=e.canvas.width/2&&(o.startX=e.canvas.width-o.endX,o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):"vertical"===t.toLowerCase()&&(o.startY<=e.canvas.height/2?(o.startY=e.canvas.height/2+(e.canvas.height/2-o.endY),o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj)):o.startY>=e.canvas.height/2&&(o.startY=e.canvas.height-o.endY,o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj))),o},t.prototype.rotateText=function(t){var e,i=this.parent,o=i.activeObj.activePoint.startX,r=i.activeObj.activePoint.startY,a=i.activeObj.activePoint;if(-450===(e=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)&&(e=-90),e<0&&(e=360+e),e%360!=0||-360===i.transform.degree&&""!==i.transform.currFlipState)e%90==0&&e%180!=0?(t.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),t.rotate(Math.PI/180*e),t.translate(-i.lowerCanvas.height/2,-i.lowerCanvas.width/2),e%90==0&&e%270!=0?(r=i.lowerCanvas.width-a.endX+.4*i.activeObj.textSettings.fontSize,o=a.startY):e%270==0&&(o=i.lowerCanvas.height-a.endY,r=a.startX+.4*i.activeObj.textSettings.fontSize),this.textFlipDegree(t,o,r),t.translate(i.lowerCanvas.height/2,i.lowerCanvas.width/2),t.rotate(Math.PI/180*-e),t.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):(t.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),t.rotate(Math.PI/180*e),o=i.lowerCanvas.width-a.endX,r=i.lowerCanvas.height-a.endY+.4*i.activeObj.textSettings.fontSize,t.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2),this.textFlipDegree(t,o,r),t.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),t.rotate(Math.PI/180*-e),t.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2));else{o=a.startX+.15*i.activeObj.textSettings.fontSize,r=a.startY+(a.endY-a.startY);for(var n=i.activeObj.keyHistory.split("\n"),s=0;s<n.length;s++)r=a.startY+(s*i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize),t.fillText(n[s],o,r)}360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},t.prototype.textFlipDegree=function(t,e,i){for(var o=this.parent,r=o.activeObj.keyHistory.split("\n"),a=(o.activeObj.textSettings.fontSize*r.length-o.activeObj.textSettings.fontSize*r.length)/r.length,n=.85*o.activeObj.textSettings.fontSize+a,s=0;s<r.length;s++){var l=r[s];s>0&&(1===s&&(n-=.85*o.activeObj.textSettings.fontSize),n+=o.activeObj.textSettings.fontSize+.15*o.activeObj.textSettings.fontSize),t.fillText(l,e+.15*o.activeObj.textSettings.fontSize,i+n+(s>0?.25*o.activeObj.textSettings.fontSize:.35*-o.activeObj.textSettings.fontSize))}},t.prototype.clearOuterCanvas=function(t){var e=this.parent,i=e.img.destLeft,o=e.img.destTop;if(e.img.destWidth<e.lowerCanvas.width){var r=e.img.destLeft>0?e.img.destLeft:0;t.clearRect(0,0,r,e.lowerCanvas.height),t.clearRect(e.img.destLeft+e.img.destWidth,0,r,e.lowerCanvas.height)}if(e.img.destHeight<e.lowerCanvas.height){var a=e.img.destTop>0?e.img.destTop:0;t.clearRect(0,0,e.lowerCanvas.width,a),t.clearRect(0,e.img.destTop+e.img.destHeight,e.lowerCanvas.width,a)}""!==e.transform.currFlipState&&(e.img.destLeft=i,e.img.destTop=o)},t.prototype.setDestPoints=function(){var t,e=this.parent;if(e.transform.degree%90==0&&e.transform.degree%180!=0){i={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.img.srcHeight,height:e.img.srcWidth,obj:i}}),t=i,this.isRotateZoom&&(t.width+=t.width*e.transform.zoomFactor,t.height+=t.height*e.transform.zoomFactor,e.img.destWidth=t.height,e.img.destHeight=t.width),e.img.destLeft=(e.lowerCanvas.clientWidth-t.height)/2,e.img.destTop=(e.lowerCanvas.clientHeight-t.width)/2,e.img.destWidth=t.height,e.img.destHeight=t.width}else{var i={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.img.srcWidth,height:e.img.srcHeight,obj:i}}),t=i,this.isRotateZoom&&(t.width+=t.width*e.transform.zoomFactor,t.height+=t.height*e.transform.zoomFactor,e.img.destWidth=t.width,e.img.destHeight=t.height),e.img.destLeft=(e.lowerCanvas.clientWidth-t.width)/2,e.img.destTop=(e.lowerCanvas.clientHeight-t.height)/2,e.img.destWidth=t.width,e.img.destHeight=t.height}},t.prototype.updateCurrTransState=function(t,i,o){var r=this.parent,a=r.img.destLeft,n=r.img.destTop;"initial"===t&&(this.lowerContext.setTransform(1,0,0,1,0,0),e.isNullOrUndefined(i)&&this.setDestPoints()),this.currTransState(t,null,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&(r.img.destLeft=a,r.img.destTop=n),(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&(o&&(r.img.destLeft+=r.panPoint.totalPannedClientPoint.x,r.img.destTop+=r.panPoint.totalPannedClientPoint.y),r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o&&(r.img.destLeft-=r.panPoint.totalPannedClientPoint.x,r.img.destTop-=r.panPoint.totalPannedClientPoint.y))},t.prototype.currTransState=function(t,i,o,r){var a=this.parent;o=o||this.lowerContext,"initial"===t?this.setTransformColl(o,t):"reverse"===t&&(this.setTransformColl(o,t),this.setClientTransDim(i),(a.isCircleCrop||a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape&&e.isNullOrUndefined(r))&&(r&&(a.img.destLeft+=a.panPoint.totalPannedClientPoint.x,a.img.destTop+=a.panPoint.totalPannedClientPoint.y),a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r&&(a.img.destLeft-=a.panPoint.totalPannedClientPoint.x,a.img.destTop-=a.panPoint.totalPannedClientPoint.y)))},t.prototype.setTransformColl=function(t,e){var i=this.parent;if("initial"===e)for(var o=0,r=i.rotateFlipColl.length;o<r;o++)this.setTransform(t,i.rotateFlipColl[o]);else if("reverse"===e)for(o=i.rotateFlipColl.length-1;o>=0;o--)this.setTransform(t,i.rotateFlipColl[o],!0)},t.prototype.setTransform=function(t,i,o){var r=this.parent;switch(o&&90===i?i=-90:o&&-90===i&&(i=90),"horizontal"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0?i="vertical":"vertical"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0&&(i="horizontal"),r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),e.isNullOrUndefined(o)&&t.clearRect(0,0,t.canvas.width,t.canvas.height),i){case 90:case-90:t.translate(t.canvas.width/2,t.canvas.height/2),t.rotate(Math.PI/180*i),t.translate(-t.canvas.width/2,-t.canvas.height/2);break;case"horizontal":t.translate(t.canvas.width,0),t.scale(-1,1);break;case"vertical":t.translate(0,t.canvas.height),t.scale(1,-1)}r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!1}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}})},t.prototype.drawImgToCanvas=function(t){var e=this.parent;this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.img.destWidth=t.width,e.img.destHeight=t.height,this.isInitialLoading&&(e.notify("filter",{prop:"initFilter",onPropertyChange:!1}),this.isInitialLoading=!1);var i=this.lowerContext.filter;e.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.lowerContext.drawImage(e.baseImg,e.img.srcLeft,e.img.srcTop,e.img.srcWidth,e.img.srcHeight,e.img.destLeft,e.img.destTop,e.img.destWidth,e.img.destHeight),(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.lowerContext.filter=i},t.prototype.renderImage=function(t){var e=this.parent,i=this.lowerContext.filter;e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),this.upperContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),t?this.setTransformColl(this.lowerContext,"initial"):(e.transform.zoomFactor>0&&(this.isRotateZoom=!0),this.updateCurrTransState("initial")),e.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),e.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.lowerContext.drawImage(e.baseImg,e.img.srcLeft,e.img.srcTop,e.img.srcWidth,e.img.srcHeight,e.img.destLeft,e.img.destTop,e.img.destWidth,e.img.destHeight),e.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),t?this.setTransformColl(this.lowerContext,"reverse"):(this.updateCurrTransState("reverse"),this.isRotateZoom=!1),this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),e.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=i,(e.isCircleCrop||e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},t.prototype.imageOnLoad=function(t){var o=this,r=this.parent,a=this;r.baseImg.src=t,r.baseImg.onload=function(){if(r.notify("filter",{prop:"update-finetunes",onPropertyChange:!1}),a.lowerContext.drawImage(r.baseImg,0,0,a.parent.lowerCanvas.width,a.parent.lowerCanvas.height),i.hideSpinner(r.element),r.element.style.opacity="1",a.updateCanvas(),r.currObjType.isUndoZoom&&(r.currObjType.isUndoZoom=!1,a.parent.lowerCanvas.style.display="block"),r.isUndoRedo=o.isErrorImage=!1,e.isBlazor())r.updateToolbar(r.element,"imageLoaded","initial"),e.Browser.isDevice&&(r.element.querySelector(".e-bottom-toolbar-area").style.display="block",r.element.querySelector(".e-canvas-wrapper").style.height=r.element.offsetHeight-2*r.toolbarHeight-3+"px");else if(e.Browser.isDevice){r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),r.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1});t={isApplyBtn:!1,isDevice:e.Browser.isDevice,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:t}),r.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1})}else{r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1});var t={isApplyBtn:!1,isDevice:!1,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:t})}},r.baseImg.onerror=function(){i.hideSpinner(r.element),a.isErrorImage=!0,a.errorLoading()}},t.prototype.errorLoading=function(){var t=this.parent,i={fileName:null,fileType:null,isValidImage:!1};e.isBlazor()&&t.events&&!0===t.events.fileOpened.hasDelegate?t.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):t.trigger("fileOpened",i)},t.prototype.updateCanvas=function(){var t=this.parent,i={fileName:this.fileName,fileType:this.fileType,isValidImage:!0};t.img.srcWidth=t.baseImg.width,t.img.srcHeight=t.baseImg.height;var o={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcWidth,height:t.img.srcHeight,obj:o}});var r=o;t.img.destLeft=(t.lowerCanvas.clientWidth-r.width)/2,t.img.destTop=(t.lowerCanvas.clientHeight-r.height)/2,this.drawImgToCanvas(r),this.zoomCrop.width=t.img.destWidth,this.zoomCrop.height=t.img.destHeight,t.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:t.img.destWidth,height:t.img.destHeight}});var a={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};t.notify("crop",{prop:"setCropDestPoints",onPropertyChange:!1,value:{point:a}});var n=this.lowerContext.filter;this.lowerContext.filter="none",t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n,t.img.destWidth>0&&t.img.destHeight>0&&(t.isImageLoaded=!0),t.isUndoRedo&&""!==t.transform.currFlipState&&t.notify("transform",{prop:"flipImage",onPropertyChange:!1,value:{direction:t.toPascalCase(t.transform.currFlipState)}}),t.disabled&&t.element.setAttribute("class","e-disabled"),t.isImageLoaded&&"0.5"!==t.element.style.opacity&&(e.isBlazor()&&t.events&&!0===t.events.fileOpened.hasDelegate?t.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):t.trigger("fileOpened",i)),(1!==t.zoomSettings.zoomFactor||t.zoomSettings.zoomPoint)&&t.zoom(t.zoomSettings.zoomFactor,t.zoomSettings.zoomPoint),e.isNullOrUndefined(this.initZoomValue)&&(this.initZoomValue=t.zoomSettings.zoomFactor),this.isImageEdited=!1},t.prototype.performCancel=function(t){var i=this.parent;t=t||!1;var o={bool:!1};if(i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:o}}),o.bool)i.notify("freehand-draw",{prop:"cancelFhd",onPropertyChange:!1}),e.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}});else if("block"===i.textArea.style.display)i.textArea.style.display="none",i.textArea.value="",i.textArea.style.transform="",this.prevActObj?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.activeObj.strokeSettings=this.tempStrokeSettings,i.activeObj.textSettings=this.tempTextSettings),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),this.isShapeTextInserted&&i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(!e.isBlazor()&&document.querySelector("#"+i.element.id+"_sliderWrapper")||e.isBlazor()&&!i.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||i.currObjType.isFiltered){this.lowerContext.filter=this.tempAdjValue,i.canvasFilter=this.tempAdjValue,i.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.tempAdjValue}}),i.initialAdjustmentValue=this.tempAdjValue,this.lowerContext.filter.split(" ").length>1&&"1"===this.lowerContext.filter.split(" ")[0].split("(")[1].split(")")[0]&&i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:!1}}),i.currentFilter=this.tempFilter,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.redrawImgWithObj(),i.currObjType.isFiltered=!1;var r={tempAdjustmentLevel:null};i.notify("filter",{prop:"getTempAdjustmentLevel",onPropertyChange:!1,value:{obj:r}}),i.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:e.extend({},r.tempAdjustmentLevel,{},!0)}}),i.notify("undo-redo",{prop:"setUndoRedoStep",onPropertyChange:!1,value:{step:this.tempUndoRedoStep}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.clearOuterCanvas(this.lowerContext),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}});a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})}else if(t){var a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})}else this.cancelItems(),i.togglePan=!1,i.notify("selection",{prop:"setDragCanvas",value:{bool:!1}});this.isShapeTextInserted=!1,this.isNewPath=!1,e.isBlazor()||(i.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}))},t.prototype.cancelItems=function(){var t,i=this.parent,o=!1,r=["rectangle","ellipse","line","arrow","path"];void 0!==i.activeObj.shape&&(t=i.activeObj.shape.split("-")),void 0===t&&i.currObjType.isCustomCrop?o=!0:void 0!==t&&"crop"===t[0]&&(o=!0),o&&i.isCropTab&&(i.isCropTab=!1,i.transform.zoomFactor=i.transform.defaultZoomFactor),i.togglePen?this.cancelPen():"text"===i.activeObj.shape?this.cancelText(o):-1!==r.indexOf(i.activeObj.shape)?this.cancelShape():o?this.cancelSelection():(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})),i.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null};var a={type:"main",isApplyBtn:null,isCropping:!1,isZooming:null};e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})},t.prototype.cancelPen=function(){var t=this.parent;this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.togglePen=!1,t.upperCanvas.style.cursor=t.cursor="default";var i=e.extend([],t.pointColl,[],!0);t.pointColl={};for(var o=0;o<this.tempFreehandCounter;o++)t.pointColl[o]=i[o];t.freehandCounter=this.tempFreehandCounter,t.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:this.tempCurrFhdIndex}}),t.activeObj.strokeSettings=this.tempStrokeSettings,t.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:t.activeObj.strokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),t.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},t.prototype.cancelText=function(t){var i=this.parent;if(i.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:this.tempTextSettings,fontFamily:null,fontSize:null}}),i.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),e.isNullOrUndefined(i.activeObj.currIndex))i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height);else{var o={appliedUndoRedoColl:[]};i.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:o}});var r=o.appliedUndoRedoColl.length;this.prevActObj&&o.appliedUndoRedoColl[r-1]&&o.appliedUndoRedoColl[r-1].currentObjColl[o.appliedUndoRedoColl[r-1].currentObjColl.length-1].currIndex===this.prevActObj.currIndex?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height)),i.activeObj.shape&&"Enter Text"===i.activeObj.keyHistory?(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"draw-shape-text"}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):i.activeObj.shape&&(i.notify("shape",{prop:"redraw-text"}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.activeObj}}),t||void 0===i.activeObj.topLeftCircle||i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),i.clearSelection())}e.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1}},t.prototype.cancelShape=function(){var t=this.parent;if(t.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),e.isNullOrUndefined(t.activeObj.currIndex))t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height);else if(this.isNewPath)t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.renderImage();else{var i={appliedUndoRedoColl:[]};t.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:i}});var o=i.appliedUndoRedoColl.length;this.prevActObj&&i.appliedUndoRedoColl[o-1]&&i.appliedUndoRedoColl[o-1].currentObjColl[i.appliedUndoRedoColl[o-1].currentObjColl.length-1].currIndex===this.prevActObj.currIndex?(t.activeObj=this.prevActObj,this.prevActObj=null,t.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:t.activeObj}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):(t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height))}t.currObjType.isDragging=!1,e.isBlazor()?t.updateToolbar(t.element,"destroyQuickAccessToolbar"):t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})},t.prototype.cancelSelection=function(){var t=this.parent;t.cancelCropSelection&&(t.cropObj=e.extend({},t.cancelCropSelection.previousCropObj,{},!0),t.afterCropActions=t.cancelCropSelection.previousObj.afterCropActions,t.notify("undo-redo",{prop:"undoDefault",onPropertyChange:!1,value:{obj:t.cancelCropSelection}}),t.currSelectionPoint=e.extend({},t.cancelCropSelection.previousCropObj.activeObj,!0),t.currSelectionPoint&&e.isNullOrUndefined(t.currSelectionPoint.shape)&&(t.currSelectionPoint=null),this.clearOuterCanvas(this.lowerContext),(t.isCircleCrop||t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}))},t.prototype.updateFlipPan=function(t){var e=this.parent;if(""!==e.transform.currFlipState){var i=this.lowerContext.filter;e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("transform",{prop:"rotatedFlip",onPropertyChange:!1}),this.lowerContext.filter="none",e.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=i,this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),t&&this.drawObject("duplicate",t)}},t.prototype.select=function(t,i,o,r,a){var n=this.parent;if(!n.disabled&&n.isImageLoaded){var s={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=e.extend([],n.objColl,[],!0),l.pointColl=e.extend([],n.pointColl,[],!0),l.afterCropActions=n.afterCropActions;var p={selPointColl:null};n.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=e.extend([],p.selPointColl,[],!0),n.notify("crop",{prop:"setPreviousCropCurrentObj",onPropertyChange:!1,value:{obj:l}}),n.transform.zoomFactor>0&&n.activeObj.shape&&"crop"===n.activeObj.shape.split("-")[0]&&e.isNullOrUndefined(this.currSelPoint)&&(this.currSelPoint=e.extend({},n.activeObj,{},!0));var h=!1,c=void 0;void 0!==n.activeObj.shape&&(c=n.activeObj.shape.split("-")),void 0===c&&n.currObjType.isCustomCrop?h=!0:void 0!==c&&"crop"===c[0]&&(h=!0);var d={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:d}});var v=d.currObj;if(v.objColl=e.extend([],n.objColl,[],!0),v.pointColl=e.extend([],n.pointColl,[],!0),v.afterCropActions=e.extend([],n.afterCropActions,[],!0),n.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),n.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.upperCanvas.style.display="block",n.currSelectionPoint||0!==n.transform.defaultZoomFactor||0!==n.transform.degree&&0!==n.panPoint.totalPannedInternalPoint.x&&0!==n.panPoint.totalPannedInternalPoint.y&&!h){if(n.isCircleCrop=!1,0!==n.transform.defaultZoomFactor){var u=n.isCropTab;n.isCropTab=!1,n.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),n.isCropTab=u,this.resetPanPoints()}this.cancelObjColl=e.extend([],n.objColl,[],!0),this.cancelPointColl=e.extend([],n.pointColl,[],!0),n.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),n.isCropTab=!0,n.isCircleCrop=!1,n.notify("crop",{prop:"setCurrSelPoints",onPropertyChange:!1,value:{isSetDimension:!0}}),n.transform.zoomFactor=n.transform.cropZoomFactor,e.isNullOrUndefined(n.cropObj.activeObj.shape)&&(n.currObjType.shape="crop-"+t.toLowerCase(),this.drawNewSelection(t,i,o,r,a))}else"custom"===t&&(n.currObjType.shape=""),this.drawNewSelection(t,i,o,r,a)}},t.prototype.drawNewSelection=function(t,e,i,o,r){var a,n=this.parent,s="crop-"+t;"crop-custom"===s.toLowerCase()?""!==n.currObjType.shape&&"crop-custom"!==n.currObjType.shape||this.drawCustomSelection("crop-custom",e,i,o,r):"crop-canvas"===s.toLowerCase()?(n.upperCanvas.style.display="block",n.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(n.currObjType.isCustomCrop=!1,n.currObjType.shape=s.toLowerCase(),o&&r?a={startX:e,startY:i,endX:e+o,endY:i+r,width:o,height:r}:o&&"crop-circle"===s&&(a={startX:e,startY:i,endX:e+o,endY:i+o,width:o,height:o}),n.activeObj.shape=s.toLowerCase(),this.updateSelectionInsert(a))},t.prototype.updateSelectionInsert=function(t){var i=this,o=this.parent,r=o.activeObj.activePoint,a={shapeSettingsObj:{}};o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n={type:o.getSelectionType(a.shapeSettingsObj.type),startX:a.shapeSettingsObj.startX,startY:a.shapeSettingsObj.startY,width:a.shapeSettingsObj.width,height:a.shapeSettingsObj.height},s={action:"insert",previousSelectionSettings:n,currentSelectionSettings:n};e.isBlazor()&&o.events&&!0===o.events.onSelectionResizeStart.hasDelegate?o.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(e){o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:e.currentSelectionSettings}}),"Custom"===e.currentSelectionSettings.type?i.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(t={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),i.drawObject("duplicate",null,!0,t))}):(o.trigger("selectionChanging",s),o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}),"Custom"===s.currentSelectionSettings.type?this.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(t={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),this.drawObject("duplicate",null,!0,t)))},t.prototype.drawCustomSelection=function(t,i,o,r,a){var n=this.parent,s=n.activeObj.activePoint;if(n.currObjType.isCustomCrop=!0,this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.currObjType.shape=n.activeObj.shape=t.toLowerCase(),e.isNullOrUndefined(i)||e.isNullOrUndefined(o)||e.isNullOrUndefined(r)||e.isNullOrUndefined(a)){if(e.isNullOrUndefined(n.transform.zoomFactor)||0===n.transform.zoomFactor){var l=n.img.destLeft,p=n.img.destTop,h=n.img.destWidth,c=n.img.destHeight,d=n.lowerCanvas.width,v=n.lowerCanvas.height,u=s;l>=0&&p>=0?(u.startX=l,u.startY=p,u.endX=l+h,u.endY=p+c):l>=0?(u.startX=l,u.startY=7.5,u.endX=l+h,u.endY=v-15):p>=0?(u.startX=7.5,u.startY=p,u.endX=d-15,u.endY=p+c):(u.startX=7.5,u.startY=7.5,u.endX=d-15,u.endY=v-15)}else{var g=n.img.destLeft,b=n.img.destTop,C=n.img.destWidth,f=n.img.destHeight,m=n.lowerCanvas.width,y=n.lowerCanvas.height,P=s;P.startX=Math.max(g>0?g:7.5,g),P.startY=Math.max(b>0?b:7.5,b),P.endX=Math.min(g+C+15<m?g+C-15:m-15,g+C),P.endY=Math.min(b+f+15<y?b+f-15:y-15,b+f)}var j=n.img.destLeft,O=n.img.destTop,x=n.img.destWidth,w=n.img.destHeight,S=n.lowerCanvas.clientWidth,T=n.lowerCanvas.clientHeight,k=s;k.startX=Math.max(k.startX,j),k.startY=Math.max(k.startY,O),k.endX=Math.min(k.endX,j+x),k.endY=Math.min(k.endY,O+w),k.startX===j&&j+x>S&&(k.endX=S-15),k.startY===O&&O+w>T&&(k.endY=T-15),n.activeObj=this.updateWidthHeight(n.activeObj),this.updateActiveObject(s,n.activeObj)}else s.startX=i,s.startY=o,s.endX=i+r,s.endY=o+a,s.width=r,s.height=a;this.updateSelectionInsert()},t.prototype.callUpdateCurrTransState=function(){var t=this.parent,i=e.extend([],t.objColl,[],!0),o=e.extend({},t.activeObj,{},!0);t.objColl=[],t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isRotateZoom=!0,this.updateCurrTransState("initial"),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),0===t.transform.degree&&t.rotateFlipColl.length>0&&(t.img.destLeft+=t.panPoint.totalPannedPoint.x,t.img.destTop+=t.panPoint.totalPannedPoint.y),t.img.destLeft+=t.panPoint.totalPannedInternalPoint.x,t.img.destTop+=t.panPoint.totalPannedInternalPoint.y;var r=this.lowerContext.filter;0===t.transform.degree&&t.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),t.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.updateCurrTransState("reverse"),0===t.transform.degree&&t.rotateFlipColl.length>0&&(t.img.destLeft+=t.panPoint.totalPannedPoint.x,t.img.destTop+=t.panPoint.totalPannedPoint.y),this.isRotateZoom=!1,t.objColl=i;var a=t.togglePen;t.togglePen=!1,this.lowerContext.filter="none",t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),t.img.destLeft+=t.panPoint.totalPannedInternalPoint.x,t.img.destTop+=t.panPoint.totalPannedInternalPoint.y,t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),t.img.destLeft-=t.panPoint.totalPannedInternalPoint.x,t.img.destTop-=t.panPoint.totalPannedInternalPoint.y,t.togglePen=a,this.lowerContext.filter=r,t.activeObj=o},t.prototype.resetPanPoints=function(){this.parent.panPoint.totalPannedPoint={x:0,y:0},this.parent.panPoint.totalPannedClientPoint={x:0,y:0},this.parent.panPoint.totalPannedInternalPoint={x:0,y:0}},t.prototype.setClientTransDim=function(t){var i=this.parent;if(i.transform.degree%90==0&&i.transform.degree%180!=0){i.img.destLeft=(i.lowerCanvas.width-i.img.destHeight)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destWidth)/2;var o=i.img.destWidth;i.img.destWidth=i.img.destHeight,i.img.destHeight=o}else e.isNullOrUndefined(t)&&(i.img.destLeft=(i.lowerCanvas.width-i.img.destWidth)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destHeight)/2)},t.prototype.redrawImgWithObj=function(){var t=this.parent,i={canvasFilter:t.canvasFilter};if(this.lowerContext.filter=i.canvasFilter,0!==t.rotateFlipColl.length){var o=e.extend({},t.panPoint.totalPannedInternalPoint,{},!0),r={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};this.callUpdateCurrTransState(),t.panPoint.totalPannedInternalPoint=o,t.img.destLeft=r.startX,t.img.destTop=r.startY,t.img.destWidth=r.width,t.img.destHeight=r.height}else this.callUpdateCurrTransState();t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}});var a=this.lowerContext.filter;this.lowerContext.filter=t.getDefaultFilter(),t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=a},t.prototype.setCurrentObj=function(t){var i=this.parent,o=!!t;t=t||i.cropObj,i.transform.cropZoomFactor=t.cropZoom,i.transform.defaultZoomFactor=t.defaultZoom,o?t.activeObj.shape&&"crop"===t.activeObj.shape.split("-")[0]?i.transform.zoomFactor=t.cropZoom:i.transform.zoomFactor=t.defaultZoom:i.transform.zoomFactor=t.cropZoom,i.setProperties({zoomSettings:{zoomFactor:t.zoomFactor}},!0),i.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:t.previousZoomValue}}),i.panPoint.totalPannedPoint=e.extend({},t.totalPannedPoint,{},!0),i.panPoint.totalPannedClientPoint=e.extend({},t.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=e.extend({},t.totalPannedInternalPoint,{},!0);var r=e.extend({},t.tempFlipPanPoint,{},!0);i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:r}}),i.rotateFlipColl=e.extend([],t.rotateFlipColl,[],!0),i.transform.degree=t.degree,i.transform.currFlipState=t.currFlipState,i.img.destLeft=t.destPoints.startX,i.img.destTop=t.destPoints.startY,i.img.destWidth=t.destPoints.width,i.img.destHeight=t.destPoints.height,i.img.srcLeft=t.srcPoints.startX,i.img.srcTop=t.srcPoints.startY,i.img.srcWidth=t.srcPoints.width,i.img.srcHeight=t.srcPoints.height,t.afterCropActions&&(i.afterCropActions=t.afterCropActions),this.lowerContext.filter=t.filter,i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:!1}});var a,n=i.isCircleCrop;e.isNullOrUndefined(i.currSelectionPoint)?a=null:(a=e.extend({},i.currSelectionPoint,{},!0),i.currSelectionPoint=null),i.isCircleCrop=!1,this.drawCropSelectionImage(t,!1),0!==i.transform.degree&&(""===i.transform.currFlipState?i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}):i.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),i.img.destLeft=t.destPoints.startX,i.img.destTop=t.destPoints.startY,i.panPoint.totalPannedClientPoint=e.extend({},t.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=e.extend({},t.totalPannedInternalPoint,{},!0)),i.activeObj=e.extend({},t.activeObj,{},!0),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0);var s=e.extend({},t.activeObj,{},!0),l=!1;if(i.afterCropActions.length>0){var p={collection:i.afterCropActions};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.afterCropActions,isRotateFlipCollection:null,obj:p}}),i.afterCropActions=p.collection}var h=e.extend([],i.afterCropActions,[],!0);if(!o&&h.length>0){l=!0;for(var c=0;c<h.length;c++)"horizontalflip"!==h[c]&&"verticalflip"!==h[c]||(i.activeObj=e.extend({},a,{},!0),this.rotatedFlipCropSel=!0),i.notify("transform",{prop:"updateTransform",onPropertyChange:!1,value:{text:h[c]}});s=e.extend({},i.activeObj,{},!0),this.resetPanPoints(),i.activeObj=s,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0),t.degree!==i.transform.degree&&(i.transform.cropZoomFactor=null,i.transform.zoomFactor=0),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.rotatedFlipCropSel&&(this.rotatedFlipCropSel=!1)}i.afterCropActions=h,this.isCancelAction||l||(i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=t.destPoints.startX,i.img.destTop=t.destPoints.startY),i.activeObj=s,i.isCircleCrop=n,e.isNullOrUndefined(a)?i.currSelectionPoint=null:(i.currSelectionPoint=e.extend({},a,{},!0),i.currSelectionPoint&&e.isNullOrUndefined(i.currSelectionPoint.shape)&&(i.currSelectionPoint=null))},t.prototype.drawCropSelectionImage=function(t,i){var o=this.parent,r=this.lowerContext.filter;o.clearContext(this.lowerContext),o.clearContext(this.upperContext),this.lowerContext.setTransform(1,0,0,1,0,0),i?this.updateCurrTransState("initial"):this.setTransformColl(this.lowerContext,"initial"),o.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.lowerContext.drawImage(o.baseImg,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,o.img.destLeft,o.img.destTop,o.img.destWidth,o.img.destHeight),i?this.updateCurrTransState("reverse"):this.setTransformColl(this.lowerContext,"reverse"),o.img.destLeft=o.cropObj.destPoints.startX,o.img.destTop=o.cropObj.destPoints.startY;var a=e.extend({},t.activeObj,{},!0);if(this.lowerContext.filter="none",this.isCancelAction)o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}});else{o.img.destLeft=t.destPoints.startX,o.img.destTop=t.destPoints.startY,o.img.destWidth=t.destPoints.width,o.img.destHeight=t.destPoints.height,o.img.srcLeft=t.srcPoints.startX,o.img.srcTop=t.srcPoints.startY,o.img.srcWidth=t.srcPoints.width,o.img.srcHeight=t.srcPoints.height;var n={startX:o.img.destLeft,startY:o.img.destTop,width:o.img.destWidth,height:o.img.destHeight};o.img.destLeft=t.activeObj.activePoint.startX,o.img.destTop=t.activeObj.activePoint.startY,o.img.destWidth=t.activeObj.activePoint.width,o.img.destHeight=t.activeObj.activePoint.height,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.img.destLeft=n.startX,o.img.destTop=n.startY,o.img.destWidth=n.width,o.img.destHeight=n.height}o.activeObj=a,this.lowerContext.filter=r},t.prototype.performPointZoom=function(t,i,o){var r=this.parent,a=(t-r.img.destLeft)/r.img.destWidth,n=(i-r.img.destTop)/r.img.destHeight,s=r.isUndoRedo;if(r.isUndoRedo=!0,r.setProperties({zoomSettings:{zoomPoint:{x:t,y:i}}},!0),"zoomIn"===o?r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}}):"zoomOut"===o&&r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}}),r.isUndoRedo=s,r.transform.zoomFactor>0){var l=r.img.destLeft,p=r.img.destTop,h=e.extend({},r.activeObj,{},!0);if(0===r.transform.degree)r.img.destLeft=t-a*r.img.destWidth,r.img.destTop=i-n*r.img.destHeight,this.drawZoomPanImage(r.img.destLeft-l,r.img.destTop-p);else{var c=r.isCropTab;r.isCropTab=!0;var d=e.extend([],r.objColl,[],!0),v=e.extend([],r.pointColl,[],!0);r.objColl=[],r.pointColl=[],r.freehandCounter=0;var u={selPointColl:null};r.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:u}});var g=u.selPointColl;r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),r.panPoint.currentPannedPoint={x:t-a*r.img.destWidth-l,y:i-n*r.img.destHeight-p},r.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),r.isCropTab=c,r.objColl=d,r.pointColl=v,r.freehandCounter=r.pointColl.length,r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:g}}}),r.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}}),r.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}})}this.adjustPanning(h),r.activeObj=h,0!==r.activeObj.activePoint.width&&0!==r.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0)}},t.prototype.adjustPanning=function(t){var i=this.parent;if(0!==t.activePoint.width&&0!==t.activePoint.height){var o=i.img.destLeft,r=i.img.destTop,a={x:0,y:0};if(i.img.destLeft>t.activePoint.startX?a.x=i.img.destLeft-t.activePoint.startX:i.img.destLeft+i.img.destWidth<t.activePoint.startX+t.activePoint.width&&(a.x=i.img.destLeft+i.img.destWidth-(t.activePoint.startX+t.activePoint.width)),i.img.destTop>t.activePoint.startY?a.y=i.img.destTop-t.activePoint.startY:i.img.destTop+i.img.destHeight<t.activePoint.startY+t.activePoint.height&&(a.y=i.img.destTop+i.img.destHeight-(t.activePoint.startY+t.activePoint.height)),0===i.transform.degree)i.img.destLeft-=a.x,i.img.destTop-=a.y,this.drawZoomPanImage(i.img.destLeft-o,i.img.destTop-r);else{var n=i.isCropTab;i.isCropTab=!0;var s=e.extend([],i.objColl,[],!0),l=e.extend([],i.pointColl,[],!0);i.objColl=[],i.pointColl=[],i.freehandCounter=0;var p={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}});var h=p.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.img.destLeft-=a.x,i.img.destTop-=a.y,i.panPoint.currentPannedPoint={x:i.img.destLeft-o,y:i.img.destTop-r},i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),i.isCropTab=n,i.objColl=s,i.pointColl=l,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:h}}}),i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}})}}},t.prototype.drawZoomPanImage=function(t,e){var i=this.parent;i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:t,yDiff:e,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:t,yDiff:e,panRegion:""}}),this.renderImage(!0);var o={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i.img.srcWidth,height:i.img.srcHeight,obj:o}});var r=o;r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.panPoint.totalPannedPoint.x+=t,i.panPoint.totalPannedPoint.y+=e,i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:{x:0,y:0}}})},t.prototype.openNewImage=function(){var t=this.parent,o=t.inMemoryCanvas.getContext("2d");i.showSpinner(t.element),t.element.style.opacity="0.5";var r=document.querySelector("#"+t.element.id+"_currPos");r&&(r.style.display="none");var a={defToolbarItems:null};if(e.isBlazor())t.element.querySelector("#"+t.element.id+"_toolbarArea")&&(t.toolbarHeight=t.element.querySelector("#"+t.element.id+"_toolbarArea").clientHeight);else if(t.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:a}}),0===a.defToolbarItems.length&&e.isNullOrUndefined(document.getElementById(t.element.id+"_toolbar"))){var n=t.element.querySelector("#"+t.element.id+"_toolbarArea").clientHeight;t.notify("toolbar",{prop:"setToolbarHeight",value:{height:n}})}if(t.reset(),t.update(),t.transform.degree=0,t.transform.zoomFactor=0,t.isImageLoaded=!1,t.currSelectionPoint=null,"string"===typeof this.openURL){var s=this.openURL.split(".");if(s.length>1?(s=s[s.length-2].split("/"),this.fileName=s[s.length-1]):this.fileName="ImageEditor",this.fileType=this.getFileExtensionFromURL(this.openURL),this.fileType){this.fileType=t.toPascalCase(this.fileType);var l=this.fileType.toLowerCase();"jpg"!==l&&"jpeg"!==l||(this.fileType="Jpeg",l="jpeg"),"jpeg"!==l&&"png"!==l&&"svg"!==l&&(this.fileType=null)}this.imageOnLoad(this.openURL)}else this.fileName="ImageEditor",this.fileType=null,t.lowerCanvas=document.querySelector("#"+t.element.id+"_lowerCanvas"),t.upperCanvas=document.querySelector("#"+t.element.id+"_upperCanvas"),this.lowerContext=t.lowerCanvas.getContext("2d"),this.upperContext=t.upperCanvas.getContext("2d"),t.clearContext(this.lowerContext),t.clearContext(this.upperContext),t.clearContext(o),t.inMemoryCanvas.width=this.openURL.width,t.inMemoryCanvas.height=this.openURL.height,o.putImageData(this.openURL,0,0),t.baseImg.src=t.inMemoryCanvas.toDataURL()},t.prototype.dlgBtnClick=function(){var t=this.parent;t.export(),this.isFileChanged?(t.isImageLoaded=this.isFileChanged=!1,t.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),e.isBlazor()||e.getComponent(document.getElementById(t.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},t.prototype.dlgCloseBtnClick=function(){var t=this.parent;this.baseImgSrc=t.baseImg.src,this.isFileChanged?(t.isImageLoaded=this.isFileChanged=!1,t.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),e.isBlazor()||e.getComponent(document.getElementById(t.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},t.prototype.showDialogPopup=function(){this.parent.element.querySelector("#"+this.parent.element.id+"_dialog").style.display="block",new i.Dialog({header:"Confirm Save Changes",closeOnEscape:!0,content:"<span>Do you want to save the changes you made to the image?</span>",target:document.getElementById("target"),width:"285px",isModal:!0,animationSettings:{effect:"Zoom"},close:this.dlgCloseBtnClick.bind(this),buttons:[{click:this.dlgCloseBtnClick.bind(this),buttonModel:{content:"No",iconCss:"e-icons e-close"}},{click:this.dlgBtnClick.bind(this),buttonModel:{content:"Yes",isPrimary:!0,iconCss:"e-icons e-check"}}]}).appendTo("#"+this.parent.element.id+"_dialog")},t.prototype.restoreOldImage=function(){this.parent.isImageLoaded?(this.reset(),this.openNewImage()):this.openNewImage()},t.prototype.open=function(t){this.parent.disabled||(this.openURL=t,this.restoreOldImage())},t.prototype.getInitialLoaded=function(t){t.isInitialLoaded=this.isInitialLoading},t.prototype.getFileExtensionFromURL=function(t){var e=t.lastIndexOf(".");return-1!==e?t.slice(e+1).toLowerCase():null},t.prototype.fileSelect=function(t,o){var r=this.parent;if(!r.disabled){var a=o.target.files[0],n=a,s=n.name&&n.name.split(".")[1].toLowerCase();if(s&&-1===["jpg","jpeg","png","svg"].indexOf(s))return void this.errorLoading();if(i.showSpinner(r.element),r.element.style.opacity="0.5",this.inputElem=t,s=n.name&&n.name.split(".")[1]){var l=r.toPascalCase(s);this.fileType="JPG"===l||"Jpg"===l?"Jpeg":l}else this.fileType=null;var p=window.URL.createObjectURL(a);this.openURL=p,r.isImageLoaded&&(this.isImageEdited||r.pointColl.length>0||r.objColl.length>0)?(this.isFileChanged=!0,e.isBlazor()?r.dotNetRef.invokeMethodAsync("UpdateDialog"):this.showDialogPopup()):this.checkToolbarTemplate(t,p)}},t.prototype.checkToolbarTemplate=function(t,i){var o=this.parent;e.isNullOrUndefined(o.toolbarTemplate)&&(o.reset(),o.update()),this.fileName=t.value.split("\\")[t.value.split("\\").length-1],this.fileName=this.fileName.split(".")[0],this.imageOnLoad(i.toString()),t.value=""},t.prototype.moveToSelectionRange=function(t,i){var o=this.parent;if(o.activeObj.shape){for(var r=!1,a=0;a<o.rotateFlipColl.length;a++)if(90===o.rotateFlipColl[a]||-90===o.rotateFlipColl[a]){r=!0;break}if(r){var n=o.transform.zoomFactor;if(o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),"rotateleft"===t||"rotateright"===t)if(o.transform.degree%90==0&&o.transform.degree%180!=0)if(o.objColl[o.objColl.length-1].activePoint.width<i.activePoint.height)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}});break}n+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null}})}else for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}});break}n-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null}})}else if(o.objColl[o.objColl.length-1].activePoint.height<i.activePoint.width)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}});break}n+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null}})}else for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){e.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}});break}n-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null}})}var s=o.lowerCanvas.clientWidth/2-(o.objColl[o.objColl.length-1].activePoint.startX+o.objColl[o.objColl.length-1].activePoint.width/2),l=o.lowerCanvas.clientHeight/2-(o.objColl[o.objColl.length-1].activePoint.startY+o.objColl[o.objColl.length-1].activePoint.height/2);0===o.transform.degree?(o.img.destLeft+=s,o.img.destTop+=l,o.notify("transform",{prop:"drawPannImage",value:{point:{x:s,y:l}}})):(o.panPoint.currentPannedPoint={x:s,y:l},o.notify("transform",{prop:"drawPannedImage",value:{xDiff:s,yDiff:l}}),o.panPoint.currentPannedPoint={x:0,y:0}),o.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),o.activeObj=e.extend({},o.objColl[o.objColl.length-1]),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})}}},t.prototype.isSelectionBiggerThanCanvas=function(t){var e=!1;return(t.activePoint.startX<=this.parent.img.destLeft||t.activePoint.startY<=this.parent.img.destTop||t.activePoint.endX>=this.parent.img.destLeft+this.parent.img.destWidth||t.activePoint.endY>=this.parent.img.destTop+this.parent.img.destHeight)&&(e=!0),e},t.prototype.isSelectionOutsideCanvas=function(t){var e=!1;return(t.activePoint.height<this.parent.lowerCanvas.height-this.parent.toolbarHeight||t.activePoint.width<this.parent.lowerCanvas.width)&&(e=!0),e},t}(),l=function(){function t(t){this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("export",this.export,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("export",this.export),this.parent.off("destroyed",this.destroy)},t.prototype.export=function(t){if(e.isBlazor()){var i={shape:""};this.parent.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:i}}),""!==i.shape&&(this.parent.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),this.parent.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}else this.parent.notify("toolbar",{prop:"refreshShapeDrawing",onPropertyChange:!1});switch(this.updatePvtVar(),t.prop){case"export":this.exportImg(t.value.type,t.value.fileName);break;case"exportToCanvas":this.exportToCanvas(t.value.object)}},t.prototype.getModuleName=function(){return"export"},t.prototype.updatePvtVar=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d"))},t.prototype.exportImg=function(t,i){var o=this,r=this.parent,a={fileName:""};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n=a.fileName;if(!r.disabled&&r.isImageLoaded){var s={bool:!1};r.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool&&r.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),r.togglePen&&(r.currObjType.isZoomed=!0,r.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}})),"block"===r.textArea.style.display&&r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}});var l={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=l.canvasFilter,t=t||"Png",r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}});var p={cancel:!1,fileName:i||n,fileType:t};e.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",p).then(function(e){o.beforeSaveEvent(e,t,i,n)}):(r.trigger("beforeSave",p),this.beforeSaveEvent(p,t,i,n))}},t.prototype.beforeSaveEvent=function(t,i,o,r){var a=this.parent;if(!t.cancel){a.currObjType.isSave=!0,o=t.fileName?t.fileName:o;var n=i.toLowerCase();o=o||r,"svg"===n?this.toSVGImg(o):this.toBlobFn(o,n);var s={fileName:o||r,fileType:i};a.trigger("saved",s),e.isBlazor()||a.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),a.lowerCanvas.style.left=a.upperCanvas.style.left="",a.lowerCanvas.style.top=a.upperCanvas.style.top="",a.lowerCanvas.style.maxWidth=a.upperCanvas.style.maxWidth="",a.lowerCanvas.style.maxHeight=a.upperCanvas.style.maxHeight=""}},t.prototype.toSVGImg=function(t){var e=this.parent;i.showSpinner(e.element),e.element.style.opacity="0.5";var o=this.exportToCanvas(),r=o.toDataURL();i.hideSpinner(e.element),e.element.style.opacity="1";var a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("width",o.style.maxWidth),a.setAttribute("height",o.style.maxHeight);var n=document.createElementNS("http://www.w3.org/2000/svg","image");n.setAttributeNS(null,"height",o.height.toString()),n.setAttributeNS(null,"width",o.width.toString()),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),a.appendChild(n);var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+o.width+'" height="'+o.height+'">'+a.innerHTML+"</svg>",l="data:image/svg+xml;base64,"+btoa(s);return null===t?l:(this.downloadImg(l,t+".svg"),null)},t.prototype.toBlobFn=function(t,e){var o=this,r=this.parent;i.showSpinner(r.element),r.element.style.opacity="0.5",this.exportToCanvas().toBlob(function(a){var n=URL.createObjectURL(a);o.downloadImg(n,t+"."+e),i.hideSpinner(r.element),r.element.style.opacity="1"},"image/png")},t.prototype.exportToCanvas=function(t){var i,o,r=this.parent;r.currSelectionPoint?(i=r.img.srcWidth,o=r.img.srcHeight):(i=r.baseImg.width,o=r.baseImg.height);var a={width:0,height:0};r.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:a,dimension:{width:i,height:o}}});var n=a,s=this.lowerContext.filter;if("none"!==this.lowerContext.filter){var l=this.lowerContext.filter.split(" "),p=parseFloat(l[5].split("(")[1]);p*=(n.width+n.height)/2,l[5]="blur("+p+"px)",this.lowerContext.filter=l.join(" ")}var h=r.createElement("canvas",{id:r.element.id+"_tempCanvas",attrs:{name:"canvasImage"}}),c=h.getContext("2d");c.filter=this.lowerContext.filter,h.width=i,h.height=o;var d={width:0,height:0};r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i,height:o,obj:d}});var v=d;h.style.maxWidth=v.width+"px",h.style.maxHeight=v.height+"px",c.filter=this.lowerContext.filter;var u=this.lowerContext.filter;if(r.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),c.drawImage(r.baseImg,r.img.srcLeft,r.img.srcTop,r.img.srcWidth,r.img.srcHeight,0,0,i,o),this.lowerContext.filter=u,0===r.transform.degree&&""===r.transform.currFlipState||(this.updateSaveContext(c),this.exportTransformedImage(c)),r.objColl.length>0){var g=c.filter;c.filter="none";for(var b=e.extend([],r.objColl,[],!0),C=0,f=r.objColl.length;C<f;C++){var m=r.objColl[C].activePoint;m.startX-=r.img.destLeft,m.startY-=r.img.destTop,m.endX-=r.img.destLeft,m.endY-=r.img.destTop,m.width=m.endX-m.startX,m.height=m.endY-m.startY,m.startX*=n.width,m.startY*=n.height,m.endX*=n.width,m.endY*=n.height,m.width=m.endX-m.startX,m.height=m.endY-m.startY,r.objColl[C].strokeSettings.strokeWidth*=(n.width+n.height)/2,"text"===r.objColl[C].shape&&(r.objColl[C].textSettings.fontSize*=(n.width+n.height)/2),r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"saveContext",obj:r.objColl[C],isCropRatio:null,points:null,isPreventDrag:!0,saveContext:c,isPreventSelection:null}})}c.filter=g,r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),r.objColl=b}if(r.freehandCounter>0){for(var y=e.extend({},r.pointColl,{},!0),P=0;P<r.freehandCounter;P++){r.points=e.extend([],r.pointColl[P].points,[]),r.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});f=r.points.length;r.pointColl[P].strokeWidth*=(n.width+n.height)/2;for(var j=0;j<f;j++)r.points[j].x=(r.points[j].x-r.img.destLeft)*n.width,r.points[j].y=(r.points[j].y-r.img.destTop)*n.height}r.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:c,points:null}}),r.pointColl=y}return r.isCircleCrop&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:c,isSave:!0,isFlip:null}}),this.lowerContext.filter=s,r.canvasFilter=s,t&&(t.canvas=h),h},t.prototype.downloadImg=function(t,e){var i=document.createElement("a");i.href=t,i.target="_parent",i.download=e,(document.body||document.documentElement).appendChild(i),i.click(),i.parentNode.removeChild(i)},t.prototype.exportTransformedImage=function(t){for(var e=this.parent,i=e.transform.degree,o=0,r=e.rotateFlipColl.length;o<r;o++){var a=e.rotateFlipColl[o];"number"==typeof a?this.exportRotate(t,a):"horizontal"===a?this.exportFlip(t,!0,!1):"vertical"===a&&this.exportFlip(t,!1,!0)}e.transform.degree=i},t.prototype.exportRotate=function(t,e){var i=this.parent;this.setMaxDim(i.transform.degree,t.canvas),t.translate(t.canvas.width/2,t.canvas.height/2),t.rotate(Math.PI/180*e),t.drawImage(i.inMemoryCanvas,-t.canvas.height/2,-t.canvas.width/2,t.canvas.height,t.canvas.width),this.updateSaveContext(t)},t.prototype.exportFlip=function(t,e,i){e&&(t.translate(t.canvas.width,0),t.scale(-1,1)),i&&(t.translate(0,t.canvas.height),t.scale(1,-1)),t.drawImage(this.parent.inMemoryCanvas,0,0),this.updateSaveContext(t)},t.prototype.updateSaveContext=function(t){var e=this.parent.inMemoryCanvas.getContext("2d");t.setTransform(1,0,0,1,0,0);var i=t.getImageData(0,0,t.canvas.width,t.canvas.height);this.parent.inMemoryCanvas.width=i.width,this.parent.inMemoryCanvas.height=i.height,e.putImageData(i,0,0)},t.prototype.setMaxDim=function(t,i){var o,r;t%90==0&&t%180!=0?(o=e.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImg.height:this.parent.img.srcHeight,r=e.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImg.width:this.parent.img.srcWidth):t%180!=0&&0!==t||(o=e.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImg.width:this.parent.img.srcWidth,r=e.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImg.height:this.parent.img.srcHeight),i.width=o,i.height=r;var a={width:0,height:0};this.parent.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o,height:r,obj:a}});var n=a;i.style.maxWidth=n.width+"px",i.style.maxHeight=n.height+"px"},t}(),p=function(){function t(t){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.adjustmentValue="",this.isBrightnessAdjusted=!1,this.appliedFilter="",this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("filter",this.filter,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("filter",this.filter),this.parent.off("destroyed",this.destroy)},t.prototype.filter=function(t){switch(this.updatePrivateVariables(),t.prop){case"finetuneImage":this.finetuneImage(t.value.option,t.value.value);break;case"applyImageFilter":this.setFilter(t.value.option);break;case"update-finetunes":this.updateFinetunes();break;case"updateBrightFilter":this.updateBrightFilter();break;case"set-adjustment":this.setAdjustment(t.value.operation);break;case"update-filter":this.updateFilter(t.value.operation,t.value.filter);break;case"initFilter":this.initFilter();break;case"setCurrAdjValue":this.setCurrAdjValue(t.value.type,t.value.value);break;case"updateAdj":this.updateAdj(t.value.type,t.value.value,t.value.isPreview,t.value.ctx);break;case"getCurrentObj":this.getCurrentObj(t.value.object);break;case"getAdjustmentLevel":t.value.obj.adjustmentLevel=this.adjustmentLevel;break;case"setAdjustmentLevel":this.adjustmentLevel=t.value.adjustmentLevel;break;case"getTempAdjustmentLevel":t.value.obj.tempAdjustmentLevel=this.tempAdjustmentLevel;break;case"setTempAdjustmentLevel":this.tempAdjustmentLevel=t.value.tempAdjustmentLevel;break;case"setAdjustmentValue":this.adjustmentValue=t.value.adjustmentValue;break;case"getBrightnessAdjusted":t.value.obj.isBrightnessAdjusted=this.isBrightnessAdjusted;break;case"setBrightnessAdjusted":this.isBrightnessAdjusted=t.value.isBrightnessAdjusted,this.parent.currentFilter.split("_")&&"cold"===this.parent.currentFilter.split("_")[1]&&(this.isBrightnessAdjusted=!1);break;case"reset":this.reset()}},t.prototype.updatePrivateVariables=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d"))},t.prototype.getModuleName=function(){return"filter"},t.prototype.updateBrightFilter=function(){var t=this.lowerContext.filter.split(" ");if(this.isBrightnessAdjusted&&t.length>0&&!e.isNullOrUndefined(t[4])){var i=parseFloat(t[4].split("(")[1]);t[4]="opacity("+(i-.3)+")",this.lowerContext.filter=t.join(" ")}},t.prototype.reset=function(){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,sharpen:!1,bw:!1},this.adjustmentValue=this.parent.getDefaultFilter(),this.isBrightnessAdjusted=!1,this.appliedFilter=""},t.prototype.updateFinetunes=function(){var t=this.parent,e=t.finetuneSettings;e&&(e.brightness&&(this.adjustmentLevel.brightness=e.brightness.defaultValue,this.tempAdjustmentLevel.brightness=e.brightness.defaultValue),e.contrast&&(this.adjustmentLevel.contrast=e.contrast.defaultValue,this.tempAdjustmentLevel.contrast=e.contrast.defaultValue),e.hue&&(this.adjustmentLevel.hue=e.hue.defaultValue,this.tempAdjustmentLevel.hue=e.hue.defaultValue),e.saturation&&(this.adjustmentLevel.saturation=e.saturation.defaultValue,this.tempAdjustmentLevel.saturation=e.saturation.defaultValue),e.exposure&&(this.adjustmentLevel.exposure=e.exposure.defaultValue,this.tempAdjustmentLevel.exposure=e.exposure.defaultValue),e.opacity&&(this.adjustmentLevel.opacity=e.opacity.defaultValue,this.tempAdjustmentLevel.opacity=e.opacity.defaultValue),e.blur&&(this.adjustmentLevel.blur=e.blur.defaultValue,this.tempAdjustmentLevel.blur=e.blur.defaultValue),t.notify("draw",{prop:"isInitialLoading",onPropertyChange:!1,value:{isInitialLoading:!0}}))},t.prototype.initFilter=function(){this.setFilterAdj("brightness",this.adjustmentLevel.brightness),this.setFilterAdj("contrast",this.adjustmentLevel.contrast),this.setFilterAdj("hue",this.adjustmentLevel.hue),this.setFilterAdj("saturation",this.adjustmentLevel.saturation),this.setFilterAdj("exposure",this.adjustmentLevel.exposure),this.setFilterAdj("opacity",this.adjustmentLevel.opacity),this.setFilterAdj("blur",this.adjustmentLevel.blur)},t.prototype.updateAdj=function(t,i,o,r){var a=this.parent;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height);var n,s,l=this.lowerContext.filter.split(" "),p=[];l[4]&&(n=parseFloat(l[4].split("(")[1])),l[0]&&(s=parseFloat(l[0].split("(")[1]));var h=this.getFilterValue(this.adjustmentLevel.brightness),c=this.getFilterValue(this.adjustmentLevel.saturation);if(-1===["brightness","contrast","hue","saturation","exposure","opacity","blur"].indexOf(t)&&e.isNullOrUndefined(o)&&(this.adjustmentLevel.sharpen||this.adjustmentLevel.bw)){a.isUndoRedo=!0;var d=this.lowerContext.filter;this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=d,a.isUndoRedo=!1}1!==h&&(l[4]="opacity("+(n-.3)+")");var v,u,g,b,C;switch(t){case"brightness":100!==parseFloat(l[3].split("(")[1])&&(i+=.1),l[0]="brightness("+i+")",this.adjustmentValue=l.join(" ");break;case"contrast":l[1]="contrast("+i+"%)",this.adjustmentValue=l.join(" ");break;case"hue":l[2]="hue-rotate("+i+"deg)",this.adjustmentValue=l.join(" ");break;case"saturation":l[3]="saturate("+i+"%)",1!==c&&(l[0]="brightness("+(s+.09)+")"),this.adjustmentValue=l.join(" ");break;case"opacity":1!==parseFloat(l[0].split("(")[1])&&(i-=.2),l[4]="opacity("+i+")",this.adjustmentValue=l.join(" ");break;case"blur":l[5]="blur("+i+"px)",this.adjustmentValue=l.join(" ");break;case"exposure":1!==h&&(l[4]="opacity("+(n-.3)+")"),i>1?(i-=1,i+=h):i<1&&(i=h-(i=1-i)),l[0]="brightness("+i+")",this.adjustmentValue=l.join(" ");break;case"chrome":v=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(v*=100)+.4*v,l[3]="saturate("+i+"%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"cold":u=this.getFilterValue(this.adjustmentLevel.brightness),i=.9*(u*=100),i*=.01,l[0]="brightness("+i+")",b=this.getFilterValue(this.adjustmentLevel.contrast),i=(b*=100)+.5*b,l[1]="contrast("+i+"%)",C=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=C*=100,l[3]="saturate("+i+"%)",p=this.adjustmentValue.split(" "),l[2]=p[2],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"warm":g=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(g*=100)+.4*g,l[3]="saturate("+i+"%)",l[6]="sepia(25%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[4]=p[4],l[5]=p[5],l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"grayscale":l[7]="grayscale(100%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[3]=p[3],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[8]="invert(0%)";break;case"sepia":l[6]="sepia(100%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[3]=p[3],l[4]=p[4],l[5]=p[5],l[7]="grayscale(0%)",l[8]="invert(0%)";break;case"invert":l[8]="invert(100%)",p=this.adjustmentValue.split(" "),l[0]=p[0],l[1]=p[1],l[2]=p[2],l[3]=p[3],l[4]=p[4],l[5]=p[5],l[6]="sepia(0%)",l[7]="grayscale(0%)"}if("sharpen"!==t&&"blackandwhite"!==t){e.isNullOrUndefined(o)&&("default"===t&&(l=this.getDefaultCurrentFilter(l)),this.lowerContext.filter=l.join(" ")),l=this.setTempFilterValue(h,o,l,t),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.appliedFilter=this.lowerContext.filter,this.lowerContext.drawImage(a.baseImg,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,a.img.destLeft,a.img.destTop,a.img.destWidth,a.img.destHeight),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),1!==h?l[4]="opacity("+n+")":1!==c&&(l[0]="brightness("+s+")"),("exposure"===t&&1!==h||"saturation"===t&&1!==c)&&(l[0]="brightness("+s+")"),l=this.setTempFilterValue(h,o,l,t),e.isNullOrUndefined(o)&&(this.lowerContext.filter=l.join(" ")),a.initialAdjustmentValue=l.join(" ");var f=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=f,a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.isBrightnessAdjusted=1!==h}var m=l.join(" ");r&&(r.filter=m)},t.prototype.setTempFilterValue=function(t,e,i,o){if(e)if("default"===o)i=this.getDefaultCurrentFilter(i);else if(1!==t){var r=this.lowerContext.filter.split(" ");r[4]=i[4],this.lowerContext.filter=r.join(" ")}return i},t.prototype.getDefaultCurrentFilter=function(t){var e=this.adjustmentValue.split(" ");return[e[0],e[1],e[2],e[3],e[4],e[5],"sepia(0%)","grayscale(0%)","invert(0%)"]},t.prototype.getFilterValue=function(t){return 0===t?1:1+.5*t/100},t.prototype.getSaturationFilterValue=function(t){return 0===t?1:1+t/100},t.prototype.setFilterAdj=function(t,i){var o=this.parent;switch(o.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1}),this.adjustmentLevel[""+t]=i,t){case"brightness":case"contrast":case"exposure":i=this.getFilterValue(i),"contrast"===t&&(i*=100);break;case"hue":i*=3;break;case"saturation":i=100*this.getSaturationFilterValue(i);break;case"opacity":i>=50?i/=100:40===i?i=.45:30===i?i=.4:20===i?i=.35:10===i?i=.3:0===i&&(i=.25);break;case"blur":0!==i&&(i/=20,i+=.5)}var r=e.extend({},o.cropObj,{},!0),a=this.getCurrentObj();a.objColl=e.extend([],o.objColl,[],!0),a.pointColl=e.extend([],o.pointColl,[],!0),a.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.updateAdj(t,i);var s=this.lowerContext.filter;this.lowerContext.filter=this.appliedFilter,o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:t,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.lowerContext.filter=s},t.prototype.setFilter=function(t){var i=this.parent;t=t.toLowerCase(),i.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1});var o={currentFilter:this.parent.currentFilter}.currentFilter,r=e.extend({},i.cropObj,{},!0),a=this.getCurrentObj();a.objColl=e.extend([],i.objColl,[],!0),a.pointColl=e.extend([],i.pointColl,[],!0),a.afterCropActions=e.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.updateAdj(t,null);var s=this.lowerContext.filter;this.lowerContext.filter=this.appliedFilter,i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:t,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:o,isCircleCrop:null}}),this.lowerContext.filter=s},t.prototype.setAdjustment=function(t){var e,i,o=this.lowerContext.filter.split(" ");switch(t){case"brightness":i=o[0].split("("),e=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.brightness=this.setFilterValue(e);break;case"contrast":i=o[1].split("("),e=parseFloat(i[1].split(")")[0]),e/=100,this.adjustmentLevel.contrast=this.setFilterValue(e);break;case"hue":i=o[2].split("("),e=parseFloat(i[1].split(")")[0]),e/=3,this.adjustmentLevel.hue=e;break;case"saturation":i=o[3].split("("),e=parseFloat(i[1].split(")")[0]),e/=100,this.adjustmentLevel.saturation=this.setSaturationFilterValue(e);break;case"opacity":i=o[4].split("("),.45===(e=parseFloat(i[1].split(")")[0]))?e=40:.4===e?e=30:.35===e?e=20:.3===e?e=10:.25===e?e=0:e*=100,this.adjustmentLevel.opacity=e;break;case"blur":i=o[5].split("("),e=parseFloat(i[1].split(")")[0]),e*=20,this.adjustmentLevel.blur=e;break;case"exposure":i=o[0].split("("),e=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.exposure=this.setFilterValue(e)}},t.prototype.setFilterValue=function(t){return Math.round(1===t?0:100*(t-1)/.5)},t.prototype.setSaturationFilterValue=function(t){return Math.round(1===t?0:100*(t-1))},t.prototype.updateFilter=function(t,e){var i=this.parent;if(-1!==["default","chrome","cold","warm","grayscale","blackandwhite","sepia","invert","sharpen"].indexOf(t)){var o=i.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");o&&o.classList.remove("e-selected");var r=document.getElementById(i.element.id+"_"+t+"Canvas");r&&r.parentElement.classList.add("e-selected"),this.parent.currentFilter=e||i.element.id+"_"+t}},t.prototype.finetuneImage=function(t,e){var i=this.parent;if(!i.disabled&&i.isImageLoaded){switch(t.toLowerCase()){case"brightness":this.setFilterAdj("brightness",e);break;case"contrast":this.setFilterAdj("contrast",e);break;case"hue":this.setFilterAdj("hue",e);break;case"saturation":this.setFilterAdj("saturation",e);break;case"opacity":this.setFilterAdj("opacity",e);break;case"blur":this.setFilterAdj("blur",e);break;case"exposure":this.setFilterAdj("exposure",e)}this.parent.canvasFilter=this.lowerContext.filter,i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},t.prototype.setCurrAdjValue=function(t,e){switch(this.parent.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),t){case"brightness":this.setFilterAdj("brightness",e);break;case"contrast":this.setFilterAdj("contrast",e);break;case"hue":this.setFilterAdj("hue",e);break;case"saturation":this.setFilterAdj("saturation",e);break;case"opacity":this.setFilterAdj("opacity",e);break;case"blur":this.setFilterAdj("blur",e);break;case"exposure":this.setFilterAdj("exposure",e)}},t.prototype.getCurrentObj=function(t){var i=this.parent,o={point:null};i.notify("crop",{prop:"getTempFlipPanPoint",value:{obj:o}});var r={previousZoomValue:null};i.notify("transform",{prop:"getPreviousZoomValue",value:{obj:r}});var a={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:""};return a.cropZoom=i.transform.cropZoomFactor,a.defaultZoom=i.transform.defaultZoomFactor,a.zoomFactor=i.zoomSettings.zoomFactor,a.previousZoomValue=r.previousZoomValue,a.totalPannedPoint=e.extend({},i.panPoint.totalPannedPoint,{},!0),a.totalPannedClientPoint=e.extend({},i.panPoint.totalPannedClientPoint,{},!0),a.totalPannedInternalPoint=e.extend({},i.panPoint.totalPannedInternalPoint,{},!0),a.tempFlipPanPoint=e.extend({},o.point,{},!0),a.activeObj=e.extend({},i.activeObj,{},!0),a.rotateFlipColl=e.extend([],i.rotateFlipColl,[],!0),a.degree=i.transform.degree,a.currFlipState=i.transform.currFlipState,a.destPoints={startX:i.img.destLeft,startY:i.img.destTop,endX:0,endY:0,width:i.img.destWidth,height:i.img.destHeight},a.srcPoints={startX:i.img.srcLeft,startY:i.img.srcTop,endX:0,endY:0,width:i.img.srcWidth,height:i.img.srcHeight},a.filter=this.lowerContext.filter,t&&(t.currObj=a),a},t}(),h=function(){function i(t){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=!1,this.freehandDownPoint={x:0,y:0},this.isFreehandPointMoved=!1,this.pointCounter=0,this.selPointColl={},this.currFHDIdx=0,this.selPoints=[],this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null},this.parent=t,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("freehand-draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("freehand-draw",this.draw),this.parent.off("destroyed",this.destroy)},i.prototype.draw=function(t){switch(this.updateFhdPvtVar(),t.prop){case"hoverFhd":this.hoverFhd(t.value.strokeColor,t.value.strokeWidth);break;case"freehandDownHandler":this.freehandDownHandler(t.value.e,t.value.canvas);break;case"freehandUpHandler":this.freehandUpHandler(t.value.e,t.value.canvas,t.value.context);break;case"handle-freehand-draw":i=parseInt(t.value.id.split("_")[1],10)-1;this.isFHDIdx(i)&&this.deleteFhd(i,!0);break;case"freehandRedraw":this.freehandRedraw(t.value.context,t.value.points);break;case"deleteFhd":i=parseInt(t.value.id.split("_")[1],10)-1;this.deleteFhd(i,!0);break;case"selectFhd":var i=null;t.value.id&&(i=parseInt(t.value.id.split("_")[1],10)-1),this.selectFhd(i);break;case"applyFhd":this.applyFhd();break;case"cancelFhd":this.cancelFhd();break;case"updateFHDCurPts":this.updateFHDCurPts();break;case"rotateFhdColl":this.rotateFhdColl();break;case"flipFHDColl":this.flipFHDColl(t.value.value);break;case"panFHDColl":this.panFHDColl(t.value.xDiff,t.value.yDiff,t.value.panRegion);break;case"updateFHDColl":this.updateFHDColl();break;case"zoomFHDColl":this.zoomFHDColl(t.value.isPreventApply);break;case"apply-pen-draw":this.applyPenDraw();break;case"freeHandDraw":this.freeHandDraw(t.value.value);break;case"isFHDIdx":this.isFHDIdx(t.value.index,t.value.obj);break;case"getSqPtFD":this.getSqPtFD(t.value.idx,t.value.obj);break;case"getSelPointColl":t.value.obj.selPointColl=e.extend([],this.selPointColl);break;case"setSelPointColl":this.selPointColl=e.extend([],t.value.obj.selPointColl);break;case"setFreehandDrawHoveredIndex":this.fhdHovIdx=t.value.index;break;case"getFreehandDrawHoveredIndex":t.value.obj.index=this.fhdHovIdx;break;case"setPointCounter":this.pointCounter=t.value.value;break;case"getPenStrokeWidth":t.value.obj.penStrokeWidth=this.penStrokeWidth;break;case"setPenStrokeWidth":this.penStrokeWidth=t.value.value;break;case"getCurrentFreehandDrawIndex":t.value.obj.currentFreehandDrawIndex=this.currFHDIdx;break;case"setCurrentFreehandDrawIndex":this.currFHDIdx=t.value.value;break;case"updateCropPtsForSel":this.updateCropPtsForSel();break;case"getFreehandDrawSelectedId":t.value.obj.freehandDrawSelectedId=this.fhdSelID;break;case"resetFreehandDrawSelectedId":this.fhdSelID=null;break;case"getTempFreeHandDrawEditingStyles":t.value.obj.tempFreeHandDrawEditingStyles=this.tempFHDStyles;break;case"setFreehandSelectedIndex":this.fhdSelIdx=t.value.index;break;case"getFreehandSelectedIndex":t.value.obj.freehandSelectedIndex=this.fhdSelIdx;break;case"reset":this.reset()}},i.prototype.updateFhdPvtVar=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=this.isFreehandPointMoved=!1,this.selPoints=[],this.freehandDownPoint={x:0,y:0},this.selPointColl={},this.fhdHovIdx=null,this.pointCounter=0,this.fhdSelID=null,this.penStrokeWidth=void 0,this.currFHDIdx=0,this.fhdSelIdx=null,this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null}},i.prototype.getModuleName=function(){return"freehand-draw"},i.prototype.hoverFhd=function(t,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=this.upperContext,a=-1;a=this.fhdHovIdx>-1?this.fhdHovIdx:this.fhdSelIdx,o.points=e.extend([],o.pointColl[a].points),this.pointCounter=0;var n,s,l,p,h=o.points.length,c=0,d=0;r.fillStyle=t||o.pointColl[a].strokeColor,r.strokeStyle=r.fillStyle,c=d=this.penStrokeWidth=i||o.pointColl[a].strokeWidth,1===h&&(n=s=l=p=o.points[0],this.startDraw(r,n,s,l,p,c,d));for(var v=0;v<h-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(n=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,s=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,l=o.points[v+1],p=o.points[v+2],this.startDraw(r,n,s,l,p,c,d));r.closePath();var u=this.getSqPtFD(a),g=r.lineWidth;r.lineWidth=2,r.strokeStyle=o.themeColl[o.theme].primaryColor,r.beginPath(),r.rect(u.startX,u.startY,u.width,u.height),r.stroke(),r.closePath(),r.lineWidth=g},i.prototype.freehandDownHandler=function(t,i){this.parent.lowerCanvas=document.querySelector("#"+this.parent.element.id+"_lowerCanvas"),this.lowerContext=this.parent.lowerCanvas.getContext("2d"),this.parent.upperCanvas=document.querySelector("#"+this.parent.element.id+"_upperCanvas"),this.upperContext=this.parent.upperCanvas.getContext("2d"),this.fhdObj.time=(new Date).getTime(),this.isFreehandDrawing=!0,"mousedown"===t.type?this.freehandDownPoint={x:t.clientX,y:t.clientY}:this.freehandDownPoint={x:t.touches[0].clientX,y:t.touches[0].clientY},this.isFreehandPointMoved=!1,e.EventHandler.add(i,"mousemove touchmove",this.freehandMoveHandler,this)},i.prototype.freehandUpHandler=function(t,i,o){var r=i.getBoundingClientRect(),a=this.parent;e.EventHandler.remove(i,"mousemove touchmove",this.freehandMoveHandler),0===a.points.length&&("mouseup"===t.type?this.processPoint(t.clientX-r.left,t.clientY-r.top,!0,o):this.isFreehandPointMoved||this.processPoint(this.freehandDownPoint.x-r.left,this.freehandDownPoint.y-r.top,!0,o)),o.closePath();var n=e.extend({},a.cropObj,{},!0),s={currObj:{}};a.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=e.extend([],a.objColl,[],!0),l.pointColl=e.extend([],a.pointColl,[],!0),l.afterCropActions=e.extend([],a.afterCropActions,[],!0);var p={selPointColl:null};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=e.extend([],p.selPointColl,[],!0);var h=a.freehandCounter;a.pointColl[h]={},a.pointColl[h].points=e.extend([],a.points),a.pointColl[h].strokeColor=a.activeObj.strokeSettings.strokeColor,a.pointColl[h].strokeWidth=this.penStrokeWidth,a.pointColl[h].flipState=a.transform.currFlipState,a.pointColl[h].id="pen_"+(this.currFHDIdx+1),a.points=[],this.selPointColl[h]={},this.selPointColl[h].points=e.extend([],this.selPoints),this.selPoints=[],this.pointCounter=0,a.freehandCounter++,this.currFHDIdx++,this.isFreehandDrawing=!1,a.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehand-draw",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:n,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})},i.prototype.freehandMoveHandler=function(t){this.isFreehandPointMoved=!0;var e,i,o=this.parent.upperCanvas.getBoundingClientRect();"mousemove"===t.type?(e=t.clientX-o.left,i=t.clientY-o.top):(e=t.touches[0].clientX-o.left,i=t.touches[0].clientY-o.top),this.isFreehandDrawing&&this.processPoint(e,i,!1,this.upperContext)},i.prototype.processPoint=function(t,i,o,r){var a,n,s,l,p=this.parent,h=this.point(t,i,(new Date).getTime()),c=!!(h=p.points.length>0&&p.points[p.points.length-1])&&this.distanceTo(h)<=5;if(this.selPoints.push({x:t,y:i,ratioX:(t-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),!h||!h||!c||o){if(this.fhdObj.time=(new Date).getTime(),p.points.push({x:t,y:i,ratioX:(t-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),p.points.length>3){var d=p.points[this.pointCounter],v=p.points[this.pointCounter+1],u=p.points[this.pointCounter+2],g=p.points[this.pointCounter+3];a=this.calcCurveCP(d,v,u).controlPoint2,n=this.calcCurveCP(v,u,g).controlPoint1,s=p.points[this.pointCounter+1],l=p.points[this.pointCounter+2];var b=.5,C=5;e.isNullOrUndefined(this.penStrokeWidth)||(b=C=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,C),this.pointCounter++}if(o){a=n=s=l={x:t,y:i,time:(new Date).getTime()};var b=.5,C=5;e.isNullOrUndefined(this.penStrokeWidth)||(b=C=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,C)}}},i.prototype.calcCurveCP=function(t,e,i){e||(e=t),i||(i=e);var o=t.x-e.x,r=t.y-e.y,a=e.x-i.x,n=e.y-i.y,s={x:(t.x+e.x)/2,y:(t.y+e.y)/2},l={x:(e.x+i.x)/2,y:(e.y+i.y)/2},p=Math.sqrt(o*o+r*r),h=Math.sqrt(a*a+n*n),c=s.x-l.x,d=s.y-l.y,v=h/(p+h),u={x:l.x+c*v,y:l.y+d*v},g=e.x-u.x,b=e.y-u.y;return{controlPoint1:this.point(s.x+g,s.y+b,0),controlPoint2:this.point(l.x+g,l.y+b,0)}},i.prototype.point=function(t,e,i){return this.fhdObj.pointX=t,this.fhdObj.pointY=e,{x:this.fhdObj.pointX,y:this.fhdObj.pointY,time:i}},i.prototype.startDraw=function(t,e,i,o,r,a,n){var s;s=.7*(s=this.pointVelocity(o))+(1-.7)*this.fhdObj.lastVelocity;var l=Math.max(n/1.7,a);this.drawCurve(this.fhdObj.time,l,t,e,i,o,r,n),this.fhdObj.lastVelocity=s,this.fhdObj.time=l},i.prototype.pointVelocity=function(t){return this.fhdObj.time!==t.time?this.distanceTo(t)/(this.fhdObj.time-t.time):0},i.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.fhdObj.pointX-t.x,2)+Math.pow(this.fhdObj.pointY-t.y,2))},i.prototype.drawCurve=function(t,e,i,o,r,a,n,s){var l,p,h,c,d,v,u,g,b,C,f=e-t,m=this.bezierLength(o,r,a,n),y=2*Math.ceil(m);for(i.beginPath(),p=0;p<y;p++)d=(c=(h=p/y)*h)*h,b=(g=(u=(v=1-h)*v)*v)*a.x,b+=3*u*h*o.x,b+=3*v*c*r.x,b+=d*n.x,C=g*a.y,C+=3*u*h*o.y,C+=3*v*c*r.y,C+=d*n.y,l=Math.min(t+d*f,s),this.drawArc(b,C,l,i);i.closePath(),i.fill()},i.prototype.bezierLength=function(t,e,i,o){var r,a,n,s,l,p,h,c,d=0;for(r=0;r<=10;r++)a=r/10,n=this.bezierPoint(a,i.x,t.x,e.x,o.x),s=this.bezierPoint(a,i.y,t.y,e.y,o.y),r>0&&(h=n-l,c=s-p,d+=Math.sqrt(h*h+c*c)),l=n,p=s;return d},i.prototype.bezierPoint=function(t,e,i,o,r){return e*(1-t)*(1-t)*(1-t)+3*i*(1-t)*(1-t)*t+3*o*(1-t)*t*t+r*t*t*t},i.prototype.drawArc=function(t,e,i,o){(t>this.parent.img.destLeft&&e>this.parent.img.destTop&&t<this.parent.img.destLeft+this.parent.img.destWidth&&e<this.parent.img.destTop+this.parent.img.destHeight||o!==this.lowerContext&&o!==this.upperContext)&&(o.moveTo(t,e),o.arc(t,e,i,0,2*Math.PI,!1))},i.prototype.freehandRedraw=function(t,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=t.filter;t.filter="none",i&&(o.pointColl[o.freehandCounter]={},o.pointColl[o.freehandCounter].points=i,o.pointColl[o.freehandCounter].strokeColor=o.activeObj.strokeSettings.strokeColor,o.pointColl[o.freehandCounter].strokeWidth=this.penStrokeWidth,o.pointColl[o.freehandCounter].flipState=o.transform.currFlipState,o.freehandCounter++);for(var a=0;a<o.freehandCounter;a++){o.points=e.extend([],o.pointColl[a].points),this.pointCounter=0;var n=o.points.length,s=void 0,l=void 0,p=void 0,h=void 0,c=void 0,d=void 0;n>0&&(t.fillStyle=o.pointColl[a].strokeColor,c=d=this.penStrokeWidth=o.pointColl[a].strokeWidth),1===n&&(s=l=p=h=o.points[0],this.startDraw(t,s,l,p,h,c,d));for(var v=0;v<n-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(s=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,l=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,p=o.points[v+1],h=o.points[v+2],this.startDraw(t,s,l,p,h,c,d));t.closePath()}t.filter=r},i.prototype.getSqPtFD=function(t,i){var o={startX:0,startY:0,endX:0,endY:0,width:0,height:0},r=e.extend([],this.selPointColl[t].points,[]);this.parent.points=e.extend([],this.parent.pointColl[t].points),this.pointCounter=0;for(var a=r.length,n=0;n<a;n++)0===o.startX&&0===o.startY&&0===o.endX&&0===o.endY?(o.startX=r[n].x,o.startY=r[n].y,o.endX=r[n].x,o.endY=r[n].y):(o.startX=Math.min(o.startX,r[n].x),o.startY=Math.min(o.startY,r[n].y),o.endX=Math.max(o.endX,r[n].x),o.endY=Math.max(o.endY,r[n].y));return o.startX-=this.penStrokeWidth,o.startY-=this.penStrokeWidth,o.endX+=this.penStrokeWidth,o.endY+=this.penStrokeWidth,o.width=o.endX-o.startX,o.height=o.endY-o.startY,i&&(i.activePoint=o),o},i.prototype.applyPenDraw=function(){var t=this.parent;"freehanddraw"===t.currObjType.shape&&(t.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),t.upperCanvas.style.cursor=t.cursor="default",t.currObjType.shape=""),t.notify("shape",{prop:"clearActObj"})},i.prototype.applyFhd=function(){var t=this.parent,i=t.pointColl[this.fhdSelIdx];"#42a5f5"===i.strokeColor&&(i.strokeColor=this.tempFHDStyles.strokeColor),e.isBlazor()||t.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.isBlazor()||t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i&&(i.isSelected=!1),t.notify("selection",{prop:"resetFreehandDrawVariables"}),this.fhdHovIdx=this.fhdSelIdx=null},i.prototype.cancelFhd=function(){var t=this.parent;e.isBlazor()||t.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.pointCounter=0,t.pointColl[this.fhdSelIdx]&&(t.pointColl[this.fhdSelIdx].strokeColor=this.tempFHDStyles.strokeColor,t.pointColl[this.fhdSelIdx].strokeWidth=this.tempFHDStyles.strokeWidth,t.pointColl[this.fhdSelIdx].isSelected=!1),this.fhdHovIdx=this.fhdSelIdx=this.fhdSelID=null,t.notify("selection",{prop:"resetFreehandDrawVariables"}),t.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor,t.activeObj.strokeSettings.strokeWidth=this.penStrokeWidth=this.tempFHDStyles.strokeWidth,this.tempFHDStyles={strokeColor:null,strokeWidth:null,fillColor:null},e.isBlazor()||t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},i.prototype.selectFhd=function(i){var o=this,r=this.parent;if(r.notify("selection",{prop:"setFreehandDrawEditing",onPropertyChange:!1,value:{bool:!0}}),i||0===i){if(!this.isFHDIdx(i))return;this.fhdSelIdx=this.fhdHovIdx=i,this.hoverFhd(),r.upperCanvas.style.cursor=r.cursor="pointer"}this.fhdSelIdx=this.fhdHovIdx,r.pointColl[this.fhdSelIdx].isSelected=!0,this.fhdSelID=r.pointColl[this.fhdSelIdx].id,"#42a5f5"!==r.pointColl[this.fhdHovIdx].strokeColor&&(r.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor=r.pointColl[this.fhdHovIdx].strokeColor),r.activeObj.strokeSettings.strokeWidth=this.tempFHDStyles.strokeWidth=r.pointColl[this.fhdHovIdx].strokeWidth;var a={bool:!1};if(r.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool){var n={id:"pen_"+(this.fhdSelIdx+1),type:t.ShapeType.FreehandDraw,startX:r.pointColl[this.fhdSelIdx].points[0].x,startY:r.pointColl[this.fhdSelIdx].points[0].y,strokeColor:r.pointColl[this.fhdSelIdx].strokeColor,strokeWidth:r.pointColl[this.fhdSelIdx].strokeWidth,points:r.pointColl[this.fhdSelIdx].points},s={action:"select",previousShapeSettings:n,currentShapeSettings:n};e.isBlazor()&&r.events&&!0===r.events.shapeChanging.hasDelegate?r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",s).then(function(t){r.pointColl[o.fhdSelIdx].strokeColor=t.currentShapeSettings.strokeColor,r.pointColl[o.fhdSelIdx].strokeWidth=t.currentShapeSettings.strokeWidth,r.pointColl[o.fhdSelIdx].points=t.currentShapeSettings.points,o.freehandRedraw(o.upperContext),r.updateToolbar(r.element,"imageLoaded"),r.updateToolbar(r.element,"pen")}):(r.trigger("shapeChanging",s),r.pointColl[this.fhdSelIdx].strokeColor=s.currentShapeSettings.strokeColor,r.pointColl[this.fhdSelIdx].strokeWidth=s.currentShapeSettings.strokeWidth,r.pointColl[this.fhdSelIdx].points=s.currentShapeSettings.points,this.freehandRedraw(this.upperContext),r.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))}else r.okBtn()},i.prototype.deleteFhd=function(t,i){var o=this.parent;if(this.isFHDIdx(t)){this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);var r=e.extend({},o.pointColl,{},!0),a=e.extend({},this.selPointColl,{},!0);o.pointColl={},this.selPointColl={};var n=0;if(e.isNullOrUndefined(i))for(s=0;s<o.freehandCounter;s++)s!==t&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);else for(var s=0;s<o.freehandCounter;s++)parseInt(r[s].id.split("_")[1],10)-1!==t&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);o.freehandCounter-=1,this.fhdHovIdx=this.fhdSelIdx=null,o.notify("selection",{prop:"resetFreehandDrawVariables"}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}}),e.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},i.prototype.zoomX=function(t){return t*this.parent.img.destWidth+this.parent.img.destLeft},i.prototype.zoomY=function(t){return t*this.parent.img.destHeight+this.parent.img.destTop},i.prototype.zoomFHDColl=function(t){for(var i=this.parent,o=0;o<i.freehandCounter;o++){i.points=e.extend([],i.pointColl[o].points,[]),this.pointCounter=0;for(var r=i.points.length,a=0;a<r;a++)i.points[a].x=this.zoomX(i.points[a].ratioX),i.points[a].y=this.zoomY(i.points[a].ratioY)}this.updateFHDCurPts(),e.isNullOrUndefined(t)&&this.freehandRedraw(this.lowerContext,null)},i.prototype.updateFHDCurPts=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x=this.zoomX(this.selPoints[r].ratioX),this.selPoints[r].y=this.zoomY(this.selPoints[r].ratioY)}},i.prototype.rotateFhdColl=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++){t.points=e.extend([],t.pointColl[i].points,[]),this.pointCounter=0;for(var o=t.points.length,r=0;r<o;r++)t.points[r].y=t.img.destTop+t.img.destHeight*t.points[r].ratioX,t.points[r].x=t.img.destLeft+t.img.destWidth-t.img.destWidth*t.points[r].ratioY,t.points[r].ratioX=(t.points[r].x-t.img.destLeft)/t.img.destWidth,t.points[r].ratioY=(t.points[r].y-t.img.destTop)/t.img.destHeight}for(i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y=t.img.destTop+t.img.destHeight*this.selPoints[r].ratioX,this.selPoints[r].x=t.img.destLeft+t.img.destWidth-t.img.destWidth*this.selPoints[r].ratioY,this.selPoints[r].ratioX=(this.selPoints[r].x-t.img.destLeft)/t.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-t.img.destTop)/t.img.destHeight}this.updateFHDCurPts()},i.prototype.flipFHDColl=function(t){var e=t.toLowerCase();if("horizontal"===e)this.pointsHorizontalFlip();else if("vertical"===e)this.pointsVerticalFlip();else{this.pointsHorizontalFlip();for(var i=0;i<this.parent.freehandCounter;i++)this.parent.pointColl[i].shapeFlip="";this.pointsVerticalFlip()}},i.prototype.pointsHorizontalFlip=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++)if(t.pointColl[i].shapeFlip!==t.transform.currFlipState){t.points=e.extend([],t.pointColl[i].points,[]),this.pointCounter=0;for(var o=t.points.length,r=0;r<o;r++)t.points[r].x<=t.img.destLeft+t.img.destWidth/2?t.points[r].x=t.img.destLeft+t.img.destWidth-(t.points[r].x-t.img.destLeft):t.points[r].x>=t.img.destLeft+t.img.destWidth/2&&(t.points[r].x=t.img.destLeft+(t.img.destLeft+t.img.destWidth-t.points[r].x)),t.points[r].ratioX=(t.points[r].x-t.img.destLeft)/t.img.destWidth,t.points[r].ratioY=(t.points[r].y-t.img.destTop)/t.img.destHeight;t.pointColl[i].shapeFlip=t.transform.currFlipState}for(i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==t.transform.currFlipState){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x<=t.img.destLeft+t.img.destWidth/2?this.selPoints[r].x=t.img.destLeft+t.img.destWidth-(this.selPoints[r].x-t.img.destLeft):this.selPoints[r].x>=t.img.destLeft+t.img.destWidth/2&&(this.selPoints[r].x=t.img.destLeft+(t.img.destLeft+t.img.destWidth-this.selPoints[r].x)),this.selPoints[r].ratioX=(this.selPoints[r].x-t.img.destLeft)/t.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-t.img.destTop)/t.img.destHeight}this.updateFHDCurPts()},i.prototype.pointsVerticalFlip=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++)if(t.pointColl[i].shapeFlip!==t.transform.currFlipState){t.points=e.extend([],t.pointColl[i].points,[]),this.pointCounter=0;for(var o=t.points.length,r=0;r<o;r++)t.points[r].y<=t.img.destTop+t.img.destHeight/2?t.points[r].y=t.img.destTop+t.img.destHeight-(t.points[r].y-t.img.destTop):t.points[r].y>=t.img.destTop+t.img.destHeight/2&&(t.points[r].y=t.img.destTop+(t.img.destTop+t.img.destHeight-t.points[r].y)),t.points[r].ratioX=(t.points[r].x-t.img.destLeft)/t.img.destWidth,t.points[r].ratioY=(t.points[r].y-t.img.destTop)/t.img.destHeight;t.pointColl[i].shapeFlip=t.transform.currFlipState}for(i=0;i<t.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==t.transform.currFlipState){this.selPoints=e.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y<=t.img.destTop+t.img.destHeight/2?this.selPoints[r].y=t.img.destTop+t.img.destHeight-(this.selPoints[r].y-t.img.destTop):this.selPoints[r].y>=t.img.destTop+t.img.destHeight/2&&(this.selPoints[r].y=t.img.destTop+(t.img.destTop+t.img.destHeight-this.selPoints[r].y)),this.selPoints[r].ratioX=(this.selPoints[r].x-t.img.destLeft)/t.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-t.img.destTop)/t.img.destHeight}this.updateFHDCurPts()},i.prototype.updateFHDColl=function(){for(var t=this.parent,i=0;i<t.objColl.length;i++){if(t.objColl[i].imageRatio={startX:(t.objColl[i].activePoint.startX-t.img.destLeft)/t.img.destWidth,startY:(t.objColl[i].activePoint.startY-t.img.destTop)/t.img.destHeight,endX:(t.objColl[i].activePoint.endX-t.img.destLeft)/t.img.destWidth,endY:(t.objColl[i].activePoint.endY-t.img.destTop)/t.img.destHeight,width:t.img.destWidth/t.objColl[i].activePoint.width,height:t.img.destHeight/t.objColl[i].activePoint.height},"path"===t.objColl[i].shape)for(var o=0;o<t.objColl[i].pointColl.length;o++)t.objColl[i].pointColl[o].ratioX=(t.objColl[i].pointColl[o].x-t.img.destLeft)/t.img.destWidth,t.objColl[i].pointColl[o].ratioY=(t.objColl[i].pointColl[o].y-t.img.destTop)/t.img.destHeight;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})}for(n=0;n<t.freehandCounter;n++){t.points=e.extend([],t.pointColl[n].points,[]),this.pointCounter=0;for(var r=t.points.length,a=0;a<r;a++)t.points[a].ratioX=(t.points[a].x-t.img.destLeft)/t.img.destWidth,t.points[a].ratioY=(t.points[a].y-t.img.destTop)/t.img.destHeight}for(var n=0;n<t.freehandCounter;n++)if(this.selPointColl[n]){this.selPoints=e.extend([],this.selPointColl[n].points,[]),this.pointCounter=0;for(var r=this.selPoints.length,a=0;a<r;a++)this.selPoints[a].ratioX=(this.selPoints[a].x-t.img.destLeft)/t.img.destWidth,this.selPoints[a].ratioY=(this.selPoints[a].y-t.img.destTop)/t.img.destHeight}},i.prototype.panFHDColl=function(t,i,o){for(var r=this.parent,a=0;a<r.freehandCounter;a++){r.points=e.extend([],r.pointColl[a].points,[]),this.pointCounter=0;for(var n=r.points.length,s=0;s<n;s++)""===o||"vertical"===o?r.points[s].x+=t:r.points[s].x-=t,""===o||"horizontal"===o?r.points[s].y+=i:r.points[s].y-=i}for(a=0;a<r.freehandCounter;a++)if(this.selPointColl[a]){this.selPoints=e.extend([],this.selPointColl[a].points,[]),this.pointCounter=0;for(var n=this.selPoints.length,s=0;s<n;s++)""===o||"vertical"===o?this.selPoints[s].x+=t:this.selPoints[s].x-=t,""===o||"horizontal"===o?this.selPoints[s].y+=i:this.selPoints[s].y-=i}this.freehandRedraw(this.lowerContext,null)},i.prototype.freeHandDraw=function(t){var i=this.parent;if(t){if(i.points=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.togglePen=!0,i.upperCanvas.style.cursor=i.cursor="crosshair",i.upperCanvas.style.display="block",e.isNullOrUndefined(i.activeObj.strokeSettings)){var o={strokeSettings:{}};i.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:o}}),i.activeObj.strokeSettings=o.strokeSettings}e.isNullOrUndefined(i.activeObj.strokeSettings.strokeWidth)&&(i.activeObj.strokeSettings.strokeWidth=4),e.isBlazor()?i.updateToolbar(i.element,"pen"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}else i.upperCanvas.style.cursor=i.cursor="default",i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}})),i.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},i.prototype.isFHDIdx=function(t,e){for(var i=!1,o=0;o<this.parent.freehandCounter;o++)if(this.parent.pointColl[o].id&&parseInt(this.parent.pointColl[o].id.split("_")[1],10)-1===t){i=!0;break}return e&&(e.isIndex=i),i},i.prototype.updateCropPtsForSel=function(){for(var t=this.parent,i=0;i<t.freehandCounter;i++){var o={selPointColl:e.extend([],this.selPointColl)};if(o.selPointColl[i]){this.selPoints=e.extend([],o.selPointColl[i].points,[]),this.pointCounter=0;for(var r=this.selPoints.length,a=0;a<r;a++)this.selPoints[a].ratioX=(this.selPoints[a].x-t.activeObj.activePoint.startX)/t.activeObj.activePoint.width,this.selPoints[a].ratioY=(this.selPoints[a].y-t.activeObj.activePoint.startY)/t.activeObj.activePoint.height}}},i}(),c=function(){function i(t){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=!1,this.isObjSelected=!1,this.isFhdPoint=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.isShapeInserted=!1,this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.cursorTargetId="",this.isPreventDragging=!1,this.dragElement="",this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.isFhdEditing=!1,this.currentDrawingShape="",this.initialPrevObj={},this.touchTime=0,this.resizedElement="",this.parent=t,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("selection",this.selection,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("selection",this.selection),this.parent.off("destroyed",this.destroy)},i.prototype.selection=function(t){var e=this;switch(this.updatePrivateVariables(),t.prop){case"mouse-up":this.selMouseUpEvent();break;case"setCursor":this.setCursor(t.value.x,t.value.y);break;case"updateActivePoint":this.updateActivePoint(t.value.x,t.value.y,t.value.isCropSelection);break;case"updateCursorStyles":this.updateCursorStyles(t.value.x,t.value.y,t.value.type);break;case"setTextSelection":this.setTextSelection(t.value.width,t.value.height);break;case"setActivePoint":this.setActivePoint(t.value.startX,t.value.startY);break;case"clearSelection":this.clearSelection();break;case"calcShapeRatio":this.calcShapeRatio(t.value.x,t.value.y,t.value.imgWidth,t.value.imgHeight);break;case"applyCurrShape":this.applyCurrShape(t.value.isShapeClick);break;case"tab":this.performTabAction();break;case"setDragDirection":this.setDragDirection(t.value.width,t.value.height);break;case"clearUpperCanvas":this.isTouch&&setTimeout(function(){e.parent.upperCanvas.getContext("2d").clearRect(0,0,e.parent.upperCanvas.width,e.parent.upperCanvas.height)},550);break;case"resetFreehandDrawVariables":this.isFhdEditing=this.isFhdPoint=!1;break;case"isShapeInserted":this.isShapeInserted=t.value.bool;break;case"redrawShape":this.redrawShape(t.value.obj);break;case"setTextBoxStylesToActObj":this.setTextBoxStylesToActObj();break;case"mouseDownEventHandler":this.mouseDownEventHandler(t.value.e);break;case"mouseMoveEventHandler":this.mouseMoveEventHandler(t.value.e);break;case"mouseUpEventHandler":this.mouseUpEventHandler(t.value.e);break;case"canvasMouseDownHandler":this.canvasMouseDownHandler(t.value.e);break;case"canvasMouseMoveHandler":this.canvasMouseMoveHandler(t.value.e);break;case"canvasMouseUpHandler":this.canvasMouseUpHandler(t.value.e);break;case"touchStartHandler":this.touchStartHandler(t.value.e);break;case"keyDownEventHandler":this.keyDownEventHandler(t.value.e);break;case"handleScroll":this.handleScroll(t.value.e);break;case"textKeyDown":setTimeout(this.textKeyDown.bind(this),1,t.value.e);break;case"deleteItem":this.deleteItem();break;case"updatePrevShapeSettings":this.updatePrevShapeSettings(t.value.obj);break;case"getZoomType":t.value.obj.zoomType=this.zoomType;break;case"setZoomType":this.zoomType=t.value.zoomType;break;case"setInitialTextEdit":this.isInitialTextEdited=t.value.bool;break;case"setDragCanvas":this.dragCanvas=t.value.bool;break;case"setFreehandDrawCustomized":this.isFhdCustomized=t.value.isFreehandDrawCustomized;break;case"setTouchEndPoint":this.touchEndPoint.x=t.value.x,this.touchEndPoint.y=t.value.y;break;case"getPanDown":t.value.obj.panDown=this.panDown;break;case"setPanDown":this.panDown=t.value.panDown;break;case"getFreehandDrawEditing":t.value.obj.bool=this.isFhdEditing;break;case"setFreehandDrawEditing":this.isFhdEditing=t.value.bool;break;case"getTempActObj":t.value.obj.tempObj=this.tempActiveObj;break;case"setTempActObj":this.tempActiveObj=t.value.obj;break;case"isInside":this.isInside(t.value.x,t.value.y,t.value.z1,t.value.z2,t.value.z3,t.value.z4);break;case"setDragElement":this.dragElement=t.value.value;break;case"setObjSelected":this.isObjSelected=t.value.bool;break;case"adjustActObjForLineArrow":this.adjustActObjForLineArrow(t.value.obj);break;case"findTarget":this.findTarget(t.value.x,t.value.y,t.value.type);break;case"getCurrentFlipState":this.getCurrentFlipState();break;case"setDragWidth":this.setDragWidth(t.value.width);break;case"setDragHeight":this.setDragHeight(t.value.setDragHeight);break;case"annotate":this.currentDrawingShape=t.value.shape,"text"===t.value.shape?(this.parent.activeObj.textSettings.fontSize=100,this.parent.activeObj.keyHistory="Enter Text",this.parent.notify("shape",{prop:"initializeTextShape",onPropertyChange:!1,value:{text:null,fontFamily:null,fontSize:null,bold:null,italic:null,strokeColor:null}})):"path"===t.value.shape&&(this.parent.activeObj.pointColl=[]);break;case"getCurrentDrawingShape":t.value.obj.shape=this.currentDrawingShape;break;case"setCurrentDrawingShape":this.currentDrawingShape=t.value.value;break;case"getTransRotationPoint":this.getTransRotationPoint(t.value.obj,t.value.object);break;case"adjustNEPoints":this.adjustNEPoints(t.value.rectangle,t.value.x,t.value.y,t.value.angle);break;case"adjustRotationPoints":this.adjustRotationPoints(t.value.rectangle,t.value.x,t.value.y,t.value.angle);break;case"getResizeDirection":this.getResizeDirection(t.value.rectangle,t.value.x,t.value.y,t.value.angle);break;case"setResizedElement":this.resizedElement=t.value.value;break;case"reset":this.reset();break;case"unWireEvent":this.unwireEvent();break;case"updPtCollForShpRot":this.updPtCollForShpRot(t.value.obj)}},i.prototype.getModuleName=function(){return"selection"},i.prototype.updatePrivateVariables=function(){var t=this.parent;t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=this.isObjSelected=this.isFhdPoint=this.isShapeInserted=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.cursorTargetId=this.dragElement="",this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.isPreventDragging=!1,this.timer=void 0,this.tempObjColl=void 0,this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.panDown=null,this.isFhdEditing=!1,this.pathAdjustedIndex=null,this.touchTime=0,this.currentDrawingShape="",this.initialPrevObj={},this.resizedElement=""},i.prototype.performTabAction=function(){if("block"===this.parent.textArea.style.display){var t=this.applyCurrShape(!1);this.parent.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t&&this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},i.prototype.selMouseUpEvent=function(){this.oldPoint.x=void 0,this.oldPoint.y=void 0},i.prototype.getMouseCursor=function(t,e,i,o,r){var a=this.getTransRotationPoint(t),n=r?0:2*t.topLeftCircle.radius;return e>=t.topLeftCircle.startX-n&&e<=t.topLeftCircle.startX+n&&i>=t.topLeftCircle.startY-n&&i<=t.topLeftCircle.startY+n?"nw-resize":e>=t.topLeftCircle.startX-n&&e<=t.topRightCircle.startX-n&&i>=t.topCenterCircle.startY-n&&i<=t.topCenterCircle.startY+n?"n-resize":e>=t.topRightCircle.startX-n&&e<=t.topRightCircle.startX+n&&i>=t.topRightCircle.startY-n&&i<=t.topRightCircle.startY+n?"ne-resize":e>=t.centerLeftCircle.startX-n&&e<=t.centerLeftCircle.startX+n&&i>=t.topLeftCircle.startY-n&&i<=t.bottomLeftCircle.startY-n?"w-resize":e>=t.centerRightCircle.startX-n&&e<=t.centerRightCircle.startX+n&&i>=t.topRightCircle.startY-n&&i<=t.bottomRightCircle.startY-n?"e-resize":e>=t.bottomLeftCircle.startX-n&&e<=t.bottomLeftCircle.startX+n&&i>=t.bottomLeftCircle.startY-n&&i<=t.bottomLeftCircle.startY+n?"sw-resize":e>=t.bottomLeftCircle.startX-n&&e<=t.bottomRightCircle.startX-n&&i>=t.bottomCenterCircle.startY-n&&i<=t.bottomCenterCircle.startY+n?"s-resize":e>=t.bottomRightCircle.startX-n&&e<=t.bottomRightCircle.startX+n&&i>=t.bottomRightCircle.startY-n&&i<=t.bottomRightCircle.startY+n?"se-resize":e>=t.activePoint.startX&&e<=t.activePoint.endX&&i>=t.activePoint.startY&&i<=t.activePoint.endY?o?"grab":"move":a&&!r&&e>=a.x-(t.bottomCenterCircle.radius+2)&&e<=a.x+(t.bottomCenterCircle.radius+2)&&i>=a.y-(t.bottomCenterCircle.radius+2)&&i<=a.y+(t.bottomCenterCircle.radius+2)?"grabbing":"default"},i.prototype.setCursor=function(t,i){var o,r=this.parent,a=document.querySelector("#"+r.element.id+"_lowerCanvas"),n=document.querySelector("#"+r.element.id+"_upperCanvas"),s=!1;if(""!==this.currentDrawingShape)return void(n.style.cursor=r.cursor="crosshair");if(r.currObjType.isDragging)return void(""===this.dragElement?n.style.cursor=r.cursor="move":n.style.cursor=r.cursor=this.dragElement);if(void 0!==r.activeObj.horTopLine){void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-")),void 0===o&&r.currObjType.isCustomCrop?s=!0:void 0!==o&&"crop"===o[0]&&(s=!0),!s&&r.togglePan&&(a.style.cursor=n.style.cursor=r.cursor="grab");var l=n.style.cursor,p=e.extend({},r.activeObj,{},!0);this.cursorTargetId=p.currIndex;var h=void 0;(h=0===p.shapeDegree?r.transform.degree:r.transform.degree-p.shapeDegree)<0&&(h=360+h),"line"===p.shape||"arrow"===p.shape?this.setCursorForLineArrow(p,t,i,n):"path"===p.shape?this.setCursorForPath(p,t,i,n):e.isNullOrUndefined(p.rotatedAngle)||0===p.rotatedAngle?(n.style.cursor=r.cursor=this.getMouseCursor(p,t,i,s,!1),"text"!==p.shape||"n-resize"!==r.cursor&&"s-resize"!==r.cursor&&"e-resize"!==r.cursor&&"w-resize"!==r.cursor||(n.style.cursor=r.cursor="move")):this.setCursorForRotatedObject(p,t,i,n),"default"===l&&"default"===r.cursor&&s&&(n.style.cursor=r.cursor="grab"),"grab"===l&&"default"===r.cursor&&(n.style.cursor=r.cursor="grab")}else r.togglePan&&!r.togglePen?a.style.cursor=n.style.cursor=r.cursor="grab":r.currObjType.isCustomCrop||r.togglePen?n.style.cursor=r.cursor="crosshair":n.style.cursor=r.cursor="default";if("default"===r.cursor||"grab"===r.cursor){l=n.style.cursor;r.objColl.length>0&&("grab"!==r.cursor||!s)&&this.setCursorFromObj(t,i,r.objColl,n,s),"grab"===l&&"default"===r.cursor&&(n.style.cursor=r.cursor="grab")}"default"!==r.cursor&&"grab"!==r.cursor||!r.pointColl[0]||"grab"===r.cursor&&s||r.currObjType.isDragging||r.currObjType.isResize||this.setCursorForFreehandDrawing(t,i,n)},i.prototype.setCursorForPath=function(t,i,o,r){this.setCursorForLineArrow(t,i,o,r);var a=this.parent;if("default"===a.cursor)for(var n=e.extend({},t,null,!0),s=!1,l=1;l<t.pointColl.length&&!s;l++){n.activePoint.startX=t.pointColl[l-1].x,n.activePoint.startY=t.pointColl[l-1].y,n.activePoint.endX=t.pointColl[l].x,n.activePoint.endY=t.pointColl[l].y,a.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:n}});for(var p=0;p<n.pointColl.length;p++){var h=n.pointColl[p];if(!e.isNullOrUndefined(h.x-2*t.topLeftCircle.radius)&&!e.isNullOrUndefined(h.x+2*t.topLeftCircle.radius)&&!e.isNullOrUndefined(h.y-2*t.topLeftCircle.radius)&&!e.isNullOrUndefined(h.y+2*t.topLeftCircle.radius)&&i>=h.x-2*t.topLeftCircle.radius&&i<=h.x+2*t.topLeftCircle.radius&&o>=h.y-2*t.topLeftCircle.radius&&o<=h.y+2*t.topLeftCircle.radius){r.style.cursor=a.cursor="move",s=!0;break}r.style.cursor=a.cursor="default"}}return a.cursor},i.prototype.setCursorForLineArrow=function(t,e,i,o){for(var r,a=0;a<t.pointColl.length;a++){var n=t.pointColl[a];if(e>=n.x-2*t.topLeftCircle.radius&&e<=n.x+2*t.topLeftCircle.radius&&i>=n.y-2*t.topLeftCircle.radius&&i<=n.y+2*t.topLeftCircle.radius){o.style.cursor=this.parent.cursor="move",r=a;break}o.style.cursor=this.parent.cursor="default"}return r},i.prototype.setCursorForRotatedObject=function(t,e,i,o){this.resizedElement="";var r=this.parent;if(e>=t.horTopLinePointColl[0].x-(t.bottomCenterCircle.radius+2)&&e<=t.horTopLinePointColl[0].x+(t.bottomCenterCircle.radius+2)&&i>=t.horTopLinePointColl[0].y-(t.bottomCenterCircle.radius+2)&&i<=t.horTopLinePointColl[0].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="nw-resize":e>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].x-5&&e<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].x+5&&i>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].y-5&&i<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="n-resize":e>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].x-(t.bottomCenterCircle.radius+2)&&e<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].x+(t.bottomCenterCircle.radius+2)&&i>=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].y-(t.bottomCenterCircle.radius+2)&&i<=t.horTopLinePointColl[Math.round(t.horTopLinePointColl.length-1)].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="ne-resize":e>=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].x-5&&e<=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].x+5&&i>=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].y-5&&i<=t.verLeftLinePointColl[Math.round(t.verLeftLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="w-resize":e>=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].x-5&&e<=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].x+5&&i>=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].y-5&&i<=t.verRightLinePointColl[Math.round(t.verRightLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="e-resize":e>=t.horBottomLinePointColl[0].x-(t.bottomCenterCircle.radius+2)&&e<=t.horBottomLinePointColl[0].x+(t.bottomCenterCircle.radius+2)&&i>=t.horBottomLinePointColl[0].y-(t.bottomCenterCircle.radius+2)&&i<=t.horBottomLinePointColl[0].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="sw-resize":e>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].x-5&&e<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].x+5&&i>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].y-5&&i<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length/2)].y+5?o.style.cursor=r.cursor=this.resizedElement="s-resize":e>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].x-(t.bottomCenterCircle.radius+2)&&e<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].x+(t.bottomCenterCircle.radius+2)&&i>=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].y-(t.bottomCenterCircle.radius+2)&&i<=t.horBottomLinePointColl[Math.round(t.horBottomLinePointColl.length-1)].y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="se-resize":t.rotationCirclePointColl&&e>=t.rotationCirclePointColl.x-(t.bottomCenterCircle.radius+2)&&e<=t.rotationCirclePointColl.x+(t.bottomCenterCircle.radius+2)&&i>=t.rotationCirclePointColl.y-(t.bottomCenterCircle.radius+2)&&i<=t.rotationCirclePointColl.y+(t.bottomCenterCircle.radius+2)?o.style.cursor=r.cursor="grabbing":(o.style.cursor=r.cursor="default",this.getRectanglePoints(t.activePoint.startX,t.activePoint.startY,t.activePoint.width,t.activePoint.height,t.rotatedAngle*(180/Math.PI),e,i)&&(o.style.cursor=r.cursor="move")),"default"===r.cursor)for(var a=0,n=t.horTopLinePointColl.length;a<n;a++)if(e>=t.horTopLinePointColl[a].x-5&&e<=t.horTopLinePointColl[a].x+5&&i>=t.horTopLinePointColl[a].y-5&&i<=t.horTopLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="n-resize";break}if("default"===r.cursor)for(var a=0,n=t.horBottomLinePointColl.length;a<n;a++)if(e>=t.horBottomLinePointColl[a].x-5&&e<=t.horBottomLinePointColl[a].x+5&&i>=t.horBottomLinePointColl[a].y-5&&i<=t.horBottomLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="s-resize";break}if("default"===r.cursor)for(var a=0,n=t.verLeftLinePointColl.length;a<n;a++)if(e>=t.verLeftLinePointColl[a].x-5&&e<=t.verLeftLinePointColl[a].x+5&&i>=t.verLeftLinePointColl[a].y-5&&i<=t.verLeftLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="w-resize";break}if("default"===r.cursor)for(var a=0,n=t.verRightLinePointColl.length;a<n;a++)if(e>=t.verRightLinePointColl[a].x-5&&e<=t.verRightLinePointColl[a].x+5&&i>=t.verRightLinePointColl[a].y-5&&i<=t.verRightLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="e-resize";break}return this.adjustCursorStylesForRotatedState(t),r.cursor},i.prototype.adjustCursorStylesForRotatedState=function(t){var e=this.parent,i=t.rotatedAngle*(180/Math.PI);if((i=i>0?Math.floor(i):Math.ceil(i))>=92&&i<=182||i>=-178&&i<=-88){var o={"nw-resize":"ne-resize","n-resize":"s-resize","ne-resize":"nw-resize","w-resize":"e-resize","e-resize":"w-resize","sw-resize":"se-resize","s-resize":"n-resize","se-resize":"sw-resize"};e.cursor in o&&(e.cursor=o[e.cursor])}return e.upperCanvas.style.cursor=this.getResizeElement(t.rotatedAngle*(180/Math.PI),e.cursor),e.cursor},i.prototype.getResizeElement=function(t,e){var i=[];"nw-resize"===e?i=[[337.5,22.5,"nw-resize"],[22.5,67.5,"n-resize"],[67.5,112.5,"ne-resize"],[112.5,157.5,"e-resize"],[157.5,202.5,"se-resize"],[202.5,247.5,"s-resize"],[247.5,292.5,"sw-resize"],[292.5,337.5,"w-resize"]]:"n-resize"===e?i=[[337.5,22.5,"n-resize"],[22.5,67.5,"ne-resize"],[67.5,112.5,"e-resize"],[112.5,157.5,"se-resize"],[157.5,202.5,"s-resize"],[202.5,247.5,"sw-resize"],[247.5,292.5,"w-resize"],[292.5,337.5,"nw-resize"]]:"ne-resize"===e?i=[[337.5,22.5,"ne-resize"],[22.5,67.5,"e-resize"],[67.5,112.5,"se-resize"],[112.5,157.5,"s-resize"],[157.5,202.5,"sw-resize"],[202.5,247.5,"w-resize"],[247.5,292.5,"nw-resize"],[292.5,337.5,"n-resize"]]:"e-resize"===e?i=[[337.5,22.5,"e-resize"],[22.5,67.5,"se-resize"],[67.5,112.5,"s-resize"],[112.5,157.5,"sw-resize"],[157.5,202.5,"w-resize"],[202.5,247.5,"nw-resize"],[247.5,292.5,"n-resize"],[292.5,337.5,"ne-resize"]]:"se-resize"===e?i=[[337.5,22.5,"se-resize"],[22.5,67.5,"s-resize"],[67.5,112.5,"sw-resize"],[112.5,157.5,"w-resize"],[157.5,202.5,"nw-resize"],[202.5,247.5,"n-resize"],[247.5,292.5,"ne-resize"],[292.5,337.5,"e-resize"]]:"s-resize"===e?i=[[337.5,22.5,"s-resize"],[22.5,67.5,"sw-resize"],[67.5,112.5,"w-resize"],[112.5,157.5,"nw-resize"],[157.5,202.5,"n-resize"],[202.5,247.5,"ne-resize"],[247.5,292.5,"e-resize"],[292.5,337.5,"se-resize"]]:"sw-resize"===e?i=[[337.5,22.5,"sw-resize"],[22.5,67.5,"w-resize"],[67.5,112.5,"nw-resize"],[112.5,157.5,"n-resize"],[157.5,202.5,"ne-resize"],[202.5,247.5,"e-resize"],[247.5,292.5,"se-resize"],[292.5,337.5,"s-resize"]]:"w-resize"===e&&(i=[[337.5,22.5,"w-resize"],[22.5,67.5,"nw-resize"],[67.5,112.5,"n-resize"],[112.5,157.5,"ne-resize"],[157.5,202.5,"e-resize"],[202.5,247.5,"se-resize"],[247.5,292.5,"s-resize"],[292.5,337.5,"sw-resize"]]);for(var o=t<0?360-Math.abs(t):t,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return e},i.prototype.setCursorForFreehandDrawing=function(t,i,o){var r=o.getContext("2d"),a=this.parent,n=document.querySelector("#"+a.element.id+"_textArea"),s=!1;a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:-1}});for(var l,p=0;p<a.freehandCounter;p++){var h={selPointColl:{}};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),l=e.extend([],h.selPointColl[p].points,[]),a.points=e.extend([],a.pointColl[p].points,[]),a.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var c=l.length,d=0;d<c;d++)if(0!==d){var v=!1;if(l[d-1]&&l[d]&&(v=this.isInside(t,i,l[d-1].x,l[d-1].y,l[d].x,l[d].y)),v){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}else a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:null}});this.isFhdPoint=!1}}else{if(t>a.points[d].x-a.pointColl[p].strokeWidth&&t<a.points[d].x+a.pointColl[p].strokeWidth&&i>a.points[d].y-a.pointColl[p].strokeWidth&&i<a.points[d].y+a.pointColl[p].strokeWidth){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){var u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}this.isFhdPoint=!1}}if(s)break}},i.prototype.setCursorFromObj=function(t,i,o,r,a){for(var n=this.parent,s=0,l=o.length;s<l;s++){if("move"===n.cursor)return;var p=e.extend({},o[s],{},!0);this.cursorTargetId=p.currIndex,"line"===p.shape||"arrow"===p.shape?this.setCursorForLineArrow(p,t,i,r):"path"===p.shape?this.setCursorForPath(p,t,i,r):e.isNullOrUndefined(p.rotatedAngle)||0===p.rotatedAngle?r.style.cursor=n.cursor=this.getMouseCursor(p,t,i,a,!0):this.setCursorForRotatedObject(p,t,i,r)}},i.prototype.isInside=function(t,e,i,o,r,a){var n=Math.min(i,r),s=Math.max(i,r),l=Math.min(o,a),p=Math.max(o,a);return n<=t&&t<=s&&l<=e&&e<=p},i.prototype.updateActivePoint=function(t,i,o){var r=this.parent,a={width:0,height:0};r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:r.activeObj.activePoint.width,height:r.activeObj.activePoint.height,obj:a}});var n=a,s=this.updatePrevShapeSettings(),l={action:"resize",previousShapeSettings:s},p={action:"move",previousShapeSettings:s};e.isNullOrUndefined(this.shapeResizingArgs)&&(this.shapeResizingArgs=l),e.isNullOrUndefined(this.shapeMovingArgs)&&(this.shapeMovingArgs=p),"text"===r.activeObj.shape&&""!==this.dragElement&&r.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:r.activeObj,isTextArea:null}}),""===this.currentDrawingShape||""!==this.dragElement&&"move"!==this.dragElement||("line"===r.activeObj.shape||"arrow"===r.activeObj.shape||"path"===r.activeObj.shape?this.dragElement="e-resize":t>r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="se-resize":t<r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="sw-resize":t>r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY?this.dragElement="ne-resize":t<r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY&&(this.dragElement="nw-resize")),"arrow"===r.activeObj.shape&&(Math.atan2(t-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)>0?r.activeObj.rotatedAngle=-Math.atan2(t-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2):r.activeObj.rotatedAngle=Math.abs(Math.atan2(t-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)));var h,c=!1,d=!1;switch(this.dragElement.toLowerCase()){case"nw-resize":this.updateNWPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"n-resize":this.updateNPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"ne-resize":this.updateNEPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"w-resize":this.updateWPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"e-resize":this.updateEPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"sw-resize":this.updateSWPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"s-resize":this.updateSPoints(t,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"se-resize":this.updateSEPoints(t,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"grabbing":Math.atan2(t-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))>0?r.activeObj.rotatedAngle=-Math.atan2(t-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2)):r.activeObj.rotatedAngle=Math.abs(Math.atan2(t-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))),(h=0===r.activeObj.shapeDegree?r.transform.degree:r.transform.degree-r.activeObj.shapeDegree)<0&&(h=360+h);for(var v=0,u=r.activeObj.flipObjColl.length;v<u;v++)"horizontal"===r.activeObj.flipObjColl[v].toLowerCase()?c=!0:"vertical"===r.activeObj.flipObjColl[v].toLowerCase()&&(d=!0);r.activeObj.rotatedAngle-=h*(Math.PI/180),0===h||360===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):90===h||-270===h?c&&(r.activeObj.rotatedAngle-=Math.PI/180*180):180===h||-180===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):270!==h&&-90!==h||c&&(r.activeObj.rotatedAngle-=Math.PI/180*180);break;case"pathdrag":e.isNullOrUndefined(this.pathAdjustedIndex)||(r.activeObj.pointColl[this.pathAdjustedIndex].x=t,r.activeObj.pointColl[this.pathAdjustedIndex].y=i);break;default:if(!o&&!r.currObjType.isCustomCrop){if(this.dragPoint.startX){var g=this.dragPoint.endX-this.previousPoint.x,b=this.dragPoint.endY-this.previousPoint.y;if(r.activeObj.activePoint.startX+=g,r.activeObj.activePoint.endX+=g,r.activeObj.activePoint.startY+=b,r.activeObj.activePoint.endY+=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x+=g,r.activeObj.rotationCirclePointColl.y+=b,r.activeObj.rotationCirclePoint.x+=g,r.activeObj.rotationCirclePoint.y+=b),"path"===r.activeObj.shape)for(var v=0,u=r.activeObj.pointColl.length;v<u;v++)r.activeObj.pointColl[v].x+=g,r.activeObj.pointColl[v].y+=b;!this.isPreventDragging&&(r.activeObj.activePoint.startX<r.img.destLeft||r.activeObj.activePoint.startY<r.img.destTop||r.activeObj.activePoint.endX>r.img.destLeft+r.img.destWidth||r.activeObj.activePoint.endY>r.img.destTop+r.img.destHeight)&&(r.activeObj.activePoint.startX-=g,r.activeObj.activePoint.endX-=g,r.activeObj.activePoint.startY-=b,r.activeObj.activePoint.endY-=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x-=g,r.activeObj.rotationCirclePointColl.y-=b,r.activeObj.rotationCirclePoint.x-=g,r.activeObj.rotationCirclePoint.y-=b),this.setDragWidth(g),this.setDragHeight(b))}else r.activeObj.activePoint.startX=t<this.mouseDownPoint.x?t:this.mouseDownPoint.x,r.activeObj.activePoint.startY=i<this.mouseDownPoint.y?i:this.mouseDownPoint.y,t=t<this.mouseDownPoint.x?this.mouseDownPoint.x:t,i=i<this.mouseDownPoint.y?this.mouseDownPoint.y:i,r.activeObj.activePoint.endX=t,r.activeObj.activePoint.endY=i;this.triggerShapeChange(l,p,"move")}}},i.prototype.triggerShapeChange=function(t,i,o){var r=this.parent;r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY;var a=this.updatePrevShapeSettings();if(t.currentShapeSettings=a,i.currentShapeSettings=a,"resize"===o){this.isCropSelection=!1;var n=void 0;if(void 0!==r.activeObj.shape&&(n=r.activeObj.shape.split("-")),void 0!==n&&"crop"===n[0]&&(this.isCropSelection=!0),!this.isCropSelection&&"resize"!==this.parent.eventType&&e.isBlazor()&&r.events&&!0===this.parent.events.onShapeResizeStart.hasDelegate)t.action="resize-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeStart",t).then(function(t){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})});else if(this.isCropSelection){var s={action:t.action,previousSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:t.previousShapeSettings.startX,startY:t.previousShapeSettings.startY,width:t.previousShapeSettings.width,height:t.previousShapeSettings.height},currentSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:t.currentShapeSettings.startX,startY:t.currentShapeSettings.startY,width:t.currentShapeSettings.width,height:t.currentShapeSettings.height}};e.isNullOrUndefined(this.selectionResizingArgs)&&(this.selectionResizingArgs=s),e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onSelectionResizeStart.hasDelegate?(s.action="resize-start",r.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(t){r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:t.currentSelectionSettings}})})):(r.trigger("selectionChanging",s),r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}))}else r.trigger("shapeChanging",t),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})}else e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onShapeDragStart.hasDelegate?(i.action="drag-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragStart",i).then(function(t){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})})):(r.trigger("shapeChanging",i),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:i.currentShapeSettings}}));this.parent.eventType=o},i.prototype.setDragWidth=function(t){var e=this.parent,i=t;if(i>=0)for(o=0;o<i&&(t=i-o,e.activeObj.activePoint.startX+=t,e.activeObj.activePoint.endX+=t,!(e.activeObj.activePoint.startX>=e.img.destLeft&&e.activeObj.activePoint.endX<=e.img.destLeft+e.img.destWidth));o++)e.activeObj.activePoint.startX-=t,e.activeObj.activePoint.endX-=t;else for(var o=1;o<Math.abs(i)&&(t=i+o,e.activeObj.activePoint.startX+=t,e.activeObj.activePoint.endX+=t,!(e.activeObj.activePoint.startX>=e.img.destLeft&&e.activeObj.activePoint.endX<=e.img.destLeft+e.img.destWidth));o++)e.activeObj.activePoint.startX-=t,e.activeObj.activePoint.endX-=t},i.prototype.setDragHeight=function(t){var e=this.parent,i=t;if(i>=0)for(o=1;o<i&&(t=i-o,e.activeObj.activePoint.startY+=t,e.activeObj.activePoint.endY+=t,!(e.activeObj.activePoint.startY>=e.img.destTop&&e.activeObj.activePoint.endY<=e.img.destTop+e.img.destHeight));o++)e.activeObj.activePoint.startY-=t,e.activeObj.activePoint.endY-=t;else for(var o=0;o<Math.abs(i)&&(t=i+o,e.activeObj.activePoint.startY+=t,e.activeObj.activePoint.endY+=t,!(e.activeObj.activePoint.startY>=e.img.destTop&&e.activeObj.activePoint.endY<=e.img.destTop+e.img.destHeight));o++)e.activeObj.activePoint.startY-=t,e.activeObj.activePoint.endY-=t},i.prototype.limitDrag=function(t){var e=this.parent,i=t?e.activeObj.activePoint.startX:e.activeObj.activePoint.endX,o=t?e.activeObj.activePoint.startY:e.activeObj.activePoint.endY,r=t?e.activeObj.activePoint.endX:e.activeObj.activePoint.startX,a=t?e.activeObj.activePoint.endY:e.activeObj.activePoint.startY;i<e.img.destLeft&&(i=e.img.destLeft),o<e.img.destTop&&(o=e.img.destTop),r>e.img.destLeft+e.img.destWidth&&(r=e.img.destLeft+e.img.destWidth),a>e.img.destTop+e.img.destHeight&&(a=e.img.destTop+e.img.destHeight),t?(e.activeObj.activePoint.startX=i,e.activeObj.activePoint.startY=o,e.activeObj.activePoint.endX=r,e.activeObj.activePoint.endY=a):(e.activeObj.activePoint.startX=r,e.activeObj.activePoint.startY=a,e.activeObj.activePoint.endX=i,e.activeObj.activePoint.endY=o)},i.prototype.preventDraggingInvertly=function(){var t=this.parent;this.isPreventDragging||0!==t.activeObj.rotatedAngle||(this.limitDrag(!0),"line"!==t.activeObj.shape&&"arrow"!==t.activeObj.shape&&"path"!==t.activeObj.shape||this.limitDrag(!1))},i.prototype.preventTextDraggingInvertly=function(){var t=this.parent,e=!1;return this.isPreventDragging||(t.activeObj.activePoint.startX<t.img.destLeft||t.activeObj.activePoint.startY<t.img.destTop||t.activeObj.activePoint.endX>t.img.destLeft+t.img.destWidth||t.activeObj.activePoint.endY>t.img.destTop+t.img.destHeight)&&(e=!0),e},i.prototype.preventInverseResize=function(t){var e=this.parent;e.activeObj.activePoint.width<0&&(e.activeObj.activePoint.width=0,e.activeObj.activePoint.startX=t.activePoint.startX,e.activeObj.activePoint.endX=t.activePoint.endX),e.activeObj.activePoint.height<0&&(e.activeObj.activePoint.height=0,e.activeObj.activePoint.startY=t.activePoint.startY,e.activeObj.activePoint.endY=t.activePoint.endY)},i.prototype.getScaleRatio=function(t){var e=this.parent,i={x:t,y:t};if(e.activeObj.shape&&"crop-custom"!==e.activeObj.shape&&"crop-circle"!==e.activeObj.shape&&"crop-square"!==e.activeObj.shape){var o=e.activeObj.shape.split("-");if(o.length>1){o=o[1].split(":");var r=t/parseInt(o[1],10);i.x=r*parseInt(o[0],10),i.y=r*parseInt(o[1],10)}}return i},i.prototype.updateNWPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=l.activeObj.activePoint.startX-t,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=this.oldPoint.x-t,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustNWPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){var v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<t&&l.activeObj.activePoint.startY<i){r=t-l.activeObj.activePoint.startX,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.startY+=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,g=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.startY<g)&&(l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.startY-=b.y)}else{r=l.activeObj.activePoint.startX-t,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.startY-=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,C=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.startY<C)&&(l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.startY+=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateNPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.startY>a.activeObj.activePoint.endY){var s=a.activeObj.activePoint.startY;a.activeObj.activePoint.startY=a.activeObj.activePoint.endY,a.activeObj.activePoint.endY=s,this.dragElement=this.resizedElement="s-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>t&&a.activeObj.activePoint.startY<e){i=a.activeObj.activePoint.endX-t,o=e-a.activeObj.activePoint.startY,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y)}else{i=t-a.activeObj.activePoint.endX,o=a.activeObj.activePoint.startY-e,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateNEPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=t-l.activeObj.activePoint.endX,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=t-this.oldPoint.x,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustNEPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){v=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){var v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>t&&l.activeObj.activePoint.startY<i){r=l.activeObj.activePoint.endX-t,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.startY+=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.startY<g)&&(l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.startY-=b.y)}else{r=t-l.activeObj.activePoint.endX,a=l.activeObj.activePoint.startY-i,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.startY-=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.startY<g)&&(l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.startY+=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateWPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startX=t,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.startY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="e-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.startX>a.activeObj.activePoint.endX){var s=a.activeObj.activePoint.startX;a.activeObj.activePoint.startX=a.activeObj.activePoint.endX,a.activeObj.activePoint.endX=s,this.dragElement=this.resizedElement="e-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.startX<t&&a.activeObj.activePoint.endY>e){i=t-a.activeObj.activePoint.startX,o=a.activeObj.activePoint.endY-e,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=a.activeObj.activePoint.startX-t,o=e-a.activeObj.activePoint.endY,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateEPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endX=t,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.endY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="w-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.endX<a.activeObj.activePoint.startX){var s=a.activeObj.activePoint.endX;a.activeObj.activePoint.endX=a.activeObj.activePoint.startX,a.activeObj.activePoint.startX=s,this.dragElement=this.resizedElement="w-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>t&&a.activeObj.activePoint.endY>e){i=a.activeObj.activePoint.endX-t,o=a.activeObj.activePoint.endY-e,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=t-a.activeObj.activePoint.endX,o=e-a.activeObj.activePoint.endY,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSWPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)e.isNullOrUndefined(this.oldPoint.x)&&e.isNullOrUndefined(this.oldPoint.y)?(this.diffPoint.x=l.activeObj.activePoint.startX-t,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=this.oldPoint.x-t,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.endY+=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.endY-=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustSWPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){var v=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<t&&l.activeObj.activePoint.endY>i){r=t-l.activeObj.activePoint.startX,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.endY-=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.endY+=b.y)}else{r=l.activeObj.activePoint.startX-t,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.startX-=b.x,l.activeObj.activePoint.endY+=b.y;var u=l.img.destLeft>0?l.img.destLeft:0,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.startX+=b.x,l.activeObj.activePoint.endY-=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateSPoints=function(t,e){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endY=e,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.endY<a.activeObj.activePoint.startY){var s=a.activeObj.activePoint.endY;a.activeObj.activePoint.endY=a.activeObj.activePoint.startY,a.activeObj.activePoint.startY=s,this.dragElement=this.resizedElement="n-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>t&&a.activeObj.activePoint.endY>e){i=a.activeObj.activePoint.endX-t,o=a.activeObj.activePoint.endY-e,r=Math.min(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=t-a.activeObj.activePoint.endX,o=e-a.activeObj.activePoint.endY,r=Math.max(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.x,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSEPoints=function(t,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=e.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=t-l.activeObj.activePoint.endX,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=t-this.oldPoint.x,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=t,this.oldPoint.y=i,s=(this.diffPoint.x>=p&&this.diffPoint.y>=h?Math.max(this.diffPoint.x,this.diffPoint.y):Math.min(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/50*s,l.activeObj.activePoint.endY+=o.height/50*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/50*s,l.activeObj.activePoint.endY-=o.height/50*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if(this.adjustSEPoints(l.activeObj.activePoint,t,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){v=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){var v=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>t&&l.activeObj.activePoint.endY>i){r=l.activeObj.activePoint.endX-t,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a);b=this.getScaleRatio(n);l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.endY-=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.endY+=b.y)}else{r=t-l.activeObj.activePoint.endX,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);var b=this.getScaleRatio(n);l.activeObj.activePoint.endX+=b.x,l.activeObj.activePoint.endY+=b.y;var u=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,g=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>u||l.activeObj.activePoint.endY>g)&&(l.activeObj.activePoint.endX-=b.x,l.activeObj.activePoint.endY-=b.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.adjustNWPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.endX,t.endY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.endX=l[0],t.endY=l[1],t.startY=p[1],t.startX=p[0],t.width=t.endX-t.startX,t.height=t.endY-t.startY,t},i.prototype.adjustNEPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.startX,t.endY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.startX=l[0],t.endY=l[1],t.width=p[0]-l[0],t.height=l[1]-p[1],t.endX=t.startX+t.width,t.startY=t.endY-t.height,t},i.prototype.adjustSWPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.endX,t.startY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.endX=l[0],t.startY=l[1],t.startX=p[0],t.endY=p[1],t.width=t.endX-t.startX,t.height=t.endY-t.startY,t},i.prototype.adjustSEPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2,n=this.rotatePoints(t.startX,t.startY,r,a,o),s=[(n[0]+e)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(e,i,s[0],s[1],-o);return t.startX=l[0],t.startY=l[1],t.width=p[0]-l[0],t.height=p[1]-l[1],t.endX=t.startX+t.width,t.endY=t.startY+t.height,t},i.prototype.adjustRotationPoints=function(t,e,i,o){var r=t.startX+t.width/2,a=t.startY+t.height/2;this.getResizeDirection(t,e,i,o);var n=this.rotatePoints(t.startX,t.startY,r,a,o),s=this.rotatePoints(t.endX,t.startY,r,a,o),l=this.rotatePoints(t.endX,t.endY,r,a,o),p=this.rotatePoints(t.startX,t.endY,r,a,o),h=[(n[0]+l[0])/2,(n[1]+l[1])/2],c=this.rotatePoints(n[0],n[1],h[0],h[1],-o),d=this.rotatePoints(p[0],p[1],h[0],h[1],-o),v=this.rotatePoints(s[0],s[1],h[0],h[1],-o);return t.startX=c[0],t.startY=c[1],t.endX=v[0],t.endY=d[1],t.width=t.endX-t.startX,t.height=t.endY-t.startY,t},i.prototype.rotatePoints=function(t,e,i,o,r){return[(t-i)*Math.cos(r)-(e-o)*Math.sin(r)+i,(t-i)*Math.sin(r)+(e-o)*Math.cos(r)+o]},i.prototype.setResizedValue=function(t,e,i,o){switch(t){case"x":e+=i;break;case"y":e+=o;break;case"abs-x":e+=i>0?-i:Math.abs(i);break;case"abs-y":e+=o>0?-o:Math.abs(o);break;case"y-abs-x":e+=o+(i>0?-i:Math.abs(i))/2;break;case"abs-x-abs-y":e+=(i>0?-i:Math.abs(i))+(o>0?-o:Math.abs(o))/2;break;case"abs-y-x":e+=(o>0?-o:Math.abs(o))+i/2;break;case"x-y":e+=i+o/2}return e},i.prototype.getResizeDirection=function(t,e,i,o){var r=o*(180/Math.PI),a=this.getResizedElement(r,this.resizedElement);"e-resize"===this.resizedElement?(t.width=this.setResizedValue(a,t.width,e,i),t.endX=t.width+t.startX):"n-resize"===this.resizedElement?(t.startY=this.setResizedValue(a,t.startY,e,i),t.height=t.endY-t.startY):"w-resize"===this.resizedElement?(t.startX=this.setResizedValue(a,t.startX,e,i),t.width=t.startX+t.endX):"s-resize"===this.resizedElement&&(t.height=this.setResizedValue(a,t.height,e,i),t.endY=t.height+t.startY)},i.prototype.getResizedElement=function(t,e){var i=[];"n-resize"===e?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"e-resize"===e?i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]:"s-resize"===e?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"w-resize"===e&&(i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]);for(var o=t<0?360-Math.abs(t):t,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return e},i.prototype.updateCursorStyles=function(t,i,o){var r=this.parent,a=!1;""===r.activeObj.keyHistory||void 0!==r.activeObj.shape||r.currObjType.isCustomCrop||r.currObjType.isLine||!r.currObjType.isText||(r.activeObj.shape="text");var n=e.extend({},r.activeObj,{},!0);if(!e.isNullOrUndefined(n.topLeftCircle)){var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),this.isObjSelected)if("line"===n.shape||"arrow"===n.shape)a=this.updateCursorStylesForLineArrow(t,i,n);else if("path"===n.shape)a=this.updateCursorStylesForPath(t,i,n);else if(n.rotatedAngle)this.setCursorForRotatedObject(n,t,i,r.upperCanvas),"grabbing"===r.cursor?(r.upperCanvas.style.cursor=this.parent.cursor="grabbing",this.dragElement=r.cursor):"move"===r.cursor?(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i):"default"!==r.cursor&&(a=!0,this.dragElement=r.cursor,r.currObjType.isResize=!0);else{var l=this.getTransRotationPoint(n);t>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.topLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.topLeftCircle.startY+2*n.topLeftCircle.radius&&"nw-resize"!==this.dragElement?(n.topLeftCircle.startX=n.topLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="nw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.topRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.topCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.topCenterCircle.startY+2*n.topLeftCircle.radius&&"n-resize"!==this.dragElement?(n.topCenterCircle.startX=n.topCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="n-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.topRightCircle.startX-2*n.topLeftCircle.radius&&t<=n.topRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.topRightCircle.startY+2*n.topLeftCircle.radius&&"ne-resize"!==this.dragElement?(n.topRightCircle.startX=n.topRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="ne-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.centerLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.centerLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&"w-resize"!==this.dragElement?(n.centerLeftCircle.startX=n.centerLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="w-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.centerRightCircle.startX-2*n.topLeftCircle.radius&&t<=n.centerRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&"e-resize"!==this.dragElement?(n.centerRightCircle.startX=n.centerRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="e-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.bottomLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY+2*n.topLeftCircle.radius&&"sw-resize"!==this.dragElement?(n.bottomLeftCircle.startX=n.bottomLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="sw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&t<=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.bottomCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomCenterCircle.startY+2*n.topLeftCircle.radius&&"s-resize"!==this.dragElement?(n.bottomCenterCircle.startX=n.bottomCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="s-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):t>=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&t<=n.bottomRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY+2*n.topLeftCircle.radius&&"se-resize"!==this.dragElement?(n.bottomRightCircle.startX=n.bottomRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="se-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):l&&t>=l.x-2*n.topLeftCircle.radius&&t<=l.x+2*n.topLeftCircle.radius&&i>=l.y-2*n.topLeftCircle.radius&&i<=l.y+2*n.topLeftCircle.radius&&"grabbing"!==this.dragElement?(r.upperCanvas.style.cursor=r.cursor="grabbing",this.dragElement=r.upperCanvas.style.cursor):(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i),"text"!==n.shape||"n-resize"!==r.cursor&&"s-resize"!==r.cursor&&"e-resize"!==r.cursor&&"w-resize"!==r.cursor||(r.upperCanvas.style.cursor=r.cursor="move",this.dragElement="",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}else this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i;this.previousPoint.x=this.previousPoint.y=this.diffPoint.x=this.diffPoint.y=0,"touchstart"===o?a||t>=n.activePoint.startX&&t<=n.activePoint.endX&&i>=n.activePoint.startY&&i<=n.activePoint.endY||"grabbing"===this.dragElement?r.currObjType.isDragging=!0:"line"===n.shape||"arrow"===n.shape?(this.setCursorForLineArrow(n,t,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):"path"===n.shape&&(this.setCursorForPath(n,t,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):r.currObjType.isDragging=!0,0===n.rotatedAngle||"e-resize"!==this.dragElement&&"w-resize"!==this.dragElement&&"n-resize"!==this.dragElement&&"s-resize"!==this.dragElement||(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}},i.prototype.updateCursorStylesForLineArrow=function(t,e,i){for(var o,r=!1,a=this.parent,n=0;n<5;n++)if(o=i.pointColl[n],t>=o.x-2*i.topLeftCircle.radius&&t<=o.x+2*i.topLeftCircle.radius&&e>=o.y-2*i.topLeftCircle.radius&&e<=o.y+2*i.topLeftCircle.radius){i.centerLeftCircle.startX=i.centerLeftCircle.startY=0,this.dragElement="w-resize",r=!0;break}if(!r)for(n=1;n<6;n++)if(o=i.pointColl[i.pointColl.length-n],t>=o.x-2*i.topLeftCircle.radius&&t<=o.x+2*i.topLeftCircle.radius&&e>=o.y-2*i.topLeftCircle.radius&&e<=o.y+2*i.topLeftCircle.radius){i.centerRightCircle.startX=i.centerRightCircle.startY=0,this.dragElement="e-resize",r=!0;break}if(!r)for(n=0;n<i.pointColl.length;n++){if(o=i.pointColl[n],t>=o.x-2*i.topLeftCircle.radius&&t<=o.x+2*i.topLeftCircle.radius&&e>=o.y-2*i.topLeftCircle.radius&&e<=o.y+2*i.topLeftCircle.radius){a.upperCanvas.style.cursor=a.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=e;break}a.upperCanvas.style.cursor=a.cursor="default"}return r},i.prototype.updateCursorStylesForPath=function(t,e,i){var o=!1;return this.pathAdjustedIndex=this.setCursorForLineArrow(i,t,e,this.parent.upperCanvas),"move"===this.parent.cursor&&(o=!0,this.dragElement="pathDrag"),o||(this.parent.upperCanvas.style.cursor=this.parent.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=e),o},i.prototype.setTextSelection=function(t,e){var i=this.parent,o=i.transform.degree;(o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o);for(var r=0,a=i.activeObj.flipObjColl.length;r<a;r++){var n=i.activeObj.flipObjColl[r].toLowerCase();switch(o){case 0:switch(n){case"horizontal":i.activeObj.activePoint={startX:i.activeObj.activePoint.endX-t,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)};break;case"vertical":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(t||0),endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(t||0),endY:i.activeObj.activePoint.startY+(e||0)}}break;case 90:switch(n){case"horizontal":i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)};break;case"vertical":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-t,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)}}break;case 180:switch(n){case"horizontal":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+t,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+e,i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(t||0),startY:i.activeObj.activePoint.startY};break;default:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(t||0),startY:i.activeObj.activePoint.endY-(e||0)}}break;case 270:switch(n){case"horizontal":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(t||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+e,endY:i.activeObj.activePoint.startY+(t||0)};break;default:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(t||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}}}if(0===i.activeObj.flipObjColl.length)switch(o){case 0:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(t||0),endY:i.activeObj.activePoint.startY+(e||0)};break;case 90:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)};break;case 180:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(t||0),startY:i.activeObj.activePoint.endY-(e||0)};break;case 270:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+e,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(t||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}i.activeObj.activePoint.width=i.activeObj.activePoint.endX-i.activeObj.activePoint.startX,i.activeObj.activePoint.height=i.activeObj.activePoint.endY-i.activeObj.activePoint.startY,360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},i.prototype.setActivePoint=function(t,i){var o=this.parent;if(!e.isNullOrUndefined(o.activeObj.activePoint))if(o.currObjType.isText){var r=t||0,a=i||o.activeObj.textSettings.fontSize;void 0===o.activeObj.textSettings.fontSize&&(o.activeObj.textSettings.fontSize=.1*Math.abs(o.baseImg.width-o.baseImg.height)),this.setTextSelection(r,a),this.mouseDownPoint.x=o.activeObj.activePoint.endX,this.mouseDownPoint.y=o.activeObj.activePoint.endY,void 0!==o.activeObj.horTopLine&&(o.activeObj.activePoint=e.extend({},o.activeObj.activePoint,{},!0)),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})}else if(t&&i)o.activeObj.activePoint.startX=this.mouseDownPoint.x=t,o.activeObj.activePoint.startY=this.mouseDownPoint.y=i,o.currObjType.isDragging=!0;else{var n=o.activeObj;o.activeObj.activePoint={startX:n.horTopLine.startX,startY:n.horTopLine.startY,endX:n.horTopLine.endX,endY:n.horTopLine.endY},o.activeObj.activePoint.width=o.activeObj.activePoint.endX-o.activeObj.activePoint.startX,o.activeObj.activePoint.height=o.activeObj.activePoint.endY-o.activeObj.activePoint.startY}},i.prototype.mouseDownEventHandler=function(t){var i=this,o=this.parent;if("touchstart"===t.type?this.isTouch=!0:this.isTouch=!1,"touchstart"!==t.type||t.currentTarget!==o.lowerCanvas||o.isImageLoaded){this.isCropSelection=!1,this.isPan=!0;var r;void 0!==o.activeObj.shape&&(r=o.activeObj.shape.split("-")),void 0!==r&&"crop"===r[0]&&(this.isCropSelection=!0),this.isCropSelection&&(this.dragCanvas=o.togglePan=!0);var a={point:this.setXYPoints(t)};e.isBlazor()&&o.events&&!0===o.events.clicked.hasDelegate?o.dotNetRef.invokeMethodAsync("ClickEventAsync","click",a).then(function(e){i.clickEvent(e,t)}):(o.trigger("click",a),this.clickEvent(a,t))}},i.prototype.getImagePoints=function(t,e){var i=this.parent;return t<i.img.destLeft?t=i.img.destLeft:t>i.img.destLeft+i.img.destWidth&&(t=i.img.destLeft+i.img.destWidth),e<i.img.destTop?e=i.img.destTop:e>i.img.destTop+i.img.destHeight&&(e=i.img.destTop+i.img.destHeight),{x:t,y:e}},i.prototype.clickEvent=function(t,i){var o=this.parent,r=t.point.x,a=t.point.y,n=o.activeObj.shape&&"text"===o.activeObj.shape?o.cursor:"default";if(""!==this.currentDrawingShape){var s={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),this.initialPrevObj=s.currObj,this.initialPrevObj.objColl=e.extend([],o.objColl,[],!0),this.initialPrevObj.pointColl=e.extend([],o.pointColl,[],!0),this.initialPrevObj.afterCropActions=e.extend([],o.afterCropActions,[],!0);var l={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),this.initialPrevObj.selPointColl=e.extend([],l.selPointColl,[],!0),this.setActivePoint(r,a),"path"===this.currentDrawingShape){var p=this.getImagePoints(r,a);o.activeObj.pointColl.push({x:p.x,y:p.y}),0!==o.activeObj.activePoint.width&&0!==o.activeObj.activePoint.height&&(o.activeObj.activePoint.width=0,o.activeObj.activePoint.height=0,o.activeObj.activePoint.startX=o.activeObj.pointColl[o.activeObj.pointColl.length-1].x,o.activeObj.activePoint.startY=o.activeObj.pointColl[o.activeObj.pointColl.length-1].y)}return o.activeObj.activePoint.endX=o.activeObj.activePoint.startX,o.activeObj.activePoint.endY=o.activeObj.activePoint.startY,void(o.currObjType.isDragging=!0)}this.isCropSelection&&this.dragCanvas&&(this.setCursor(r,a),"move"!==o.cursor&&"crosshair"!==o.cursor&&"default"!==o.cursor&&"grab"!==o.cursor&&(this.isPan=!1)),o.activeObj.shape?this.isObjSelected=!0:this.isObjSelected=!1;var h={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:h}});var c=h.currObj,d=e.extend({},o.activeObj,null,!0),v=this.isShapeTouch(i,this.isCropSelection),u=this.isFreehandDrawTouch(i,this.isCropSelection),g=v||this.isShapeClick(i,this.isCropSelection),b=this.applyCurrShape(g);if(this.isTouch&&!v&&d.shape&&!this.isCropSelection){this.applyObj(r,a)&&(o.okBtn(!0),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}));var C=e.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:c,previousObjColl:c.objColl,previousPointColl:c.pointColl,previousSelPointColl:c.selPointColl,previousCropObj:C,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),b&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}if(v||o.togglePen||this.isCropSelection||(e.isBlazor()?o.isImageLoaded&&o.updateToolbar(o.element,"imageLoaded","okBtnClick"):(o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}))),!this.dragCanvas||!this.isPan||"grab"!==o.cursor&&!this.isTouch||v||u||o.togglePen){var f=!1;!o.activeObj.shape||"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||(f=!0);var m=this.setXYPoints(i),y=m.x,P=m.y;this.applyObj(y,P)&&(o.okBtn(!0),b&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:y,y:P,isMouseDown:!0}});var j={index:null};o.notify("freehand-draw",{prop:"getFreehandDrawHoveredIndex",onPropertyChange:!1,value:{obj:j}});var O={freehandSelectedIndex:null};if(o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:O}}),this.isFhdPoint||this.isFhdCustomized&&!o.togglePen){if(!e.isNullOrUndefined(O.freehandSelectedIndex)&&O.freehandSelectedIndex!==j.index){var x=j.index;if(o.okBtn(),this.isFhdCustomized=!1,o.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:x}}),j.index>-1){w=o.pointColl[j.index].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:w,strokeWidth:o.pointColl[j.index].strokeWidth}})}}if(O.freehandSelectedIndex=null,o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:O}}),!e.isNullOrUndefined(j.index)&&j.index>-1)o.notify("freehand-draw",{prop:"selectFhd",value:{type:"ok"}}),e.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}});else if(O.freehandSelectedIndex){o.okBtn();var w=o.pointColl[O.freehandSelectedIndex].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:w,strokeWidth:o.pointColl[O.freehandSelectedIndex].strokeWidth}})}}else{if(this.isFhdEditing&&(o.notify("freehand-draw",{prop:"cancelFhd",value:{type:"ok"}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none")),e.isBlazor()||o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),this.isFhdEditing=!1,f?this.setCursor(y,P):"default"!==n&&(o.upperCanvas.style.cursor=o.cursor=n),"crosshair"===o.cursor||e.Browser.isDevice&&o.togglePen){if(o.togglePen){if(e.isNullOrUndefined(o.activeObj.strokeSettings)){var S={strokeSettings:{}};o.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:S}}),o.activeObj.strokeSettings=S.strokeSettings}var T={penStrokeWidth:null};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:T}}),e.isNullOrUndefined(T.penStrokeWidth)&&o.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:2}}),this.upperContext.strokeStyle=o.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=o.activeObj.strokeSettings.strokeColor,o.notify("freehand-draw",{prop:"freehandDownHandler",onPropertyChange:!1,value:{e:i,canvas:o.upperCanvas}})}else o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);o.currObjType.isActiveObj=!1,this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0}"crosshair"!==o.cursor&&"touchstart"===i.type.toLowerCase()||o.currObjType.isActiveObj&&"default"!==o.cursor&&!o.togglePen?(o.currObjType.isUndoAction&&o.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}}),this.findTarget(y,P,i.type)):""!==o.currObjType.shape&&!o.currObjType.isCustomCrop||o.togglePen||"default"===o.cursor||this.setActivePoint(y,P)}}else this.applyObj(r,a)&&(o.okBtn(!0),b&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),this.isFhdEditing&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.isFhdCustomized=!1,e.isBlazor()||o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),!o.activeObj.shape||"rectangle"!==o.activeObj.shape&&"ellipse"!==o.activeObj.shape&&"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape&&"path"!==o.activeObj.shape&&"text"!==o.activeObj.shape||(o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isBlazor()?o.updateToolbar(o.element,"imageLoaded"):(o.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}),o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}))),this.canvasMouseDownHandler(i);this.isShapeInserted=!1,this.tempActiveObj=e.extend({},o.activeObj,{},!0)},i.prototype.mouseMoveEventHandler=function(i){var o=this.parent,r=o.cursor,a=o.upperCanvas.style.cursor;i.preventDefault();var n=o.lowerCanvas.getBoundingClientRect();if("touchmove"===i.type&&2===i.touches.length){if(this.isFirstMove)this.startTouches=this.targetTouches(i.touches),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft-n.left,y:(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top}),this.tempTouches.push({x:(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,y:(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top});else{var s=(i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft)-n.left,l=(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top,p=(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,h=(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top,c={x:s<p?p-(p-s)/2:s-(s-p)/2,y:l<h?h-(h-l)/2:l-(l-h)/2};if(this.currMousePoint.x!==c.x&&this.currMousePoint.y!==c.y){var d="";if("touchmove"===i.type&&(o.zoomSettings.zoomTrigger&t.ZoomTrigger.Pinch)===t.ZoomTrigger.Pinch){this.zoomType="Pinch";var v=this.calculateScale(this.startTouches,this.targetTouches(i.touches));this.startTouches=this.targetTouches(i.touches),v>1?d="zoomIn":v<1&&(d="zoomOut")}""!==d&&o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:c.x,y:c.y,type:d}}),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft,y:i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop}),this.tempTouches.push({x:i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft,y:i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop}),this.currMousePoint.x=c.x,this.currMousePoint.y=c.y}}return void(this.isFirstMove=!1)}var u,g;"mousemove"===i.type?(u=i.clientX,g=i.clientY):(this.touchEndPoint.x=u=i.touches[0].clientX,this.touchEndPoint.y=g=i.touches[0].clientY),u-=n.left,g-=n.top,this.canvasMouseMoveHandler(i);var b,C=!1;void 0!==o.activeObj.shape&&(b=o.activeObj.shape.split("-")),void 0!==b&&"crop"===b[0]&&(C=!0),C&&o.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),o.upperCanvas.style.cursor=a,o.cursor=r,(o.currObjType.isActiveObj&&(void 0!==o.activeObj.activePoint||o.objColl.length>0)&&!this.dragCanvas||void 0!==o.activeObj.activePoint)&&""===this.dragElement&&(this.setCursor(u,g),o.activeObj.activePoint&&(0===o.activeObj.activePoint.width||!e.isNullOrUndefined(o.activeObj.currIndex)&&this.cursorTargetId!==o.activeObj.currIndex)&&"default"!==o.cursor&&"move"!==o.cursor&&"crosshair"!==o.cursor&&"grab"!==o.cursor&&"pointer"!==o.cursor&&(o.upperCanvas.style.cursor=o.cursor="move"),this.findTarget(u,g,i.type)),o.currObjType.isDragging&&(this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.updateActivePoint(u,g,C),o.notify("shape",{prop:"updateTrianglePoints",onPropertyChange:!1,value:{obj:o.activeObj}}),this.isPreventDragging?(o.activeObj.activePoint.startX>o.img.destLeft&&o.activeObj.activePoint.endX<o.img.destLeft+o.img.destWidth&&o.activeObj.activePoint.startY>o.img.destTop&&o.activeObj.activePoint.endY<o.img.destTop+o.img.destHeight&&(this.isPreventDragging=!1),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:null,saveContext:null,isPreventSelection:null}}),C&&(this.dragCanvas=o.togglePan=!0))},i.prototype.mouseUpEventHandler=function(t){var i=this,o=this.parent;"touchstart"===t.type?this.isTouch=!1:"touchend"===t.type&&t.stopImmediatePropagation(),t.preventDefault(),o.togglePan&&this.canvasMouseUpHandler(t);var r,a;"mouseup"===t.type?(r=t.clientX,a=t.clientY):(r=this.touchEndPoint.x,a=this.touchEndPoint.y);var n=o.lowerCanvas.getBoundingClientRect();r-=n.left,a-=n.top,"touchend"===t.type&&(this.startTouches=this.tempTouches=[],this.isFirstMove=!1,"none"===o.textArea.style.display&&(this.timer=0));var s,l=!1;if(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),e.isBlazor()&&this.parent.eventType){if("pan"===this.parent.eventType)o.events&&!0===o.events.onPanEnd.hasDelegate&&o.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanEnd",this.parent.panEventArgs);else if("resize"===this.parent.eventType){if(!this.isCropSelection&&this.parent.events&&!0===this.parent.events.onShapeResizeEnd.hasDelegate)this.shapeResizingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeResizingArgs.action="resize-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeEnd",this.shapeResizingArgs).then(function(t){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})});else if(this.shapeResizingArgs&&this.selectionResizingArgs&&this.parent.events&&!0===this.parent.events.onSelectionResizeEnd.hasDelegate){var p={type:this.parent.activeObj.shape,startX:this.shapeResizingArgs.currentShapeSettings.startX,startY:this.shapeResizingArgs.currentShapeSettings.startY,width:this.shapeResizingArgs.currentShapeSettings.width,height:this.shapeResizingArgs.currentShapeSettings.height};this.selectionResizingArgs.currentSelectionSettings=p,this.selectionResizingArgs.action="resize-end",this.parent.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeEnd",this.selectionResizingArgs).then(function(t){i.parent.notify("shape",{prop:"updateSelectionChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:t.currentSelectionSettings}})})}}else this.shapeMovingArgs&&this.parent.events&&!0===this.parent.events.onShapeDragEnd.hasDelegate&&(this.shapeMovingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeMovingArgs.action="drag-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragEnd",this.shapeMovingArgs).then(function(t){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}})}));this.shapeResizingArgs=null,this.shapeMovingArgs=null,this.parent.panEventArgs=null,this.parent.eventType=null}if("path"!==this.currentDrawingShape){if(t.currentTarget===o.upperCanvas){if(this.pathAdjustedIndex=null,""!==this.currentDrawingShape){if("text"===this.currentDrawingShape){var h=e.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.initialPrevObj,previousObjColl:this.initialPrevObj.objColl,previousPointColl:this.initialPrevObj.pointColl,previousSelPointColl:this.initialPrevObj.selPointColl,previousCropObj:h,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:this.initialPrevObj.objColl}});this.isShapeInserted=!0,this.currentDrawingShape="",0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&o.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}})}this.adjustActObjForLineArrow(),this.updPtCollForShpRot(),o.currObjType.shape=o.currObjType.shape.toLowerCase();var c=e.extend({},o.cropObj,{},!0),d={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:d}});var v=d.currObj;v.objColl=e.extend([],o.objColl,[],!0),v.pointColl=e.extend([],o.pointColl,[],!0),v.afterCropActions=e.extend([],o.afterCropActions,[],!0);var u={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:u}}),v.selPointColl=e.extend([],u.selPointColl,[],!0),o.togglePen||l||(this.tempObjColl&&0!==o.activeObj.activePoint.width&&(o.objColl.push(o.activeObj),JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(this.tempActiveObj.activePoint)&&o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:v,previousObjColl:this.tempObjColl,previousPointColl:v.pointColl,previousSelPointColl:v.selPointColl,previousCropObj:c,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.redrawShape(o.objColl[o.objColl.length-1],!0),this.tempObjColl=void 0),this.isFhdEditing||(this.applyCurrActObj(r,a),o.currObjType.isResize=!1,e.isBlazor()||o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))),o.activeObj){var g,b=!1;if(void 0!==o.activeObj.shape&&(g=o.activeObj.shape.split("-")),void 0===g&&(o.currObjType.isCustomCrop||o.togglePen)?b=!0:void 0!==g&&"crop"===g[0]&&(b=!0),e.isBlazor())"rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape?o.updateToolbar(o.element,o.activeObj.shape):"text"===o.activeObj.shape&&o.updateToolbar(o.element,"text");else{if("rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if("text"===o.activeObj.shape)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(this.isFhdEditing)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(!b){var C={type:"main",isApplyBtn:null,isCropping:!1,isZooming:null};o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:C})}o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})}}}void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),o.activeObj.shape&&!l&&t.currentTarget===o.upperCanvas&&"none"===o.textArea.style.display&&("text"===o.activeObj.shape?e.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):e.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),e.isBlazor()?o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape):(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),o.togglePen&&t.currentTarget===o.upperCanvas?o.notify("freehand-draw",{prop:"freehandUpHandler",onPropertyChange:!1,value:{e:t,canvas:o.upperCanvas,context:this.upperContext}}):o.currObjType.shape="",this.dragElement="",o.currObjType.isInitialLine=o.currObjType.isDragging=!1,this.selMouseUpEvent()}},i.prototype.adjustActObjForLineArrow=function(t){var e=!1,i=this.parent;if((t=t||i.activeObj).shape&&("line"===t.shape||"arrow"===i.activeObj.shape)){var o=void 0;if(("e-resize"===this.dragElement&&t.activePoint.endX<t.activePoint.startX||"w-resize"===this.dragElement&&t.activePoint.startX>t.activePoint.endX)&&(e=!0,o=t.activePoint.startX,t.activePoint.startX=t.activePoint.endX,t.activePoint.endX=o,o=t.activePoint.startY,t.activePoint.startY=t.activePoint.endY,t.activePoint.endY=o),t.activePoint.width=Math.abs(t.activePoint.endX-t.activePoint.startX),t.activePoint.height=Math.abs(t.activePoint.endY-t.activePoint.startY),"path"!==i.activeObj.shape){i.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:t}});for(var r=0;r<t.pointColl.length;r++)t.pointColl[r].ratioX=(t.pointColl[r].x-i.img.destLeft)/i.img.destWidth,t.pointColl[r].ratioY=(t.pointColl[r].y-i.img.destTop)/i.img.destHeight}}return e},i.prototype.updPtCollForShpRot=function(t){var e=this.parent;if((t=t||e.activeObj).shape&&0!==t.rotatedAngle){e.notify("shape",{prop:"setPointCollForShapeRotation",onPropertyChange:!1,value:{obj:t}});for(i=0;i<t.horTopLinePointColl.length;i++)t.horTopLinePointColl[i].ratioX=(t.horTopLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.horTopLinePointColl[i].ratioY=(t.horTopLinePointColl[i].y-e.img.destTop)/e.img.destHeight;for(i=0;i<t.horBottomLinePointColl.length;i++)t.horBottomLinePointColl[i].ratioX=(t.horBottomLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.horBottomLinePointColl[i].ratioY=(t.horBottomLinePointColl[i].y-e.img.destTop)/e.img.destHeight;for(i=0;i<t.verLeftLinePointColl.length;i++)t.verLeftLinePointColl[i].ratioX=(t.verLeftLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.verLeftLinePointColl[i].ratioY=(t.verLeftLinePointColl[i].y-e.img.destTop)/e.img.destHeight;for(var i=0;i<t.verRightLinePointColl.length;i++)t.verRightLinePointColl[i].ratioX=(t.verRightLinePointColl[i].x-e.img.destLeft)/e.img.destWidth,t.verRightLinePointColl[i].ratioY=(t.verRightLinePointColl[i].y-e.img.destTop)/e.img.destHeight}},i.prototype.setXYPoints=function(t){t.preventDefault();var e,i;"mousedown"===t.type?(e=t.clientX,i=t.clientY):(this.touchEndPoint.x=e=t.touches[0].clientX,this.touchEndPoint.y=i=t.touches[0].clientY);var o=this.parent.lowerCanvas.getBoundingClientRect();return e-=o.left,i-=o.top,{x:e,y:i}},i.prototype.getCurrentIndex=function(){for(var t,e=this.parent,i=0;i<e.objColl.length;i++)if(e.activeObj.currIndex===e.objColl[i].currIndex){t=i;break}return t},i.prototype.isShapeClick=function(t,i){var o=this.parent,r=!1;if(o.togglePen)return r;if(o.activeObj.shape&&"text"===o.activeObj.shape&&this.isShapeInserted){var a="block"===o.textArea.style.display,n=e.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(t),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;h=this.getCurrentIndex();e.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;var h=this.getCurrentIndex();e.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?e.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1)}}return r},i.prototype.isShapeTouch=function(t,i){var o=this.parent,r=!1;if("touchstart"===t.type&&!o.togglePen){o.activeObj&&"text"===o.activeObj.shape&&(this.timer=setTimeout(this.setTimer.bind(this),1e3,t));var a="block"===o.textArea.style.display,n=e.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(t),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;h=this.getCurrentIndex();e.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;var h=this.getCurrentIndex();i||(e.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?e.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.isFreehandDrawTouch=function(t,i){var o=this.parent,r=!1;if("touchstart"===t.type&&!i&&!o.togglePen){var a="block"===o.textArea.style.display,n=e.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(t),l=s.x,p=s.y;if(this.setCursor(l,p),this.isFhdPoint&&(r=!0),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;h=this.getCurrentIndex();e.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(n.shape){o.activeObj=n;var h=this.getCurrentIndex();i||(e.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?e.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.applyObj=function(t,e){var i=this.parent,o=!1;return!i.activeObj.shape||"rectangle"!==i.activeObj.shape&&"ellipse"!==i.activeObj.shape&&"text"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"arrow"!==i.activeObj.shape&&"path"!==i.activeObj.shape||(o=!(t>=i.activeObj.activePoint.startX-2*i.activeObj.topLeftCircle.radius&&t<=i.activeObj.activePoint.endX+2*i.activeObj.topLeftCircle.radius&&e>=i.activeObj.activePoint.startY-2*i.activeObj.topLeftCircle.radius&&e<=i.activeObj.activePoint.endY+2*i.activeObj.topLeftCircle.radius)&&("default"===i.upperCanvas.style.cursor||"grab"===i.upperCanvas.style.cursor||"crosshair"===i.upperCanvas.style.cursor||"pointer"===i.upperCanvas.style.cursor)),o},i.prototype.applyCurrShape=function(t){var i=this.parent,o=!1;if(i.togglePen)return o;var r=e.extend({},i.activeObj,null,!0);if(this.isShapeInserted&&"text"===i.activeObj.shape&&t&&(this.isInitialTextEdited=!0,i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}})),"block"===i.textArea.style.display){var a=e.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r=e.extend({},i.objColl[i.objColl.length-1],null,!0),i.objColl.pop(),i.activeObj=e.extend({},a,null,!0),i.textArea.value=r.keyHistory,i.textArea.style.display="block";var n="rgb"===r.strokeSettings.strokeColor.split("(")[0]?this.rgbToHex(parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[0]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[1]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[2])):r.strokeSettings.strokeColor;"#ffffff"===n&&(n="#fff"),"#ffffff"===this.tempActiveObj.strokeSettings.strokeColor&&(this.tempActiveObj.strokeSettings.strokeColor="#fff"),r.keyHistory===this.tempActiveObj.keyHistory&&n===this.tempActiveObj.strokeSettings.strokeColor&&r.textSettings.fontFamily===this.tempActiveObj.textSettings.fontFamily&&Math.round(r.textSettings.fontSize)===Math.round(this.tempActiveObj.textSettings.fontSize)&&Math.round(r.textSettings.fontRatio)===Math.round(this.tempActiveObj.textSettings.fontRatio)&&r.textSettings.bold===this.tempActiveObj.textSettings.bold&&r.textSettings.italic===this.tempActiveObj.textSettings.italic&&r.textSettings.underline===this.tempActiveObj.textSettings.underline||(o=!0),this.isInitialTextEdited&&!o&&(o=!0,this.isInitialTextEdited=!1)}else this.tempActiveObj.activePoint.height=Math.abs(this.tempActiveObj.activePoint.height),o=JSON.stringify(r)!==JSON.stringify(this.tempActiveObj);return o},i.prototype.canvasMouseDownHandler=function(t){var i=this.parent;t.preventDefault();var o,r;"mousedown"===t.type?(o=t.offsetX||t.pageX-i.lowerCanvas.offsetLeft,r=t.offsetY||t.pageY-i.lowerCanvas.offsetTop):(o=t.touches[0].clientX||t.touches[0].pageX-i.lowerCanvas.offsetLeft,r=t.touches[0].clientY||t.touches[0].pageY-i.lowerCanvas.offsetTop);var a=i.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top,this.panDown={x:o,y:r};var n={tempPanMove:null};i.notify("transform",{prop:"getTempPanMove",onPropertyChange:!1,value:{obj:n}}),e.isNullOrUndefined(n.tempPanMove)&&i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:{x:o,y:r}}})},i.prototype.canvasMouseMoveHandler=function(t){var e=this.parent;this.dragCanvas?e.lowerCanvas.style.cursor="grab":(this.dragCanvas=e.togglePan=!1,e.lowerCanvas.style.cursor=e.upperCanvas.style.cursor=e.cursor="default");var i,o;"mousemove"===t.type?(i=t.offsetX,o=t.offsetY):(i=t.touches[0].clientX||t.touches[0].pageX-e.lowerCanvas.offsetLeft,o=t.touches[0].clientY||t.touches[0].pageY-e.lowerCanvas.offsetTop);var r=e.lowerCanvas.getBoundingClientRect(),a={x:i-=r.left,y:o-=r.top};e.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:{x:i,y:o}}}),this.panDown&&a&&e.togglePan&&this.dragCanvas&&e.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:null,yDiff:null}})},i.prototype.canvasMouseUpHandler=function(t){var e=this.parent;t.preventDefault();var i={panMove:null};e.notify("transform",{prop:"getPanMove",onPropertyChange:!1,value:{obj:i}}),e.togglePan&&this.panDown&&i.panMove&&e.togglePan&&this.dragCanvas&&(this.panDown=null,e.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:null}}),e.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}})),"path"!==this.currentDrawingShape&&(e.currObjType.isDragging=!1)},i.prototype.touchStartHandler=function(t){t.preventDefault(),0===this.touchTime?this.touchTime=(new Date).getTime():(new Date).getTime()-this.touchTime<400?(this.parent.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e:t}}),this.touchTime=0):this.touchTime=(new Date).getTime(),2===t.touches.length?this.isFirstMove=!0:this.mouseDownEventHandler(t),e.EventHandler.add(this.parent.lowerCanvas,"touchend",this.mouseUpEventHandler,this),e.EventHandler.add(this.parent.lowerCanvas,"touchmove",this.mouseMoveEventHandler,this),e.EventHandler.add(this.parent.upperCanvas,"touchend",this.mouseUpEventHandler,this),e.EventHandler.add(this.parent.upperCanvas,"touchmove",this.mouseMoveEventHandler,this)},i.prototype.unwireEvent=function(){e.EventHandler.remove(this.parent.lowerCanvas,"touchend",this.mouseUpEventHandler),e.EventHandler.remove(this.parent.lowerCanvas,"touchmove",this.mouseMoveEventHandler),e.EventHandler.remove(this.parent.upperCanvas,"touchend",this.mouseUpEventHandler),e.EventHandler.remove(this.parent.upperCanvas,"touchmove",this.mouseMoveEventHandler)},i.prototype.keyDownEventHandler=function(i){var o=this,r=this.parent;!i.ctrlKey||"+"!==i.key&&"-"!==i.key||i.preventDefault();var a={fileName:"",fileType:null};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n,s={fileName:a.fileName,fileType:a.fileType,cancel:!1};switch(i.key){case i.ctrlKey&&"s":e.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",s).then(function(t){o.beforeSaveEvent(t,i)}):(r.trigger("beforeSave",s),this.beforeSaveEvent(s,i));break;case i.ctrlKey&&"z":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-undo"});break;case i.ctrlKey&&"y":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-redo"});break;case i.ctrlKey&&"+":(r.zoomSettings.zoomTrigger&t.ZoomTrigger.Commands)===t.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}}));break;case i.ctrlKey&&"-":(r.zoomSettings.zoomTrigger&t.ZoomTrigger.Commands)===t.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}}));break;case"Delete":this.deleteItem();break;case"Escape":r.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});break;case"Enter":r.activeObj.shape&&(n=r.activeObj.shape.split("-")),this.isKeyBoardCrop(i)&&r.activeObj.horTopLine&&r.activeObj.shape&&"crop"===n[0]&&r.crop();break;case"Tab":this.performTabAction();break;default:e.Browser.isDevice&&"block"===r.textArea.style.display&&setTimeout(this.textKeyDown.bind(this),1,i)}},i.prototype.isKeyBoardCrop=function(t){var i=!1,o=t.target;return o.id!==this.parent.element.id+"_ok"&&""!==o.id||e.isBlazor()||(i=!0),i},i.prototype.beforeSaveEvent=function(t,e){var i=this.parent;t.cancel||i.notify("export",{prop:"export",onPropertyChange:!1,value:{type:t.fileType,fileName:t.fileName}}),e.preventDefault(),e.stopImmediatePropagation()},i.prototype.handleScroll=function(i){var o,r,a=this.parent,n=!1;"mousewheel"===i.type&&(o=i.clientX,r=i.clientY);var s=a.lowerCanvas.getBoundingClientRect();if(o-=s.left,r-=s.top,o>a.img.destLeft&&o<a.img.destLeft+a.img.destWidth&&r>a.img.destTop&&r<a.img.destTop+a.img.destHeight&&(n=!0),i.stopPropagation(),!0===i.ctrlKey&&n){i.preventDefault(),!a.isCropTab&&a.activeObj.shape&&"crop"!==a.activeObj.shape.split("-")[0]&&(a.okBtn(),e.isBlazor()||a.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}));var l="";"mousewheel"===i.type&&(a.zoomSettings.zoomTrigger&t.ZoomTrigger.MouseWheel)===t.ZoomTrigger.MouseWheel&&(this.zoomType="MouseWheel",l=i.wheelDelta>0?"zoomIn":"zoomOut"),""!==l&&a.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:o,y:r,type:l}})}},i.prototype.textKeyDown=function(t){var i=this.parent;"\r"===String.fromCharCode(t.which)&&(this.textRow+=1),i.textArea.setAttribute("rows",this.textRow.toString()),i.textArea.style.height="auto",i.textArea.style.height=i.textArea.scrollHeight+"px",i.notify("shape",{prop:"setTextBoxWidth",onPropertyChange:!1,value:{e:t}}),e.Browser.isDevice&&(i.textArea.style.width=parseFloat(i.textArea.style.width)+i.textArea.style.fontSize+"px");var o=i.textArea.value.split("\n");this.textRow=o.length,i.textArea.setAttribute("rows",this.textRow.toString()),this.isInitialTextEdited=!1},i.prototype.clearSelection=function(){var t=this.parent;!t.disabled&&t.isImageLoaded&&(t.togglePen=!1,t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0,t.currObjType.shape="",this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.currObjType.isActiveObj=!0,t.currObjType.isCustomCrop=!1,t.upperCanvas.style.cursor=t.cursor="default")},i.prototype.setDragDirection=function(t,e){var i=this.parent;i.img.destWidth>i.img.destHeight?(i.activeObj.activePoint.startX=this.dragPoint.startX=t/2-e/2+7.5,i.activeObj.activePoint.startY=this.dragPoint.startY=e/2-e/2+7.5,i.activeObj.activePoint.endX=t/2+e/2-7.5,i.activeObj.activePoint.endY=e/2+e/2-7.5):(i.activeObj.activePoint.startY=this.dragPoint.startX=e/2-t/2+7.5,i.activeObj.activePoint.endY=e/2+t/2-7.5,i.activeObj.activePoint.startX=this.dragPoint.startX=7.5,i.activeObj.activePoint.endX=t-7.5)},i.prototype.calcShapeRatio=function(t,e,i,o){for(var r=this.parent,a=i,n=o,s=t/e,l=a>=n?a:n,p=l*s,h=l,c=this.getScale(p,a),d=[],v=0;v<2;v++)0===v?d.push(p*c):d.push(h*c);p=d[0],h=d[1];for(var u=this.getScale(h,n),g=[],v=0;v<2;v++)0===v?g.push(p*u):g.push(h*u);p=g[0],h=g[1],r.activeObj.activePoint.width=p,r.activeObj.activePoint.height=h,r.activeObj.activePoint.startX=7.5+(this.dragPoint.startX=(a-p)/2),r.activeObj.activePoint.startY=7.5+(this.dragPoint.startY=(n-h)/2),r.activeObj.activePoint.endX=(a-p)/2+p-7.5,r.activeObj.activePoint.endY=(n-h)/2+h-7.5,r.activeObj.activePoint.startX<r.img.destLeft&&r.img.destLeft+r.img.destWidth>r.lowerCanvas.clientWidth&&(r.activeObj.activePoint.startX=r.img.destLeft,r.activeObj.activePoint.endX=r.activeObj.activePoint.startX+p-7.5),r.activeObj.activePoint.startY<r.img.destTop&&r.img.destTop+r.img.destHeight>r.lowerCanvas.clientHeight&&(r.activeObj.activePoint.startY=r.img.destTop,r.activeObj.activePoint.endY=r.activeObj.activePoint.startY+h-7.5),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY},i.prototype.getScale=function(t,e){return t>e?e/t:1},i.prototype.findTarget=function(t,e,i){var o=this.parent;if("mousedown"===i.toLowerCase()||"touchstart"===i.toLowerCase()){var r=!1;o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]&&(r=!0),this.findTargetObj(t,e,r),this.updateCursorStyles(t,e,i)}else switch(this.dragElement.toLowerCase()){case"nw-resize":o.activeObj.topLeftCircle.startX=t,o.activeObj.topLeftCircle.startY=e;break;case"n-resize":o.activeObj.topCenterCircle.startX=t,o.activeObj.topCenterCircle.startY=e;break;case"ne-resize":o.activeObj.topRightCircle.startX=t,o.activeObj.topRightCircle.startY=e;break;case"w-resize":o.activeObj.centerLeftCircle.startX=t,o.activeObj.centerLeftCircle.startY=e;break;case"e-resize":o.activeObj.centerRightCircle.startX=t,o.activeObj.centerRightCircle.startY=e;break;case"sw-resize":o.activeObj.bottomLeftCircle.startX=t,o.activeObj.bottomLeftCircle.startY=e;break;case"s-resize":o.activeObj.bottomCenterCircle.startX=t,o.activeObj.bottomCenterCircle.startY=e;break;case"se-resize":o.activeObj.bottomRightCircle.startX=t,o.activeObj.bottomRightCircle.startY=e;break;default:this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e)}},i.prototype.findTargetObj=function(t,i,o){var r=this,a=this.parent,n=!1;if(0!==a.objColl.length&&!a.currObjType.isCustomCrop&&!o){for(var s=0,l=void 0,p=0;p<a.objColl.length;p++){var h=a.upperCanvas.style.cursor;this.setCursor(t,i);var c=e.extend({},a.objColl[p],{},!0);if("line"===c.shape||"arrow"===c.shape){for(var d=0;d<c.pointColl.length;d++)if(t>=c.pointColl[d].x-2*c.topLeftCircle.radius&&t<=c.pointColl[d].x+2*c.topLeftCircle.radius&&i>=c.pointColl[d].y-2*c.topLeftCircle.radius&&i<=c.pointColl[d].y+2*c.topLeftCircle.radius){this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p);break}}else if("path"===c.shape){var v=this.setCursorForPath(c,t,i,a.upperCanvas);"default"!==v&&"grab"!==v&&(this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p))}else if(0!==c.rotatedAngle){var u=this.setCursorForRotatedObject(c,t,i,a.upperCanvas);"default"!==u&&"grab"!==u&&(this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p))}else{var g=this.getTransRotationPoint(c);(t>=c.activePoint.startX-2*c.topLeftCircle.radius&&t<=c.activePoint.endX+2*c.topLeftCircle.radius&&i>=c.activePoint.startY-2*c.topLeftCircle.radius&&i<=c.activePoint.endY+2*c.topLeftCircle.radius||g&&t>=g.x-2*c.topLeftCircle.radius&&t<=g.x+2*c.topLeftCircle.radius&&i>=g.y-2*c.topLeftCircle.radius&&i<=g.y+2*c.topLeftCircle.radius)&&(this.isTouch||"move"===h||"grabbing"===h||this.isShapeInserted||"move"===a.cursor||"grabbing"===a.cursor?(0===s||s>t-c.activePoint.startX)&&(s=t-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p))}}if(e.isNullOrUndefined(l))a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n=!1;else{this.tempObjColl=e.extend([],a.objColl,[],!0),a.currObjType.isCustomCrop=!1,a.activeObj=e.extend({},a.objColl[l],{},!0);var b=e.extend({},a.objColl[l],{},!0);if(a.objColl.splice(l,1),0===a.transform.degree){var C=this.lowerContext.filter;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height),a.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(a.baseImg,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,a.img.destLeft,a.img.destTop,a.img.destWidth,a.img.destHeight),this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.activeObj=e.extend({},C,{},!0),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=C,this.getCurrentFlipState()}else a.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}});a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.setActivePoint(),a.activeObj=e.extend({},b,{},!0);var f=e.extend({},a.activeObj.strokeSettings,{},!0);a.notify("draw",{prop:"setTempStrokeSettings",onPropertyChange:!1,value:{tempStrokeSettings:f}});var m=e.extend({},a.activeObj.textSettings,{},!0);a.notify("draw",{prop:"setTempTextSettings",onPropertyChange:!1,value:{tempTextSettings:m}});var y=this.updatePrevShapeSettings(),P={action:"select",previousShapeSettings:y,currentShapeSettings:y};"line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape||(P.currentShapeSettings.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,P.currentShapeSettings.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),this.isCropSelection=!1;var j=void 0;if(void 0!==a.activeObj.shape&&(j=a.activeObj.shape.split("-")),void 0!==j&&"crop"===j[0]&&(this.isCropSelection=!0),!this.isCropSelection&&e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&a.events&&!0===a.events.shapeChanging.hasDelegate)a.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",P).then(function(t){r.shapeEvent(t)});else if(this.isCropSelection){var O={action:P.action,previousSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:P.previousShapeSettings.startX,startY:P.previousShapeSettings.startY,width:P.previousShapeSettings.width,height:P.previousShapeSettings.height},currentSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:P.currentShapeSettings.startX,startY:P.currentShapeSettings.startY,width:P.currentShapeSettings.width,height:P.currentShapeSettings.height}};e.isBlazor()&&a.events&&!0===a.events.onSelectionResizeStart.hasDelegate?a.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",O).then(function(t){P.currentShapeSettings.startX=t.currentSelectionSettings.startX,P.currentShapeSettings.startY=t.currentSelectionSettings.startY,P.currentShapeSettings.width=t.currentSelectionSettings.width,P.currentShapeSettings.height=t.currentSelectionSettings.height,r.shapeEvent(P)}):(a.trigger("selectionChanging",O),P.currentShapeSettings.startX=O.currentSelectionSettings.startX,P.currentShapeSettings.startY=O.currentSelectionSettings.startY,P.currentShapeSettings.width=O.currentSelectionSettings.width,P.currentShapeSettings.height=O.currentSelectionSettings.height,this.shapeEvent(P))}else a.trigger("shapeChanging",P),this.shapeEvent(P);n=!0}}return n},i.prototype.shapeEvent=function(t){var i=this.parent;if(i.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings}}),i.activeObj.activePoint){var o={prevActObj:null};i.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:o}}),e.isNullOrUndefined(o.prevActObj)&&i.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:e.extend({},i.activeObj,{},!0)}}),i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}}),this.isShapeInserted||(i.activeObj.activePoint.startX<i.img.destLeft?this.isPreventDragging=!0:i.activeObj.activePoint.endX>i.img.destLeft+i.img.destWidth?this.isPreventDragging=!0:i.activeObj.activePoint.startY<i.img.destTop?this.isPreventDragging=!0:i.activeObj.activePoint.endY>i.img.destTop+i.img.destHeight&&(this.isPreventDragging=!0))}},i.prototype.targetTouches=function(t){var e=this.parent.lowerCanvas.getBoundingClientRect();return[{x:t[0].pageX-e.left,y:t[0].pageY-e.top},{x:t[1].pageX-e.left,y:t[1].pageY-e.top}]},i.prototype.calculateScale=function(t,e){var i=this.getDistance(t[0],t[1]);return this.getDistance(e[0],e[1])/i},i.prototype.getDistance=function(t,e){var i=0,o=0;return t&&e&&(i=t.x-e.x,o=t.y-e.y),Math.sqrt(i*i+o*o)},i.prototype.redrawShape=function(t,e){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++)if(JSON.stringify(t)===JSON.stringify(i.objColl[o])){i.objColl.splice(o,1);break}this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.isPreventDragging?(i.activeObj.activePoint.startX>i.img.destLeft&&(this.isPreventDragging=!1),e&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):(e&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}))},i.prototype.setTimer=function(t){this.timer>10&&(clearTimeout(this.timer),this.timer=0,this.parent.notify("shape",{prop:"findTextTarget",onPropertyChange:!1,value:{e:t}}),e.Browser.isDevice&&this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height))},i.prototype.applyCurrActObj=function(t,i){var o=this.parent,r=!1,a=e.extend({},o.activeObj,{},!0);if(!e.isNullOrUndefined(a.activePoint)){if(t>=Math.floor(a.activePoint.startX)&&t<=Math.ceil(a.activePoint.endX)&&i>=Math.floor(a.activePoint.startY)&&i<=Math.ceil(a.activePoint.endY))r=!0;else if("text"===a.shape&&""!==this.dragElement)r=!0;else if("line"===a.shape||"arrow"===a.shape){var n={x:a.activePoint.startX<a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY<a.activePoint.endY?a.activePoint.startY:a.activePoint.endY},s={x:a.activePoint.startX>a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY>a.activePoint.endY?a.activePoint.startY:a.activePoint.endY};t>=Math.floor(n.x)-5&&t<=Math.ceil(s.x)+5&&i>=Math.floor(n.y)-5&&i<=Math.ceil(s.y)+5&&(r=!0)}else if("path"===a.shape)"move"===(l=this.setCursorForPath(a,t,i,o.upperCanvas))&&(r=!0);else if("grabbing"===this.dragElement)r=!0;else if(0!==a.rotatedAngle){var l=this.setCursorForRotatedObject(a,t,i,o.upperCanvas);("default"!==l&&"grab"!==l||"n-resize"===this.dragElement||"e-resize"===this.dragElement||"s-resize"===this.dragElement||"w-resize"===this.dragElement)&&(r=!0)}if(!r){if(e.isNullOrUndefined(o.activeObj.currIndex)&&(o.activeObj.currIndex="shape_"+(o.objColl.length+1)),o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),void 0===o.activeObj.horTopLine||0===o.activeObj.horTopLine.startX||0===o.activeObj.horTopLine.endX||o.currObjType.isCustomCrop||""===o.currObjType.shape||o.objColl.push(e.extend({},o.activeObj,{},!0)),"text"===o.activeObj.shape||"ellipse"===o.currObjType.shape||"rectangle"===o.currObjType.shape||"line"===o.currObjType.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape){var p=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var h=0;h<o.objColl.length;h++){var c={isInside:!1};o.notify("crop",{prop:"isObjInImage",onPropertyChange:!1,value:{obj:o.objColl[h],object:c}}),c.isInside&&(o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:o.objColl[h].shape,obj:o.objColl[h],canvas:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=p,o.activeObj.shape&&o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})}e.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}}},i.prototype.getCurrentFlipState=function(){var t=this.parent;if(0!==t.rotateFlipColl.length){var i=e.extend({},t.panPoint.totalPannedInternalPoint,{},!0);t.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),t.panPoint.totalPannedInternalPoint=i}else t.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1})},i.prototype.setTextBoxStylesToActObj=function(){var t=this.parent;t.activeObj.textSettings.fontFamily=t.textArea.style.fontFamily,t.activeObj.strokeSettings.strokeColor=""!==t.textArea.style.color?this.rgbToHex(parseFloat(t.textArea.style.color.split("(")[1].split(",")[0]),parseFloat(t.textArea.style.color.split("(")[1].split(",")[1]),parseFloat(t.textArea.style.color.split("(")[1].split(",")[2])):t.textArea.style.color,"bold"===t.textArea.style.fontWeight?t.activeObj.textSettings.bold=!0:t.activeObj.textSettings.bold=!1,"italic"===t.textArea.style.fontStyle?t.activeObj.textSettings.italic=!0:t.activeObj.textSettings.italic=!1,t.activeObj.textSettings.fontSize=parseFloat(t.textArea.style.fontSize)},i.prototype.rgbToHex=function(t,e,i){return"#"+this.componentToHex(t)+this.componentToHex(e)+this.componentToHex(i)},i.prototype.componentToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},i.prototype.deleteItem=function(){var t=this.parent,i={};if(this.isFhdEditing){this.updateFreehandDrawColorChange();var o=e.extend({},t.cropObj,{},!0),r={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),(p=r.currObj).objColl=e.extend([],t.objColl,[],!0),p.pointColl=e.extend([],t.pointColl,[],!0),p.afterCropActions=e.extend([],t.afterCropActions,[],!0);h={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),p.selPointColl=e.extend([],h.selPointColl,[],!0);a={freehandDrawSelectedId:null};t.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:a}}),t.notify("freehand-draw",{prop:"deleteFhd",value:{id:a.freehandDrawSelectedId}}),t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteFreehandDrawing",previousObj:p,previousObjColl:this.tempObjColl,previousPointColl:p.pointColl,previousSelPointColl:p.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),t.notify("freehand-draw",{prop:"resetFreehandDrawSelectedId"})}else if("none"===t.textArea.style.display){var a={prevActObj:null};if(t.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:a}}),a.prevActObj&&(a.prevActObj.activePoint.width=Math.abs(a.prevActObj.activePoint.width),a.prevActObj.activePoint.height=Math.abs(a.prevActObj.activePoint.height)),a.prevActObj&&JSON.stringify(a.prevActObj)!==JSON.stringify(t.activeObj)){var n=t.activeObj.currIndex;t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});for(var s=0;s<t.objColl.length;s++)if(t.objColl[s].currIndex===n){t.objColl.splice(s,1),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null}});break}}r={isNewPath:null};if(t.notify("draw",{prop:"getNewPath",value:{obj:r}}),r.isNewPath)t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.isBlazor()?t.updateToolbar(t.element,"imageLoaded"):t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(t.activeObj.shape){t.objColl.push(t.activeObj);var o=e.extend({},t.cropObj,{},!0),l={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:l}});var p=l.currObj;p.objColl=e.extend([],t.objColl,[],!0),p.pointColl=e.extend([],t.pointColl,[],!0),p.afterCropActions=e.extend([],t.afterCropActions,[],!0);var h={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),p.selPointColl=e.extend([],h.selPointColl,[],!0),t.objColl.pop(),i={action:"delete",previousShapeSettings:this.updatePrevShapeSettings(),currentShapeSettings:null},t.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),t.clearSelection(),e.isBlazor()&&t.events&&!0===t.events.shapeChanging.hasDelegate?t.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",i):(t.trigger("shapeChanging",i),e.isBlazor()||t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})),e.isNullOrUndefined(p.objColl[p.objColl.length-1].currIndex)||(t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteObj",previousObj:p,previousObjColl:this.tempObjColl,previousPointColl:p.pointColl,previousSelPointColl:p.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))}t.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})}document.getElementById(t.element.id+"_quickAccessToolbarArea")&&(document.getElementById(t.element.id+"_quickAccessToolbarArea").style.display="none")},i.prototype.updateFreehandDrawColorChange=function(){var t=this.parent,i={freehandSelectedIndex:null};if(t.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:i}}),!e.isNullOrUndefined(i.freehandSelectedIndex)&&!e.isNullOrUndefined(t.pointColl[i.freehandSelectedIndex])&&"#42a5f5"===t.pointColl[i.freehandSelectedIndex].strokeColor){var o={tempFreeHandDrawEditingStyles:null};t.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:o}}),t.pointColl[i.freehandSelectedIndex].strokeColor=o.tempFreeHandDrawEditingStyles.strokeColor}},i.prototype.updatePrevShapeSettings=function(t){var i=this.parent,o=[];"text"===i.activeObj.shape&&i.activeObj.textSettings&&(i.activeObj.textSettings.bold&&o.push("bold"),i.activeObj.textSettings.italic&&o.push("italic"),i.activeObj.textSettings.underline&&o.push("underline"));var r={id:e.isNullOrUndefined(i.activeObj.currIndex)?null:i.activeObj.currIndex,type:i.toPascalCase(i.activeObj.shape),startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,width:i.activeObj.activePoint.width,height:i.activeObj.activePoint.height,strokeColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null,strokeWidth:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeWidth:null,fillColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.fillColor:null,radius:"ellipse"===i.activeObj.shape?i.activeObj.activePoint.width/2:null,length:"line"===i.activeObj.shape||"arrow"===i.activeObj.shape?i.activeObj.activePoint.width:null,text:"text"===i.activeObj.shape?i.activeObj.keyHistory?i.activeObj.keyHistory:i.activeObj.textSettings.text?i.activeObj.textSettings.text:null:null,fontSize:"text"===i.activeObj.shape&&i.activeObj.textSettings?i.activeObj.textSettings.fontSize:null,fontFamily:"text"===i.activeObj.shape&&i.activeObj.textSettings?i.activeObj.textSettings.fontFamily:null,fontStyle:"text"===i.activeObj.shape?o:null,color:"text"===i.activeObj.shape&&i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null};return t&&(t.shapeSettingsObj=r),r},i.prototype.getRectanglePoints=function(t,e,i,o,r,a,n){var s=t+i/2,l=e+o/2,p=r*(Math.PI/180),h=Math.cos(p),c=Math.sin(p),d=a-s,v=n-l,u=d*h+v*c,g=-d*c+v*h,b=i/2,C=o/2;return u>=-b&&u<=b&&g>=-C&&g<=C},i.prototype.getTransRotationPoint=function(t,e){var i,o,r=!1,a=!1;if((o=0===t.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-t.shapeDegree)<0&&(o=360+o),t.flipObjColl)for(var n=0;n<t.flipObjColl.length;n++)"horizontal"===t.flipObjColl[n].toLowerCase()?r=!0:"vertical"===t.flipObjColl[n].toLowerCase()&&(a=!0);return 0===o||360===o?i=a?{x:t.topCenterCircle.startX,y:t.topCenterCircle.startY-t.rotationCircleLine}:{x:t.bottomCenterCircle.startX,y:t.bottomCenterCircle.startY+t.rotationCircleLine}:90===o||-270===o?i=r?{x:t.centerRightCircle.startX+t.rotationCircleLine,y:t.centerLeftCircle.startY}:{x:t.centerLeftCircle.startX-t.rotationCircleLine,y:t.centerLeftCircle.startY}:180===o||-180===o?i=a?{x:t.bottomCenterCircle.startX,y:t.bottomCenterCircle.startY+t.rotationCircleLine}:{x:t.topCenterCircle.startX,y:t.topCenterCircle.startY-t.rotationCircleLine}:270!==o&&-90!==o||(i=r?{x:t.centerLeftCircle.startX-t.rotationCircleLine,y:t.centerLeftCircle.startY}:{x:t.centerRightCircle.startX+t.rotationCircleLine,y:t.centerLeftCircle.startY}),e&&(e.rotationCirclePoint=i),i},i}(),d=function(){function i(t){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.keyHistory="",this.parent=t,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("shape",this.shape,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("shape",this.shape),this.parent.off("destroyed",this.destroy)},i.prototype.shape=function(t){switch(this.initShapePvtProps(),t.prop){case"drawEllipse":this.drawEllipse(t.value.x,t.value.y,t.value.radiusX,t.value.radiusY,t.value.strokeWidth,t.value.strokeColor,t.value.fillColor);break;case"drawLine":this.drawLine(t.value.startX,t.value.startY,t.value.endX,t.value.endY,t.value.strokeWidth,t.value.strokeColor);break;case"drawArrow":this.drawArrow(t.value.startX,t.value.startY,t.value.endX,t.value.endY,t.value.strokeWidth,t.value.strokeColor,t.value.arrowStart,t.value.arrowEnd);break;case"drawPath":this.drawPath(t.value.pointColl,t.value.strokeWidth,t.value.strokeColor);break;case"drawRectangle":this.drawRectangle(t.value.x,t.value.y,t.value.width,t.value.height,t.value.strokeWidth,t.value.strokeColor,t.value.fillColor);break;case"drawText":this.drawText(t.value.x,t.value.y,t.value.text,t.value.fontFamily,t.value.fontSize,t.value.bold,t.value.italic,t.value.color);break;case"redrawActObj":this.redrawActObj(t.value.x,t.value.y,t.value.isMouseDown);break;case"apply":this.apply(t.value.shape,t.value.obj,t.value.canvas);break;case"updateShapeChangeEventArgs":this.updateShapeChangeEventArgs(t.value.shapeSettings);break;case"updSelChangeEventArgs":this.updSelChangeEventArgs(t.value.selectionSettings);break;case"iterateObjColl":this.iterateObjColl();break;case"updImgRatioForActObj":this.updImgRatioForActObj();break;case"zoomObjColl":this.zoomObjColl(t.value.isPreventApply);break;case"redrawObj":this.redrawObj(t.value.degree);break;case"rotateObjColl":this.rotateObjColl();break;case"draw-shape-text":this.drawShapeText();break;case"redraw-text":this.redrawText();break;case"draw-shape":this.drawShape(t.value.obj,t.value.strokeWidth,t.value.strokeColor,t.value.fillColor,t.value.start,t.value.width,t.value.height);break;case"renderTextArea":this.renderTextArea(t.value.x,t.value.y,t.value.actObj);break;case"setTextBoxWidth":this.setTextBoxWidth(t.value.e);break;case"findTextTarget":this.findTextTarget(t.value.e);break;case"panObjColl":this.panObjColl(t.value.xDiff,t.value.yDiff,t.value.panRegion);break;case"updateFontStyles":this.updateFontStyles(t.value.isTextBox);break;case"applyFontStyle":this.applyFontStyle(t.value.item);break;case"updateFontRatio":this.updateFontRatio(t.value.obj,t.value.isTextArea);break;case"updateFontSize":this.updateFontSize(t.value.obj);break;case"updateObjColl":this.updateObjColl(t.value.item,t.value.objColl);break;case"pushActItemIntoObj":this.pushActItemIntoObj();break;case"clearActObj":this.clearActObj();break;case"refreshActiveObj":this.refreshActiveObj();break;case"applyActObj":this.applyActObj(t.value.isMouseDown);break;case"wireEvent":e.EventHandler.add(this.parent.upperCanvas,"dblclick",this.findTextTarget,this),e.EventHandler.add(this.parent.textArea,"mousedown",this.findTextTarget,this);break;case"unWireEvent":e.EventHandler.remove(this.parent.upperCanvas,"dblclick",this.findTextTarget),e.EventHandler.remove(this.parent.textArea,"mousedown",this.findTextTarget);break;case"getShapeSetting":this.getShapeSetting(t.value.id,t.value.obj);break;case"getShapeSettings":this.getShapeSettings(t.value.obj);break;case"isPointsInRange":this.isPointsInRange(t.value.x,t.value.y,t.value.obj);break;case"alignRotateFlipColl":this.alignRotateFlipColl(t.value.collection,t.value.isRotateFlipCollection,t.value.obj);break;case"selectShape":this.selectShape(t.value.id,t.value.obj);break;case"deleteShape":this.deleteShape(t.value.id);break;case"getMaxText":this.getMaxText(t.value.isTextBox,t.value.text,t.value.obj);break;case"setPointCollForLineArrow":t.value.obj.pointColl=this.getLinePoints(t.value.obj.activePoint.startX,t.value.obj.activePoint.startY,t.value.obj.activePoint.endX,t.value.obj.activePoint.endY);break;case"setPointCollForShapeRotation":this.setPointCollForShapeRotation(t.value.obj);break;case"setTextSettings":t.value.textSettings?this.textSettings=t.value.textSettings:t.value.fontFamily?this.textSettings.fontFamily=t.value.fontFamily:t.value.fontSize&&(this.textSettings.fontSize=t.value.fontSize);break;case"setStrokeSettings":t.value.strokeSettings?this.strokeSettings=t.value.strokeSettings:t.value.strokeColor?this.strokeSettings.strokeColor=t.value.strokeColor:t.value.fillColor?this.strokeSettings.fillColor=t.value.fillColor:t.value.strokeWidth&&(this.strokeSettings.strokeWidth=t.value.strokeWidth);break;case"getStrokeSettings":t.value.obj.strokeSettings=this.strokeSettings;break;case"setKeyHistory":this.keyHistory=t.value.keyHistory;break;case"getKeyHistory":t.value.obj.keyHistory=this.keyHistory;break;case"setTextBoxPos":this.setTextBoxPos(t.value.actObj,t.value.degree,t.value.flip,t.value.x,t.value.y);break;case"setTextBoxPoints":this.setTextBoxPoints(t.value.actObj,t.value.degree,t.value.flip,t.value.x,t.value.y);break;case"alignTextAreaIntoCanvas":this.alignTextAreaIntoCanvas();break;case"initializeTextShape":this.initializeTextShape(t.value.text,t.value.fontFamily,t.value.fontSize,t.value.bold,t.value.italic,t.value.strokeColor);break;case"stopPathDrawing":this.stopPathDrawing(t.value.e);break;case"updateArrowRatio":this.updateArrowRatio(t.value.obj);break;case"getSquarePointForRotatedShape":this.getSquarePointForRotatedShape(t.value.obj,t.value.object);break;case"reset":this.reset()}},i.prototype.getModuleName=function(){return"shape"},i.prototype.initShapePvtProps=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null}},i.prototype.drawEllipse=function(t,e,i,o,r,a,n,s){this.initializeShape("ellipse");var l=t&&e?{x:t,y:e}:null;this.drawShape("ellipse",r,a,n,l,i,o,null,null,null,s)},i.prototype.drawLine=function(t,e,i,o,r,a){this.initializeShape("line");var n=t&&e?{x:t,y:e}:null,s=i-t,l=o-e;this.drawShape("line",r,a,null,n,s,l)},i.prototype.drawPath=function(t,i,o){if(this.initializeShape("path"),t)this.drawShape("path",i,o,null,null,null,null,t);else{this.drawShape("line",i,o,null,null,null,null);var r=e.extend({},this.parent.objColl[this.parent.objColl.length-1],null,!0);r.shape="path",r.lineDraw=null,r.pointColl=[{x:r.activePoint.startX,y:r.activePoint.startY},{x:r.activePoint.endX,y:r.activePoint.endY}],this.parent.objColl[this.parent.objColl.length-1]=r}},i.prototype.drawArrow=function(t,e,i,o,r,a,n,s){this.initializeShape("arrow");var l=t&&e?{x:t,y:e}:null,p=i-t,h=o-e;this.drawShape("arrow",r,a,null,l,p,h,null,n,s)},i.prototype.drawRectangle=function(t,e,i,o,r,a,n,s){this.initializeShape("rectangle");var l=t&&e?{x:t,y:e}:null;this.drawShape("rectangle",r,a,n,l,i,o,null,null,null,s)},i.prototype.drawText=function(t,e,i,o,r,a,n,s){this.drawShapeText(i,o,r,a,n,s,t,e)},i.prototype.initializeShape=function(t){this.redrawActObj(),this.parent.activeObj.shape=t,"freehanddraw"===this.parent.currObjType.shape&&(this.apply(),this.parent.upperCanvas.style.cursor=this.parent.cursor="default",this.parent.currObjType.shape=""),this.parent.currObjType.isCustomCrop=!1},i.prototype.updateWidthHeight=function(t){return t.activePoint.width=t.activePoint.endX-t.activePoint.startX,t.activePoint.height=t.activePoint.endY-t.activePoint.startY,t},i.prototype.setDimension=function(t,e){t&&e&&(this.parent.activeObj.activePoint.width=t,this.parent.activeObj.activePoint.height=e,"ellipse"===this.parent.currObjType.shape.toLowerCase()&&(this.parent.activeObj.activePoint.width=2*t,this.parent.activeObj.activePoint.height=2*e))},i.prototype.getArrowType=function(t){var e=t;return t&&(e={None:"none",Arrow:"arrow",SolidArrow:"arrowSolid",Circle:"circle",SolidCircle:"circleSolid",Square:"square",SolidSquare:"squareSolid",Bar:"bar"}[""+t]),e},i.prototype.drawShape=function(t,i,o,r,a,n,s,l,p,h,c){var d=this,v=this.parent;if(!v.disabled&&v.isImageLoaded){v.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.redrawActObj();var u=e.extend([],v.objColl,[],!0);if(v.togglePen=!1,this.keyHistory="",this.parent.upperCanvas.style.display="block",this.refreshActiveObj(),v.currObjType.shape=t,"path"===v.currObjType.shape.toLowerCase()&&e.isNullOrUndefined(l))v.activeObj.shape=v.currObjType.shape.toLowerCase(),v.activeObj.pointColl=[],v.upperCanvas.style.cursor=this.parent.cursor="crosshair",v.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:"path"}}),e.isBlazor()||(v.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),v.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}));else if("freehanddraw"!==v.currObjType.shape.toLowerCase()&&""!==v.currObjType.shape.toLowerCase()){v.activeObj.shape=v.currObjType.shape.toLowerCase(),this.upperContext.clearRect(0,0,v.upperCanvas.width,v.upperCanvas.height),e.isNullOrUndefined(v.activeObj.strokeSettings)&&(v.activeObj.strokeSettings=this.strokeSettings),"path"===v.currObjType.shape.toLowerCase()&&l&&(v.activeObj.pointColl=l),v.activeObj.strokeSettings.strokeWidth=i||v.activeObj.strokeSettings.strokeWidth,v.activeObj.strokeSettings.strokeColor=o||v.activeObj.strokeSettings.strokeColor,v.activeObj.strokeSettings.fillColor=r||v.activeObj.strokeSettings.fillColor;var g=v.img.destWidth>100?100:v.img.destWidth/2,b=v.img.destHeight>100?100:v.img.destHeight/2;v.activeObj.activePoint.width=g,v.activeObj.activePoint.height=b,"line"===v.currObjType.shape.toLowerCase()||"arrow"===v.currObjType.shape.toLowerCase()?(v.activeObj.lineDraw="horizontal",v.activeObj.activePoint.height=0,"arrow"===v.currObjType.shape.toLowerCase()&&(v.activeObj.activePoint.width+=50,v.activeObj.start=this.getArrowType(p),v.activeObj.end=this.getArrowType(h))):"rectangle"===v.currObjType.shape.toLowerCase()&&(v.activeObj.activePoint.width+=v.activeObj.activePoint.width/2),this.setDimension(n,s),a?(v.activeObj.activePoint.startX=a.x,v.activeObj.activePoint.startY=a.y,v.activeObj.activePoint.endX=v.activeObj.activePoint.startX+v.activeObj.activePoint.width,v.activeObj.activePoint.endY=v.activeObj.activePoint.startY+v.activeObj.activePoint.height):this.setCenterPoints(),this.setPointCollForLineAndArrow(),"arrow"===v.currObjType.shape.toLowerCase()&&(v.activeObj.triangleDirection="right"),v.currObjType.isDragging=v.currObjType.isCustomCrop=!1,this.initShapeProps();var C={shapeSettingsObj:{}};v.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:C}});var f=C.shapeSettingsObj,m={action:"insert",previousShapeSettings:f,currentShapeSettings:f};e.isBlazor()&&v.events&&!0===v.events.shapeChanging.hasDelegate?this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",m).then(function(t){d.updateShapeChangeEventArgs(t.currentShapeSettings),d.setDimension(n,s),v.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),c&&(v.activeObj.rotatedAngle=c*(Math.PI/180),v.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:v.activeObj}})),v.updateToolbar(v.element,"quickAccessToolbar","shape"),v.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),v.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:u}}),v.isPublicMethod&&v.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),v.isPublicMethod=!1}):(v.trigger("shapeChanging",m),this.updateShapeChangeEventArgs(m.currentShapeSettings),this.setDimension(n,s),v.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),c&&(v.activeObj.rotatedAngle=c*(Math.PI/180),v.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:v.activeObj}})),e.isBlazor()?v.updateToolbar(v.element,"quickAccessToolbar","shape"):v.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),v.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),v.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:u}}),v.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),v.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),v.isPublicMethod&&v.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),v.isPublicMethod=!1)}}},i.prototype.initShapeProps=function(){var t=this.parent;t.activeObj.shapeDegree=t.transform.degree,t.activeObj.shapeFlip=t.transform.currFlipState,t.activeObj.textFlip=t.transform.currFlipState,t.activeObj.flipObjColl=[]},i.prototype.setPointCollForLineAndArrow=function(){var t=this.parent;if(("line"===t.activeObj.shape||"arrow"===t.activeObj.shape)&&(t.activeObj.pointColl=this.getLinePoints(t.activeObj.activePoint.startX,t.activeObj.activePoint.startY,t.activeObj.activePoint.endX,t.activeObj.activePoint.endY),t.activeObj.pointColl))for(var e=0,i=t.activeObj.pointColl.length;e<i;e++)t.activeObj.pointColl[e].ratioX=(t.activeObj.pointColl[e].x-t.img.destLeft)/t.img.destWidth,t.activeObj.pointColl[e].ratioY=(t.activeObj.pointColl[e].y-t.img.destTop)/t.img.destHeight},i.prototype.prevObjColl=function(){var t=this.parent,i={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}}),this.prevObj=i.currObj,this.prevObj.objColl=e.extend([],t.objColl,[],!0),this.prevObj.pointColl=e.extend([],t.pointColl,[],!0),this.prevObj.afterCropActions=e.extend([],t.afterCropActions,[],!0);var o={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),this.prevObj.selPointColl=e.extend([],o.selPointColl,[],!0)},i.prototype.drawShapeText=function(t,i,o,r,a,n,s,l){var p=this,h=this.parent;if(!h.disabled&&h.isImageLoaded){"freehanddraw"===h.currObjType.shape&&(this.apply(),h.upperCanvas.style.cursor=h.cursor="default",h.currObjType.shape=""),h.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),h.togglePen=!1,this.redrawActObj(),this.prevObjColl(),this.refreshActiveObj(),h.activeObj.shape=h.currObjType.shape="text",h.currObjType.isCustomCrop=!1,this.initializeTextShape(t,i,o,r,a,n),h.currObjType.isText=h.currObjType.isInitialText=!0,e.isNullOrUndefined(h.activeObj.textSettings.fontSize)&&(h.img.destWidth>h.img.destHeight?h.activeObj.textSettings.fontSize=h.img.destWidth/15:h.activeObj.textSettings.fontSize=h.img.destHeight/15,h.activeObj.textSettings.fontSize<20&&(h.activeObj.textSettings.fontSize=20)),h.img.destWidth<100?h.activeObj.textSettings.fontSize=Math.floor(h.img.destWidth/20):h.img.destHeight<100&&(h.activeObj.textSettings.fontSize=Math.floor(h.img.destHeight/20)),h.activeObj.shapeDegree=h.transform.degree,h.activeObj.shapeFlip=h.transform.currFlipState,h.activeObj.flipObjColl=[],this.updateFontStyles();var c=this.upperContext.measureText(h.activeObj.textSettings.text).width+.5*h.activeObj.textSettings.fontSize,d=h.activeObj.textSettings.fontSize+.25*h.activeObj.textSettings.fontSize;e.isNullOrUndefined(s)||e.isNullOrUndefined(l)?this.setCenterPoints(!0,c,d):(h.activeObj.activePoint.startX=s,h.activeObj.activePoint.startY=l,h.activeObj.activePoint.endX=h.activeObj.activePoint.startX+c,h.activeObj.activePoint.endY=h.activeObj.activePoint.startY+d);var v={shapeSettingsObj:{}};h.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:v}});var u=v.shapeSettingsObj,g={action:"insert",previousShapeSettings:u,currentShapeSettings:u};e.isBlazor()&&h.events&&!0===h.events.shapeChanging.hasDelegate?h.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",g).then(function(t){p.drawShapeTextEvent(t),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1}):(h.trigger("shapeChanging",g),this.drawShapeTextEvent(g),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1)}},i.prototype.drawShapeTextEvent=function(t){var i=this.parent;this.updateShapeChangeEventArgs(t.currentShapeSettings),this.addLetter(i.activeObj.textSettings.text),i.activeObj.textFlip=i.transform.currFlipState,this.updateFontRatio(i.activeObj),i.objColl.push(i.activeObj);var o=e.extend({},i.cropObj,{},!0);i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}}),e.isBlazor()?i.updateToolbar(i.element,"quickAccessToolbar","text"):i.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),i.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),e.isBlazor()||(i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))},i.prototype.initializeTextShape=function(t,i,o,r,a,n){var s=this.parent;this.keyHistory="",s.upperCanvas.style.display="block",e.isNullOrUndefined(s.activeObj.textSettings)&&(s.activeObj.textSettings=this.textSettings),e.isNullOrUndefined(s.activeObj.strokeSettings)&&(s.activeObj.strokeSettings=this.strokeSettings),s.activeObj.strokeSettings.strokeColor=n||s.activeObj.strokeSettings.strokeColor,s.activeObj.textSettings.text=t||s.activeObj.textSettings.text,s.activeObj.textSettings.fontFamily=i||s.activeObj.textSettings.fontFamily,s.activeObj.textSettings.fontSize=o||s.activeObj.textSettings.fontSize,s.activeObj.textSettings.bold=r||s.activeObj.textSettings.bold,s.activeObj.textSettings.italic=a||s.activeObj.textSettings.italic},i.prototype.redrawActObj=function(t,e,i){var o,r=this.parent;r.activeObj.shape&&(o=r.activeObj.shape.split("-")),r.activeObj.horTopLine&&r.activeObj.shape&&"crop"!==o[0]&&("block"===r.textArea.style.display?(r.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.updateFontRatio(r.activeObj,!0),t&&e?t!==r.activeObj.activePoint.startX&&e!==r.activeObj.activePoint.startY&&(this.updateTextFromTextArea(),this.applyActObj()):(this.updateTextFromTextArea(),this.apply(r.activeObj.shape,r.activeObj),r.objColl.push(r.activeObj),this.refreshActiveObj(),r.textArea.style.transform="",r.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}))):this.applyActObj(i))},i.prototype.apply=function(t,i,o){var r=this.parent;if(!r.disabled)if(r.togglePen&&!r.currObjType.isCustomCrop){var a=r.img.destLeft,n=r.img.destTop,s=r.img.destWidth,l=r.img.destHeight;r.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1});var p=this.lowerContext.filter;this.lowerContext.filter="none",r.togglePen=!1,this.iterateObjColl(),r.notify("freehandDraw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),r.togglePen=!1,(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r.img.destLeft=a,r.img.destTop=n,r.img.destWidth=s,r.img.destHeight=l,this.lowerContext.filter=p}else o=o||"original",e.isNullOrUndefined(r.activeObj.shape)&&e.isNullOrUndefined(t)?r.currObjType.shape="":r.currObjType.shape=t||r.currObjType.shape,""!==r.currObjType.shape&&(this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),"text"===r.activeObj.shape?(r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),r.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}})):r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i}}),r.activeObj.shape=r.currObjType.shape.toLowerCase(),t||""===r.currObjType.shape||r.currObjType.isCustomCrop||r.objColl.push(e.extend({},r.activeObj,{},!0)),this.keyHistory="")},i.prototype.setCenterPoints=function(t,e,i){var o,r,a=this.parent;t&&e&&i?(o=e,r=i):(o=a.activeObj.activePoint.width,r=a.activeObj.activePoint.height),a.activeObj.activePoint.startX=a.lowerCanvas.width/2-o/2,a.activeObj.activePoint.startY=a.lowerCanvas.height/2-r/2,a.activeObj.activePoint.endX=a.lowerCanvas.width/2+o/2,a.activeObj.activePoint.endY=a.lowerCanvas.height/2+r/2},i.prototype.updSelChangeEventArgs=function(t){var e=this.parent;e.activeObj.activePoint.startX=t.startX,e.activeObj.activePoint.startY=t.startY,e.activeObj.activePoint.width=t.width,e.activeObj.activePoint.height=t.height,e.activeObj.activePoint.endX=e.activeObj.activePoint.startX+e.activeObj.activePoint.width,e.activeObj.activePoint.endY=e.activeObj.activePoint.startY+e.activeObj.activePoint.height},i.prototype.updateShapeChangeEventArgs=function(t){var e=this.parent;switch(e.activeObj.currIndex=t.id,e.activeObj.activePoint.startX=t.startX,e.activeObj.activePoint.startY=t.startY,e.activeObj.activePoint.width=t.width,e.activeObj.activePoint.height=t.height,e.activeObj.activePoint.endX=e.activeObj.activePoint.startX+e.activeObj.activePoint.width,e.activeObj.activePoint.endY=e.activeObj.activePoint.startY+e.activeObj.activePoint.height,e.activeObj.strokeSettings.strokeColor=t.strokeColor,e.activeObj.strokeSettings.fillColor=t.fillColor,e.activeObj.shape){case"ellipse":e.activeObj.activePoint.width=t.radius/2;break;case"line":case"arrow":e.activeObj.activePoint.width=t.length;break;case"text":e.activeObj.keyHistory=e.activeObj.textSettings.text=t.text,e.activeObj.textSettings.fontSize=t.fontSize,e.activeObj.strokeSettings.strokeColor=t.color,e.activeObj.textSettings.fontFamily=t.fontFamily}if("text"===e.activeObj.shape&&e.activeObj.textSettings)for(var i=0;i<t.fontStyle.length;i++)switch(t.fontStyle[i]){case"bold":e.activeObj.textSettings.bold=!0;break;case"italic":e.activeObj.textSettings.italic=!0;break;case"underline":e.activeObj.textSettings.underline=!0}},i.prototype.addLetter=function(t){var e=this.parent;if("none"===e.textArea.style.display&&(e.currObjType.isText||"text"===e.activeObj.shape)){"Backspace"===t?this.keyHistory=this.keyHistory.slice(0,-1):this.keyHistory+=t,this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.updateFontStyles();var i=this.upperContext.measureText(this.keyHistory).width+.5*e.activeObj.textSettings.fontSize,o=e.activeObj.textSettings.fontSize+.25*e.activeObj.textSettings.fontSize;this.upperContext.fillText(this.keyHistory,e.activeObj.activePoint.startX,e.activeObj.activePoint.startY+e.activeObj.textSettings.fontSize),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.currObjType.isText=!0,e.notify("selection",{prop:"setActivePoint",onPropertyChange:!1,value:{startX:i,startY:o}})}},i.prototype.redrawText=function(){var t=this.parent,e="";t.activeObj.textSettings.bold&&(e+="bold "),t.activeObj.textSettings.italic&&(e+="italic "),this.upperContext.font=e+t.activeObj.textSettings.fontSize+"px "+t.activeObj.textSettings.fontFamily;var i=t.activeObj.keyHistory.split("\n"),o="block"===t.textArea.style.display?this.getMaxText(!0):this.getMaxText(),r=this.upperContext.measureText(o).width+.5*t.activeObj.textSettings.fontSize,a=i.length*(t.activeObj.textSettings.fontSize+.25*t.activeObj.textSettings.fontSize);t.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:r,height:a}}),t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.activeObj.activePoint,obj:t.activeObj,isMouseMove:null,x:null,y:null}}),t.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:t.activeObj}})},i.prototype.updateTextFromTextArea=function(){var t=this.parent;if(t.activeObj.keyHistory!==t.textArea.value){var i=e.extend({},t.cropObj,{},!0),o={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],t.objColl,[],!0),r.pointColl=e.extend([],t.pointColl,[],!0),r.afterCropActions=e.extend([],this.parent.afterCropActions,[],!0);var a={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"text",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:t.activeObj.keyHistory,currentText:t.textArea.value,previousFilter:null,isCircleCrop:null}})}t.activeObj.keyHistory=t.textArea.value,t.textArea.style.display="none",t.textArea.value="",this.updateFontStyles();var n=this.upperContext.measureText(t.activeObj.keyHistory).width+.5*t.activeObj.textSettings.fontSize,s=t.activeObj.textSettings.fontSize+.25*this.parent.activeObj.textSettings.fontSize,l=t.activeObj.keyHistory.split("\n");if(l.length>1){s*=l.length;for(var p=[],h=0,c=l.length;h<c;h++)p.push(this.upperContext.measureText(l[h]).width+.5*t.activeObj.textSettings.fontSize);n=Math.max.apply(Math,p)}t.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:n,height:s}}),t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.activeObj.activePoint,obj:t.activeObj,isMouseMove:null,x:null,y:null}}),this.updImgRatioForActObj()},i.prototype.iterateObjColl=function(){for(var t=this.parent,e=0,i=t.objColl.length;e<i;e++)this.apply(t.objColl[e].shape,t.objColl[e]),this.refreshActiveObj()},i.prototype.updImgRatioForActObj=function(){var t=this.parent;t.activeObj.imageRatio={startX:(t.activeObj.activePoint.startX-t.img.destLeft)/t.img.destWidth,startY:(t.activeObj.activePoint.startY-t.img.destTop)/t.img.destHeight,endX:(t.activeObj.activePoint.endX-t.img.destLeft)/t.img.destWidth,endY:(t.activeObj.activePoint.endY-t.img.destTop)/t.img.destHeight,width:t.img.destWidth/t.activeObj.activePoint.width,height:t.img.destHeight/t.activeObj.activePoint.height},t.activeObj.rotationCirclePointColl&&(t.activeObj.rotationCirclePointColl.ratioX=(t.activeObj.rotationCirclePointColl.x-t.img.destLeft)/t.img.destWidth,t.activeObj.rotationCirclePointColl.ratioY=(t.activeObj.rotationCirclePointColl.y-t.img.destTop)/t.img.destHeight),"path"===t.activeObj.shape?this.updatePathRatio(t.activeObj):"arrow"===t.activeObj.shape&&this.updateArrowRatio(t.activeObj)},i.prototype.zoomObjColl=function(t){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++){var a=i.objColl[o];if(a.activePoint.startX=a.imageRatio.startX*i.img.destWidth+i.img.destLeft,a.activePoint.startY=a.imageRatio.startY*i.img.destHeight+i.img.destTop,a.activePoint.endX=a.imageRatio.endX*i.img.destWidth+i.img.destLeft,a.activePoint.endY=a.imageRatio.endY*i.img.destHeight+i.img.destTop,"text"===(a=this.updateWidthHeight(a)).shape)this.updateFontSize(a);else if("line"===a.shape||"arrow"===a.shape){a.pointColl=this.getLinePoints(a.activePoint.startX,a.activePoint.startY,a.activePoint.endX,a.activePoint.endY);for(var n=0,s=a.pointColl.length;n<s;n++)a.pointColl[n].ratioX=(a.pointColl[n].x-i.img.destLeft)/i.img.destWidth,a.pointColl[n].ratioY=(a.pointColl[n].y-i.img.destTop)/i.img.destHeight;"arrow"===a.shape&&this.updateArrowSize(a)}else if("path"===a.shape){for(var l=0,p=a.pointColl.length;l<p;l++)a.pointColl[l].x=a.pointColl[l].ratioX*i.img.destWidth+i.img.destLeft,a.pointColl[l].y=a.pointColl[l].ratioY*i.img.destHeight+i.img.destTop;this.updatePathRatio(a)}if(i.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:a.activePoint,obj:a}}),e.isNullOrUndefined(t)){var h=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(a.shape,a),this.refreshActiveObj(),this.lowerContext.filter=h}"line"!==a.shape&&"arrow"!==a.shape&&"path"!==a.shape&&0!==a.rotatedAngle&&(this.setPointCollForShapeRotation(a),a.rotationCirclePoint.x=a.rotationCirclePoint.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePoint.y=a.rotationCirclePoint.ratioY*i.img.destHeight+i.img.destTop,a.rotationCirclePointColl.x=a.rotationCirclePointColl.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePointColl.y=a.rotationCirclePointColl.ratioY*i.img.destHeight+i.img.destTop)}},i.prototype.redrawObj=function(t){var e=this.parent;if(this.parent.objColl.length>0)if("horizontal"===t||"vertical"===t||"Horizontal"===t||"Vertical"===t||"horizontalVertical"===t||"verticalHorizontal"===t)this.updateCurrentActiveObjPoint(t.toLowerCase());else if("number"==typeof t){this.updateCurrentActiveObjPoint(t);var i=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var o=0,r=e.objColl.length;o<r;o++)"crop"!==e.objColl[o].shape.split("-")[0]&&this.apply(e.objColl[o].shape,e.objColl[o]);this.lowerContext.filter=i}},i.prototype.updateCurrentActiveObjPoint=function(t){for(var i,o=this.parent,r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(o.activeObj.shape===n.shape&&o.activeObj.activePoint.startX===n.activePoint.startX&&o.activeObj.activePoint.startY===n.activePoint.startY&&o.activeObj.activePoint.endX===n.activePoint.endX&&o.activeObj.activePoint.endY===n.activePoint.endY&&o.activeObj.currIndex===n.currIndex){i=r;break}}if("horizontal"===t||"vertical"===t||"Horizontal"===t||"Vertical"===t||"horizontalvertical"===t||"verticalhorizontal"===t){if("horizontal"===t||"Horizontal"===t)for(var s=0,a=o.objColl.length;s<a;s++)(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"horizontal"):0!==n.rotatedAngle&&(n.rotatedAngle=n.rotatedAngle+2*(Math.PI-n.rotatedAngle),n.rotationCirclePointColl.x<=o.img.destLeft+o.img.destWidth/2?n.rotationCirclePointColl.x=o.img.destLeft+o.img.destWidth-(n.rotationCirclePointColl.x-o.img.destLeft):n.rotationCirclePointColl.x>=o.img.destLeft+o.img.destWidth/2&&(n.rotationCirclePointColl.x=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.rotationCirclePointColl.x)),n.rotationCirclePointColl.ratioX=(n.rotationCirclePointColl.x-o.img.destLeft)/o.img.destWidth),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height});else if("vertical"===t||"Vertical"===t)for(s=0;s<o.objColl.length;s++)(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"vertical"):0!==n.rotatedAngle&&(n.rotatedAngle=-n.rotatedAngle,n.rotationCirclePointColl.y<=o.img.destTop+o.img.destHeight/2?n.rotationCirclePointColl.y=o.img.destTop+o.img.destHeight-(n.rotationCirclePointColl.y-o.img.destTop):n.rotationCirclePointColl.y>=o.img.destTop+o.img.destHeight/2&&(n.rotationCirclePointColl.y=o.img.destTop+(o.img.destTop+o.img.destHeight-n.rotationCirclePointColl.y)),n.rotationCirclePointColl.ratioY=(n.rotationCirclePointColl.y-o.img.destTop)/o.img.destHeight),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height});else if("verticalhorizontal"===t||"horizontalvertical"===t)for(var s=0,a=o.objColl.length;s<a;s++)(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"!==n.shape&&"arrow"!==n.shape&&"path"!==n.shape||this.flipLineArrowObj(n,t),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height});void 0!==i&&(o.activeObj=e.extend({},o.objColl[i],{},!0))}else if(90===t)this.rotateObjColl();else if(-90===t)for(s=0;s<3;s++)this.rotateObjColl();else if("number"==typeof t)if(t>0)this.rotateObjColl();else for(s=0;s<3;s++)this.rotateObjColl()},i.prototype.rotateObjColl=function(){for(var t=this.parent,e=0,i=t.objColl.length;e<i;e++)(o=t.objColl[e]).activePoint.startY=t.img.destTop+t.img.destHeight*o.imageRatio.startX,o.activePoint.endY=t.img.destTop+t.img.destHeight*o.imageRatio.endX,o.activePoint.startX=t.img.destLeft+t.img.destWidth-t.img.destWidth*o.imageRatio.endY,o.activePoint.endX=t.img.destLeft+t.img.destWidth-t.img.destWidth*o.imageRatio.startY,o=this.updateWidthHeight(t.objColl[e]),this.updateFontSize(o),"line"===o.shape||"arrow"===o.shape||"path"===o.shape?(this.rotateLineArrowObj(o),"arrow"===o.shape&&this.updateArrowSize(o)):0!==o.rotatedAngle&&(o.rotationCirclePointColl.y=t.img.destTop+t.img.destHeight*o.rotationCirclePointColl.ratioX,o.rotationCirclePointColl.x=t.img.destLeft+t.img.destWidth-t.img.destWidth*o.rotationCirclePointColl.ratioY,o.rotationCirclePointColl.ratioX=(o.rotationCirclePointColl.x-t.img.destLeft)/t.img.destWidth,o.rotationCirclePointColl.ratioY=(o.rotationCirclePointColl.y-t.img.destTop)/t.img.destHeight);for(var e=0,i=t.objColl.length;e<i;e++)t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.objColl[e].activePoint,obj:t.objColl[e]}});for(var e=0,i=t.objColl.length;e<i;e++){var o=t.objColl[e];o.imageRatio={startX:(o.activePoint.startX-t.img.destLeft)/t.img.destWidth,startY:(o.activePoint.startY-t.img.destTop)/t.img.destHeight,endX:(o.activePoint.endX-t.img.destLeft)/t.img.destWidth,endY:(o.activePoint.endY-t.img.destTop)/t.img.destHeight,width:t.img.destWidth/o.activePoint.width,height:t.img.destHeight/o.activePoint.height}}},i.prototype.rotateLineArrowObj=function(t){if(!e.isNullOrUndefined(t.pointColl)){var i=this.parent;if(t.pointColl.length>0){for(o=0;o<t.pointColl.length;o++)t.pointColl[o].y=i.img.destTop+i.img.destHeight*t.pointColl[o].ratioX,t.pointColl[o].x=i.img.destLeft+i.img.destWidth-i.img.destWidth*t.pointColl[o].ratioY;for(var o=0;o<t.pointColl.length;o++)t.pointColl[o].ratioX=(t.pointColl[o].x-i.img.destLeft)/i.img.destWidth,t.pointColl[o].ratioY=(t.pointColl[o].y-i.img.destTop)/i.img.destHeight;var r=void 0;r=e.isNullOrUndefined(t.pointColl[t.pointColl.length-2])?{x:0,y:0}:{x:t.pointColl[t.pointColl.length-2].x,y:t.pointColl[t.pointColl.length-2].y};var a=t.pointColl[t.pointColl.length-1].x-r.x,n=t.pointColl[t.pointColl.length-1].y-r.y;t.activePoint.startX=t.pointColl[0].x,t.activePoint.startY=t.pointColl[0].y,t.activePoint.endX=t.pointColl[t.pointColl.length-1].x+a/2,t.activePoint.endY=t.pointColl[t.pointColl.length-1].y+n/2,t=this.updateWidthHeight(t)}}},i.prototype.flipLineArrowObj=function(t,i){if(!e.isNullOrUndefined(t.pointColl)&&("horizontal"===i.toLowerCase()?this.lineArrowHorizontalFlip(t):"vertical"===i.toLowerCase()?this.lineArrowVerticalFlip(t):(this.lineArrowHorizontalFlip(t),t.shapeFlip="",this.lineArrowVerticalFlip(t)),t.activePoint.startX=t.pointColl[0].x,t.activePoint.startY=t.pointColl[0].y,t.activePoint.endX=t.pointColl[t.pointColl.length-1].x,t.activePoint.endY=t.pointColl[t.pointColl.length-1].y,t.activePoint.startX>t.activePoint.endX)){var o=t.activePoint.startX;t.activePoint.startX=t.activePoint.endX,t.activePoint.endX=o,o=t.activePoint.startY,t.activePoint.startY=t.activePoint.endY,t.activePoint.endY=o}},i.prototype.lineArrowHorizontalFlip=function(t){var e=this.parent;if(t.shapeFlip!==e.transform.currFlipState){for(var i=0,o=t.pointColl.length;i<o;i++){var r=t.pointColl[i];r.x<=e.img.destLeft+e.img.destWidth/2?r.x=e.img.destLeft+e.img.destWidth-(r.x-e.img.destLeft):r.x>=e.img.destLeft+e.img.destWidth/2&&(r.x=e.img.destLeft+(e.img.destLeft+e.img.destWidth-r.x)),r.ratioX=(r.x-e.img.destLeft)/e.img.destWidth,r.ratioY=(r.y-e.img.destTop)/e.img.destHeight}if("arrow"===t.shape){var a=t.start;t.start=t.end,t.end=a}t.shapeFlip=e.transform.currFlipState}},i.prototype.lineArrowVerticalFlip=function(t){var e=this.parent;if(t.shapeFlip!==e.transform.currFlipState){for(var i=0,o=t.pointColl.length;i<o;i++){var r=t.pointColl[i];r.y<=e.img.destTop+e.img.destHeight/2?r.y=e.img.destTop+e.img.destHeight-(r.y-e.img.destTop):r.y>=e.img.destTop+e.img.destHeight/2&&(r.y=e.img.destTop+(e.img.destTop+e.img.destHeight-r.y)),r.ratioX=(r.x-e.img.destLeft)/e.img.destWidth,r.ratioY=(r.y-e.img.destTop)/e.img.destHeight}t.shapeFlip=e.transform.currFlipState}},i.prototype.getRotDegOfShape=function(t){var e;return(e=0===t.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-t.shapeDegree)<0&&(e=360+e),e},i.prototype.renderTextArea=function(t,i,o){var r=this.parent,a=this.getRotDegOfShape(r.activeObj);this.transformTextArea(),e.isBlazor()?r.updateToolbar(r.element,"destroyQuickAccessToolbar"):r.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),r.element.querySelector("#"+r.element.id+"_duplicate")&&r.element.querySelector("#"+r.element.id+"_duplicate").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_remove")&&r.element.querySelector("#"+r.element.id+"_remove").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_editText")&&r.element.querySelector("#"+r.element.id+"_editText").classList.add("e-disabled"),r.textArea.style.display="block",r.textArea.style.left=t+"px",r.textArea.style.top=i+"px",r.textArea.style.fontFamily=o.textSettings.fontFamily,r.textArea.style.fontSize=o.textSettings.fontSize+"px",r.textArea.style.color=o.strokeSettings.strokeColor,r.textArea.style.fontWeight=o.textSettings.bold?"bold":"normal",r.textArea.style.fontStyle=o.textSettings.italic?"italic":"normal",r.textArea.style.border="2px solid "+r.themeColl[r.theme].primaryColor,r.textArea.value=o.keyHistory,r.textArea.style.overflow="hidden",r.textArea.style.width="auto",r.textArea.style.height="auto",r.textArea.focus();r.transform.zoomFactor;var n=o.activePoint,s=n.width,l=n.height;a%90==0&&a%180!=0&&0!==a?(r.textArea.style.width=l+"px",r.textArea.style.height=s+"px"):(r.textArea.style.width=s+"px",r.textArea.style.height=l+"px"),this.setTextBoxWidth();var p={flipColl:null};r.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:p}}),p.flipColl.length<=1&&this.setTextBoxHeight(),a%90==0&&a%180!=0?parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destTop+r.img.destHeight&&this.alignTextAreaIntoCanvas():parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destLeft+r.img.destWidth&&this.alignTextAreaIntoCanvas(),r.notify("selection",{prop:"clearUpperCanvas",onPropertyChange:!1})},i.prototype.setTextBoxWidth=function(t){var i=this.parent,o=this.getMaxText(!0);"block"===i.textArea.style.display?this.updateFontStyles(!0):this.updateFontStyles();var r=this.upperContext.measureText(o).width+parseFloat(i.textArea.style.fontSize)/2,a=t?this.upperContext.measureText(String.fromCharCode(t.which)).width:0,n=e.extend({},i.activeObj,{},!0),s="",l=this.getRotDegOfShape(n);if(s=n.shapeFlip!==i.transform.currFlipState?"":i.transform.currFlipState,t&&parseFloat(i.textArea.style.width)<r+a||e.isNullOrUndefined(t))if(0===l)"horizontal"===s.toLowerCase()?parseFloat(i.textArea.style.left)-i.img.destLeft-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)>r+a&&(i.textArea.style.width=r+a+"px");else if(90===l)"vertical"===s.toLowerCase()?parseFloat(i.textArea.style.top)-i.img.destTop-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destHeight-(parseFloat(i.textArea.style.top)-i.img.destTop)>r+a&&(i.textArea.style.width=r+a+"px");else if(180===l){var p=parseFloat(i.textArea.style.left),h=i.img.destLeft;"horizontal"===s.toLowerCase()?i.img.destWidth-(p-h)>r+a&&(i.textArea.style.width=r+a+"px"):p-h-r-a>0&&(i.textArea.style.width=r+a+"px")}else if(270===l){var c=parseFloat(i.textArea.style.top),d=i.img.destTop;"vertical"===s.toLowerCase()?i.img.destHeight-(c-d)>r+a&&(i.textArea.style.width=r+a+"px"):c-d-r-a>0&&(i.textArea.style.width=r+a+"px")}},i.prototype.setTextBoxHeight=function(){var t,i=this.parent,o=e.extend({},i.activeObj,{},!0),r="",a=this.getRotDegOfShape(o);switch(r=o.textFlip===i.transform.currFlipState?"":""===o.textFlip?i.transform.currFlipState:o.textFlip,a){case 0:"vertical"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destHeight-(i.img.destHeight-parseFloat(i.textArea.style.top))+"px":(t=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-t+"px");break;case 90:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px":i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px";break;case 180:"vertical"===r.toLowerCase()?(t=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-t+"px"):i.textArea.style.maxHeight=parseFloat(i.textArea.style.top)-i.img.destTop+"px";break;case 270:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px":i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px"}},i.prototype.updatePathRatio=function(t){for(var e=this.parent,i=0,o=t.pointColl.length;i<o;i++){var r=t.pointColl[i];r.ratioX=(r.x-e.img.destLeft)/e.img.destWidth,r.ratioY=(r.y-e.img.destTop)/e.img.destHeight}},i.prototype.stopPathDrawing=function(t){var i=this.parent;if("path"===i.activeObj.shape){var o={shape:null};if(i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:o}}),"path"===o.shape){var r=e.extend({},this.parent.cropObj,{},!0),a={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=e.extend([],this.parent.objColl,[],!0),n.pointColl=e.extend([],this.parent.pointColl,[],!0),n.afterCropActions=e.extend([],this.parent.afterCropActions,[],!0);var s={selPointColl:null};this.parent.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=e.extend([],s.selPointColl,[],!0),i.notify("selection",{prop:"setCurrentDrawingShape",value:{value:""}}),i.currObjType.isDragging=!1,"touchstart"!==t.type&&i.activeObj.pointColl.pop(),this.updatePathRatio(i.activeObj),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("selection",{prop:"mouseUpEventHandler",value:{e:t}}),i.notify("draw",{prop:"setNewPath",value:{bool:!0}}),i.objColl[i.objColl.length-1]&&i.selectShape(i.objColl[i.objColl.length-1].currIndex),e.isBlazor()?i.updateToolbar(i.element,"quickAccessToolbar",i.activeObj.shape):i.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})}}},i.prototype.findTextTarget=function(t){var i=this.parent;if("text"!==i.activeObj.shape)return void this.stopPathDrawing(t);var o,r;if("dblclick"===t.type?(o=t.clientX,r=t.clientY):"touchstart"===t.type&&(o=t.touches[0].clientX,r=t.touches[0].clientY,i.notify("selection",{prop:"setTouchEndPoint",onPropertyChange:!1,value:{x:t.touches[0].clientX,y:t.touches[0].clientY}})),i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!0}}),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!1}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),e.isNullOrUndefined(o)||e.isNullOrUndefined(r))if("block"===i.textArea.style.display&&""!==this.selectedText()&&"mousedown"===t.type){l=i.textArea.value;i.textArea.value+="a",i.textArea.value=l}else"none"===i.textArea.style.display&&(i.textArea.style.display="block");else{var a=this.parent.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top;var n="",s=this.getRotDegOfShape(i.activeObj);n=""===i.activeObj.textFlip?i.activeObj.textFlip===i.transform.currFlipState?"":i.transform.currFlipState:i.activeObj.textFlip===i.transform.currFlipState?"":""===i.transform.currFlipState?i.activeObj.textFlip:i.transform.currFlipState;var l=void 0;if("none"===i.textArea.style.display){l=e.extend({},i.activeObj,{},!0);for(var p=0;p<i.objColl.length;p++)JSON.stringify(i.activeObj)===JSON.stringify(i.objColl[p])&&i.objColl.splice(p,1);this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),this.lowerContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.activeObj=l,this.updateFontStyles();var h=e.extend({},i.activeObj,{},!0);if(o>=h.activePoint.startX-2*h.topLeftCircle.radius&&o<=h.activePoint.endX+2*h.topLeftCircle.radius&&r>=h.activePoint.startY-2*h.topLeftCircle.radius&&r<=h.activePoint.endY+2*h.topLeftCircle.radius){if(this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),4===h.flipObjColl.length&&(h.flipObjColl=[],n="",h.shapeFlip=""),""===n&&h.flipObjColl.length>1&&(n=h.flipObjColl[h.flipObjColl.length-1]),h.flipObjColl.length<=1)o=(c=this.setTextBoxPos(h,s,n,o,r)).x,r=c.y;else{var c=this.setTextBoxPoints(h,s,n,o,r);o=c.x,r=c.y}0!==i.activeObj.rotatedAngle&&(o=i.activeObj.horTopLinePointColl[0].x,r=i.activeObj.horTopLinePointColl[0].y),this.renderTextArea(o,r,h)}else this.applyActObj()}}},i.prototype.setTextBoxPos=function(t,e,i,o,r){var a={x:o,y:r};switch(e){case 0:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.endY):(a.x=t.activePoint.startX,a.y=t.activePoint.startY);break;case 90:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):(a.x=t.activePoint.endX,a.y=t.activePoint.startY);break;case 180:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.startY):(a.x=t.activePoint.endX,a.y=t.activePoint.endY);break;case 270:"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):(a.x=t.activePoint.startX,a.y=t.activePoint.endY)}return a},i.prototype.setTextBoxPoints=function(t,e,i,o,r){var a={x:o,y:r};switch(e){case 0:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.startY);break;case 90:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.startY);break;case 180:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.startX,a.y=t.activePoint.endY);break;case 270:t.flipObjColl[0]&&"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=t.activePoint.startX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=t.activePoint.endX,a.y=t.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=t.activePoint.endX,a.y=t.activePoint.endY)}return a},i.prototype.selectedText=function(){var t=this.parent.textArea.selectionStart,e=this.parent.textArea.selectionEnd;return this.parent.textArea.value.substring(t,e)},i.prototype.panObjColl=function(t,e,i){for(var o=this.parent,r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(""===i||"vertical"===i){if(n.activePoint.startX+=t,n.activePoint.endX+=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x+=t),"path"===n.shape)for(var s=0,l=n.pointColl.length;s<l;s++)n.pointColl[s].x+=t}else if(n.activePoint.startX-=t,n.activePoint.endX-=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x-=t),"path"===n.shape)for(var s=0,p=n.pointColl.length;s<p;s++)n.pointColl[s].x-=t;if(""===i||"horizontal"===i){if(n.activePoint.startY+=e,n.activePoint.endY+=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y+=e),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y+=e}else if(n.activePoint.startY-=e,n.activePoint.endY-=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y-=e),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y-=e;if(n=this.updateWidthHeight(n),o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}}),"line"===n.shape||"arrow"===n.shape){n.pointColl=this.getLinePoints(n.activePoint.startX,n.activePoint.startY,n.activePoint.endX,n.activePoint.endY);for(var h=0,c=n.pointColl.length;h<c;h++)n.pointColl[h].ratioX=(n.pointColl[h].x-o.img.destLeft)/o.img.destWidth,n.pointColl[h].ratioY=(n.pointColl[h].y-o.img.destTop)/o.img.destHeight}var d=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(n.shape,n),this.lowerContext.filter=d,this.refreshActiveObj()}},i.prototype.updateFontStyles=function(t){var e=this.parent;this.upperContext.strokeStyle=e.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=e.activeObj.strokeSettings.strokeColor;var i="";e.activeObj.textSettings.bold&&(i="bold "),e.activeObj.textSettings.italic&&(i="italic "),e.activeObj.textSettings.bold&&e.activeObj.textSettings.italic&&(i="italic bold ");var o=t?parseFloat(e.textArea.style.fontSize):e.activeObj.textSettings.fontSize,r="block"===e.textArea.style.display?e.textArea.style.fontFamily:e.activeObj.textSettings.fontFamily;this.upperContext.font=i+o+"px "+r},i.prototype.applyFontStyle=function(t){var i=this.parent;this.pushActItemIntoObj();var o=e.extend([],i.objColl,[],!0);switch(i.objColl.pop(),"none"===i.textArea.style.display?this.updateFontRatio(i.activeObj):this.updateFontRatio(i.activeObj,!0),t){case"default":this.updateFontStyle(t,o,"normal","normal");break;case"bold":this.updateFontStyle(t,o,"bold","normal");break;case"italic":this.updateFontStyle(t,o,"normal","italic");break;case"bolditalic":this.updateFontStyle(t,o,"bold","italic")}},i.prototype.updateFontStyle=function(t,e,i,o){var r=this.parent;if("block"===r.textArea.style.display){var a=this.getTextAreaWidth(t);r.textArea.style.width=a+"px",r.textArea.style.fontWeight=i,r.textArea.style.fontStyle=o,this.updateObjColl(t,e)}else this.textSettings.bold=r.activeObj.textSettings.bold="normal"!==i,this.textSettings.italic=r.activeObj.textSettings.italic="normal"!==o,this.redrawText(),r.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:e}})},i.prototype.updateArrowRatio=function(t){var e={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:e}});var i,o=this.getRotDegOfShape(t);i=0===o||180===o||-180===o?Math.abs(t.activePoint.width):Math.abs(t.activePoint.height);for(var r,a=0,n=["bar","arrow","arrowSolid","circle","square"];a<n.length;a++){r=n[a];var s=i/e.arrowDimension[r].width,l=i/e.arrowDimension[r].height;e.arrowDimension[r].ratioX=s,e.arrowDimension[r].ratioY=l}},i.prototype.updateArrowSize=function(t){var e={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:e}});var i,o=this.getRotDegOfShape(t);i=0===o||180===o||-180===o?Math.abs(t.activePoint.width):Math.abs(t.activePoint.height);for(var r,a=0,n=["bar","arrow","arrowSolid","circle","square"];a<n.length;a++){r=n[a];var s=e.arrowDimension[r].ratioX,l=e.arrowDimension[r].ratioY;e.arrowDimension[r].width=i/s,e.arrowDimension[r].height=i/l}},i.prototype.updateFontRatio=function(t,i){var o=this.parent,r=this.getMaxText(i),a=this.upperContext.measureText(r).width+.5*o.activeObj.textSettings.fontSize,n=o.activeObj.textSettings.fontSize+.25*o.activeObj.textSettings.fontSize,s=this.getRotDegOfShape(t);e.isNullOrUndefined(i)?0===s||180===Math.abs(s)?t.textSettings.fontRatio=a/t.textSettings.fontSize:t.textSettings.fontRatio=n/t.textSettings.fontSize:i&&(t.textSettings.fontRatio=a/parseFloat(o.textArea.style.fontSize))},i.prototype.updateFontSize=function(t){var e=this.getRotDegOfShape(t);0===e||180===Math.abs(e)?t.textSettings.fontSize=t.activePoint.width/t.textSettings.fontRatio:t.textSettings.fontSize=t.activePoint.height/t.textSettings.fontRatio},i.prototype.updateObjColl=function(t,i){var o=this.parent,r=e.extend({},o.cropObj,{},!0),a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=i,n.pointColl=e.extend([],o.pointColl,[],!0),n.afterCropActions=e.extend([],o.afterCropActions,[],!0);var s={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=e.extend([],s.selPointColl,[],!0);var l=o.activeObj.textSettings.bold,p=o.activeObj.textSettings.italic;switch(t){case"default":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!1;break;case"bold":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!1;break;case"italic":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!0;break;case"bolditalic":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!0}o.objColl.push(o.activeObj),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.objColl.pop(),o.activeObj.textSettings.bold=l,o.activeObj.textSettings.italic=p},i.prototype.pushActItemIntoObj=function(){if("none"===this.parent.textArea.style.display)this.parent.objColl.push(this.parent.activeObj);else{var t=e.extend({},this.parent.activeObj,{},!0);this.parent.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.parent.objColl.push(this.parent.activeObj),this.parent.activeObj=t}},i.prototype.clearActObj=function(){"none"===this.parent.textArea.style.display&&(this.refreshActiveObj(),this.applyActObj(),this.refreshActiveObj(),this.parent.currObjType.isCustomCrop=!1)},i.prototype.refreshActiveObj=function(){this.parent.activeObj={},this.parent.activeObj.activePoint={startX:0,startY:0,endX:0,endY:0,width:0,height:0},this.parent.activeObj.triangle=[],this.parent.activeObj.triangleRatio=[],this.parent.activeObj.flipObjColl=[],this.parent.activeObj.strokeSettings=this.strokeSettings,this.parent.activeObj.textSettings=this.textSettings,this.parent.activeObj.rotatedAngle=0},i.prototype.applyActObj=function(t){var i=!1;if(void 0!==this.parent.activeObj.shape&&"text"===this.parent.activeObj.shape&&""===this.parent.activeObj.keyHistory)this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height);else{var o=void 0,r=!1;if(void 0!==this.parent.activeObj.shape&&(o=this.parent.activeObj.shape.split("-")),void 0===o&&this.parent.currObjType.isCustomCrop?r=!0:void 0!==o&&"crop"===o[0]&&(r=!0),this.parent.activeObj.shape&&!r&&"shape"!==this.parent.activeObj.shape){for(s=0;s<this.parent.objColl.length;s++)if(JSON.stringify(this.parent.activeObj)===JSON.stringify(this.parent.objColl[s])){i=!0;break}if(!i){e.isNullOrUndefined(this.parent.activeObj.currIndex)&&(this.parent.activeObj.currIndex="shape_"+(this.parent.objColl.length+1)),this.updImgRatioForActObj();var a=this.parent.activeObj.currIndex.split("_"),n=this.parent.objColl.splice(0,parseInt(a[1],10)-1);n.push(e.extend({},this.parent.activeObj,{},!0));for(var s=0;s<this.parent.objColl.length;s++)n.push(this.parent.objColl[s]);this.parent.objColl=n,n=[],this.refreshActiveObj(),this.lowerContext.clearRect(0,0,this.parent.lowerCanvas.width,this.parent.lowerCanvas.height),this.parent.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.parent.currObjType.shape="",this.refreshActiveObj(),this.parent.isCircleCrop&&this.parent.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),e.isBlazor()?this.parent.updateToolbar(this.parent.element,"destroyQuickAccessToolbar"):this.parent.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),e.isNullOrUndefined(t)&&(this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.parent.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}))}}}},i.prototype.alignTextAreaIntoCanvas=function(){var t=this.parent,e=t.textArea.value;t.textArea.value="";for(var i=0,o=e.length;i<o;i++)t.textArea.value+=e[i],t.textArea.style.height="auto",t.textArea.style.height=t.textArea.scrollHeight+"px",this.setTextBoxWidth()},i.prototype.transformTextArea=function(){var t=this.parent;if("text"===t.activeObj.shape){t.textArea.style.transformOrigin="0 0";var e=t.activeObj.rotatedAngle*(180/Math.PI),i="",o=this.getRotDegOfShape(t.activeObj);if(t.activeObj.flipObjColl.length>0)for(var r=0;r<t.activeObj.flipObjColl.length;r++)i+=0!==o&&o%90==0&&180!==o?"horizontal"===t.activeObj.flipObjColl[r].toLowerCase()?"scale(1, -1)":"scale(-1, 1)":"horizontal"===t.activeObj.flipObjColl[r].toLowerCase()?"scale(-1, 1)":"scale(1, -1)",o+=e,"horizontal"===t.activeObj.flipObjColl[r].toLowerCase()?t.textArea.style.transform="rotate("+o+"deg)"+i:"vertical"===t.activeObj.flipObjColl[r].toLowerCase()&&(t.textArea.style.transform="rotate("+o+"deg)"+i);else o+=e,t.textArea.style.transform="rotate("+o+"deg)"}},i.prototype.getTextAreaWidth=function(t){var e=this.parent,i=e.activeObj.textSettings.bold,o=e.activeObj.textSettings.italic;switch(t){case"default":e.activeObj.textSettings.bold=!1,e.activeObj.textSettings.italic=!1;break;case"bold":e.activeObj.textSettings.bold=!0,e.activeObj.textSettings.italic=!1;break;case"italic":e.activeObj.textSettings.bold=!1,e.activeObj.textSettings.italic=!0;break;case"bolditalic":e.activeObj.textSettings.bold=!0,e.activeObj.textSettings.italic=!0}this.updateFontStyles();var r;return r="none"===e.textArea.style.display?this.upperContext.measureText(e.activeObj.keyHistory).width+.5*e.activeObj.textSettings.fontSize:this.upperContext.measureText(e.textArea.value).width+.5*e.activeObj.textSettings.fontSize,e.activeObj.textSettings.bold=i,e.activeObj.textSettings.italic=o,r},i.prototype.getObjDetails=function(t){var e=this.parent,i={};switch(i.id=t.currIndex,i.type=e.toPascalCase(t.shape),i.startX=t.activePoint.startX,i.startY=t.activePoint.startY,t.shape){case"rectangle":i.width=t.activePoint.width,i.height=t.activePoint.height,i.strokeColor=t.strokeSettings.strokeColor,i.fillColor=t.strokeSettings.fillColor,i.strokeWidth=t.strokeSettings.strokeWidth;break;case"ellipse":i.radius=t.activePoint.width/2,i.strokeColor=t.strokeSettings.strokeColor,i.fillColor=t.strokeSettings.fillColor,i.strokeWidth=t.strokeSettings.strokeWidth;break;case"line":case"arrow":i.length=t.activePoint.width,i.strokeColor=t.strokeSettings.strokeColor,i.strokeWidth=t.strokeSettings.strokeWidth;break;case"text":i.text=t.keyHistory,i.fontSize=t.textSettings.fontSize,i.color=t.strokeSettings.strokeColor,i.fontStyle=[],t.textSettings.bold&&i.fontStyle.push("bold"),t.textSettings.italic&&i.fontStyle.push("italic");break;case"path":i.strokeColor=t.strokeSettings.strokeColor,i.strokeWidth=t.strokeSettings.strokeWidth}return i},i.prototype.getFreehandDrawDetails=function(i){var o=this.parent,r={};return r.id=o.pointColl[i].id,r.type=t.ShapeType.FreehandDraw,r.points=e.extend([],o.pointColl[i].points),r.strokeColor=o.pointColl[i].strokeColor,r.strokeWidth=o.pointColl[i].strokeWidth,r},i.prototype.getShapeSetting=function(t,i){var o,r=this.parent;if(!r.disabled&&r.isImageLoaded)if(this.applyActObj(),"shape"===t.split("_")[0]){for(var a,n=0,s=r.objColl.length;n<s;n++)if(r.objColl[n].currIndex===t){a=e.extend({},r.objColl[n],{},!0);break}o=this.getObjDetails(a)}else"pen"===t.split("_")[0]&&(o=this.getFreehandDrawDetails(parseInt(t.split("_")[1],10)-1));i.shapeDetails=o},i.prototype.getShapeSettings=function(t){var e=this.parent,i=[];if(!e.disabled&&e.isImageLoaded){this.applyActObj();for(var o=0,r=e.objColl.length;o<r;o++){a=this.getObjDetails(e.objColl[o]);i.push(a)}for(o=0;o<e.freehandCounter;o++){var a=this.getFreehandDrawDetails(o);i.push(a)}}t.shapeDetailsColl=i},i.prototype.isPointsInRange=function(t,i,o){var r=!1;!e.isNullOrUndefined(t)&&!e.isNullOrUndefined(i)&&t>=this.parent.img.destLeft&&i>=this.parent.img.destTop&&t<=this.parent.img.destLeft+this.parent.img.destWidth&&i<=this.parent.img.destTop+this.parent.img.destHeight&&(r=!0),o.inRange=r},i.prototype.alignRotateFlipColl=function(t,e,i){return t=this.popForDefaultTransformedState(t),t=this.popForDefaultFlipState(t),0===(t=this.popForDefaultRotateState(t)).length&&e&&(this.parent.transform.degree=0,this.parent.transform.currFlipState=""),i.collection=t,t},i.prototype.popForDefaultTransformedState=function(t){for(var e=0,i=0,o=0,r=0,a=0;a<t.length;a++)90===t[a]||"rotateRight"===t[a]?(i=0,o=0,r=0,4===++e&&(t.pop(),t.pop(),t.pop(),t.pop())):-90===t[a]||"rotateLeft"===t[a]?(e=0,o=0,r=0,4===++i&&(t.pop(),t.pop(),t.pop(),t.pop())):"horizontal"===t[a]||"Horizontal"===t[a]||"horizontalflip"===t[a]?(i=0,e=0,r=0,2===++o&&(t.pop(),t.pop())):"vertical"!==t[a]&&"Vertical"!==t[a]&&"verticalflip"!==t[a]||(o=0,i=0,e=0,2===++r&&(t.pop(),t.pop()));return t},i.prototype.popForDefaultFlipState=function(t){for(var i=0;i<t.length;i++)e.isNullOrUndefined(t[i+3])||("horizontal"!==t[i]&&"Horizontal"!==t[i]&&"horizontalFlip"!==t[i]||"vertical"!==t[i+1]&&"Vertical"!==t[i+1]&&"verticalFlip"!==t[i]||"horizontal"!==t[i+2]&&"Horizontal"!==t[i+2]&&"horizontalFlip"!==t[i]||"vertical"!==t[i+3]&&"Vertical"!==t[i+3]&&"verticalFlip"!==t[i]?"vertical"!==t[i]&&"Vertical"!==t[i]&&"verticalFlip"!==t[i]||"horizontal"!==t[i+1]&&"Horizontal"!==t[i+1]&&"horizontalFlip"!==t[i+1]||"vertical"!==t[i+2]&&"Vertical"!==t[i+2]&&"verticalFlip"!==t[i]||"horizontal"!==t[i+3]&&"Horizontal"!==t[i+3]&&"horizontalFlip"!==t[i]||(t.pop(),t.pop(),t.pop(),t.pop()):(t.pop(),t.pop(),t.pop(),t.pop()));return t},i.prototype.popForDefaultRotateState=function(t){for(var i=0;i<t.length;i++)e.isNullOrUndefined(t[i+1])||(90!==t[i]&&"rotateRight"!==t[i]||-90!==t[i+1]&&"rotateLeft"!==t[i]?-90!==t[i]&&"rotateLeft"!==t[i]||90!==t[i+1]&&"rotateRight"!==t[i]||(t.pop(),t.pop()):(t.pop(),t.pop()));return t},i.prototype.selectShape=function(t,i){var o=this.parent,r=!1;if(!o.disabled&&o.isImageLoaded)if(this.applyActObj(),"shape"===t.split("_")[0]){for(var a,n=0,s=o.objColl.length;n<s;n++)if(o.objColl[n].currIndex===t){a=e.extend({},o.objColl[n],{},!0);break}if(e.isNullOrUndefined(a))r=!1;else{r=!0,o.activeObj=a;l={canvasFilter:null};o.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:l}}),this.lowerContext.filter=l.canvasFilter,o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.activeObj}}),e.isBlazor()?(o.updateToolbar(o.element,o.activeObj.shape),"path"===o.activeObj.shape?o.updateToolbar(this.parent.element,"path","pathQuickAccessToolbar"):o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape)):("text"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):"pen"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))}}else if("pen"===t.split("_")[0]){var l={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:l}}),l.bool&&o.okBtn();var p={isIndex:!1};o.notify("freehand-draw",{prop:"isFHDIdx",value:{index:parseInt(t.split("_")[1],10)-1,obj:p}}),p.isIndex?(r=!0,o.notify("freehand-draw",{prop:"selectFhd",value:{id:t}}),e.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):(o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))):r=!1}i.isSelected=r},i.prototype.deleteShape=function(t){var i=this.parent;if(!i.disabled&&i.isImageLoaded){if(this.applyActObj(),"shape"===t.split("_")[0]){for(var o=0,r=i.objColl.length;o<r;o++)if(i.objColl[o].currIndex===t){i.objColl.splice(o,1);break}}else"pen"===t.split("_")[0]&&i.notify("freehand-draw",{prop:"handle-freehand-draw",value:{id:t}});var a={canvasFilter:null};i.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:a}}),this.lowerContext.filter=a.canvasFilter,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),e.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},i.prototype.getMaxText=function(t,i,o){e.isNullOrUndefined(i)&&(i=t?this.parent.textArea.value:this.parent.activeObj.keyHistory);for(var r,a=i.split("\n"),n=a[0].length,s=a[0],l=1;l<a.length;l++)(r=a[l].length)>n&&(s=a[l],n=r);return o&&(o.maxText=s),s},i.prototype.getLinePoints=function(t,i,o,r){var a,n,s=[];if(t===o){i<r?(a=[t,i],n=[o,r]):(n=[t,i],a=[o,r]);for(var l=this.getSlope(a,n,!0),p=this.getIntercept(a,l),h=a[1];h<=n[1];h++){c=l*h+p;s.push({x:c,y:h})}}else{t<o?(a=[t,i],n=[o,r]):(n=[t,i],a=[o,r]);for(var l=this.getSlope(a,n,!1),p=this.getIntercept(a,l),c=a[0];c<=n[0];c++){h=l*c+p;s.push({x:c,y:h})}}if(Math.floor(t)===Math.floor(o)||s.length<10&&(r-i>10||i-r>10)){s=[];for(var d=Math.min(i,r),v=0;v<Math.abs(Math.floor(r)-Math.floor(i));v++)s.push({x:t,y:d+v});if(s.length>1){f=void 0;f=e.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];var u=s[s.length-1].x-f.x,g=s[s.length-1].y-f.y;s.push({x:s[s.length-1].x+u/2,y:s[s.length-1].y+g/2})}}else if(Math.floor(i)===Math.floor(r)||s.length<10&&(o-t>10||t-o>10)){s=[];for(var b=Math.min(t,o),C=0;C<Math.abs(Math.floor(o)-Math.floor(t));C++)s.push({x:b+C,y:i});if(s.length>1){var f=void 0;f=e.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];var u=s[s.length-1].x-f.x,g=s[s.length-1].y-f.y;s.push({x:s[s.length-1].x+u/2,y:s[s.length-1].y+g/2})}}return s},i.prototype.getSlope=function(t,e,i){var o;if(i){if(t[1]===e[1])return null;o=(e[0]-t[0])/(e[1]-t[1])}else{if(t[0]===e[0])return null;o=(e[1]-t[1])/(e[0]-t[0])}return o},i.prototype.getIntercept=function(t,e){return null===e?t[0]:t[1]-e*t[0]},i.prototype.setPointCollForShapeRotation=function(t){var e={x:t.activePoint.startX+t.activePoint.width/2,y:t.activePoint.startY+t.activePoint.height/2},i={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.y},o={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-e.y)+e.y},r={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.y},a={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-e.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-e.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-e.y)+e.y};t.horTopLinePointColl=this.getLinePoints(i.x,i.y,o.x,o.y),t.horBottomLinePointColl=this.getLinePoints(r.x,r.y,a.x,a.y),t.verLeftLinePointColl=this.getLinePoints(i.x,i.y,r.x,r.y),t.verRightLinePointColl=this.getLinePoints(o.x,o.y,a.x,a.y),t.verLeftLinePointColl.reverse(),t.verRightLinePointColl.reverse();for(n=0;n<t.horTopLinePointColl.length;n++)t.horTopLinePointColl[n].ratioX=(t.horTopLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.horTopLinePointColl[n].ratioY=(t.horTopLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;for(n=0;n<t.horBottomLinePointColl.length;n++)t.horBottomLinePointColl[n].ratioX=(t.horBottomLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.horBottomLinePointColl[n].ratioY=(t.horBottomLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;for(n=0;n<t.verLeftLinePointColl.length;n++)t.verLeftLinePointColl[n].ratioX=(t.verLeftLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.verLeftLinePointColl[n].ratioY=(t.verLeftLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;for(var n=0;n<t.verRightLinePointColl.length;n++)t.verRightLinePointColl[n].ratioX=(t.verRightLinePointColl[n].x-this.parent.img.destLeft)/this.parent.img.destWidth,t.verRightLinePointColl[n].ratioY=(t.verRightLinePointColl[n].y-this.parent.img.destTop)/this.parent.img.destHeight;if("move"!==this.parent.upperCanvas.style.cursor){var s={rotationCirclePoint:null};this.parent.notify("selection",{prop:"getTransRotationPoint",value:{obj:t,object:s}});var l=s.rotationCirclePoint;l&&(t.rotationCirclePointColl={x:Math.cos(t.rotatedAngle)*(l.x-e.x)-Math.sin(t.rotatedAngle)*(l.y-e.y)+e.x,y:Math.sin(t.rotatedAngle)*(l.x-e.x)+Math.cos(t.rotatedAngle)*(l.y-e.y)+e.y},t.rotationCirclePointColl.ratioX=(t.rotationCirclePointColl.x-this.parent.img.destLeft)/this.parent.img.destWidth,t.rotationCirclePointColl.ratioY=(t.rotationCirclePointColl.y-this.parent.img.destTop)/this.parent.img.destHeight)}},i.prototype.getSquarePointForRotatedShape=function(t,e){var i={startX:0,startY:0,endX:0,endY:0,width:0,height:0},o={x:t.activePoint.startX+t.activePoint.width/2,y:t.activePoint.startY+t.activePoint.height/2},r={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.y},a={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.startY-o.y)+o.y},n={x:Math.cos(t.rotatedAngle)*(t.activePoint.startX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.startX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.y},s={x:Math.cos(t.rotatedAngle)*(t.activePoint.endX-o.x)-Math.sin(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.x,y:Math.sin(t.rotatedAngle)*(t.activePoint.endX-o.x)+Math.cos(t.rotatedAngle)*(t.activePoint.endY-o.y)+o.y};return i.startX=r.x,i.startY=r.y,i.endX=r.x,i.endY=r.y,i.startX>a.x&&(i.startX=a.x),i.startX>n.x&&(i.startX=n.x),i.startX>s.x&&(i.startX=s.x),i.startY>a.y&&(i.startY=a.y),i.startY>n.y&&(i.startY=n.y),i.startY>s.y&&(i.startY=s.y),i.endX<a.x&&(i.endX=a.x),i.endX<n.x&&(i.endX=n.x),i.endX<s.x&&(i.endX=s.x),i.endY<a.y&&(i.endY=a.y),i.endY<n.y&&(i.endY=n.y),i.endY<s.y&&(i.endY=s.y),i.width=i.endX-i.startX,i.height=i.endY-i.startY,e&&(e.activePoint=i),i},i}(),v=function(){function o(t){this.isReverseFlip=!1,this.disablePan=!1,this.isReverseRotate=!1,this.flipColl=[],this.prevZoomValue=1,this.cropDimension={width:0,height:0},this.isPreventSelect=!1,this.parent=t,this.addEventListener()}return o.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},o.prototype.addEventListener=function(){this.parent.on("transform",this.transform,this),this.parent.on("destroyed",this.destroy,this)},o.prototype.removeEventListener=function(){this.parent.off("transform",this.transform),this.parent.off("destroyed",this.destroy)},o.prototype.transform=function(t){switch(this.initTransformPvtVar(),t.prop){case"rotateImage":this.rotateImage(t.value.degree);break;case"flipImage":this.flipImage(t.value.direction);break;case"setDestPointsForFlipState":this.setDestPointsForFlipState();break;case"zoomAction":this.zoomAction(t.value.zoomFactor,t.value.zoomPoint);break;case"disableZoomOutBtn":this.disableZoomOutBtn(t.value.isZoomOut);break;case"rotatedFlip":this.rotatedFlip();break;case"drawPannedImage":this.drawPannedImage(t.value.xDiff,t.value.yDiff);break;case"drawPannImage":this.drawPannImage(t.value.point);break;case"performTransformation":this.performTransformation(t.value.text);break;case"updateTransform":this.updateTransform(t.value.text);break;case"rotatePan":this.rotatePan(t.value.isCropSelection,t.value.isDefaultZoom);break;case"drawRotatedImage":this.drawRotatedImage(t.value.degree);break;case"limitPan":this.limitPan();break;case"updateFlipActiveObj":this.updateFlipActiveObj(t.value.panRegion);break;case"resetZoom":this.resetZoom();break;case"pan":this.pan(t.value.value);break;case"zoom":this.zoom(t.value.zoomFactor,t.value.zoomPoint);break;case"setCurrPanRegion":this.setCurrPanRegion(t.value.region,t.value.type,t.value.obj);break;case"rotate":this.rotate(t.value.degree,t.value.obj);break;case"flip":this.flip(t.value.direction);break;case"update":this.update();break;case"calcMaxDimension":this.calcMaxDimension(t.value.width,t.value.height,t.value.obj);break;case"updatePanPoints":this.updatePanPoints(t.value.panRegion,t.value.obj);break;case"getPanMove":t.value.obj.panMove=this.panMove;break;case"setPanMove":this.panMove=t.value.point;break;case"getTempPanMove":t.value.obj.tempPanMove=this.tempPanMove;break;case"setTempPanMove":this.tempPanMove=t.value.point;break;case"setReverseFlip":this.isReverseFlip=t.value.isReverseFlip;break;case"setDisablePan":this.disablePan=t.value.bool;break;case"setCurrDestinationPoint":this.currDestPoint=t.value.point,this.currDestPoint.startX-=this.parent.cropObj.totalPannedPoint.x,this.currDestPoint.startY-=this.parent.cropObj.totalPannedPoint.y;break;case"setReverseRotate":this.isReverseRotate=t.value.bool;break;case"getFlipColl":t.value.obj.flipColl=this.flipColl;break;case"setFlipColl":this.flipColl=t.value.flipColl;break;case"getPreviousZoomValue":t.value.obj.previousZoomValue=this.prevZoomValue;break;case"setPreviousZoomValue":this.prevZoomValue=t.value.previousZoomValue;break;case"getCropDimension":t.value.obj.cropDimension=this.cropDimension;break;case"setCropDimension":this.cropDimension.width=t.value.width,this.cropDimension.height=t.value.height;break;case"getPreventSelect":t.value.obj.bool=this.isPreventSelect;break;case"setPreventSelect":this.isPreventSelect=t.value.bool;break;case"reset":this.reset()}},o.prototype.getModuleName=function(){return"transform"},o.prototype.initTransformPvtVar=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},o.prototype.reset=function(){this.zoomBtnHold=null,this.tempPanMove=null,this.panMove=null,this.disablePan=!1,this.currDestPoint=null,this.isReverseRotate=!1,this.flipColl=[],this.transCurrObj=null,this.prevZoomValue=1,this.isPreventSelect=!1},o.prototype.rotateImage=function(t){var i=this,o=this.parent,r={cancel:!1,previousDegree:o.transform.degree,currentDegree:360===Math.abs(o.transform.degree+t)?0:o.transform.degree+t};!this.isPreventSelect&&e.isBlazor()&&o.events&&!0===o.events.rotating.hasDelegate?o.dotNetRef.invokeMethodAsync("RotateEventAsync","OnRotate",r).then(function(e){i.rotateEvent(e,t)}):(this.isPreventSelect||o.trigger("rotating",r),this.rotateEvent(r,t))},o.prototype.rotateEvent=function(t,i){var o=this.parent;if(!t.cancel){var r=void 0;if(e.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=e.extend([],o.objColl,null,!0),r.pointColl=e.extend({},o.pointColl,null,!0),r.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=e.extend([],n.selPointColl,[],!0)}o.afterCropActions.push(90===i?"rotateRight":"rotateLeft");var s=[],l=void 0;o.activeObj.activePoint&&o.activeObj.shape&&(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===s[0])&&(l=o.currObjType.isCustomCrop?"custom":s[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.drawRotatedImage(i),o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),l&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=e.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})),o.isUndoRedo=!1;var p={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:p}}),o.rotateFlipColl=p.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.select("custom"),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.drawRotatedImage=function(t){var i=this.parent;0===t?i.transform.degree=0:i.transform.degree+=t,360===Math.abs(i.transform.degree)&&(i.transform.degree=0),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var o=e.extend([],i.objColl,[],!0),r=e.extend({},i.activeObj,{},!0);if(i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseRotate||i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.rotateDegree(t),this.isReverseRotate||(i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.rotateFlipColl.push(t)),i.objColl=e.extend([],o,[],!0),i.activeObj=e.extend({},r,{},!0),i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:t}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t>0)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});else for(var a=0;a<3;a++)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.updateCurrSelectionPoint(t)},o.prototype.rotateDegree=function(t){var e=this.parent;this.lowerContext.save(),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.lowerContext.translate(e.lowerCanvas.width/2,e.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*t),this.lowerContext.translate(-e.lowerCanvas.width/2,-e.lowerCanvas.height/2);var i=this.lowerContext.filter;this.parent.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(this.parent.baseImg,this.parent.img.srcLeft,this.parent.img.srcTop,this.parent.img.srcWidth,this.parent.img.srcHeight,this.parent.img.destLeft,this.parent.img.destTop,this.parent.img.destWidth,this.parent.img.destHeight),this.lowerContext.filter=i,this.lowerContext.translate(e.lowerCanvas.width/2,e.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*-t),this.lowerContext.translate(-e.lowerCanvas.width/2,-e.lowerCanvas.height/2),this.lowerContext.restore()},o.prototype.updateCurrSelectionPoint=function(t){var i=this.parent;if(i.currSelectionPoint&&this.currDestPoint){var o=e.extend({},i.activeObj,{},!0),r=e.extend([],i.objColl,[],!0),a={startX:i.img.srcLeft,startY:i.img.srcTop,width:i.img.srcWidth,height:i.img.srcHeight},n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.objColl=[],i.objColl.push(e.extend({},i.currSelectionPoint,{},!0)),e.isNullOrUndefined(i.objColl[0].imageRatio)&&(i.activeObj=i.objColl[0],i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),i.objColl[0]=i.activeObj),i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImg.width,i.img.srcHeight=i.baseImg.height,i.img.destLeft=this.currDestPoint.startX,i.img.destTop=this.currDestPoint.startY,i.img.destWidth=this.currDestPoint.width,i.img.destHeight=this.currDestPoint.height,"number"==typeof t&&(i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}})),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:t}}),i.currSelectionPoint=e.extend({},i.objColl[0],{},!0),this.currDestPoint={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight},i.objColl=r,i.activeObj=o,i.img.srcLeft=a.startX,i.img.srcTop=a.startY,i.img.srcWidth=a.width,i.img.srcHeight=a.height,i.img.destLeft=n.startX,i.img.destTop=n.startY,i.img.destWidth=n.width,i.img.destHeight=n.height}},o.prototype.flipImage=function(t){var i=this,o=this.parent,r={direction:t,cancel:!1,previousDirection:o.toPascalCase(o.transform.currFlipState)};!this.isPreventSelect&&e.isBlazor()&&o.events&&!0===o.events.flipping.hasDelegate?o.dotNetRef.invokeMethodAsync("FlipEventAsync","OnFlip",r).then(function(e){i.flipEvent(e,t)}):(this.isPreventSelect||o.trigger("flipping",r),this.flipEvent(r,t))},o.prototype.flipEvent=function(t,i){var o=this.parent;if(!t.cancel){var r;if(e.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=e.extend([],o.objColl,null,!0),r.pointColl=e.extend({},o.pointColl,null,!0),r.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=e.extend([],n.selPointColl,[],!0)}o.afterCropActions.push("horizontal"===i.toLowerCase()?"horizontalflip":"verticalflip");var s,l=[];o.activeObj.activePoint&&(void 0!==o.activeObj.shape&&(l=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===l[0])&&(s=o.currObjType.isCustomCrop?"custom":l[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.clearContext(this.lowerContext),o.clearContext(this.upperContext);var p=e.extend([],o.objColl,[],!0),h=e.extend({},o.activeObj,{},!0);o.objColl=[],o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseFlip||o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var c=i.toLowerCase();this.updateFlipState(c),o.transform.currFlipState="horizontal"===c?"horizontal"===o.transform.currFlipState.toLowerCase()?"":"horizontal":"vertical"===o.transform.currFlipState.toLowerCase()?"":"vertical";var d={isSelected:null};o.notify("draw",{prop:"getRotatedFlipCropSelection",onPropertyChange:!1,value:{bool:d}}),d.isSelected&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y);var v=this.lowerContext.filter;if(o.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(o.baseImg,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,o.img.destLeft,o.img.destTop,o.img.destWidth,o.img.destHeight),this.lowerContext.filter=v,o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.updateFlipState(i.toLowerCase()),this.isReverseFlip||(o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),this.updateFlipColl(i.toLocaleLowerCase()),o.rotateFlipColl.push(i.toLowerCase())),1===o.rotateFlipColl.length){var u={panRegion:""};o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:u}}),""===u.panRegion?o.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}}):this.setDestPointsForFlipState()}o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.objColl=e.extend([],p,[],!0),o.activeObj=e.extend({},h,{},!0);for(var g=0,b=o.objColl.length;g<b;g++){var C=o.objColl[g].flipObjColl;0===C.length?C.push(i):C[C.length-1]===i?C.pop():C.push(i)}o.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:i.toLowerCase()}});var f=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),"horizontal"===i.toLowerCase()||"vertical"===i.toLowerCase()?(o.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:i.toLowerCase()}}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}})):o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=f,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.updateCurrSelectionPoint(i.toLowerCase()),o.isUndoRedo=!1,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),s&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=e.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}));var m={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:m}}),o.rotateFlipColl=m.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.select("custom"),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.updateFlipState=function(t){var e=this.parent.transform.degree;"horizontal"===t?e%90==0&&e%180!=0?this.verticalFlip():this.horizontalFlip():"vertical"===t&&(e%90==0&&e%180!=0?this.horizontalFlip():this.verticalFlip())},o.prototype.horizontalFlip=function(){this.lowerContext.translate(this.lowerContext.canvas.width,0),this.lowerContext.scale(-1,1),this.upperContext.translate(this.upperContext.canvas.width,0),this.upperContext.scale(-1,1)},o.prototype.verticalFlip=function(){this.lowerContext.translate(0,this.lowerContext.canvas.height),this.lowerContext.scale(1,-1),this.upperContext.translate(0,this.upperContext.canvas.height),this.upperContext.scale(1,-1)},o.prototype.updateFlipColl=function(t){if(!this.isPreventSelect&&(0===this.flipColl.length||this.flipColl[this.flipColl.length-1]!==t?this.flipColl.push(t):this.flipColl.pop(),this.flipColl.length>=4)){var e=this.flipColl.slice(-4);("horizontal"===e[0]&&"vertical"===e[1]&&"horizontal"===e[2]&&"vertical"===e[3]||"vertical"===e[0]&&"horizontal"===e[1]&&"vertical"===e[2]&&"horizontal"===e[3])&&this.flipColl.splice(-4)}},o.prototype.setDestPointsForFlipState=function(){var t=this.parent,e={panRegion:""};t.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:e}}),""!==e.panRegion&&("horizontal"===e.panRegion?t.img.destLeft=t.lowerCanvas.clientWidth-(t.img.destWidth+t.img.destLeft):"vertical"===e.panRegion?t.img.destTop=t.lowerCanvas.clientHeight-(t.img.destHeight+t.img.destTop):(t.img.destLeft=t.lowerCanvas.clientWidth-(t.img.destWidth+t.img.destLeft),t.img.destTop=t.lowerCanvas.clientHeight-(t.img.destHeight+t.img.destTop)))},o.prototype.zoomAction=function(t,i){var o=this,r=this.parent;if(!r.disabled&&r.isImageLoaded){if(r.zoomSettings.zoomFactor>=r.zoomSettings.maxZoomFactor&&t>0||r.zoomSettings.zoomFactor>r.zoomSettings.minZoomFactor&&t<0&&this.disableZoomOutBtn(!0)||r.zoomSettings.zoomFactor<=r.zoomSettings.minZoomFactor&&t<0)return void(e.isBlazor()||r.notify("toolbar",{prop:"zoom-up-handler",onPropertyChange:!1}));r.notify("draw",{prop:"setImageEdited",onPropertyChange:!1});var a=t;t=a>0?.1:-.1;for(var n=0;n<Math.abs(a/.1);n++)if(1===this.prevZoomValue)this.prevZoomValue+=t>0?10*t:10*t/10;else if(this.prevZoomValue>1)this.prevZoomValue+=10*t;else if(this.prevZoomValue<1){this.prevZoomValue+=10*t/10;var s=Math.pow(10,1);this.prevZoomValue=Math.round(this.prevZoomValue*s)/s}t=a,r.setProperties({zoomSettings:{zoomFactor:this.prevZoomValue}},!0);var l=void 0;this.tempActiveObj=null,this.isShape=!1,void 0!==r.activeObj.shape&&("shape"===r.activeObj.shape?r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}):l=r.activeObj.shape.split("-")),void 0!==l&&"crop"===l[0]?(this.tempActiveObj=e.extend({},r.activeObj,{},!0),r.isCropTab=!0):r.activeObj.shape&&"crop"!==l[0]&&(this.isShape=!0);var p={zoomType:null};r.notify("selection",{prop:"getZoomType",onPropertyChange:!1,value:{obj:p}}),e.isNullOrUndefined(i)&&(i=r.isCropTab&&this.tempActiveObj?{x:r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2,y:r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2}:{x:r.lowerCanvas.clientWidth/2,y:r.lowerCanvas.clientHeight/2},"MouseWheel"!==p.zoomType&&"Pinch"!==p.zoomType||(i={x:r.zoomSettings.zoomPoint.x,y:r.zoomSettings.zoomPoint.y}));var h={zoomPoint:i,cancel:!1,previousZoomFactor:r.zoomSettings.zoomFactor-10*t,currentZoomFactor:r.zoomSettings.zoomFactor,zoomTrigger:p.zoomType};!r.isCropToolbar&&e.isBlazor()&&r.events&&!0===r.events.zooming.hasDelegate?r.dotNetRef.invokeMethodAsync("ZoomEventAsync","OnZoom",h).then(function(e){o.zoomEvent(e,t)}):(r.isCropToolbar||r.trigger("zooming",h),this.zoomEvent(h,t))}},o.prototype.zoomEvent=function(t,i){var o=this.parent;if(!t.cancel){e.isBlazor()?o.element.querySelector(".e-contextual-toolbar-wrapper")&&!o.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hidden")&&o.updateToolbar(o.element,"closeContextualToolbar"):o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var r={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=r.canvasFilter,o.upperCanvas.style.cursor=o.cursor="default";var a=e.extend([],o.objColl,[],!0);if(o.isCropTab||(0!==o.transform.degree?(o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.panPoint.currentPannedPoint={x:0,y:0},this.rotatePan(!0,!0)):""!==o.transform.currFlipState&&(o.panPoint.totalPannedPoint={x:0,y:0}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})),0===o.transform.degree){this.drawZoomImgToCanvas(i,this.tempActiveObj);var n={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:n}}),""!==n.panRegion){o.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:o.panPoint.totalPannedPoint,isAdd:!0}}),a=e.extend([],o.objColl,[],!0),o.objColl=[];var s=o.img.destLeft,l=o.img.destTop;this.setDestPointsForFlipState(),this.rotatedFlip(),o.img.destLeft=s,o.img.destTop=l,o.objColl=a,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})}o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&!o.isCropTab&&(o.panPoint.totalPannedPoint={x:0,y:0})}else{o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),o.panPoint.totalPannedClientPoint={x:0,y:0},o.panPoint.totalPannedInternalPoint={x:0,y:0},this.rotateZoom(i);var p={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:p}}),""!==p.panRegion){d=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=d}}var h=Math.pow(10,1);(o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor||Math.round(o.transform.zoomFactor*h)/h==2)&&(clearInterval(this.zoomBtnHold),this.zoomBtnHold=0);var c={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:c}}),""===c.panRegion){var d=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=d}(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.tempActiveObj&&(o.activeObj=e.extend({},this.tempActiveObj,{},!0),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}),o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&(o.currSelectionPoint=null)),o.isUndoRedo=!1;var v;e.isBlazor()?(v=o.element.querySelector("#zoomout"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?v.classList.add("e-overlay"):v&&v.classList.remove("e-overlay"):(v=document.querySelector("#"+o.element.id+"_zoomOut"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?(v.classList.add("e-disabled"),v.parentElement.classList.add("e-overlay")):v&&(v.classList.remove("e-disabled"),v.parentElement.classList.remove("e-overlay")),this.autoEnablePan(),this.tempActiveObj&&(o.activeObj=e.extend({},this.tempActiveObj,{},!0)),"crop-custom"===o.activeObj.shape&&(o.currObjType.isCustomCrop=!0);var u=o.element.querySelector(".e-img-pan .e-btn");u&&o.togglePan?u.classList.add("e-selected-btn"):u&&u.classList.remove("e-selected-btn"),this.isShape&&(o.activeObj=e.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),e.isBlazor()||(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),e.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}),o.notify("selection",{prop:"setZoomType",onPropertyChange:!1,value:{zoomType:"Toolbar"}})}},o.prototype.disableZoomOutBtn=function(t){var i,o=this.parent,r=!1;e.isNullOrUndefined(t)||(o.transform.zoomFactor-=.1),i=e.isBlazor()?this.parent.element.querySelector("#zoomout"):document.querySelector("#"+o.element.id+"_zoomOut");var a=o.img.destLeft,n=o.img.destTop,s=o.img.destWidth,l=o.img.destHeight;return o.activeObj.shape?(this.setZoomDimension(-.1,o.activeObj),e.isNullOrUndefined(i)||(o.img.destLeft>o.activeObj.activePoint.startX||o.img.destTop>o.activeObj.activePoint.startY||o.img.destLeft+o.img.destWidth<o.activeObj.activePoint.endX||o.img.destTop+o.img.destHeight<o.activeObj.activePoint.endY||o.zoomSettings.zoomFactor===o.zoomSettings.minZoomFactor?(e.isBlazor()?i.classList.add("e-overlay"):(i.classList.add("e-disabled"),i.parentElement.classList.add("e-overlay")),r=!0):(e.isBlazor()?i.classList.remove("e-overlay"):(i.classList.remove("e-disabled"),i.parentElement.classList.remove("e-overlay")),r=!1))):this.setZoomDimension(-.1,null),e.isNullOrUndefined(t)||(o.transform.zoomFactor+=.1),o.img.destLeft=a,o.img.destTop=n,o.img.destWidth=s,o.img.destHeight=l,r},o.prototype.drawZoomImgToCanvas=function(t,e){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===t?i.transform.zoomFactor=0:i.transform.zoomFactor+=t,i.transform[i.isCropTab?"cropZoomFactor":"defaultZoomFactor"]=i.transform.zoomFactor;var r={width:0,height:0};i.isCropTab?r=this.cropZoom(t,e):((r=this.calcMaxDimension(i.img.srcWidth,i.img.srcHeight)).width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.img.destLeft=(i.lowerCanvas.clientWidth-r.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-r.height)/2),i.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:r}}),r.width=this.cropDimension.width,r.height=this.cropDimension.height,r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:r.width,height:r.height}})},o.prototype.rotatedFlip=function(){var t=this.parent;this.isReverseFlip=!0;var i=t.transform.currFlipState,o=this.flipColl,r=e.extend([],t.objColl,[],!0),a=e.extend({},t.activeObj,{},!0);this.flipColl=[],t.objColl=[],t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}});var n=this.lowerContext.filter;t.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=n,t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,context:null,isPreventCircleCrop:null}}),""===i&&""!==t.transform.currFlipState&&(i=t.transform.currFlipState),t.transform.currFlipState=i,this.flipColl=o,t.objColl=e.extend([],r,[],!0),this.lowerContext.filter="none",t.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=n,0!==a.activePoint.width&&(t.activeObj=e.extend({},a,{},!0)),this.isReverseFlip=!1},o.prototype.rotateZoom=function(t){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===t?i.transform.zoomFactor=0:i.transform.zoomFactor+=t,i.isCropTab?i.transform.cropZoomFactor=i.transform.zoomFactor:i.transform.defaultZoomFactor=i.transform.zoomFactor;var r=e.extend([],i.objColl,[],!0),a=e.extend({},i.activeObj,{},!0);i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var n=this.lowerContext.filter;i.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(i.baseImg,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,i.img.destLeft,i.img.destTop,i.img.destWidth,i.img.destHeight),this.lowerContext.filter=n,i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.objColl=r,i.activeObj=a;var s={width:this.cropDimension.width,height:this.cropDimension.height};s.width+=s.width*i.transform.zoomFactor,s.height+=s.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:s.width,height:s.height}})},o.prototype.autoEnablePan=function(){this.parent.transform.zoomFactor<=0?(this.parent.togglePan=!1,this.parent.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),this.parent.pan(!1),this.disablePan=!1):this.parent.pan(!this.disablePan)},o.prototype.cropZoom=function(t,i){var o=this.parent,r=o.img.destLeft,a=o.img.destTop,n={width:0,height:0};return 0===o.img.srcLeft||0===o.img.srcTop?n=e.isNullOrUndefined(i)?this.setZoomDimension(t,null):this.setZoomDimension(t,i):((n=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight)).width+=n.width*o.transform.zoomFactor,n.height+=n.height*o.transform.zoomFactor),o.img.destLeft=r-(n.width-o.img.destWidth)/2,o.img.destTop=a-(n.height-o.img.destHeight)/2,r=o.img.destLeft,a=o.img.destTop,i&&(o.img.destLeft>i.activePoint.startX&&(o.img.destLeft=i.activePoint.startX,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop>i.activePoint.startY&&(o.img.destTop=i.activePoint.startY,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop)),o.img.destLeft+n.width<i.activePoint.endX&&(o.img.destLeft=i.activePoint.endX-n.width,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop+n.height<i.activePoint.endY&&(o.img.destTop=i.activePoint.endY-n.height,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop))),n},o.prototype.setZoomDimension=function(t,i){var o=this.parent,r={width:0,height:0};if(r=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight),r.width+=r.width*o.transform.zoomFactor,r.height+=r.height*o.transform.zoomFactor,o.img.destLeft+=(o.img.destWidth-r.width)/2,o.img.destTop+=(o.img.destHeight-r.height)/2,t<0&&i){var a=i.activePoint.startX,n=i.activePoint.startY,s=i.activePoint.width,l=i.activePoint.height,p=o.img.destLeft+r.width,h=o.img.destTop+r.height;o.img.destLeft>a&&(o.img.destLeft=a),o.img.destTop>n&&(o.img.destTop=n),p<a+s&&(o.img.destLeft=a+s-r.width),h<n+l&&(o.img.destTop=n+l-r.height)}else t<0&&e.isNullOrUndefined(i)&&(o.img.destLeft>0&&(o.img.destLeft=0),o.img.destTop>0&&(o.img.destTop=0),o.img.destLeft+r.width<o.lowerCanvas.width&&(o.img.destLeft=o.lowerCanvas.width-o.img.destWidth),o.img.destTop+r.height<o.lowerCanvas.height&&(o.img.destTop=o.lowerCanvas.height-o.img.destHeight));return r},o.prototype.drawPannedImage=function(t,i){var o=this,r=this.parent,a={panDown:null};r.notify("selection",{prop:"getPanDown",onPropertyChange:!1,value:{obj:a}});var n={startPoint:a.panDown,endPoint:this.panMove,cancel:!1};e.isBlazor()&&e.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onPanStart.hasDelegate?(this.parent.eventType="pan",this.parent.panEventArgs=n,r.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanStart",n).then(function(e){o.panEvent(e,t,i)})):(r.trigger("panning",n),this.panEvent(n,t,i))},o.prototype.panEvent=function(t,i,o){if(!t.cancel){var r=this.parent,a=!1;if(r.activeObj.shape&&"shape"===r.activeObj.shape&&r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isNullOrUndefined(r.activeObj.shape)){a=!0,r.activeObj.activePoint={startX:r.img.destLeft,startY:r.img.destTop,endX:r.img.destLeft+r.img.destWidth,endY:r.img.destTop+r.img.destHeight};var n=r.activeObj.activePoint.startX,s=r.activeObj.activePoint.startY,l=r.activeObj.activePoint.endX,p=r.activeObj.activePoint.endY;n<0&&(r.activeObj.activePoint.startX=0),s<0&&(r.activeObj.activePoint.startY=0),l>r.lowerCanvas.width&&(r.activeObj.activePoint.endX=r.lowerCanvas.width),p>r.lowerCanvas.height&&(r.activeObj.activePoint.endY=r.lowerCanvas.height),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY,r.activeObj.shape="crop-custom";var h={strokeSettings:{}};r.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:h}}),r.activeObj.strokeSettings=h.strokeSettings,r.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:r.activeObj.activePoint,obj:r.activeObj,isMouseMove:null,x:null,y:null}}),r.isCropTab=!0}if(0===r.transform.degree){var c=void 0;c=e.isNullOrUndefined(i)&&e.isNullOrUndefined(o)?this.updatePanPoints(""):{x:i,y:o},r.panPoint.totalPannedPoint.x+=c.x,r.panPoint.totalPannedPoint.y+=c.y;var d=e.extend({},r.activeObj,{},!0),v=this.lowerContext.filter;this.drawPannImage(c),this.lowerContext.filter=v,this.tempPanMove=e.extend({},this.panMove,{},!0),r.activeObj=e.extend({},d,{},!0),this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),r.activeObj.shape&&r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:r.activeObj}})}else{var u=r.transform.currFlipState;r.isCropTab=!0,e.isNullOrUndefined(i)&&e.isNullOrUndefined(o)?r.panPoint.currentPannedPoint=this.updatePanPoints(""):r.panPoint.currentPannedPoint={x:i,y:o},r.transform.currFlipState=u,this.rotatePan(),r.isCropTab=!1,this.tempPanMove=e.extend({},this.panMove,{},!0)}a&&(r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),r.isCropTab=!1,this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height))}},o.prototype.drawPannImage=function(t){var e=this.parent,i={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),e.img.destLeft=i.startX,e.img.destTop=i.startY,e.img.destWidth=i.width,e.img.destHeight=i.height,this.setDestPointsForFlipState(),e.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(e.baseImg,e.img.srcLeft,e.img.srcTop,e.img.srcWidth,e.img.srcHeight,e.img.destLeft,e.img.destTop,e.img.destWidth,e.img.destHeight),(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}}),e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),e.img.destLeft=i.startX,e.img.destTop=i.startY,e.img.destWidth=i.width,e.img.destHeight=i.height;var o=this.lowerContext.filter;this.lowerContext.filter="none",e.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:t.x,yDiff:t.y,panRegion:""}}),e.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:t.x,yDiff:t.y,panRegion:""}}),this.lowerContext.filter=o,e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}})},o.prototype.resetZoom=function(){var t=this.parent;if(0!==t.transform.defaultZoomFactor){var i=t.isUndoRedo,o={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),this.transCurrObj=o.currObj,this.transCurrObj.objColl=e.extend([],t.objColl,null,!0),this.transCurrObj.pointColl=e.extend({},t.pointColl,null,!0),this.transCurrObj.afterCropActions=e.extend([],t.afterCropActions,[],!0);var r={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:r}}),this.transCurrObj.selPointColl=e.extend([],r.selPointColl,[],!0),t.isUndoRedo=t.isCropToolbar=!0,t.transform.defaultZoomFactor>0?this.zoomAction(-t.transform.defaultZoomFactor):this.zoomAction(Math.abs(t.transform.defaultZoomFactor)),t.isCropToolbar=!1,t.isUndoRedo=i}},o.prototype.performTransformation=function(t){var i=this.parent,o=i.transform.defaultZoomFactor,r=i.isUndoRedo,a=e.extend({},i.cropObj,{},!0);this.resetZoom(),this.updateTransform(t);for(var n=0,s=i.objColl.length;n<s;n++)if(i.objColl[n].flipObjColl.length>0){var l={collection:i.objColl[n].flipObjColl};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.objColl[n].flipObjColl,isRotateFlipCollection:null,obj:l}}),i.objColl[n].flipObjColl=l.collection,0===i.objColl[n].flipObjColl.length&&(i.objColl[n].shapeFlip="")}if(0!==o){i.isUndoRedo=!0,this.zoomAction(o),i.isUndoRedo=r;var p="";"rotateleft"===t||"rotateright"===t?p="rotate":"horizontalflip"!==t&&"verticalflip"!==t||(p="flip"),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:p,previousObj:this.transCurrObj,previousObjColl:this.transCurrObj.objColl,previousPointColl:this.transCurrObj.pointColl,previousSelPointColl:this.transCurrObj.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.transCurrObj=null}},o.prototype.updateTransform=function(e){switch(e.toLowerCase()){case"rotateleft":this.rotateImage(-90);break;case"rotateright":this.rotateImage(90);break;case"horizontalflip":this.flipImage(t.Direction.Horizontal);break;case"verticalflip":this.flipImage(t.Direction.Vertical)}},o.prototype.rotatePan=function(t,i){var o=this.parent;this.isReverseRotate=!0;var r,a=o.transform.degree,n={selPointColl:null};o.activeObj.activePoint&&o.activeObj.shape&&(r=e.extend({},o.activeObj,{},!0));var s=e.extend([],o.objColl,[],!0),l=e.extend([],o.pointColl,[],!0);o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}});var p=n.selPointColl;o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var h=o.img.destLeft,c=o.img.destTop;o.isCropTab&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y),o.notify("crop",{prop:"updateRotatePan",onPropertyChange:!1}),o.isCropTab&&(o.panPoint.totalPannedInternalPoint.x=o.img.destLeft-h,o.panPoint.totalPannedInternalPoint.y=o.img.destTop-c);var d=this.lowerContext.filter;o.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(o.baseImg,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,o.img.destLeft,o.img.destTop,o.img.destWidth,o.img.destHeight),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,isRotatePan:!0}});var v=o.img.destLeft,u=o.img.destTop;o.img.destLeft+=o.panPoint.totalPannedClientPoint.x,o.img.destTop+=o.panPoint.totalPannedClientPoint.y,o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y,o.panPoint.totalPannedClientPoint.x=o.img.destLeft-v,o.panPoint.totalPannedClientPoint.y=o.img.destTop-u,o.objColl=s,o.pointColl=l,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:p}}}),o.transform.degree=a,this.lowerContext.filter="none",t&&(i?(o.panPoint.totalPannedClientPoint.x=-o.panPoint.totalPannedClientPoint.x,o.panPoint.totalPannedClientPoint.y=-o.panPoint.totalPannedClientPoint.y,o.panPoint.currentPannedPoint=e.extend({},o.panPoint.totalPannedClientPoint,{},!0),o.panPoint.totalPannedClientPoint={x:0,y:0},o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y):o.panPoint.currentPannedPoint=e.extend({},o.panPoint.totalPannedClientPoint,{},!0)),o.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),o.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),this.lowerContext.filter=d,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=e.extend({},r,{},!0),o.activeObj.activePoint&&o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),this.isReverseRotate=!1},o.prototype.limitPan=function(){var t=this.parent;t.activeObj.activePoint&&(t.img.destLeft>t.activeObj.activePoint.startX&&(t.img.destLeft=t.activeObj.activePoint.startX),t.img.destTop>t.activeObj.activePoint.startY&&(t.img.destTop=t.activeObj.activePoint.startY),t.img.destLeft+t.img.destWidth<t.activeObj.activePoint.endX&&(t.img.destLeft=t.activeObj.activePoint.endX-t.img.destWidth),t.img.destTop+t.img.destHeight<t.activeObj.activePoint.endY&&(t.img.destTop=t.activeObj.activePoint.endY-t.img.destHeight))},o.prototype.updateFlipActiveObj=function(t){var e=this.parent;"horizontal"===t?(e.activeObj.activePoint.startX>e.lowerCanvas.width/2?e.activeObj.activePoint.endX=e.lowerCanvas.width/2-(e.activeObj.activePoint.startX-e.lowerCanvas.width/2):e.activeObj.activePoint.endX=e.lowerCanvas.width/2+(e.lowerCanvas.width/2-e.activeObj.activePoint.startX),e.activeObj.activePoint.startX=e.activeObj.activePoint.endX-e.activeObj.activePoint.width):"vertical"===t?(e.activeObj.activePoint.startX>e.lowerCanvas.width/2?e.activeObj.activePoint.endY=e.lowerCanvas.height/2-(e.activeObj.activePoint.startY-e.lowerCanvas.height/2):e.activeObj.activePoint.endY=e.lowerCanvas.height/2+(e.lowerCanvas.height/2-e.activeObj.activePoint.startY),e.activeObj.activePoint.startY=e.activeObj.activePoint.endY-e.activeObj.activePoint.height):"verticalHorizontal"!==t&&"horizontalVertical"!==t||(e.activeObj.activePoint.startX>e.lowerCanvas.width/2?(e.activeObj.activePoint.endX=e.lowerCanvas.width/2-(e.activeObj.activePoint.startX-e.lowerCanvas.width/2),e.activeObj.activePoint.endY=e.lowerCanvas.height/2-(e.activeObj.activePoint.startY-e.lowerCanvas.height/2)):(e.activeObj.activePoint.endX=e.lowerCanvas.width/2+(e.lowerCanvas.width/2-e.activeObj.activePoint.startX),e.activeObj.activePoint.endY=e.lowerCanvas.height/2+(e.lowerCanvas.height/2-e.activeObj.activePoint.startY)),e.activeObj.activePoint.startX=e.activeObj.activePoint.endX-e.activeObj.activePoint.width,e.activeObj.activePoint.startY=e.activeObj.activePoint.endY-e.activeObj.activePoint.height),e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}})},o.prototype.pan=function(t){var e=this.parent;!e.disabled&&e.isImageLoaded&&(t?(e.togglePan=!0,e.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),e.lowerCanvas.style.cursor=e.upperCanvas.style.cursor=e.cursor="grab",e.notify("selection",{prop:"setPanDown",onPropertyChange:!1,value:{panDown:null}})):(e.togglePan=e.currObjType.isCustomCrop=!1,e.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),e.lowerCanvas.style.cursor=e.upperCanvas.style.cursor=e.cursor="default"))},o.prototype.zoom=function(t,i){var o=this.parent;if(!o.disabled&&o.isImageLoaded){var r=this.getCurrentZoomFactor(t);if(e.isNullOrUndefined(i))this.zoomAction(r,i);else for(var a=r>0?"zoomIn":"zoomOut",n=0;n<10*Math.abs(r);n++)o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:i.x,y:i.y,type:a}})}},o.prototype.getCurrentZoomFactor=function(t){return.1*(t-this.prevZoomValue)},o.prototype.setCurrPanRegion=function(t,e,i){var o=t;""===t?"horizontal"===e?o="horizontal":"vertical"===e&&(o="vertical"):"horizontal"===t?"horizontal"===e?o="horizontalVertical":"vertical"===e?o="verticalHorizontal":90===e?o="vertical":-90===e&&(o="horizontal"):"vertical"===t?"horizontal"===e?o="horizontalVertical":"vertical"===e?o="verticalHorizontal":90===e?o="horizontal":-90===e&&(o="vertical"):"horizontal"===e?o="vertical":"vertical"===e&&(o="horizontal"),i.panRegion=o},o.prototype.rotate=function(t,e){var i=this.parent;!i.disabled&&i.isImageLoaded&&t%90==0&&this.rotateImage(t),e.isRotate=!1},o.prototype.flip=function(t){var e=this.parent;!e.disabled&&e.isImageLoaded&&this.flipImage(t)},o.prototype.update=function(){var t=this.parent,o=0,r=!1,a={bool:!1};t.isImageLoaded&&((t.element.querySelector("#"+t.element.id+"_contextualToolbar")&&!t.element.querySelector("#"+t.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||t.element.querySelector("#"+t.element.id+"_headWrapper")&&!t.element.querySelector("#"+t.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.okBtn(),e.isBlazor()?t.updateToolbar(t.element,"imageLoaded"):(t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))),t.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(e.isBlazor()?t.updateToolbar(t.element,"destroyQuickAccessToolbar"):t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),void 0!==t.activeObj.shape&&(r=!0,"block"===t.textArea.style.display?(t.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e.isBlazor()?t.updateToolbar(t.element,"destroyQuickAccessToolbar"):t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})):(t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.objColl.push(t.activeObj)),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})));var n=this.lowerContext.filter,s=document.querySelector("#"+t.element.id+"_canvasWrapper");if(s&&(s.style.width=t.element.offsetWidth-2+"px"),t.lowerCanvas.width=t.upperCanvas.width=t.element.offsetWidth-2,t.toolbarTemplate?o=t.element.querySelector("#"+t.element.id+"_toolbarArea").clientHeight:t.element.querySelector("#"+t.element.id+"_toolbar")&&(o=t.element.querySelector("#"+t.element.id+"_toolbar").clientHeight),t.notify("toolbar",{prop:"setToolbarHeight",value:{height:o}}),e.Browser.isDevice?(s&&(s.style.height=t.element.offsetHeight-2*o-5+"px"),t.lowerCanvas.height=t.upperCanvas.height=t.element.offsetHeight-2*o-5):(s&&(s.style.height=t.element.offsetHeight-o-3+"px"),t.lowerCanvas.height=t.upperCanvas.height=t.element.offsetHeight-o-3),this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",t.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),t.canvasFilter=this.lowerContext.filter,this.parent.initialAdjustmentValue=this.lowerContext.filter,t.clearContext(this.lowerContext),this.parent.clearContext(this.upperContext),t.isImageLoaded){if(t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.lowerContext.filter=n,t.initialAdjustmentValue=n,t.canvasFilter=this.lowerContext.filter,t.isImageLoaded&&(i.showSpinner(t.element),t.element.style.opacity="0.5"),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),s){s.style.width=t.element.offsetWidth-2+"px",s.style.height=t.element.offsetHeight+"px";var l={toolbarHeight:e.isBlazor()?t.toolbarHeight:0};e.isBlazor()||t.notify("toolbar",{prop:"getToolbarHeight",value:{obj:l}}),e.Browser.isDevice?s.style.height=parseFloat(s.style.height)-2*l.toolbarHeight-3+"px":s.style.height=parseFloat(s.style.height)-l.toolbarHeight-3+"px"}var p={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcWidth,height:t.img.srcHeight,obj:p}});var h=p;if(t.transform.defaultZoomFactor>0&&(h.width+=h.width*t.transform.defaultZoomFactor,h.height+=h.height*t.transform.defaultZoomFactor),t.img.destLeft=(t.lowerCanvas.clientWidth-h.width)/2,t.img.destTop=(t.lowerCanvas.clientHeight-h.height)/2,0===t.transform.degree&&""===t.transform.currFlipState)t.transform.defaultZoomFactor>0&&(t.img.destLeft+=t.panPoint.totalPannedPoint.x,t.img.destTop+=t.panPoint.totalPannedPoint.y),t.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:h}});else{t.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:h}}),t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var c=this.lowerContext.filter;t.notify("filter",{prop:"updateBrightFilter",onPropertyChange:!1}),this.lowerContext.drawImage(t.baseImg,t.img.srcLeft,t.img.srcTop,t.img.srcWidth,t.img.srcHeight,t.img.destLeft,t.img.destTop,t.img.destWidth,t.img.destHeight),this.lowerContext.filter=c,t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}})}t.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.hideSpinner(t.element),t.element.style.opacity="1";var d={defToolbarItems:null};if(e.isBlazor()||(t.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:d}}),d.defToolbarItems&&d.defToolbarItems.length>0&&document.getElementById(t.element.id+"_toolbar")&&(e.getComponent(t.element.id+"_toolbar","toolbar").refreshOverflow(),t.element.querySelector(".e-contextual-toolbar-wrapper")&&t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"))),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),r&&(t.activeObj=e.extend({},t.objColl[t.objColl.length-1],null,!0),t.objColl.pop(),0!==t.activeObj.activePoint.width&&0!==t.activeObj.activePoint.height&&(t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:t.activeObj}}),"rectangle"!==t.activeObj.shape&&"ellipse"!==t.activeObj.shape&&"text"!==t.activeObj.shape&&"line"!==t.activeObj.shape&&"arrow"!==t.activeObj.shape&&"path"!==t.activeObj.shape||(e.isBlazor()?t.updateToolbar(t.element,"quickAccessToolbar",t.activeObj.shape):t.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})))),a.bool&&(e.isBlazor()?t.updateToolbar(t.element,"quickAccessToolbar","pen"):t.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}})),(0!==t.transform.degree||""!==t.transform.currFlipState)&&t.transform.defaultZoomFactor>0){var v=e.extend({},t.panPoint.totalPannedPoint,null,!0),u=e.extend({},t.panPoint.totalPannedInternalPoint,null,!0),g=e.extend({},t.panPoint.totalPannedClientPoint,null,!0);t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}}),t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}}),0===t.transform.degree?(t.img.destLeft+=v.x,t.img.destTop+=v.y,t.panPoint.totalPannedPoint=v,t.notify("draw",{prop:"updateFlipPan",value:{tempSelectionObj:null}})):(t.panPoint.totalPannedInternalPoint=u,t.panPoint.totalPannedClientPoint=g,t.panPoint.currentPannedPoint={x:0,y:0},t.isCropTab=!0,t.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),t.isCropTab=!1)}else 0!==t.transform.degree&&t.transform.cropZoomFactor>0&&(t.transform.zoomFactor=0,t.transform.cropZoomFactor=null,e.isBlazor()?t.updateToolbar(t.element,"enableDisableToolbarBtn"):t.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}))}},o.prototype.calcMaxDimension=function(t,i,o){var r={toolbarHeight:0};e.isBlazor()?r.toolbarHeight=this.parent.toolbarHeight:this.parent.notify("toolbar",{prop:"getToolbarHeight",value:{obj:r}});var a=this.parent.element.clientWidth,n=this.parent.element.clientHeight-r.toolbarHeight;n=e.Browser.isDevice?n-r.toolbarHeight:n,a>30&&(a-=30),n>30&&(n-=30);var s=a/t,l=n/i,p=Math.min(t,a),h=Math.min(i,n);s<1&&s<l?(p=t*s,h=i*s):l<1&&l<s&&(p=t*l,h=i*l);var c={bool:null};return this.parent.notify("crop",{prop:"getPreventScaling",onPropertyChange:!1,value:{obj:c}}),c.bool&&this.parent.cropObj.activeObj.activePoint&&0!==this.parent.cropObj.activeObj.activePoint.width&&0!==this.parent.cropObj.activeObj.activePoint.height&&(p=this.parent.cropObj.activeObj.activePoint.width,h=this.parent.cropObj.activeObj.activePoint.height),o&&(o.width=p,o.height=h),{width:p,height:h}},o.prototype.updatePanPoints=function(t,i){var o=this.parent,r=e.extend({},o.activeObj,{},!0),a=o.img.destLeft,n=o.img.destTop;e.isNullOrUndefined(this.tempPanMove)&&(this.tempPanMove={x:this.panMove.x,y:this.panMove.y});var s=this.panMove.x-this.tempPanMove.x,l=this.panMove.y-this.tempPanMove.y;switch(t){case"":o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontal":this.updateFlipActiveObj(t),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop+=l;break;case"vertical":this.updateFlipActiveObj(t),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontalVertical":this.updateFlipActiveObj(t),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop-=l;break;case"verticalHorizontal":this.updateFlipActiveObj(t),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft-=s,o.img.destTop+=l}return this.limitPan(),o.activeObj=r,i&&(i.x=o.img.destLeft-a,i.y=o.img.destTop-n),{x:o.img.destLeft-a,y:o.img.destTop-n}},o}(),u=function(){function t(t){this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,this.parent=t,this.addEventListener()}return t.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},t.prototype.addEventListener=function(){this.parent.on("undo-redo",this.undoRedo,this),this.parent.on("destroyed",this.destroy,this)},t.prototype.removeEventListener=function(){this.parent.off("undo-redo",this.undoRedo),this.parent.off("destroyed",this.destroy)},t.prototype.initializeUrPvtProp=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},t.prototype.undoRedo=function(t){switch(this.initializeUrPvtProp(),t.prop){case"updateUndoRedoColl":this.updateUrc(t.value.operation,t.value.previousObj,t.value.previousObjColl,t.value.previousPointColl,t.value.previousSelPointColl,t.value.previousCropObj,t.value.previousText,t.value.currentText,t.value.previousFilter,t.value.isCircleCrop);break;case"refreshUrc":this.refreshUrc(t.value.bool);break;case"updateCurrUrc":this.updateCurrUrc(t.value.type);break;case"call-undo":this.callUndo();break;case"call-redo":this.callRedo();break;case"undo":this.undo();break;case"redo":this.redo();break;case"updateUrObj":this.updateUrObj(t.value.objColl);break;case"updateUndoRedo":this.updateUndoRedo();break;case"getAppliedUndoRedoColl":t.value.obj.appliedUndoRedoColl=this.appliedUndoRedoColl;break;case"getUndoRedoStep":t.value.obj.undoRedoStep=this.undoRedoStep;break;case"setUndoRedoStep":this.undoRedoStep=t.value.step;break;case"undoDefault":this.undoDefault(t.value.obj);break;case"reset":this.reset()}},t.prototype.getModuleName=function(){return"undo-redo"},t.prototype.reset=function(){this.tempCurrSelPoint=null,this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempActObj=null,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0},t.prototype.refreshUrc=function(t){var i=this.parent;(t=t||!1)?(e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!0}}),this.tempUndoRedoColl=e.extend([],this.appliedUndoRedoColl,[],!0),this.tempUndoRedoStep=this.undoRedoStep):e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),this.undoRedoColl=this.undoRedoColl.slice(0,this.undoRedoStep),this.appliedUndoRedoColl=this.appliedUndoRedoColl.slice(0,this.undoRedoStep),i.isUndoRedo=i.currObjType.isUndoAction=!1,e.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})},t.prototype.updateCurrUrc=function(t){var i=this.parent;if(e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),"ok"===t){i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!1}});var o=this.tempUndoRedoColl.length>0?e.extend([],this.tempUndoRedoColl,[],!0):e.extend([],this.undoRedoColl,[],!0),r=this.undoRedoColl[this.undoRedoColl.length-1];if(e.isNullOrUndefined(this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1])?this.undoRedoColl[0]&&(r.previousCropObj=o[0].previousCropObj,r.previousObj=o[0].previousObj,r.previousObjColl=o[0].previousObjColl,r.previousPointColl=o[0].previousPointColl,r.previousText=o[0].previousText):(r.previousCropObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentCropObj,r.previousObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObj,r.previousObjColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObjColl,r.previousPointColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentPointColl,r.previousText=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentText),r){var a=this.getZeroZoomObjPointValue(r.currentObjColl,r.currentPointColl);r.currentObjColl=a.obj,r.currentPointColl=a.point,this.appliedUndoRedoColl.push(r)}this.tempUndoRedoColl=[],this.tempUndoRedoStep=0}else this.tempUndoRedoColl.length>0&&(this.appliedUndoRedoColl=e.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0);this.appliedUndoRedoColl.length>16&&this.appliedUndoRedoColl.splice(0,1),this.undoRedoColl=[],this.undoRedoColl=e.extend([],this.appliedUndoRedoColl,[],!0),"ok"===t&&(this.undoRedoStep=this.undoRedoColl.length,e.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})),i.transform.zoomFactor>0&&(i.togglePan=!0,i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}))},t.prototype.cancelCropSelection=function(){var t,i=this.parent,o=!1;i.activeObj.shape&&(t=i.activeObj.shape.split("-")),(i.currObjType.isCustomCrop||t&&"crop"===t[0])&&(o=!0),o&&i.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),0===this.tempUndoRedoColl.length&&0===this.tempUndoRedoStep||(this.appliedUndoRedoColl=e.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoColl=e.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,e.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}))},t.prototype.refreshToolbarActions=function(){var t=this.parent;e.isBlazor()?e.isNullOrUndefined(t.activeObj.shape)&&t.updateToolbar(t.element,"imageLoaded"):t.activeObj.shape?(t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})):t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},t.prototype.applyCurrentChanges=function(){var t=this.parent;t.currObjType.isFiltered=!1,0===t.transform.zoomFactor&&(t.togglePan=!1,t.notify("selection",{prop:"setDragCanvas",value:{bool:!1}})),t.element.querySelector(".e-contextual-toolbar-wrapper")&&!e.isBlazor()&&t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.togglePen&&(t.togglePen=!1,t.upperCanvas.style.cursor=t.cursor="default",this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height)),this.appliedUndoRedoColl.length>0&&(this.undoRedoColl=e.extend([],this.appliedUndoRedoColl,[],!0))},t.prototype.callUndo=function(){this.applyCurrentChanges(),this.undo()},t.prototype.callRedo=function(){this.applyCurrentChanges(),this.redo()},t.prototype.undo=function(){var t=this.parent;if(this.cancelCropSelection(),!t.disabled&&t.isImageLoaded&&this.undoRedoStep>0){this.refreshToolbarActions(),t.activeObj.activePoint&&0!==t.activeObj.activePoint.width&&(this.tempActObj=t.activeObj),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.undoRedoStep--,e.isBlazor()?t.updateToolbar(t.element,"enableDisableToolbarBtn"):(t.notify("toolbar",{prop:"enable-disable-btns"}),t.element.querySelector(".e-contextual-toolbar-wrapper")&&t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),t.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep];this.undoRedoColl.length===this.undoRedoStep?t.currObjType.isUndoAction=!1:t.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===t.textArea.style.display&&(t.textArea.style.display="none"),t.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}});switch(t.cropObj=e.extend({},i.previousCropObj,{},!0),t.afterCropActions=i.previousObj.afterCropActions,this.lowerContext.filter=i.previousObj.filter,t.canvasFilter=this.lowerContext.filter,i.operation){case"shapeTransform":this.shapeTransform(i.previousObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.previousPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.previousPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.previousObjColl,i.previousPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(void 0,i.previousObjColl);break;case"text":this.updateText(i.previousObjColl,!0);break;default:this.undoDefault(i),t.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),t.notify("filter",{prop:"update-filter",value:{operation:i.operation,filter:i.filter}})}"crop"===i.operation&&(i.previousObj.currSelectionPoint&&(t.currSelectionPoint=e.extend({},i.previousObj.currSelectionPoint,{},!0),t.currSelectionPoint&&e.isNullOrUndefined(t.currSelectionPoint.shape)&&(t.currSelectionPoint=null)),t.updateCropTransformItems(),t.select("custom"),t.isCircleCrop&&(t.isCircleCrop=!1,this.tempCurrSelPoint=e.extend({},t.currSelectionPoint,{},!0),t.currSelectionPoint=null),t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}})),this.undoRedoColl[this.undoRedoStep-1]&&this.undoRedoColl[this.undoRedoStep-1].isCircleCrop&&(t.isCircleCrop=!0,t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})),this.endUndoRedo(i.operation,!0)}},t.prototype.redo=function(){var t=this.parent;if(this.cancelCropSelection(),!t.disabled&&t.isImageLoaded&&this.undoRedoStep<this.appliedUndoRedoColl.length){this.refreshToolbarActions(),this.undoRedoStep++,e.isBlazor()?t.updateToolbar(t.element,"enableDisableToolbarBtn"):t.notify("toolbar",{prop:"enable-disable-btns"}),t.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep-1];this.undoRedoColl.length===this.undoRedoStep?t.currObjType.isUndoAction=!1:t.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===t.textArea.style.display&&(t.textArea.style.display="none"),t.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}}),t.cropObj=e.extend({},i.currentCropObj,{},!0),t.afterCropActions=i.currentObj.afterCropActions,this.lowerContext.filter=i.currentObj.filter,!e.isBlazor()&&t.element.querySelector(".e-contextual-toolbar-wrapper")&&t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.canvasFilter=this.lowerContext.filter;var o=void 0;switch(i.operation){case"shapeTransform":this.shapeTransform(i.currentObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.currentPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.currentPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.currentObjColl,i.currentPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(o,i.currentObjColl);break;case"text":this.updateText(i.currentObjColl,!1);break;default:t.objColl=[],t.pointColl=[],t.freehandCounter=0,t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),t.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:i.currentObj}}),t.img.destLeft=i.currentObj.destPoints.startX,t.img.destTop=i.currentObj.destPoints.startY,o=e.extend({},t.activeObj,{},!0),t.objColl=e.extend([],i.currentObjColl,[],!0),t.pointColl=e.extend([],i.currentPointColl,[],!0),t.freehandCounter=t.pointColl.length,t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:e.extend([],i.currentSelPointColl,[],!0)}}}),this.lowerContext.filter="none",t.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=i.currentObj.filter,t.activeObj=o,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),0!==t.activeObj.activePoint.width&&0!==t.activeObj.activePoint.height&&t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),t.notify("filter",{prop:"update-filter",value:{operation:i.operation}})}"crop"===i.operation&&i.isCircleCrop&&(t.isCircleCrop=!0,t.currSelectionPoint=e.extend({},this.tempCurrSelPoint,{},!0),this.tempCurrSelPoint=null),"crop"!==i.operation||i.isCircleCrop||(t.isCircleCrop=!1),"crop"===i.operation&&i.currentObj.currSelectionPoint&&(t.currSelectionPoint=e.extend({},i.currentObj.currSelectionPoint,{},!0)),t.currSelectionPoint&&e.isNullOrUndefined(t.currSelectionPoint.shape)&&(t.currSelectionPoint=null),this.endUndoRedo(i.operation,!1)}},t.prototype.shapeTransform=function(t){var i=this.parent;i.objColl=e.extend([],t,[],!0),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.isUndoRedo=!0,i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},t.prototype.updateFreehandDraw=function(t){var e=this.parent;e.pointColl=t,e.freehandCounter=e.pointColl.length,e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.isUndoRedo=!0,e.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},t.prototype.updateFreehandDrawCustomized=function(t){var e=this.parent;e.pointColl=t,e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.isUndoRedo=!0,e.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},t.prototype.updateDelete=function(t,e,i){var o=this.parent;"deleteFreehandDrawing"===t?(o.pointColl=i,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})):"deleteObj"===t&&(o.objColl=e,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}})),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},t.prototype.updateTextAreaCustomization=function(t,i){var o=this.parent;o.objColl=e.extend([],i,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1});for(var r=0,a=i.length;r<a;r++){if(!this.tempActObj){t=e.extend({},i[i.length-1],{},!0),o.objColl.splice(r,1);break}if(this.tempActObj.currIndex===i[r].currIndex){t=e.extend({},i[r],{},!0),o.objColl.splice(r,1);break}}t&&this.updateTextBox(t),"block"===o.textArea.style.display&&o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}})},t.prototype.updateText=function(t,i){var o=this.parent;if(this.tempActObj&&(o.activeObj=e.extend({},this.tempActObj,{},!0)),0===t.length&&1===o.objColl.length)this.tempActObj=e.extend({},o.objColl[0],{},!0);else for(var r=0;r<o.objColl.length;r++){if(o.objColl[r]&&e.isNullOrUndefined(t[r])){this.tempActObj=e.extend({},o.objColl[r],{},!0);break}if(t[r].currIndex!==o.objColl[r].currIndex){this.tempActObj=e.extend({},o.objColl[r],{},!0);break}}i&&(o.activeObj=e.extend({},this.tempActObj,{},!0)),o.objColl=e.extend([],t,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},t.prototype.updateTextBox=function(t){var i=this.parent;this.upperContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),e.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.textArea.style.display="block",i.textArea.style.fontFamily=t.textSettings.fontFamily,i.textArea.style.fontSize=t.textSettings.fontSize+"px",i.textArea.style.color=t.strokeSettings.strokeColor,i.textArea.style.fontWeight=t.textSettings.bold?"bold":"normal",i.textArea.style.fontStyle=t.textSettings.italic?"italic":"normal",i.textArea.style.border="2px solid "+i.themeColl[i.theme].primaryColor,i.textArea.value=t.keyHistory,i.activeObj=e.extend({},t,{},!0),i.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}}),i.textArea.style.width=i.activeObj.activePoint.width+"px"},t.prototype.undoDefault=function(t){this.lowerContext.filter=t.previousObj.filter;var i=this.parent;i.objColl=[],i.pointColl=[],i.freehandCounter=0,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:t.previousObj}}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.img.destLeft=t.previousObj.destPoints.startX,i.img.destTop=t.previousObj.destPoints.startY;var o=e.extend({},i.activeObj,{},!0);i.objColl=e.extend([],t.previousObjColl,[],!0),i.pointColl=e.extend([],t.previousPointColl,[],!0),i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:e.extend([],t.previousSelPointColl,[],!0)}}}),this.lowerContext.filter="none",i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=t.previousObj.filter,i.activeObj=o,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})},t.prototype.endUndoRedo=function(t,i){var o=this.parent;o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.isCircleCrop&&(i&&"crop"!==t||!i)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.transform.zoomFactor>0&&o.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),o.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!1}}),e.isBlazor()?(e.isNullOrUndefined(o.activeObj.shape)||"crop"!==o.activeObj.shape.split("-")[0])&&(o.updateToolbar(o.element,"imageLoaded"),o.updateToolbar(o.element,"enableDisableToolbarBtn")):(o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!0,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"enable-disable-btns"})),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"),e.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns"}),0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}}),o.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),o.currObjType.isCustomCrop=!1},t.prototype.updateUrc=function(t,i,o,r,a,n,s,l,p,h){var c=this.parent,d={isInitialLoaded:!1};if(c.currObjType.isUndoAction&&this.refreshUrc(!0),c.notify("draw",{prop:"isInitialLoaded",onPropertyChange:!1,value:{object:d}}),!d.isInitialLoaded&&c.allowUndoRedo){var v={currObj:{}};c.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:v}});var u=v.currObj;u.objColl=e.extend([],c.objColl,[],!0),u.pointColl=e.extend([],c.pointColl,[],!0),u.afterCropActions=e.extend([],c.afterCropActions,[],!0);var g={selPointColl:null};c.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:g}}),u.selPointColl=e.extend([],g.selPointColl,[],!0),"crop"===t&&(u.currSelectionPoint=e.extend({},c.currSelectionPoint,{},!0)),this.undoRedoColl.push({operation:t,previousObj:i,currentObj:u,previousObjColl:o,currentObjColl:u.objColl,previousPointColl:r,currentPointColl:u.pointColl,previousSelPointColl:a,currentSelPointColl:u.selPointColl,previousCropObj:n,currentCropObj:e.extend({},c.cropObj,{},!0),previousText:s,currentText:l,filter:p,isCircleCrop:h}),e.isBlazor()?c.updateToolbar(c.element,"enableDisableToolbarBtn"):c.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1})}},t.prototype.updateUrObj=function(t){var i=this.parent;if(i.allowUndoRedo){i.currObjType.isUndoAction&&this.refreshUrc(!0),i.objColl.push(i.activeObj);var o=e.extend({},i.cropObj,{},!0),r={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],i.objColl,[],!0),a.pointColl=e.extend([],i.pointColl,[],!0),a.afterCropActions=e.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.undoRedoColl.push({operation:"shapeTransform",previousObj:a,currentObj:a,previousObjColl:t,currentObjColl:a.objColl,previousPointColl:a.pointColl,currentPointColl:a.pointColl,previousSelPointColl:a.selPointColl,currentSelPointColl:a.selPointColl,previousCropObj:o,currentCropObj:o}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}})}},t.prototype.updateUndoRedo=function(){var t=this.parent,i=e.extend({},t.cropObj,{},!0),o={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],t.objColl,[],!0),r.pointColl=e.extend([],t.pointColl,[],!0),r.afterCropActions=e.extend([],t.afterCropActions,[],!0);var a={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),t.objColl.push(t.activeObj),this.updateUrc("shapeTransform",r,r.objColl,r.pointColl,r.selPointColl,i),t.objColl.pop(),t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isBlazor()?t.updateToolbar(t.element,"imageLoaded"):(t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))},t.prototype.getZeroZoomObjPointValue=function(t,i){var o=this.parent,r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],o.objColl,[],!0),a.pointColl=e.extend([],o.pointColl,[],!0),a.afterCropActions=e.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0);var s={cropDimension:null};o.notify("transform",{prop:"getCropDimension",onPropertyChange:!1,value:{obj:s}});var l=e.extend([],o.objColl,[],!0),p=e.extend([],o.pointColl,[],!0),h={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:h}});var c=e.extend({},h.arrowDimension,{},!0);if(o.transform.zoomFactor>0&&(t.length>0||i.length>0)){o.objColl=t,o.pointColl=i;var d=o.isUndoRedo;if(0!==o.transform.zoomFactor){o.isUndoRedo=o.isCropTab=!0,o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var v=e.extend({},o.zoomSettings,null,!0);o.transform.zoomFactor>0?o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-o.transform.zoomFactor,zoomPoint:null}}):o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(o.transform.zoomFactor),zoomPoint:null}}),o.zoomSettings=v,o.isCropTab=!1,o.isUndoRedo=d,l=e.extend([],o.objColl,[],!0),p=e.extend([],o.pointColl,[],!0),o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:s.cropDimension.width,height:s.cropDimension.height}});var u={width:s.cropDimension.width,height:s.cropDimension.height};u.width+=u.width*a.defaultZoom,u.height+=u.height*a.defaultZoom,o.notify("draw",{prop:"setZoomCropWidth",value:{width:u.width,height:u.height}}),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:a}}),o.img.destLeft=a.destPoints.startX,o.img.destTop=a.destPoints.startY,o.panPoint.totalPannedPoint=a.totalPannedPoint,o.panPoint.totalPannedClientPoint=a.totalPannedClientPoint,o.panPoint.totalPannedInternalPoint=a.totalPannedInternalPoint,o.objColl=e.extend([],a.objColl,[],!0),o.pointColl=e.extend([],a.pointColl,[],!0),o.freehandCounter=o.pointColl.length,o.notify("draw",{prop:"setArrowDimension",onPropertyChange:!1,value:{arrowDimension:c}}),o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:e.extend([],a.selPointColl,[],!0)}}}),this.lowerContext.filter="none",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),o.notify("freehand-draw",{prop:"updateFHDCurPts",onPropertyChange:!1}),this.lowerContext.filter=a.filter,0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}})}}return{obj:l,point:p}},t}(),g=function(){var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(e,i)};return function(e,i){function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),b=function(t,e,i,o){var r,a=arguments.length,n=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(n=(a<3?r(n):a>3?r(e,i,n):r(e,i))||n);return a>3&&n&&Object.defineProperty(e,i,n),n},C=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return g(i,t),b([e.Property(null)],i.prototype,"brightness",void 0),b([e.Property(null)],i.prototype,"contrast",void 0),b([e.Property(null)],i.prototype,"hue",void 0),b([e.Property(null)],i.prototype,"saturation",void 0),b([e.Property(null)],i.prototype,"exposure",void 0),b([e.Property(null)],i.prototype,"opacity",void 0),b([e.Property(null)],i.prototype,"blur",void 0),i}(e.ChildProperty),f=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return g(i,t),b([e.Property(null)],i.prototype,"zoomTrigger",void 0),b([e.Property(1)],i.prototype,"minZoomFactor",void 0),b([e.Property(10)],i.prototype,"maxZoomFactor",void 0),b([e.Property(1)],i.prototype,"zoomFactor",void 0),b([e.Property(null)],i.prototype,"zoomPoint",void 0),i}(e.ChildProperty),m=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return g(i,t),b([e.Property(!0)],i.prototype,"showCircle",void 0),b([e.Property(null)],i.prototype,"strokeColor",void 0),b([e.Property(null)],i.prototype,"fillColor",void 0),i}(e.ChildProperty),y=function(o){function r(t,i){var r=o.call(this,t)||this;return r.isImageLoaded=!1,r.activeObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[],rotatedAngle:0},r.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},r.objColl=[],r.pointColl={},r.freehandCounter=0,r.points=[],r.togglePen=!1,r.togglePan=!1,r.img={destLeft:0,destTop:0,destWidth:0,destHeight:0,srcLeft:0,srcTop:0,srcWidth:0,srcHeight:0},r.rotateFlipColl=[],r.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",zoomFactor:0,previousZoomValue:0},r.afterCropActions=[],r.transform={degree:0,currFlipState:"",zoomFactor:0,cropZoomFactor:null,defaultZoomFactor:0},r.panPoint={currentPannedPoint:{x:0,y:0},totalPannedPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0}},r.isUndoRedo=!1,r.isCropTab=!1,r.isCircleCrop=!1,r.fontSizeColl=[],r.initialAdjustmentValue="",r.currentFilter="",r.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",r.toolbarHeight=0,r.isPublicMethod=!1,r.isCropToolbar=!1,r.cursor="default",e.isBlazor()?(new n(r),new s(r),new p(r),new h(r),new c(r),new d(r),new v(r),new u(r),new l(r)):(a.Inject(n,s,c,v,l,P),a.Inject(u),a.Inject(p),a.Inject(d),a.Inject(h),i&&r.appendTo(i)),r}g(r,o),a=r,r.prototype.requiredModules=function(){var t=[];return t.push({member:"crop",args:[this]}),t.push({member:"draw",args:[this]}),t.push({member:"selection",args:[this]}),t.push({member:"transform",args:[this]}),t.push({member:"export",args:[this]}),t.push({member:"toolbar-module",args:[this]}),t.push({member:"undo-redo",args:[this]}),t.push({member:"filter",args:[this]}),t.push({member:"shape",args:[this]}),t.push({member:"freehand-draw",args:[this]}),t},r.prototype.preRender=function(){this.element.id=this.element.id||e.getUniqueID("ej2-image-editor"),e.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},r.prototype.render=function(){this.initialize()},r.prototype.getModuleName=function(){return"image-editor"},r.prototype.getPersistData=function(){return this.addOnPersist([])},r.prototype.onPropertyChanged=function(i,o){for(var r=0,a=Object.keys(i);r<a.length;r++)switch(a[r]){case"cssClass":o.cssClass&&e.removeClass([this.element],o.cssClass.replace(/\s+/g," ").trim().split(" ")),i.cssClass&&e.addClass([this.element],i.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"disabled":i.disabled?(this.element.classList.add("e-disabled"),this.unwireEvent()):(this.element.classList.remove("e-disabled"),this.wireEvent());break;case"height":this.element.style.height=i.height;break;case"width":this.element.style.width=i.width;break;case"theme":i.theme&&(this.theme&&""!==this.theme?this.theme=this.toPascalCase(this.theme):this.theme="Bootstrap5",this.upperContext.strokeStyle=this.themeColl[this.theme].primaryColor,this.upperContext.fillStyle=this.themeColl[this.theme].secondaryColor);break;case"finetuneSettings":i.finetuneSettings&&(this.finetuneSettings=i.finetuneSettings,this.notify("filter",{prop:"update-finetunes"}));break;case"locale":i.locale&&(this.notify("toolbar",{prop:"setLocale",onPropertyChange:!1,value:{locale:i.locale}}),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"allowUndoRedo":i.allowUndoRedo?this.allowUndoRedo=!0:this.allowUndoRedo=!1,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"showQuickAccessToolbar":i.showQuickAccessToolbar?(this.showQuickAccessToolbar=!0,this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})):(this.showQuickAccessToolbar=!1,this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}));break;case"zoomSettings":i.zoomSettings&&(this.zoomSettings.zoomTrigger=i.zoomSettings.zoomTrigger),e.isNullOrUndefined(this.zoomSettings.zoomTrigger)?(this.zoomSettings.zoomTrigger=t.ZoomTrigger.MouseWheel|t.ZoomTrigger.Pinch|t.ZoomTrigger.Toolbar|t.ZoomTrigger.Commands,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})):(i.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)===t.ZoomTrigger.Toolbar&&this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"selectionSettings":i.selectionSettings&&(this.selectionSettings=i.selectionSettings,this.activeObj.shape&&(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})))}},r.prototype.destroy=function(){var t=[];this.element.removeAttribute("tabindex"),this.cssClass&&(t=t.concat(this.cssClass.replace(/\s+/g," ").trim().split(" "))),e.removeClass([this.element],t),this.element.getAttribute("class")||this.element.removeAttribute("class"),e.isBlazor()?this.element.classList.remove("e-image-editor"):(this.notify("toolbar",{prop:"destroySubComponents",onPropertyChange:!1}),this.notify("destroyed",null),o.prototype.destroy.call(this)),this.unwireEvent(),this.element.innerHTML=""},r.prototype.initialize=function(){if(this.toolbarTemplate?(this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplateFn()):(this.notify("toolbar",{prop:"create-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"create-contextual-toolbar",onPropertyChange:!1})),this.createCanvas(),this.showQuickAccessToolbar){document.querySelector("#"+this.element.id+"_canvasWrapper").appendChild(this.createElement("div",{id:this.element.id+"_quickAccessToolbarArea",className:"e-quick-access-toolbar-area"}));var t=document.getElementById(this.element.id+"_quickAccessToolbarArea");t.style.position="absolute",t.style.display="none",this.activeObj&&(t.style.left=this.activeObj.activePoint.startX+"px",t.style.top=this.activeObj.activePoint.startY+"px"),t.style.width="100%"}this.quickAccessToolbarTemplate?this.quickAccessToolbarTemplateFn():this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),this.wireEvent(),this.lowerContext=this.lowerCanvas.getContext("2d"),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.canvasFilter=this.lowerContext.filter,this.notify("toolbar",{prop:"setInitialAdjustmentValue",onPropertyChange:!1,value:{value:this.lowerContext.filter}}),this.cssClass&&e.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},r.prototype.wireEvent=function(){e.EventHandler.add(document,"keydown",this.keyDownEventHandler,this),e.EventHandler.add(document,"keypress",this.keyUpEventHandler,this),e.EventHandler.add(this.upperCanvas,"mousedown",this.mouseDownEventHandler,this),e.EventHandler.add(this.upperCanvas,"mousemove",this.mouseMoveEventHandler,this),e.EventHandler.add(this.upperCanvas,"mouseup",this.mouseUpEventHandler,this),e.EventHandler.add(document,"mouseup",this.mouseUpEventHandler,this),e.EventHandler.add(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler,this),e.EventHandler.add(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler,this),e.EventHandler.add(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler,this),e.EventHandler.add(document,"mouseup",this.canvasMouseUpHandler,this),e.EventHandler.add(this.upperCanvas,"touchstart",this.touchStartHandler,this),e.EventHandler.add(this.lowerCanvas,"touchstart",this.touchStartHandler,this),e.EventHandler.add(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),e.EventHandler.add(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),window.addEventListener("resize",this.windowResizeHandler.bind(this)),e.Browser.isIos||"safari"===e.Browser.info.name||screen.orientation.addEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"wireEvent",onPropertyChange:!1})},r.prototype.unwireEvent=function(){e.EventHandler.remove(document,"keydown",this.keyDownEventHandler),e.EventHandler.remove(document,"keypress",this.keyUpEventHandler),e.EventHandler.remove(this.upperCanvas,"mousedown",this.mouseDownEventHandler),e.EventHandler.remove(this.upperCanvas,"mousemove",this.mouseMoveEventHandler),e.EventHandler.remove(this.upperCanvas,"mouseup",this.mouseUpEventHandler),e.EventHandler.remove(document,"mouseup",this.mouseUpEventHandler),e.EventHandler.remove(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler),e.EventHandler.remove(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler),e.EventHandler.remove(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler),e.EventHandler.remove(document,"mouseup",this.canvasMouseUpHandler),e.EventHandler.remove(this.upperCanvas,"touchstart",this.touchStartHandler),e.EventHandler.remove(this.lowerCanvas,"touchstart",this.touchStartHandler),e.EventHandler.remove(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll),e.EventHandler.remove(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll),window.removeEventListener("resize",this.windowResizeHandler.bind(this)),e.Browser.isIos||"safari"===e.Browser.info.name||screen.orientation.removeEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"unWireEvent",onPropertyChange:!1}),this.notify("selection",{prop:"unWireEvent",onPropertyChange:!1})},r.prototype.createCanvas=function(){this.element.style.boxSizing="border-box";var t={toolbarHeight:0};this.notify("toolbar",{prop:"getToolbarHeight",value:{obj:t}});var e=t.toolbarHeight;this.element.style.width=this.width,this.element.style.height=this.height;var i=this.element.appendChild(this.createElement("div",{id:this.element.id+"_canvasWrapper",className:"e-canvas-wrapper",attrs:{style:"height:"+(this.element.offsetHeight-e-2)+"px; width:"+(this.element.offsetWidth-2)+"px; position: relative; overflow: hidden; margin: 0 auto;"}}));this.lowerCanvas=i.appendChild(this.createElement("canvas",{id:this.element.id+"_lowerCanvas",attrs:{name:"canvasImage"}})),this.upperCanvas=i.appendChild(this.createElement("canvas",{id:this.element.id+"_upperCanvas",attrs:{name:"canvasImage"}})),this.inMemoryCanvas=this.createElement("canvas",{id:this.element.id+"_inMemoryCanvas",attrs:{name:"canvasImage"}}),this.textArea=i.appendChild(this.createElement("textarea",{id:this.element.id+"_textArea",className:"e-textarea",attrs:{name:"textArea"}})),this.element.appendChild(this.createElement("div",{id:this.element.id+"_dialog",className:"e-dialog"})).style.display="none",this.textArea.setAttribute("spellcheck","false"),this.textArea.style.lineHeight="normal",this.lowerCanvas.style.width=this.upperCanvas.style.width=this.inMemoryCanvas.style.width="100%",this.lowerCanvas.style.height=this.upperCanvas.style.height=this.inMemoryCanvas.style.height="100%",this.upperCanvas.style.position=this.lowerCanvas.style.position=this.textArea.style.position="absolute",this.textArea.style.backgroundColor="transparent",this.textArea.style.display="none",this.textArea.style.resize="none",this.lowerContext=this.lowerCanvas.getContext("2d"),this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.upperCanvas.style.cursor=this.cursor="default",this.upperCanvas.style.display="block",this.upperContext=this.upperCanvas.getContext("2d")},r.prototype.touchStartHandler=function(t){this.notify("selection",{prop:"touchStartHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.mouseDownEventHandler=function(t){this.notify("selection",{prop:"mouseDownEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.mouseMoveEventHandler=function(t){this.notify("selection",{prop:"mouseMoveEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.mouseUpEventHandler=function(t){this.notify("selection",{prop:"mouseUpEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.keyDownEventHandler=function(t){this.notify("selection",{prop:"keyDownEventHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.keyUpEventHandler=function(t){"block"===this.textArea.style.display&&t.target.id===this.element.id+"_textArea"&&this.notify("selection",{prop:"textKeyDown",value:{e:t}})},r.prototype.canvasMouseDownHandler=function(t){this.notify("selection",{prop:"canvasMouseDownHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.canvasMouseMoveHandler=function(t){this.notify("selection",{prop:"canvasMouseMoveHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.canvasMouseUpHandler=function(t){this.notify("selection",{prop:"canvasMouseUpHandler",onPropertyChange:!1,value:{e:t}})},r.prototype.handleScroll=function(t){this.notify("selection",{prop:"handleScroll",onPropertyChange:!1,value:{e:t}})},r.prototype.adjustToScreen=function(){this.update()},r.prototype.screenOrientation=function(){e.Browser.isDevice&&setTimeout(this.adjustToScreen.bind(this),100)},r.prototype.windowResizeHandler=function(){!e.Browser.isDevice&&this.element.classList.contains("e-image-editor")&&this.adjustToScreen()},r.prototype.notifyResetForAllModules=function(){for(var t=this.requiredModules(),e=0;e<t.length;e++)this.notify(t[e].member,{prop:"reset",onPropertyChange:!1})},r.prototype.allowShape=function(t,e){this.isPublicMethod=!0;var i={inRange:!1};return this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:t,y:e,obj:i}}),i.inRange},r.prototype.clearSelection=function(){this.notify("selection",{prop:"clearSelection",onPropertyChange:!1})},r.prototype.crop=function(){var t={isCrop:!1};return this.notify("crop",{prop:"crop",onPropertyChange:!1,value:{obj:t}}),t.isCrop},r.prototype.flip=function(t){this.notify("transform",{prop:"flip",value:{direction:t}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},r.prototype.getImageData=function(){var t={canvas:null};return this.notify("export",{prop:"exportToCanvas",value:{object:t}}),t.canvas.getContext("2d").getImageData(0,0,t.canvas.width,t.canvas.height)},r.prototype.open=function(t){this.notify("draw",{prop:"open",value:{data:t}})},r.prototype.reset=function(){var t={isErrorImage:!1};if(this.notify("draw",{prop:"getErrorImage",value:{obj:t}}),!this.disabled&&!t.isErrorImage){this.clearContext(this.inMemoryContext),this.clearContext(this.lowerContext),this.clearContext(this.upperContext),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.isBlazor()||(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),e.Browser.isDevice&&document.getElementById(this.element.id+"_bottomToolbar")&&(e.getComponent(document.getElementById(this.element.id+"_bottomToolbar"),"toolbar").destroy(),this.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1}))),this.currObjType.isUndoAction=this.isUndoRedo=this.togglePan=this.togglePen=this.isImageLoaded=!1,this.isCircleCrop=this.isCropTab=!1,this.objColl=[],this.transform.degree=0,this.upperCanvas.style.display="block",this.transform.currFlipState="",this.upperCanvas.style.cursor=this.cursor=this.lowerCanvas.style.cursor="default",this.lowerContext.lineWidth=this.upperContext.lineWidth=void 0,this.textArea.value=this.textArea.textContent="",this.textArea.style.display="none",this.lowerContext.filter=this.canvasFilter=this.getDefaultFilter(),this.img.destLeft=this.img.destTop=this.img.srcLeft=this.img.srcTop=0,this.img.destWidth=this.img.destHeight=this.img.srcWidth=this.img.srcHeight=null,this.currSelectionPoint=null,this.panPoint.currentPannedPoint={x:0,y:0},this.rotateFlipColl=[],this.points=[],this.pointColl={},this.freehandCounter=0,this.notify("draw",{prop:"resetPanPoints"}),this.lowerCanvas.style.left=this.upperCanvas.style.left="",this.fontSizeColl=[],this.lowerCanvas.style.top=this.upperCanvas.style.top="",this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth="",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight="",this.transform.defaultZoomFactor=this.transform.zoomFactor=0,this.transform.cropZoomFactor=null,this.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},this.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:""},this.afterCropActions=[],this.currentFilter="";var i={initialZoomValue:!1};this.notify("draw",{prop:"getInitialZoomValue",onPropertyChange:!1,value:{obj:i}}),i.initialZoomValue&&this.setProperties({zoomSettings:{zoomFactor:i.initialZoomValue}},!0),document.getElementById(this.element.id+"_quickAccessToolbarArea")&&(document.getElementById(this.element.id+"_quickAccessToolbarArea").style.display="none"),this.notifyResetForAllModules(),this.notify("filter",{prop:"update-finetunes"}),this.isImageLoaded=!1,this.notify("draw",{prop:"update-canvas",onPropertyChange:!1}),this.isImageLoaded=!0,e.isBlazor()||(this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),this.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),this.notify("toolbar",{prop:"enable-disable-btns"}))}},r.prototype.rotate=function(t){var e={isRotate:!1};return this.notify("transform",{prop:"rotate",value:{degree:t,obj:e}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),e.isRotate},r.prototype.export=function(t,e){this.notify("export",{prop:"export",onPropertyChange:!1,value:{type:t,fileName:e}})},r.prototype.select=function(t,e,i,o,r){this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:t,startX:e,startY:i,width:o,height:r}})},r.prototype.freeHandDraw=function(t){this.notify("freehand-draw",{prop:"freeHandDraw",onPropertyChange:!1,value:{value:t}})},r.prototype.freehandDraw=function(t){!this.disabled&&this.isImageLoaded&&this.freeHandDraw(t)},r.prototype.pan=function(t){this.notify("transform",{prop:"pan",onPropertyChange:!1,value:{value:t}})},r.prototype.zoom=function(t,e){this.notify("transform",{prop:"zoom",onPropertyChange:!1,value:{zoomFactor:t,zoomPoint:e}})},r.prototype.drawEllipse=function(t,i,o,r,a,n,s){var l=!1,p=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(p||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(l=!0,this.notify("shape",{prop:"drawEllipse",onPropertyChange:!1,value:{x:t,y:i,radiusX:o,radiusY:r,strokeWidth:a,strokeColor:n,fillColor:s}})),l},r.prototype.drawLine=function(t,i,o,r,a,n){var s=!1,l=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(l||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(s=!0,this.notify("shape",{prop:"drawLine",onPropertyChange:!1,value:{startX:t,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n}})),s},r.prototype.drawArrow=function(t,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(h||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawArrow",onPropertyChange:!1,value:{startX:t,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n,arrowStart:s,arrowEnd:l}})),p},r.prototype.drawPath=function(t,i,o){this.isPublicMethod=!0;var r={inRange:!1},a=!1;if(t&&t.length>0)for(var n=0;n<t.length&&!r.inRange;n++)this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:t[n].x,y:t[n].y,obj:r}});return!this.disabled&&this.isImageLoaded&&(r.inRange||e.isNullOrUndefined(t))&&(a=!0,this.notify("shape",{prop:"drawPath",onPropertyChange:!1,value:{pointColl:t,strokeWidth:i,strokeColor:o}})),a},r.prototype.drawRectangle=function(t,i,o,r,a,n,s){var l=!1,p=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(p||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(l=!0,this.notify("shape",{prop:"drawRectangle",onPropertyChange:!1,value:{x:t,y:i,width:o,height:r,strokeWidth:a,strokeColor:n,fillColor:s}})),l},r.prototype.drawText=function(t,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(t,i);return!this.disabled&&this.isImageLoaded&&(h||e.isNullOrUndefined(t)&&e.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawText",onPropertyChange:!1,value:{x:t,y:i,text:o,fontFamily:r,fontSize:a,bold:n,italic:s,color:l}})),p},r.prototype.selectShape=function(t){var e={isSelected:!1};return this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:t,obj:e}}),e.isSelected},r.prototype.deleteShape=function(t){this.notify("shape",{prop:"deleteShape",onPropertyChange:!1,value:{id:t}})},r.prototype.getShapeSetting=function(t){var e={};return this.notify("shape",{prop:"getShapeSetting",onPropertyChange:!1,value:{id:t,obj:e}}),e},r.prototype.getShapeSettings=function(){var t={shapeDetailsColl:[]};return this.notify("shape",{prop:"getShapeSettings",onPropertyChange:!1,value:{obj:t}}),t.shapeDetailsColl},r.prototype.update=function(){this.notify("transform",{prop:"update"})},r.prototype.finetuneImage=function(t,e){!this.disabled&&this.isImageLoaded&&this.notify("filter",{prop:"finetuneImage",value:{value:e,option:t}})},r.prototype.applyImageFilter=function(t){!this.disabled&&this.isImageLoaded&&(this.notify("filter",{prop:"applyImageFilter",value:{option:t.toString()}}),this.canvasFilter=this.lowerContext.filter,this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))},r.prototype.undo=function(){this.notify("undo-redo",{prop:"undo",onPropertyChange:!1})},r.prototype.redo=function(){this.notify("undo-redo",{prop:"redo",onPropertyChange:!1})},r.prototype.getImageDimension=function(){return{x:this.img.destLeft,y:this.img.destTop,width:this.img.destWidth,height:this.img.destHeight}},r.prototype.toolbarTemplateFn=function(){var t,e=this.element.id+"_toolbar",i=this.element.querySelector("#"+this.element.id+"_toolbarArea");if(this.toolbarTemplate){if(this.toolbarFn=this.templateParser(this.toolbarTemplate),this.isReact)t=this.toolbarFn({type:"toolbar"},this,"Template",e)[0];else if(this.isAngular){var o=this.toolbarFn({type:"toolbar"},this,"Template",e);t=3===o[0].nodeType?o[1]:o[0]}else t=this.toolbarFn({type:"toolbar"},this,"Template",e)[0];i.appendChild(t),this.toolbarHeight=i.clientHeight,this.notify("toolbar",{prop:"setToolbarHeight",value:{height:this.toolbarHeight}}),this.renderReactTemplates()}},r.prototype.quickAccessToolbarTemplateFn=function(){var t,e=this.element.id+"_quickAccessToolbar",i=this.element.querySelector("#"+this.element.id+"_quickAccessToolbarArea");if(this.quickAccessToolbarTemplate){if(this.qatFn=this.templateParser(this.quickAccessToolbarTemplate),this.isReact)t=this.qatFn({type:"toolbar"},this,"Template",e)[0];else if(this.isAngular){var o=this.qatFn({type:"toolbar"},this,"Template",e);t=3===o[0].nodeType?o[1]:o[0]}else t=this.qatFn({type:"toolbar"},this,"Template",e)[0];i.appendChild(t),this.renderReactTemplates()}},r.prototype.templateParser=function(t){if(t)try{return"function"!=typeof t&&document.querySelectorAll(t).length?e.compile(document.querySelector(t).innerHTML.trim()):e.compile(t)}catch(i){return e.compile(t)}},r.prototype.getTextFromId=function(t){return{1:"none",2:"bar",3:"arrow",4:"arrowSolid",5:"circle",6:"circleSolid",7:"square",8:"squareSolid"}[""+t]},r.prototype.getFinetuneOption=function(e){return{brightness:t.ImageFinetuneOption.Brightness,contrast:t.ImageFinetuneOption.Contrast,hue:t.ImageFinetuneOption.Hue,saturation:t.ImageFinetuneOption.Saturation,opacity:t.ImageFinetuneOption.Opacity,blur:t.ImageFinetuneOption.Blur,exposure:t.ImageFinetuneOption.Exposure}[""+e]},r.prototype.setPenStroke=function(t){this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:parseInt(t,10)}})},r.prototype.updateFreehandDrawColorChange=function(){var t={tempFreeHandDrawEditingStyles:null};this.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:t}}),this.notify("freehand-draw",{prop:"color-change",value:{color:t.tempFreeHandDrawEditingStyles.strokeColor}})},r.prototype.setInitialZoomState=function(){this.objColl.push(this.activeObj),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1});var t=this.isUndoRedo;this.isCropTab=!1,this.isUndoRedo=!0,this.transform.cropZoomFactor&&this.transform.cropZoomFactor>0?this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.cropZoomFactor,zoomPoint:null}}):this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(this.transform.cropZoomFactor),zoomPoint:null}}),this.isUndoRedo=t,this.panPoint.totalPannedPoint={x:0,y:0},this.transform.cropZoomFactor=0,this.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.activeObj=e.extend({},this.objColl[this.objColl.length-1],{},!0),this.objColl.pop(),this.isCropTab=!0,this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})},r.prototype.updateCropTransformItems=function(){this.prevCurrSelectionPoint=e.extend({},this.currSelectionPoint,{},!0);var t={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:t}});var i=t.currObj;i.objColl=e.extend([],this.objColl,[],!0),i.pointColl=e.extend([],this.pointColl,[],!0),i.afterCropActions=e.extend([],this.afterCropActions,[],!0);var o={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),i.selPointColl=e.extend([],o.selPointColl,[],!0),this.cancelCropSelection={operation:"cropTransform",previousObj:i,currentObj:i,previousObjColl:i.objColl,currentObjColl:i.objColl,previousPointColl:i.pointColl,currentPointColl:i.pointColl,previousSelPointColl:i.selPointColl,currentSelPointColl:i.selPointColl,previousCropObj:e.extend({},this.cropObj,{},!0),currentCropObj:e.extend({},this.cropObj,{},!0),previousText:null,currentText:null,filter:null,isCircleCrop:this.isCircleCrop}},r.prototype.toPascalCase=function(t,i){var o=[];e.isNullOrUndefined(t)||(o=t.toLowerCase().split("-"));for(var r=0;r<o.length;r++)o[r]=o[r].charAt(0).toUpperCase()+o[r].slice(1);return i&&(i.maxText=o.join("")),o.join("")},r.prototype.getFontSizes=function(){var t=[];this.fontSizeColl=[];var e;e=0===this.transform.degree||this.transform.degree%180==0?this.img.destWidth/25:this.img.destHeight/25;for(var i=1;i<=10;i++)this.fontSizeColl.push({text:(i*Math.round(e/2)).toString()}),t.push({text:i.toString()});return t},r.prototype.okBtn=function(t){var i,o=!1;void 0!==this.activeObj.shape&&(i=this.activeObj.shape.split("-")),void 0===i&&this.currObjType.isCustomCrop?o=!0:void 0!==i&&"crop"===i[0]&&(o=!0);var r=this.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected"),a={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),r&&(this.currentFilter=r.children[0].children[0].id.replace("Canvas","")),o)this.crop();else if(this.togglePen)this.freeHandDraw(!1),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if("block"===this.textArea.style.display)this.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e.isNullOrUndefined(t)&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if(!e.isBlazor()&&document.querySelector("#"+this.element.id+"_sliderWrapper")||e.isBlazor()&&!this.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||this.currObjType.isFiltered){this.initialAdjustmentValue=this.canvasFilter=this.lowerContext.filter,this.currObjType.isFiltered=!1;var n={value:null};this.notify("draw",{prop:"getTempAdjustmentValue",value:{obj:n}}),n.value!==this.lowerContext.filter&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}else a.bool?(this.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}}),e.isBlazor()?this.updateToolbar(this.element,"destroyQuickAccessToolbar"):this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})):(0!==this.activeObj.activePoint.width&&0!==this.activeObj.activePoint.height||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)&&this.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:t}});e.isBlazor()||a.isCropToolbar||this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}}),this.notify("draw",{prop:"setNewPath",value:{bool:!1}}),this.isCropTab=!1,this.transform.zoomFactor=this.transform.defaultZoomFactor,this.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}})},r.prototype.setTempFilterProperties=function(){this.upperCanvas.style.display="block",this.cropSelectedState();var t={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:t}}),this.lowerContext.filter=this.initialAdjustmentValue,this.notify("draw",{prop:"setTempAdjustmentValue",value:{tempAdjustmentValue:this.lowerContext.filter}}),this.notify("filter",{prop:"setTempAdjustmentLevel",onPropertyChange:!1,value:{tempAdjustmentLevel:e.extend({},t.adjustmentLevel,{},!0)}}),this.notify("draw",{prop:"setTempFilter",value:{tempFilter:this.currentFilter}});var i={undoRedoStep:null};this.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}}),this.notify("draw",{prop:"setTempUndoRedoStep",value:{tempUndoRedoStep:i.undoRedoStep}})},r.prototype.cropSelectedState=function(){this.activeObj.shape&&"crop"===this.activeObj.shape.split("-")[0]&&this.okBtn()},r.prototype.getCurrentCanvasData=function(){var t=this.lowerContext.filter;this.lowerContext.filter=this.canvasFilter="none";var i=e.extend([],this.objColl,null,!0),o=e.extend([],this.pointColl,null,!0);this.objColl=[],this.pointColl=[],this.freehandCounter=0,this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}});var r=this.getImageData();return e.isBlazor()||(e.Browser.isDevice||this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!1}}),this.element.querySelector("#"+this.element.id+"_contextualToolbarArea").classList.remove("e-hide")),this.objColl=i,this.pointColl=o,this.freehandCounter=o.length,this.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=this.canvasFilter=t,r},r.prototype.setCurrAdjustmentValue=function(t,i){var o=this,r={finetune:this.getFinetuneOption(t),value:i,cancel:!1};if(e.isBlazor()&&this.events&&!0===this.events.finetuneValueChanging.hasDelegate)this.dotNetRef.invokeMethodAsync("OnFinetuneValueChangeAsync",r).then(function(e){e.cancel||o.notify("filter",{prop:"setCurrAdjValue",value:{type:t.toLowerCase(),value:i}})});else{if(this.trigger("finetuneValueChanging",r),r.cancel)return;this.notify("filter",{prop:"setCurrAdjValue",value:{type:t.toLowerCase(),value:i}})}},r.prototype.getSquarePointForPath=function(t){var e={startX:0,startY:0,endX:0,endY:0,width:0,height:0};if(t.pointColl.length>0){e={startX:t.pointColl[0].x,startY:t.pointColl[0].y,endX:t.pointColl[0].x,endY:t.pointColl[0].y};for(var i=1;i<t.pointColl.length;i++)t.pointColl[i].x<e.startX&&(e.startX=t.pointColl[i].x),t.pointColl[i].y<e.startY&&(e.startY=t.pointColl[i].y),t.pointColl[i].x>e.endX&&(e.endX=t.pointColl[i].x),t.pointColl[i].y>e.endY&&(e.endY=t.pointColl[i].y);e.width=e.endX-e.startX,e.height=e.endY-e.startY}return e},r.prototype.getSelectionType=function(t){return{CropCustom:"Custom",CropSquare:"Square",CropCircle:"Circle","Crop3:2":"3:2","Crop4:3":"4:3","Crop5:4":"5:4","Crop7:5":"7:5","Crop16:9":"16:9"}[""+t]},r.prototype.clearContext=function(t){t.clearRect(0,0,t.canvas.width,t.canvas.height),t.clearRect(0,0,t.canvas.height,t.canvas.width)},r.prototype.updateArrow=function(t,i){this.notify("shape",{prop:"pushActItemIntoObj"});var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0),this.objColl.pop(),"startArrow"===t?this.activeObj.start=this.getTextFromId(i):"endArrow"===t&&(this.activeObj.end=this.getTextFromId(i)),this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}),e.isBlazor()||(e.Browser.isDevice?document.getElementById(this.element.id+"_bottomToolbar")&&e.getComponent(this.element.id+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(this.element.id+"_toolbar")&&e.getComponent(this.element.id+"_toolbar","toolbar").refreshOverflow())},r.prototype.updateFontFamily=function(t){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend([],this.objColl,[],!0),o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var s=this.activeObj.textSettings.fontFamily;this.activeObj.textSettings.fontFamily=this.toPascalCase(t),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);var l=this.activeObj.activePoint.width+.25*this.activeObj.textSettings.fontSize;this.textArea.style.width=l+"px",this.textArea.style.fontFamily=this.toPascalCase(t),this.activeObj.textSettings.fontFamily=s,this.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}})}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var p=this.activeObj.textSettings.fontFamily=this.toPascalCase(t);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:p,fontSize:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:a,previousObjColl:i,previousPointColl:e.extend([],this.pointColl,[],!0),previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}},r.prototype.updateFontSize=function(t){var i=t;this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var s=this.activeObj.textSettings.fontSize;this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop();var l="";"bold"===this.textArea.style.fontWeight&&(l="bold "),"italic"===this.textArea.style.fontStyle&&(l="italic "),"bold"===this.textArea.style.fontWeight&&"italic"===this.textArea.style.fontStyle&&(l="italic bold "),this.upperContext.font=l+this.activeObj.textSettings.fontSize+"px "+this.textArea.style.fontFamily;var p=this.textArea.value.split("\n"),h={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:!0,text:null,obj:h}});var c=h.maxText,d=this.upperContext.measureText(c).width+.5*this.activeObj.textSettings.fontSize;this.textArea.style.width=d+"px",this.textArea.style.height=p.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize)+"px",this.activeObj.textSettings.fontSize=s,this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily,this.textArea.style.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10)+"px","georgia"===this.textArea.style.fontFamily&&(this.textArea.style.width=parseFloat(this.textArea.style.width)+parseFloat(this.textArea.style.fontSize)+"px")}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var v=this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:null,fontSize:v}}),this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily;var p=this.activeObj.keyHistory.split("\n"),h={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:null,text:null,obj:h}});var u=h.maxText,d=this.upperContext.measureText(u).width+.5*this.activeObj.textSettings.fontSize,g=p.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize);this.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:d,height:g}}),this.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:this.activeObj.activePoint,obj:this.activeObj,isMouseMove:null,x:null,y:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}},r.prototype.updateFontColor=function(t){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),"none"===this.textArea.style.display)this.activeObj.strokeSettings.strokeColor=t,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));else if("block"===this.textArea.style.display){this.textArea.style.color=t;var n=this.activeObj.strokeSettings.strokeColor;this.activeObj.strokeSettings.strokeColor=t,this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=n}else this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},r.prototype.updatePenStrokeWidth=function(t){var i=e.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.pointColl=i,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.setPenStroke(t);var s={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool){var l={penStrokeWidth:null};this.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:l}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:l.penStrokeWidth}});var p={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:p}}),this.pointColl[p.freehandSelectedIndex].strokeWidth=l.penStrokeWidth,this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}},r.prototype.updatePenStrokeColor=function(t){var i=e.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var o=e.extend({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=e.extend([],this.objColl,[],!0),a.pointColl=e.extend([],this.pointColl,[],!0),a.afterCropActions=e.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=e.extend([],n.selPointColl,[],!0),this.pointColl=i,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.activeObj.strokeSettings.strokeColor=t;var s={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool){var l={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:l}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.pointColl[l.freehandSelectedIndex].strokeColor=t,this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:t}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else this.togglePen||this.notify("selection",{prop:"redrawShape",value:{obj:this.activeObj}})},r.prototype.updateStrokeWidth=function(t){this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeWidth=parseInt(t,10),this.activeObj.strokeSettings.strokeWidth*=2,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})},r.prototype.updateStrokeColor=function(t){this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=t,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},r.prototype.updateFillColor=function(t){this.notify("shape",{prop:"pushActItemIntoObj"});var i=e.extend({},this.cropObj,{},!0),o={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=e.extend([],this.objColl,[],!0),r.pointColl=e.extend([],this.pointColl,[],!0),r.afterCropActions=e.extend([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=e.extend([],a.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.fillColor=t,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:this.activeObj.strokeSettings.fillColor,strokeWidth:null}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})},r.prototype.pascalToSplitWords=function(t){var i=(t=t.charAt(0).toUpperCase()+t.slice(1)).match(/[A-Z][a-z]+/g);return e.isNullOrUndefined(i)?t:i.map(function(t){return t.charAt(0).toUpperCase()+t.slice(1)}).join(" ")},r.prototype.getCurrAdjustmentValue=function(t){var e={adjustmentLevel:null};return this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:e}}),{brightness:e.adjustmentLevel.brightness,contrast:e.adjustmentLevel.contrast,hue:e.adjustmentLevel.hue,saturation:e.adjustmentLevel.saturation,opacity:e.adjustmentLevel.opacity,blur:e.adjustmentLevel.blur,exposure:e.adjustmentLevel.exposure}[""+t]},r.prototype.transformSelect=function(t){this.isCropToolbar=!0,this.setInitialZoomState();var i=e.extend({},this.activeObj,{},!0);this.cropSelectedState(),this.notify("draw",{prop:"resetCurrentSelectionPoint"}),this.notify("transform",{prop:"performTransformation",value:{text:t}}),this.notify("draw",{prop:"moveToSelectionRange",value:{type:t,activeObj:i}}),this.isCropToolbar=!1},r.prototype.getDefaultFilter=function(){return"brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},r.prototype.initializeImageEditor=function(t,o){this.element=t;var r=this.element.querySelector(".e-canvas-wrapper");this.element.querySelector("#"+this.element.id+"_toolbarArea")?this.toolbarHeight=this.element.querySelector("#"+this.element.id+"_toolbarArea").clientHeight:this.toolbarHeight=0,r.style.height=this.element.offsetHeight-this.toolbarHeight-2+"px",r.style.width=this.element.offsetWidth-2+"px",this.lowerCanvas=this.element.querySelector(".e-lower-canvas"),this.upperCanvas=this.element.querySelector(".e-upper-canvas"),this.lowerCanvas.id=this.element.id+"_lowerCanvas",this.upperCanvas.id=this.element.id+"_upperCanvas",this.textArea=this.element.querySelector(".e-textbox"),this.inMemoryCanvas=this.createElement("canvas",{id:this.element.id+"_inMemoryCanvas",attrs:{name:"canvasImage"}}),this.upperCanvas.width=this.lowerCanvas.width=this.inMemoryCanvas.width=this.element.offsetWidth,this.upperCanvas.height=this.lowerCanvas.height=this.inMemoryCanvas.height=this.element.offsetHeight-this.toolbarHeight,this.lowerContext=this.lowerCanvas.getContext("2d"),this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),o&&(this.dotNetRef=o),this.prerender(),this.wireEvent(),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.canvasFilter=this.initialAdjustmentValue=this.lowerContext.filter,this.cssClass&&e.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},r.prototype.prerender=function(){this.element.id=this.element.id||e.getUniqueID("ej2-image-editor"),e.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},r.prototype.initializeZoomSettings=function(){e.isNullOrUndefined(this.zoomSettings.zoomTrigger)&&(this.zoomSettings.zoomTrigger=t.ZoomTrigger.MouseWheel|t.ZoomTrigger.Pinch|t.ZoomTrigger.Toolbar|t.ZoomTrigger.Commands),e.isNullOrUndefined(this.selectionSettings.strokeColor)&&(this.selectionSettings.strokeColor=this.themeColl[this.theme].primaryColor),e.isNullOrUndefined(this.selectionSettings.fillColor)&&(this.selectionSettings.fillColor=this.themeColl[this.theme].secondaryColor)},r.prototype.initializeThemeColl=function(){this.themeColl={Bootstrap5:{primaryColor:"#0d6efd",secondaryColor:"#fff"},Bootstrap5Dark:{primaryColor:"#0d6efd",secondaryColor:"#fff"},Tailwind:{primaryColor:"#4f46e5",secondaryColor:"#fff"},TailwindDark:{primaryColor:"#22d3ee",secondaryColor:"#fff"},Fluent:{primaryColor:"#0078d4",secondaryColor:"#fff"},FluentDark:{primaryColor:"#0078d4",secondaryColor:"#fff"},Bootstrap4:{primaryColor:"#007bff",secondaryColor:"#fff"},Bootstrap:{primaryColor:"#317ab9",secondaryColor:"#fff"},BootstrapDark:{primaryColor:"#317ab9",secondaryColor:"#fff"},Material:{primaryColor:"#e3165b",secondaryColor:"#fff"},MaterialDark:{primaryColor:"#00b0ff",secondaryColor:"#fff"},Fabric:{primaryColor:"#0078d6",secondaryColor:"#fff"},FabricDark:{primaryColor:"#0074cc",secondaryColor:"#fff"},Highcontrast:{primaryColor:"#000000",secondaryColor:"#fff"},Material3:{primaryColor:"#6750a4",secondaryColor:"#fff"},Material3Dark:{primaryColor:"#d0bcff",secondaryColor:"#fff"}}},r.prototype.updateToolbar=function(t,e,i){};var a;return b([e.Property("")],r.prototype,"cssClass",void 0),b([e.Property(!1)],r.prototype,"disabled",void 0),b([e.Property("100%")],r.prototype,"height",void 0),b([e.Property("Bootstrap5")],r.prototype,"theme",void 0),b([e.Property()],r.prototype,"toolbar",void 0),b([e.Property()],r.prototype,"toolbarTemplate",void 0),b([e.Property("100%")],r.prototype,"width",void 0),b([e.Property(!0)],r.prototype,"allowUndoRedo",void 0),b([e.Property(!0)],r.prototype,"showQuickAccessToolbar",void 0),b([e.Property()],r.prototype,"quickAccessToolbarTemplate",void 0),b([e.Property(!1)],r.prototype,"isReadOnly",void 0),b([e.Property(!1)],r.prototype,"enableRtl",void 0),b([e.Property(!1)],r.prototype,"enablePersistence",void 0),b([e.Complex({},C)],r.prototype,"finetuneSettings",void 0),b([e.Complex({},f)],r.prototype,"zoomSettings",void 0),b([e.Complex({},m)],r.prototype,"selectionSettings",void 0),b([e.Event()],r.prototype,"beforeSave",void 0),b([e.Event()],r.prototype,"created",void 0),b([e.Event()],r.prototype,"destroyed",void 0),b([e.Event()],r.prototype,"zooming",void 0),b([e.Event()],r.prototype,"panning",void 0),b([e.Event()],r.prototype,"cropping",void 0),b([e.Event()],r.prototype,"rotating",void 0),b([e.Event()],r.prototype,"flipping",void 0),b([e.Event()],r.prototype,"shapeChanging",void 0),b([e.Event()],r.prototype,"selectionChanging",void 0),b([e.Event()],r.prototype,"fileOpened",void 0),b([e.Event()],r.prototype,"saved",void 0),b([e.Event()],r.prototype,"toolbarCreated",void 0),b([e.Event()],r.prototype,"toolbarUpdating",void 0),b([e.Event()],r.prototype,"toolbarItemClicked",void 0),b([e.Event()],r.prototype,"imageFiltering",void 0),b([e.Event()],r.prototype,"finetuneValueChanging",void 0),b([e.Event()],r.prototype,"click",void 0),b([e.Event()],r.prototype,"quickAccessToolbarOpen",void 0),b([e.Event()],r.prototype,"quickAccessToolbarItemClick",void 0),r=a=b([e.NotifyPropertyChanges],r)}(e.Component);!function(t){t.Png="Png",t.Jpeg="Jpeg",t.Svg="Svg"}(t.FileType||(t.FileType={})),function(t){t.Horizontal="Horizontal",t.Vertical="Vertical"}(t.Direction||(t.Direction={})),function(t){t.Rectangle="Rectangle",t.Ellipse="Ellipse",t.Line="Line",t.Arrow="Arrow",t.Path="Path",t.Text="Text",t.FreehandDraw="FreehandDraw"}(t.ShapeType||(t.ShapeType={})),function(t){t[t.MouseWheel=1]="MouseWheel",t[t.Pinch=2]="Pinch",t[t.Commands=4]="Commands",t[t.Toolbar=8]="Toolbar"}(t.ZoomTrigger||(t.ZoomTrigger={})),function(t){t.Bootstrap5="Bootstrap5",t.Bootstrap5Dark="Bootstrap5Dark",t.Tailwind="Tailwind",t.TailwindDark="TailwindDark",t.Fluent="Fluent",t.FluentDark="FluentDark",t.Bootstrap4="Bootstrap4",t.Bootstrap="Bootstrap",t.BootstrapDark="BootstrapDark",t.Material="Material",t.MaterialDark="MaterialDark",t.Fabric="Fabric",t.FabricDark="FabricDark",t.Highcontrast="Highcontrast"}(t.Theme||(t.Theme={})),function(t){t.Crop="Crop",t.Transform="Transform",t.Annotate="Annotate",t.ZoomIn="ZoomIn",t.ZoomOut="ZoomOut",t.Open="Open",t.Reset="Reset",t.Save="Save",t.Pan="Pan",t.Move="Move",t.Pen="Pen",t.Line="Line",t.Arrow="Arrow",t.Path="Path",t.Rectangle="Rectangle",t.Ellipse="Ellipse",t.Text="Text",t.CustomSelection="CustomSelection",t.CircleSelection="CircleSelection",t.SquareSelection="SquareSelection",t.RatioSelection="RatioSelection",t.RotateLeft="RotateLeft",t.RotateRight="RotateRight",t.FlipHorizontal="FlipHorizontal",t.FlipVertical="FlipVertical"}(t.ImageEditorCommand||(t.ImageEditorCommand={})),function(t){t.Default="Default",t.Chrome="Chrome",t.Cold="Cold",t.Warm="Warm",t.Grayscale="Grayscale",t.Sepia="Sepia",t.Invert="Invert"}(t.ImageFilterOption||(t.ImageFilterOption={})),function(t){t.Brightness="Brightness",t.Contrast="Contrast",t.Hue="Hue",t.Saturation="Saturation",t.Exposure="Exposure",t.Opacity="Opacity",t.Blur="Blur"}(t.ImageFinetuneOption||(t.ImageFinetuneOption={})),function(t){t.None="None",t.Arrow="Arrow",t.SolidArrow="SolidArrow",t.Circle="Circle",t.SolidCircle="SolidCircle",t.Square="Square",t.SolidSquare="SolidSquare",t.Bar="Bar"}(t.ArrowheadType||(t.ArrowheadType={}));var P=function(){function n(t){this.defToolbarItems=[],this.toolbarHeight=46,this.currToolbar="",this.preventZoomBtn=!1,this.currentToolbar="main",this.selFhdColor="#42a5f5",this.preventEnableDisableUr=!1,this.parent=t,this.addEventListener(),this.initLocale()}return n.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},n.prototype.addEventListener=function(){this.parent.on("toolbar",this.toolbar,this),this.parent.on("destroyed",this.destroy,this)},n.prototype.removeEventListener=function(){this.parent.off("toolbar",this.toolbar),this.parent.off("destroyed",this.destroy)},n.prototype.initLocale=function(){this.defaultLocale={Crop:"Crop",ZoomIn:"Zoom In",ZoomOut:"Zoom Out",Undo:"Undo",Redo:"Redo",Transform:"Transform",Annotation:"Annotation",Finetune:"Finetune",Brightness:"Brightness",Contrast:"Contrast",Hue:"Hue",Saturation:"Saturation",Opacity:"Opacity",Blur:"Blur",Sharpen:"Sharpen",Exposure:"Exposure",Filter:"Filter",Default:"Default",Chrome:"Chrome",Cold:"Cold",Warm:"Warm",Grayscale:"Grayscale",BlackAndWhite:"Black and White",Sepia:"Sepia",Invert:"Invert",Text:"Add Text",Pen:"Pen",Reset:"Reset",Save:"Save",Select:"Select",RotateLeft:"Rotate Left",RotateRight:"Rotate Right",HorizontalFlip:"Horizontal Flip",VerticalFlip:"Vertical Flip",OK:"OK",Cancel:"Cancel",FillColor:"Fill Color",StrokeColor:"Stroke Color",StrokeWidth:"Stroke Width",FontFamily:"Font Family",FontStyle:"Font Style",FontSize:"Font Size",FontColor:"Font Color",Pan:"Pan",Move:"Move",Load:"Load",Custom:"Custom",Square:"Square",Circle:"Circle",Ellipse:"Ellipse",Rectangle:"Rectangle",Line:"Line",Arrow:"Arrow",Path:"Path",Bold:"Bold",Italic:"Italic",BoldItalic:"Bold Italic",XSmall:"X-Small",Small:"Small",Medium:"Medium",Large:"Large",XLarge:"X-Large",ABC:"ABC",Browse:"Browse",Duplicate:"Duplicate",Remove:"Remove",EditText:"Edit Text",Start:"Start",End:"End",Bar:"Bar",ArrowSolid:"Arrow Solid",CircleSolid:"Circle Solid",SquareSolid:"Square Solid",None:"None",CropAndTransform:"Crop and Transform",CropSelection:"Crop Selection"},this.l10n=new e.L10n("image-editor",this.defaultLocale,this.parent.locale)},n.prototype.toolbar=function(t){var e=this.parent;switch(this.updatePrivateVariables(),t.prop){case"create-toolbar":this.createToolbar();break;case"create-contextual-toolbar":this.createContextualToolbar();break;case"update-toolbar-items":this.updateToolbarItems();break;case"refresh-toolbar":this.refreshToolbar(t.value.type,t.value.isApplyBtn,t.value.isCropping,t.value.isZooming,t.value.cType);break;case"renderQAT":this.renderQAT(t.value.isPenEdit);break;case"enable-disable-btns":this.enableDisableTbrBtn();break;case"init-main-toolbar":this.initMainToolbar(t.value.isApplyBtn,t.value.isDevice,t.value.isOkBtn);break;case"create-bottom-toolbar":this.createBottomToolbar();break;case"refresh-main-toolbar":this.refreshMainToolbar();break;case"create-qa-toolbar":this.createQuickAccessToolbar();break;case"destroy-qa-toolbar":this.destroyQuickAccessToolbar();break;case"zoom-up-handler":this.zoomBtnMouseUpHandler();break;case"refresh-dropdown-btn":this.refreshDropDownBtn(t.value.isDisabled);break;case"close-contextual-toolbar":this.closeContextualToolbar();break;case"destroy-bottom-toolbar":this.destroyBottomToolbar();break;case"destroy-top-toolbar":this.destroyTopToolbar();break;case"destroySubComponents":this.destroySubComponents();break;case"setLocale":this.l10n.setLocale(t.value.locale);break;case"setPreventZoomBtn":this.preventZoomBtn=t.value.isPrevent;break;case"getToolbarHeight":t.value.obj.toolbarHeight=this.toolbarHeight;break;case"setToolbarHeight":this.toolbarHeight=t.value.height;break;case"setCurrentToolbar":this.currentToolbar=t.value.type;break;case"setSelectedFreehandColor":this.selFhdColor=t.value.color;break;case"getCurrentFilter":t.value.obj.currentFilter=e.currentFilter;break;case"setCurrentFilter":e.currentFilter=t.value.filter;break;case"setInitialAdjustmentValue":e.initialAdjustmentValue=t.value.value;break;case"getCanvasFilter":t.value.obj.canvasFilter=e.canvasFilter;break;case"getDefToolbarItems":t.value.obj.defToolbarItems=this.defToolbarItems;break;case"getPenStroke":this.getPenStroke(t.value.value);break;case"performDefToolbarClickAction":this.performDefTbrClick(t.value.type,t.value.isContextualToolbar,t.value.isDisabledAdjustment,t.value.isDisabledFilter,t.value.isFilterFinetune);break;case"setTempFilterProperties":e.setTempFilterProperties();break;case"refreshSlider":this.refreshSlider();break;case"renderSlider":this.renderSlider(t.value.type);break;case"getCurrAdjustmentValue":e.getCurrAdjustmentValue(t.value.type);break;case"setCurrAdjustmentValue":e.setCurrAdjustmentValue(t.value.type,t.value.value);break;case"refreshShapeDrawing":this.refreshShapeDrawing();break;case"getCropToolbar":t.value.obj.isCropToolbar=e.isCropToolbar;break;case"getPrevCurrSelectionPoint":t.value.obj.prevCurrSelectionPoint=e.prevCurrSelectionPoint;break;case"setPrevCurrSelectionPoint":e.prevCurrSelectionPoint=t.value.point;break;case"updateCropTransformItems":e.updateCropTransformItems();break;case"setEnableDisableUndoRedo":this.preventEnableDisableUr=t.value.isPrevent;break;case"reset":this.reset()}},n.prototype.updatePrivateVariables=function(){var t=this.parent;this.inMemoryCanvas=t.inMemoryCanvas,t.lowerCanvas&&(this.lowerContext=t.lowerCanvas.getContext("2d")),t.upperCanvas&&(this.upperContext=t.upperCanvas.getContext("2d")),this.inMemoryCanvas&&(this.inMemoryContext=this.inMemoryCanvas.getContext("2d"))},n.prototype.reset=function(){var t=this.parent;this.defToolbarItems=[],this.toolbarHeight=46,t.prevCurrSelectionPoint=null,this.zoomBtnHold=null,this.currToolbar="",this.currentToolbar="main",this.selFhdColor="#42a5f5",t.currentFilter="",this.preventZoomBtn=t.isCropToolbar=this.preventEnableDisableUr=!1,t.initialAdjustmentValue=t.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},n.prototype.destroyTopToolbar=function(){var t=this.parent,i=document.getElementById(t.element.id+"_toolbar");this.isToolbar()&&i&&i.classList.contains("e-control")&&e.getComponent(document.getElementById(t.element.id+"_toolbar"),"toolbar").destroy()},n.prototype.destroyBottomToolbar=function(){var t=this.parent,i=document.getElementById(t.element.id+"_bottomToolbar");i&&i.classList.contains("e-control")&&e.getComponent(document.getElementById(t.element.id+"_bottomToolbar"),"toolbar").destroy()},n.prototype.isToolbar=function(){var t=this.parent;return e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.length>0||!e.isNullOrUndefined(t.toolbarTemplate)},n.prototype.createToolbar=function(){var t=this,i=this.parent;if(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){i.element.appendChild(i.createElement("div",{id:i.element.id+"_toolbarArea",className:"e-toolbar-area"}));var r={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg"})};e.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(r);var n=document.getElementById(i.element.id+"_toolbarArea"),s=i.createElement("div",{id:i.element.id+"_toolbar"});n.appendChild(s);var l=[{cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",selected:function(){i.disabled||(e.Browser.isDevice?(t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(document.getElementById(i.element.id+"_bottomToolbar"),"toolbar").destroy(),t.initMainToolbar(!1,e.Browser.isDevice,null),t.createBottomToolbar()):(t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),t.initMainToolbar(!1,!1,null)))}})}];new o.Toolbar({items:l,width:"100%",created:function(){i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_toolbar"),this.createLeftToolbarControls(),document.getElementById(i.element.id+"_toolbar")&&(this.toolbarHeight=document.getElementById(i.element.id+"_toolbar").clientHeight)}else this.toolbarHeight=0},n.prototype.createContextualToolbar=function(){var t=this.parent;if(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.length>0){t.element.appendChild(t.createElement("div",{id:t.element.id+"_contextualToolbarArea",className:"e-contextual-toolbar-wrapper e-hide",attrs:{style:"position: absolute;"}}));var i=document.getElementById(t.element.id+"_contextualToolbarArea"),o=t.createElement("div",{id:t.element.id+"_contextualToolbar"});i.appendChild(o)}},n.prototype.createBottomToolbar=function(){var t=this.parent;if(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.length>0){if(t.element.appendChild(t.createElement("div",{id:t.element.id+"_bottomToolbarArea",className:"e-bottom-toolbar"})),!t.toolbarTemplate){document.getElementById(t.element.id+"_canvasWrapper").style.height=t.element.offsetHeight-2*this.toolbarHeight-3+"px";var i=document.getElementById(t.element.id+"_bottomToolbarArea"),o=t.createElement("div",{id:t.element.id+"_bottomToolbar"});i.appendChild(o)}this.initBottomToolbar()}},n.prototype.createQuickAccessToolbar=function(){var t=this.parent;if(t.showQuickAccessToolbar){var i={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg"})};e.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(i);var r=document.getElementById(t.element.id+"_quickAccessToolbarArea"),n=t.createElement("div",{id:t.element.id+"_quickAccessToolbar"});r.appendChild(n),new o.Toolbar({clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+t.element.id+"_quickAccessToolbar")}},n.prototype.initMainToolbar=function(t,i,r){var a=this,n=this.parent;if(this.isToolbar()){var s=this.getLeftToolbarItem(r),l=this.getRightToolbarItem(r),p=this.getMainToolbarItem(t),h=this.getZoomToolbarItem();this.defToolbarItems=i?s.concat(l):s.concat(p,l,h),new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i||a.renderAnnotationBtn(),a.wireZoomBtnEvents(),a.renderSaveBtn(),n.trigger("toolbarCreated",{toolbarType:"main"})}}).appendTo("#"+n.element.id+"_toolbar"),this.createLeftToolbarControls(),this.enableDisableTbrBtn(),this.isToolbar()&&document.getElementById(n.element.id+"_toolbar")&&e.getComponent(n.element.id+"_toolbar","toolbar").refreshOverflow()}},n.prototype.initBottomToolbar=function(){var t=this,i=this.parent;if(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){var r=this.getMainToolbarItem();new o.Toolbar({items:r,width:"100%",created:function(){t.renderAnnotationBtn(),t.renderCropBtn(),t.renderTransformBtn(),i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_bottomToolbar"),this.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}},n.prototype.getLeftToolbarItem=function(i){var o=this.parent,r=[];i||(r.push({id:o.element.id+"_upload",cssClass:"e-image-upload",align:"Left",type:"Input",template:new a.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg"})}),r.push({visible:!1,cssClass:"e-image-position e-btn e-flat",tooltipText:this.l10n.getConstant("Browse"),align:"Left"})),o.allowUndoRedo&&((e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Undo")>-1)&&r.push({id:o.element.id+"_undo",prefixIcon:"e-icons e-undo",cssClass:"top-icon e-undo",tooltipText:this.l10n.getConstant("Undo"),align:"Left"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Redo")>-1)&&r.push({id:o.element.id+"_redo",prefixIcon:"e-icons e-redo",cssClass:"top-icon e-redo",tooltipText:this.l10n.getConstant("Redo"),align:"Left"})),this.preventZoomBtn||(o.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)!==t.ZoomTrigger.Toolbar||((e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("ZoomOut")>-1)&&r.push({id:o.element.id+"_zoomOut",prefixIcon:"e-icons e-zoom-out",cssClass:"top-icon e-dec-zoom",tooltipText:this.l10n.getConstant("ZoomOut"),align:"Left"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("ZoomIn")>-1)&&r.push({id:o.element.id+"_zoomIn",prefixIcon:"e-icons e-zoom-in",cssClass:"top-icon e-inc-zoom",tooltipText:this.l10n.getConstant("ZoomIn"),align:"Left"}));for(var n=this.processToolbar("left"),s=0,l=n.length;s<l;s++)r.push(n[s]);return r},n.prototype.getRightToolbarItem=function(t){var i=this.parent,o=[];t&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Reset")>-1)&&o.push({id:i.element.id+"_reset",prefixIcon:"e-icons e-btn-reset",cssClass:"top-icon e-img-reset",tooltipText:this.l10n.getConstant("Reset"),align:"Right"}),t||(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Save")>-1)&&o.push({id:i.element.id+"_save",prefixIcon:"e-icons e-btn-save",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Save"),align:"Right",template:'<button id="'+i.element.id+'_saveBtn"></button>'});for(var r=this.processToolbar("right"),a=0,n=r.length;a<n;a++)o.push(r[a]);return o},n.prototype.getMainToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Crop")>-1)&&o.push({id:i.element.id+"_cropTransform",prefixIcon:"e-icons e-crop",cssClass:"top-icon e-crop",tooltipText:this.l10n.getConstant("CropAndTransform"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Annotate")>-1)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Finetune")>-1)&&o.push({id:i.element.id+"_adjustment",prefixIcon:"e-icons e-adjustment",cssClass:"top-icon e-adjustment",tooltipText:this.l10n.getConstant("Finetune"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Filter")>-1)&&o.push({id:i.element.id+"_filter",prefixIcon:"e-icons e-filters",cssClass:"top-icon e-filters",tooltipText:this.l10n.getConstant("Filter"),align:"Center"});for(var r=this.processToolbar("center"),a=0,n=r.length;a<n;a++)o.push(r[a]);return t&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.getZoomToolbarItem=function(){return[]},n.prototype.updateContextualToolbar=function(t,i){var o=this.parent,r=o.element.querySelector("#"+o.element.id+"_toolbarArea"),a=o.element.querySelector("#"+o.element.id+"_contextualToolbarArea");if(a.classList.remove("e-hide"),a.style.left=r.offsetLeft+"px","filter"===t?(document.getElementById(o.element.id+"_toolbar")&&this.defToolbarItems.length>0&&e.getComponent(document.getElementById(o.element.id+"_toolbar"),"toolbar").destroy(),e.Browser.isDevice?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!0,null,null),this.refreshSlider(),this.initFilterToolbarItem()):(document.querySelector("#"+o.element.id+"_contextualToolbar").classList.contains("e-control")&&e.getComponent(document.getElementById(o.element.id+"_contextualToolbar"),"toolbar").destroy(),this.refreshSlider(),this.renderSlider(i)),e.Browser.isDevice){var n=a.offsetHeight,s=o.element.querySelector("#"+o.element.id+"_canvasWrapper").offsetHeight;a.style.top=this.toolbarHeight+s-n+"px"}else a.style.top=this.toolbarHeight+"px"},n.prototype.processToolbar=function(t){var i=this.parent,o=[];if(i.toolbar)for(var r=0,a=i.toolbar.length;r<a;r++)"object"==typeof i.toolbar[r]&&(e.isNullOrUndefined(i.toolbar[r].align)?"left"===t&&o.push(i.toolbar[r]):i.toolbar[r].align.toLowerCase()===t&&o.push(i.toolbar[r]));return o},n.prototype.processSubToolbar=function(t){var e=[];if(t)for(var i=0,o=t.length;i<o;i++)"object"==typeof t[i]&&(t[i].align="Center",e.push(t[i]));return e},n.prototype.wireZoomBtnEvents=function(){var t=document.querySelector("#"+this.parent.element.id+"_zoomIn"),e=document.querySelector("#"+this.parent.element.id+"_zoomOut");t&&(t.addEventListener("mousedown",this.zoomInBtnMouseDownHandler.bind(this)),t.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),t.addEventListener("click",this.zoomInBtnClickHandler.bind(this)),t.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this))),e&&(e.addEventListener("mousedown",this.zoomOutBtnMouseDownHandler.bind(this)),e.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),e.addEventListener("click",this.zoomOutBtnClickHandler.bind(this)),t.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this)))},n.prototype.enableDisableTbrBtn=function(){var t=this.parent;if(!this.preventEnableDisableUr){var e={appliedUndoRedoColl:[]};t.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:e}});var i={undoRedoStep:null};t.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}});var o=document.querySelector("#"+t.element.id+"_undo");o&&0===i.undoRedoStep?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):o&&i.undoRedoStep>0&&(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay"));var r=document.querySelector("#"+t.element.id+"_redo");r&&i.undoRedoStep===e.appliedUndoRedoColl.length?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):r&&0===i.undoRedoStep&&e.appliedUndoRedoColl.length>0?(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")):r&&i.undoRedoStep>0&&(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay"))}var a=document.querySelector("#"+t.element.id+"_zoomIn");a&&t.zoomSettings.zoomFactor>=t.zoomSettings.maxZoomFactor?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):a&&(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay"));var n=document.querySelector("#"+t.element.id+"_zoomOut");n&&t.zoomSettings.zoomFactor<=t.zoomSettings.minZoomFactor?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):n&&(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay"));var s=document.querySelector("#"+t.element.id+"_pan");s&&t.zoomSettings.zoomFactor<=t.zoomSettings.minZoomFactor?s.style.display="none":s&&(s.style.display="block")},n.prototype.createLeftToolbarControls=function(){var t=this.parent;if(void 0!==this.defToolbarItems&&this.defToolbarItems.length>0&&document.getElementById(t.element.id+"_toolbar")){var e=document.getElementById(t.element.id+"_toolbar").querySelector(".e-image-upload");if(e){var i=e.getElementsByTagName("input")[0],o=e.getElementsByTagName("button")[0];o.className="e-tbar-btn e-tbtn-txt top-icon",o.innerHTML="",o.appendChild(t.createElement("span",{className:"e-btn-icon e-icons e-upload-icon e-icon-left"})),i.onchange=this.fileSelect.bind(this,i)}}},n.prototype.fileSelect=function(t,e){this.parent.notify("draw",{prop:"fileSelect",value:{inputElement:t,args:e}})},n.prototype.renderAnnotationBtn=function(t){var i=this,o=this.parent,a=[];(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Pen")>-1)&&a.push({text:this.l10n.getConstant("Pen"),id:"pen",iconCss:"e-icons e-free-pen"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Line")>-1)&&a.push({text:this.l10n.getConstant("Line"),id:"line",iconCss:"e-icons e-line"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Rectangle")>-1)&&a.push({text:this.l10n.getConstant("Rectangle"),id:"rectangle",iconCss:"e-icons e-rectangle"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Ellipse")>-1)&&a.push({text:this.l10n.getConstant("Ellipse"),id:"ellipse",iconCss:"e-icons e-circle"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Arrow")>-1)&&a.push({text:this.l10n.getConstant("Arrow"),id:"arrow",iconCss:"e-icons e-arrow-right-up"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Path")>-1)&&a.push({text:this.l10n.getConstant("Path"),id:"path",iconCss:"e-icons e-critical-path"}),(e.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Text")>-1)&&a.push({text:this.l10n.getConstant("Text"),id:"text",iconCss:"e-icons e-add-text"});var n={freehandDrawSelectedId:null};o.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:n}});var s=document.querySelector("#"+o.element.id+"_duplicate"),l=document.querySelector("#"+o.element.id+"_remove"),p=document.querySelector("#"+o.element.id+"_editText");0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&(e.isNullOrUndefined(o.activeObj.pointColl)||o.activeObj.pointColl&&0===o.activeObj.pointColl.length)&&e.isNullOrUndefined(n.freehandDrawSelectedId)?(s&&s.classList.add("e-disabled"),l&&l.classList.add("e-disabled"),p&&p.classList.add("e-disabled")):(s&&s.classList.remove("e-disabled"),l&&l.classList.remove("e-disabled"),p&&p.classList.remove("e-disabled"));var h=t?this.getCurrentShapeIcon(o.activeObj.shape):"e-annotation",c=new r.DropDownButton({items:a,iconCss:"e-icons "+h,cssClass:"e-image-popup",open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=c.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px"),o.activeObj.shape?document.getElementById(o.activeObj.shape).classList.add("e-selected"):o.togglePen&&document.getElementById("pen").classList.add("e-selected")},select:function(t){o.okBtn();var e,r=!1;void 0!==o.activeObj.shape&&(e=o.activeObj.shape.split("-")),void 0===e&&o.currObjType.isCustomCrop?r=!0:void 0!==e&&"crop"===e[0]&&(r=!0),o.currObjType.isCustomCrop=!1,(r||o.togglePan)&&(o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),i.refreshToolbar("main"));var a={currentFreehandDrawIndex:null};switch(o.notify("freehand-draw",{prop:"getCurrentFreehandDrawIndex",value:{obj:a}}),c.iconCss="e-icons "+i.getCurrentShapeIcon(t.item.id),t.item.id){case"pen":o.notify("draw",{prop:"setTempFreehandCounter",value:{tempFreehandCounter:o.freehandCounter}}),o.notify("draw",{prop:"setTempCurrentFreehandDrawIndex",value:{tempCurrentFreehandDrawIndex:a.currentFreehandDrawIndex}}),i.currentToolbar="pen",o.freeHandDraw(!0);break;case"text":i.currentToolbar="text",o.notify("shape",{prop:"draw-shape-text"});break;default:i.currentToolbar="shapes",i.setInitialShapeSettings(t),o.notify("selection",{prop:"annotate",value:{shape:t.item.id}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}i.updateToolbarItems()}});c.appendTo("#"+o.element.id+"_annotationBtn")},n.prototype.renderCropBtn=function(){var t=this,i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("CustomSelection")>-1)&&o.push({text:this.l10n.getConstant("Custom"),id:"custom",iconCss:"e-icons e-custom"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("CircleSelection")>-1)&&o.push({text:this.l10n.getConstant("Circle"),id:"circle",iconCss:"e-icons e-circle"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("SquareSelection")>-1)&&o.push({text:this.l10n.getConstant("Square"),id:"square",iconCss:"e-icons e-square"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("RatioSelection")>-1)&&(o.push({text:"3:2",id:"3:2",iconCss:"e-icons e-custom-a"}),o.push({text:"4:3",id:"4:3",iconCss:"e-icons e-custom-b"}),o.push({text:"5:4",id:"5:4",iconCss:"e-icons e-custom-c"}),o.push({text:"7:5",id:"7:5",iconCss:"e-icons e-custom-d"}),o.push({text:"16:9",id:"16:9",iconCss:"e-icons e-custom-e"}));var a,n;i.activeObj.shape?(a=this.getCurrentShapeIcon(i.activeObj.shape),n=i.activeObj.shape):i.currSelectionPoint?(a=this.getCurrentShapeIcon(i.currSelectionPoint.shape),n=i.currSelectionPoint.shape):(a="e-custom",n="custom");var s=new r.DropDownButton({open:function(o){i.togglePan&&t.cancelPan(),e.Browser.isDevice&&(o.element.parentElement.style.top=s.element.getBoundingClientRect().top-o.element.parentElement.offsetHeight+"px"),i.activeObj.shape&&i.activeObj.shape.split("-").length>1&&document.getElementById(i.activeObj.shape.split("-")[1]).classList.add("e-selected"),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},items:o,select:function(e){t.cropSelect(e),s.iconCss="e-icons "+t.getCurrentShapeIcon("crop-"+e.item.id),s.content=i.toPascalCase(e.item.id)},iconCss:"e-icons "+a,cssClass:"e-image-popup",content:i.toPascalCase(n.replace("crop-",""))});s.appendTo("#"+i.element.id+"_cropBtn")},n.prototype.renderTransformBtn=function(){var t=this.parent,i=[];(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("RotateLeft")>-1)&&i.push({text:this.l10n.getConstant("RotateLeft"),id:"rotateleft",iconCss:"e-icons e-anti-clock-wise"}),(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("RotateRight")>-1)&&i.push({text:this.l10n.getConstant("RotateRight"),id:"rotateright",iconCss:"e-icons e-clock-wise"}),(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("FlipHorizontal")>-1)&&i.push({text:this.l10n.getConstant("HorizontalFlip"),id:"horizontalflip",iconCss:"e-icons e-horizontal-flip"}),(e.isNullOrUndefined(t.toolbar)||t.toolbar&&t.toolbar.indexOf("FlipVertical")>-1)&&i.push({text:this.l10n.getConstant("VerticalFlip"),id:"verticalflip",iconCss:"e-icons e-vertical-flip"});var o=new r.DropDownButton({open:function(t){if(e.Browser.isDevice){var i=t.element.parentElement.offsetHeight;t.element.parentElement.style.display="none",t.element.parentElement.style.top=o.element.getBoundingClientRect().top-i+"px",t.element.parentElement.style.display="block"}},items:i,select:t.transformSelect.bind(this),iconCss:"e-icons e-transform",cssClass:"e-image-popup"});o.appendTo("#"+t.element.id+"_transformBtn")},n.prototype.renderSaveBtn=function(){var t=this.parent,e=[{text:"JPEG",id:"jpeg"},{text:"PNG",id:"png"},{text:"SVG",id:"svg"}];document.getElementById(t.element.id+"_saveBtn")&&new r.DropDownButton({items:e,cssClass:"e-caret-hide e-image-popup",iconCss:"e-icons e-save",select:function(e){t.export(e.item.text)}}).appendTo("#"+t.element.id+"_saveBtn")},n.prototype.getCropTransformToolbarItem=function(){var t=this.parent,i=[];return i.push({id:t.element.id+"_crop",tooltipText:this.l10n.getConstant("CropSelection"),align:"Center",template:'<button id="'+t.element.id+'_cropBtn"></button>'}),i.push({align:"Center",type:"Separator"}),i.push({id:t.element.id+"_rotateLeft",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),i.push({id:t.element.id+"_rotateRight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),i.push({align:"Center",type:"Separator"}),i.push({id:t.element.id+"_horizontalFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),i.push({id:t.element.id+"_verticalFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"}),e.Browser.isDevice||(i.push({id:t.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:t.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},n.prototype.getShapesToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),t.indexOf("fillColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_fillcolor",cssClass:"top-icon e-fill",tooltipText:this.l10n.getConstant("FillColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fillColorBtn"></button>'}),t.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_strokecolor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderColorBtn"></button>'}),t.indexOf("strokeWidth")>-1&&o.push({id:i.element.id+"_strokeWidth",cssClass:"top-icon e-size",tooltipText:"Stroke Width",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderWidthBtn"></button>'}),t.indexOf("start")>-1&&o.push({id:i.element.id+"_start",cssClass:"top-icon e-size",tooltipText:"Start",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_startBtn"></button>'}),t.indexOf("end")>-1&&o.push({id:i.element.id+"_end",cssClass:"top-icon e-size",tooltipText:"End",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_endBtn"></button>'}),o.push({align:"Center",type:"Separator"}),t.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),t.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"}),t.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center"});for(var r=this.processSubToolbar(t),a=0,n=r.length;a<n;a++)o.push(r[a]);if(!e.Browser.isDevice){var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"!==s.shape&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"}))}return o},n.prototype.initCropTransformToolbar=function(){var t=this,i=this.parent,r=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),n=this.getCropTransformToolbarItem(),s=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=r.concat(s,n,a);var l=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.renderCropBtn(),t.wireZoomBtnEvents(),e.Browser.isDevice||t.renderSaveBtn(),i.trigger("toolbarCreated",{toolbarType:"shapes"}),e.Browser.isDevice?t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&(l.refreshOverflow(),l.refreshOverflow(),l.refreshOverflow()):(t.createLeftToolbarControls(),t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow()),i.select("custom")}});e.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.getCurrentShapeIcon=function(t){var e="";switch(t){case"rectangle":e="e-rectangle";break;case"ellipse":e="e-circle";break;case"line":e="e-line";break;case"arrow":e="e-arrow-right-up";break;case"path":e="e-critical-path";break;case"text":e="e-add-text";break;case"pen":e="e-free-pen";break;case"crop-custom":e="e-custom";break;case"crop-circle":e="e-circle";break;case"crop-square":e="e-square";break;case"crop-3:2":e="e-custom-a";break;case"crop-4:3":e="e-custom-b";break;case"crop-5:4":e="e-custom-c";break;case"crop-7:5":e="e-custom-d";break;case"crop-16:9":e="e-custom-e";break;default:e="e-free-pen"}return e},n.prototype.initShapesToolbarItem=function(t){var i=this,r=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getShapesToolbarItem(t),l=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createShapeColor(t),i.createShapeBtn(t),"arrow"===r.activeObj.shape&&(i.createStartBtn(),i.createEndBtn()),i.wireZoomBtnEvents(),e.Browser.isDevice||i.renderSaveBtn(),r.trigger("toolbarCreated",{toolbarType:"shapes"}),e.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&p.refreshOverflow())}});e.Browser.isDevice?p.appendTo("#"+r.element.id+"_bottomToolbar"):p.appendTo("#"+r.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createShapeColor=function(t){var i=this.parent;if(t.indexOf("fillColor")>-1){i.element.querySelector(".e-template.e-fill").appendChild(i.createElement("input",{id:i.element.id+"_shape_fill"}));var o=new a.ColorPicker({modeSwitcher:!1,noColor:!0,value:"",showButtons:!1,mode:"Palette",cssClass:"e-shape-fill-color",change:function(t){i.updateFillColor(t.currentValue.hex),""===t.currentValue.rgba?n.element.children[0].classList.add("e-nocolor-item"):(n.element.children[0].classList.remove("e-nocolor-item"),n.element.children[0].style.backgroundColor=t.currentValue.rgba),n.toggle()}},"#"+i.element.id+"_shape_fill"),n=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fillColorBtn");o.inline=!0,i.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item")}if(t.indexOf("strokeColor")>-1){i.element.querySelector(".e-template.e-stroke").appendChild(i.createElement("input",{id:i.element.id+"_shape_stroke"}));var s=new a.ColorPicker({modeSwitcher:!1,noColor:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-shape-stroke-color",change:function(t){i.updateStrokeColor(t.currentValue.hex),l.element.children[0].style.backgroundColor=t.currentValue.rgba,l.toggle()}},"#"+i.element.id+"_shape_stroke"),l=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=l.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-stroke-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_borderColorBtn");s.inline=!0,i.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createShapeBtn=function(t){var i=this.parent,o=[{id:"1",text:this.l10n.getConstant("XSmall")},{id:"2",text:this.l10n.getConstant("Small")},{id:"3",text:this.l10n.getConstant("Medium")},{id:"4",text:this.l10n.getConstant("Large")},{id:"5",text:this.l10n.getConstant("XLarge")}];if(t.indexOf("strokeWidth")>-1){var a=document.getElementById(i.element.id+"_borderWidthBtn"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant("XSmall"),n.className="e-shape-stroke-width",a.appendChild(n);var s=new r.DropDownButton({items:o,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=s.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=n.innerHTML;""!==i&&t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){n.textContent=t.item.text,i.updateStrokeWidth(t.item.id),e.Browser.isDevice?document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i.element.id+"_toolbar")&&e.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}});s.appendTo("#"+i.element.id+"_borderWidthBtn")}},n.prototype.createStartBtn=function(){var t=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(t.element.id+"_startBtn"),a=document.createElement("span");e.isNullOrUndefined(t.activeObj.start)&&(t.activeObj.start="none"),a.innerHTML=t.pascalToSplitWords(t.activeObj.start),a.className="e-shape-start",o.appendChild(a);var n=new r.DropDownButton({items:i,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=a.innerHTML;""!==i&&t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){a.textContent=e.item.text,t.updateArrow("startArrow",e.item.id)}});n.appendTo("#"+t.element.id+"_startBtn")},n.prototype.createEndBtn=function(){var t=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(t.element.id+"_endBtn"),a=document.createElement("span");e.isNullOrUndefined(t.activeObj.end)&&(t.activeObj.end="arrowSolid"),a.innerHTML=t.pascalToSplitWords(t.activeObj.end),a.className="e-shape-end",o.appendChild(a);var n=new r.DropDownButton({items:i,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=a.innerHTML;""!==i&&t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){a.textContent=e.item.text,t.updateArrow("endArrow",e.item.id)}});n.appendTo("#"+t.element.id+"_endBtn")},n.prototype.getTextToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),t.indexOf("fontFamily")>-1&&o.push({id:i.element.id+"_fontFamily",cssClass:"top-icon e-img-font-family",tooltipText:this.l10n.getConstant("FontFamily"),align:"Center",template:'<button id="'+i.element.id+'_fontFamilyBtn"></button>'}),t.indexOf("fontSize")>-1&&o.push({id:i.element.id+"_fontSize",cssClass:"top-icon e-img-font-size",tooltipText:this.l10n.getConstant("FontSize"),align:"Center",template:'<button id="'+i.element.id+'_fontSizeBtn"></button>'}),t.indexOf("fontColor")>-1&&o.push({cssClass:"top-icon e-text-font-color",id:i.element.id+"_text_strokecolor",tooltipText:this.l10n.getConstant("FontColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fontColorBtn"></button>'}),t.indexOf("bold")>-1&&o.push({id:i.element.id+"_bold",prefixIcon:"e-icons e-bold",cssClass:"top-icon e-bold",tooltipText:this.l10n.getConstant("Bold"),align:"Center"}),t.indexOf("italic")>-1&&o.push({id:i.element.id+"_italic",prefixIcon:"e-icons e-italic",cssClass:"top-icon e-italic",tooltipText:this.l10n.getConstant("Italic"),align:"Center"}),o.push({align:"Center",type:"Separator"}),t.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),t.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"}),t.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center"});for(var r=this.processSubToolbar(t),a=0,n=r.length;a<n;a++)o.push(r[a]);return e.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.getFontFamilyItems=function(){return e.Browser.isDevice?[{id:"arial",text:"ABC"},{id:"calibri",text:"ABC"},{id:"georgia",text:"ABC"},{id:"roboto",text:"ABC"},{id:"tahoma",text:"ABC"}]:[{id:"arial",text:"Arial"},{id:"calibri",text:"Calibri"},{id:"georgia",text:"Georgia"},{id:"roboto",text:"Roboto"},{id:"tahoma",text:"Tahoma"}]},n.prototype.initTextToolbarItem=function(t){var i=this,r=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getTextToolbarItem(t),l=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createTextColor(t),i.createTextBtn(t),i.wireZoomBtnEvents(),e.Browser.isDevice||i.renderSaveBtn(),r.trigger("toolbarCreated",{toolbarType:"text"}),e.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&p.refreshOverflow())}});e.Browser.isDevice?p.appendTo("#"+r.element.id+"_bottomToolbar"):p.appendTo("#"+r.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createTextColor=function(t){var i=this.parent;if(t.indexOf("fontColor")>-1&&i.element.querySelector(".e-template.e-text-font-color")){i.element.querySelector(".e-template.e-text-font-color").appendChild(i.createElement("input",{id:i.element.id+"_text_font"}));var o=new a.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",change:function(t){i.updateFontColor(t.currentValue.hex),n.element.children[0].style.backgroundColor=t.currentValue.rgba,n.toggle()}},"#"+i.element.id+"_text_font"),n=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fontColorBtn");o.inline=!0,i.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createTextBtn=function(t){var i=this.parent;if(t.indexOf("fontFamily")>-1){var o=document.getElementById(i.element.id+"_fontFamilyBtn"),a=document.createElement("span");e.Browser.isDevice?(a.innerHTML="ABC",a.setAttribute("style","font-family: arial")):a.innerHTML="Arial",a.className="e-text-font-family",o&&o.appendChild(a);var n=new r.DropDownButton({items:this.getFontFamilyItems(),cssClass:"e-font-family",createPopupOnClick:!0,beforeItemRender:function(t){t.element.setAttribute("style","font-family:"+t.element.id)},open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var o;o="block"===i.textArea.style.display?i.textArea.style.fontFamily:i.activeObj.textSettings.fontFamily,t.element.querySelector('[id *= "'+o.toLowerCase()+'"]').classList.add("e-selected-btn")},select:function(t){a.textContent=t.item.text,e.Browser.isDevice&&a.setAttribute("style","font-family:"+t.item.id),i.updateFontFamily(t.item.id)}});n.appendTo("#"+i.element.id+"_fontFamilyBtn")}if(t.indexOf("fontSize")>-1){var s=document.getElementById(i.element.id+"_fontSizeBtn"),l=document.createElement("span"),p=i.getFontSizes();l.innerHTML=p[0].text,l.className="e-text-font-size",s.appendChild(l);var h=new r.DropDownButton({cssClass:"e-font-size",items:p,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=h.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=l.innerHTML;t.element.querySelector('[aria-label *= "'+i+'"]').classList.add("e-selected-btn")},select:function(t){l.textContent=t.item.text,i.updateFontSize(t.item.text)}});h.appendTo("#"+i.element.id+"_fontSizeBtn")}},n.prototype.refreshToolbar=function(t,i,o,r,a){var n=this.parent;if(n.isImageLoaded&&!n.isCropToolbar){var s={toolbarType:"shapes"===t&&n.activeObj.shape?n.activeObj.shape:t};switch("filter"!==t&&"color"!==t&&(document.getElementById(n.element.id+"_toolbar")&&this.defToolbarItems.length>0&&(e.getComponent(document.getElementById(n.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_toolbar").innerHTML=""),document.getElementById(n.element.id+"_bottomToolbar")&&this.defToolbarItems.length>0&&document.getElementById(n.element.id+"_bottomToolbar").className.indexOf("e-control")>-1&&(e.getComponent(document.getElementById(n.element.id+"_bottomToolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_bottomToolbar").innerHTML="")),this.refreshSlider(),n.isCropTab=!1,t){case"main":e.Browser.isDevice?o?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!1,!0,null):e.Browser.isDevice&&!r||this.initMainToolbar(i,e.Browser.isDevice,null),e.Browser.isDevice&&this.initBottomToolbar();break;case"shapes":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),"line"===n.activeObj.shape||"path"===n.activeObj.shape?s.toolbarItems=["strokeColor","strokeWidth","duplicate","remove"]:"arrow"===n.activeObj.shape?s.toolbarItems=["strokeColor","strokeWidth","start","end","duplicate","remove"]:s.toolbarItems=["fillColor","strokeColor","strokeWidth","duplicate","remove"],n.trigger("toolbarUpdating",s),this.initShapesToolbarItem(s.toolbarItems);break;case"text":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),s.toolbarItems=["fontFamily","fontSize","fontColor","bold","italic","duplicate","remove","text"],n.trigger("toolbarUpdating",s),this.initTextToolbarItem(s.toolbarItems);break;case"pen":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),s.toolbarItems=["strokeColor","strokeWidth","remove"],n.trigger("toolbarUpdating",s),this.initPenToolbarItem(s.toolbarItems);break;case"adjustment":e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),this.initAdjustmentToolbarItem();break;case"filter":this.updateContextualToolbar(t);break;case"color":this.updateContextualToolbar(t,a);break;case"croptransform":n.isCropTab=!0,e.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),n.updateCropTransformItems(),this.initCropTransformToolbar()}this.currToolbar=t,this.refreshDropDownBtn(o)}},n.prototype.getAdjustmentToolbarItem=function(){var t=[],i=this.parent;(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Brightness")>-1)&&t.push({id:i.element.id+"_brightness",prefixIcon:"e-icons e-brightness",cssClass:"top-icon e-brightness",tooltipText:this.l10n.getConstant("Brightness"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Contrast")>-1)&&t.push({id:i.element.id+"_contrast",prefixIcon:"e-icons e-contrast",cssClass:"top-icon e-contrast",tooltipText:this.l10n.getConstant("Contrast"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Hue")>-1)&&t.push({id:i.element.id+"_hue",prefixIcon:"e-icons e-fade",cssClass:"top-icon e-fade",tooltipText:this.l10n.getConstant("Hue"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Saturation")>-1)&&t.push({id:i.element.id+"_saturation",prefixIcon:"e-icons e-saturation",cssClass:"top-icon e-saturation",tooltipText:this.l10n.getConstant("Saturation"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Exposure")>-1)&&t.push({id:i.element.id+"_exposure",prefixIcon:"e-icons e-grain",cssClass:"top-icon e-grain",tooltipText:this.l10n.getConstant("Exposure"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Opacity")>-1)&&t.push({id:i.element.id+"_opacity",prefixIcon:"e-icons e-opacity",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Opacity"),align:"Center"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Blur")>-1)&&t.push({id:i.element.id+"_blur",prefixIcon:"e-icons e-tint",cssClass:"top-icon e-tint",tooltipText:this.l10n.getConstant("Blur"),align:"Center"});for(var o=this.processToolbar("center"),r=0,a=o.length;r<a;r++)t.push(o[r]);return e.Browser.isDevice||(t.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),t.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),t},n.prototype.getFilterToolbarItem=function(){var t=[],i=this.parent;(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Default")>-1)&&t.push({id:i.element.id+"_default",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Default"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_defaultCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Default")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Chrome")>-1)&&t.push({id:i.element.id+"_chrome",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Chrome"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_chromeCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Chrome")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Cold")>-1)&&t.push({id:i.element.id+"_cold",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Cold"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_coldCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Cold")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Warm")>-1)&&t.push({id:i.element.id+"_warm",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Warm"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_warmCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Warm")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Grayscale")>-1)&&t.push({id:i.element.id+"_grayscale",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Grayscale"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_grayscaleCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Grayscale")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Sepia")>-1)&&t.push({id:i.element.id+"_sepia",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Sepia"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_sepiaCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Sepia")+"</span></div></div>"}),(e.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Invert")>-1)&&t.push({id:i.element.id+"_invert",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Invert"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_invertCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Invert")+"</span></div></div>"});for(var o=this.processToolbar("center"),r=0,a=o.length;r<a;r++)t.push(o[r]);return t},n.prototype.getPenToolbarItem=function(t){var i=this.parent,o=[];(e.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),t.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_pen_strokecolor",cssClass:"top-icon e-pen-stroke-color",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penColorBtn"></button>'}),t.indexOf("strokeWidth")>-1&&o.push({prefixIcon:"e-icons e-copy",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("StrokeWidth"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penStrokeWidth"></button>'}),o.push({align:"Center",type:"Separator"}),t.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"});for(var r=this.processSubToolbar(t),a=0,n=r.length;a<n;a++)o.push(r[a]);return e.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.initPenToolbarItem=function(t){var i=this,r=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getPenToolbarItem(t),l=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createPenColor(t),i.createPenBtn(t),i.wireZoomBtnEvents(),e.Browser.isDevice||i.renderSaveBtn(),r.trigger("toolbarCreated",{toolbarType:"pen"}),e.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&(p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(r.element.id+"_toolbar")&&p.refreshOverflow())}});e.Browser.isDevice?p.appendTo("#"+r.element.id+"_bottomToolbar"):p.appendTo("#"+r.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createPenColor=function(t){var i=this,o=this.parent;if(t.indexOf("strokeColor")>-1){o.element.querySelector(".e-template.e-pen-stroke-color").appendChild(o.createElement("input",{id:o.element.id+"_pen_stroke"}));var n=new a.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-pen-color",change:function(t){o.updatePenStrokeColor(t.currentValue.hex),i.selFhdColor=t.currentValue.hex,s.element.children[0].style.backgroundColor=t.currentValue.rgba,s.toggle()}},"#"+o.element.id+"_pen_stroke"),s=new r.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=s.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=o.element.offsetLeft+"px")},target:".e-pen-color",iconCss:"e-dropdownbtn-preview"},"#"+o.element.id+"_penColorBtn");n.inline=!0;var l={tempFreeHandDrawEditingStyles:null};o.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:l}});var p={freehandSelectedIndex:null};o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:p}}),!e.isNullOrUndefined(p.freehandSelectedIndex)&&p.freehandSelectedIndex>-1?o.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#42a5f5"===this.selFhdColor?l.tempFreeHandDrawEditingStyles.strokeColor:o.pointColl[p.freehandSelectedIndex].strokeColor:o.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createPenBtn=function(t){var i=this.parent,o=[{id:"1",text:this.l10n.getConstant("XSmall")},{id:"2",text:this.l10n.getConstant("Small")},{id:"3",text:this.l10n.getConstant("Medium")},{id:"4",text:this.l10n.getConstant("Large")},{id:"5",text:this.l10n.getConstant("XLarge")}];if(t.indexOf("strokeWidth")>-1){var a=document.getElementById(i.element.id+"_penStrokeWidth"),n=document.createElement("span"),s={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:s}}),!e.isNullOrUndefined(s.freehandSelectedIndex)&&s.freehandSelectedIndex>-1?n.innerHTML=this.getPenStroke(i.pointColl[s.freehandSelectedIndex].strokeWidth):n.innerHTML=this.l10n.getConstant("Small"),n.className="e-pen-stroke-width",a.appendChild(n);var l=new r.DropDownButton({items:o,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=l.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=n.innerHTML;t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){n.textContent=t.item.text,i.updatePenStrokeWidth(t.item.id),e.Browser.isDevice?document.getElementById(i.element.id+"_bottomToolbar")&&e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i.element.id+"_toolbar")&&e.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+i.element.id+"_penStrokeWidth")}},n.prototype.getPenStroke=function(t){var e="",i={1:this.l10n.getConstant("XSmall"),2:this.l10n.getConstant("Small"),3:this.l10n.getConstant("Medium"),4:this.l10n.getConstant("Large"),5:this.l10n.getConstant("XLarge")};return t>=1&&t<=5&&(e=i[t]),e},n.prototype.initAdjustmentToolbarItem=function(){var t=this,i=this.parent,r=this.getLeftToolbarItem(null),a=this.getRightToolbarItem(),n=this.getAdjustmentToolbarItem(),s=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=r.concat(s,n,a);var l=new o.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.wireZoomBtnEvents(),e.Browser.isDevice||t.renderSaveBtn(),e.Browser.isDevice?t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow():(t.createLeftToolbarControls(),t.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow())}});e.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.initFilterToolbarItem=function(){var t=this,i=this.parent,r=this.getFilterToolbarItem();document.querySelector("#"+i.element.id+"_contextualToolbar").classList.contains("e-control")&&e.getComponent(document.getElementById(i.element.id+"_contextualToolbar"),"toolbar").destroy();var a=new o.Toolbar({width:"100%",items:r,clicked:this.contextualToolbarClicked.bind(this),created:function(){t.updatePrivateVariables(),t.createCanvasFilter(),""===i.currentFilter&&(i.currentFilter=i.element.id+"_default");var e=document.querySelector("#"+i.element.id+"_headWrapper");e&&(e.style.display="none"),document.getElementById(i.currentFilter+"Canvas").parentElement.parentElement.classList.add("e-selected"),t.enableDisableTbrBtn(),a.refreshOverflow()}});a.appendTo("#"+i.element.id+"_contextualToolbar")},n.prototype.createCanvasFilter=function(){var t=this.parent;i.showSpinner(t.element),t.element.style.opacity="0.5";var e=t.getCurrentCanvasData();this.inMemoryCanvas.width=e.width,this.inMemoryCanvas.height=e.height,this.inMemoryContext.putImageData(e,0,0),this.updateFilterCanvas("_defaultCanvas","default"),this.updateFilterCanvas("_chromeCanvas","chrome"),this.updateFilterCanvas("_coldCanvas","cold"),this.updateFilterCanvas("_warmCanvas","warm"),this.updateFilterCanvas("_grayscaleCanvas","grayscale"),this.updateFilterCanvas("_sepiaCanvas","sepia"),this.updateFilterCanvas("_invertCanvas","invert"),i.hideSpinner(t.element),t.element.style.opacity="1",t.initialAdjustmentValue=this.lowerContext.filter},n.prototype.updateFilterCanvas=function(t,e){var i=this.parent,o=i.element.querySelector("#"+i.element.id+t);if(o){var r=o.getContext("2d");r=o.getContext("2d"),o.style.width="100px",o.style.height="100px",i.notify("filter",{prop:"updateAdj",value:{type:e,value:null,isPreview:!0,ctx:r}}),r.drawImage(this.inMemoryCanvas,0,0,300,150)}},n.prototype.getQuickAccessToolbarItem=function(t){var i=this.parent,o={cancel:!1,toolbarItems:[]},r=[];e.isNullOrUndefined(t)?(r.push("Clone"),r.push("Delete"),"text"===i.activeObj.shape&&r.push("EditText"),o.shape=i.toPascalCase(i.activeObj.shape)):t&&(r.push("Delete"),o.shape="Freehand draw"),o.toolbarItems=e.extend([],r,null,!0),i.trigger("quickAccessToolbarOpen",o);var a=[];if(o.cancel)a=[];else for(var n=0;n<o.toolbarItems.length;n++)switch(o.toolbarItems[n]){case"Clone":a.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Left"});break;case"Delete":a.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Left"});break;case"EditText":a.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Left"});break;default:a.push(o.toolbarItems[n])}return a},n.prototype.renderQAT=function(t){var i=this.parent;if(i.activeObj&&i.showQuickAccessToolbar){var r=document.getElementById(i.element.id+"_quickAccessToolbarArea");r&&(this.destroyQuickAccessToolbar(),r.style.display="block");var a=this.getQuickAccessToolbarItem(t);if(0===a.length)return;if(e.isNullOrUndefined(i.quickAccessToolbarTemplate)&&new o.Toolbar({items:a,clicked:this.quickAccessToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_quickAccessToolbar"),e.isNullOrUndefined(t)){r.style.width="auto",i.activeObj.activePoint.width=Math.abs(i.activeObj.activePoint.width),i.activeObj.activePoint.height=Math.abs(i.activeObj.activePoint.height);var n=i.activeObj.activePoint.startX<i.activeObj.activePoint.endX?i.activeObj.activePoint.startX:i.activeObj.activePoint.endX,s=i.activeObj.activePoint.startY<i.activeObj.activePoint.endY?i.activeObj.activePoint.startY:i.activeObj.activePoint.endY,l=i.activeObj.activePoint.width;if(0!==i.activeObj.rotatedAngle&&"arrow"!==i.activeObj.shape){var p={activePoint:null};i.notify("shape",{prop:"getSquarePointForRotatedShape",onPropertyChange:!1,value:{obj:i.activeObj,object:p}}),n=(v=p.activePoint).startX,s=v.startY,l=v.width}else if("path"===i.activeObj.shape){var h=i.getSquarePointForPath(i.activeObj);n=h.startX,s=h.startY,l=h.width}r.style.left=n+l/2-25*a.length+"px",s-60<i.img.destTop?r.style.top=i.img.destTop+"px":r.style.top=s-60+"px"}else if(t){var c={activePoint:null},d={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:d}}),i.notify("freehand-draw",{prop:"getSqPtFD",value:{idx:d.freehandSelectedIndex,obj:c}});var v=c.activePoint;r.style.width="auto",r.style.left=v.startX+v.width/2-27*a.length+"px",v.startY-60<i.img.destTop?r.style.top=i.img.destTop+"px":r.style.top=v.startY-60+"px"}}},n.prototype.refreshDropDownBtn=function(t){if(!e.isNullOrUndefined(t)){var i=this.parent,o=document.querySelector("#"+i.element.id+"_annotationBtn");o&&(t?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay")),e.getComponent(o,"dropdown-btn").disabled=t);var r=document.querySelector("#"+i.element.id+"_transformBtn");r&&(t?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")),e.getComponent(r,"dropdown-btn").disabled=t);var a=document.querySelector("#"+i.element.id+"_adjustment");a&&(t?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay")),e.getComponent(a,"btn").disabled=t);var n=document.querySelector("#"+i.element.id+"_filter");n&&(t?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay")),e.getComponent(n,"btn").disabled=t)}},n.prototype.cropSelect=function(t){var i=this.parent;i.isCropTab=!0,e.isNullOrUndefined(i.transform.cropZoomFactor)&&(i.transform.cropZoomFactor=i.transform.zoomFactor,i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}})),i.transform.zoomFactor=i.transform.cropZoomFactor;var o=t.item.id;this.currentToolbar="crop",i.currSelectionPoint=null,i.select(o),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.quickAccessToolbarClicked=function(t,i){var o=this.parent,r={x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY};if(t.item){var a=void 0,n=void 0,s=null,l={prevActObj:null},p={tempObj:null};o.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:l}}),o.notify("selection",{prop:"getTempActObj",onPropertyChange:!1,value:{obj:p}}),p.tempObj.activePoint.height=Math.abs(p.tempObj.activePoint.height);var h={isNewPath:null};switch(o.notify("draw",{prop:"getNewPath",value:{obj:h}}),t.item.id.replace(o.element.id+"_","").toLowerCase()){case"duplicate":if(!o.element.querySelector("#"+o.element.id+"_duplicate").classList.contains("e-disabled")){if(h.isNewPath||JSON.stringify(p.tempObj)!==JSON.stringify(o.activeObj)||(s=!0),a=e.extend({},o.activeObj,{},!0),e.isNullOrUndefined(o.activeObj.currIndex)?o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}}):l.prevActObj?(o.activeObj.currIndex=null,a.currIndex=null,o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}})):o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),h.isNewPath&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),n=e.extend([],o.objColl,[],!0),a.activePoint.startX+=10,a.activePoint.startY-=10,a.activePoint.endX+=10,a.activePoint.endY-=10,"path"===a.shape)for(var c=0;c<a.pointColl.length;c++)a.pointColl[c].x+=10,a.pointColl[c].y-=10;o.activeObj=a,"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||o.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:o.activeObj}}),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:n}}),this.renderQAT()}break;case"remove":o.element.querySelector("#"+o.element.id+"_remove").classList.contains("e-disabled")||o.notify("selection",{prop:"deleteItem",onPropertyChange:!1});break;case"edittext":o.element.querySelector("#"+o.element.id+"_editText").classList.contains("e-disabled")||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:e.extend({},o.activeObj,{},!0)}}),o.notify("selection",{prop:"setInitialTextEdit",onPropertyChange:!1,value:{bool:!0}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:e.extend({},o.activeObj,{},!0)}}),0!==o.activeObj.rotatedAngle&&(r.x=o.activeObj.horTopLinePointColl[0].x,r.y=o.activeObj.horTopLinePointColl[0].y),o.notify("shape",{prop:"renderTextArea",onPropertyChange:!1,value:{x:r.x,y:r.y,actObj:o.activeObj}}),e.isNullOrUndefined(o.activeObj.currIndex)?o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}):l.prevActObj&&o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"))}}e.isNullOrUndefined(i)&&o.trigger("quickAccessToolbarItemClick",t)},n.prototype.defToolbarClicked=function(t){var e=this.parent,i=!1,o=!1;if(e.element.querySelector(".e-contextual-toolbar-wrapper")&&(e.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(i=o=!0),e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),t.item){var r=t.item.id.replace(e.element.id+"_","").toLowerCase();if("duplicate"===r||"remove"===r||"edittext"===r)this.quickAccessToolbarClicked(t,!0),e.trigger("toolbarItemClicked",t);else{var a=!1,n=!1,s=document.querySelector("#"+e.element.id+"_adjustment");s&&s.classList.contains("e-disabled")&&(n=!0);var l=document.querySelector("#"+e.element.id+"_filter");l&&l.classList.contains("e-disabled")&&(a=!0),this.enableDisableTbrBtn(),this.performDefTbrClick(r,i,n,a,o),e.trigger("toolbarItemClicked",t)}}},n.prototype.performDefTbrClick=function(t,e,o,r,a){var n,s,l=this.parent,p=l.element.querySelector("#"+l.element.id+"_zoomIn"),h=!1;if(void 0!==l.activeObj.shape&&(s=l.activeObj.shape.split("-")),void 0===s&&l.currObjType.isCustomCrop?h=!0:void 0!==s&&"crop"===s[0]&&(h=!0),!l.disabled)switch(t){case"pan":l.currObjType.isCustomCrop=l.currObjType.isFiltered=!1,l.currObjType.isUndoAction&&l.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}}),h&&(l.currObjType.isCustomCrop=!1,l.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,l.upperCanvas.width,l.upperCanvas.height),this.refreshToolbar("main")),l.togglePan?(this.cancelPan(),l.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!0}}),"pen"===this.currentToolbar&&l.freehandDraw(!0)):((n=l.element.querySelector(".e-img-pan .e-btn"))&&n.classList.add("e-selected-btn"),l.pan(!0),l.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!1}})),p&&l.zoomSettings.zoomFactor>=l.zoomSettings.maxZoomFactor?(p.classList.add("e-disabled"),p.parentElement.classList.add("e-overlay")):p&&(p.classList.remove("e-disabled"),p.parentElement.classList.remove("e-overlay")),this.refreshToolbar("main");break;case"cancel":l.notify("draw",{prop:"performCancel",value:{isContextualToolbar:e}});break;case"ok":l.okBtn(),this.refreshDropDownBtn(!1),this.currentToolbar="main";break;case"crop":l.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"reset":l.reset(),this.currentToolbar="main";break;case"undo":l.notify("undo-redo",{prop:"call-undo"});break;case"redo":l.notify("undo-redo",{prop:"call-redo"});break;case"adjustment":o||(l.currObjType.isFiltered&&l.okBtn(),this.refreshToolbar("adjustment"),l.setTempFilterProperties(),this.openSlider("brightness"));break;case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":this.openSlider(t);break;case"filter":r||(i.showSpinner(l.element),this.refreshToolbar("filter"),l.setTempFilterProperties(),i.hideSpinner(l.element));break;case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":l.currObjType.isFiltered=!0,l.notify("filter",{prop:"applyImageFilter",value:{option:t}});break;case"upload":a&&l.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-hide");break;case"bold":l.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}):l.activeObj.textSettings.bold&&!l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):!l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):l.activeObj.textSettings.bold||l.activeObj.textSettings.italic||l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}),l.element.querySelector("#"+l.element.id+"_bold").classList.contains("e-selected-btn")?l.element.querySelector("#"+l.element.id+"_bold").classList.remove("e-selected-btn"):l.element.querySelector("#"+l.element.id+"_bold").classList.add("e-selected-btn");break;case"italic":l.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}):l.activeObj.textSettings.bold&&!l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):!l.activeObj.textSettings.bold&&l.activeObj.textSettings.italic?l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):l.activeObj.textSettings.bold||l.activeObj.textSettings.italic||l.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}),l.element.querySelector("#"+l.element.id+"_italic").classList.contains("e-selected-btn")?l.element.querySelector("#"+l.element.id+"_italic").classList.remove("e-selected-btn"):l.element.querySelector("#"+l.element.id+"_italic").classList.add("e-selected-btn");break;case"croptransform":this.refreshToolbar("croptransform");break;case"rotateleft":case"rotateright":case"horizontalflip":case"verticalflip":l.transformSelect(t),l.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"save":if(l.element.querySelector("#"+l.element.id+"_saveBtn").classList.contains("e-hide")){l.element.querySelector("#"+l.element.id+"_saveBtn").classList.remove("e-hide");break}l.okBtn(),l.element.querySelector("#"+l.element.id+"_saveBtn").classList.add("e-hide"),l.element.querySelector("#"+l.element.id+"_saveBtn").click()}},n.prototype.contextualToolbarClicked=function(t){var e=this.parent,i=e.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");i&&i.classList.remove("e-selected");var o=t.item.id.replace(e.element.id,"").split("_")[1],r={filter:e.toPascalCase(o),cancel:!1};e.trigger("imageFiltering",r),r.cancel||(document.getElementById(t.item.id+"Canvas").parentElement.parentElement.classList.add("e-selected"),e.currObjType.isFiltered=!0,e.notify("filter",{prop:"applyImageFilter",value:{option:o.toLowerCase()}}),e.currentFilter=t.item.id,this.enableDisableTbrBtn())},n.prototype.refreshShapeDrawing=function(){var t=this.parent,e={shape:""};t.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:e}}),""!==e.shape&&(t.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.refreshToolbar("main",!1))},n.prototype.zoomInBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)===t.ZoomTrigger.Toolbar){if(this.refreshShapeDrawing(),e.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomIn");e.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null}})}},n.prototype.zoomOutBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&t.ZoomTrigger.Toolbar)===t.ZoomTrigger.Toolbar){if(this.refreshShapeDrawing(),e.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomOut");e.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null}})}},n.prototype.zoomInBtnMouseDownHandler=function(t){t.preventDefault(),this.zoomBtnHold=setInterval(this.zoomInBtnClickHandler.bind(this),250)},n.prototype.zoomOutBtnMouseDownHandler=function(t){t.preventDefault(),this.zoomBtnHold=setInterval(this.zoomOutBtnClickHandler.bind(this),250)},n.prototype.zoomBtnMouseUpHandler=function(){clearInterval(this.zoomBtnHold),this.zoomBtnHold=0},n.prototype.closeContextualToolbar=function(){var t=this.parent,e=!1;return(t.element.querySelector("#"+t.element.id+"_contextualToolbar")&&!t.element.querySelector("#"+t.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||t.element.querySelector("#"+t.element.id+"_headWrapper")&&!t.element.querySelector("#"+t.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),t.okBtn(),this.refreshMainToolbar(),e=!0),e},n.prototype.destroyQuickAccessToolbar=function(){var t=this.parent,i=document.getElementById(t.element.id+"_quickAccessToolbar");i&&i.classList.contains("e-control")&&e.getComponent(i,"toolbar").destroy();var o=document.getElementById(t.element.id+"_quickAccessToolbarArea");o&&(o.style.display="none")},n.prototype.renderSlider=function(t){var i=this.parent,o=document.querySelector("#"+i.element.id+"_contextualToolbarArea"),r=document.querySelector("#"+i.element.id+"_headWrapper"),a=document.querySelector("#"+i.element.id+"_labelWrapper");r?r.style.display="block":a=(r=o.appendChild(i.createElement("div",{id:i.element.id+"_headWrapper",styles:"position: relative"}))).appendChild(i.createElement("label",{id:i.element.id+"_labelWrapper",styles:e.Browser.isDevice?"position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;":"position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;"})),a.textContent=this.l10n.getConstant(i.toPascalCase(t));var n,s,l,p=r.appendChild(i.createElement("div",{id:i.element.id+"_sliderWrapper",styles:"position: absolute"})),h=i.getCurrAdjustmentValue(t);"brightness"===t||"contrast"===t||"saturation"===t||"exposure"===t?(i.finetuneSettings?"brightness"===t&&i.finetuneSettings.brightness?(n=i.finetuneSettings.brightness.min,s=i.finetuneSettings.brightness.max):"contrast"===t&&i.finetuneSettings.contrast?(n=i.finetuneSettings.contrast.min,s=i.finetuneSettings.contrast.max):"saturation"===t&&i.finetuneSettings.saturation?(n=i.finetuneSettings.saturation.min,s=i.finetuneSettings.saturation.max):"exposure"===t&&i.finetuneSettings.exposure?(n=i.finetuneSettings.exposure.min,s=i.finetuneSettings.exposure.max):(n=-100,s=100):(n=-100,s=100),l=this.createSlider(n,s,h,t)):"hue"!==t&&"blur"!==t&&"opacity"!==t||(i.finetuneSettings?"hue"===t&&i.finetuneSettings.hue?(n=i.finetuneSettings.hue.min,s=i.finetuneSettings.hue.max):"blur"===t&&i.finetuneSettings.blur?(n=i.finetuneSettings.blur.min,s=i.finetuneSettings.blur.max):"opacity"===t&&i.finetuneSettings.opacity?(n=i.finetuneSettings.opacity.min,s=i.finetuneSettings.opacity.max):(n=0,s=100):(n=0,s=100),l=this.createSlider(n,s,h,t)),l.appendTo("#"+i.element.id+"_sliderWrapper"),p.style.left=(parseFloat(o.style.width)-parseFloat(l.width))/2+"px"},n.prototype.createSlider=function(t,i,o,r){var n=this,s=this.parent;return new a.Slider({value:o,tooltip:{isVisible:!0,placement:"Before",showOn:"Always"},type:"MinRange",min:t,max:i,step:10,width:e.Browser.isDevice?"200px":"300px",cssClass:"e-slider",change:function(t){s.setCurrAdjustmentValue(r,t.value),n.enableDisableTbrBtn()}})},n.prototype.applyPreviewFilter=function(){var t=this.parent;(document.querySelector("#"+t.element.id+"_sliderWrapper")||t.currObjType.isFiltered)&&(t.initialAdjustmentValue=this.lowerContext.filter,t.canvasFilter=this.lowerContext.filter,t.currObjType.isFiltered=!1)},n.prototype.unselectBtn=function(){for(var t=this.parent,e=0,i=["#"+t.element.id+"_brightness","#"+t.element.id+"_contrast","#"+t.element.id+"_hue","#"+t.element.id+"_saturation","#"+t.element.id+"_opacity","#"+t.element.id+"_blur","#"+t.element.id+"_exposure"];e<i.length;e++){var o=i[e],r=document.querySelector(o);if(r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},n.prototype.openSlider=function(t){this.unselectBtn(),this.parent.currObjType.isFiltered=!0,this.refreshToolbar("color",null,null,null,t),document.getElementById(this.parent.element.id+"_"+t).classList.add("e-selected-btn")},n.prototype.refreshSlider=function(){var t=document.querySelector("#"+this.parent.element.id+"_sliderWrapper"),e=document.querySelector(".e-slider"),i=document.querySelector("#"+this.parent.element.id+"_headWrapper");i&&(i.style.display="none"),t&&e&&(e.ej2_instances[0].destroy(),t.remove())},n.prototype.updateToolbarItems=function(){var t=this.parent,i=t.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview"),o=t.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview"),r=t.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview"),a=t.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview"),n=t.element.querySelector(".e-shape-stroke-width"),s=t.element.querySelector(".e-text-font-family"),l=t.element.querySelector(".e-text-font-size"),p=t.element.querySelector("#"+t.element.id+"_bold"),h=t.element.querySelector("#"+t.element.id+"_italic");if(e.isNullOrUndefined(t.activeObj.strokeSettings.strokeWidth)&&(t.activeObj.strokeSettings.strokeWidth=2),i&&(""===t.activeObj.strokeSettings.fillColor?i.classList.add("e-nocolor-item"):(i.classList.remove("e-nocolor-item"),i.style.background=t.activeObj.strokeSettings.fillColor),e.getComponent(t.element.id+"_shape_fill","colorpicker").value=t.activeObj.strokeSettings.fillColor+"ff"),o&&(o.style.background=t.activeObj.strokeSettings.strokeColor,e.getComponent(t.element.id+"_shape_stroke","colorpicker").value=t.activeObj.strokeSettings.strokeColor+"ff"),r&&(r.style.background=t.activeObj.strokeSettings.strokeColor,e.getComponent(t.element.id+"_text_font","colorpicker").value=t.activeObj.strokeSettings.strokeColor+"ff"),a&&(a.style.background=t.activeObj.strokeSettings.strokeColor,e.getComponent(t.element.id+"_pen_stroke","colorpicker").value=t.activeObj.strokeSettings.strokeColor+"ff"),s&&(e.Browser.isDevice?s.setAttribute("style","font-family:"+t.activeObj.textSettings.fontFamily.toLowerCase()):s.textContent=t.activeObj.textSettings.fontFamily),l)for(var c=0;c<t.fontSizeColl.length;c++)if(parseInt(t.fontSizeColl[c].text,10)>=Math.round(t.activeObj.textSettings.fontSize)){l.textContent=(c+1).toString();break}if(p&&(t.activeObj.textSettings.bold?p.classList.add("e-selected-btn"):p.classList.remove("e-selected-btn")),h&&(t.activeObj.textSettings.italic?h.classList.add("e-selected-btn"):h.classList.remove("e-selected-btn")),n){var d=Math.round(t.activeObj.strokeSettings.strokeWidth).toString();n.textContent=this.getStrokeWidth(d)}},n.prototype.getStrokeWidth=function(t){var e;switch(parseInt(t,10)/2){case 1:e=this.l10n.getConstant("XSmall");break;case 2:e=this.l10n.getConstant("Small");break;case 3:e=this.l10n.getConstant("Medium");break;case 4:e=this.l10n.getConstant("Large");break;case 5:e=this.l10n.getConstant("XLarge")}return e},n.prototype.cancelPan=function(){var t=this.parent;t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}});var e=t.element.querySelector(".e-img-pan .e-btn");e&&e.classList.remove("e-selected-btn"),t.pan(!1)},n.prototype.refreshMainToolbar=function(){"main"!==this.currToolbar&&this.refreshToolbar("main")},n.prototype.destroySubComponents=function(){for(var t=this.parent,i=t.element.querySelectorAll("input.e-control"),o=t.element.querySelectorAll("button.e-control"),r=0,a=i.length;r<a;r++)i[r].classList.contains("e-color-picker")&&(e.getComponent(i[r],"color-picker").destroy(),e.detach(e.select("input#"+i[r].id,t.element)));for(var r=0,a=o.length;r<a;r++)o[r].classList.contains("e-dropdown-btn")?(e.getComponent(o[r],"dropdown-btn").destroy(),e.detach(e.select("button#"+o[r].id,t.element))):o[r].classList.contains("e-btn")&&(e.getComponent(o[r],"btn").destroy(),e.detach(e.select("button#"+o[r].id,t.element)))},n.prototype.setInitialShapeSettings=function(t){var e=this.parent;e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.currObjType.shape=t.item.id,e.activeObj.shape=e.currObjType.shape.toLowerCase(),e.currObjType.isDragging=e.currObjType.isCustomCrop=!1,e.activeObj.shapeDegree=e.transform.degree,e.activeObj.shapeFlip=e.transform.currFlipState,e.activeObj.textFlip=e.transform.currFlipState,e.activeObj.flipObjColl=[]},n.prototype.getModuleName=function(){return"toolbar-module"},n}();return t.Crop=n,t.Draw=s,t.Export=l,t.Filter=p,t.FreehandDrawing=h,t.Selection=c,t.Shape=d,t.Transform=v,t.UndoRedo=u,t.FinetuneSettings=C,t.ZoomSettings=f,t.SelectionSettings=m,t.ImageEditor=y,t.ToolbarModule=P,t}({},ej.base,ej.popups,ej.navigations,ej.splitbuttons,ej.inputs),this.ejs=ej;
|
|
11
11
|
//# sourceMappingURL=ej2-image-editor.min.js.map
|