@syncfusion/ej2-react-form-renderer 34.2.4 → 34.2.5
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.
|
@@ -1,10 +1 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* filename: ej2-react-form-renderer.min.js
|
|
3
|
-
* version : 34.2.4
|
|
4
|
-
* Copyright Syncfusion Inc. 2001 - 2025. All rights reserved.
|
|
5
|
-
* Use of this code is subject to the terms of our license.
|
|
6
|
-
* A copy of the current license can be obtained at any time by e-mailing
|
|
7
|
-
* licensing@syncfusion.com. Any infringement will be prosecuted under
|
|
8
|
-
* applicable laws.
|
|
9
|
-
*/
|
|
10
1
|
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("SyncfusionBase"),require("SyncfusionNavigations"),require("SyncfusionPopups"),require("SyncfusionInputs"),require("SyncfusionButtons"),require("SyncfusionSplitbuttons"),require("SyncfusionDropdowns"),require("SyncfusionCalendars"),require("SyncfusionNotifications"),require("SyncfusionRichtexteditor"),require("SyncfusionData"),require("SyncfusionGrids"),require("SyncfusionReactBase")):"function"==typeof define&&define.amd?define(["React","SyncfusionBase","SyncfusionNavigations","SyncfusionPopups","SyncfusionInputs","SyncfusionButtons","SyncfusionSplitbuttons","SyncfusionDropdowns","SyncfusionCalendars","SyncfusionNotifications","SyncfusionRichtexteditor","SyncfusionData","SyncfusionGrids","SyncfusionReactBase"],t):"object"==typeof exports?exports.SyncfusionReactFormRenderer=t(require("React"),require("SyncfusionBase"),require("SyncfusionNavigations"),require("SyncfusionPopups"),require("SyncfusionInputs"),require("SyncfusionButtons"),require("SyncfusionSplitbuttons"),require("SyncfusionDropdowns"),require("SyncfusionCalendars"),require("SyncfusionNotifications"),require("SyncfusionRichtexteditor"),require("SyncfusionData"),require("SyncfusionGrids"),require("SyncfusionReactBase")):e.SyncfusionReactFormRenderer=t(e.React,e.SyncfusionBase,e.SyncfusionNavigations,e.SyncfusionPopups,e.SyncfusionInputs,e.SyncfusionButtons,e.SyncfusionSplitbuttons,e.SyncfusionDropdowns,e.SyncfusionCalendars,e.SyncfusionNotifications,e.SyncfusionRichtexteditor,e.SyncfusionData,e.SyncfusionGrids,e.SyncfusionReactBase)}(self,(e,t,o,i,r,a,n,s,l,p,h,d,c,u)=>(()=>{"use strict";var g={24:t=>{t.exports=e},766:e=>{e.exports=t},741:e=>{e.exports=a},570:e=>{e.exports=l},74:e=>{e.exports=d},778:e=>{e.exports=s},707:e=>{e.exports=c},323:e=>{e.exports=r},215:e=>{e.exports=o},344:e=>{e.exports=p},197:e=>{e.exports=i},705:e=>{e.exports=u},674:e=>{e.exports=h},295:e=>{e.exports=n}},v={};function f(e){var t=v[e];if(void 0!==t)return t.exports;var o=v[e]={exports:{}};return g[e](o,o.exports,f),o.exports}f.d=(e,t)=>{for(var o in t)f.o(t,o)&&!f.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},f.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),f.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var m={};return(()=>{f.r(m),f.d(m,{FORM_COMPONENT_TYPES:()=>Ye,FormLayout:()=>Xe,FormRenderer:()=>Ee,FormRendererComponent:()=>He,defaultLocale:()=>Le});var e,t,o,i,r,a,n,s,l,p,h,d,c,u=f(24),g=f(766),v=f(215),b=f(197),C=f(323),y=f(741),x=f(295),P=f(778),w=f(570),j=f(344),S=function(){function e(e){this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1,this.isInitCrop=!1,this.isTransformCrop=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("crop",this.cropping,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("crop",this.cropping),this.parent.off("destroyed",this.destroy)},e.prototype.cropping=function(e){switch(this.updateCropPvtVar(),e.prop){case"cropCircle":this.cropCircle(e.value.context,e.value.isSave,e.value.isFlip);break;case"setCurrSelPoints":this.setCurrSelPoints(e.value.isSetDimension);break;case"updateRotatePan":this.updateRotatePan();break;case"crop":this.crop(e.value.obj);break;case"calcRatio":this.calcRatio(e.value.obj,e.value.dimension);break;case"getCurrFlipState":this.getCurrFlipState(e.value.panObj);break;case"getPreviousCropCurrentObj":e.value.obj.prevObj=this.prevCropCurrObj;break;case"setPreviousCropCurrentObj":this.prevCropCurrObj=e.value.obj;break;case"setCropDestPoints":this.cropDestPoints=e.value.point;break;case"getTempFlipPanPoint":e.value.obj.point=this.tempFlipPanPoint;break;case"setTempFlipPanPoint":(0,g.isNullOrUndefined)(e.value.isAdd)?this.tempFlipPanPoint=e.value.point:(this.tempFlipPanPoint.x+=e.value.point.x,this.tempFlipPanPoint.y+=e.value.point.y);break;case"getPreventScaling":e.value.obj.bool=this.isPreventScaling;break;case"adjustStraightenForShapes":this.adjustStraightenForShapes(e.value.type,e.value.isInitialRotated);break;case"resizeWrapper":this.resizeWrapper();break;case"setTransformCrop":this.isTransformCrop=e.value.bool;break;case"setInitCrop":this.isInitCrop=e.value.bool;break;case"resetZoom":this.resetZoom();break;case"revertTransform":this.revertTransform(e.value.type,e.value.coll);break;case"reset":this.reset()}},e.prototype.getModuleName=function(){return"crop"},e.prototype.updateCropPvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},e.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,this.isInitCrop=!1,this.isTransformCrop=!1},e.prototype.cropImg=function(e){for(var t=this.parent,o=(0,g.isNullOrUndefined)(e),i=t.element.querySelector("#"+t.element.id+"_nonaspectratio"),r=t.activeObj.activePoint,a=t.img,n=!1,s=0,l=t.rotateFlipColl.length;s<l;s++){var p=t.rotateFlipColl[s];90!==p&&-90!==p||(n=!0)}if(t.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),(o||i)&&(this.croppedDegree=t.transform.degree),o&&0!==t.transform.degree||n){this.updateCropObj();var h={startX:a.destLeft,startY:a.destTop,width:a.destWidth,height:a.destHeight};t.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:h}}),this.rotateCrop()}else if(o&&""!==t.transform.currFlipState){this.updateCropObj();h={startX:a.destLeft,startY:a.destTop,width:a.destWidth,height:a.destHeight};t.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:h}}),this.flipCrop()}else{this.adjustStraightenForShapes("initial",!1),t.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:t.transform.zoomFactor}});var d=this.calcRatio();if(o||!e){this.updateCropObj(),t.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1});h={startX:a.destLeft,startY:a.destTop,width:a.destWidth,height:a.destHeight};t.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:h}}),t.currSelectionPoint=(0,g.extend)({},t.activeObj,{},!0),this.cropDestPoints={startX:a.destLeft,startY:a.destTop,width:a.destWidth,height:a.destHeight}}var c={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:r.width*d.width,height:r.height*d.height,obj:c,isImgShape:null}});var u=c;this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.img={srcLeft:r.startX*d.width-a.destLeft*d.width,srcTop:r.startY*d.height-a.destTop*d.height,srcWidth:r.width*d.width,srcHeight:r.height*d.height,destLeft:(t.lowerCanvas.clientWidth-u.width)/2,destTop:(t.lowerCanvas.clientHeight-u.height)/2,destWidth:u.width,destHeight:u.height};var v=this.lowerContext.filter;t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter="none";var f=(0,g.extend)({},t.activeObj,{},!0);this.cropObjColl(),t.transform.straighten=0,t.activeObj=f,this.cropFreehandDrawColl(),t.shapeColl=[],t.notify("shape",{prop:"updateShapeColl",onPropertyChange:!1}),t.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape?this.cropCircle(this.lowerContext):t.isCircleCrop=!1,this.lowerContext.filter=v,t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.currObjType.isCustomCrop=!1,t.pan(!1),t.transform.defaultZoomFactor=0}},e.prototype.adjustStraightenForShapes=function(e,t){for(var o=this.parent,i=o.img.destLeft+o.img.destWidth/2,r=o.img.destTop+o.img.destHeight/2,a=0,n=o.objColl;a<n.length;a++){var s=n[a];if(-1!==["rectangle","ellipse","text","image","redact"].indexOf(s.shape)&&(t||0!==s.rotatedAngle)){var l=s.activePoint,p=l.startX,h=l.startY,d=l.width,c=l.height,u="initial"===e?s.rotatedAngle:-s.rotatedAngle,g=p+d/2-i,v=h+c/2-r,f=Math.cos(u),m=Math.sin(u),b=f*g-m*v+i-p-d/2,C=m*g+f*v+r-h-c/2;s.activePoint.startX+=b,s.activePoint.startY+=C,s.activePoint.endX+=b,s.activePoint.endY+=C}}},e.prototype.updateCropObj=function(){this.parent.afterCropActions=[];var e={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:e}});var t=e.currObj;t.straighten=this.parent.transform.straighten,this.parent.cropObj=(0,g.extend)({},t,{},!0)},e.prototype.rotateCrop=function(){var e=this.parent,t=this.getCurrFlipState(),o=e.activeObj.shape||"";e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.currSelectionPoint=(0,g.extend)({},e.activeObj,{},!0),e.objColl.push(e.activeObj),e.activeObj=(0,g.extend)({},e.objColl[e.objColl.length-1],{},!0);var i=(0,g.extend)({},e.objColl[e.objColl.length-1],{},!0),r=(0,g.extend)({},e.currSelectionPoint,{},!0),a={bool:null};e.notify("transform",{prop:"getPreventSelect",onPropertyChange:!1,value:{obj:a}}),e.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:!0}});var n=(0,g.extend)([],e.rotateFlipColl,[],!0);this.panToSelRangle(!0),i=(0,g.extend)({},e.objColl[e.objColl.length-1],{},!0),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i}}),e.objColl.pop(),e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj);var s=e.transform.straighten;0!==s&&(e.transform.straighten=0,e.straightenBaseImageCanvas(),e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}})),this.resetZoom();var l=(0,g.extend)([],e.afterCropActions,[],!0);this.revertTransform("initial",n),0!==s&&(e.transform.straighten="horizontal"===t||"vertical"===t?-s:s,e.straightenBaseImageCanvas(),e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}})),i=(0,g.extend)({},e.objColl[e.objColl.length-1],{},!0),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i}}),e.objColl.pop(),e.transform.degree=0;var p={isIntersect:null};e.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),e.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:p}});for(var h=0;0!==s&&p.isIntersect&&50!==++h;)e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.025,zoomPoint:null},isResize:null}),e.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),e.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:p}});this.cropImg(!0),this.revertTransform("reverse",n),e.afterCropActions=l,e.currSelectionPoint=r,e.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:a.bool}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),"crop-circle"===o&&this.cropCircle(this.lowerContext),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})},e.prototype.revertTransform=function(e,t){var o=this.parent,i={isRotate:!1};if("initial"===e)for(var r=t.length-1;r>=0;r--){switch(n=t[r]){case 90:o.notify("transform",{prop:"rotate",value:{degree:-90,obj:i}});break;case-90:o.notify("transform",{prop:"rotate",value:{degree:90,obj:i}});break;default:o.notify("transform",{prop:"flipImage",value:{direction:o.toPascalCase(n.toString())}})}}else{this.updateFlipState();r=0;for(var a=t.length;r<a;r++){var n;switch(n=t[r]){case 90:o.notify("transform",{prop:"rotate",value:{degree:90,obj:i}});break;case-90:o.notify("transform",{prop:"rotate",value:{degree:-90,obj:i}});break;default:o.notify("transform",{prop:"flipImage",value:{direction:o.toPascalCase(n.toString())}})}}}},e.prototype.updateFlipState=function(){for(var e=this.parent,t=e.objColl,o=0,i=t.length;o<i;o++)t[o].shapeFlip="";var r=e.pointColl;for(o=0;o<e.freehandCounter;o++)r[o].shapeFlip=""},e.prototype.resetZoom=function(){var e=this.parent;if(e.transform.zoomFactor>0){var t=e.transform.zoomFactor,o=e.isUndoRedo;e.setProperties({zoomSettings:{zoomFactor:10*t}},!0),e.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:e.zoomSettings.zoomFactor}});for(var i=0;i<10*t;i++)e.isUndoRedo=!0,e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});e.isUndoRedo=o,e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})}},e.prototype.flipCrop=function(){var e=this.parent;e.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),e.panPoint.totalPannedPoint.x+=this.tempFlipPanPoint.x,e.panPoint.totalPannedPoint.y+=this.tempFlipPanPoint.y;var t=e.transform.currFlipState,o={flipColl:null};e.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:o}});var i=o.flipColl;if(e.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:[]}}),e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj),0===e.transform.degree){var r=-e.cropObj.totalPannedPoint.x,a=-e.cropObj.totalPannedPoint.y;e.img.destLeft+=r,e.img.destTop+=a,e.notify("transform",{prop:"drawPannImage",value:{point:{x:r,y:a}}}),e.activeObj=(0,g.extend)({},e.objColl[e.objColl.length-1],{},!0),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:e.activeObj}}),e.objColl.pop(),e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj)}this.resetZoom(),e.currSelectionPoint=(0,g.extend)({},e.objColl[e.objColl.length-1],{},!0),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height);var n=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.updateFlipState(),e.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),e.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),e.activeObj=(0,g.extend)({},e.objColl[e.objColl.length-1],{},!0),e.objColl.pop(),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.cropImg(!0),e.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),this.lowerContext.setTransform(1,0,0,1,0,0),e.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=n,e.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),e.transform.currFlipState=t,e.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:i}}),this.lowerContext.filter="none",this.updateFlipState(),e.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),e.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),this.lowerContext.filter=n,(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)&&this.cropCircle(this.lowerContext),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}}),e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),this.tempFlipPanPoint={x:0,y:0}},e.prototype.cropObjColl=function(){var e,t,o,i=this.parent;if(i.objColl.length>0)for(var r=0,a=i.objColl.length;r<a;r++){e=(o=i.objColl[r]).activePoint;var n=i.activeObj.activePoint,s=n.startX,l=n.startY,p=n.width,h=n.height;t=o.shape,o.imageRatio={startX:(e.startX-s)/p,startY:(e.startY-l)/h,endX:(e.endX-s)/p,endY:(e.endY-l)/h,width:p/e.width,height:h/e.height};var d=void 0,c=void 0;switch(t){case"text":c=0===(d=0===o.shapeDegree?i.transform.degree:i.transform.degree-o.shapeDegree)||180===Math.abs(d)?e.width:e.height,o.textSettings.fontRatio=c/o.textSettings.fontSize;break;case"line":case"arrow":this.cropPointCollection(r),"arrow"===t&&i.notify("shape",{prop:"updateArrowRatio",onPropertyChange:!1,value:{obj:o}});break;case"path":this.cropPointCollection(r)}}},e.prototype.cropPointCollection=function(e){var t,o,i,r,a=this.parent,n=a.objColl[e].shape,s=a.activeObj.activePoint,l=a.img,p=l.destLeft,h=l.destTop,d=l.destWidth,c=l.destHeight;"path"===n?(t=s.startX,o=s.startY,i=s.width,r=s.height):(t=p,o=h,i=d,r=c);for(var u=a.objColl[e].pointColl,g=0,v=u.length;g<v;g++)u[g].ratioX=(u[g].x-t)/i,u[g].ratioY=(u[g].y-o)/r},e.prototype.cropFreehandDrawColl=function(){for(var e=this.parent,t=e.activeObj.activePoint,o=t.startX,i=t.startY,r=t.width,a=t.height,n=0;n<e.freehandCounter;n++){e.points=(0,g.extend)([],e.pointColl[n].points,[]),e.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var s=e.points.length,l=0;l<s;l++)e.points[l].ratioX=(e.points[l].x-o)/r,e.points[l].ratioY=(e.points[l].y-i)/a}e.notify("freehand-draw",{prop:"updateCropPtsForSel",onPropertyChange:!1})},e.prototype.resetAnnotations=function(){var e=this.parent;e.objColl=[],e.pointColl=[],e.freehandCounter=0,e.notify("freehand-draw",{prop:"resetStraightenPoint"})},e.prototype.setCurrSelPoints=function(e){var t=this.parent;t.allowDownScale=!1;var o=this.cropDestPoints,i=this.lowerContext.filter,r=t.isCropTab;t.img={srcLeft:0,srcTop:0,srcWidth:t.baseImgCanvas.width,srcHeight:t.baseImgCanvas.height,destLeft:o.startX,destTop:o.startY,destWidth:o.width,destHeight:o.height};var a=t.img,n=t.currSelectionPoint;this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),e&&t.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),0===this.croppedDegree&&0===t.transform.degree&&n&&"crop-circle"!==n.shape&&"crop-square"!==n.shape&&(a.destLeft=o.startX,a.destTop=o.startY,a.destWidth=o.width,a.destHeight=o.height),0===t.transform.degree&&(a.destLeft+=t.panPoint.totalPannedInternalPoint.x,a.destTop+=t.panPoint.totalPannedInternalPoint.y),t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=i,t.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:!0}});var s=(0,g.extend)([],t.objColl,null,!0),l=(0,g.extend)([],t.pointColl,null,!0),p={straightenPoint:null};if(t.notify("freehand-draw",{prop:"getStraightenPoint",onPropertyChange:!1,value:{obj:p}}),this.resetAnnotations(),(0,g.isNullOrUndefined)(t.activeObj.shape)&&t.cropObj.activeObj.shape&&(t.activeObj=(0,g.extend)({},t.cropObj.activeObj,null,!0)),this.panToSelRangle(),t.isCropTab=r,t.objColl=s,t.pointColl=l,t.freehandCounter=t.pointColl.length,p.straightenPoint.x&&p.straightenPoint.y&&t.notify("freehand-draw",{prop:"setStraightenPoint",onPropertyChange:!1,value:{x:p.straightenPoint.x,y:p.straightenPoint.y,ratioX:p.straightenPoint.ratioX,ratioY:p.straightenPoint.ratioY}}),t.cropObj.activeObj.shape){var h={startX:a.destLeft,startY:a.destTop,width:a.destWidth,height:a.destHeight};if(n&&n.activePoint){var d=n.activePoint,c=d.startX,u=d.startY,v=d.width,f=d.height;a.destLeft=c,a.destTop=u,a.destWidth=v,a.destHeight=f}t.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),a.destLeft=h.startX,a.destTop=h.startY,a.destWidth=h.width,a.destHeight=h.height,t.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),s=(0,g.extend)([],t.objColl,null,!0),l=(0,g.extend)([],t.pointColl,null,!0),t.notify("freehand-draw",{prop:"getStraightenPoint",onPropertyChange:!1,value:{obj:p}}),this.resetAnnotations();var m={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:m}});var b=m.selPointColl;t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),t.cropObj.filter=this.lowerContext.filter;var C=(0,g.extend)({},t.currSelectionPoint,null,!0);t.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:null}}),t.activeObj=(0,g.extend)({},C,null,!0);var y=(0,g.extend)({},t.activeObj,null,!0);if(t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.currSelectionPoint=null,t.isCircleCrop=!1,0!==t.transform.degree&&((0,g.isNullOrUndefined)(t.activeObj.shape)&&t.cropObj.activeObj.shape&&(t.activeObj=(0,g.extend)({},t.cropObj.activeObj,null,!0)),t.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),t.panPoint.currentPannedPoint={x:0,y:0}),t.objColl=s,t.pointColl=l,t.freehandCounter=t.pointColl.length,p.straightenPoint.x&&p.straightenPoint.y&&t.notify("freehand-draw",{prop:"setStraightenPoint",onPropertyChange:!1,value:{x:p.straightenPoint.x,y:p.straightenPoint.y,ratioX:p.straightenPoint.ratioX,ratioY:p.straightenPoint.ratioY}}),t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:b}}}),t.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),this.adjustStraightenForShapes("reverse",!1),t.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1,value:{isPreventApply:!0}}),t.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),0===t.transform.degree?t.notify("transform",{prop:"drawPannImage",onPropertyChange:!1,value:{point:{x:0,y:0}}}):((0,g.isNullOrUndefined)(t.activeObj.shape)&&t.cropObj.activeObj.shape&&(t.activeObj=(0,g.extend)({},t.cropObj.activeObj,null,!0)),t.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),t.panPoint.currentPannedPoint={x:0,y:0}),t.activeObj=y,t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),this.isInitCrop||0!==t.transform.degree||""===t.cropObj.currFlipState||0===t.cropObj.cropZoom)this.isInitCrop=!1;else{this.isInitCrop=!0;var x={activeObj:null};t.notify("draw",{prop:"getStraightenActObj",onPropertyChange:!1,value:{obj:x}}),t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),t.notify("draw",{prop:"setStraightenActObj",onPropertyChange:!1,value:{activeObj:x.activeObj}}),t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"croptransform",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}})}}else{this.adjustStraightenForShapes("reverse",!0),t.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1,value:{isPreventApply:!0}});var P=this.lowerContext.filter;this.lowerContext.filter="none",t.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),this.lowerContext.filter=P,t.currSelectionPoint=null}document.querySelector(".e-ie-straighten-value-span")&&(document.querySelector(".e-ie-straighten-value-span").innerHTML=t.transform.straighten.toString()+"°")},e.prototype.panToSelRangle=function(e){var t=this.parent,o=t.cropObj.totalPannedClientPoint,i=0!==t.transform.degree?e?-o.x:o.x:0,r=0!==t.transform.degree?e?-o.y:o.y:0;0!==t.transform.degree&&(t.panPoint.currentPannedPoint={x:i,y:r},t.notify("transform",{prop:"drawPannedImage",value:{xDiff:i,yDiff:r}}),t.panPoint.currentPannedPoint={x:0,y:0})},e.prototype.cropCircle=function(e,t,o){var i=this.parent,r=i.img,a=r.destLeft,n=r.destTop,s=r.destWidth,l=r.destHeight;o&&""!==i.transform.currFlipState&&i.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:e,value:i.transform.currFlipState,isReverse:null}});var p=e.filter;e.filter="none",e.globalCompositeOperation="destination-in",e.beginPath();var h=(0,g.isNullOrUndefined)(t)?a+s/2:e.canvas.width/2,d=(0,g.isNullOrUndefined)(t)?n+l/2:e.canvas.height/2,c=t?e.canvas.width/2:s/2;e.arc(h,d,c,0,2*Math.PI),e.closePath(),e.fill(),e.restore(),e.globalCompositeOperation="source-over",i.currObjType.isActiveObj=i.isCircleCrop=!0,e.filter=p,o&&""!==i.transform.currFlipState&&i.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:e,value:i.transform.currFlipState,isReverse:null}})},e.prototype.getCurrCropState=function(){var e=this.parent,t="",o={flipColl:null};return e.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:o}}),t=this.getCurrFlipState(),-90!==e.transform.degree&&-270!==e.transform.degree||("horizontal"===t?t="vertical":"vertical"===t&&(t="horizontal")),""===t&&(t=o.flipColl.length>1?this.getCurrFlipState():e.transform.currFlipState),t},e.prototype.updateRotatePan=function(){var e=this.parent;if(!(0,g.isNullOrUndefined)(e.panPoint.currentPannedPoint)){var t="",o=e.transform.degree,i=e.panPoint.currentPannedPoint,r=i.x,a=i.y;t=e.rotateFlipColl.length>0&&"number"==typeof e.rotateFlipColl[0]&&o<0?this.getCurrCropState():this.getCurrFlipState(),o%90==0&&o%180!=0?90===o||-90===o&&("horizontal"===t||"vertical"===t)||-270===o&&(""===t||"verticalHorizontal"===t||"horizontalVertical"===t)?("horizontal"===t||""===t?e.img.destLeft+=a:e.img.destLeft-=a,""===t||"vertical"===t?e.img.destTop-=r:e.img.destTop+=r):270!==o&&(-270!==o||"horizontal"!==t&&"vertical"!==t)&&(-90!==o||""!==t&&"verticalHorizontal"!==t&&"horizontalVertical"!==t)||(""===t||"horizontal"===t?e.img.destLeft-=a:e.img.destLeft+=a,""===t||"vertical"===t?e.img.destTop+=r:e.img.destTop-=r):180!==o&&-180!==o||(""===t||"vertical"===t?e.img.destLeft-=r:e.img.destLeft+=r,""===t||"horizontal"===t?e.img.destTop-=a:e.img.destTop+=a)}},e.prototype.crop=function(e){var t=this.parent,o=t.activeObj.activePoint,i=o.startX,r=o.startY,a=o.endX,n=o.endY;if(!t.disabled&&t.isImageLoaded){var s={isCropToolbar:t.isCropToolbar};t.currObjType.isUndoAction&&!s.isCropToolbar&&t.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}});var l={cancel:!1,startPoint:{x:i,y:r},endPoint:{x:a,y:n},preventScaling:!1};s.isCropToolbar||(t.trigger("cropping",l),t.editCompleteArgs=l),this.cropEvent(l,e,s)}},e.prototype.cropEvent=function(e,t,o){var i,r=this.parent;if(!e.cancel&&(i=r.activeObj.shape?r.activeObj.shape.split("-"):[],!r.disabled&&r.activeObj.horTopLine&&(r.currObjType.isCustomCrop||i.length>0&&"crop"===i[0]))){t.isCrop=!0;var a=(0,g.extend)({},r.cropObj,{},!0),n=(0,g.extend)({},this.prevCropCurrObj,{},!0);e.preventScaling?this.isPreventScaling=!0:this.isPreventScaling=!1,this.cropImg(),this.isPreventScaling&&(r.aspectWidth=r.img.destWidth,r.aspectHeight=r.img.destHeight),r.notify("freehand-draw",{prop:"resetStraightenPoint"}),r.isCropTab=!1,r.transform.zoomFactor=0,r.setProperties({zoomSettings:{zoomFactor:1}},!0),r.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:r.zoomSettings.zoomFactor}}),g.Browser.isDevice||this.updateUndoRedoColl(n,a,o),r.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:r.cropObj.destPoints.width,height:r.cropObj.destPoints.height}});var s=r.element.querySelector("#"+r.element.id+"_aspectratio"),l=r.element.querySelector("#"+r.element.id+"_nonaspectratio");r.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),!o.isCropToolbar&&(0,g.isNullOrUndefined)(s)&&(0,g.isNullOrUndefined)(l)&&r.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),this.resizeWrapper(),g.Browser.isDevice&&this.updateUndoRedoColl(n,a,o)}},e.prototype.updateUndoRedoColl=function(e,t,o){var i=this.parent,r={prevCurrSelectionPoint:i.prevCurrSelectionPoint};e.currSelectionPoint=(0,g.extend)({},r.prevCurrSelectionPoint,{},!0),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"crop",previousObj:e,previousObjColl:e.objColl,previousPointColl:e.pointColl,previousSelPointColl:e.selPointColl,previousCropObj:t,previousText:null,currentText:null,previousFilter:null,isCircleCrop:i.isCircleCrop}}),o.isCropToolbar||i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},e.prototype.resizeWrapper=function(){var e=this.parent;if(g.Browser.isDevice){var t=e.element,o=t.querySelector("#"+t.id+"_contextualToolbarArea");o&&""===o.style.position&&!this.isTransformCrop&&(o.style.position="absolute",e.isStraightening=!1,e.update(),e.notify("filter",{prop:"setAdjustmentValue",value:{adjustmentValue:e.canvasFilter}}))}},e.prototype.calcRatio=function(e,t){var o=this.parent,i=o.transform.degree,r=o.img,a=r.destWidth,n=r.destHeight,s=t||o.baseImgCanvas,l=s.width,p=s.height,h=0===i||i%180==0?l/a:p/a,d=0===i||i%180==0?p/n:l/n;return e&&(e.width=h,e.height=d),{width:h,height:d}},e.prototype.getCurrFlipState=function(e){var t=this.parent,o={panRegion:""},i={collection:t.rotateFlipColl};t.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:t.rotateFlipColl,isRotateFlipCollection:!0,obj:i}}),t.rotateFlipColl=i.collection;for(var r=0,a=t.rotateFlipColl.length;r<a;r++)t.notify("transform",{prop:"setCurrPanRegion",onPropertyChange:!1,value:{region:o.panRegion,type:t.rotateFlipColl[r],obj:o}});return e&&(e.panRegion=o.panRegion),o.panRegion},e}(),O=function(e,t,o,i){return new(o||(o=Promise))(function(r,a){function n(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){e.done?r(e.value):new o(function(t){t(e.value)}).then(n,s)}l((i=i.apply(e,t||[])).next())})},T=function(e,t){var o,i,r,a,n={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;n;)try{if(o=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,i=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(!(r=n.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){n=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(6===a[0]&&n.label<r[1]){n.label=r[1],r=a;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(a);break}r[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e],i=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},k=function(){function e(e){this.isInitialLoading=!1,this.fileName="",this.isErrorImage=!1,this.isShapeTextInserted=!1,this.isRotateZoom=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null,outlineColor:"",radius:null,outlineWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1,strikethrough:!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.isResizeSelect=!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.origDim={width:0,height:0},this.isImageApply=!1,this.imgCanvasPoints=[],this.isCropSelect=!1,this.isDownScale=!1,this.preventStraightening=!1,this.tempObjColl=[],this.tempPointColl={},this.imageBackgroundColor="",this.allowRedactStraighten=!0,this.isNullExtension=!0,this.isRedactStraighten=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("draw",this.draw),this.parent.off("destroyed",this.destroy)},e.prototype.draw=function(e){switch(this.updatePrivateVariables(),e.prop){case"drawObject":this.drawObject(e.value.canvas,e.value.obj,e.value.isCropRatio,e.value.points,e.value.isPreventDrag,e.value.saveContext,e.value.isPreventSelection);break;case"updateActiveObject":this.updateActiveObject(e.value.actPoint,e.value.obj,e.value.isMouseMove,e.value.x,e.value.y);break;case"clearOuterCanvas":this.clearOuterCanvas(e.value.context);break;case"setDestPoints":this.setDestPoints();break;case"updateCurrTransState":this.updateCurrTransState(e.value.type,e.value.isPreventDestination,e.value.isRotatePan);break;case"currTransState":this.currTransState(e.value.type,e.value.isPreventDestination,e.value.context,e.value.isPreventCircleCrop);break;case"setTransform":this.setTransform(e.value.context,e.value.value,e.value.isReverse);break;case"render-image":this.renderImage(e.value.isMouseWheel,e.value.isPreventClearRect,e.value.isFrame,e.value.isStraighten);break;case"draw-image-to-canvas":this.drawImgToCanvas(e.value.dimension);break;case"update-canvas":this.updateCanvas();break;case"performCancel":this.performCancel(e.value.isContextualToolbar,e.value.isUndoRedo,e.value.isFinalCancel);break;case"updateFlipPan":this.updateFlipPan(e.value.tempSelectionObj);break;case"select":this.select(e.value.type,e.value.startX,e.value.startY,e.value.width,e.value.height);break;case"callUpdateCurrTransState":this.callUpdateCurrTransState();break;case"resetPanPoints":this.resetPanPoints();break;case"setClientTransDim":this.setClientTransDim(e.value.isPreventDimension);break;case"redrawImgWithObj":this.redrawImgWithObj();break;case"setCurrentObj":this.setCurrentObj(e.value.obj,e.value.isUndoRedo,e.value.isCircleCrop);break;case"performPointZoom":this.performPointZoom(e.value.x,e.value.y,e.value.type,e.value.isResize);break;case"open":this.open(e.value.data);break;case"isInitialLoading":this.isInitialLoading=e.value.isInitialLoading;break;case"isInitialLoaded":this.getInitialLoaded(e.value.object);break;case"fileSelect":this.fileSelect(e.value.inputElement,e.value.args);break;case"getFileName":e.value.obj.fileName=this.fileName,e.value.obj.fileType=this.fileType;break;case"getErrorImage":e.value.obj.isErrorImage=this.isErrorImage;break;case"getInitialZoomValue":e.value.obj.initialZoomValue=this.initZoomValue;break;case"setShapeTextInsert":this.isShapeTextInserted=e.value.bool;break;case"resetCurrentSelectionPoint":this.currSelPoint=null;break;case"setRotateZoom":this.isRotateZoom=e.value.isRotateZoom;break;case"setTempStrokeSettings":this.tempStrokeSettings=e.value.tempStrokeSettings;break;case"setTempTextSettings":this.tempTextSettings=e.value.tempTextSettings;break;case"setTempAdjustmentValue":this.tempAdjValue=e.value.tempAdjustmentValue;break;case"getTempAdjustmentValue":e.value.obj.value=this.tempAdjValue;break;case"setTempFilter":this.tempFilter=e.value.tempFilter;break;case"setTempUndoRedoStep":this.tempUndoRedoStep=e.value.tempUndoRedoStep;break;case"setTempFreehandCounter":this.tempFreehandCounter=e.value.tempFreehandCounter;break;case"setTempCurrentFreehandDrawIndex":this.tempCurrFhdIndex=e.value.tempCurrentFreehandDrawIndex;break;case"setTempZoomFactor":this.tempZoomFactor=e.value.tempZoomFactor;break;case"setCancelAction":this.isCancelAction=e.value.bool;break;case"getRotatedFlipCropSelection":e.value.bool.isSelected=this.rotatedFlipCropSel;break;case"getPrevActObj":e.value.obj.prevActObj=this.prevActObj;break;case"setPrevActObj":this.prevActObj=e.value.prevActObj;break;case"setZoomCropWidth":this.zoomCrop.width=e.value.width,this.zoomCrop.height=e.value.height;break;case"setImageEdited":this.isImageEdited=!0;break;case"reset":this.reset();break;case"setNewPath":this.isNewPath=e.value.bool;break;case"getNewPath":e.value.obj.isNewPath=this.isNewPath;break;case"getArrowDimension":e.value.obj.arrowDimension=(0,g.extend)({},this.arrowDimension,{},!0);break;case"setArrowDimension":this.arrowDimension=e.value.arrowDimension;break;case"moveToSelectionRange":this.moveToSelectionRange(e.value.type,e.value.activeObj);break;case"setResizeSelect":this.isResizeSelect=e.value.bool;break;case"applyFrame":this.applyFrame(e.value.ctx,e.value.frame,e.value.preventImg);break;case"drawImage":this.drawImage();break;case"downScaleImgCanvas":this.downScaleImgCanvas(e.value.ctx,e.value.isImgAnnotation,e.value.isHFlip,e.value.isVFlip);break;case"downScale":this.downScale(e.value.canvas,e.value.width,e.value.height);break;case"resetFrameZoom":this.resetFrameZoom(e.value.isOk);break;case"triggerFrameChange":e.value.obj.frameChangeEventArgs=this.triggerFrameChange(e.value.prevFrameSettings);break;case"setImageApply":this.isImageApply=e.value.bool;break;case"zoomToSel":this.zoomToSel(e.value.activeObj,e.value.isToolbar);break;case"getStraightenActObj":e.value.obj.activeObj=this.straightenActObj;break;case"setStraightenActObj":this.straightenActObj=e.value.activeObj;break;case"updateImgCanvasPoints":this.updateImgCanvasPoints();break;case"isLinesIntersect":e.value.obj.isIntersect=this.isLinesIntersect(e.value.obj);break;case"getImageCanvasPoints":e.value.obj.points=this.imgCanvasPoints;break;case"setDestForStraighten":this.setDestForStraighten();break;case"setTempDestForStraighten":this.tempStraightenDestPoints=(0,g.extend)({},this.straightenDestPoints,{},!0);break;case"getStraightenInitZoom":e.value.obj.zoomFactor=this.straightenInitZoom;break;case"setStraightenInitZoom":this.straightenInitZoom=e.value.zoomFactor;break;case"isPointsInsideImg":e.value.obj.bool="inside"!==this.checkPointPosition(e.value.x,e.value.y,this.imgCanvasPoints[0].x,this.imgCanvasPoints[0].y,this.imgCanvasPoints[1].x,this.imgCanvasPoints[1].y,this.imgCanvasPoints[2].x,this.imgCanvasPoints[2].y,this.imgCanvasPoints[3].x,this.imgCanvasPoints[3].y);break;case"setIsCropSelect":this.isCropSelect=e.value.bool;break;case"updateCropSelection":this.updateCropSelection();break;case"updateCropSelObj":this.updateCropSelObj();break;case"redrawDownScale":this.redrawDownScale();break;case"updateFinetune":this.updateFinetune();break;case"isSelOutsideImg":e.value.obj.bool=this.isSelOutsideImg();break;case"resetStraightenDestPoints":this.straightenDestPoints=null;break;case"checkPointPosition":e.value.obj.position=this.checkPointPosition(e.value.obj.x,e.value.obj.y,e.value.obj.x1,e.value.obj.y1,e.value.obj.x2,e.value.obj.y2,e.value.obj.x3,e.value.obj.y3,e.value.obj.x4,e.value.obj.y4);break;case"updateTempObjColl":this.tempObjColl=(0,g.extend)([],this.parent.objColl,[],!0);break;case"resetTempObjColl":this.tempObjColl=null;break;case"updateTempPointColl":this.tempPointColl=(0,g.extend)({},this.parent.pointColl,{},!0);break;case"resetTempPointColl":this.tempPointColl={};break;case"showDialogPopup":this.showDialogPopup();break;case"imageBackgroundColor":this.imageBackgroundColor=e.value.color;break;case"getImageBackgroundColor":e.value.obj.color=this.imageBackgroundColor;break;case"setTempStrokeWidth":this.tempStrokeWidth=e.value.strokeWidth;break;case"setNullExtension":this.isNullExtension=e.value.extension;break;case"setRedactStraighten":this.isRedactStraighten=e.value.bool}},e.prototype.getModuleName=function(){return"draw"},e.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d")),(0,g.isNullOrUndefined)(this.tempZoomFactor)&&(this.tempZoomFactor=e.transform.zoomFactor),""===this.tempTextSettings.fontFamily&&(this.tempTextSettings.fontFamily=e.fontFamily.default)},e.prototype.reset=function(){this.isInitialLoading=this.isErrorImage=this.isNewPath=this.isResizeSelect=!1,this.isShapeTextInserted=!1,this.isImageApply=!1,this.isNullExtension=!0,this.initZoomValue=null,this.tempFilter="",this.origDim={width:0,height:0},this.currSelPoint=null,this.isRotateZoom=!1,this.tempAdjValue="",this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null,radius:null,outlineColor:"",outlineWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:this.parent.fontFamily.default,fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1,strikethrough:!1},this.tempUndoRedoStep=this.tempFreehandCounter=this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.prevActObj=null,this.tempStraightenDestPoints=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}},this.straightenActObj=null,this.imgCanvasPoints=[],this.straightenInitZoom=null,this.allowRedactStraighten=!0,this.tempObjColl=[],this.tempPointColl={},this.imageBackgroundColor="",this.tempStrokeWidth=null,this.straightenDestPoints=null,this.isCropSelect=this.isDownScale=this.preventStraightening=!1,this.isRedactStraighten=!1},e.prototype.redrawDownScale=function(){var e=this.parent;if(e.transform.zoomFactor&&e.transform.zoomFactor<0){var t=(0,g.extend)({},e.activeObj,{},!0);e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isDownScale=!0,this.renderImage(),this.isDownScale=!1,t.shape&&this.drawObject("duplicate",t)}},e.prototype.updateFinetune=function(){var e=this.parent;if(e.transform.zoomFactor&&e.transform.zoomFactor<0){var t=this.lowerContext.filter;this.lowerContext.filter="none",e.notify("draw",{prop:"redrawDownScale"});var o=e.inMemoryCanvas.getContext("2d"),i=this.lowerContext,r=i.getImageData(0,0,i.canvas.width,i.canvas.height);e.inMemoryCanvas.width=r.width,e.inMemoryCanvas.height=r.height,o.putImageData(r,0,0),this.lowerContext.filter=t,e.notify("draw",{prop:"redrawDownScale"})}},e.prototype.drawImage=function(){this.applyFrame(this.lowerContext,this.parent.frameObj.type)},e.prototype.drawObject=function(e,t,o,i,r,a,n){var s,l=this.parent,p=l.activeObj,h=l.activeObj.activePoint;(this.upperContext.clearRect(0,0,l.upperCanvas.width,l.upperCanvas.height),"original"===(e=e.toLowerCase())?s=this.lowerContext:"duplicate"===e?s=this.upperContext:a&&(s=a),!r&&p.shape&&this.setDragLimit(),l.currObjType.shape)&&("crop"===l.currObjType.shape.split("-")[0].toLowerCase()&&o&&this.drawCropRatio());if(p=l.activeObj,h=l.activeObj.activePoint,(0,g.isNullOrUndefined)(p.strokeSettings)){var d={strokeSettings:{}};l.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:d}}),p.strokeSettings=d.strokeSettings}if((0,g.isNullOrUndefined)(p.strokeSettings.strokeWidth)&&(p.strokeSettings.strokeWidth=2),t&&(l.activeObj=(0,g.extend)({},t,{},!0)),i&&i.startX&&i.startY&&i.endX&&i.endY&&i.width&&i.height&&(h.startX=i.startX,h.startY=i.startY,h.endX=i.endX,h.endY=i.endY,h.width=i.width,h.height=i.height),this.updateActiveObject(),p=l.activeObj,h=l.activeObj.activePoint,!(0,g.isNullOrUndefined)(h.startX)||!(0,g.isNullOrUndefined)(h.startY)){if(l.currObjType.isText){var c={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:c}}),p.keyHistory=c.keyHistory}var u=!1;if("original"!==e){p.shape&&"crop"===p.shape.split("-")[0]&&(u=!0),u&&(i&&i.startX&&i.startY&&i.endX&&i.endY&&i.width&&i.height?(h.startX=i.startX,h.startY=i.startY,h.endX=i.endX,h.endY=i.endY,h.width=i.width,h.height=i.height):h=p.activePoint,this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,l.lowerCanvas.width,l.lowerCanvas.height),this.upperContext.clearRect(h.startX,h.startY,h.width,h.height)),!(0,g.isNullOrUndefined)(n)||s!==this.lowerContext&&s!==this.upperContext||(this.rotateContext("initial",s),this.drawOuterSelection(s),this.rotateContext("reverse",s))}l.currObjType.isActiveObj=!0;var v={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:v}}),t?this.drawShapeObj(e,t.shape,a,n):""!==v.keyHistory&&l.currObjType.isText?this.drawShapeObj(e,"text",a,n):p.shape?this.drawShapeObj(e,p.shape,a,n):this.drawShapeObj(e,void 0,a,n),"duplicate"===e&&u&&"crop-circle"!==p.shape&&"none"!==l.frameObj.type&&(this.applyFrame(this.upperContext,l.frameObj.type),this.drawCornerCircles(this.upperContext))}},e.prototype.rotateContext=function(e,t){var o=this.parent,i=o.activeObj,r=i.shape,a=i.rotatedAngle,n=o.img,s=n.destLeft,l=n.destTop,p=n.destWidth,h=n.destHeight,d=o.activeObj.activePoint,c=d.startX,u=d.startY,g=d.width,v=d.height;if("line"!==r&&"arrow"!==r){var f,m,b="initial"===e?a:-a;0!==o.transform.straighten||o.isCropTab?(f=s+p/2,m=l+h/2):(f=c+g/2,m=u+v/2),t.translate(f,m),t.rotate(b),t.translate(-f,-m)}},e.prototype.setDragLimit=function(){var e=this.parent,t=e.activeObj.activePoint,o=e.activeObj,i=o.shape,r=o.rotatedAngle;if(t&&"image"!==i&&"line"!==i&&0===r&&e.activeObj.preventShapeDragOut){var a=e.img,n=a.destLeft,s=a.destTop,l=a.destWidth,p=a.destHeight;t.startX<n?(t.startX=n,t.endX=Math.min(t.startX+t.width,n+l)):t.endX>n+l&&(t.endX=n+l,t.startX=Math.max(t.endX-t.width,n)),t.startY<s?t.startY=s:t.endY>s+p&&(t.endY=s+p,t.startY=Math.max(t.endY-t.height,s)),e.activeObj=this.updateWidthHeight(e.activeObj)}},e.prototype.drawCropRatio=function(){var e,t,o,i,r=this.parent,a=r.activeObj.activePoint,n=r.img,s=n.destLeft,l=n.destTop,p=n.destWidth,h=n.destHeight;if(r.transform.zoomFactor>0&&this.currSelPoint){var d=(0,g.extend)({},r.activeObj,{},!0);this.drawCustomSelection("crop-custom",null,null,null,null),0!==r.transform.straighten&&(a=r.activeObj.activePoint),r.transform.degree%90==0&&r.transform.degree%180!=0?i=o=a.width<a.height?a.width:a.height:(o=a.width,i=a.height),r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),r.activeObj=d,r.currObjType.shape=d.shape,this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),r.currObjType.isCustomCrop=!1}else o=p,i=h,s<0&&(o+=s),l<0&&(i+=l),s+p>r.lowerCanvas.width&&(o-=s+p-r.lowerCanvas.width),l+h>r.lowerCanvas.height&&(i-=l+h-r.lowerCanvas.height);switch(r.currObjType.shape.toLowerCase()){case"crop-square":case"crop-circle":r.notify("selection",{prop:"setDragDirection",onPropertyChange:!1,value:{width:o,height:i}}),a=r.activeObj.activePoint,r.lowerCanvas.width<a.endX-a.startX&&(a.startX=7.5,a.endX=r.lowerCanvas.width-7.5),r.lowerCanvas.height<a.endY-a.startY&&(a.startY=7.5,a.endY=r.lowerCanvas.height-7.5),o===p&&i===h&&(a.startX+=s,a.startY+=l,a.endX+=s,a.endY+=l),r.lowerCanvas.width>r.lowerCanvas.height?(a.height=a.endY-a.startY,a.width=a.height,a.endX=a.startX+a.width):(a.width=a.endX-a.startX,a.height=a.width,a.endY=a.startY+a.height);break;case"crop-3:2":e=3,t=2;break;case"crop-4:3":e=4,t=3;break;case"crop-5:4":e=5,t=4;break;case"crop-7:5":e=7,t=5;break;case"crop-16:9":e=16,t=9;break;case"crop-2:3":e=2,t=3;break;case"crop-3:4":e=3,t=4;break;case"crop-4:5":e=4,t=5;break;case"crop-5:7":e=5,t=7;break;case"crop-9:16":e=9,t=16;break;default:e=parseInt(r.currObjType.shape.toLowerCase().split("crop-")[1].split(":")[0]),t=parseInt(r.currObjType.shape.toLowerCase().split("crop-")[1].split(":")[1])}if(void 0!==e&&void 0!==t&&(r.notify("selection",{prop:"calcShapeRatio",onPropertyChange:!1,value:{x:e,y:t,imgWidth:o,imgHeight:i}}),o===p&&i===h&&this.updatePoints(),a=r.activeObj.activePoint),a.startX<s){var c=s-a.startX+7.5;a.startX+=c,a.endX+=c}if(a.startY<l){c=l-a.startY+7.5;a.startY+=c,a.endY+=c}r.activeObj=this.updateWidthHeight(r.activeObj),this.adjToCenter(),this.enlargeToImg(),0!==r.transform.straighten&&(this.adjToStraighten(),this.updateActiveObject(r.activeObj.activePoint,r.activeObj));var u={isIntersect:null,arr:null},v=0;if(a=r.activeObj.activePoint,0!==r.transform.straighten)for(;this.isLinesIntersect(u)&&v<100;){v++;c=1*a.width/100;a.startX+=c,a.endX-=c,c=1*a.height/100,a.startY+=c,a.endY-=c,a.width=a.endX-a.startX,a.height=a.endY-a.startY,this.updateActiveObject(a,r.activeObj)}this.straightenInitZoom=r.transform.zoomFactor,this.straightenActObj=(0,g.extend)({},r.activeObj,{},!0),r.notify("draw",{prop:"resetStraightenDestPoints"}),r.notify("draw",{prop:"setDestForStraighten"})},e.prototype.adjToCenter=function(){var e=this.parent,t=e.activeObj.activePoint,o=e.img,i=o.destLeft,r=o.destTop,a=o.destWidth,n=o.destHeight,s=e.lowerCanvas.width/2-(t.endX-t.width/2),l=e.lowerCanvas.height/2-(t.endY-t.height/2);if(t.startX+=s,t.endX+=s,t.startY+=l,t.endY+=l,t.startX<(i>=7.5?i:7.5)){var p=(i>=7.5?i:0)-t.startX;t.startX+=p,t.endX+=p}else if(t.endX>i+a){p=t.endX-(i+a);t.startX-=p,t.endX-=p}if(t.startY<(r>=7.5?r:7.5)){p=(r>=7.5?r:0)-t.startY;t.startY+=p,t.endY+=p}else if(t.endY>r+n){p=t.endY-(r+n);t.startY-=p,t.endY-=p}},e.prototype.enlargeToImg=function(){var e=this.parent;if(0!==e.transform.straighten&&e.transform.degree%90==0&&e.transform.degree%180!=0)for(var t=e.activeObj.activePoint,o=(0,g.extend)({},t,{},!0),i=0;;){i++;var r=5*t.width/100;t.startX-=r,t.endX+=r,r=5*t.height/100,t.startY-=r,t.endY+=r,t.width=t.endX-t.startX,t.height=t.endY-t.startY,this.updateActiveObject(t,e.activeObj);var a={isIntersect:null,arr:null};if(this.updateImgCanvasPoints(),this.isLinesIntersect(a),a.arr[0]||a.arr[1]||a.arr[2]||a.arr[3]||t.startX<7.5||t.startY<7.5||100===i){r=1*(t=(0,g.extend)({},o,{},!0)).width/100,t.startX+=r,t.endX-=r,r=1*t.height/100,t.startY+=r,t.endY-=r,t.width=t.endX-t.startX,t.height=t.endY-t.startY,this.updateActiveObject(t,e.activeObj);break}o=(0,g.extend)({},t,{},!0)}},e.prototype.updateActiveObject=function(e,t,o,i,r){var a=this.parent;e=e||(0,g.extend)({},a.activeObj.activePoint,{},!0),t=t||(0,g.extend)({},a.activeObj,{},!0),e.width=e.endX-e.startX,e.height=e.endY-e.startY;var n=e.startX,s=e.startY,l=e.endX,p=e.endY;i=i||0,r=r||0;var h=e.width/2,d=e.height/2,c=7.5;t.horTopLine={startX:n+i,startY:s-r,endX:l+i,endY:p+r},t.horBottomLine={startX:n-i,startY:p-r,endX:l-i,endY:p+r},t.verLeftLine={startX:n+i,startY:s-r,endX:n-r,endY:p-r},t.verRightLine={startX:l+i,startY:s+r,endX:l-i,endY:p+r},t.topLeftCircle={startX:n,startY:s,radius:t.horTopLine.endX?c:0},t.topCenterCircle={startX:n+h,startY:s,radius:t.horTopLine.endX?c:0},t.topRightCircle={startX:l,startY:s,radius:t.horTopLine.endX?c:0},t.centerLeftCircle={startX:n,startY:s+d,radius:t.horTopLine.endX?c:0},t.centerRightCircle={startX:l,startY:s+d,radius:t.horTopLine.endX?c:0},t.bottomLeftCircle={startX:n,startY:p,radius:t.horTopLine.endX?c:0},t.bottomCenterCircle={startX:n+h,startY:p,radius:t.horTopLine.endX?c:0},t.bottomRightCircle={startX:l,startY:p,radius:t.horTopLine.endX?c:0},0===t.rotatedAngle&&(t.rotationCirclePoint={x:t.bottomCenterCircle.startX,y:t.bottomCenterCircle.startY+25},t.rotationCirclePoint.ratioX=(t.rotationCirclePoint.x-a.img.destLeft)/a.img.destWidth,t.rotationCirclePoint.ratioY=(t.rotationCirclePoint.y-a.img.destTop)/a.img.destHeight),t.activePoint=e,(0,g.isNullOrUndefined)(o)&&(a.activeObj=(0,g.extend)({},t,{},!0))},e.prototype.drawOuterSelection=function(e,t){var o,i=this.parent,r=i.activeObj.activePoint,a=i.activeObj;e.lineWidth=.5;var n,s=(0,g.extend)({},a,{},!0);if(a.shape&&(o=a.shape.split("-")),(o&&"crop"===o[0]||void 0===a.shape)&&!t&&(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.upperContext.clearRect(r.startX,r.startY,r.width,r.height)),e.strokeStyle=i.themeColl[i.theme].primaryColor,e.fillStyle=i.themeColl[i.theme].secondaryColor,(n=0===s.shapeDegree?i.transform.degree:i.transform.degree-s.shapeDegree)<0&&(n=360+n),"arrow"===a.shape||"line"===a.shape)e.beginPath(),e.moveTo(r.startX,r.startY),e.lineTo(r.endX,r.endY),e.stroke();else if("path"===a.shape){e.beginPath();var l=(0,g.extend)({},i.activeObj,{},!0);if(l.pointColl[0]&&(e.moveTo(l.pointColl[0].x,l.pointColl[0].y),l.pointColl.length>1))for(var p=1,h=l.pointColl.length;p<h;p++)r.endX=l.pointColl[p].x,r.endY=l.pointColl[p].y,e.lineTo(r.endX,r.endY);var d={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:d}}),"path"===d.shape&&(i.activeObj=a=l),e.lineTo(r.endX,r.endY),e.stroke()}else this.drawCornerCircles(e);if(i.selectionSettings.showCircle&&(void 0===o||"crop"!==o[0])){var c=e.strokeStyle,u=e.fillStyle;e.strokeStyle=i.selectionSettings.strokeColor,e.fillStyle=i.selectionSettings.fillColor,"text"===a.shape?(e.lineWidth*=2,e.beginPath(),this.drawRotationArcLine(e),e.lineTo(a.rotationCirclePoint.x,a.rotationCirclePoint.y),e.stroke(),e.fill(),e.closePath(),e.beginPath(),e.moveTo(a.rotationCirclePoint.x,a.rotationCirclePoint.y),e.arc(a.rotationCirclePoint.x,a.rotationCirclePoint.y,a.bottomCenterCircle.radius,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),e.lineWidth/=2):"redact"!==i.activeObj.shape&&this.drawCenterCircles(e),e.strokeStyle=c,e.fillStyle=u}s.rotationCircleLine=a.rotationCircleLine,i.activeObj=(0,g.extend)({},s,{},!0)},e.prototype.drawArrowHead=function(e,t){switch(t?this.parent.activeObj.start:this.parent.activeObj.end){case"arrowSolid":t?this.arrowSolid(e,!0):this.arrowSolid(e,!1);break;case"arrow":t?this.arrow(e,!0):this.arrow(e,!1);break;case"circleSolid":t?this.arrowCircleSolid(e,!0):this.arrowCircleSolid(e,!1);break;case"circle":t?this.arrowCircle(e,!0):this.arrowCircle(e,!1);break;case"bar":t?this.arrowBar(e,!0):this.arrowBar(e,!1);break;case"square":case"squareSolid":t?this.arrowSquareStart(e):this.arrowSquareEnd(e)}},e.prototype.drawShapeObj=function(e,t,o,i){var r,a=this.parent,n=a.activeObj.activePoint,s=a.activeObj,l=s.strokeSettings,p=l.strokeColor,h=l.fillColor,d=l.strokeWidth,c=void 0!==t?t:a.currObjType.shape;a.currObjType.shape=c,"original"===e.toLowerCase()?r=this.lowerContext:"duplicate"===e.toLowerCase()?r=this.upperContext:o&&(r=o);var u=a.currObjType.shape.toLowerCase();-1!==["rectangle","ellipse","line","arrow","path","image","redact"].indexOf(u)&&(s.shape=a.currObjType.shape),r.strokeStyle=p,r.fillStyle="text"===t||"freehanddraw"===t?p:h;var v,f=n.width/3,m=n.height/3,b=n.endX-n.startX,C=n.endY-n.startY;this.rotateContext("initial",r);var y,x=r.fillStyle;switch(a.currObjType.shape.toLowerCase()){case"rectangle":this.drawSquareLines(r),(0,g.isNullOrUndefined)(i)&&r===this.upperContext&&this.drawOuterSelection(r);break;case"redact":this.drawRedact(r,s),(0,g.isNullOrUndefined)(i)&&r===this.upperContext&&this.drawOuterSelection(r),a.currObjType.isRedact=!0;break;case"ellipse":b=Math.abs(b),C=Math.abs(C),r.beginPath(),r.ellipse(n.startX+b/2,n.startY+C/2,b/2,C/2,0,0,2*Math.PI,!1),""!==h&&(r.fillStyle=h,r.fill()),r.ellipse(n.startX+b/2,n.startY+C/2,Math.abs(b/2-d),Math.abs(C/2-d),0,0,2*Math.PI,!1),r.fillStyle=p,r.fill("evenodd"),r.closePath(),(0,g.isNullOrUndefined)(i)&&r===this.upperContext&&this.drawOuterSelection(r);break;case"crop-circle":this.shapeCircle(r,b,C);break;case"line":this.shapeLine(r,n.startX,n.startY,n.endX,n.endY),(0,g.isNullOrUndefined)(i)&&r===this.upperContext&&this.drawOuterSelection(r);break;case"arrow":(v=0===s.shapeDegree?a.transform.degree:a.transform.degree-s.shapeDegree)<0&&(v=360+v),r.fillStyle=r.strokeStyle,(0,g.isNullOrUndefined)(s.triangleDirection)&&(s.triangleDirection="right"),(0,g.isNullOrUndefined)(s.start)&&(s.start="none"),(0,g.isNullOrUndefined)(s.end)&&(s.end="arrowSolid"),this.drawArrowHead(r,!0),this.drawArrowHead(r,!1),"none"===s.end&&"circle"!==s.start&&"square"!==s.start&&this.shapeLine(r,n.startX,n.startY,n.endX,n.endY),r.fillStyle=x,(0,g.isNullOrUndefined)(i)&&r===this.upperContext&&this.drawOuterSelection(r);break;case"path":if((y=(0,g.extend)({},a.activeObj,{},!0)).pointColl.length>1){var P={shape:null};if(a.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:P}}),"path"===P.shape&&a.isShapeDrawing)for(var w={x:0,y:0},j=0,S=y.pointColl.length;j<S;j++)(0,g.isNullOrUndefined)(y.pointColl[j+1])?(w.x=y.activePoint.endX,w.y=y.activePoint.endY):(w.x=y.pointColl[j+1].x,w.y=y.pointColl[j+1].y),n.startX=y.pointColl[j].x,n.startY=y.pointColl[j].y,n.endX=w.x,n.endY=w.y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(r,n.startX,n.startY,n.endX,n.endY),g.Browser.isDevice&&(y.activePoint.endX=w.x,y.activePoint.endY=w.y);else for(j=1,S=y.pointColl.length;j<S;j++)n.startX=y.pointColl[j-1].x,n.startY=y.pointColl[j-1].y,n.endX=y.pointColl[j].x,n.endY=y.pointColl[j].y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(r,n.startX,n.startY,n.endX,n.endY);a.activeObj=s=y}else this.shapeLine(r,n.startX,n.startY,n.endX,n.endY);r===this.upperContext&&this.drawOuterSelection(r);break;case"text":this.shapeText(r);break;case"image":this.shapeImage(r),(0,g.isNullOrUndefined)(i)&&r===this.upperContext&&this.drawOuterSelection(r);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":r===this.lowerContext&&(r=this.upperContext),this.drawSelection(f,m),a.currObjType.shape="";break;default:this.drawSelection(f,m)}this.rotateContext("reverse",r)},e.prototype.updatePoints=function(){var e=this.parent,t=e.activeObj.activePoint,o=e.img,i=o.destLeft,r=o.destTop;t.startX+=i,t.startY+=r,t.endX+=i,t.endY+=r,e.activeObj=this.updateWidthHeight(e.activeObj)},e.prototype.updateWidthHeight=function(e){var t=e.activePoint,o=t.startX,i=t.startY,r=t.endX,a=t.endY;return e.activePoint.width=r-o,e.activePoint.height=a-i,e},e.prototype.drawCornerCircles=function(e){var t=this.parent,o=t.activeObj;if(e.beginPath(),e.rect(o.activePoint.startX,o.activePoint.startY,o.activePoint.width,o.activePoint.height),e.stroke(),e.closePath(),t.selectionSettings.showCircle){var i=e.strokeStyle,r=e.fillStyle;e.strokeStyle=t.selectionSettings.strokeColor,e.fillStyle=t.selectionSettings.fillColor,e.lineWidth*=2,e.beginPath(),e.moveTo(o.topLeftCircle.startX,o.topLeftCircle.startY),e.arc(o.topLeftCircle.startX,o.topLeftCircle.startY,o.topLeftCircle.radius,0,2*Math.PI),e.moveTo(o.topRightCircle.startX,o.topRightCircle.startY),e.arc(o.topRightCircle.startX,o.topRightCircle.startY,o.topRightCircle.radius,0,2*Math.PI),e.moveTo(o.bottomLeftCircle.startX,o.bottomLeftCircle.startY),e.arc(o.bottomLeftCircle.startX,o.bottomLeftCircle.startY,o.bottomLeftCircle.radius,0,2*Math.PI),e.moveTo(o.bottomRightCircle.startX,o.bottomRightCircle.startY),e.arc(o.bottomRightCircle.startX,o.bottomRightCircle.startY,o.bottomRightCircle.radius,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),e.lineWidth/=2,e.strokeStyle=i,e.fillStyle=r}},e.prototype.drawCenterCircles=function(e){var t=this.parent,o=t.activeObj.activePoint,i=t.activeObj;if(e.lineWidth*=2,e.beginPath(),"arrow"===i.shape||"line"===i.shape)e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.bottomCenterCircle.radius,0,2*Math.PI);else if("path"===i.shape){var r=(0,g.extend)({},t.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,e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.bottomCenterCircle.radius,0,2*Math.PI);var s={shape:null};t.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"===s.shape&&(t.activeObj=i=r),e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.bottomCenterCircle.radius,0,2*Math.PI)}else this.drawRotationArcLine(e),e.lineTo(i.rotationCirclePoint.x,i.rotationCirclePoint.y);e.stroke(),e.fill(),e.closePath(),"arrow"!==i.shape&&"line"!==i.shape&&"path"!==i.shape&&(e.beginPath(),e.moveTo(i.rotationCirclePoint.x,i.rotationCirclePoint.y),e.arc(i.rotationCirclePoint.x,i.rotationCirclePoint.y,i.bottomCenterCircle.radius,0,2*Math.PI),e.stroke(),e.fill(),e.closePath()),e.lineWidth/=2},e.prototype.drawRotationArcLine=function(e){var t,o=this.parent,i=o.activeObj;(0,g.isNullOrUndefined)(i.rotationCircleLine)&&(i.rotationCircleLine=22.5);var r=!1,a=!1;if((t=0===i.shapeDegree?o.transform.degree:o.transform.degree-i.shapeDegree)<0&&(t=360+t),i.flipObjColl)for(var n=0,s=i.flipObjColl.length;n<s;n++){var l=i.flipObjColl[n].toLowerCase();"horizontal"===l?r=!0:"vertical"===l&&(a=!0)}switch(t){case 0:case 360:a?(i.rotationCirclePoint={x:i.topCenterCircle.startX,y:i.topCenterCircle.startY-i.rotationCircleLine},e.moveTo(i.rotationCirclePoint.x,i.rotationCirclePoint.y+i.rotationCircleLine)):(i.rotationCirclePoint={x:i.bottomCenterCircle.startX,y:i.bottomCenterCircle.startY+i.rotationCircleLine},e.moveTo(i.rotationCirclePoint.x,i.rotationCirclePoint.y-i.rotationCircleLine));break;case 90:case-270:r?(i.rotationCirclePoint={x:i.centerRightCircle.startX+i.rotationCircleLine,y:i.centerLeftCircle.startY},e.moveTo(i.rotationCirclePoint.x-i.rotationCircleLine,i.rotationCirclePoint.y)):(i.rotationCirclePoint={x:i.centerLeftCircle.startX-i.rotationCircleLine,y:i.centerLeftCircle.startY},e.moveTo(i.rotationCirclePoint.x+i.rotationCircleLine,i.rotationCirclePoint.y));break;case 180:case-180:a?(i.rotationCirclePoint={x:i.bottomCenterCircle.startX,y:i.bottomCenterCircle.startY+i.rotationCircleLine},e.moveTo(i.rotationCirclePoint.x,i.rotationCirclePoint.y-i.rotationCircleLine)):(i.rotationCirclePoint={x:i.topCenterCircle.startX,y:i.topCenterCircle.startY-i.rotationCircleLine},e.moveTo(i.rotationCirclePoint.x,i.rotationCirclePoint.y+i.rotationCircleLine));break;case 270:case-90:r?(i.rotationCirclePoint={x:i.centerLeftCircle.startX-i.rotationCircleLine,y:i.centerLeftCircle.startY},e.moveTo(i.rotationCirclePoint.x+i.rotationCircleLine,i.rotationCirclePoint.y)):(i.rotationCirclePoint={x:i.centerRightCircle.startX+i.rotationCircleLine,y:i.centerLeftCircle.startY},e.moveTo(i.rotationCirclePoint.x-i.rotationCircleLine,i.rotationCirclePoint.y))}},e.prototype.drawSquareLines=function(e){var t,o=this.parent,i=o.activeObj,r=i.activePoint,a=r.startX,n=r.startY,s=r.width,l=r.height,p=i.strokeSettings,h=p.fillColor,d=p.strokeColor,c=p.strokeWidth,u=p.radius;i.shape&&(t=i.shape.split("-")),"crop"===t[0]?e.strokeStyle="#fff":e.strokeStyle=d,e.beginPath();var g,v={width:0,height:0};o.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:v,dimension:{width:e.canvas.width,height:e.canvas.height}}}),g=v;var f=e.canvas.id===o.element.id+"_tempCanvas",m=o.transform.zoomFactor,b=f?10*u*((g.width+g.height)/2):10*u,C=b+b*m;null!==u?o.isSafari?this.drawRoundedRect(e,a,n,s,l,C):e.roundRect(a,n,s,l,C):e.rect(a,n,s,l),""!==h&&(e.fillStyle=h,e.fill()),null!==u?o.isSafari?this.drawRoundedRect(e,a+c,n+c,s-2*c,l-2*c,C):e.roundRect(a+c,n+c,s-2*c,l-2*c,C):e.rect(a+c,n+c,s-2*c,l-2*c),e.fillStyle=d,e.fill("evenodd"),e.closePath()},e.prototype.drawRoundedRect=function(e,t,o,i,r,a){var n=Math.max(0,Math.min(a,i/2,r/2));e.moveTo(t+n,o),e.arcTo(t+i,o,t+i,o+r,n),e.arcTo(t+i,o+r,o,o+r,n),e.arcTo(t,o+r,t,o,n),e.arcTo(t,o,t+i,o,n),e.closePath()},e.prototype.drawSelection=function(e,t){var o=this.parent,i=o.activeObj,r=i.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY;this.upperContext.strokeStyle=o.themeColl[o.theme].primaryColor,this.upperContext.beginPath(),i.horTopInnerLine={startX:a,startY:n+t,endX:s,endY:l+t},i.horBottomInnerLine={startX:a,startY:n+2*t,endX:s,endY:l+2*t},i.verLeftInnerLine={startX:a+e,startY:n,endX:a+e,endY:l},i.verRightInnerLine={startX:a+2*e,startY:n,endX:a+2*e,endY:l},this.upperContext.moveTo(i.horTopInnerLine.startX,i.horTopInnerLine.startY),this.upperContext.lineTo(i.horTopInnerLine.endX,i.horTopInnerLine.startY),this.upperContext.moveTo(i.horBottomInnerLine.startX,i.horBottomInnerLine.startY),this.upperContext.lineTo(i.horBottomInnerLine.endX,i.horBottomInnerLine.startY),this.upperContext.moveTo(i.verLeftInnerLine.startX,i.verLeftInnerLine.startY),this.upperContext.lineTo(i.verLeftInnerLine.endX,i.verLeftInnerLine.endY),this.upperContext.moveTo(i.verRightInnerLine.startX,i.verRightInnerLine.startY),this.upperContext.lineTo(i.verRightInnerLine.endX,i.verRightInnerLine.endY),this.upperContext.stroke(),this.upperContext.closePath()},e.prototype.shapeCircle=function(e,t,o){var i=this.parent,r=i.activeObj.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY,p=r.width;e.strokeStyle=i.themeColl[i.theme].primaryColor,e.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),e.fillStyle="rgb(0, 0, 0, 0.25)",e.fillRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height);var h=e.lineWidth;e.lineWidth=2,e.beginPath(),e.ellipse(i.activeObj.horTopLine.startX+t/2,i.activeObj.horTopLine.startY+o/2,t/2,o/2,0,0,2*Math.PI,!1),e.stroke(),e.closePath(),e.save(),e.beginPath(),e.arc((s-a)/2+a,(l-n)/2+n,p/2,0,2*Math.PI),e.closePath(),e.clip(),e.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),e.restore(),e.lineWidth=h,this.drawOuterSelection(e,!0),i.currObjType.shape=""},e.prototype.shapeLine=function(e,t,o,i,r){var a=e.lineWidth;e.lineWidth=this.parent.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.moveTo(t,o),e.lineTo(i,r),e.stroke(),e.lineWidth=a},e.prototype.manipulateSaveCtx=function(e,t,o){if(e!==this.lowerContext&&e!==this.upperContext){var i={width:0,height:0};this.parent.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:i,dimension:{width:e.canvas.width,height:e.canvas.height}}});t&&(t*=i.width),o&&(o*=i.height)}return{x:t,y:o}},e.prototype.arrow=function(e,t){var o=this.parent.activeObj,i=o.activePoint,r=i.startX,a=i.startY,n=i.endX,s=i.endY,l=o.strokeSettings.strokeWidth;e.lineWidth=l;var p=this.arrowDimension.arrow.width,h=this.arrowDimension.arrow.height,d=this.manipulateSaveCtx(e,p,h);p=d.x+l,h=d.y+l,this.dx=n-r,this.dy=s-a,e.fillStyle=o.strokeSettings.strokeColor;var c=Math.atan2(this.dy,this.dx),u="arrow"===o.start,g="arrow"===o.end,v="circle"===o.end||"square"===o.end,f="circle"===o.start||"square"===o.start;((t&&"left"===o.triangleDirection||"right"===o.triangleDirection)&&(u&&"none"===o.end||u&&!v&&!f)||!t&&(g&&"none"===o.start||!u&&!v&&!f))&&this.shapeLine(e,r,a,n,s),t&&"left"===o.triangleDirection||!t&&"right"===o.triangleDirection?(e.translate(n,s),e.rotate(c),this.shapeLine(e,0,0,-p,h/2),this.shapeLine(e,0,0,-p,-h/2),e.rotate(-c),e.translate(-n,-s)):(t&&"right"===o.triangleDirection||!t&&"left"===o.triangleDirection)&&(e.translate(r,a),e.rotate(c),this.shapeLine(e,0,0,p,h/2),this.shapeLine(e,0,0,p,-h/2),e.rotate(-c),e.translate(-r,-a))},e.prototype.arrowSolid=function(e,t){var o=this.parent.activeObj,i=o.strokeSettings.strokeWidth,r=o.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY,p=this.arrowDimension.arrowSolid.width,h=this.arrowDimension.arrowSolid.height,d=this.manipulateSaveCtx(e,p,h);p=d.x+i,h=d.y+i,this.dx=s-a,this.dy=l-n;var c=Math.atan2(this.dy,this.dx),u="arrowSolid"===o.start,g="arrowSolid"===o.end,v="circle"===o.end||"square"===o.end,f="circle"===o.start||"square"===o.start;(t&&u&&"none"===o.end||u&&!v&&!f||!t&&(g&&"none"===o.start||!u&&!v&&!f))&&this.shapeLine(e,a,n,s,l),t&&"left"===o.triangleDirection||!t&&"right"===o.triangleDirection?(e.translate(s,l),e.rotate(c),e.beginPath(),e.moveTo(i,0),e.lineTo(h/2-p,h/2),e.lineTo(h/2-p,-h/2),e.closePath(),e.fill(),e.rotate(-c),e.translate(-s,-l),o.rotatedAngle=c):(t&&"right"===o.triangleDirection||!t&&"left"===o.triangleDirection)&&(e.translate(a,n),e.rotate(c),e.beginPath(),e.moveTo(0-i,0),e.lineTo(p-h/2,h/2),e.lineTo(p-h/2,-h/2),e.closePath(),e.fill(),e.rotate(-c),e.translate(-a,-n),o.rotatedAngle=c)},e.prototype.arrowSquareStart=function(e){var t=this.parent.activeObj,o=t.strokeSettings.strokeWidth,i=t.activePoint,r=i.startX,a=i.startY,n=i.endX,s=i.endY,l="square"===t.start,p="circle"===t.end,h="squareSolid"===t.start,d="circleSolid"===t.end;(l&&"none"===t.end||l&&!p&&"square"!==t.start||h&&d)&&this.shapeLine(e,r,a,n,s),e.lineWidth=o,e.beginPath(),e.fillStyle=t.strokeSettings.strokeColor;var c=this.arrowDimension.square.width,u=this.arrowDimension.square.height,g=this.manipulateSaveCtx(e,c,u);c=g.x+o,u=g.y+o,this.dx=n-r,this.dy=s-a;var v=Math.atan2(this.dy,this.dx);"left"===t.triangleDirection?(e.translate(n,s),e.rotate(v),"squareSolid"===t.start&&e.fillRect(u/2-c,-u/2,c,u),e.strokeRect(u/2-c,-u/2,c,u),e.rotate(-v),e.translate(-n,-s),this.squareStartIntersectX1=n-u/2*Math.cos(v),this.squareStartIntersectY1=s-u/2*Math.sin(v),"square"===t.start&&"square"!==t.end&&"circle"!==t.end?this.shapeLine(e,r,a,this.squareStartIntersectX1,this.squareStartIntersectY1):"square"===t.start&&"circle"===t.end?this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1):"squareSolid"===t.start&&"squareSolid"===t.end&&this.shapeLine(e,r,a,n,s)):"right"===t.triangleDirection&&(e.lineWidth=o,e.fillStyle=t.strokeSettings.strokeColor,"squareSolid"===t.start&&"squareSolid"===t.end&&this.shapeLine(e,r,a,n,s),e.translate(r,a),e.rotate(v),"squareSolid"===t.start&&e.fillRect(u/2-c,-u/2,c,u),e.strokeRect(u/2-c,-u/2,c,u),e.rotate(-v),e.translate(-r,-a),t.rotatedAngle=v,this.squareStartIntersectX1=r+u/2*Math.cos(v),this.squareStartIntersectY1=a+u/2*Math.sin(v),"square"===t.start&&"square"!==t.end&&"circle"!==t.end&&this.shapeLine(e,n,s,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===t.start&&"circle"===t.end&&this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},e.prototype.arrowSquareEnd=function(e){var t=this.parent.activeObj,o=t.activePoint,i=o.startX,r=o.startY,a=o.endX,n=o.endY,s=t.strokeSettings.strokeWidth,l=this.arrowDimension.square.width,p=this.arrowDimension.square.height,h=this.manipulateSaveCtx(e,l,p);l=h.x+s,p=h.y+s,this.dx=a-i,this.dy=n-r;var d=Math.atan2(this.dy,this.dx);e.lineWidth=s,"right"===t.triangleDirection?(e.fillStyle=t.strokeSettings.strokeColor,"squareSolid"===t.end&&"none"===t.start&&this.shapeLine(e,i,r,a,n),e.translate(a,n),e.rotate(d),"squareSolid"===t.end&&e.fillRect(p/2-l,-p/2,l,p),e.strokeRect(p/2-l,-p/2,l,p),e.rotate(-d),e.translate(-a,-n),t.rotatedAngle=d,this.squareEndIntersectX1=a-p/2*Math.cos(d),this.squareEndIntersectY1=n-p/2*Math.sin(d),"square"===t.end&&"square"!==t.start&&"circle"!==t.start?this.shapeLine(e,i,r,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===t.start&&"square"===t.end?this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===t.start&&"square"===t.end&&this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1)):"left"===t.triangleDirection&&(e.translate(i,r),e.rotate(d),"squareSolid"===t.end&&e.fillRect(p/2-l,-p/2,l,p),e.strokeRect(p/2-l,-p/2,l,p),e.rotate(-d),e.translate(-i,-r),t.rotatedAngle=d,this.squareEndIntersectX1=i+p/2*Math.cos(d),this.squareEndIntersectY1=r+p/2*Math.sin(d),"square"===t.end&&"square"!==t.start&&"circle"!==t.start?this.shapeLine(e,a,n,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===t.start&&"square"===t.end?this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===t.start&&"square"===t.end?this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1):"squareSolid"===t.end&&"none"===t.start&&this.shapeLine(e,i,r,a,n))},e.prototype.arrowCircle=function(e,t){var o=this.parent,i=o.activeObj,r=i.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY,p=i.strokeSettings.strokeWidth;if(t&&"left"===i.triangleDirection||!t&&"right"===i.triangleDirection){e.lineWidth=p;var h=this.arrowDimension.circle.width;h=this.manipulateSaveCtx(e,h,null).x+p,e.beginPath(),e.arc(s,l,h,0,2*Math.PI),e.stroke(),e.closePath(),this.dx=s-a,this.dy=l-n;var d=this.dx*this.dx+this.dy*this.dy;if((m=(f=2*(this.dx*(a-s)+this.dy*(n-l)))*f-4*d*((a-s)*(a-s)+(n-l)*(n-l)-h*h))>=0){e.fillStyle=i.strokeSettings.strokeColor;var c=(-f-Math.sqrt(m))/(2*d),u=a+this.dx*c,g=n+this.dy*c;t?(this.startCircleIntersectX1=u,this.startCircleIntersectY1=g,this.endCircleIntersectX1=s-this.dx*c,this.endCircleIntersectY1=l-this.dy*c,e.beginPath(),e.fill(),e.beginPath(),"circle"===i.start&&"circle"===i.end?this.shapeLine(e,this.startCircleIntersectX1,this.startCircleIntersectY1,this.endCircleIntersectX1,this.endCircleIntersectY1):"circle"===i.start&&"circle"!==i.end&&"square"!==i.end&&this.shapeLine(e,a,n,this.startCircleIntersectX1,this.startCircleIntersectY1),e.stroke(),e.closePath()):(this.endCircleIntersectX1=u,this.endCircleIntersectY1=g,"circle"===i.end&&"circle"!==i.start&&"square"!==i.start&&this.shapeLine(e,a,n,this.endCircleIntersectX1,this.endCircleIntersectY1))}var v=Math.atan2(this.dy,this.dx);o.activeObj.rotatedAngle=v}else if(t&&"right"===i.triangleDirection||!t&&"left"===i.triangleDirection){e.lineWidth=p;h=this.arrowDimension.circle.width;h=this.manipulateSaveCtx(e,h,null).x+p,e.beginPath(),e.arc(a,n,h,0,2*Math.PI),e.stroke(),e.closePath(),this.dx=a-s,this.dy=n-l;var f,m;d=this.dx*this.dx+this.dy*this.dy;if((m=(f=2*(this.dx*(s-a)+this.dy*(l-n)))*f-4*d*((s-a)*(s-a)+(l-n)*(l-n)-h*h))>=0){e.fillStyle=i.strokeSettings.strokeColor;c=(-f-Math.sqrt(m))/(2*d),u=s+this.dx*c,g=l+this.dy*c;t?(this.startCircleIntersectX1=u,this.startCircleIntersectY1=g,this.endCircleIntersectX1=a-this.dx*c,this.endCircleIntersectY1=n-this.dy*c,"circle"===i.start&&"circle"===i.end?this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"circle"===i.start&&"circle"!==i.end&&"square"!==i.end&&this.shapeLine(e,s,l,this.startCircleIntersectX1,this.startCircleIntersectY1)):(this.endCircleIntersectX1=u,this.endCircleIntersectY1=g,e.beginPath(),e.fill(),e.beginPath(),"circle"===i.end&&"circle"!==i.start&&"square"!==i.start&&this.shapeLine(e,s,l,this.endCircleIntersectX1,this.endCircleIntersectY1))}v=Math.atan2(this.dy,this.dx);o.activeObj.rotatedAngle=v}},e.prototype.arrowCircleSolid=function(e,t){var o=this.parent.activeObj,i=o.activePoint,r=i.startX,a=i.startY,n=i.endX,s=i.endY,l="circleSolid"===o.start,p=o.strokeSettings.strokeWidth;if(t&&"left"===o.triangleDirection||!t&&"right"===o.triangleDirection){e.lineWidth=p,e.beginPath(),e.fillStyle=o.strokeSettings.strokeColor,(t&&l&&"none"===o.end||l&&"circle"!==o.end&&"square"!==o.end||!t&&"circleSolid"===o.end&&"none"===o.start)&&this.shapeLine(e,r,a,n,s);var h=this.arrowDimension.circle.width;h=this.manipulateSaveCtx(e,h,null).x+p,this.dx=n-r,this.dy=s-a,e.save(),e.beginPath(),e.arc(n,s,h,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),o.rotatedAngle=Math.atan2(this.dy,this.dx)}else if(t&&"right"===o.triangleDirection||!t&&"left"===o.triangleDirection){e.lineWidth=p,e.beginPath(),e.fillStyle=o.strokeSettings.strokeColor,(t&&l&&"none"===o.end||l&&"circle"!==o.end&&"square"!==o.end||!t&&"circleSolid"===o.end&&"none"===o.start)&&this.shapeLine(e,r,a,n,s);h=this.arrowDimension.circle.width;h=this.manipulateSaveCtx(e,h,null).x+p,this.dx=n-r,this.dy=s-a,e.save(),e.beginPath(),e.arc(r,a,h,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),o.rotatedAngle=Math.atan2(this.dy,this.dx)}},e.prototype.arrowBar=function(e,t){var o=this.parent,i=o.activeObj,r=i.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY,p=i.strokeSettings.strokeWidth;if(t&&"left"===i.triangleDirection||!t&&"right"===i.triangleDirection){e.lineWidth=p,e.beginPath(),e.fillStyle=i.strokeSettings.strokeColor,(t&&"bar"===i.start&&"none"===i.end||"bar"===i.start&&"circle"!==i.end&&"square"!==i.end||!t&&("bar"===i.end&&"none"===i.start||"bar"===i.end&&"circle"!==i.start&&"square"!==i.start))&&this.shapeLine(e,a,n,s,l);var h=this.arrowDimension.bar.width,d=this.arrowDimension.bar.height;h=(u=this.manipulateSaveCtx(e,h,d)).x+p,d=u.y+p,this.dx=s-a,this.dy=l-n;var c=Math.atan2(this.dy,this.dx);e.translate(s,l),e.rotate(c),e.fillRect(d/4-h,-d/2,h,d),e.rotate(-c),e.translate(-s,-l),i.rotatedAngle=c}else if(t&&"right"===i.triangleDirection||!t&&"left"===i.triangleDirection){e.lineWidth=p,e.beginPath(),e.fillStyle=i.strokeSettings.strokeColor,(t&&"bar"===i.start&&"none"===i.end||"bar"===i.start&&"circle"!==i.end&&"square"!==i.end||!t&&"bar"===i.end&&"none"===i.start)&&this.shapeLine(e,a,n,s,l);var u;h=this.arrowDimension.bar.width,d=this.arrowDimension.bar.height;h=(u=this.manipulateSaveCtx(e,h,d)).x+p,d=u.y+p,this.dx=s-a,this.dy=l-n;c=Math.atan2(this.dy,this.dx);e.translate(a,n),e.rotate(c),e.fillRect(d/4-h,-d/2,h,d),e.rotate(-c),e.translate(-a,-n),o.activeObj.rotatedAngle=c}},e.prototype.shapeImage=function(e){var t=this.parent,o=t.activeObj,i=o.activePoint,r=i.startX,a=i.startY,n=i.width,s=i.height,l=o.imageCanvas.getContext("2d");if(e===this.lowerContext&&this.isImageApply){var p={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o.imageElement.width,height:o.imageElement.height,obj:p,isImgShape:null}}),(n<p.width/5||s<p.height/5)&&(l.clearRect(0,0,o.imageCanvas.width,o.imageCanvas.height),t.notify("selection",{prop:"applyTransformToImg",onPropertyChange:!1,value:{ctx:l}}),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("selection",{prop:"setImageClarity",onPropertyChange:!1,value:{bool:!1}}),this.isImageApply=!1)}var h={startX:0,startY:0,width:0,height:0};h.width=n,h.height=s,4===o.flipObjColl.length&&(o.flipObjColl=[],o.shapeFlip=""),h.startX=(n-h.width)/2+r,h.startY=(s-h.height)/2+a;var d=e.globalAlpha;e.globalAlpha=o.opacity,o.rotateFlipColl&&o.rotateFlipColl.length>0?this.rotateImage(e):e.drawImage(o.imageCanvas,h.startX,h.startY,h.width,h.height),e.globalAlpha=d,t.currObjType.isText=!1},e.prototype.shapeText=function(e){var t=this.parent,o=e.filter,i=t.activeObj,r=i.activePoint,a=r.startX,n=r.startY,s=r.width,l=r.height,p=i.keyHistory.split("\n"),h=i.textSettings,d=h.fontFamily,c=h.bold,u=h.italic,g=h.underline,v=h.strikethrough,f=i.textSettings.fontSize,m=((f+.25*f)*p.length-f*p.length)/p.length;e.filter="none";var b=e.fillStyle;""!==i.strokeSettings.fillColor&&(e.fillStyle=i.strokeSettings.fillColor,e.fillRect(i.activePoint.startX,i.activePoint.startY,i.activePoint.width,i.activePoint.height)),e.fillStyle=b;for(var C=0;C<p.length;C++){var y=p[C],x=(C+1)*f*.9+C*m;-360===t.transform.degree&&(t.transform.degree=0),0===t.transform.degree||180===t.transform.degree?f>l&&(f=i.textSettings.fontSize=l/1.18):f>s&&(f=i.textSettings.fontSize=s/1.18),e.strokeStyle=i.strokeSettings.outlineColor,e.fillStyle=i.strokeSettings.strokeColor;var P,w=e.lineWidth,j={width:0,height:0};t.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:j,dimension:{width:e.canvas.width,height:e.canvas.height}}}),P=j;var S=e.canvas.id===t.element.id+"_tempCanvas",O=Math.max(1,i.strokeSettings.outlineWidth/2);/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$|^[a-zA-Z]+$/.test(i.strokeSettings.outlineColor)?(e.lineWidth=O*(.5*(S?Math.floor((f-1)/60):Math.floor((f-1)/16))+.5),S&&(e.lineWidth*=(P.width+P.height)/2,0!==t.transform.degree&&(e.lineWidth/=1.8))):e.lineWidth=1;var T="";if(c&&(T="bold "),u&&(T="italic "),c&&u&&(T="italic bold "),e.font=T+f+"px "+d,4===i.flipObjColl.length&&(i.flipObjColl=[],i.shapeFlip=""),i.rotateFlipColl&&i.rotateFlipColl.length>0)this.rotateText(e);else{if(e.strokeText(y,a+.1*f,n+x),e.fillText(y,a+.1*f,n+x),g){var k=x+.1*f;this.drawTextDecoration(e,y,a,n,k,f,.1)}if(v){k=x-m-.025*f;this.drawTextDecoration(e,y,a,n,k,f,.1)}}e.lineWidth=w}e.filter=o,t.currObjType.isText=!1,this.upperContext===e&&this.drawOuterSelection(e)},e.prototype.drawTextDecoration=function(e,t,o,i,r,a,n){void 0===n&&(n=.1);var s=e.lineWidth,l=e.measureText(t).width;e.lineWidth=.1*a,e.beginPath(),e.moveTo(o+a*n,i+r),e.lineTo(o+l+a*n,i+r),e.strokeStyle=e.fillStyle,e.stroke(),e.lineWidth=s,e.strokeStyle=this.parent.activeObj.strokeSettings.outlineColor},e.prototype.updateActPoint=function(e,t){var o=this.parent,i=o.activeObj,r=i.activePoint;return"horizontal"===e.toLowerCase()?r.startX<=t.canvas.width/2?(r.startX=t.canvas.width/2+(t.canvas.width/2-r.endX),r.endX=r.startX+r.width,this.updateActiveObject(r,i),o.activeObj=i):r.startX>=t.canvas.width/2&&(r.startX=t.canvas.width-r.endX,r.endX=r.startX+r.width,this.updateActiveObject(r,i),o.activeObj=i):"vertical"===e.toLowerCase()&&(r.startY<=t.canvas.height/2?(r.startY=t.canvas.height/2+(t.canvas.height/2-r.endY),r.endY=r.startY+r.height,this.updateActiveObject(r,i),o.activeObj=i):r.startY>=t.canvas.height/2&&(r.startY=t.canvas.height-r.endY,r.endY=r.startY+r.height,this.updateActiveObject(r,i),o.activeObj=i)),r},e.prototype.rotateImage=function(e){var t,o=this.parent,i=o.activeObj,r=(0,g.extend)({},o.activeObj,null,!0);-450===(t=0===i.shapeDegree?o.transform.degree:o.transform.degree-i.shapeDegree)&&(t=-90),t<0&&(t=360+t);var a={startX:0,startY:0,width:0,height:0};a.width=t%90==0&&t%180!=0?i.activePoint.height:i.activePoint.width,a.height=t%90==0&&t%180!=0?i.activePoint.width:i.activePoint.height,a.startX=i.activePoint.startX,a.startY=i.activePoint.startY;var n,s=a.startX,l=a.startY,p=[];e.save();for(var h=0,d=i.rotateFlipColl.length;h<d;h++){var c=i.rotateFlipColl[h];p.push(c),"number"==typeof c?(-450===(n=c)&&(n=-90),n<0&&(n=360+n),a.width=n%90==0&&n%180!=0?i.activePoint.height:i.activePoint.width,a.height=n%90==0&&n%180!=0?i.activePoint.width:i.activePoint.height,e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*c),e.translate(-e.canvas.height/2,-e.canvas.width/2),n%90==0&&n%270!=0||0===n?(l=e.canvas.width-(i.activePoint.startX+i.activePoint.width),l+=(i.activePoint.width-a.height)/2,s=a.startY):n%270==0&&(s=e.canvas.height-(i.activePoint.startY+i.activePoint.height),s+=(i.activePoint.height-a.width)/2,l=a.startX),a.startX=s,a.startY=l,i.activePoint.startX=s,i.activePoint.startY=l,i.activePoint.endX=i.activePoint.startX+a.width,i.activePoint.endY=i.activePoint.startY+a.height,i=this.updateWidthHeight(i)):("horizontal"===c&&t%90==0&&t%180!=0?c="vertical":"vertical"===c&&t%90==0&&t%180!=0&&(c="horizontal"),"horizontal"===c?(e.translate(e.canvas.width,0),e.scale(-1,1),i.activePoint=this.updateActPoint("horizontal",e)):"vertical"===c&&(e.translate(0,e.canvas.height),e.scale(1,-1),i.activePoint=this.updateActPoint("vertical",e)),a.startX=i.activePoint.startX,a.startY=i.activePoint.startY),a.startX=i.activePoint.startX,a.startY=i.activePoint.startY,s=a.startX,l=a.startY}0!==i.rotatedAngle&&o.notify("shape",{prop:"setPointCollForShapeRotation",onPropertyChange:!1,value:{obj:i}}),e.drawImage(i.imageCanvas,a.startX,a.startY,a.width,a.height),e.restore(),o.activeObj=r,360!==o.transform.degree&&-360!==o.transform.degree||(o.transform.degree=0)},e.prototype.rotateText=function(e){var t,o=this.parent,i=o.activeObj,r=(0,g.extend)({},o.activeObj,null,!0),a=o.activeObj.activePoint;-450===(t=0===i.shapeDegree?o.transform.degree:o.transform.degree-i.shapeDegree)&&(t=-90),t<0&&(t=360+t);var n={startX:0,startY:0,width:0,height:0};n.width=t%90==0&&t%180!=0?a.height:a.width,n.height=t%90==0&&t%180!=0?a.width:a.height,n.startX=a.startX,n.startY=a.startY;var s,l=n.startX,p=n.startY,h=[];e.save();for(var d=0,c=i.rotateFlipColl.length;d<c;d++){var u=i.rotateFlipColl[d];h.push(u),"number"==typeof u?(-450===(s=u)&&(s=-90),s<0&&(s=360+s),n.width=s%90==0&&s%180!=0?a.height:a.width,n.height=s%90==0&&s%180!=0?a.width:a.height,e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*u),e.translate(-e.canvas.height/2,-e.canvas.width/2),s%90==0&&s%270!=0||0===s?(p=e.canvas.width-a.endX,l=a.startY):s%270==0&&(l=e.canvas.height-a.endY,p=a.startX),n.startX=l,n.startY=p,a.startX=l,a.startY=p,a.endX=a.startX+n.width,a.endY=a.startY+n.height,i=this.updateWidthHeight(i)):("horizontal"===u&&t%90==0&&t%180!=0?u="vertical":"vertical"===u&&t%90==0&&t%180!=0&&(u="horizontal"),"horizontal"===u?(e.translate(e.canvas.width,0),e.scale(-1,1)):"vertical"===u&&(e.translate(0,e.canvas.height),e.scale(1,-1)),i.activePoint=a=this.updateActPoint(u,e),n.startX=a.startX,n.startY=a.startY),n.startX=a.startX,n.startY=a.startY,l=n.startX,p=n.startY}0!==i.rotatedAngle&&o.notify("shape",{prop:"setPointCollForShapeRotation",onPropertyChange:!1,value:{obj:i}}),p+=.4*i.textSettings.fontSize,this.textFlipDegree(e,l,p),e.restore(),o.activeObj=r,360!==o.transform.degree&&-360!==o.transform.degree||(o.transform.degree=0)},e.prototype.textFlipDegree=function(e,t,o){for(var i=this.parent.activeObj,r=i.keyHistory.split("\n"),a=i.textSettings.fontSize,n=(a*r.length-a*r.length)/r.length,s=.85*a+n,l=0,p=r.length;l<p;l++){var h=r[l];if(l>0&&(1===l&&(s-=.85*a),s+=a+.15*a),e.strokeText(h,t+.15*a,o+s+(l>0?.25*a:.35*-a)),e.fillText(h,t+.15*a,o+s+(l>0?.25*a:.35*-a)),i.textSettings.underline){var d=s+(l>0?.35*a:.25*-a);this.drawTextDecoration(e,h,t,o,d,a,.15)}if(i.textSettings.strikethrough){d=s-n+(l>0?.04*-a:.64*-a);this.drawTextDecoration(e,h,t,o,d,a,.1)}}},e.prototype.clearOuterCanvas=function(e){var t=this.parent,o=t.img,i=o.destLeft,r=o.destTop,a=o.destWidth,n=o.destHeight,s=i>0?i:0,l=r>0?r:0;e.clearRect(0,0,s,t.lowerCanvas.height),e.clearRect(i+a,0,t.lowerCanvas.width-(i+a),t.lowerCanvas.height),e.clearRect(0,0,t.lowerCanvas.width,l),e.clearRect(0,r+n,t.lowerCanvas.width,t.lowerCanvas.height-(r+n)),""!==t.transform.currFlipState&&(t.img.destLeft=i,t.img.destTop=r)},e.prototype.setDestPoints=function(){var e,t=this.parent,o=t.transform,i=o.degree,r=o.zoomFactor;if(i%90==0&&i%180!=0){var a={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcHeight,height:t.img.srcWidth,obj:a,isImgShape:null}}),e=a,this.isRotateZoom&&(e.width+=e.width*r,e.height+=e.height*r,t.img.destWidth=e.height,t.img.destHeight=e.width),t.img.destLeft=(t.lowerCanvas.clientWidth-e.height)/2,t.img.destTop=(t.lowerCanvas.clientHeight-e.width)/2,t.img.destWidth=e.height,t.img.destHeight=e.width}else{a={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcWidth,height:t.img.srcHeight,obj:a,isImgShape:null}}),e=a,this.isRotateZoom&&(e.width+=e.width*r,e.height+=e.height*r,t.img.destWidth=e.width,t.img.destHeight=e.height),t.img.destLeft=(t.lowerCanvas.clientWidth-e.width)/2,t.img.destTop=(t.lowerCanvas.clientHeight-e.height)/2,t.img.destWidth=e.width,t.img.destHeight=e.height}},e.prototype.updateCurrTransState=function(e,t,o,i){var r=this.parent,a=r.img.destLeft,n=r.img.destTop;"initial"===e&&(this.lowerContext.setTransform(1,0,0,1,0,0),(0,g.isNullOrUndefined)(t)&&this.setDestPoints()),r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape?(this.currTransState(e,!0,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&0===r.transform.straighten&&(0,g.isNullOrUndefined)(i)&&(r.img.destLeft=a,r.img.destTop=n),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)):(this.currTransState(e,null,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&0===r.transform.straighten&&(0,g.isNullOrUndefined)(i)&&(r.img.destLeft=a,r.img.destTop=n))},e.prototype.currTransState=function(e,t,o,i){var r=this.parent;o=o||this.lowerContext,"initial"===e?this.setTransformColl(o,e):"reverse"===e&&(this.setTransformColl(o,e),this.setClientTransDim(t),(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape&&(0,g.isNullOrUndefined)(i))&&(i&&(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}}),i&&(r.img.destLeft-=r.panPoint.totalPannedClientPoint.x,r.img.destTop-=r.panPoint.totalPannedClientPoint.y)))},e.prototype.setTransformColl=function(e,t){var o=this.parent;if("initial"===t)for(var i=0,r=o.rotateFlipColl.length;i<r;i++)this.setTransform(e,o.rotateFlipColl[i]);else if("reverse"===t)for(i=o.rotateFlipColl.length-1;i>=0;i--)this.setTransform(e,o.rotateFlipColl[i],!0)},e.prototype.setTransform=function(e,t,o){var i=this.parent;switch(o&&90===t?t=-90:o&&-90===t&&(t=90),"horizontal"===t&&i.transform.degree%90==0&&i.transform.degree%180!=0?t="vertical":"vertical"===t&&i.transform.degree%90==0&&i.transform.degree%180!=0&&(t="horizontal"),i.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),i.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),(0,g.isNullOrUndefined)(o)&&e.clearRect(0,0,e.canvas.width,e.canvas.height),t){case 90:case-90:e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*t),e.translate(-e.canvas.width/2,-e.canvas.height/2);break;case"horizontal":e.translate(e.canvas.width,0),e.scale(-1,1);break;case"vertical":e.translate(0,e.canvas.height),e.scale(1,-1)}i.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!1}}),i.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}})},e.prototype.drawImgToCanvas=function(e){var t=this.parent;this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.img.destWidth=e.width,t.img.destHeight=e.height,this.isInitialLoading&&(t.notify("filter",{prop:"initFilter",onPropertyChange:!1}),this.isInitialLoading=!1);var o=this.lowerContext.filter;this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.drawImage(),(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.lowerContext.filter=o},e.prototype.renderImage=function(e,t,o,i){var r=this.parent;r.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),(0,g.isNullOrUndefined)(t)&&(this.upperContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.lowerContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height)),e?this.setTransformColl(this.lowerContext,"initial"):(0!==r.transform.zoomFactor&&(this.isRotateZoom=!0),this.updateCurrTransState("initial",null,null,i)),r.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),r.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),e?this.setTransformColl(this.lowerContext,"reverse"):(this.updateCurrTransState("reverse",null,null,i),this.isRotateZoom=!1),o?r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}):r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),this.clearOuterCanvas(this.lowerContext),(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},e.prototype.imageOnLoad=function(e){var o=this,i=this.parent,r=this;i.imageLoaded=!1,i.baseImg.src=e,i.baseImg.onload=function(){i.imgSrc=e,i.isUndoRedo||i.notify("filter",{prop:"update-finetunes",onPropertyChange:!1}),r.lowerContext.imageSmoothingQuality=i.imageSmoothingEnabled?"high":"low",r.lowerContext.drawImage(i.baseImg,0,0,r.parent.lowerCanvas.width,r.parent.lowerCanvas.height);var a=!1,n=!1;if(i.isImageUpdated){var s=i.img,l=s.srcWidth,p=s.srcHeight,h=i.baseImgCanvas,d=h.width,c=h.height;a=l!==d||p!==c,n=i.baseImg.width===d&&i.baseImg.height===c}(0,b.hideSpinner)(i.element),i.element.style.opacity="1",r.updateBaseImgCanvas();var u={fileName:o.fileName,fileType:o.fileType,isValidImage:!0};if(r.updateCanvas(a,n),i.currObjType.isUndoZoom&&(i.currObjType.isUndoZoom=!1,r.parent.lowerCanvas.style.display="block"),i.isUndoRedo=o.isErrorImage=!1,g.Browser.isDevice){i.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),i.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1});var v={isApplyBtn:!1,isDevice:g.Browser.isDevice,isOkBtn:null,isResize:null,isFrame:null,isMainToolbar:!0};i.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:v}),i.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1})}else{i.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1});v={isApplyBtn:!1,isDevice:!1,isOkBtn:null};i.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:v})}if(i.isImageLoaded&&"0.5"!==i.element.style.opacity){i.trigger("fileOpened",u);var f={action:"file-open",actionEventArgs:u};i.triggerEditCompleteEvent(f)}"Bmp"===o.fileType&&(o.fileType=t.Png),i.imageLoaded=!0},i.baseImg.onerror=function(){(0,b.hideSpinner)(i.element),r.isErrorImage=!0,r.errorLoading()}},e.prototype.errorLoading=function(){this.parent.trigger("fileOpened",{fileName:null,fileType:null,isValidImage:!1})},e.prototype.updateBaseImgCanvas=function(){var e=this.parent;if(!e.aspectRatioBaseDimension&&e.imageSettings.width&&e.imageSettings.height){var t=(e.baseImg.width/e.imageSettings.width+e.baseImg.height/e.imageSettings.height)/2;t=t<1?1:t,e.baseImgCanvas.width=e.imageSettings.width*t,e.baseImgCanvas.height=e.imageSettings.height*t,e.baseImgCanvas.getContext("2d").drawImage(e.baseImg,0,0,e.baseImgCanvas.width,e.baseImgCanvas.height)}else e.baseImgCanvas.width=e.baseImg.width,e.baseImgCanvas.height=e.baseImg.height,e.baseImgCanvas.getContext("2d").drawImage(e.baseImg,0,0)},e.prototype.updateCanvas=function(e,t){var o=this.parent;o.isImageUpdated&&e?!t&&e&&(o.img.srcLeft=0,o.img.srcTop=0,o.img.srcWidth=o.baseImgCanvas.width,o.img.srcHeight=o.baseImgCanvas.height,o.currSelectionPoint=null,o.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:"",straighten:0,destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,zoomFactor:0,previousZoomValue:0,aspectWidth:null,aspectHeight:null,frame:"none",straightenZoom:0,adjustmentLevel:{brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},currentFilter:""}):(o.img.srcWidth=o.baseImgCanvas.width,o.img.srcHeight=o.baseImgCanvas.height);var i={width:0,height:0};o.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o.img.srcWidth,height:o.img.srcHeight,obj:i,isImgShape:null}});var r=i;o.img.destLeft=(o.lowerCanvas.clientWidth-r.width)/2,o.img.destTop=(o.lowerCanvas.clientHeight-r.height)/2,this.drawImgToCanvas(r),this.origDim.width=o.img.destWidth,this.origDim.height=o.img.destHeight,this.zoomCrop.width=o.img.destWidth,this.zoomCrop.height=o.img.destHeight,o.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:o.img.destWidth,height:o.img.destHeight}});var a={startX:o.img.destLeft,startY:o.img.destTop,width:o.img.destWidth,height:o.img.destHeight};o.notify("crop",{prop:"setCropDestPoints",onPropertyChange:!1,value:{point:a}});var n=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"zoom",isPreventApply:null}}),this.lowerContext.filter=n,o.img.destWidth>0&&o.img.destHeight>0&&(o.isImageLoaded=!0),o.isUndoRedo&&""!==o.transform.currFlipState&&o.notify("transform",{prop:"flipImage",onPropertyChange:!1,value:{direction:o.toPascalCase(o.transform.currFlipState)}}),o.disabled&&o.element.setAttribute("class","e-disabled"),(1!==o.zoomSettings.zoomFactor||o.zoomSettings.zoomPoint)&&o.zoom(o.zoomSettings.zoomFactor,o.zoomSettings.zoomPoint),(0,g.isNullOrUndefined)(this.initZoomValue)&&(this.initZoomValue=o.zoomSettings.zoomFactor),this.isImageEdited=!1},e.prototype.resetFrameZoom=function(e){var t=this.parent;if(!(0,g.isNullOrUndefined)(t.tempFrameZoomLevel)){var o=t.tempFrameZoomLevel;t.tempFrameZoomLevel=null,t.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:o,zoomPoint:null,isResize:!0}});var i=t.cancelCropSelection;e&&i&&(i.previousObj.frameObj=(0,g.extend)({},t.frameObj,null,!0),i.currentObj.frameObj=(0,g.extend)({},t.frameObj,null,!0),i.previousObj.frame=i.currentObj.frame=t.frameObj.type),this.updateCropSelObj(),t.cancelCropSelection=null}},e.prototype.performCancel=function(e,t,o){var i=this.parent;o&&(i.noPushUndo=!1);var r=i.isStraightening;e=e||!1;var a={bool:!1};i.allowDownScale=!0,i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),(0,g.isNullOrUndefined)(t)&&JSON.stringify(i.frameObj)!==JSON.stringify(i.tempFrameObj)&&((0,g.extend)(i.frameObj,i.tempFrameObj),this.renderImage(null,null,!0)),this.resetFrameZoom(!1);var n={action:""};if(a.bool)n.action="freehand-draw",i.notify("freehand-draw",{prop:"cancelFhd",onPropertyChange:!1}),i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if("block"===i.textArea.style.display||"inline-block"===i.textArea.style.display)n.action="text-editing",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}}),i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:i.activeObj}}),i.drawingShape&&i.enableShapeDrawing(i.toPascalCase(i.drawingShape),!0);else if(i.activeObj.shape&&"redact"===i.activeObj.shape||!((!g.Browser.isDevice||g.Browser.isDevice&&!r)&&document.querySelector("#"+i.element.id+"_sliderWrapper")||i.currObjType.isFiltered))if(i.activeObj.shape&&"redact"===i.activeObj.shape||!e||g.Browser.isDevice&&(!g.Browser.isDevice||r))this.cancelItems(n),i.transform.zoomFactor>0?(i.togglePan=!0,i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(i.togglePan=!1,i.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}));else{l={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:l})}else{n.action=i.isFinetuneBtnClick?"fine-tune":"filter",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,i.notify("filter",{prop:"setBevelFilter",onPropertyChange:!1,value:{bevelFilter:this.lowerContext.filter}}),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.redrawImgWithObj(),i.currObjType.isFiltered=!1;var s={tempAdjustmentLevel:null};i.notify("filter",{prop:"getTempAdjustmentLevel",onPropertyChange:!1,value:{obj:s}}),i.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:(0,g.extend)({},s.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,radius:null,outlineColor:"",outlineWidth: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}});var l={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};i.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:l}),i.activeObj.shape&&"image"===i.activeObj.shape&&i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.drawingShape&&(i.drawingShape=null,i.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}))}this.isShapeTextInserted=!1,this.isNewPath=!1,i.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}),o&&(i.noPushUndo=!1),i.drawingShape=null,i.notify("draw",{prop:"resetTempObjColl"}),i.notify("draw",{prop:"resetTempPointColl"}),i.isMaskImage=i.isFinetuneBtnClick=!1;var p={action:"cancel",actionEventArgs:n};i.triggerEditCompleteEvent(p)},e.prototype.cancelItems=function(e){var t,o=this.parent,i=!1,r=o.element.id,a=o.element.querySelector("#"+r+"_aspectratio"),n=o.element.querySelector("#"+r+"_nonaspectratio");if(void 0!==o.activeObj.shape&&(t=o.activeObj.shape.split("-")),(void 0===t&&o.currObjType.isCustomCrop||void 0!==t&&"crop"===t[0])&&(i=!0),i&&o.isCropTab&&(o.isCropTab=!1,o.transform.zoomFactor=o.transform.defaultZoomFactor),o.isResize&&(a||n||"resize-toolbar"===o.currentToolbar)){e.action="resize";var s={width:null,height:null};o.notify("selection",{prop:"getNumTextValue",onPropertyChange:!1,value:{obj:s}});var l={x:s.width,y:s.height},p=o.element.querySelector("#"+o.element.id+"_aspectratio"),h=o.element.querySelector(".e-ie-toolbar-aspect-ratio-btn");if(l&&l.x&&l.y&&!(0,g.isNullOrUndefined)(o.aspectWidth))if(p||h&&!h.classList.contains("e-hidden"))o.notify("transform",{prop:"resizeImage",value:{width:o.aspectWidth,height:o.aspectHeight}});else{var d=o.currObjType.isUndoAction;o.currObjType.isUndoAction=!1,o.notify("transform",{prop:"resizeCrop",value:{width:o.aspectWidth,height:o.aspectHeight}}),o.currObjType.isUndoAction=d}var c={prevCropObj:o.prevCropObj},u={prevObj:o.prevObj};if(o.notify("toolbar",{prop:"getPrevCropObj",onPropertyChange:!1,value:{obj:c}}),o.notify("toolbar",{prop:"getPrevObj",onPropertyChange:!1,value:{obj:u}}),c.prevCropObj&&u.prevObj){o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.cropObj=(0,g.extend)({},c.prevCropObj,{},!0),this.setCurrentObj(u.prevObj),o.objColl=u.prevObj.objColl,o.pointColl=u.prevObj.pointColl,o.freehandCounter=o.pointColl.length,o.transform.straighten=0,o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}});var v=o.currSelectionPoint?(0,g.extend)({},o.currSelectionPoint,{},!0):null;o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-o.transform.zoomFactor,zoomPoint:null,isResize:!0}}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:u.prevObj.defaultZoom,zoomPoint:null,isResize:!0}}),o.currSelectionPoint=v,u.prevObj.zoomFactor&&o.setProperties({zoomSettings:{zoomFactor:u.prevObj.zoomFactor}},!0),o.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:o.zoomSettings.zoomFactor}})}o.isResize=!1,o.notify("transform",{prop:"setResizedImgAngle",onPropertyChange:!1,value:{angle:null}});var f=o.isCropTab;o.isCropTab=!1,this.updateCropSelObj(),o.cancelCropSelection=null,o.isCropTab=f}switch(!0){case o.togglePen:e.action="freehand-draw",this.cancelPen();break;case"text"===o.activeObj.shape:e.action="text",this.cancelText();break;case-1!==["rectangle","ellipse","line","arrow","path","image","redact"].indexOf(o.activeObj.shape):e.action=o.activeObj.shape,this.cancelShape(),o.currObjType.isRedact=!1;break;case i:e.action="crop-selection",this.cancelSelection();break;default:o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})}o.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),o.upperCanvas.style.cursor=o.cursor="default",o.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null,radius:null,outlineColor:"",outlineWidth:null};o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:!1,isZooming:null}})},e.prototype.cancelPen=function(){var e=this.parent;this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.togglePen=!1,e.upperCanvas.style.cursor=e.cursor="default";var t=(0,g.extend)([],e.pointColl,[],!0);e.pointColl={};for(var o=0;o<this.tempFreehandCounter;o++)e.pointColl[o]=t[o];e.freehandCounter=this.tempFreehandCounter,e.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:this.tempCurrFhdIndex}}),e.activeObj.strokeSettings=this.tempStrokeSettings,e.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:e.activeObj.strokeSettings,strokeColor:null,fillColor:null,strokeWidth:null,radius:null}}),e.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:this.tempStrokeWidth}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),e.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}}),e.objColl=(0,g.extend)([],this.tempObjColl,[],!0),e.pointColl=(0,g.extend)([],this.tempPointColl,[],!0),e.freehandCounter=e.pointColl.length,this.tempPointColl={},this.renderImage(),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok",isCancel:!0}})},e.prototype.cancelText=function(){var e=this.parent;if(e.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:this.tempTextSettings,fontFamily:null,fontSize:null}}),e.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null,radius:null}}),(0,g.isNullOrUndefined)(e.activeObj.currIndex))e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height);else{var t={appliedUndoRedoColl:[]};e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:t}});var o=t.appliedUndoRedoColl.length,i=t.appliedUndoRedoColl[o-1];this.prevActObj&&i&&i.currentObjColl.length&&i.currentObjColl[i.currentObjColl.length-1].currIndex===this.prevActObj.currIndex?(e.activeObj=this.prevActObj,this.prevActObj=null):(e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height))}e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.tempTextSettings={text:"Enter Text",fontFamily:e.fontFamily.default,fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1,strikethrough:!1},e.objColl=(0,g.extend)([],this.tempObjColl,[],!0),e.pointColl=(0,g.extend)([],this.tempPointColl,[],!0),this.renderImage(),this.tempObjColl=[],e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok",isCancel:!0}})},e.prototype.cancelShape=function(){var e=this.parent;if(e.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null,radius:null}}),(0,g.isNullOrUndefined)(e.activeObj.currIndex))e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height);else if(this.isNewPath)e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.renderImage();else{var t={appliedUndoRedoColl:[]};e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:t}});for(var o=void 0,i=0,r=t.appliedUndoRedoColl.length;i<r;i++)for(var a=t.appliedUndoRedoColl[i].currentObjColl,n=0,s=a.length;n<s;n++)if(this.prevActObj&&this.prevActObj.currIndex&&a[n].currIndex===this.prevActObj.currIndex){o=a[0];break}this.prevActObj&&o?(e.activeObj=this.prevActObj,this.prevActObj=null,e.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:e.activeObj}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):(e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height));var l={undoRedoStep:null};e.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:l}}),t.appliedUndoRedoColl[l.undoRedoStep-1]?e.objColl=(0,g.extend)([],t.appliedUndoRedoColl[l.undoRedoStep-1].currentObjColl,[],!0):e.objColl=[],this.renderImage()}e.currObjType.isDragging=!1,e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),e.objColl=(0,g.extend)([],this.tempObjColl,[],!0),e.pointColl=(0,g.extend)([],this.tempPointColl,[],!0),this.renderImage(),this.tempObjColl=[],e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok",isCancel:!0}})},e.prototype.cancelSelection=function(){var e=this.parent;if(e.cancelCropSelection){var t={value:e.tempStraighten};e.transform.straighten=t.value,e.straightenBaseImageCanvas(),e.notify("freehand-draw",{prop:"resetStraightenPoint"}),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),e.notify("draw",{prop:"setStraightenActObj",value:{activeObj:e.activeObj}}),e.notify("crop",{prop:"resizeWrapper"}),this.updateCropSelObj(),this.tempStraightenDestPoints&&JSON.stringify(this.tempStraightenDestPoints)!==JSON.stringify(this.straightenDestPoints)&&(this.straightenDestPoints=(0,g.extend)({},this.tempStraightenDestPoints,{},!0))}},e.prototype.updateCropSelObj=function(){var e=this.parent;e.cancelCropSelection&&(e.cropObj=(0,g.extend)({},e.cancelCropSelection.previousCropObj,{},!0),e.afterCropActions=e.cancelCropSelection.previousObj.afterCropActions,e.notify("undo-redo",{prop:"undoDefault",onPropertyChange:!1,value:{obj:e.cancelCropSelection}}),e.currSelectionPoint=(0,g.extend)({},e.cancelCropSelection.previousCropObj.activeObj,!0),e.currSelectionPoint&&(0,g.isNullOrUndefined)(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null),this.clearOuterCanvas(this.lowerContext),(e.isCircleCrop||e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}))},e.prototype.updateCropSelection=function(){var e=this.parent,t={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:t}});var o=t.currObj;o.objColl=(0,g.extend)([],e.objColl,[],!0),o.pointColl=(0,g.extend)([],e.pointColl,[],!0),o.afterCropActions=(0,g.extend)([],e.afterCropActions,[],!0);var i={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:i}}),o.selPointColl=(0,g.extend)([],i.selPointColl,[],!0),e.cancelCropSelection={operation:"cropTransform",previousObj:o,currentObj:o,previousObjColl:o.objColl,currentObjColl:o.objColl,previousPointColl:o.pointColl,currentPointColl:o.pointColl,previousSelPointColl:o.selPointColl,currentSelPointColl:o.selPointColl,previousCropObj:(0,g.extend)({},e.cropObj,{},!0),currentCropObj:(0,g.extend)({},e.cropObj,{},!0),previousText:null,currentText:null,filter:null,isCircleCrop:e.isCircleCrop}},e.prototype.updateFlipPan=function(e){var t=this.parent;if(""!==t.transform.currFlipState){var o=this.lowerContext.filter;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("transform",{prop:"rotatedFlip",onPropertyChange:!1}),this.lowerContext.filter="none",t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=o,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),e&&this.drawObject("duplicate",e)}},e.prototype.select=function(e,t,o,i,r){var a=this.parent;if(e=e.toLowerCase(),!a.disabled&&a.isImageLoaded){a.allowDownScale=!1;var n={currObj:{}};a.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=(0,g.extend)([],a.objColl,[],!0),s.pointColl=(0,g.extend)([],a.pointColl,[],!0),s.afterCropActions=a.afterCropActions;var l={selPointColl:null};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=(0,g.extend)([],l.selPointColl,[],!0),a.notify("crop",{prop:"setPreviousCropCurrentObj",onPropertyChange:!1,value:{obj:s}}),a.transform.zoomFactor>0&&a.activeObj.shape&&"crop"===a.activeObj.shape.split("-")[0]&&(0,g.isNullOrUndefined)(this.currSelPoint)&&(this.currSelPoint=(0,g.extend)({},a.activeObj,{},!0));var p=!1,h=void 0;void 0!==a.activeObj.shape&&(h=a.activeObj.shape.split("-")),(void 0===h&&a.currObjType.isCustomCrop||void 0!==h&&"crop"===h[0])&&(p=!0);var d={currObj:{}};a.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:d}});var c=d.currObj;if(c.objColl=(0,g.extend)([],a.objColl,[],!0),c.pointColl=(0,g.extend)([],a.pointColl,[],!0),c.afterCropActions=(0,g.extend)([],a.afterCropActions,[],!0),a.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),a.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),this.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.upperCanvas.style.display="block",a.currSelectionPoint||0!==a.transform.defaultZoomFactor||0!==a.transform.degree&&0!==a.panPoint.totalPannedInternalPoint.x&&0!==a.panPoint.totalPannedInternalPoint.y&&!p){if(a.isCircleCrop=!1,0!==a.transform.defaultZoomFactor&&!this.isResizeSelect){var u=a.isCropTab;a.isCropTab=!1,a.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),a.isCropTab=u,this.resetPanPoints()}a.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),a.isCropTab=!0,a.isCircleCrop=!1,this.isResizeSelect||a.notify("crop",{prop:"setCurrSelPoints",onPropertyChange:!1,value:{isSetDimension:!0}}),a.transform.zoomFactor=a.transform.cropZoomFactor,(0,g.isNullOrUndefined)(a.cropObj.activeObj.shape)&&(a.currObjType.shape="crop-"+e,this.drawNewSelection(e,t,o,i,r))}else this.isCropSelect?this.isCropSelect=!1:(a.notify("crop",{prop:"adjustStraightenForShapes",onPropertyChange:!1,value:{type:"reverse",isInitialRotated:!0}}),a.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.renderImage()),"custom"===e&&(a.currObjType.shape=""),this.drawNewSelection(e,t,o,i,r)}},e.prototype.drawNewSelection=function(e,t,o,i,r){var a,n=this.parent,s="crop-"+e.toLowerCase();"crop-custom"===s?""!==n.currObjType.shape&&"crop-custom"!==n.currObjType.shape||(this.drawCustomSelection("crop-custom",t,o,i,r),this.adjToStraighten(),this.updateSelectionInsert(),n.isStraightening&&(this.straightenActObj=(0,g.extend)({},n.activeObj,{},!0),this.straightenInitZoom=n.transform.zoomFactor)):"crop-canvas"===s?(n.upperCanvas.style.display="block",n.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(n.currObjType.isCustomCrop=!1,n.currObjType.shape=s,i&&r?a={startX:t,startY:o,endX:t+i,endY:o+r,width:i,height:r}:i&&"crop-circle"===s&&(a={startX:t,startY:o,endX:t+i,endY:o+i,width:i,height:i}),n.activeObj.shape=s,this.updateSelectionInsert(a))},e.prototype.updateSelectionInsert=function(e){var t=this.parent,o=t.activeObj.activePoint,i={shapeSettingsObj:{}};t.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var r={type:t.getSelectionType(i.shapeSettingsObj.type),startX:i.shapeSettingsObj.startX,startY:i.shapeSettingsObj.startY,width:i.shapeSettingsObj.width,height:i.shapeSettingsObj.height},a={action:"insert",previousSelectionSettings:r,currentSelectionSettings:r};t.trigger("selectionChanging",a),t.editCompleteArgs=a,t.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:a.currentSelectionSettings}}),"Custom"===a.currentSelectionSettings.type?this.drawObject("duplicate",t.activeObj,null,null,!0):(0===o.startX&&0===o.startY&&0===o.width&&0===o.height||(e={startX:o.startX,startY:o.startY,endX:o.endX,endY:o.endY,width:o.width,height:o.height}),this.drawObject("duplicate",null,!0,e))},e.prototype.drawCustomSelection=function(e,t,o,i,r){var a=this.parent,n=a.activeObj.activePoint;if(a.currObjType.isCustomCrop=!0,this.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.currObjType.shape=a.activeObj.shape=e.toLowerCase(),(0,g.isNullOrUndefined)(t)||(0,g.isNullOrUndefined)(o)||(0,g.isNullOrUndefined)(i)||(0,g.isNullOrUndefined)(r))if(i&&r){var s=a.img,l=s.destLeft,p=s.destTop,h=s.destWidth,d=s.destHeight;n.width=i,n.height=r,n.startX=l+(h/2-i/2),n.startY=p+(d/2-r/2)}else{if((0,g.isNullOrUndefined)(a.transform.zoomFactor)||0===a.transform.zoomFactor){var c=a.img,u=c.destLeft,v=c.destTop,f=c.destWidth,m=c.destHeight,b=a.lowerCanvas.width,C=a.lowerCanvas.height,y=n;u>=0&&v>=0?(y.startX=u,y.startY=v,y.endX=u+f,y.endY=v+m):u>=0?(y.startX=u,y.startY=7.5,y.endX=u+f,y.endY=C-15):v>=0?(y.startX=7.5,y.startY=v,y.endX=b-15,y.endY=v+m):(y.startX=7.5,y.startY=7.5,y.endX=b-15,y.endY=C-15)}else{var x=a.img,P=x.destLeft,w=x.destTop,j=x.destWidth,S=x.destHeight,O=a.lowerCanvas.width,T=a.lowerCanvas.height,k=n;k.startX=Math.max(P>0?P:7.5,P),k.startY=Math.max(w>0?w:7.5,w),k.endX=Math.min(P+j+15<O?P+j-15:O-15,P+j),k.endY=Math.min(w+S+15<T?w+S-15:T-15,w+S)}var F=a.img,I=(l=F.destLeft,p=F.destTop,h=F.destWidth,d=F.destHeight,a.lowerCanvas.clientWidth),A=a.lowerCanvas.clientHeight,z=n;if(z.startX=Math.max(z.startX,l),z.startY=Math.max(z.startY,p),z.endX=Math.min(z.endX,l+h),z.endY=Math.min(z.endY,p+d),a.transform.straighten>0?(this.imgCanvasPoints[0].x>z.startX&&(z.startX=this.imgCanvasPoints[0].x),this.imgCanvasPoints[0].y>z.startY&&(z.startY=this.imgCanvasPoints[0].y),this.imgCanvasPoints[2].x<z.endX&&(z.endX=this.imgCanvasPoints[2].x),this.imgCanvasPoints[2].y<z.endY&&(z.endY=this.imgCanvasPoints[2].x)):a.transform.straighten<0&&(this.imgCanvasPoints[3].x>z.startX&&(z.startX=this.imgCanvasPoints[3].x),this.imgCanvasPoints[3].y<z.startY&&(z.startY=this.imgCanvasPoints[3].y),this.imgCanvasPoints[1].x<z.endX&&(z.endX=this.imgCanvasPoints[1].x),this.imgCanvasPoints[1].y>z.endY&&(z.endY=this.imgCanvasPoints[1].x)),z.startX===l&&l+h>I&&(z.endX=I-15),z.startY===p&&p+d>A&&(z.endY=A-15),a.activeObj.activePoint.startX>a.activeObj.activePoint.endX){var D=a.activeObj.activePoint.startX;a.activeObj.activePoint.startX=a.activeObj.activePoint.endX,a.activeObj.activePoint.endX=D}if(a.activeObj.activePoint.startY>a.activeObj.activePoint.endY){D=a.activeObj.activePoint.startY;a.activeObj.activePoint.startY=a.activeObj.activePoint.endY,a.activeObj.activePoint.endY=D}a.activeObj=this.updateWidthHeight(a.activeObj),this.updateActiveObject(n,a.activeObj),this.adjActObj()}else n.startX=t,n.startY=o,n.endX=t+i,n.endY=o+r,n.width=i,n.height=r;this.updateSelectionInsert()},e.prototype.adjToStraighten=function(){var e=this.parent;if(0!==e.transform.straighten&&e.isStraightening){var t=e.activeObj.activePoint;t.startX+=7.5,t.startY+=7.5,t.endX-=7.5,t.endY-=7.5,e.activeObj=this.updateWidthHeight(e.activeObj)}},e.prototype.adjActObj=function(){var e=this.parent;if(0!==e.transform.straighten)for(var t=e.activeObj.activePoint,o=(0,g.extend)({},t,{},!0),i=0;;){i++;var r={isIntersect:null,arr:null};if(e.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),e.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:r}}),r.arr[0]||r.arr[1]||r.arr[2]||r.arr[3]||100===i){t=(0,g.extend)({},o,{},!0);break}o=(0,g.extend)({},t,{},!0),t.startX-=5,t.endX+=5,t.width=t.endX-t.startX,this.updateActiveObject(t,e.activeObj)}},e.prototype.callUpdateCurrTransState=function(){var e=this.parent,t=(0,g.extend)([],e.objColl,[],!0),o=(0,g.extend)({},e.activeObj,{},!0);e.objColl=[],e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isRotateZoom=!0,this.updateCurrTransState("initial"),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),0===e.transform.degree&&e.rotateFlipColl.length>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),e.img.destLeft+=e.panPoint.totalPannedInternalPoint.x,e.img.destTop+=e.panPoint.totalPannedInternalPoint.y;var i=this.lowerContext.filter;0===e.transform.degree&&e.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),this.updateCurrTransState("reverse"),0===e.transform.degree&&e.rotateFlipColl.length>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),this.isRotateZoom=!1,e.objColl=t;var r=e.togglePen;e.togglePen=!1,this.lowerContext.filter="none";var a={penStrokeWidth:null};e.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:a}}),e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),e.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:a.penStrokeWidth}}),e.img.destLeft+=e.panPoint.totalPannedInternalPoint.x,e.img.destTop+=e.panPoint.totalPannedInternalPoint.y,e.img.destLeft-=e.panPoint.totalPannedInternalPoint.x,e.img.destTop-=e.panPoint.totalPannedInternalPoint.y,e.togglePen=r,this.lowerContext.filter=i,e.activeObj=o},e.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}},e.prototype.setClientTransDim=function(e){var t=this.parent;if(t.transform.degree%90==0&&t.transform.degree%180!=0){t.img.destLeft=(t.lowerCanvas.clientWidth-t.img.destHeight)/2,t.img.destTop=(t.lowerCanvas.clientHeight-t.img.destWidth)/2;var o=t.img.destWidth;t.img.destWidth=t.img.destHeight,t.img.destHeight=o}else(0,g.isNullOrUndefined)(e)&&(t.img.destLeft=(t.lowerCanvas.clientWidth-t.img.destWidth)/2,t.img.destTop=(t.lowerCanvas.clientHeight-t.img.destHeight)/2)},e.prototype.redrawImgWithObj=function(){var e=this.parent,t={canvasFilter:e.canvasFilter};if(this.lowerContext.filter=t.canvasFilter,0!==e.rotateFlipColl.length){var o=(0,g.extend)({},e.panPoint.totalPannedInternalPoint,{},!0),i={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};this.callUpdateCurrTransState(),e.panPoint.totalPannedInternalPoint=o,e.img.destLeft=i.startX,e.img.destTop=i.startY,e.img.destWidth=i.width,e.img.destHeight=i.height}else this.callUpdateCurrTransState();e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},e.prototype.setCurrentObj=function(e,t,o){var i=this.parent,r=!!e;r||(i.cropObj.aspectWidth=i.aspectWidth,i.cropObj.aspectHeight=i.aspectHeight,i.cropObj.frame=i.frameObj.type),e=e||i.cropObj,i.transform.cropZoomFactor=e.cropZoom,i.transform.defaultZoomFactor=e.defaultZoom,this.straightenInitZoom=e.straightenZoom,r?e.activeObj.shape&&"crop"===e.activeObj.shape.split("-")[0]?i.transform.zoomFactor=e.cropZoom:i.transform.zoomFactor=e.defaultZoom:i.transform.zoomFactor=e.cropZoom,i.setProperties({zoomSettings:{zoomFactor:e.zoomFactor}},!0),i.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:e.previousZoomValue}}),i.panPoint.totalPannedPoint=(0,g.extend)({},e.totalPannedPoint,{},!0),i.panPoint.totalPannedClientPoint=(0,g.extend)({},e.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=(0,g.extend)({},e.totalPannedInternalPoint,{},!0);var a=(0,g.extend)({},e.tempFlipPanPoint,{},!0);i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:a}}),i.rotateFlipColl=(0,g.extend)([],e.rotateFlipColl,[],!0),i.transform.degree=e.degree,i.frameObj.type=e.frame,i.transform.currFlipState=e.currFlipState,i.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:e.adjustmentLevel}}),i.notify("filter",{prop:"setTempAdjVal"}),i.currentFilter=e.currentFilter,i.notify("filter",{prop:"setTempFilVal"}),(i.transform.straighten!==e.straighten||t)&&(i.transform.straighten=e.straighten,i.straightenBaseImageCanvas()),i.img={destLeft:e.destPoints.startX,destTop:e.destPoints.startY,destWidth:e.destPoints.width,destHeight:e.destPoints.height,srcLeft:e.srcPoints.startX,srcTop:e.srcPoints.startY,srcWidth:e.srcPoints.width,srcHeight:e.srcPoints.height},i.aspectWidth=e.aspectWidth,i.aspectHeight=e.aspectHeight,e.afterCropActions&&(i.afterCropActions=e.afterCropActions),this.lowerContext.filter=e.filter,i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:e.isBrightAdjust}}),i.notify("draw",{prop:"imageBackgroundColor",onPropertyChange:!1,value:{color:e.bgColor}});var n,s=i.isCircleCrop;(0,g.isNullOrUndefined)(i.currSelectionPoint)?n=null:(n=(0,g.extend)({},i.currSelectionPoint,{},!0),i.currSelectionPoint=null),i.isCircleCrop=!1,o&&(i.frameObj.type="none"),this.drawCropSelectionImage(e,!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=e.destPoints.startX,i.img.destTop=e.destPoints.startY,i.panPoint.totalPannedClientPoint=(0,g.extend)({},e.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=(0,g.extend)({},e.totalPannedInternalPoint,{},!0)),i.activeObj=(0,g.extend)({},e.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 l=(0,g.extend)({},e.activeObj,{},!0),p=!1;if(i.afterCropActions.length>0){var h={collection:i.afterCropActions};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.afterCropActions,isRotateFlipCollection:null,obj:h}}),i.afterCropActions=h.collection}var d=(0,g.extend)([],i.afterCropActions,[],!0);if(!r&&d.length>0){p=!0;for(var c=0,u=d.length;c<u;c++)"horizontalflip"!==d[c]&&"verticalflip"!==d[c]||(i.activeObj=(0,g.extend)({},n,{},!0),this.rotatedFlipCropSel=!0),i.notify("transform",{prop:"updateTransform",onPropertyChange:!1,value:{text:d[c]}});l=(0,g.extend)({},i.activeObj,{},!0),this.resetPanPoints(),i.activeObj=l,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),e.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=d,this.isCancelAction||p||(i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),i.img.destLeft=e.destPoints.startX,i.img.destTop=e.destPoints.startY),i.activeObj=l,i.isCircleCrop=s,(0,g.isNullOrUndefined)(n)?i.currSelectionPoint=null:(i.currSelectionPoint=(0,g.extend)({},n,{},!0),i.currSelectionPoint&&(0,g.isNullOrUndefined)(i.currSelectionPoint.shape)&&(i.currSelectionPoint=null))},e.prototype.drawCropSelectionImage=function(e,t){var o=this.parent,i=this.lowerContext.filter;o.clearContext(this.lowerContext),o.clearContext(this.upperContext),this.lowerContext.setTransform(1,0,0,1,0,0),t?this.updateCurrTransState("initial"):this.setTransformColl(this.lowerContext,"initial"),o.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),t?this.updateCurrTransState("reverse"):this.setTransformColl(this.lowerContext,"reverse"),o.img.destLeft=o.cropObj.destPoints.startX,o.img.destTop=o.cropObj.destPoints.startY;var r=(0,g.extend)({},e.activeObj,{},!0);if(this.lowerContext.filter="none",o.img={destLeft:e.destPoints.startX,destTop:e.destPoints.startY,destWidth:e.destPoints.width,destHeight:e.destPoints.height,srcLeft:e.srcPoints.startX,srcTop:e.srcPoints.startY,srcWidth:e.srcPoints.width,srcHeight:e.srcPoints.height},0!==e.activeObj.activePoint.width&&0!==e.activeObj.activePoint.height){var a={startX:o.img.destLeft,startY:o.img.destTop,width:o.img.destWidth,height:o.img.destHeight};o.img.destLeft=e.activeObj.activePoint.startX,o.img.destTop=e.activeObj.activePoint.startY,o.img.destWidth=e.activeObj.activePoint.width,o.img.destHeight=e.activeObj.activePoint.height,o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),o.img.destLeft=a.startX,o.img.destTop=a.startY,o.img.destWidth=a.width,o.img.destHeight=a.height}o.activeObj=r,this.lowerContext.filter=i},e.prototype.performPointZoom=function(e,t,o,i,r){var a=this.parent,n=a.img,s=n.destLeft,l=n.destTop,p=n.destWidth,h=n.destHeight,d=!1;a.activeObj.shape&&a.activeObj.shape.indexOf("crop-")>-1&&(d=!0),a.element.querySelector(".e-contextual-toolbar-wrapper")&&!d&&(a.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(a.okBtn(),a.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")));var c=(e-s)/p,u=(t-l)/h,g=a.isUndoRedo;a.isUndoRedo=!0,a.setProperties({zoomSettings:{zoomPoint:{x:e,y:t}}},!0);var v=r||("zoomIn"===o?.1:-.1);a.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:v,zoomPoint:null,isResize:i}}),a.isUndoRedo=g,this.panToPoint(e,t,c,u)},e.prototype.panToPoint=function(e,t,o,i){var r=this.parent;if(r.transform.zoomFactor>0){var a=r.img.destLeft,n=r.img.destTop,s=(0,g.extend)({},r.activeObj,{},!0);if(0===r.transform.degree)r.img.destLeft=e-o*r.img.destWidth,r.img.destTop=t-i*r.img.destHeight,this.drawZoomPanImage(r.img.destLeft-a,r.img.destTop-n);else{var l=r.isCropTab;r.isCropTab=!0;var p=(0,g.extend)([],r.objColl,[],!0),h=(0,g.extend)([],r.pointColl,[],!0),d={straightenPoint:null};r.notify("freehand-draw",{prop:"getStraightenPoint",onPropertyChange:!1,value:{obj:d}}),r.objColl=[],r.pointColl=[],r.freehandCounter=0,r.notify("freehand-draw",{prop:"setStraightenPoint",onPropertyChange:!1,value:{x:null,y:null,ratioX:null,ratioY:null}});var c={selPointColl:null};r.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:c}});var u=c.selPointColl;r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),r.panPoint.currentPannedPoint={x:e-o*r.img.destWidth-a,y:t-i*r.img.destHeight-n},r.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),r.isCropTab=l,r.objColl=p,r.pointColl=h,r.freehandCounter=r.pointColl.length,d.straightenPoint.x&&d.straightenPoint.y&&r.notify("freehand-draw",{prop:"setStraightenPoint",onPropertyChange:!1,value:{x:d.straightenPoint.x,y:d.straightenPoint.y,ratioX:d.straightenPoint.ratioX,ratioY:d.straightenPoint.ratioY}}),r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:u}}}),r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"pan",pen:"pan",x:r.panPoint.currentPannedPoint.x,y:r.panPoint.currentPannedPoint.y,panRegion:""}})}this.adjustPanning(s);for(var v=!1,f=0;f<r.objColl.length;f++)if(JSON.stringify(s.activePoint)===JSON.stringify(r.objColl[f].activePoint)){v=!0;break}v||(r.activeObj=s),0!==r.activeObj.activePoint.width&&0!==r.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0)}},e.prototype.adjustPanning=function(e){var t=this.parent,o=e.activePoint,i=o.startX,r=o.startY,a=o.width,n=o.height;if(0!==a&&0!==n){var s=t.img,l=s.destLeft,p=s.destTop,h=s.destWidth,d=s.destHeight,c={x:0,y:0};if(l>i?c.x=l-i:l+h<i+a&&(c.x=l+h-(i+a)),p>r?c.y=p-r:p+d<r+n&&(c.y=p+d-(r+n)),0===t.transform.degree)t.img.destLeft-=c.x,t.img.destTop-=c.y,this.drawZoomPanImage(t.img.destLeft-l,t.img.destTop-p);else{var u=t.isCropTab;t.isCropTab=!0;var v=(0,g.extend)([],t.objColl,[],!0),f=(0,g.extend)([],t.pointColl,[],!0);t.objColl=[],t.pointColl=[],t.freehandCounter=0;var m={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:m}});var b=m.selPointColl;t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),t.img.destLeft-=c.x,t.img.destTop-=c.y,t.panPoint.currentPannedPoint={x:t.img.destLeft-l,y:t.img.destTop-p},t.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),t.isCropTab=u,t.objColl=v,t.pointColl=f,t.freehandCounter=t.pointColl.length,t.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:b}}}),t.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"pan",pen:"pan",x:t.panPoint.currentPannedPoint.x,y:t.panPoint.currentPannedPoint.y,panRegion:""}})}}},e.prototype.panToSel=function(){var e=this.parent,t=(0,g.extend)({},e.activeObj,{},!0),o=t.activePoint,i=o.startX,r=o.startY,a=o.width,n=o.height;this.allowRedactStraighten=!0;var s={straightenPoint:null};if(e.notify("freehand-draw",{prop:"getStraightenPoint",onPropertyChange:!1,value:{obj:s}}),s.straightenPoint.x&&s.straightenPoint.y){var l=i+a/2-s.straightenPoint.x,p=r+n/2-s.straightenPoint.y;0===e.transform.degree?(e.img.destLeft+=l,e.img.destTop+=p,e.notify("transform",{prop:"drawPannImage",value:{point:{x:l,y:p}}})):(e.panPoint.currentPannedPoint={x:l,y:p},e.notify("transform",{prop:"drawPannedImage",value:{xDiff:l,yDiff:p}}),e.panPoint.currentPannedPoint={x:0,y:0},e.notify("transform",{prop:"setTempPanMove",value:{point:null}})),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:t}});var h=e.img,d=h.destLeft,c=h.destTop,u=h.destWidth,v=h.destHeight,f=this.imgCanvasPoints;f.forEach(function(e){e.x=e.ratioX*u+d,e.y=e.ratioY*v+c}),this.imgCanvasPoints=f;var m=0;if(3===e.transform.straighten&&!this.preventStraightening){this.preventStraightening=!0;var b=e.prevStraightenedDegree;e.prevStraightenedDegree=e.transform.straighten,e.setStraighten(0),e.setStraighten(3),e.prevStraightenedDegree=b,this.preventStraightening=!1}for(;this.isLinesIntersect()&&0!==e.transform.straighten&&360!==e.transform.straighten&&m<100;)m++,this.performPointZoom(e.activeObj.activePoint.startX+e.activeObj.activePoint.width/2,e.activeObj.activePoint.startY+e.activeObj.activePoint.height/2,"zoomIn",!1,.025),this.updateImgCanvasPoints()}},e.prototype.drawZoomPanImage=function(e,t){var o=this.parent;o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"pan",pen:"pan",x:e,y:t,panRegion:""}}),this.renderImage(!0);var i={width:0,height:0};o.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o.img.srcWidth,height:o.img.srcHeight,obj:i,isImgShape:null}});var r=i;r.width+=r.width*o.transform.zoomFactor,r.height+=r.height*o.transform.zoomFactor,o.panPoint.totalPannedPoint.x+=e,o.panPoint.totalPannedPoint.y+=t,o.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:{x:0,y:0}}})},e.prototype.openNewImage=function(){var e=this,t=this.parent,o=t.element.id,i=t.inMemoryCanvas.getContext("2d");(0,b.showSpinner)(t.element),t.element.style.opacity="0.5";var r=document.querySelector("#"+o+"_currPos");r&&(r.style.display="none");var a={defToolbarItems:null};if(t.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:a}}),a.defToolbarItems&&0===a.defToolbarItems.length&&(0,g.isNullOrUndefined)(document.getElementById(o+"_toolbar"))&&t.element.querySelector("#"+o+"_toolbarArea")){var n=t.element.querySelector("#"+o+"_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&&"webp"!==l&&"bmp"!==l&&(this.fileType=null)}this.imageOnLoad(this.openURL),"string"==typeof this.openURL&&-1!==this.openURL.indexOf("localhost")||this.getImageSizeFromURL(this.openURL.toString(),function(t){null!==t&&e.parent.notify("toolbar",{prop:"setInitialSize",value:{value:+t}})})}else this.fileName="ImageEditor",this.fileType=null,t.lowerCanvas=document.querySelector("#"+o+"_lowerCanvas"),t.upperCanvas=document.querySelector("#"+o+"_upperCanvas"),this.lowerContext=t.lowerCanvas.getContext("2d"),this.upperContext=t.upperCanvas.getContext("2d"),t.clearContext(this.lowerContext),t.clearContext(this.upperContext),t.clearContext(i),t.inMemoryCanvas.width=this.openURL.width,t.inMemoryCanvas.height=this.openURL.height,i.putImageData(this.openURL,0,0),t.baseImg.src=t.inMemoryCanvas.toDataURL()},e.prototype.getImageSizeFromURL=function(e,t){return O(this,void 0,void 0,function(){var o,i,r,a;return T(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),i=0===e.indexOf("blob:"),[4,fetch(e,{method:i?"GET":"HEAD"})];case 1:return o=n.sent(),i?[4,o.blob()]:[3,3];case 2:return r=n.sent().size,[3,4];case 3:r=parseInt(o.headers.get("content-length")||"0",10),n.label=4;case 4:return t(r),[3,6];case 5:return a=n.sent(),console.log(a.message),[3,6];case 6:return[2]}})})},e.prototype.dlgBtnClick=function(){this.parent.export(),this.applyDialogOption()},e.prototype.dlgCloseBtnClick=function(){this.applyDialogOption()},e.prototype.applyDialogOption=function(){var e=this.parent;this.isFileChanged?(e.isImageLoaded=this.isFileChanged=!1,e.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),(0,g.getComponent)(document.getElementById(e.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},e.prototype.showDialogPopup=function(){var e=this.parent,t={key:"ConfirmDialogHeader"};e.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:t}});var o={key:"ConfirmDialogContent"};e.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});var i={key:"Yes"};e.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:i}});var r={key:"No"};e.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}}),e.element.querySelector("#"+e.element.id+"_dialog").style.display="block",new b.Dialog({header:t.value,closeOnEscape:!0,content:"<span>"+o.value+"</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:r.value,iconCss:"e-icons e-close"}},{click:this.dlgBtnClick.bind(this),buttonModel:{content:i.value,isPrimary:!0,iconCss:"e-icons e-check"}}]}).appendTo("#"+e.element.id+"_dialog")},e.prototype.restoreOldImage=function(){var e=this,t=this.parent,o=document.getElementById(this.parent.element.id+"_dropArea"),i=t.getExtensionArray();if("string"===typeof this.openURL){var r=this.getFileExtensionFromURL(this.openURL);r&&(r="jpg"===(r=r.toLowerCase())||"jpeg"===r?"jpeg":r);var a=!!r&&(i.indexOf(r)>-1||"jpeg"===r&&(t.uploadSettings.allowedExtensions.indexOf("jpg")>-1||t.uploadSettings.allowedExtensions.indexOf("jpeg")>-1))||this.isNullExtension;this.openURL.indexOf("data:image/")>-1&&this.openURL.indexOf("base64")>-1||this.openURL.indexOf("blob")>-1?this.openImageData(o,!0):t.uploadSettings.minFileSize||t.uploadSettings.maxFileSize?this.getImageSizeFromURL(this.openURL.toString(),function(i){var r=t.uploadSettings.minFileSize&&i<t.uploadSettings.minFileSize||t.uploadSettings.maxFileSize&&i>t.uploadSettings.maxFileSize;e.handleFileSize(!a||r,o,!a)}):this.handleFileSize(!a,o,!a)}else this.openImageData(o)},e.prototype.handleFileSize=function(e,t,o){var i=this.parent;e?(this.errorLoading(),i.showDialogPopup("unsupported",o),t&&!i.isImageLoaded&&(t.style.display="flex")):(t&&(t.style.display="none"),this.parent.isImageLoaded&&this.reset(),this.openNewImage())},e.prototype.openImageData=function(e,t){var o=this.parent,i=this,r=o.createElement("canvas"),a=r.getContext("2d");if(o.uploadSettings.minFileSize||o.uploadSettings.maxFileSize)if(t){var n=new Image;n.src=this.openURL,n.onload=function(){a.canvas.width=n.width,a.canvas.height=n.height,a.drawImage(n,0,0),i.getImageSize(r,e)}}else r.width=this.openURL.width,r.height=this.openURL.height,a.putImageData(this.openURL,0,0),this.getImageSize(r,e);else this.handleFileSize(!1,e,!1)},e.prototype.getImageSize=function(e,t){var o=this.parent;e.toBlob(function(e){o.uploadSettings.minFileSize&&e.size<o.uploadSettings.minFileSize||o.uploadSettings.maxFileSize&&e.size>o.uploadSettings.maxFileSize?this.handleFileSize(!0,t,!1):this.handleFileSize(!1,t,!1)}.bind(this),"image/jpeg",1)},e.prototype.open=function(e){this.parent.disabled||(this.openURL=e,this.restoreOldImage())},e.prototype.getInitialLoaded=function(e){e.isInitialLoaded=this.isInitialLoading},e.prototype.getFileExtensionFromURL=function(e){var t=e.lastIndexOf(".");return-1!==t?e.slice(t+1).toLowerCase():-1!==e.indexOf("base64")?e.slice(e.indexOf("/")+1,e.indexOf(";")).toLowerCase():null},e.prototype.fileSelect=function(e,t){var o=this.parent,i=document.getElementById(o.element.id+"_dropArea");if(i&&(i.style.display="none"),!o.disabled){var r=void 0,a=void 0;t.target?a=r=t.target.files[0]:r=a=t.filesData[0].rawFile;var n=void 0;if(a.name){var s=a.name.split(".");n=s[s.length-1].toLowerCase()}var l=o.getExtensionArray(),p=("jpg"===n||"jpeg"===n)&&(o.uploadSettings.allowedExtensions.indexOf("jpg")>-1||o.uploadSettings.allowedExtensions.indexOf("jpeg")>-1);if(n&&-1===l.indexOf(n)&&!p||o.uploadSettings.minFileSize&&a.size<o.uploadSettings.minFileSize||o.uploadSettings.maxFileSize&&a.size>o.uploadSettings.maxFileSize)return void this.errorLoading();if(o.imageSettings={width:null,height:null},o.aspectRatioBaseDimension=null,(0,b.showSpinner)(o.element),o.element.style.opacity="0.5",this.inputElem=e,n=a.name&&a.name.split(".")[1]){var h=o.toPascalCase(n);this.fileType="JPG"===h||"Jpg"===h?"Jpeg":h}else this.fileType=null;var d=window.URL.createObjectURL(r);this.openURL=d,o.isImageLoaded&&!o.isChangesSaved&&(this.isImageEdited||o.pointColl.length>0||o.objColl.length>0)?(this.isFileChanged=!0,this.showDialogPopup()):this.checkToolbarTemplate(e,d)}},e.prototype.checkToolbarTemplate=function(e,t){var o=this.parent;(0,g.isNullOrUndefined)(o.toolbarTemplate)&&(o.reset(),o.update()),this.fileName=e.value.split("\\")[e.value.split("\\").length-1],this.fileName=this.fileName.split(".")[0],this.imageOnLoad(t.toString()),e.value=""},e.prototype.moveToSelectionRange=function(e,t){var o=this.parent;if(o.activeObj.shape){for(var i=!1,r=0,a=o.rotateFlipColl.length;r<a;r++){var n=o.rotateFlipColl[r];if(90===n||-90===n){i=!0;break}}if(i){if(0===o.transform.degree)return;var s=o.transform.zoomFactor;o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1});var l=o.objColl[o.objColl.length-1];if("rotateleft"===e||"rotateright"===e)if(o.transform.degree%90==0&&o.transform.degree%180!=0)if(l.activePoint.width<t.activePoint.height)for(r=2;r<o.zoomSettings.maxZoomFactor;r++){if(l.activePoint.width>=t.activePoint.height||this.isSelectionBiggerThanCanvas(l)||this.isSelectionOutsideCanvas(l)){(0,g.isNullOrUndefined)(s)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});break}s+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:s,zoomPoint:null},isResize:null})}else for(r=2;r<o.zoomSettings.maxZoomFactor;r++){if(l.activePoint.width>=t.activePoint.height||this.isSelectionBiggerThanCanvas(l)||this.isSelectionOutsideCanvas(l)){(0,g.isNullOrUndefined)(s)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null,isResize:null}});break}s-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:s,zoomPoint:null},isResize:null})}else if(l.activePoint.height<t.activePoint.width)for(r=2;r<o.zoomSettings.maxZoomFactor;r++){if(l.activePoint.height>=t.activePoint.width||this.isSelectionBiggerThanCanvas(l)||this.isSelectionOutsideCanvas(l)){(0,g.isNullOrUndefined)(s)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});break}s+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:s,zoomPoint:null},isResize:null})}else for(r=2;r<o.zoomSettings.maxZoomFactor;r++){if(l.activePoint.height>=t.activePoint.width||this.isSelectionBiggerThanCanvas(l)||this.isSelectionOutsideCanvas(l)){(0,g.isNullOrUndefined)(s)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null});break}s-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:s,zoomPoint:null},isResize:null})}var p=o.lowerCanvas.clientWidth/2-(l.activePoint.startX+l.activePoint.width/2),h=o.lowerCanvas.clientHeight/2-(l.activePoint.startY+l.activePoint.height/2);(0,g.isNullOrUndefined)(o.activeObj.shape)&&(o.activeObj=(0,g.extend)({},t,{},!0)),0===o.transform.degree?(o.img.destLeft+=p,o.img.destTop+=h,o.notify("transform",{prop:"drawPannImage",value:{point:{x:p,y:h}}})):(o.panPoint.currentPannedPoint={x:p,y:h},o.notify("transform",{prop:"drawPannedImage",value:{xDiff:p,yDiff:h}}),o.panPoint.currentPannedPoint={x:0,y:0}),o.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),o.activeObj=(0,g.extend)({},o.objColl[o.objColl.length-1]),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})}}},e.prototype.isSelectionBiggerThanCanvas=function(e){var t=!1,o=this.parent,i=e.activePoint,r=i.startX,a=i.startY,n=i.endX,s=i.endY,l=o.img,p=l.destLeft,h=l.destTop,d=l.destWidth,c=l.destHeight;return(r<=p||a<=h||n>=p+d||s>=h+c)&&(t=!0),t},e.prototype.isSelectionOutsideCanvas=function(e){var t=!1,o=this.parent;return(e.activePoint.height<o.lowerCanvas.height-o.toolbarHeight||e.activePoint.width<o.lowerCanvas.width)&&(t=!0),t},e.prototype.downScaleImgCanvas=function(e,t,o,i){var r=this.parent,a=t?r.activeObj.imageCanvas:r.baseImgCanvas,n=t?r.activeObj.imageElement:r.baseImg,s=t?r.activeObj.activePoint.width:r.img.destWidth,l=t?r.activeObj.activePoint.height:r.img.destHeight,p={width:0,height:0};if(r.transform.degree%90==0&&r.transform.degree%180!=0?r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:n.height,height:n.width,obj:p,isImgShape:t}}):r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:n.width,height:n.height,obj:p,isImgShape:t}}),t||r.allowDownScale&&!r.isCropTab&&!r.isCropToolbar&&0!==n.width&&0!==n.height&&.75*p.width>s&&.75*p.height>l){var h=r.createElement("canvas",{id:r.element.id+"_downScaleCanvas",attrs:{name:"canvasImage"}});h.width=t?n.width:r.img.srcWidth,h.height=t?n.height:r.img.srcHeight,t?h.getContext("2d").drawImage(n,0,0,h.width,h.height):(""!==this.imageBackgroundColor&&(e.fillStyle=this.imageBackgroundColor,e.fillRect(r.img.destLeft,r.img.destTop,r.img.destWidth,r.img.destHeight)),h.getContext("2d").drawImage(a,r.img.srcLeft,r.img.srcTop,r.img.srcWidth,r.img.srcHeight,0,0,h.width,h.height)),(t||this.isDownScale)&&this.downScale(h,s,l,t),t?(e.canvas.width=h.width,e.canvas.height=h.height,o&&i?(e.translate(r.activeObj.imageCanvas.width,0),e.scale(-1,1),e.translate(0,r.activeObj.imageCanvas.height),e.scale(1,-1)):o?((0,g.isNullOrUndefined)(r.activeObj.isHorImageFlip)||!r.activeObj.isHorImageFlip?(r.activeObj.isHorImageFlip=!0,e.translate(r.activeObj.imageCanvas.width,0),e.scale(-1,1)):r.activeObj.isHorImageFlip&&(r.activeObj.isHorImageFlip=!1),r.activeObj.isVerImageFlip&&(e.translate(0,r.activeObj.imageCanvas.height),e.scale(1,-1))):i&&((0,g.isNullOrUndefined)(r.activeObj.isVerImageFlip)||!r.activeObj.isVerImageFlip?(r.activeObj.isVerImageFlip=!0,e.translate(0,r.activeObj.imageCanvas.height),e.scale(1,-1)):r.activeObj.isVerImageFlip&&(r.activeObj.isVerImageFlip=!1),r.activeObj.isHorImageFlip&&(e.translate(r.activeObj.imageCanvas.width,0),e.scale(-1,1))),e.drawImage(h,0,0),e.setTransform(1,0,0,1,0,0)):r.isFinetuning?(e.save(),e.setTransform(1,0,0,1,0,0),e.drawImage(r.inMemoryCanvas,0,0),e.restore()):e.drawImage(h,0,0,h.width,h.height,r.img.destLeft,r.img.destTop,h.width,h.height)}else!(0,g.isNullOrUndefined)(t)&&t||0===r.baseImgCanvas.width||0===r.baseImgCanvas.height||(""!==this.imageBackgroundColor&&(e.fillStyle=this.imageBackgroundColor,e.fillRect(r.img.destLeft,r.img.destTop,r.img.destWidth,r.img.destHeight)),e.drawImage(r.baseImgCanvas,r.img.srcLeft,r.img.srcTop,r.img.srcWidth,r.img.srcHeight,r.img.destLeft,r.img.destTop,r.img.destWidth,r.img.destHeight));r.isSafari&&r.notify("filter",{prop:"apply-filter",onPropertyChange:!1,value:{context:e}})},e.prototype.downScale=function(e,t,o,i){var r=this.parent;if(!i||!r.isStraightening){for(var a=e.width,n=e.height,s=a/(t=Math.round(t)),l=n/(o=Math.round(o)),p=Math.ceil(s/2),h=Math.ceil(l/2),d=e.getContext("2d"),c=d.getImageData(0,0,a,n),u=d.createImageData(t,o),g=c.data,v=u.data,f=0;f<o;f++)for(var m=0;m<t;m++){for(var b=4*(m+f*t),C=0,y=0,x=0,P=0,w=0,j=0,S=0,O=(f+.5)*l,T=Math.floor(f*l),k=Math.ceil((f+1)*l),F=T;F<k;F++)for(var I=Math.abs(O-(F+.5))/h,A=(m+.5)*s,z=I*I,D=Math.floor(m*s),R=Math.ceil((m+1)*s),L=D;L<R;L++){var E=Math.abs(A-(L+.5))/p,X=Math.sqrt(z+E*E);if(!(X>=1)){var Y=4*(L+F*a);S+=(C=2*X*X*X-3*X*X+1)*g[Y+3],x+=C,P+=(C=C*g[Y+3]/250)*g[Y],w+=C*g[Y+1],j+=C*g[Y+2],y+=C}}v[b]=P/y,v[b+1]=w/y,v[b+2]=j/y,v[b+3]=S/x}e.width=i?r.activeObj.activePoint.width:r.lowerCanvas.width,e.height=i?r.activeObj.activePoint.height:r.lowerCanvas.height,d.putImageData(u,0,0)}},e.prototype.drawImgToCtx=function(e,t){var o=this.parent;e.canvas.id!==o.element.id+"_tempCanvas"&&e!==this.upperContext&&(0,g.isNullOrUndefined)(t)&&this.downScaleImgCanvas(e,null,null,null)},e.prototype.getFrameColor=function(e,t,o){var i=this.parent.frameObj.color;if(e.gradientColor){var r=t.createLinearGradient(o.startX,o.startY,o.startX+o.width,o.startY+o.height);r.addColorStop(0,e.color),r.addColorStop(1,e.gradientColor),i=r}else i=e.color;return i},e.prototype.applyFrame=function(e,t,o){var i,r=this.parent;r.frameObj.type=t;var a={width:1,height:1},n={startX:r.img.destLeft-e.lineWidth,startY:r.img.destTop-e.lineWidth,width:r.img.destWidth+2*e.lineWidth,height:r.img.destHeight+2*e.lineWidth},s={type:r.frameObj.type,color:r.frameObj.color,size:r.frameObj.size,inset:r.frameObj.inset,offset:r.frameObj.offset/2,radius:r.frameObj.radius,amount:r.frameObj.amount,border:r.frameObj.border,gradientColor:r.frameObj.gradientColor},l=r.transform.zoomFactor;if(e.canvas.id===r.element.id+"_tempCanvas"){var p=e.canvas.width,h=e.canvas.height,d={width:0,height:0};r.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:d,dimension:{width:p,height:h}}}),a=d,s.size*=(a.width+a.height)/2,s.inset*=(a.width+a.height)/2,s.offset*=(a.width+a.height)/2,s.radius*=(a.width+a.height)/2,n={startX:0,startY:0,width:e.canvas.width,height:e.canvas.height},r.notify("export",{prop:"updateSaveContext",onPropertyChange:!1,value:{context:e}})}else e===this.upperContext&&r.activeObj.shape?n={startX:r.activeObj.activePoint.startX-e.lineWidth,startY:r.activeObj.activePoint.startY-e.lineWidth,width:r.activeObj.activePoint.width+2*e.lineWidth,height:r.activeObj.activePoint.height+2*e.lineWidth}:(0,g.isNullOrUndefined)(o)&&e.clearRect(0,0,e.canvas.width,e.canvas.height);var c=(a.width+a.height)/2*40,u=(a.width+a.height)/2*50;if(e!==this.upperContext&&(s.size+=s.size*l,s.inset+=s.inset*l,s.offset+=s.offset*l,s.radius+=s.radius*l,c+=c*l,u+=u*l),e!==this.upperContext||!r.activeObj.shape||!("mat"===t&&(n.width-2*s.size<0||n.height-2*s.size<0)||"bevel"===t&&(n.width-2*s.size<40||n.height-2*s.size<40)||"inset"===t&&(n.startX+n.width-s.offset-(n.startX+s.offset)<0||n.startY+n.height-s.offset-(n.startY+s.offset)<0)||"hook"===t&&(n.width-2*s.size<50||n.height-2*s.size<50))){var v={bevelFilter:e.filter},f=e.filter;if(r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape||r.isCircleCrop||e===this.lowerContext&&r.isCropTab)this.drawImgToCtx(e,o);else{switch(t){case"none":this.drawImgToCtx(e,o);break;case"mat":for(this.drawImgToCtx(e,o);(n.width-2*s.size<0||n.height-2*s.size<0)&&s.size>0;)s.size-=20;e.filter="none",e.fillStyle=this.getFrameColor(s,e,n),e.beginPath(),e.rect(n.startX,n.startY,n.width,n.height),e.rect(n.startX+s.size,n.startY+s.size,n.width-2*s.size,n.height-2*s.size),e.fill("evenodd"),e.closePath();break;case"bevel":for(e.filter="none",e.fillStyle=this.getFrameColor(s,e,n),e.beginPath(),e.fillRect(n.startX,n.startY,n.width,n.height),e.closePath(),n.startX+=s.size,n.startY+=s.size,n.width-=2*s.size,n.height-=2*s.size;(n.width-2*s.size<40||n.height-2*s.size<40)&&s.size>0;)n.startX-=s.size,n.startY-=s.size,n.width+=2*s.size,n.height+=2*s.size,s.size-=20,n.startX+=s.size,n.startY+=s.size,n.width-=2*s.size,n.height-=2*s.size;e.fillStyle=this.getFrameColor(s,e,n),e.save(),e.beginPath(),e.moveTo(n.startX+c,n.startY),e.lineTo(n.startX+n.width-c,n.startY),e.quadraticCurveTo(n.startX+n.width,n.startY,n.startX+n.width,n.startY+c),e.lineTo(n.startX+n.width,n.startY+n.height-c),e.quadraticCurveTo(n.startX+n.width,n.startY+n.height,n.startX+n.width-c,n.startY+n.height),e.lineTo(n.startX+c,n.startY+n.height),e.quadraticCurveTo(n.startX,n.startY+n.height,n.startX,n.startY+n.height-c),e.lineTo(n.startX,n.startY+c),e.quadraticCurveTo(n.startX,n.startY,n.startX+c,n.startY),e.closePath(),e.clip(),e.filter="none"===f?r.canvasFilter:f,e.canvas.id===r.element.id+"_tempCanvas"?(o=null,e.filter="none",e.drawImage(r.inMemoryCanvas,0,0),e.filter="none"===f?r.canvasFilter:f):(e.clearRect(0,0,e.canvas.width,e.canvas.height),o?(o=null,0!==r.transform.zoomFactor&&(this.isRotateZoom=!0),r.notify("filter",{prop:"getBevelFilter",onPropertyChange:!1,value:{obj:v}}),e.filter=v.bevelFilter,this.updateCurrTransState("initial"),this.drawImgToCtx(e,o),this.updateCurrTransState("reverse"),this.isRotateZoom=!1,r.frameObj.type="none",e.filter="none",r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:e,shape:"iterate",pen:"iterate",isPreventApply:null}}),r.frameObj.type="bevel",e.filter="none"===f?r.canvasFilter:f):(r.notify("filter",{prop:"getBevelFilter",onPropertyChange:!1,value:{obj:v}}),e.filter=v.bevelFilter,this.drawImgToCtx(e,o))),e.restore();break;case"line":this.drawImgToCtx(e,o),i=e.lineWidth,e.lineWidth=s.size/10;for(var m=0;m<r.frameObj.amount;m++){m>0&&(n.startX+=s.offset,n.startY+=s.offset,n.width-=2*s.offset,n.height-=2*s.offset);var b=n.startY+n.height-s.inset-s.radius,C=n.startY+s.inset+s.radius,y=n.startX+n.width-s.inset-s.radius,x=n.startX+s.inset+s.radius,P=n.startX+s.inset+s.radius,w=n.startX+n.width-s.inset-s.radius,j=n.startY+s.inset+s.radius,S=n.startY+n.height-s.inset-s.radius;b>=C&&y>=x&&P<=w&&j<=S&&(e.filter="none",e.strokeStyle=this.getFrameColor(s,e,n),"dashed"===s.border?e.setLineDash([2.5*e.lineWidth,1.5*e.lineWidth]):"dotted"===s.border&&e.setLineDash([e.lineWidth,e.lineWidth]),e.beginPath(),e.moveTo(n.startX+s.inset+s.radius,n.startY+s.inset),e.lineTo(n.startX+n.width-s.inset-s.radius,n.startY+s.inset),e.arcTo(n.startX+n.width-s.inset,n.startY+s.inset,n.startX+n.width-s.inset,n.startY+s.inset+s.radius,s.radius),e.lineTo(n.startX+n.width-s.inset,n.startY+n.height-s.inset-s.radius),e.arcTo(n.startX+n.width-s.inset,n.startY+n.height-s.inset,n.startX+n.width-s.inset-s.radius,n.startY+n.height-s.inset,s.radius),e.lineTo(n.startX+s.inset+s.radius,n.startY+n.height-s.inset),e.arcTo(n.startX+s.inset,n.startY+n.height-s.inset,n.startX+s.inset,n.startY+n.height-s.inset-s.radius,s.radius),e.lineTo(n.startX+s.inset,n.startY+s.inset+s.radius),e.arcTo(n.startX+s.inset,n.startY+s.inset,n.startX+s.inset+s.radius,n.startY+s.inset,s.radius),e.closePath(),e.stroke(),e.setLineDash([]))}e.lineWidth=i;break;case"inset":this.drawImgToCtx(e,o),e.filter="none",e.strokeStyle=this.getFrameColor(s,e,n),i=e.lineWidth,e.lineWidth=s.size/10,e.beginPath(),e.moveTo(n.startX+s.offset,n.startY+s.inset),e.lineTo(n.startX+n.width-s.offset,n.startY+s.inset),e.moveTo(n.startX+n.width-s.inset,n.startY+s.offset),e.lineTo(n.startX+n.width-s.inset,n.startY+n.height-s.offset),e.moveTo(n.startX+n.width-s.offset,n.startY+n.height-s.inset),e.lineTo(n.startX+s.offset,n.startY+n.height-s.inset),e.moveTo(n.startX+s.inset,n.startY+n.height-s.offset),e.lineTo(n.startX+s.inset,n.startY+s.offset),e.stroke(),e.closePath(),e.lineWidth=i;break;case"hook":this.drawImgToCtx(e,o),e.filter="none",e.strokeStyle=this.getFrameColor(s,e,n),i=e.lineWidth,e.lineWidth=s.size/10,e.beginPath(),e.moveTo(n.startX+s.inset+u,n.startY+s.inset),e.lineTo(n.startX+s.inset,n.startY+s.inset),e.lineTo(n.startX+s.inset,n.startY+s.inset+u),e.moveTo(n.startX+n.width-s.inset-u,n.startY+s.inset),e.lineTo(n.startX+n.width-s.inset,n.startY+s.inset),e.lineTo(n.startX+n.width-s.inset,n.startY+s.inset+u),e.moveTo(n.startX+n.width-s.inset-u,n.startY+n.height-s.inset),e.lineTo(n.startX+n.width-s.inset,n.startY+n.height-s.inset),e.lineTo(n.startX+n.width-s.inset,n.startY+n.height-s.inset-u),e.moveTo(n.startX+s.inset+u,n.startY+n.height-s.inset),e.lineTo(n.startX+s.inset,n.startY+n.height-s.inset),e.lineTo(n.startX+s.inset,n.startY+n.height-s.inset-u),e.stroke(),e.lineWidth=i}(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:e,isSave:e.canvas.id===r.element.id+"_tempCanvas"||null,isFlip:null}}),e.filter=f}}},e.prototype.triggerFrameChange=function(e){var t=this.parent,o={cancel:!1,previousFrameSetting:e,currentFrameSetting:{type:t.toPascalCase(t.frameObj.type),color:t.frameObj.color,gradientColor:t.frameObj.gradientColor,size:t.frameObj.size,inset:t.frameObj.inset,offset:t.frameObj.offset,borderRadius:t.frameObj.radius,frameLineStyle:t.toPascalCase(t.frameObj.border),lineCount:t.frameObj.amount}};return t.trigger("frameChange",o),t.editCompleteArgs=o,o.cancel||this.setFrameObj(o.currentFrameSetting),o},e.prototype.setFrameObj=function(e){var t=this.parent;t.frameObj.type=e.type.toLowerCase(),t.frameObj.color=e.color,t.frameObj.gradientColor=e.gradientColor,t.frameObj.size=e.size,t.frameObj.inset=e.inset,t.frameObj.offset=e.offset,t.frameObj.radius=e.borderRadius,t.frameObj.border=e.frameLineStyle.toLowerCase(),t.frameObj.amount=e.lineCount},e.prototype.zoomToSel=function(e,t){var o=this.parent;if(this.straightenActObj&&JSON.stringify(this.straightenActObj.activePoint)===JSON.stringify(e.activePoint))if(o.activeObj=(0,g.extend)({},this.straightenActObj,null,!0),this.allowRedactStraighten=!1,0===o.transform.straighten){var i=o.img.destWidth,r=o.img.destHeight;for(o.transform.straighten=360;;){if((0,g.isNullOrUndefined)(this.straightenInitZoom)||!(Math.round(o.transform.zoomFactor*Math.pow(10,3))/Math.pow(10,3)>Math.round(this.straightenInitZoom*Math.pow(10,3))/Math.pow(10,3))){this.performDummyZoom();break}if(this.setZoomPan("out"),i===o.img.destWidth&&r===o.img.destHeight){this.performDummyZoom();break}0===o.transform.degree&&(o.transform.zoomFactor-=.025,o.transform.cropZoomFactor-=.025)}o.transform.straighten=0,o.img={destLeft:o.img.destLeft,destTop:o.img.destTop,destWidth:o.img.destWidth,destHeight:o.img.destHeight,srcLeft:o.img.srcLeft,srcTop:o.img.srcTop,srcWidth:o.img.srcWidth,srcHeight:o.img.srcHeight}}else(0,g.isNullOrUndefined)(this.straightenInitZoom)&&(this.straightenInitZoom=o.transform.zoomFactor),this.straightenInitZoom-o.transform.zoomFactor>0?o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-(this.straightenInitZoom-o.transform.zoomFactor),zoomPoint:null,isResize:!0}}):this.straightenInitZoom-o.transform.zoomFactor<0&&o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:this.straightenInitZoom-o.transform.zoomFactor,zoomPoint:null,isResize:!0}}),o.activeObj=(0,g.extend)({},e,null,!0),o.transform.zoomFactor+=.001,this.calcStraightenedPoints(t);else this.straightenActObj=(0,g.extend)({},e,null,!0),o.activeObj=(0,g.extend)({},this.straightenActObj,null,!0),this.straightenInitZoom=o.transform.zoomFactor,this.calcStraightenedPoints(t)},e.prototype.isDestPointSmall=function(){var e=this.parent,t=e.img,o={startX:t.destLeft,startY:t.destTop,width:t.destWidth,height:t.destHeight};e.notify("shape",{prop:"straightenShapes",onPropertyChange:!1});var i=!1;return this.straightenDestPoints.destWidth&&this.straightenDestPoints.destHeight&&(t.destWidth<this.straightenDestPoints.destWidth||t.destHeight<this.straightenDestPoints.destHeight)&&(i=!0),t.destLeft=o.startX,t.destTop=o.startY,t.destWidth=o.width,t.destHeight=o.height,e.img=t,i},e.prototype.calcStraightenedPoints=function(e){var t=this.parent,o=t.img.destWidth,i=t.img.destHeight;(0,g.isNullOrUndefined)(t.transform.zoomFactor)&&(t.transform.zoomFactor+=.025),this.updateImgCanvasPoints();for(var r=function(){if(!(a.isLinesIntersect()||a.isSelOutsideImg()||e&&a.isDestPointSmall()))return a.performDummyZoom(),"break";if(t.activeObj=(0,g.extend)({},a.straightenActObj,null,!0),a.setZoomPan("in"),o===t.img.destWidth&&i===t.img.destHeight)return a.performDummyZoom(),"break";0===t.transform.degree&&(t.transform.zoomFactor+=.025,t.transform.cropZoomFactor+=.025);var r=a.imgCanvasPoints,n=t.img.destLeft,s=t.img.destTop,l=t.img.destWidth,p=t.img.destHeight;r.forEach(function(e){e.x=e.ratioX*l+n,e.y=e.ratioY*p+s}),a.imgCanvasPoints=r},a=this;;){if("break"===r())break}},e.prototype.performDummyZoom=function(){var e=this.parent;e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.025,zoomPoint:null,isResize:!0}}),e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.025,zoomPoint:null,isResize:!0}});var t=10*e.transform.zoomFactor;t<1&&(t=1+t/10),e.setProperties({zoomSettings:{zoomFactor:t}},!0),e.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:t}}),this.panToSel()},e.prototype.setZoomPan=function(e){var t=this.parent,o={maxDimension:null};0===t.transform.degree?(t.notify("transform",{prop:"cropZoom",onPropertyChange:!1,value:{value:"in"===e?.025:-.025,selectionObj:t.activeObj,obj:o}}),t.img.destWidth=o.maxDimension.width,t.img.destHeight=o.maxDimension.height):(t.transform.zoomFactor+="in"===e?.025:-.025,t.transform.cropZoomFactor+="in"===e?.025:-.025,this.updateCurrTransState("initial"),this.isRotateZoom=!0,this.setDestPoints(),this.isRotateZoom=!1,this.updateCurrTransState("reverse"))},e.prototype.updateImgCanvasPoints=function(){var e=this.parent,t=this.getImagePoints(),o={width:0,height:0},i=e.baseImgCanvas.width,r=e.baseImgCanvas.height;e.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:o,dimension:{width:i,height:r}}});var a,n,s,l,p=o;i=e.transform.degree%90==0&&e.transform.degree%180!=0?p.height:p.width,r=e.transform.degree%90==0&&e.transform.degree%180!=0?p.width:p.height;var h=e.img,d=h.destLeft,c=h.destTop,u=h.destWidth,g=h.destHeight;e.transform.straighten>0?(a={x:d+t[0].x/i,y:c},n={x:d+u,y:c+t[1].y/r},s={x:d+u-t[0].x/i,y:c+g},l={x:d,y:c+g-t[1].y/r}):e.transform.straighten<0?(a={x:d,y:c+t[0].y/r},n={x:d+t[1].x/i,y:c},s={x:d+u,y:c+g-t[0].y/r},l={x:d+u-t[1].x/i,y:c+g}):0===e.transform.straighten&&(a={x:d,y:c},n={x:d+u,y:c},s={x:d+u,y:c+g},l={x:d,y:c+g}),a.ratioX=(a.x-d)/u,a.ratioY=(a.y-c)/g,n.ratioX=(n.x-d)/u,n.ratioY=(n.y-c)/g,s.ratioX=(s.x-d)/u,s.ratioY=(s.y-c)/g,l.ratioX=(l.x-d)/u,l.ratioY=(l.y-c)/g,this.imgCanvasPoints=[a,n,s,l]},e.prototype.isLinesIntersect=function(e){var t=this.parent,o=t.activeObj.activePoint;if(0!==t.activeObj.rotatedAngle){var i=t.activeObj.activePoint,r=i.startX,a=i.startY,n=i.endX,s=i.endY,l={x:r+i.width/2,y:a+i.height/2},p=Math.cos(t.activeObj.rotatedAngle),h=Math.sin(t.activeObj.rotatedAngle),d={x:p*(r-l.x)-h*(a-l.y)+l.x,y:h*(r-l.x)+p*(a-l.y)+l.y},c={x:p*(n-l.x)-h*(a-l.y)+l.x,y:h*(n-l.x)+p*(a-l.y)+l.y},u={x:p*(r-l.x)-h*(s-l.y)+l.x,y:h*(r-l.x)+p*(s-l.y)+l.y},g={x:p*(n-l.x)-h*(s-l.y)+l.x,y:h*(n-l.x)+p*(s-l.y)+l.y},v=this.imgCanvasPoints,f=this.doIntersect(d,c,v[0],v[1]),m=this.doIntersect(c,g,v[1],v[2]),b=this.doIntersect(u,g,v[2],v[3]),C=this.doIntersect(d,u,v[3],v[0]);return e&&(e.arr=[f,m,b,C]),f||m||b||C}var y=this.imgCanvasPoints,x=this.doIntersect({x:o.startX,y:o.startY},{x:o.endX,y:o.startY},y[0],y[1]),P=this.doIntersect({x:o.endX,y:o.startY},{x:o.endX,y:o.endY},y[1],y[2]),w=this.doIntersect({x:o.startX,y:o.endY},{x:o.endX,y:o.endY},y[2],y[3]),j=this.doIntersect({x:o.startX,y:o.startY},{x:o.startX,y:o.endY},y[3],y[0]),S=this.isInsideRect(y[0]),O=this.isInsideRect(y[1]),T=this.isInsideRect(y[2]),k=this.isInsideRect(y[3]);return e&&(e.arr=[x,P,w,j]),x||P||w||j||S||O||T||k||y[0].x>o.startX&&y[1].x<o.endX&&y[2].x<o.endX&&y[3].x>o.startX&&y[0].y<o.startY&&y[1].y<o.startY&&y[2].y>o.endY&&y[3].y>o.endY||y[0].x<o.startX&&y[1].x>o.endX&&y[2].x>o.endX&&y[3].x<o.startX&&y[0].y>o.startY&&y[1].y>o.startY&&y[2].y<o.endY&&y[3].y<o.endY},e.prototype.isSelOutsideImg=function(){var e=this.parent,t=this.imgCanvasPoints,o=e.activeObj.activePoint;return"inside"!==this.checkPointPosition(o.startX,o.startY,t[0].x,t[0].y,t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y)||"inside"!==this.checkPointPosition(o.endX,o.startY,t[0].x,t[0].y,t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y)||"inside"!==this.checkPointPosition(o.startX,o.endY,t[0].x,t[0].y,t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y)||"inside"!==this.checkPointPosition(o.endX,o.endY,t[0].x,t[0].y,t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y)},e.prototype.calcTriangleArea=function(e,t,o,i,r,a){return Math.abs((e*(i-a)+o*(a-t)+r*(t-i))/2)},e.prototype.checkPointPosition=function(e,t,o,i,r,a,n,s,l,p){var h=this.calcTriangleArea(e,t,o,i,l,p),d=this.calcTriangleArea(e,t,l,p,n,s),c=this.calcTriangleArea(e,t,n,s,r,a),u=this.calcTriangleArea(e,t,r,a,o,i),g=this.calcTriangleArea(o,i,r,a,n,s)+this.calcTriangleArea(n,s,l,p,o,i);return h+d+c+u>g?"outside":h+d+c+u!==g||0!==h&&0!==d&&0!==c&&0!==u?"inside":"on"},e.prototype.getImagePoints=function(){var e,t,o=[],i=this.parent,r=i.transform.degree;if(!i.aspectRatioBaseDimension&&i.imageSettings.width&&i.imageSettings.height){var a=(i.baseImg.width/i.imageSettings.width+i.baseImg.height/i.imageSettings.height)/2;a=a<1?1:a,e=i.imageSettings.width*a,t=i.imageSettings.height*a}else e=i.baseImg.width,t=i.baseImg.height;var n={dim:null,width:t,height:e,angle:i.transform.straighten};n.dim=i.getRotatedCanvasDim(n.width,n.height,n.angle);var s=r%90==0&&r%180!=0?t:e,l=r%90==0&&r%180!=0?e:t,p=(r%90==0&&r%180!=0?n.dim.width:i.baseImgCanvas.width)/2,h=(r%90==0&&r%180!=0?n.dim.height:i.baseImgCanvas.height)/2,d=p-s/2,c=h-l/2,u=p+s/2,g=h+l/2,v=p,f=h,m=i.transform.straighten*(Math.PI/180),b={x:Math.cos(m)*(d-v)-Math.sin(m)*(c-f)+v,y:Math.sin(m)*(d-v)+Math.cos(m)*(c-f)+f},C={x:Math.cos(m)*(u-v)-Math.sin(m)*(c-f)+v,y:Math.sin(m)*(u-v)+Math.cos(m)*(c-f)+f},y={x:Math.cos(m)*(u-v)-Math.sin(m)*(g-f)+v,y:Math.sin(m)*(u-v)+Math.cos(m)*(g-f)+f},x={x:Math.cos(m)*(d-v)-Math.sin(m)*(g-f)+v,y:Math.sin(m)*(d-v)+Math.cos(m)*(g-f)+f};return o.push(b),o.push(C),o.push(y),o.push(x),o},e.prototype.doIntersect=function(e,t,o,i){var r=this.initiation(e,t,o),a=this.initiation(e,t,i),n=this.initiation(o,i,e),s=this.initiation(o,i,t);return r!==a&&n!==s||(!(0!==r||!this.onSegment(e,o,t))||(!(0!==a||!this.onSegment(e,i,t))||(!(0!==n||!this.onSegment(o,e,i))||!(0!==s||!this.onSegment(o,t,i)))))},e.prototype.initiation=function(e,t,o){var i=(t.y-e.y)*(o.x-t.x)-(t.x-e.x)*(o.y-t.y);return 0===i?0:i>0?1:2},e.prototype.onSegment=function(e,t,o){return t.x<=Math.max(e.x,o.x)&&t.x>=Math.min(e.x,o.x)&&t.y<=Math.max(e.y,o.y)&&t.y>=Math.min(e.y,o.y)},e.prototype.isInsideRect=function(e){var t=this.parent.activeObj.activePoint,o=!1;return e.x>=t.startX&&e.x<=t.endX&&e.y>=t.startY&&e.y<=t.endY&&(o=!0),o},e.prototype.setDestForStraighten=function(){var e=this.parent;if((0,g.isNullOrUndefined)(this.straightenDestPoints)){var t=e.img,o=t.destLeft,i=t.destTop,r=t.destWidth,a=t.destHeight;e.notify("shape",{prop:"straightenShapes",onPropertyChange:!1}),this.straightenDestPoints=(0,g.extend)({},e.img,{},!0),e.img.destLeft=o,e.img.destTop=i,e.img.destWidth=r,e.img.destHeight=a}},e.prototype.drawRedact=function(e,t){var o=t.activePoint,i=o.startX,r=o.startY,a=o.endX,n=o.endY,s=t.activePoint,l=s.width,p=s.height,h=!1,d=e.canvas;-1!==d.id.indexOf("_tempCanvas")&&(h=!0);var c=this.parent.img;if(!(l<=0||p<=0))if(this.parent.isCropTab)e.drawImage(t.redactImage,0,0,t.redactImage.width,t.redactImage.height,i,r,l,p);else{var u=document.createElement("canvas"),g=u.getContext("2d"),v=d.width,f=d.height,m=Math.min(v,f)/1e3,b=Math.round(this.parent.activeObj.rotatedAngle*(180/Math.PI));if(this.allowRedactStraighten&&0!==b){var C=document.createElement("canvas"),y=C.getContext("2d");h?(C.width=d.width,C.height=d.height,y.drawImage(d,0,0)):(C.width=c.destWidth>d.width?d.width:c.destWidth,C.height=c.destHeight>d.height?d.height:c.destHeight,y.drawImage(this.lowerContext.canvas,c.destLeft>0?c.destLeft:0,c.destTop>0?c.destTop:0,C.width,C.height,0,0,C.width,C.height));var x=-b*Math.PI/180,P=document.createElement("canvas"),w=P.getContext("2d");P.width=C.width,P.height=C.height,c.destWidth>d.width&&!h&&(P.width=d.width),c.destHeight>d.height&&!h&&(P.height=d.height),w.save(),w.translate(C.width/2,C.height/2),w.rotate(x),w.drawImage(C,-C.width/2,-C.height/2),w.restore(),c.destLeft>0&&!h&&(i-=c.destLeft,a-=c.destLeft),c.destTop>0&&!h&&(r-=c.destTop,n-=c.destTop);var j={x:i+l/2,y:r+p/2},S=Math.cos(b*Math.PI/180),O=Math.sin(b*Math.PI/180),T={x:S*(i-j.x)-O*(r-j.y)+j.x,y:O*(i-j.x)+S*(r-j.y)+j.y},k={x:S*(a-j.x)-O*(r-j.y)+j.x,y:O*(a-j.x)+S*(r-j.y)+j.y},F={x:S*(i-j.x)-O*(n-j.y)+j.x,y:O*(i-j.x)+S*(n-j.y)+j.y};h?j={x:d.width/2,y:d.height/2}:(j={x:c.destWidth/2,y:c.destHeight/2},c.destWidth>d.width&&(j.x=d.width/2),c.destHeight>d.height&&(j.y=d.height/2)),S=Math.cos(x),O=Math.sin(x);var I={x:S*(T.x-j.x)-O*(T.y-j.y)+j.x,y:O*(T.x-j.x)+S*(T.y-j.y)+j.y},A={x:S*(k.x-j.x)-O*(k.y-j.y)+j.x,y:O*(k.x-j.x)+S*(k.y-j.y)+j.y},z={x:S*(F.x-j.x)-O*(F.y-j.y)+j.x,y:O*(F.x-j.x)+S*(F.y-j.y)+j.y},D=h?e.canvas.width:c.destWidth>d.width?d.width:c.destWidth,R=h?e.canvas.height:c.destHeight>d.height?d.height:c.destHeight,L=Math.abs(D*Math.cos(x))+Math.abs(R*Math.sin(x)),E=Math.abs(D*Math.sin(x))+Math.abs(R*Math.cos(x)),X=P.width,Y=P.height;if(P.width=L,P.height=E,w.save(),w.translate(L/2,E/2),w.rotate(x),w.drawImage(C,-C.width/2,-C.height/2),w.restore(),"blur"===this.parent.activeObj.redactType){u.width=l,u.height=p;var M=I.x+(L-X)/2,B=I.y+(E-Y)/2;this.isRedactStraighten&&(M=i+(L-X)/2,B=r+(E-Y)/2),g.drawImage(P,M,B,A.x-I.x,z.y-A.y,0,0,l,p)}else{var H=t.redactPixelate/100*20;h&&(H=m*(t.redactPixelate/100)*35),u.width=Math.ceil(l/H),u.height=Math.ceil(p/H);M=I.x+(L-X)/2,B=I.y+(E-Y)/2;this.isRedactStraighten&&(M=i+(L-X)/2,B=r+(E-Y)/2),g.drawImage(P,M,B,A.x-I.x,z.y-A.y,0,0,u.width,u.height)}}if("blur"===this.parent.activeObj.redactType){if(0===b&&(u.width=l,u.height=p,g.drawImage(h?d:this.lowerContext.canvas,i,r,l,p,0,0,l,p)),h){var U=m*(t.redactBlur/100*34);g.filter="blur("+U+"px)"}else g.filter="blur("+t.redactBlur/100*17+"px)";g.drawImage(u,0,0),0===b?g.drawImage(h?d:this.lowerContext.canvas,i,r,l,p,0,0,l,p):(c.destLeft>0&&!h&&(i+=c.destLeft,a+=c.destLeft),c.destTop>0&&!h&&(r+=c.destTop,n+=c.destTop)),this.parent.isSafari&&this.parent.notify("filter",{prop:"apply-filter",onPropertyChange:!1,value:{context:g}}),e.drawImage(u,0,0,l,p,i,r,l,p)}else{H=t.redactPixelate/100*20;h&&(H=m*(t.redactPixelate/100)*35),0===b?(u.width=Math.ceil(l/H),u.height=Math.ceil(p/H),g.drawImage(h?d:this.lowerContext.canvas,i,r,l,p,0,0,u.width,u.height)):(c.destLeft>0&&!h&&(i+=c.destLeft,a+=c.destLeft),c.destTop>0&&!h&&(r+=c.destTop,n+=c.destTop)),e.imageSmoothingEnabled=!1,e.drawImage(u,0,0,u.width,u.height,i,r,l,p),this.parent.imageSmoothingEnabled&&(e.imageSmoothingEnabled=!0)}t.redactImage=this.parent.createElement("canvas"),t.redactImage.width=u.width,t.redactImage.height=u.height,t.redactImage.getContext("2d").drawImage(u,0,0),e.beginPath(),e.rect(i,r,l,p),e.rect(i,r,l,p),e.fill("evenodd"),e.closePath()}},e}(),F=function(){function e(e){this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("export",this.export,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("export",this.export),this.parent.off("destroyed",this.destroy)},e.prototype.export=function(e){switch(this.parent.notify("toolbar",{prop:"refreshShapeDrawing",onPropertyChange:!1}),this.updatePvtVar(),e.prop){case"export":this.exportImg(e.value.type,e.value.fileName,e.value.imgQuality);break;case"exportToCanvas":this.exportToCanvas(e.value.object);break;case"updateSaveContext":this.updateSaveContext(e.value.context);break;case"setImageQuality":this.imageQuality=e.value.value;break;case"drawAnnotation":this.drawAnnotation(e.value.context,e.value.ratio);break;case"downScaleImgCanvas":this.downScaleImgCanvas(e.value.canvas,e.value.width,e.value.height)}},e.prototype.getModuleName=function(){return"export"},e.prototype.updatePvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d"))},e.prototype.exportImg=function(e,t,o){var i=this.parent,r={fileName:""};i.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:r}});var a=r.fileName;if(!i.disabled&&i.isImageLoaded){i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}});var n={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=n.canvasFilter,e=e||"Png",i.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}});var s={cancel:!1,fileName:t||a,fileType:e,imageQuality:o};i.trigger("beforeSave",s),this.beforeSaveEvent(s,e,t,a,o)}},e.prototype.beforeSaveEvent=function(e,t,o,i,r){var a=this.parent;if(!e.cancel){a.currObjType.isSave=!0,o=e.fileName?e.fileName:o;var n=t.toLowerCase();o=o||i,"svg"===n?this.toSVGImg(o):this.toBlobFn(o,n,e.imageQuality||r);var s={fileName:o||i,fileType:t};a.trigger("saved",s);var l={action:"save",actionEventArgs:s};a.triggerEditCompleteEvent(l),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=""}},e.prototype.toSVGImg=function(e){var t=this.parent;(0,b.showSpinner)(t.element),t.element.style.opacity="0.5";var o=this.exportToCanvas(),i=o.toDataURL();(0,b.hideSpinner)(t.element),t.element.style.opacity="1";var r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width",o.style.maxWidth),r.setAttribute("height",o.style.maxHeight);var a=document.createElementNS("http://www.w3.org/2000/svg","image");a.setAttributeNS(null,"height",o.height.toString()),a.setAttributeNS(null,"width",o.width.toString()),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i),r.appendChild(a);var n='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+o.width+'" height="'+o.height+'">',s=r.innerHTML,l="data:image/svg+xml;base64,"+btoa(n+s+"</svg>");return null===e?l:(this.downloadImg(l,e+".svg"),null)},e.prototype.toBlobFn=function(e,t,o){var i=this,r=this.parent;(0,b.showSpinner)(r.element),r.element.style.opacity="0.5",(0,g.isNullOrUndefined)(o)||(o=o>1?1:o<=0?.01:o,this.imageQuality=o||null);var a=this.exportToCanvas(),n="jpeg"===t?"image/jpeg":"webp"===t?"image/webp":"image/png";a.toBlob(function(o){var a=URL.createObjectURL(o);i.downloadImg(a,e+"."+t),(0,b.hideSpinner)(r.element),r.element.style.opacity="1"},n,this.imageQuality?this.imageQuality:null)},e.prototype.exportToCanvas=function(e){var t,o,i=this.parent,r=(0,g.extend)({},i.cropObj,{},!0),a={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=(0,g.extend)([],i.objColl,[],!0),n.pointColl=(0,g.extend)([],i.pointColl,[],!0),n.afterCropActions=(0,g.extend)([],i.afterCropActions,[],!0);var s={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),this.parent.aspectWidth?(i.notify("undo-redo",{prop:"setPreventUR",value:{bool:!0}}),i.notify("toolbar",{prop:"resizeClick",value:{bool:!1}}),i.okBtn(),i.transform.degree%90==0&&i.transform.degree%180!=0?(t=this.parent.aspectHeight,o=this.parent.aspectWidth):(t=this.parent.aspectWidth,o=this.parent.aspectHeight),i.notify("undo-redo",{prop:"setPreventUR",value:{bool:!1}})):i.currSelectionPoint?(t=i.img.srcWidth,o=i.img.srcHeight):(t=i.baseImgCanvas.width,o=i.baseImgCanvas.height);var l={width:0,height:0};i.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:l,dimension:{width:t,height:o}}});var p=l,h=this.lowerContext.filter;if("none"!==this.lowerContext.filter){var d=this.lowerContext.filter.split(" "),c=parseFloat(d[5].split("(")[1]);c*=(p.width+p.height)/2,d[5]="blur("+c+"px)",this.lowerContext.filter=d.join(" ")}var u=i.createElement("canvas",{id:i.element.id+"_tempCanvas",attrs:{name:"canvasImage"}}),v=u.getContext("2d");u.width=t,u.height=o;var f={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t,height:o,obj:f}});var m=f;u.style.maxWidth=m.width+"px",u.style.maxHeight=m.height+"px";var b=this.lowerContext.filter;return v.filter=this.lowerContext.filter,this.downScaleImgCanvas(v,t,o),this.lowerContext.filter=b,0===i.transform.degree&&""===i.transform.currFlipState&&0===i.transform.straighten||(this.updateSaveContext(v),this.exportTransformedImage(v)),i.isSafari&&i.notify("filter",{prop:"apply-filter",onPropertyChange:!1,value:{context:v}}),this.drawAnnotation(v,p),i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:v,isSave:!0,isFlip:null}}),this.updateFrame(v,!0),this.lowerContext.filter=h,i.canvasFilter=h,e&&(e.canvas=u),i.aspectWidth&&(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:n}}),n.selPointColl=(0,g.extend)([],s.selPointColl,[],!0),i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:n.selPointColl}}}),i.cropObj=r,i.objColl=(0,g.extend)([],n.objColl,[],!0),i.pointColl=(0,g.extend)([],n.pointColl,[],!0),i.freehandCounter=i.pointColl.length,i.transform.straighten=0,this.lowerContext.filter="none",i.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),this.lowerContext.filter=n.filter,i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(i.isCircleCrop||i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})),u},e.prototype.drawAnnotation=function(e,t){var o=this.parent,i=(0,g.extend)([],o.objColl,[],!0),r=(0,g.extend)([],o.pointColl,[],!0),a=o.shapeColl.filter(function(e){return"redact"!==e.shape}),n=o.shapeColl.filter(function(e){return"redact"===e.shape});o.shapeColl=n.concat(a);for(var s=0;s<o.shapeColl.length;s++)o.shapeColl[s].order&&(o.shapeColl[s].currIndex&&o.shapeColl[s].currIndex.indexOf("shape")>-1?(o.objColl=[],o.objColl.push((0,g.extend)({},o.shapeColl[s],{},!0)),this.drawShape(e,t)):o.shapeColl[s].id&&o.shapeColl[s].id.indexOf("pen")>-1&&(o.pointColl=[],o.freehandCounter=0,o.pointColl.push((0,g.extend)({},o.shapeColl[s],{},!0)),o.freehandCounter=o.pointColl.length,this.drawPen(e,t)));o.objColl=i,o.pointColl=r,o.freehandCounter=o.pointColl.length},e.prototype.drawShape=function(e,t){var o=this.parent;if(o.objColl.length>0){var i=e.filter;e.filter="none";var r={index:null};o.notify("shape",{prop:"getSmallestIndex",onPropertyChange:!1,value:{obj:r}});for(var a=r.index,n=(0,g.extend)([],o.objColl,[],!0),s=(0,g.extend)([],o.objColl,[],!0);n.length>0;){for(var l=!1,p=0;p<n.length;p++){var h=n[p];if((0,g.isNullOrUndefined)(h.order))n.splice(p,1),p--;else if(h.order===a){var d=e.filter;e.filter="none";var c=n[p],u=c.activePoint;if(u.startX-=o.img.destLeft,u.startY-=o.img.destTop,u.endX-=o.img.destLeft,u.endY-=o.img.destTop,u.width=u.endX-u.startX,u.height=u.endY-u.startY,u.startX*=t.width,u.startY*=t.height,u.endX*=t.width,u.endY*=t.height,u.width=u.endX-u.startX,u.height=u.endY-u.startY,c.strokeSettings.strokeWidth*=(t.width+t.height)/2,"text"===c.shape)c.textSettings.fontSize*=(t.width+t.height)/2;else if("path"===c.shape)for(var v=0;v<c.pointColl.length;v++)c.pointColl[v].x=(c.pointColl[v].x-o.img.destLeft)*t.width,c.pointColl[v].y=(c.pointColl[v].y-o.img.destTop)*t.height;else"image"===c.shape&&(o.activeObj=(0,g.extend)({},n[p],{},!0),o.notify("selection",{prop:"upgradeImageQuality",onPropertyChange:!1}),n[p]=(0,g.extend)({},o.activeObj,{},!0));o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"saveContext",obj:n[p],isCropRatio:null,points:null,isPreventDrag:!0,saveContext:e,isPreventSelection:null}}),e.filter=d,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),a++;var f={bool:!1};o.notify("shape",{prop:"isIndexInObjColl",onPropertyChange:!1,value:{obj:f,index:a}}),f.bool||a++,n.splice(p,1),l=!0;break}}if(!l)break}e.filter=i,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.objColl=s}},e.prototype.drawPen=function(e,t){var o=this.parent;if(o.freehandCounter>0){var i={penStrokeWidth:null};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:i}});for(var r=(0,g.extend)({},o.pointColl,{},!0),a=0;a<o.freehandCounter;a++){o.points=(0,g.extend)([],o.pointColl[a].points,[]),o.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});var n=o.points.length;o.pointColl[a].strokeWidth*=(t.width+t.height)/2;for(var s=0;s<n;s++)o.points[s].x=(o.points[s].x-o.img.destLeft)*t.width,o.points[s].y=(o.points[s].y-o.img.destTop)*t.height}o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:e,points:null}}),o.pointColl=r,o.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:i.penStrokeWidth}})}},e.prototype.downScaleImgCanvas=function(e,t,o){var i=this.parent,r=i.baseImgCanvas,a=i.baseImg,n={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:a.width,height:a.height,obj:n,isImgShape:null}});var s={color:null};if(i.notify("draw",{prop:"getImageBackgroundColor",value:{obj:s}}),""!==s.color&&(e.fillStyle=s.color,e.fillRect(0,0,e.canvas.width,e.canvas.height)),n.width>t&&n.height>o){var l=i.createElement("canvas",{id:i.element.id+"_downScaleCanvas",attrs:{name:"canvasImage"}});l.width=this.parent.img.srcWidth,l.height=this.parent.img.srcHeight,l.getContext("2d").drawImage(r,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,0,0,l.width,l.height),i.notify("draw",{prop:"downScale",value:{canvas:l,width:t,height:o}}),e.drawImage(l,0,0)}else e.drawImage(i.baseImgCanvas,i.img.srcLeft,i.img.srcTop,i.img.srcWidth,i.img.srcHeight,0,0,t,o)},e.prototype.updateFrame=function(e,t){if("none"!==this.parent.frameObj.type){var o=e.filter;e.filter="none",this.parent.notify("draw",{prop:"applyFrame",value:{ctx:e,frame:this.parent.frameObj.type,preventImg:t}}),e.filter=o}},e.prototype.downloadImg=function(e,t){var o=document.createElement("a");o.href=e,o.target="_parent",o.download=t,(document.body||document.documentElement).appendChild(o),o.click(),o.parentNode.removeChild(o)},e.prototype.exportTransformedImage=function(e){var t=this.parent,o=t.transform.degree;if(t.rotateFlipColl.length>0)for(var i=0,r=t.rotateFlipColl.length;i<r;i++){var a=t.rotateFlipColl[i];"number"==typeof a?this.exportRotate(e,a):"horizontal"===a?this.exportFlip(e,!0,!1):"vertical"===a&&this.exportFlip(e,!1,!0)}t.transform.degree=o},e.prototype.exportRotate=function(e,t){var o=this.parent;e.clearRect(0,0,e.canvas.width,e.canvas.height),this.setMaxDim(o.transform.degree,e.canvas),e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*t),e.drawImage(o.inMemoryCanvas,-e.canvas.height/2,-e.canvas.width/2,e.canvas.height,e.canvas.width),this.updateSaveContext(e)},e.prototype.exportFlip=function(e,t,o){e.clearRect(0,0,e.canvas.width,e.canvas.height),t&&(e.translate(e.canvas.width,0),e.scale(-1,1)),o&&(e.translate(0,e.canvas.height),e.scale(1,-1)),e.drawImage(this.parent.inMemoryCanvas,0,0),this.updateSaveContext(e)},e.prototype.updateSaveContext=function(e){var t=this.parent.inMemoryCanvas.getContext("2d");e.setTransform(1,0,0,1,0,0);var o=e.getImageData(0,0,e.canvas.width,e.canvas.height);this.parent.inMemoryCanvas.width=o.width,this.parent.inMemoryCanvas.height=o.height,t.putImageData(o,0,0)},e.prototype.setMaxDim=function(e,t){var o,i;e%90==0&&e%180!=0?(0,g.isNullOrUndefined)(this.parent.currSelectionPoint)?(o=this.parent.baseImgCanvas.height,i=this.parent.baseImgCanvas.width):(o=this.parent.img.srcHeight,i=this.parent.img.srcWidth):e%180!=0&&0!==e||((0,g.isNullOrUndefined)(this.parent.currSelectionPoint)?(o=this.parent.baseImgCanvas.width,i=this.parent.baseImgCanvas.height):(o=this.parent.img.srcWidth,i=this.parent.img.srcHeight)),(0,g.isNullOrUndefined)(this.parent.aspectWidth)||(o=this.parent.aspectWidth,i=this.parent.aspectHeight),t.width=o,t.height=i;var r={width:0,height:0};this.parent.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o,height:i,obj:r,isImgShape:null}});var a=r;t.style.maxWidth=a.width+"px",t.style.maxHeight=a.height+"px"},e}(),I=function(){function e(e){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.adjustmentValue="",this.isBrightnessAdjusted=!1,this.bevelFilter="none",this.tempAdjVal={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.tempFilVal="",this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("filter",this.filter,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("filter",this.filter),this.parent.off("destroyed",this.destroy)},e.prototype.filter=function(e){switch(this.updatePrivateVariables(),e.prop){case"finetuneImage":this.finetuneImage(e.value.option,e.value.value);break;case"applyImageFilter":this.setFilter(e.value.option);break;case"update-finetunes":this.updateFinetunes();break;case"set-adjustment":this.setAdjustment(e.value.operation);break;case"initFilter":this.initFilter();break;case"setCurrAdjValue":this.setCurrAdjValue(e.value.type,e.value.value);break;case"updateAdj":this.updateAdj(e.value.type,e.value.value,e.value.isPreview,e.value.ctx);break;case"getCurrentObj":this.getCurrentObj(e.value.object);break;case"getAdjustmentLevel":(0,g.isNullOrUndefined)(this.parent.activeObj.opacity)?this.adjustmentLevel.transparency=100:this.adjustmentLevel.transparency=100*this.parent.activeObj.opacity,e.value.obj.adjustmentLevel=this.adjustmentLevel;break;case"setAdjustmentLevel":this.adjustmentLevel=e.value.adjustmentLevel;break;case"getTempAdjustmentLevel":e.value.obj.tempAdjustmentLevel=this.tempAdjustmentLevel;break;case"setTempAdjustmentLevel":this.tempAdjustmentLevel=e.value.tempAdjustmentLevel;break;case"setAdjustmentValue":this.adjustmentValue=e.value.adjustmentValue;break;case"setBrightnessAdjusted":this.isBrightnessAdjusted=e.value.isBrightnessAdjusted,this.parent.currentFilter.split("_")&&"cold"===this.parent.currentFilter.split("_")[1]&&(this.isBrightnessAdjusted=!1);break;case"getBevelFilter":e.value.obj.bevelFilter=this.bevelFilter;break;case"setBevelFilter":this.bevelFilter=e.value.bevelFilter;break;case"setTempAdjVal":this.tempAdjVal=(0,g.extend)({},this.adjustmentLevel,{},!0);break;case"setTempFilVal":this.tempFilVal=this.parent.currentFilter;break;case"reset":this.reset();break;case"apply-filter":this.applyFilter(e.value.context)}},e.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d"))},e.prototype.getModuleName=function(){return"filter"},e.prototype.reset=function(){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.adjustmentValue=this.parent.getDefaultFilter(),this.isBrightnessAdjusted=!1,this.bevelFilter="none",this.tempFilVal="",this.tempAdjVal={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1}},e.prototype.updateFinetunes=function(){var e=this,t=this.parent,o=t.finetuneSettings;if(o){["brightness","contrast","hue","saturation","exposure","opacity","blur"].forEach(function(t){o[t]&&(e.adjustmentLevel[t]=o[t].defaultValue,e.tempAdjustmentLevel[t]=o[t].defaultValue)}),t.notify("draw",{prop:"isInitialLoading",onPropertyChange:!1,value:{isInitialLoading:!0}})}},e.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)},e.prototype.updateAdj=function(e,t,o,i){var r=this.parent;this.lowerContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height);var a,n,s,l,p,h=this.lowerContext.filter.split(" "),d=[],c=this.getFilterValue(this.adjustmentLevel.brightness);switch(e){case"brightness":t=this.getFilterValue(this.adjustmentLevel.exposure)+.005*t,h[0]="brightness("+t+")",0!==this.adjustmentLevel.brightness?(t=this.adjustmentLevel.opacity/100-.3*this.adjustmentLevel.opacity/100,h[4]="opacity("+t+")"):(t=this.adjustmentLevel.opacity/100,h[4]="opacity("+t+")"),this.adjustmentValue=h.join(" ");break;case"contrast":h[1]="contrast("+t+"%)",this.adjustmentValue=h.join(" ");break;case"hue":h[2]="hue-rotate("+t+"deg)",this.adjustmentValue=h.join(" ");break;case"saturation":h[3]="saturate("+t+"%)",this.adjustmentValue=h.join(" ");break;case"opacity":1!==parseFloat(h[0].split("(")[1])&&(t-=.2),t<0&&(t=0),h[4]="opacity("+t+")",this.adjustmentValue=h.join(" ");break;case"blur":h[5]="blur("+t+"px)",this.adjustmentValue=h.join(" ");break;case"exposure":t>1?(t-=1,t+=c):t<1&&(t=c-(t=1-t)),h[0]="brightness("+t+")",this.adjustmentValue=h.join(" ");break;case"chrome":a=this.getSaturationFilterValue(this.adjustmentLevel.saturation),t=(a*=100)+.4*a,h[3]="saturate("+t+"%)",d=this.adjustmentValue.split(" "),h[0]=d[0],h[1]=d[1],h[2]=d[2],h[4]=d[4],h[5]=d[5],h[6]="sepia(0%)",h[7]="grayscale(0%)",h[8]="invert(0%)";break;case"cold":n=this.getFilterValue(this.adjustmentLevel.brightness),t=.9*(n*=100),t*=.01,h[0]="brightness("+t+")",l=this.getFilterValue(this.adjustmentLevel.contrast),t=(l*=100)+.5*l,h[1]="contrast("+t+"%)",p=this.getSaturationFilterValue(this.adjustmentLevel.saturation),t=p*=100,h[3]="saturate("+t+"%)",d=this.adjustmentValue.split(" "),h[2]=d[2],h[4]=d[4],h[5]=d[5],h[6]="sepia(0%)",h[7]="grayscale(0%)",h[8]="invert(0%)";break;case"warm":s=this.getSaturationFilterValue(this.adjustmentLevel.saturation),t=(s*=100)+.4*s,h[3]="saturate("+t+"%)",h[6]="sepia(25%)",d=this.adjustmentValue.split(" "),h[0]=d[0],h[1]=d[1],h[2]=d[2],h[4]=d[4],h[5]=d[5],h[7]="grayscale(0%)",h[8]="invert(0%)";break;case"grayscale":h[7]="grayscale(100%)",d=this.adjustmentValue.split(" "),h[0]=d[0],h[1]=d[1],h[2]=d[2],h[3]=d[3],h[4]=d[4],h[5]=d[5],h[6]="sepia(0%)",h[8]="invert(0%)";break;case"sepia":h[6]="sepia(100%)",d=this.adjustmentValue.split(" "),h[0]=d[0],h[1]=d[1],h[2]=d[2],h[3]=d[3],h[4]=d[4],h[5]=d[5],h[7]="grayscale(0%)",h[8]="invert(0%)";break;case"invert":h[8]="invert(100%)",d=this.adjustmentValue.split(" "),h[0]=d[0],h[1]=d[1],h[2]=d[2],h[3]=d[3],h[4]=d[4],h[5]=d[5],h[6]="sepia(0%)",h[7]="grayscale(0%)"}if("sharpen"!==e&&"blackandwhite"!==e){(0,g.isNullOrUndefined)(o)&&("default"===e&&(h=this.getDefaultCurrentFilter(h)),this.lowerContext.filter=h.join(" ")),h=this.setTempFilterValue(c,o,h,e),r.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),r.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var u=void 0;"bevel"===r.frameObj.type&&(u=this.lowerContext.filter,this.bevelFilter=u),0===r.transform.degree&&r.rotateFlipColl.length>0&&(r.img.destLeft+=r.panPoint.totalPannedPoint.x,r.img.destTop+=r.panPoint.totalPannedPoint.y),r.img.destLeft+=r.panPoint.totalPannedInternalPoint.x,r.img.destTop+=r.panPoint.totalPannedInternalPoint.y,0===r.transform.degree&&r.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),r.notify("draw",{prop:"drawImage",onPropertyChange:!1}),r.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),r.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),0===r.transform.degree&&r.rotateFlipColl.length>0&&(r.img.destLeft+=r.panPoint.totalPannedPoint.x,r.img.destTop+=r.panPoint.totalPannedPoint.y),h=this.setTempFilterValue(c,o,h,e),(0,g.isNullOrUndefined)(o)&&(this.lowerContext.filter=h.join(" ")),r.initialAdjustmentValue=h.join(" "),u=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%)",this.bevelFilter=u,r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),this.lowerContext.filter=u,r.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape||r.isCircleCrop)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.isBrightnessAdjusted=1!==c}var v=h.join(" ");i&&(i.filter=v)},e.prototype.setTempFilterValue=function(e,t,o,i){if(t)if("default"===i)o=this.getDefaultCurrentFilter(o);else if(1!==e){var r=this.lowerContext.filter.split(" ");r[4]=o[4],this.lowerContext.filter=r.join(" ")}return o},e.prototype.getDefaultCurrentFilter=function(e){var t=this.adjustmentValue.split(" ");return[t[0],t[1],t[2],t[3],t[4],t[5],"sepia(0%)","grayscale(0%)","invert(0%)"]},e.prototype.getFilterValue=function(e){return 0===e?1:1+.5*e/100},e.prototype.getSaturationFilterValue=function(e){return 0===e?1:1+e/100},e.prototype.setFilterAdj=function(e,t){var o=this.parent;switch(o.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1}),this.adjustmentLevel[""+e]=t,e){case"contrast":case"exposure":t=this.getFilterValue(t),"contrast"===e&&(t*=100);break;case"hue":t*=3;break;case"saturation":t=100*this.getSaturationFilterValue(t);break;case"opacity":t<10&&(t+=1),t/=100;break;case"blur":0!==t&&(t/=20,t+=.5)}var i=(0,g.extend)({},o.cropObj,{},!0),r=this.getCurrentObj();r.objColl=(0,g.extend)([],o.objColl,[],!0),r.pointColl=(0,g.extend)([],o.pointColl,[],!0),r.afterCropActions=(0,g.extend)([],o.afterCropActions,[],!0);var a={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=(0,g.extend)([],a.selPointColl,[],!0),this.updateAdj(e,t),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:e,previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})},e.prototype.setFilter=function(e){var t=this.parent;e=e.toLowerCase(),t.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1});var o={currentFilter:this.parent.currentFilter}.currentFilter,i=(0,g.extend)({},t.cropObj,{},!0),r=this.getCurrentObj();r.objColl=(0,g.extend)([],t.objColl,[],!0),r.pointColl=(0,g.extend)([],t.pointColl,[],!0),r.afterCropActions=(0,g.extend)([],t.afterCropActions,[],!0);var a={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=(0,g.extend)([],a.selPointColl,[],!0),this.updateAdj(e,null),t.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:e,previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:o,isCircleCrop:null}})},e.prototype.setAdjustment=function(e){var t,o,i=this.lowerContext.filter.split(" ");switch(e){case"brightness":o=i[0].split("("),t=parseFloat(o[1].split(")")[0]),this.adjustmentLevel.brightness=this.setFilterValue(t);break;case"contrast":o=i[1].split("("),t=parseFloat(o[1].split(")")[0]),t/=100,this.adjustmentLevel.contrast=this.setFilterValue(t);break;case"hue":o=i[2].split("("),t=parseFloat(o[1].split(")")[0]),t/=3,this.adjustmentLevel.hue=t;break;case"saturation":o=i[3].split("("),t=parseFloat(o[1].split(")")[0]),t/=100,this.adjustmentLevel.saturation=this.setSaturationFilterValue(t);break;case"opacity":o=i[4].split("("),.45===(t=parseFloat(o[1].split(")")[0]))?t=40:.4===t?t=30:.35===t?t=20:.3===t?t=10:.25===t?t=0:t*=100,this.adjustmentLevel.opacity=t;break;case"blur":o=i[5].split("("),t=parseFloat(o[1].split(")")[0]),t*=20,this.adjustmentLevel.blur=t;break;case"exposure":o=i[0].split("("),t=parseFloat(o[1].split(")")[0]),this.adjustmentLevel.exposure=this.setFilterValue(t)}},e.prototype.setFilterValue=function(e){return Math.round(1===e?0:100*(e-1)/.5)},e.prototype.setSaturationFilterValue=function(e){return Math.round(1===e?0:100*(e-1))},e.prototype.finetuneImage=function(e,t){var o=this.parent;if(!o.disabled&&o.isImageLoaded){switch(e.toLowerCase()){case"brightness":this.setFilterAdj("brightness",t);break;case"contrast":this.setFilterAdj("contrast",t);break;case"hue":this.setFilterAdj("hue",t);break;case"saturation":this.setFilterAdj("saturation",t);break;case"opacity":this.setFilterAdj("opacity",t);break;case"blur":this.setFilterAdj("blur",t);break;case"exposure":this.setFilterAdj("exposure",t)}this.parent.canvasFilter=this.lowerContext.filter,o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},e.prototype.setCurrAdjValue=function(e,t){var o=this.parent;switch(this.parent.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),e){case"brightness":this.setFilterAdj("brightness",t);break;case"contrast":this.setFilterAdj("contrast",t);break;case"hue":this.setFilterAdj("hue",t);break;case"saturation":this.setFilterAdj("saturation",t);break;case"opacity":this.setFilterAdj("opacity",t);break;case"blur":this.setFilterAdj("blur",t);break;case"exposure":this.setFilterAdj("exposure",t)}o.isFinetuneBtnClick=!0,o.curFinetuneObjEvent={finetune:o.toPascalCase(e),value:t}},e.prototype.getCurrentObj=function(e){var t=this.parent,o={point:null};t.notify("crop",{prop:"getTempFlipPanPoint",value:{obj:o}});var i={previousZoomValue:null};t.notify("transform",{prop:"getPreviousZoomValue",value:{obj:i}});var r={zoomFactor:null};t.notify("draw",{prop:"getStraightenInitZoom",value:{obj:r}});var a={color:null};t.notify("draw",{prop:"getImageBackgroundColor",value:{obj:a}});var n={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,straighten:0,destPoints:{startX:0,startY:0,width:0,height:0},frame:"none",srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:this.isBrightnessAdjusted,aspectWidth:null,aspectHeight:null,straightenZoom:0,adjustmentLevel:(0,g.extend)({},this.tempAdjVal,{},!0),currentFilter:this.tempFilVal,imageSource:"",bgColor:""};return n.cropZoom=t.transform.cropZoomFactor,n.defaultZoom=t.transform.defaultZoomFactor,n.zoomFactor=t.zoomSettings.zoomFactor,n.previousZoomValue=i.previousZoomValue,n.straightenZoom=r.zoomFactor,n.totalPannedPoint=(0,g.extend)({},t.panPoint.totalPannedPoint,{},!0),n.totalPannedClientPoint=(0,g.extend)({},t.panPoint.totalPannedClientPoint,{},!0),n.totalPannedInternalPoint=(0,g.extend)({},t.panPoint.totalPannedInternalPoint,{},!0),n.tempFlipPanPoint=(0,g.extend)({},o.point,{},!0),n.activeObj=(0,g.extend)({},t.activeObj,{},!0),n.rotateFlipColl=(0,g.extend)([],t.rotateFlipColl,[],!0),n.degree=t.transform.degree,n.straighten=t.cropObj.straighten,n.currFlipState=t.transform.currFlipState,n.destPoints={startX:t.img.destLeft,startY:t.img.destTop,endX:0,endY:0,width:t.img.destWidth,height:t.img.destHeight},n.srcPoints={startX:t.img.srcLeft,startY:t.img.srcTop,endX:0,endY:0,width:t.img.srcWidth,height:t.img.srcHeight},n.filter=this.lowerContext.filter,n.aspectWidth=t.aspectWidth,n.aspectHeight=t.aspectHeight,n.frame=t.frameObj.type,n.frameObj=(0,g.extend)({},t.frameObj),n.imageSource=t.baseImg.src,n.bgColor=a.color,e&&(e.currObj=n),n},e.prototype.getValFromPercentage=function(e){var t=parseFloat(e);return/%\s*?$/i.test(e)&&(t/=100),t},e.prototype.getValFromLength=function(e){return parseFloat(e)},e.prototype.parseFilterString=function(e){var t=[];return e&&"none"!==e&&(t=e.split(" ").map(function(e){var t=e.match(/([a-z-]+)\(([^)]+)\)/).slice(1,3);return{filter:t[0],value:t[1]}})),t},e.prototype.applyFilter=function(e){for(var t=e.canvas,o=t.height,i=t.width,r=e.getImageData(0,0,i,o),a=this.parseFilterString(e.filter),n=0,s=a.length;n<s;n++)switch(a[n].filter){case"blur":r=this.blur(e,r,a[n].value);break;case"brightness":r=this.brightness(r,a[n].value);break;case"contrast":r=this.contrast(r,a[n].value);break;case"grayscale":r=this.grayscale(r,a[n].value);break;case"hue-rotate":r=this.hueRotate(r,a[n].value);break;case"invert":r=this.invert(r,a[n].value);break;case"opacity":r=this.opacity(r,a[n].value);break;case"saturate":r=this.saturate(e,r,a[n].value);break;case"sepia":r=this.sepia(r,a[n].value)}e.putImageData(r,0,0)},e.prototype.blur=function(e,t,o){void 0===o&&(o="0");var i=this.getValFromLength(o);if((i=Math.floor(i))<=0)return t;for(var r=e.canvas,a=r.height,n=r.width,s=t.data,l=new Uint8ClampedArray(s.length),p=0;p<a;p++)for(var h=0;h<n;h++){for(var d=0,c=0,u=0,g=0,v=0,f=-i;f<=i;f++)for(var m=-i;m<=i;m++){var b=h+m,C=p+f;if(b>=0&&b<n&&C>=0&&C<a){var y=4*(C*n+b);d+=s[y],c+=s[y+1],u+=s[y+2],g+=s[y+3],v++}}l[x=4*(p*n+h)]=d/v,l[x+1]=c/v,l[x+2]=u/v,l[x+3]=g/v}for(var x=0;x<s.length;x++)s[x]=l[x];return t},e.prototype.brightness=function(e,t){void 0===t&&(t="1");var o=this.getValFromPercentage(t);if(1!==o)for(var i=e.data,r=i.length,a=0;a<r;a+=4)i[a+0]*=o,i[a+1]*=o,i[a+2]*=o;return e},e.prototype.contrast=function(e,t){void 0===t&&(t="1");var o=this.getValFromPercentage(t);if(1!==o)for(var i=e.data,r=i.length,a=0;a<r;a+=4)i[a+0]=255*((i[a+0]/255-.5)*o+.5),i[a+1]=255*((i[a+1]/255-.5)*o+.5),i[a+2]=255*((i[a+2]/255-.5)*o+.5);return e},e.prototype.grayscale=function(e,t){void 0===t&&(t="0");var o=this.getValFromPercentage(t);if(o>0)for(var i=e.data,r=i.length,a=0;a<r;a+=4){var n=i[a],s=i[a+1],l=i[a+2],p=.299*n+.587*s+.114*l;i[a]=n*(1-o)+p*o,i[a+1]=s*(1-o)+p*o,i[a+2]=l*(1-o)+p*o}return e},e.prototype.hueRotate=function(e,t){void 0===t&&(t="0deg");var o=e.data,i=parseFloat(t)*(Math.PI/180);if(i>0)for(var r=Math.cos(i),a=Math.sin(i),n=[.213+.787*r-.213*a,.715-.715*r-.715*a,.072-.072*r+.928*a,.213-.213*r+.143*a,.715+.285*r+.14*a,.072-.072*r-.283*a,.213-.213*r-.787*a,.715-.715*r+.715*a,.072+.928*r+.072*a],s=0;s<o.length;s+=4){var l=o[s],p=o[s+1],h=o[s+2];o[s]=n[0]*l+n[1]*p+n[2]*h,o[s+1]=n[3]*l+n[4]*p+n[5]*h,o[s+2]=n[6]*l+n[7]*p+n[8]*h}return e},e.prototype.invert=function(e,t){void 0===t&&(t="0");var o=this.getValFromPercentage(t);if(o>0)for(var i=e.data,r=i.length,a=0;a<r;a+=4)i[a+0]=Math.abs(i[a+0]-255*o),i[a+1]=Math.abs(i[a+1]-255*o),i[a+2]=Math.abs(i[a+2]-255*o);return e},e.prototype.opacity=function(e,t){void 0===t&&(t="0");var o=this.getValFromPercentage(t);if(o>=0)for(var i=e.data,r=i.length,a=3;a<r;a+=4)i[a]*=o;return e},e.prototype.saturate=function(e,t,o){void 0===o&&(o="0");var i=this.getValFromPercentage(o);if(1!==i)for(var r=e.canvas,a=r.width,n=r.height,s=t.data,l=.3086*(1-i),p=.6094*(1-i),h=.082*(1-i),d=a<<2,c=0;c<n;c++)for(var u=c*d,g=0;g<a;g++){var v=u+(g<<2),f=s[v+0],m=s[v+1],b=s[v+2];s[v+0]=(l+i)*f+p*m+h*b,s[v+1]=l*f+(p+i)*m+h*b,s[v+2]=l*f+p*m+(h+i)*b}return t},e.prototype.sepia=function(e,t){void 0===t&&(t="0");var o=this.getValFromPercentage(t);if(o>1&&(o=1),o>0)for(var i=e.data,r=i.length,a=0;a<r;a+=4){var n=i[a+0],s=i[a+1],l=i[a+2];i[a+0]=(.393*n+.769*s+.189*l)*o+n*(1-o),i[a+1]=(.349*n+.686*s+.168*l)*o+s*(1-o),i[a+2]=(.272*n+.534*s+.131*l)*o+l*(1-o)}return e},e}(),A=function(){function e(e){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.dummyPoints=[],this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null},this.straightenPoint={x:null,y:null,ratioX:null,ratioY:null},this.straightenPointAngle=0,this.isMasking=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("freehand-draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("freehand-draw",this.draw),this.parent.off("destroyed",this.destroy)},e.prototype.draw=function(e){switch(this.updateFhdPvtVar(),e.prop){case"hoverFhd":this.hoverFhd(e.value.strokeColor,e.value.strokeWidth);break;case"freehandDownHandler":this.freehandDownHandler(e.value.e,e.value.canvas);break;case"freehandUpHandler":this.freehandUpHandler(e.value.e,e.value.canvas,e.value.context);break;case"handle-freehand-draw":var t=parseInt(e.value.id.split("_")[1],10)-1;this.isFHDIdx(t)&&this.deleteFhd(t,!0);break;case"freehandRedraw":this.freehandRedraw(e.value.context,e.value.points);break;case"deleteFhd":t=parseInt(e.value.id.split("_")[1],10)-1;this.deleteFhd(t,!0);break;case"selectFhd":t=null;e.value.id&&(t=parseInt(e.value.id.split("_")[1],10)-1),this.selectFhd(t);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(e.value.value);break;case"panFHDColl":this.panFHDColl(e.value.xDiff,e.value.yDiff,e.value.panRegion);break;case"updateFHDColl":e.value&&e.value.isPreventApply?this.updateFHDColl(e.value.isPreventApply):this.updateFHDColl();break;case"zoomFHDColl":this.zoomFHDColl(e.value.isPreventApply);break;case"apply-pen-draw":this.applyPenDraw();break;case"freeHandDraw":this.freeHandDraw(e.value.value);break;case"isFHDIdx":this.isFHDIdx(e.value.index,e.value.obj);break;case"getSqPtFD":this.getSqPtFD(e.value.idx,e.value.obj);break;case"getSelPointColl":e.value.obj.selPointColl=(0,g.extend)([],this.selPointColl);break;case"setSelPointColl":this.selPointColl=(0,g.extend)([],e.value.obj.selPointColl);break;case"pushSelPointColl":this.selPointColl.push((0,g.extend)([],e.value.obj.selPointColl));break;case"setFreehandDrawHoveredIndex":this.fhdHovIdx=e.value.index;break;case"getFreehandDrawHoveredIndex":e.value.obj.index=this.fhdHovIdx;break;case"setPointCounter":this.pointCounter=e.value.value;break;case"getPenStrokeWidth":e.value.obj.penStrokeWidth=this.penStrokeWidth;break;case"setPenStrokeWidth":this.penStrokeWidth=e.value.value;break;case"getCurrentFreehandDrawIndex":e.value.obj.currentFreehandDrawIndex=this.currFHDIdx;break;case"setCurrentFreehandDrawIndex":this.currFHDIdx=e.value.value;break;case"updateCropPtsForSel":this.updateCropPtsForSel();break;case"getFreehandDrawSelectedId":e.value.obj.freehandDrawSelectedId=this.fhdSelID;break;case"resetFreehandDrawSelectedId":this.fhdSelID=null;break;case"getFHDSelected":e.value.obj.isSelected=!(!this.parent.pointColl[this.fhdSelIdx]||!this.parent.pointColl[this.fhdSelIdx].isSelected)&&this.parent.pointColl[this.fhdSelIdx].isSelected;break;case"resetFHDIdx":this.fhdHovIdx=this.fhdSelID=this.fhdSelIdx=null;break;case"getHighestOrder":this.getHighestOrder();break;case"getTempFreeHandDrawEditingStyles":e.value.obj.tempFreeHandDrawEditingStyles=this.tempFHDStyles;break;case"setFreehandSelectedIndex":this.fhdSelIdx=e.value.index;break;case"getFreehandSelectedIndex":e.value.obj.freehandSelectedIndex=this.fhdSelIdx;break;case"setCenterSelPoints":this.setCenterSelPoints();break;case"getStraightenPoint":e.value.obj.straightenPoint=(0,g.extend)({},this.straightenPoint,{},!0);break;case"setStraightenPoint":this.straightenPoint.x=e.value.x,this.straightenPoint.y=e.value.y,e.value.ratioX&&e.value.ratioY&&(this.straightenPoint.ratioX=e.value.ratioX,this.straightenPoint.ratioY=e.value.ratioY);break;case"resetStraightenPoint":this.straightenPoint={x:null,y:null,ratioX:null,ratioY:null},this.prevStraightenObj=null,this.straightenPointAngle=0;break;case"getStraightenPointAngle":e.value.obj.angle=this.straightenPointAngle;break;case"reset":this.reset();break;case"triggerShapeChanging":this.triggerShapeChanging(e.value.shapeChangingArgs);break;case"setMasking":this.isMasking=e.value.value;break;case"resetSelPoints":this.selPoints=[]}},e.prototype.updateFhdPvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},e.prototype.reset=function(){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=this.isFreehandPointMoved=!1,this.selPoints=[],this.dummyPoints=[],this.freehandDownPoint={x:0,y:0},this.selPointColl={},this.straightenPointAngle=0,this.fhdHovIdx=null,this.pointCounter=0,this.fhdSelID=null,this.isMasking=!1,this.penStrokeWidth=void 0,this.currFHDIdx=0,this.fhdSelIdx=null,this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null},this.straightenPoint={x:null,y:null,ratioX:null,ratioY:null},this.prevStraightenObj=null},e.prototype.getModuleName=function(){return"freehand-draw"},e.prototype.hoverFhd=function(e,t){var o=this.parent,i=this.upperContext,r=-1;r=this.fhdHovIdx>-1?this.fhdHovIdx:this.fhdSelIdx,o.points=(0,g.extend)([],o.pointColl[r].points),this.pointCounter=0;var a,n,s,l,p,h,d=o.points.length;i.fillStyle=e||o.pointColl[r].strokeColor,i.strokeStyle=i.fillStyle,p=h=this.penStrokeWidth=t||o.pointColl[r].strokeWidth,1===d&&(a=n=s=l=o.points[0],this.startDraw(i,a,n,s,l,p,h));for(var c=0;c<d-3;c++)o.points[c+1]&&o.points[c+2]&&o.points[c+2]&&(a=this.calcCurveCP(o.points[c+0],o.points[c+1],o.points[c+2]).controlPoint2,n=this.calcCurveCP(o.points[c+1],o.points[c+2],o.points[c+3]).controlPoint1,s=0===c?o.points[c]:o.points[c+1],l=o.points[c+2],this.startDraw(i,a,n,s,l,p,h));i.closePath();var u=this.getSqPtFD(r),v=i.lineWidth;i.lineWidth=2,i.strokeStyle=o.themeColl[o.theme].primaryColor,i.beginPath(),i.rect(u.startX,u.startY,u.width,u.height),i.stroke(),i.closePath(),i.lineWidth=v},e.prototype.freehandDownHandler=function(e,t){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"),this.fhdObj.time=(new Date).getTime(),this.isFreehandDrawing=!0,"mousedown"===e.type?this.freehandDownPoint={x:e.clientX,y:e.clientY}:this.freehandDownPoint={x:e.touches[0].clientX,y:e.touches[0].clientY},this.isFreehandPointMoved=!1,g.EventHandler.add(t,"mousemove touchmove",this.freehandMoveHandler,this);var r={id:"pen_"+(this.currFHDIdx+1),type:i.FreehandDraw,startX:this.freehandDownPoint.x,startY:this.freehandDownPoint.y,strokeColor:o.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,points:null,index:o.objColl.length+o.freehandCounter+1},a={cancel:!1,action:"draw-start",previousShapeSettings:r,currentShapeSettings:r};this.triggerShapeChanging(a)},e.prototype.freehandUpHandler=function(e,t,o){var r=t.getBoundingClientRect(),a=this.parent;g.EventHandler.remove(t,"mousemove touchmove",this.freehandMoveHandler),0===a.points.length&&("mouseup"===e.type?this.processPoint(e.clientX-r.left,e.clientY-r.top,!0,o):"touchend"===e.type&&e.changedTouches?this.processPoint(e.changedTouches[0].clientX-r.left,e.changedTouches[0].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=(0,g.extend)({},a.cropObj,{},!0),s={currObj:{}};a.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=(0,g.extend)([],a.objColl,[],!0),l.pointColl=(0,g.extend)([],a.pointColl,[],!0),l.afterCropActions=(0,g.extend)([],a.afterCropActions,[],!0);var p={selPointColl:null};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=(0,g.extend)([],p.selPointColl,[],!0);var h=a.freehandCounter,d=this.getHighestOrder(),c=a.objColl.length+d+1;a.pointColl[h]={points:(0,g.extend)([],a.points),strokeColor:a.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,flipState:a.transform.currFlipState,id:"pen_"+(d+1),order:c},a.points=[],this.dummyPoints=[],this.selPointColl[h]={points:(0,g.extend)([],this.selPoints)},this.selPoints=[],this.pointCounter=0,a.freehandCounter++,this.isFreehandDrawing=!1,a.isMaskImage||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}});var u={id:"pen_"+(d+1),type:i.FreehandDraw,startX:this.freehandDownPoint.x,startY:this.freehandDownPoint.y,strokeColor:a.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,points:a.pointColl[this.currFHDIdx].points,index:c},v={cancel:!1,action:"draw-end",previousShapeSettings:u,currentShapeSettings:u};this.triggerShapeChanging(v),this.currFHDIdx++},e.prototype.getHighestOrder=function(){for(var e=this.parent,t=0,o=0;o<e.pointColl.length;o++){var i=parseInt(e.pointColl[o].id.split("_")[1],10);t<i&&(t=i)}return t},e.prototype.freehandMoveHandler=function(e){this.isFreehandPointMoved=!0;var t,o,i=this.parent.upperCanvas.getBoundingClientRect();"mousemove"===e.type?(t=e.clientX-i.left,o=e.clientY-i.top):(t=e.touches[0].clientX-i.left,o=e.touches[0].clientY-i.top),this.isFreehandDrawing&&(this.upperContext.fillStyle=this.parent.activeObj.strokeSettings.strokeColor,this.parent.isMaskImage&&(this.upperContext.globalCompositeOperation="xor"),this.processPoint(t,o,!1,this.upperContext))},e.prototype.processPoint=function(e,t,o,i){var r,a,n,s,l=this.parent,p=this.point(e,t,(new Date).getTime()),h=!!(p=l.points.length>0&&l.points[l.points.length-1])&&this.distanceTo(p)<=5;if(this.selPoints.push({x:e,y:t,ratioX:(e-l.img.destLeft)/l.img.destWidth,ratioY:(t-l.img.destTop)/l.img.destHeight,time:this.fhdObj.time}),!p||!p||!h||o){if(this.fhdObj.time=(new Date).getTime(),l.points.push({x:e,y:t,ratioX:(e-l.img.destLeft)/l.img.destWidth,ratioY:(t-l.img.destTop)/l.img.destHeight,time:this.fhdObj.time}),this.dummyPoints.push({x:e,y:t,ratioX:(e-l.img.destLeft)/l.img.destWidth,ratioY:(t-l.img.destTop)/l.img.destHeight,time:this.fhdObj.time}),this.dummyPoints.length>2){3===this.dummyPoints.length&&this.dummyPoints.unshift(this.dummyPoints[0]);var d=this.dummyPoints[0],c=this.dummyPoints[1],u=this.dummyPoints[2],v=this.dummyPoints[3];r=this.calcCurveCP(d,c,u).controlPoint2,a=this.calcCurveCP(c,u,v).controlPoint1,n=this.dummyPoints[1],s=this.dummyPoints[2];var f=.5,m=5;(0,g.isNullOrUndefined)(this.penStrokeWidth)||(f=m=this.penStrokeWidth),this.startDraw(i,r,a,n,s,f,m),this.pointCounter++,this.dummyPoints.shift()}if(o){r=a=n=s={x:e,y:t,time:(new Date).getTime()};f=.5,m=5;(0,g.isNullOrUndefined)(this.penStrokeWidth)||(f=m=this.penStrokeWidth),this.startDraw(i,r,a,n,s,f,m)}}},e.prototype.calcCurveCP=function(e,t,o){t||(t=e),o||(o=t);var i=e.x-t.x,r=e.y-t.y,a=t.x-o.x,n=t.y-o.y,s=(e.x+t.x)/2,l=(e.y+t.y)/2,p=(t.x+o.x)/2,h=(t.y+o.y)/2,d=Math.sqrt(i*i+r*r),c=Math.sqrt(a*a+n*n),u=c/(d+c),g=p+(s-p)*u,v=h+(l-h)*u,f=t.x-g,m=t.y-v;return{controlPoint1:this.point(s+f,l+m,0),controlPoint2:this.point(p+f,h+m,0)}},e.prototype.point=function(e,t,o){return this.fhdObj.pointX=e,this.fhdObj.pointY=t,{x:this.fhdObj.pointX,y:this.fhdObj.pointY,time:o}},e.prototype.startDraw=function(e,t,o,i,r,a,n){var s;s=.7*(s=this.pointVelocity(i))+(1-.7)*this.fhdObj.lastVelocity;var l=Math.max(n/1.7,a);this.drawCurve(this.fhdObj.time,l,e,t,o,i,r,n),this.fhdObj.lastVelocity=s,this.fhdObj.time=l},e.prototype.pointVelocity=function(e){return this.fhdObj.time!==e.time?this.distanceTo(e)/(this.fhdObj.time-e.time):0},e.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.fhdObj.pointX-e.x,2)+Math.pow(this.fhdObj.pointY-e.y,2))},e.prototype.drawCurve=function(e,t,o,i,r,a,n,s){var l,p,h,d,c,u,g,v,f,m,b=t-e,C=this.bezierLength(i,r,a,n),y=2*Math.ceil(C);for(o.beginPath(),p=0;p<y;p++)c=(d=(h=p/y)*h)*h,f=(v=(g=(u=1-h)*u)*u)*a.x,f+=3*g*h*i.x,f+=3*u*d*r.x,f+=c*n.x,m=v*a.y,m+=3*g*h*i.y,m+=3*u*d*r.y,m+=c*n.y,l=Math.min(e+c*b,s),this.drawArc(f,m,l,o);o.closePath(),o.fill()},e.prototype.bezierLength=function(e,t,o,i){var r,a,n,s,l,p,h,d,c=0;for(r=0;r<=10;r++)a=r/10,n=this.bezierPoint(a,o.x,e.x,t.x,i.x),s=this.bezierPoint(a,o.y,e.y,t.y,i.y),r>0&&(h=n-l,d=s-p,c+=Math.sqrt(h*h+d*d)),l=n,p=s;return c},e.prototype.bezierPoint=function(e,t,o,i,r){return t*(1-e)*(1-e)*(1-e)+3*o*(1-e)*(1-e)*e+3*i*(1-e)*e*e+r*e*e*e},e.prototype.drawArc=function(e,t,o,i){var r=this.parent.img;(e>r.destLeft&&t>r.destTop&&e<r.destLeft+r.destWidth&&t<r.destTop+r.destHeight||i!==this.lowerContext&&i!==this.upperContext)&&(i.moveTo(e,t),i.arc(e,t,o,0,2*Math.PI,!1))},e.prototype.freehandRedraw=function(e,t){var o=this.parent,i=e.filter;if(e.filter="none",t&&(o.pointColl[o.freehandCounter]={points:t,strokeColor:o.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,flipState:o.transform.currFlipState,id:"pen_"+(o.freehandCounter+1),order:o.objColl.length+o.freehandCounter+1},this.selPointColl[o.freehandCounter]=(0,g.extend)({},o.pointColl[o.freehandCounter],{},!0),o.freehandCounter++),o.freehandCounter>0){for(var r=0;r<o.freehandCounter;r++){o.points=(0,g.extend)([],o.pointColl[r].points),this.pointCounter=0;var a=o.points.length,n=void 0,s=void 0,l=void 0,p=void 0,h=void 0,d=void 0;a>0&&(e.fillStyle=o.pointColl[r].strokeColor,h=d=this.penStrokeWidth=o.pointColl[r].strokeWidth),1===a&&(n=s=l=p=o.points[0],this.startDraw(e,n,s,l,p,h,d));for(var c=0;c<a-3;c++)o.points[c+1]&&o.points[c+2]&&o.points[c+2]&&(n=this.calcCurveCP(o.points[c+0],o.points[c+1],o.points[c+2]).controlPoint2,s=this.calcCurveCP(o.points[c+1],o.points[c+2],o.points[c+3]).controlPoint1,l=0===c?o.points[c]:o.points[c+1],p=o.points[c+2],this.startDraw(e,n,s,l,p,h,d));e.closePath()}e===this.lowerContext&&(o.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:o.frameObj.type,preventImg:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height))}e.filter=i},e.prototype.getSqPtFD=function(e,t){var o={startX:0,startY:0,endX:0,endY:0,width:0,height:0},i=(0,g.extend)([],this.selPointColl[e].points,[]);this.parent.points=(0,g.extend)([],this.parent.pointColl[e].points),this.pointCounter=0;for(var r=i.length,a=0;a<r;a++)0===o.startX&&0===o.startY&&0===o.endX&&0===o.endY?(o.startX=i[a].x,o.startY=i[a].y,o.endX=i[a].x,o.endY=i[a].y):(o.startX=Math.min(o.startX,i[a].x),o.startY=Math.min(o.startY,i[a].y),o.endX=Math.max(o.endX,i[a].x),o.endY=Math.max(o.endY,i[a].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,t&&(t.activePoint=o),o},e.prototype.applyPenDraw=function(){var e=this.parent;"freehanddraw"===e.currObjType.shape&&(e.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),e.upperCanvas.style.cursor=e.cursor="default",e.currObjType.shape=""),e.notify("shape",{prop:"clearActObj"})},e.prototype.applyFhd=function(){var e=this.parent,t=e.pointColl[this.fhdSelIdx];"#42a5f5"===t.strokeColor&&(t.strokeColor=this.tempFHDStyles.strokeColor),e.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),t&&(t.isSelected=!1),e.notify("selection",{prop:"resetFreehandDrawVariables"}),this.fhdHovIdx=this.fhdSelIdx=null},e.prototype.cancelFhd=function(){var e=this.parent,t=e.pointColl[this.fhdSelIdx];e.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.lowerContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.pointCounter=0,t&&(t.strokeColor=this.tempFHDStyles.strokeColor,t.strokeWidth=this.tempFHDStyles.strokeWidth,t.isSelected=!1),this.fhdHovIdx=this.fhdSelIdx=this.fhdSelID=null,e.notify("selection",{prop:"resetFreehandDrawVariables"}),e.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor,e.activeObj.strokeSettings.strokeWidth=this.penStrokeWidth=this.tempFHDStyles.strokeWidth,this.tempFHDStyles={strokeColor:null,strokeWidth:null,fillColor:null},e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},e.prototype.selectFhd=function(e){var t=this.parent,o=(0,g.extend)({},this.tempFHDStyles,{},!0);if(t.notify("selection",{prop:"setFreehandDrawEditing",onPropertyChange:!1,value:{bool:!0}}),e||0===e){if(!this.isFHDIdx(e))return;this.fhdSelIdx=this.fhdHovIdx=e,this.hoverFhd(),t.upperCanvas.style.cursor=t.cursor="pointer"}this.fhdSelIdx=this.fhdHovIdx;var r=t.pointColl[this.fhdSelIdx];r.isSelected=!0,this.fhdSelID=r.id,"#42a5f5"!==r.strokeColor&&(t.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor=r.strokeColor),t.activeObj.strokeSettings.strokeWidth=this.tempFHDStyles.strokeWidth=t.pointColl[this.fhdHovIdx].strokeWidth;var a={bool:!1};if(t.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool){var n={id:"pen_"+(this.fhdSelIdx+1),type:i.FreehandDraw,startX:r.points[0].x,startY:r.points[0].y,strokeColor:r.strokeColor,strokeWidth:r.strokeWidth,points:r.points,opacity:r.opacity,index:r.order},s={cancel:!1,action:"select",previousShapeSettings:n,currentShapeSettings:n};this.triggerShapeChanging(s)}else t.okBtn(null,!0);t.isUndoRedoStack&&(this.tempFHDStyles=o)},e.prototype.deleteFhd=function(e,t){var o=this.parent;if(this.isFHDIdx(e)){this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);var i=(0,g.extend)({},o.pointColl,{},!0),r=(0,g.extend)({},this.selPointColl,{},!0);o.pointColl={},this.selPointColl={};for(var a=0,n=0;n<o.freehandCounter;n++)parseInt(i[n].id.split("_")[1],10)-1!==e&&(o.pointColl[a]=i[n],this.selPointColl[a]=r[n],a++);o.freehandCounter-=1,this.fhdHovIdx=this.fhdSelIdx=null,this.currFHDIdx--,o.notify("selection",{prop:"resetFreehandDrawVariables"}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},e.prototype.zoomX=function(e){return e*this.parent.img.destWidth+this.parent.img.destLeft},e.prototype.zoomY=function(e){return e*this.parent.img.destHeight+this.parent.img.destTop},e.prototype.zoomFHDColl=function(e){var t=this.parent,o={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};t.notify("shape",{prop:"straightenShapes",onPropertyChange:!1});for(var i=0;i<t.freehandCounter;i++){t.points=(0,g.extend)([],t.pointColl[i].points,[]),this.pointCounter=0;for(var r=t.points.length,a=0;a<r;a++){var n=t.points[a];n.x=this.zoomX(n.ratioX),n.y=this.zoomY(n.ratioY)}}this.updateFHDCurPts(),this.straightenPoint.x&&this.straightenPoint.y&&(this.straightenPoint.x=this.zoomX(this.straightenPoint.ratioX),this.straightenPoint.y=this.zoomY(this.straightenPoint.ratioY)),0!==t.transform.straighten&&t.notify("shape",{prop:"straightenFHD",onPropertyChange:!1}),t.img.destLeft=o.startX,t.img.destTop=o.startY,t.img.destWidth=o.width,t.img.destHeight=o.height,(0,g.isNullOrUndefined)(e)&&this.freehandRedraw(this.lowerContext,null)},e.prototype.updateFHDCurPts=function(){for(var e=this.parent,t=0;t<e.freehandCounter;t++)if(this.selPointColl[t]){this.selPoints=(0,g.extend)([],this.selPointColl[t].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,i=0;i<o;i++){var r=this.selPoints[i];r.x=this.zoomX(r.ratioX),r.y=this.zoomY(r.ratioY)}}},e.prototype.rotateFhdColl=function(){for(var e=this.parent,t=e.img,o=t.destLeft,i=t.destTop,r=t.destWidth,a=t.destHeight,n=0;n<e.freehandCounter;n++){e.points=(0,g.extend)([],e.pointColl[n].points,[]),this.pointCounter=0;for(var s=e.points.length,l=0;l<s;l++){(p=e.points[l]).y=i+a*p.ratioX,p.x=o+r-r*p.ratioY,p.ratioX=(p.x-o)/r,p.ratioY=(p.y-i)/a}}for(n=0;n<e.freehandCounter;n++)if(this.selPointColl[n]){this.selPoints=(0,g.extend)([],this.selPointColl[n].points,[]),this.pointCounter=0;for(s=this.selPoints.length,l=0;l<s;l++){var p;(p=this.selPoints[l]).y=i+a*p.ratioX,p.x=o+r-r*p.ratioY,p.ratioX=(p.x-o)/r,p.ratioY=(p.y-i)/a}}this.updateFHDCurPts()},e.prototype.flipFHDColl=function(e){var t=e.toLowerCase();if("horizontal"===t)this.pointsHorizontalFlip();else if("vertical"===t)this.pointsVerticalFlip();else{this.pointsHorizontalFlip();for(var o=0;o<this.parent.freehandCounter;o++)this.parent.pointColl[o].shapeFlip="";this.pointsVerticalFlip()}},e.prototype.pointsHorizontalFlip=function(){for(var e=this.parent,t=e.img,o=t.destLeft,i=t.destTop,r=t.destWidth,a=t.destHeight,n=0;n<e.freehandCounter;n++)if(e.pointColl[n].shapeFlip!==e.transform.currFlipState){e.points=(0,g.extend)([],e.pointColl[n].points,[]),this.pointCounter=0;for(var s=e.points.length,l=0;l<s;l++){(p=e.points[l]).x<=o+r/2?p.x=o+r-(p.x-o):p.x>=o+r/2&&(p.x=o+(o+r-p.x)),p.ratioX=(p.x-o)/r,p.ratioY=(p.y-i)/a}e.pointColl[n].shapeFlip=e.transform.currFlipState}for(n=0;n<e.freehandCounter;n++)if(this.selPointColl[n]&&this.selPointColl[n].shapeFlip!==e.transform.currFlipState){this.selPoints=(0,g.extend)([],this.selPointColl[n].points,[]),this.pointCounter=0;for(s=this.selPoints.length,l=0;l<s;l++){var p;(p=this.selPoints[l]).x<=o+r/2?p.x=o+r-(p.x-o):p.x>=o+r/2&&(p.x=o+(o+r-p.x)),p.ratioX=(p.x-o)/r,p.ratioY=(p.y-i)/a}}this.updateFHDCurPts()},e.prototype.pointsVerticalFlip=function(){for(var e=this.parent,t=e.img,o=t.destLeft,i=t.destTop,r=t.destWidth,a=t.destHeight,n=0;n<e.freehandCounter;n++)if(e.pointColl[n].shapeFlip!==e.transform.currFlipState){e.points=(0,g.extend)([],e.pointColl[n].points,[]),this.pointCounter=0;for(var s=e.points.length,l=0;l<s;l++){(p=e.points[l]).y<=i+a/2?p.y=i+a-(p.y-i):p.y>=i+a/2&&(p.y=i+(i+a-p.y)),p.ratioX=(p.x-o)/r,p.ratioY=(p.y-i)/a}e.pointColl[n].shapeFlip=e.transform.currFlipState}for(n=0;n<e.freehandCounter;n++)if(this.selPointColl[n]&&this.selPointColl[n].shapeFlip!==e.transform.currFlipState){this.selPoints=(0,g.extend)([],this.selPointColl[n].points,[]),this.pointCounter=0;for(s=this.selPoints.length,l=0;l<s;l++){var p;(p=this.selPoints[l]).y<=i+a/2?p.y=i+a-(p.y-i):p.y>=i+a/2&&(p.y=i+(i+a-p.y)),p.ratioX=(p.x-o)/r,p.ratioY=(p.y-i)/a}}this.updateFHDCurPts()},e.prototype.updateFHDColl=function(e){var t=this.parent,o={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};t.notify("shape",{prop:"straightenShapes",onPropertyChange:!1});for(var i=t.img,r=i.destLeft,a=i.destTop,n=i.destWidth,s=i.destHeight,l=0,p=t.objColl.length;l<p;l++){var h=t.objColl[l];if("line"===h.shape||"arrow"===h.shape)t.notify("shape",{prop:"straightenShapePoints",value:{obj:h,isReverse:!0}});else if("path"===h.shape){var d=t.transform.straighten;t.transform.straighten=-t.transform.straighten,t.notify("shape",{prop:"straightenPath",onPropertyChange:!1,value:{obj:h}}),t.transform.straighten=d}if(h.imageRatio={startX:(h.activePoint.startX-r)/n,startY:(h.activePoint.startY-a)/s,endX:(h.activePoint.endX-r)/n,endY:(h.activePoint.endY-a)/s,width:n/h.activePoint.width,height:s/h.activePoint.height},"path"===h.shape)for(var c=0,u=h.pointColl.length;c<u;c++)h.pointColl[c].ratioX=(h.pointColl[c].x-r)/n,h.pointColl[c].ratioY=(h.pointColl[c].y-a)/s;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})}if(t.freehandCounter>0&&0!==t.transform.straighten){d=t.transform.straighten;t.transform.straighten=-t.transform.straighten,t.notify("shape",{prop:"straightenFHD",onPropertyChange:!1}),t.transform.straighten=d}for(var v=0;v<t.freehandCounter;v++){t.points=(0,g.extend)([],t.pointColl[v].points,[]),this.pointCounter=0;for(var f=t.points.length,m=0;m<f;m++){(b=t.points[m]).ratioX=(b.x-r)/n,b.ratioY=(b.y-a)/s}}for(v=0;v<t.freehandCounter;v++)if(this.selPointColl[v]){this.selPoints=(0,g.extend)([],this.selPointColl[v].points,[]),this.pointCounter=0;for(f=this.selPoints.length,m=0;m<f;m++){var b;(b=this.selPoints[m]).ratioX=(b.x-r)/n,b.ratioY=(b.y-a)/s}}this.straightenPoint.x&&this.straightenPoint.y&&(this.straightenPoint.ratioX=(this.straightenPoint.x-r)/n,this.straightenPoint.ratioY=(this.straightenPoint.y-a)/s),t.img.destLeft=o.startX,t.img.destTop=o.startY,t.img.destWidth=o.width,t.img.destHeight=o.height,t.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:e}})},e.prototype.panFHDColl=function(e,t,o){for(var i=this.parent,r=0;r<i.freehandCounter;r++){i.points=(0,g.extend)([],i.pointColl[r].points,[]),this.pointCounter=0;for(var a=i.points.length,n=0;n<a;n++){var s=i.points[n];""===o||"vertical"===o?s.x+=e:s.x-=e,""===o||"horizontal"===o?s.y+=t:s.y-=t}}for(r=0;r<i.freehandCounter;r++)if(this.selPointColl[r]){this.selPoints=(0,g.extend)([],this.selPointColl[r].points,[]),this.pointCounter=0;for(a=this.selPoints.length,n=0;n<a;n++){s=this.selPoints[n];""===o||"vertical"===o?s.x+=e:s.x-=e,""===o||"horizontal"===o?s.y+=t:s.y-=t}}this.straightenPoint.x&&this.straightenPoint.y&&(""===o||"vertical"===o?this.straightenPoint.x+=e:this.straightenPoint.x-=e,""===o||"horizontal"===o?this.straightenPoint.y+=t:this.straightenPoint.y-=t),this.freehandRedraw(this.lowerContext,null)},e.prototype.freeHandDraw=function(e){var t=this.parent;if(e){if(t.points=[],this.dummyPoints=[],t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.togglePen=!0,t.upperCanvas.style.cursor=t.cursor="crosshair",t.upperCanvas.style.display="block",(0,g.isNullOrUndefined)(t.activeObj.strokeSettings)){var o={strokeSettings:{}};t.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:o}}),t.activeObj.strokeSettings=o.strokeSettings}(0,g.isNullOrUndefined)(t.activeObj.strokeSettings.strokeWidth)&&(t.activeObj.strokeSettings.strokeWidth=2),t.isMaskImage?t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}):t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}else{t.upperCanvas.style.cursor=t.cursor="default";var i=this.penStrokeWidth;t.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),t.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}),t.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}}),this.penStrokeWidth=i}},e.prototype.isFHDIdx=function(e,t){for(var o=!1,i=0;i<this.parent.freehandCounter;i++)if(this.parent.pointColl[i].id&&parseInt(this.parent.pointColl[i].id.split("_")[1],10)-1===e){o=!0;break}return t&&(t.isIndex=o),o},e.prototype.updateCropPtsForSel=function(){for(var e=this.parent,t=e.activeObj.activePoint,o=0;o<e.freehandCounter;o++){var i={selPointColl:(0,g.extend)([],this.selPointColl)};if(i.selPointColl[o]){this.selPoints=(0,g.extend)([],i.selPointColl[o].points,[]),this.pointCounter=0;for(var r=this.selPoints.length,a=0;a<r;a++){var n=this.selPoints[a];n.ratioX=(n.x-t.startX)/t.width,n.ratioY=(n.y-t.startY)/t.height}}}},e.prototype.triggerShapeChanging=function(e){var t=this.parent,o=t.pointColl[this.fhdSelIdx];if(t.trigger("shapeChanging",e),"mask-drawing"===t.element.getAttribute("data-value")&&!this.isMasking)return this.isMasking=!0,t.upperCanvas.style.cursor="crosshair",t.notify("draw",{prop:"updateTempObjColl"}),t.notify("draw",{prop:"updateTempPointColl"}),t.discard(),void t.selectMaskImage();if(t.editCompleteArgs=e,-1===e.currentShapeSettings.id.indexOf("pen_")&&("draw-end"===e.action||"select"===e.action)){var i="pen_"+e.currentShapeSettings.id;this.fhdSelIdx?t.pointColl[this.fhdSelIdx].id=i:t.pointColl[t.freehandCounter-1].id=i}this.penStrokeWidth=e.currentShapeSettings.strokeWidth,t.activeObj.strokeSettings.strokeColor!==e.currentShapeSettings.strokeColor&&(t.activeObj.strokeSettings.strokeColor=e.currentShapeSettings.strokeColor,t.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})),this.fhdSelID&&o&&e.currentShapeSettings&&(o.strokeColor=e.currentShapeSettings.strokeColor,o.strokeWidth=e.currentShapeSettings.strokeWidth,o.points=e.currentShapeSettings.points,o.opacity=e.currentShapeSettings.opacity),"select"===e.action&&(this.freehandRedraw(this.upperContext),t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))},e.prototype.setCenterSelPoints=function(){var e=this.parent,t={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};e.notify("shape",{prop:"straightenShapes",onPropertyChange:!1});var o=e.img,i=o.destLeft,r=o.destTop,a=o.destWidth,n=o.destHeight,s=e.activeObj.activePoint;((0,g.isNullOrUndefined)(this.prevStraightenObj)||JSON.stringify(this.prevStraightenObj.activePoint)!==JSON.stringify(s))&&(this.straightenPoint={x:s.startX+s.width/2,y:s.startY+s.height/2,ratioX:(s.startX+s.width/2-i)/a,ratioY:(s.startY+s.height/2-r)/n},this.prevStraightenObj=(0,g.extend)({},e.activeObj,{},!0),this.straightenPointAngle=e.transform.straighten),e.img.destLeft=t.startX,e.img.destTop=t.startY,e.img.destWidth=t.width,e.img.destHeight=t.height},e}(),z=function(){function e(e){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:[],order:null},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.isImageClarity=!0,this.isPinching=!1,this.isSliding=!1,this.mouseDown="",this.isSliderActive=!1,this.arrowShape=[p.None,p.SolidArrow],this.isTouchDblClick=!1,this.isMouseDown=!1,this.isMouseUp=!1,this.mouseWheel=0,this.isTransformedShape=!1,this.mouseClickPoint={x:0,y:0},this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("selection",this.selection,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("selection",this.selection),this.parent.off("destroyed",this.destroy)},e.prototype.selection=function(e){var t=this.parent;switch(this.updatePrivateVariables(),e.prop){case"setCursor":this.setCursor(e.value.x,e.value.y);break;case"updateActivePoint":this.updateActivePoint(e.value.x,e.value.y,e.value.isCropSelection);break;case"updateCursorStyles":this.updateCursorStyles(e.value.x,e.value.y,e.value.type);break;case"setTextSelection":this.setTextSelection(e.value.width,e.value.height);break;case"setActivePoint":this.setActivePoint(e.value.startX,e.value.startY);break;case"clearSelection":this.clearSelection(e.value.resetCrop);break;case"calcShapeRatio":this.calcShapeRatio(e.value.x,e.value.y,e.value.imgWidth,e.value.imgHeight);break;case"tab":this.performTabAction();break;case"setDragDirection":this.setDragDirection(e.value.width,e.value.height);break;case"clearUpperCanvas":this.isTouch&&setTimeout(function(){t.upperCanvas.getContext("2d").clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height)},550);break;case"resetFreehandDrawVariables":this.isFhdEditing=this.isFhdPoint=!1;break;case"isShapeInserted":this.isShapeInserted=e.value.bool;break;case"redrawShape":this.redrawShape(e.value.obj);break;case"setTextBoxStylesToActObj":this.setTextBoxStylesToActObj();break;case"mouseDownEventHandler":this.mouseDownEventHandler(e.value.e);break;case"mouseMoveEventHandler":this.mouseMoveEventHandler(e.value.e);break;case"mouseUpEventHandler":this.mouseUpEventHandler(e.value.e);break;case"canvasMouseDownHandler":this.canvasMouseDownHandler(e.value.e);break;case"canvasMouseMoveHandler":this.canvasMouseMoveHandler(e.value.e);break;case"canvasMouseUpHandler":this.canvasMouseUpHandler(e.value.e);break;case"touchStartHandler":this.touchStartHandler(e.value.e);break;case"keyDownEventHandler":this.keyDownEventHandler(e.value.e);break;case"handleScroll":this.handleScroll(e.value.e);break;case"textKeyDown":setTimeout(this.textKeyDown.bind(this),1,e.value.e);break;case"deleteItem":this.deleteItem();break;case"updatePrevShapeSettings":this.updatePrevShapeSettings(e.value.obj);break;case"getZoomType":e.value.obj.zoomType=this.zoomType;break;case"setZoomType":this.zoomType=e.value.zoomType;break;case"setInitialTextEdit":this.isInitialTextEdited=e.value.bool;break;case"setDragCanvas":this.dragCanvas=e.value.bool;break;case"setFreehandDrawCustomized":this.isFhdCustomized=e.value.isFreehandDrawCustomized;break;case"setTouchEndPoint":this.touchEndPoint.x=e.value.x,this.touchEndPoint.y=e.value.y;break;case"getPanDown":e.value.obj.panDown=this.panDown;break;case"setPanDown":this.panDown=e.value.panDown;break;case"getFreehandDrawEditing":e.value.obj.bool=this.isFhdEditing;break;case"setFreehandDrawEditing":this.isFhdEditing=e.value.bool;break;case"getTempActObj":e.value.obj.tempObj=this.tempActiveObj;break;case"setTempActObj":this.tempActiveObj=e.value.obj;break;case"isInside":this.isInside(e.value.x,e.value.y,e.value.z1,e.value.z2,e.value.z3,e.value.z4);break;case"setDragElement":this.dragElement=e.value.value;break;case"setObjSelected":this.isObjSelected=e.value.bool;break;case"adjustActObjForLineArrow":this.adjustActObjForLineArrow(e.value.obj);break;case"findTarget":this.findTarget(e.value.x,e.value.y,e.value.type);break;case"getCurrentFlipState":this.getCurrentFlipState();break;case"setDragWidth":this.setDragWidth(e.value.width);break;case"setDragHeight":this.setDragHeight(e.value.setDragHeight);break;case"annotate":this.currentDrawingShape=e.value.shape,"text"===e.value.shape?(t.activeObj.textSettings.fontSize=11,t.activeObj.keyHistory="Enter Text",t.notify("shape",{prop:"initializeTextShape",onPropertyChange:!1,value:{text:null,fontFamily:null,fontSize:null,bold:null,italic:null,underline:null,strikethrough:null,strokeColor:null}})):"path"===e.value.shape&&(t.activeObj.pointColl=[]);break;case"getCurrentDrawingShape":e.value.obj.shape=this.currentDrawingShape;break;case"setCurrentDrawingShape":this.currentDrawingShape=e.value.value;break;case"getTransRotationPoint":this.getTransRotationPoint(e.value.obj,e.value.object);break;case"adjustNEPoints":this.adjustNEPoints(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"adjustRotationPoints":this.adjustRotationPoints(e.value.rectangle,e.value.x,e.value.y,e.value.angle,e.value.type,e.value.elem);break;case"getResizeDirection":this.getResizeDirection(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"setResizedElement":this.resizedElement=e.value.value;break;case"reset":this.reset();break;case"unWireEvent":this.unwireEvent();break;case"updPtCollForShpRot":this.updPtCollForShpRot(e.value.obj);break;case"findImageRatio":this.findImageRatio(e.value.width,e.value.height,e.value.obj);break;case"getNumTextValue":this.getNumTextValue(e.value.obj);break;case"setImageClarity":this.isImageClarity=e.value.bool;break;case"upgradeImageQuality":this.upgradeImageQuality();break;case"triggerShapeChange":this.triggerShapeChange(e.value.shapeResizingArgs,e.value.shapeMovingArgs,e.value.type);break;case"applyTransformToImg":this.applyTransformToImg(e.value.ctx);break;case"findTargetObj":e.value.obj.bool=this.findTargetObj(e.value.x,e.value.y,e.value.isCrop);break;case"setSliding":this.isSliding=e.value.bool;break;case"setSliderActive":this.isSliderActive=e.value.bool;break;case"getArrowType":e.value.obj.type=this.getArrowType(e.value.type);break;case"setArrowShape":"initial"===e.value.type?this.arrowShape[0]=e.value.shape:this.arrowShape[1]=e.value.shape;break;case"updateNWPoints":this.updateNWPoints(e.value.x,e.value.y);break;case"updateNPoints":this.updateNPoints(e.value.x,e.value.y);break;case"updateNEPoints":this.updateNEPoints(e.value.x,e.value.y);break;case"updateWPoints":this.updateWPoints(e.value.x,e.value.y);break;case"updateEPoints":this.updateEPoints(e.value.x,e.value.y);break;case"updateSWPoints":this.updateSWPoints(e.value.x,e.value.y);break;case"updateSPoints":this.updateSPoints(e.value.x,e.value.y);break;case"updateSEPoints":this.updateSEPoints(e.value.x,e.value.y);break;case"drawMaskCircle":this.drawMaskCircle(e.value.x,e.value.y);break;case"isValueUpdated":this.isValueUpdated();break;case"getDistance":this.getDistance(e.value.x,e.value.y);break;case"redact":this.currentDrawingShape=e.value.shape;break;case"updateTransColl":e.value.obj.coll=this.updateTransColl(e.value.object);break;case"getTransformedShape":e.value.obj.bool=this.isTransformedShape;break;case"setTransformedShape":this.isTransformedShape=e.value.bool;break;case"rgbToHex":this.rgbToHex(e.value.r,e.value.g,e.value.b,e.value.a);break;case"padLeft":this.padLeft(e.value.value,e.value.length,e.value.padChar);break;case"setTimer":this.setTimer(e.value.e);break;case"targetTouches":e.value.output=this.targetTouches(e.value.touches);break;case"calculateScale":e.value.output=this.calculateScale(e.value.startTouches,e.value.endTouches);break;case"beforeSaveEvent":this.beforeSaveEvent(e.value.args,e.value.e);break;case"isKeyBoardCrop":e.value.output=this.isKeyBoardCrop(e.value.e);break;case"focusRatioBtn":this.focusRatioBtn();break;case"performEnterAction":this.performEnterAction(e.value.e);break;case"getImagePoints":e.value.output=this.getImagePoints(e.value.x,e.value.y);break;case"revertPoints":this.revertPoints(e.value.actPoint,e.value.tempActiveObj);break;case"performNWResize":this.performNWResize(e.value.x,e.value.y,e.value.tempActiveObj,e.value.actPoint);break;case"performSEResize":this.performSEResize(e.value.x,e.value.y,e.value.tempActiveObj,e.value.actPoint);break;case"isMouseOutsideImg":e.value.output=this.isMouseOutsideImg(e.value.x,e.value.y)}},e.prototype.getModuleName=function(){return"selection"},e.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},e.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:[],order:null},this.isFirstMove=!1,this.cursorTargetId=this.dragElement="",this.isTouchDblClick=!1,this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.isPreventDragging=!1,this.timer=void 0,this.tempObjColl=void 0,this.mouseWheel=0,this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=this.isPinching=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.panDown=null,this.isSliding=!1,this.isFhdEditing=!1,this.pathAdjustedIndex=null,this.touchTime=0,this.isImageClarity=!0,this.currentDrawingShape="",this.initialPrevObj={},this.resizedElement="",this.mouseDown="",this.isSliderActive=!1,this.arrowShape=[p.None,p.SolidArrow],this.isMouseDown=this.isMouseUp=this.isTransformedShape=!1,this.mouseClickPoint={x:0,y:0}},e.prototype.performTabAction=function(){var e=this.parent;if("block"===e.textArea.style.display||"inline-block"===e.textArea.style.display){var t=this.applyCurrShape(!1);e.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t&&e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}e.isKBDNavigation=!0},e.prototype.selMouseUpEvent=function(){this.oldPoint.x=void 0,this.oldPoint.y=void 0},e.prototype.getMouseCursor=function(e,t,o,i,r){var a=this.getTransRotationPoint(e),n=e.bottomCenterCircle.radius,s=r?0:2*e.topLeftCircle.radius;return t>=e.topLeftCircle.startX-s&&t<=e.topLeftCircle.startX+s&&o>=e.topLeftCircle.startY-s&&o<=e.topLeftCircle.startY+s?"nw-resize":t>=e.topLeftCircle.startX-s&&t<=e.topRightCircle.startX-s&&o>=e.topCenterCircle.startY-s&&o<=e.topCenterCircle.startY+s?"n-resize":t>=e.topRightCircle.startX-s&&t<=e.topRightCircle.startX+s&&o>=e.topRightCircle.startY-s&&o<=e.topRightCircle.startY+s?"ne-resize":t>=e.centerLeftCircle.startX-s&&t<=e.centerLeftCircle.startX+s&&o>=e.topLeftCircle.startY-s&&o<=e.bottomLeftCircle.startY-s?"w-resize":t>=e.centerRightCircle.startX-s&&t<=e.centerRightCircle.startX+s&&o>=e.topRightCircle.startY-s&&o<=e.bottomRightCircle.startY-s?"e-resize":t>=e.bottomLeftCircle.startX-s&&t<=e.bottomLeftCircle.startX+s&&o>=e.bottomLeftCircle.startY-s&&o<=e.bottomLeftCircle.startY+s?"sw-resize":t>=e.bottomLeftCircle.startX-s&&t<=e.bottomRightCircle.startX-s&&o>=e.bottomCenterCircle.startY-s&&o<=e.bottomCenterCircle.startY+s?"s-resize":t>=e.bottomRightCircle.startX-s&&t<=e.bottomRightCircle.startX+s&&o>=e.bottomRightCircle.startY-s&&o<=e.bottomRightCircle.startY+s?"se-resize":t>=e.activePoint.startX&&t<=e.activePoint.endX&&o>=e.activePoint.startY&&o<=e.activePoint.endY?i?"grab":"move":a&&!r&&t>=a.x-(n+2)&&t<=a.x+(n+2)&&o>=a.y-(n+2)&&o<=a.y+(n+2)?"grabbing":"default"},e.prototype.setCursor=function(e,t){var o=this.parent;o.upperCanvas.style.cursor=o.cursor="default";var i={bool:null};if(o.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:i}}),o.isResize||this.isSliding||i.bool)o.upperCanvas.style.cursor="default";else{var r,a=!1;if(o.activeObj.shape&&(r=o.activeObj.shape.split("-")),(!r&&o.currObjType.isCustomCrop||r&&"crop"===r[0])&&(a=!0),o.currObjType.isDragging)""===this.dragElement?o.upperCanvas.style.cursor=o.cursor="move":o.upperCanvas.style.cursor=o.cursor=this.dragElement;else{if(o.togglePen)return o.upperCanvas.style.cursor=o.cursor="crosshair",void(o.isMaskImage&&(this.drawMaskCircle(e,t),o.upperCanvas.style.cursor="none"));if(o.activeObj.shape&&this.setCursorForActObj(r,a,e,t),"default"===o.cursor||"grab"===o.cursor){for(var n=this.getHighestOrder(),s=(0,g.extend)([],o.shapeColl,[],!0),l=(0,g.extend)([],o.objColl,[],!0),p=!1;n>0;){p=!1;for(var h=s.length-1;h>=0;h--)if(s[h].order===n)if(p=!0,s[h].id&&s[h].id.indexOf("pen")>-1){if(o.pointColl[0]&&("grab"!==o.cursor||!a)&&!o.currObjType.isDragging&&!o.currObjType.isResize){var d=(0,g.extend)([],o.points,[],!0);a||this.setCursorForFreehandDrawing(e,t,o.upperCanvas,s[h].id),o.points=d}}else{o.objColl=[],o.objColl.push((0,g.extend)({},s[h],null,!0));var c=o.upperCanvas.style.cursor;o.objColl.length>0&&("grab"!==o.cursor||!a)&&this.setCursorFromObj(e,t,o.objColl,o.upperCanvas,a),"grab"===c&&"default"===o.cursor&&(o.upperCanvas.style.cursor=o.cursor="grab")}else(0,g.isNullOrUndefined)(s[h].order)&&(p=!0);if("default"!==o.cursor&&"grab"!==o.cursor)break;if(p)for(var u=!1;!u&&n>0;){for(var v=0;v<s.length;v++)if(s[v].order===n-1){u=!0;break}n--,u||n--}}o.objColl=l,"default"!==o.cursor&&"grab"!==o.cursor||o.togglePan&&(o.lowerCanvas.style.cursor=o.upperCanvas.style.cursor=o.cursor="grab")}""===this.currentDrawingShape||"default"!==o.cursor&&"grab"!==o.cursor||(o.upperCanvas.style.cursor=o.cursor="crosshair")}}},e.prototype.getHighestOrder=function(){for(var e=0,t=0;t<this.parent.shapeColl.length;t++)this.parent.shapeColl[t].order>e&&(e=this.parent.shapeColl[t].order);return e},e.prototype.drawMaskCircle=function(e,t){var o=this.parent;if(o.isMaskImage){var i=2*o.activeObj.strokeSettings.strokeWidth,r=o.maskCanvas.getContext("2d");r.clearRect(0,0,o.maskCanvas.width,o.maskCanvas.height),r.fillStyle=o.activeObj.strokeSettings.strokeColor,r.strokeStyle="#fff",r.beginPath(),r.ellipse(e,t,i/2,i/2,0,0,2*Math.PI,!1),r.fill(),r.stroke(),r.closePath(),o.maskCanvas.style.cursor="none"}},e.prototype.setCursorForActObj=function(e,t,o,i){var r=this.parent;if(void 0!==r.activeObj.horTopLine){void 0!==r.activeObj.shape&&(e=r.activeObj.shape.split("-")),(void 0===e&&r.currObjType.isCustomCrop||void 0!==e&&"crop"===e[0])&&(t=!0),!t&&r.togglePan&&(r.lowerCanvas.style.cursor=r.upperCanvas.style.cursor=r.cursor="grab");var a=r.upperCanvas.style.cursor,n=(0,g.extend)({},r.activeObj,{},!0);this.cursorTargetId=n.currIndex;var s=void 0;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),"line"===n.shape||"arrow"===n.shape)this.setCursorForLineArrow(n,o,i,r.upperCanvas);else if("path"===n.shape)this.setCursorForPath(n,o,i,r.upperCanvas);else if((0,g.isNullOrUndefined)(n.rotatedAngle)||0===n.rotatedAngle){r.upperCanvas.style.cursor=r.cursor=this.getMouseCursor(n,o,i,t,!1);"text"===n.shape&&["n-resize","s-resize","e-resize","w-resize"].indexOf(r.cursor)>-1&&(r.upperCanvas.style.cursor=r.cursor="move")}else this.setCursorForRotatedObject(n,o,i,r.upperCanvas);"default"===a&&"default"===r.cursor&&t&&(r.upperCanvas.style.cursor=r.cursor="grab"),"grab"===a&&"default"===r.cursor&&(r.upperCanvas.style.cursor=r.cursor="grab")}else r.togglePan&&!r.togglePen?r.lowerCanvas.style.cursor=r.upperCanvas.style.cursor=r.cursor="grab":r.currObjType.isCustomCrop||r.togglePen?r.upperCanvas.style.cursor=r.cursor="crosshair":r.upperCanvas.style.cursor=r.cursor="default"},e.prototype.setCursorForPath=function(e,t,o,i){this.setCursorForLineArrow(e,t,o,i);var r=this.parent;if("default"===r.cursor)for(var a=(0,g.extend)({},e,null,!0),n=!1,s=1,l=e.pointColl.length;s<l&&!n;s++){a.activePoint.startX=e.pointColl[s-1].x,a.activePoint.startY=e.pointColl[s-1].y,a.activePoint.endX=e.pointColl[s].x,a.activePoint.endY=e.pointColl[s].y,r.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:a}});for(var p=e.topLeftCircle.radius,h=0,d=a.pointColl.length;h<d;h++){var c=a.pointColl[h];if(!(0,g.isNullOrUndefined)(c.x-2*p)&&!(0,g.isNullOrUndefined)(c.x+2*p)&&!(0,g.isNullOrUndefined)(c.y-2*p)&&!(0,g.isNullOrUndefined)(c.y+2*p)&&t>=c.x-2*p&&t<=c.x+2*p&&o>=c.y-2*p&&o<=c.y+2*p){i.style.cursor=r.cursor="move",n=!0;break}i.style.cursor=r.cursor="default"}}return r.cursor},e.prototype.setCursorForLineArrow=function(e,t,o,i){var r,a=e.topLeftCircle.radius;if((0,g.isNullOrUndefined)(e.pointColl))return r;for(var n=0,s=e.pointColl.length;n<s;n++){var l=e.pointColl[n];if(t>=l.x-2*a&&t<=l.x+2*a&&o>=l.y-2*a&&o<=l.y+2*a){i.style.cursor=this.parent.cursor="move",r=n;break}i.style.cursor=this.parent.cursor="default"}return r},e.prototype.setCursorForRotatedObject=function(e,t,o,i){this.resizedElement="";var r=this.parent,a=e.bottomCenterCircle.radius,n=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)],s=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)],l=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)],p=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)],h=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)],d=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)],c=e.rotationCirclePointColl,u=e.horTopLinePointColl[0],g=e.horBottomLinePointColl[0];if(t>=u.x-(a+2)&&t<=u.x+(a+2)&&o>=u.y-(a+2)&&o<=u.y+(a+2))i.style.cursor=r.cursor="nw-resize";else if(t>=n.x-5&&t<=n.x+5&&o>=n.y-5&&o<=n.y+5)i.style.cursor=r.cursor=this.resizedElement="n-resize";else if(t>=s.x-(a+2)&&t<=s.x+(a+2)&&o>=s.y-(a+2)&&o<=s.y+(a+2))i.style.cursor=r.cursor="ne-resize";else if(t>=l.x-5&&t<=l.x+5&&o>=l.y-5&&o<=l.y+5)i.style.cursor=r.cursor=this.resizedElement="w-resize";else if(t>=p.x-5&&t<=p.x+5&&o>=p.y-5&&o<=p.y+5)i.style.cursor=r.cursor=this.resizedElement="e-resize";else if(t>=g.x-(a+2)&&t<=g.x+(a+2)&&o>=g.y-(a+2)&&o<=g.y+(a+2))i.style.cursor=r.cursor="sw-resize";else if(t>=h.x-5&&t<=h.x+5&&o>=h.y-5&&o<=h.y+5)i.style.cursor=r.cursor=this.resizedElement="s-resize";else if(t>=d.x-(a+2)&&t<=d.x+(a+2)&&o>=d.y-(a+2)&&o<=d.y+(a+2))i.style.cursor=r.cursor="se-resize";else if(c&&t>=c.x-(a+2)&&t<=c.x+(a+2)&&o>=c.y-(a+2)&&o<=c.y+(a+2))i.style.cursor=r.cursor="grabbing";else{i.style.cursor=r.cursor="default",this.getRectanglePoints(e.activePoint.startX,e.activePoint.startY,e.activePoint.width,e.activePoint.height,e.rotatedAngle*(180/Math.PI),t,o)&&(i.style.cursor=r.cursor="move")}if("default"===r.cursor)for(var v=0,f=e.horTopLinePointColl.length;v<f;v++){var m=e.horTopLinePointColl[v];if(t>=m.x-5&&t<=m.x+5&&o>=m.y-5&&o<=m.y+5){i.style.cursor=r.cursor=this.resizedElement="n-resize";break}}if("default"===r.cursor)for(v=0,f=e.horBottomLinePointColl.length;v<f;v++){var b=e.horBottomLinePointColl[v];if(t>=b.x-5&&t<=b.x+5&&o>=b.y-5&&o<=b.y+5){i.style.cursor=r.cursor=this.resizedElement="s-resize";break}}if("default"===r.cursor)for(v=0,f=e.verLeftLinePointColl.length;v<f;v++){var C=e.verLeftLinePointColl[v];if(t>=C.x-5&&t<=C.x+5&&o>=C.y-5&&o<=C.y+5){i.style.cursor=r.cursor=this.resizedElement="w-resize";break}}if("default"===r.cursor)for(v=0,f=e.verRightLinePointColl.length;v<f;v++){var y=e.verRightLinePointColl[v];if(t>=y.x-5&&t<=y.x+5&&o>=y.y-5&&o<=y.y+5){i.style.cursor=r.cursor=this.resizedElement="e-resize";break}}return this.adjustCursorStylesForRotatedState(e),r.cursor},e.prototype.adjustCursorStylesForRotatedState=function(e){var t=this.parent,o=e.rotatedAngle*(180/Math.PI);if((o=o>0?Math.floor(o):Math.ceil(o))>=92&&o<=182||o>=-178&&o<=-88){var i={"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"};t.cursor in i&&(t.cursor=i[t.cursor])}return t.upperCanvas.style.cursor=this.getResizeElement(e.rotatedAngle*(180/Math.PI),t.cursor),t.cursor},e.prototype.getResizeElement=function(e,t){var o=[];switch(t){case"nw-resize":o=[[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"]];break;case"n-resize":o=[[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"]];break;case"ne-resize":o=[[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"]];break;case"e-resize":o=[[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"]];break;case"se-resize":o=[[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"]];break;case"s-resize":o=[[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"]];break;case"sw-resize":o=[[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"]];break;case"w-resize":o=[[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 i=e<0?360-Math.abs(e):e,r=0,a=o;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(i>s&&i<=l||i+360>s&&i+360<=l)return p}return t},e.prototype.setCursorForFreehandDrawing=function(e,t,o,i){var r,a=o.getContext("2d"),n=this.parent,s=document.querySelector("#"+n.element.id+"_textArea"),l=!1;n.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:-1}});for(var p=0;p<n.freehandCounter;p++)if(!i||i===n.pointColl[p].id){var h={selPointColl:{}};n.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),r=(0,g.extend)([],h.selPointColl[p].points,[]),n.points=(0,g.extend)([],n.pointColl[p].points,[]);var d=n.pointColl[p];n.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var c=r.length,u=0;u<c;u++)if(0!==u){var v=!1;if(r[u-1]&&r[u]&&(v=this.isInside(e,t,r[u-1].x,r[u-1].y,r[u].x,r[u].y)),v){this.isFhdPoint=!0,n.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),n.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=n.cursor="pointer",l=!0;break}if(!this.isFhdEditing||d.isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(a.clearRect(0,0,o.width,o.height),n.activeObj.shape&&"none"===s.style.display&&n.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:n.activeObj}})),this.isFhdEditing){var f={freehandSelectedIndex:-1};n.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:f}});var m=n.pointColl[f.freehandSelectedIndex].strokeColor,b=n.pointColl[f.freehandSelectedIndex].strokeWidth;n.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:m,strokeWidth:b}})}else n.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:null}});this.isFhdPoint=!1}}else{var C=n.points[u];if(e>C.x-d.strokeWidth&&e<C.x+d.strokeWidth&&t>C.y-d.strokeWidth&&t<C.y+d.strokeWidth){this.isFhdPoint=!0,n.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),n.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=n.cursor="pointer",l=!0;break}if(!this.isFhdEditing||d.isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(a.clearRect(0,0,o.width,o.height),n.activeObj.shape&&"none"===s.style.display&&n.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:n.activeObj}})),this.isFhdEditing){f={freehandSelectedIndex:-1};n.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:f}});m=n.pointColl[f.freehandSelectedIndex].strokeColor,b=n.pointColl[f.freehandSelectedIndex].strokeWidth;n.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:m,strokeWidth:b}})}this.isFhdPoint=!1}}if(l)break}},e.prototype.setCursorFromObj=function(e,t,o,i,r){for(var a=this.parent,n=0,s=o.length;n<s;n++){if("move"===a.cursor)return;var l=(0,g.extend)({},o[n],{},!0);if(0===l.activePoint.width&&0===l.activePoint.height)return void o.splice(n,1);this.cursorTargetId=l.currIndex,"line"===l.shape||"arrow"===l.shape?this.setCursorForLineArrow(l,e,t,i):"path"===l.shape?this.setCursorForPath(l,e,t,i):(0,g.isNullOrUndefined)(l.rotatedAngle)||0===l.rotatedAngle?i.style.cursor=a.cursor=this.getMouseCursor(l,e,t,r,!0):this.setCursorForRotatedObject(l,e,t,i)}},e.prototype.isInside=function(e,t,o,i,r,a){var n=Math.min(o,r),s=Math.max(o,r),l=Math.min(i,a),p=Math.max(i,a);return n<=e&&e<=s&&l<=t&&t<=p},e.prototype.preventResizing=function(e){var t=this.parent;if(t.activeObj.preventShapeDragOut&&this.isShapeDragOut()){var o=t.activeObj.activePoint;o.startX=e.activePoint.startX,o.startY=e.activePoint.startY,o.endX=e.activePoint.endX,o.endY=e.activePoint.endY,o.width=e.activePoint.width,o.height=e.activePoint.height,t.activeObj.rotatedAngle=e.rotatedAngle,t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:o,obj:t.activeObj,isMouseMove:null,x:null,y:null}})}},e.prototype.updateActivePoint=function(e,t,o){var i=this.parent,r=i.activeObj.activePoint,a=r.startX,n=r.startY,s=i.activeObj.activePoint,l=s.width,p=s.height;i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:l,height:p,obj:{width:0,height:0},isImgShape:null}});var h,d=this.updatePrevShapeSettings(),c={cancel:!1,action:"resize",previousShapeSettings:d,allowShapeOverflow:this.allowOutofBound()},u={cancel:!1,action:"move",previousShapeSettings:d,allowShapeOverflow:this.allowOutofBound()};if(this.shapeResizingArgs=c,this.shapeMovingArgs=u,"text"===i.activeObj.shape&&""!==this.dragElement&&i.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:i.activeObj,isTextArea:null}}),""!==this.currentDrawingShape&&(""===this.dragElement||"move"===this.dragElement)&&i.isShapeDrawing){["line","arrow","path"].indexOf(i.activeObj.shape)>-1?this.dragElement="e-resize":e>a&&t>n?this.dragElement="se-resize":e<a&&t>n?this.dragElement="sw-resize":e>a&&t<n?this.dragElement="ne-resize":e<a&&t<n&&(this.dragElement="nw-resize")}"arrow"===i.activeObj.shape&&(Math.atan2(e-i.lowerCanvas.width/2,t-i.lowerCanvas.height/2)>0?i.activeObj.rotatedAngle=-Math.atan2(e-i.lowerCanvas.width/2,t-i.lowerCanvas.height/2):i.activeObj.rotatedAngle=Math.abs(Math.atan2(e-i.lowerCanvas.width/2,t-i.lowerCanvas.height/2)));var v=!1,f=!1;if(!o||0===i.transform.straighten||!this.isMouseOutsideImg(e,t)){var m,b,C=(0,g.extend)({},i.activeObj,{},!0);switch(void 0!==i.activeObj.shape&&(m=i.activeObj.shape.split("-")),void 0!==m&&"crop"===m[0]&&(b=!0),this.dragElement.toLowerCase()){case"nw-resize":this.updateNWPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"n-resize":this.updateNPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"ne-resize":this.updateNEPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"w-resize":this.updateWPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"e-resize":this.updateEPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"sw-resize":this.updateSWPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"s-resize":this.updateSPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"se-resize":this.updateSEPoints(e,t),this.preventResizing(C),i.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:i.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(c,u,"resize");break;case"grabbing":Math.atan2(e-(a+l/2),t-(n+p/2))>0?i.activeObj.rotatedAngle=-Math.atan2(e-(a+l/2),t-(n+p/2)):i.activeObj.rotatedAngle=Math.abs(Math.atan2(e-(a+l/2),t-(n+p/2))),(h=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(h=360+h);for(var y=0,x=i.activeObj.flipObjColl.length;y<x;y++)"horizontal"===i.activeObj.flipObjColl[y].toLowerCase()?v=!0:"vertical"===i.activeObj.flipObjColl[y].toLowerCase()&&(f=!0);i.activeObj.rotatedAngle-=h*(Math.PI/180),0===h||360===h?f&&(i.activeObj.rotatedAngle-=Math.PI/180*180):90===h||-270===h?v&&(i.activeObj.rotatedAngle-=Math.PI/180*180):180===h||-180===h?f&&(i.activeObj.rotatedAngle-=Math.PI/180*180):270!==h&&-90!==h||v&&(i.activeObj.rotatedAngle-=Math.PI/180*180),this.preventResizing(C);break;case"pathdrag":(0,g.isNullOrUndefined)(this.pathAdjustedIndex)||(i.activeObj.pointColl[this.pathAdjustedIndex].x=e,i.activeObj.pointColl[this.pathAdjustedIndex].y=t);break;default:if(!o&&!i.currObjType.isCustomCrop){var P=i.activeObj.activePoint;if(this.dragPoint.startX){var w=this.dragPoint.endX-this.previousPoint.x,j=this.dragPoint.endY-this.previousPoint.y;if(P.startX+=w,P.endX+=w,P.startY+=j,P.endY+=j,a=P.startX,n=P.startY,"line"!==i.activeObj.shape&&"arrow"!==i.activeObj.shape&&i.activeObj.rotationCirclePointColl&&(i.activeObj.rotationCirclePointColl.x+=w,i.activeObj.rotationCirclePointColl.y+=j,i.activeObj.rotationCirclePoint.x+=w,i.activeObj.rotationCirclePoint.y+=j),"path"===i.activeObj.shape)for(y=0,x=i.activeObj.pointColl.length;y<x;y++)i.activeObj.pointColl[y].x+=w,i.activeObj.pointColl[y].y+=j;if(!this.isPreventDragging&&this.isShapeDragOut()&&(i.activeObj.preventShapeDragOut||"redact"===i.activeObj.shape||b)){if(P.startX-=w,P.endX-=w,P.startY-=j,P.endY-=j,"line"!==i.activeObj.shape&&"arrow"!==i.activeObj.shape&&i.activeObj.rotationCirclePointColl)i.activeObj.rotationCirclePointColl.x-=w,i.activeObj.rotationCirclePointColl.y-=j,i.activeObj.rotationCirclePoint.x-=w,i.activeObj.rotationCirclePoint.y-=j;else if("path"===i.activeObj.shape){var S=0;for(x=i.activeObj.pointColl.length;S<x;S++)i.activeObj.pointColl[S].x-=w,i.activeObj.pointColl[S].y-=j}if(0===i.activeObj.rotatedAngle){var O=i.activeObj.activePoint.endX,T=i.activeObj.activePoint.endY;"path"===i.activeObj.shape&&(i.activeObj.activePoint=i.getSquarePointForPath(i.activeObj)),this.setDragWidth(w),this.setDragHeight(j);var k=i.activeObj,F=k.activePoint.endX-O,I=k.activePoint.endY-T;if("path"===k.shape)for(S=0,x=k.pointColl.length;S<x;S++)k.pointColl[S].x+=F,k.pointColl[S].y+=I}else i.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:i.activeObj}})}}else P.startX=e<this.mouseDownPoint.x?e:this.mouseDownPoint.x,P.startY=t<this.mouseDownPoint.y?t:this.mouseDownPoint.y,e=e<this.mouseDownPoint.x?this.mouseDownPoint.x:e,t=t<this.mouseDownPoint.y?this.mouseDownPoint.y:t,P.endX=e,P.endY=t;this.triggerShapeChange(c,u,"move")}}}},e.prototype.isShapeDragOut=function(){var e=this.parent,t=!1,o=!1,i=e.activeObj.shape;if((e.activeObj.preventShapeDragOut||0===e.activeObj.rotatedAngle&&"line"!==i&&"arrow"!==i&&"path"!==i)&&(o=!0),o){var r=e.activeObj.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY;if("path"===i){var p=e.getSquarePointForPath(e.activeObj);a=p.startX,n=p.startY,s=p.endX,l=p.endY}if(0===e.activeObj.rotatedAngle||"arrow"===i)t=this.isObjOutsideImg(a,n,s,l,i);else{var h={isIntersect:null,arr:null};e.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),e.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:h}}),t=!!(h.arr[0]||h.arr[1]||h.arr[2]||h.arr[3])||this.isObjOutsideImg(a,n,s,l,i)}}return t},e.prototype.isObjOutsideImg=function(e,t,o,i,r){var a=this.parent.img,n=a.destLeft,s=a.destTop,l=a.destWidth,p=a.destHeight;return e<n||t<s||o>n+l||i>s+p||("line"===r||"arrow"===r)&&(e>n+l||t>s+p||o<n||i<s)},e.prototype.triggerShapeChange=function(e,t,o){var i=this.parent,r=i.activeObj.activePoint;r.width=r.endX-r.startX,r.height=r.endY-r.startY;var a=this.updatePrevShapeSettings();if((0,g.isNullOrUndefined)(this.shapeResizingArgs)||(0,g.isNullOrUndefined)(this.shapeMovingArgs)?(e.currentShapeSettings=a,t.currentShapeSettings=a):(e.currentShapeSettings=this.shapeResizingArgs.currentShapeSettings=a,t.currentShapeSettings=this.shapeMovingArgs.currentShapeSettings=a),"resize"===o){this.isCropSelection=!1;var n=void 0;if(void 0!==i.activeObj.shape&&(n=i.activeObj.shape.split("-")),void 0!==n&&"crop"===n[0]&&(this.isCropSelection=!0),this.isCropSelection){this.isMouseDown?e.action="resize-start":this.isMouseUp&&(e.action="resize-end");var s={action:e.action,previousSelectionSettings:{type:i.getSelectionType(i.activeObj.shape),startX:e.previousShapeSettings.startX,startY:e.previousShapeSettings.startY,width:e.previousShapeSettings.width,height:e.previousShapeSettings.height},currentSelectionSettings:{type:i.getSelectionType(i.activeObj.shape),startX:e.currentShapeSettings.startX,startY:e.currentShapeSettings.startY,width:e.currentShapeSettings.width,height:e.currentShapeSettings.height}};this.selectionResizingArgs=s,i.trigger("selectionChanging",s),i.editCompleteArgs=s,i.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}})}else""!==this.currentDrawingShape&&"crosshair"===i.upperCanvas.style.cursor&&(e.action="drawing"),i.currObjType.isRedact&&"redact"===i.activeObj.shape||i.trigger("shapeChanging",e),i.editCompleteArgs=e,this.isPreventShaping=e.cancel,i.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings,allowShapeOverflow:e.allowShapeOverflow}})}else"mouse-down"===o||"mouse-up"===o?("redact"!==i.activeObj.shape&&i.trigger("shapeChanging",e),i.editCompleteArgs=e,this.isPreventShaping=e.cancel,i.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings,allowShapeOverflow:e.allowShapeOverflow}})):("redact"!==i.activeObj.shape&&i.trigger("shapeChanging",t),i.editCompleteArgs=t,this.isPreventShaping=t.cancel,i.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:t.currentShapeSettings,allowShapeOverflow:t.allowShapeOverflow}}));i.eventType=o},e.prototype.setDragWidth=function(e){var t=this.parent,o=t.activeObj.activePoint,i=t.img,r=i.destLeft,a=i.destWidth,n=e,s=t.activeObj.shape,l=!1;if(!t.activeObj.preventShapeDragOut||"line"!==s&&"arrow"!==s||(l=!0),n>=0)for(var p=0;p<n&&(e=n-p,o.startX+=e,o.endX+=e,!(o.startX>=r&&o.endX<=r+a&&!l||o.startX>=r&&o.endX<=r+a&&o.endX>=r&&o.startX<=r+a&&l));p++)o.startX-=e,o.endX-=e;else for(p=1;p<Math.abs(n)&&(e=n+p,o.startX+=e,o.endX+=e,!(o.startX>=r&&o.endX<=r+a&&!l||o.startX>=r&&o.endX<=r+a&&o.endX>=r&&o.startX<=r+a&&l));p++)o.startX-=e,o.endX-=e},e.prototype.setDragHeight=function(e){var t=this.parent,o=t.activeObj.activePoint,i=t.img,r=i.destTop,a=i.destHeight,n=e,s=t.activeObj.shape,l=!1;if(!t.activeObj.preventShapeDragOut||"line"!==s&&"arrow"!==s||(l=!0),n>=0)for(var p=1;p<n&&(e=n-p,o.startY+=e,o.endY+=e,!(o.startY>=r&&o.endY<=r+a&&!l||o.startY>=r&&o.endY<=r+a&&o.endY>=r&&o.startY<=r+a&&l));p++)o.startY-=e,o.endY-=e;else for(p=0;p<Math.abs(n)&&(e=n+p,o.startY+=e,o.endY+=e,!(o.startY>=r&&o.endY<=r+a&&!l||o.startY>=r&&o.endY<=r+a&&o.endY>=r&&o.startY<=r+a&&l));p++)o.startY-=e,o.endY-=e},e.prototype.limitDrag=function(e){var t=!1,o=this.parent,i=o.img,r=i.destLeft,a=i.destTop,n=i.destWidth,s=i.destHeight,l=o.activeObj.activePoint,p=e?l.startX:l.endX,h=e?l.startY:l.endY,d=e?l.endX:l.startX,c=e?l.endY:l.startY,u=o.upperCanvas.width,v=o.upperCanvas.height,f=r<0?0:r,m=a<0?0:a,b=r+n>u?u:r+n,C=a+s>v?v:a+s;if(g.Browser.isDevice?(p<f&&(p=f),h<m&&(h=m),d>b&&(d=b),c>C&&(c=C)):(p<r&&(p=r),h<a&&(h=a),d>r+n&&(d=r+n),c>a+s&&(c=a+s)),l.width<0&&l.height<0&&this.isCropSelection&&(t=!0),0!==o.transform.straighten){var y={isIntersect:null,arr:null};o.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),o.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:y}}),(y.arr[0]||y.arr[1]||y.arr[2]||y.arr[3])&&(t=!0)}return e?(l.startX=p,l.startY=h,l.endX=d,l.endY=c):(l.startX=d,l.startY=c,l.endX=p,l.endY=h),t},e.prototype.isMouseOutsideImg=function(e,t){var o={bool:!1};return this.parent.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),this.parent.notify("draw",{prop:"isPointsInsideImg",value:{obj:o,x:e,y:t}}),o.bool},e.prototype.preventDraggingInvertly=function(){var e,t,o=!1,i=this.parent;if("image"===i.activeObj.shape)return o;if(void 0!==i.activeObj.shape&&(e=i.activeObj.shape.split("-")),void 0!==e&&"crop"===e[0]&&(t=!0),!this.isPreventDragging&&0===i.activeObj.rotatedAngle&&(i.activeObj.preventShapeDragOut||"redact"===i.activeObj.shape||t)){o=this.limitDrag(!0);["line","arrow","path"].indexOf(i.activeObj.shape)>-1&&(o=this.limitDrag(!1))}return o},e.prototype.preventTextDraggingInvertly=function(){var e=this.parent,t=!1,o=e.activeObj.activePoint,i=e.img,r=i.destLeft,a=i.destTop,n=i.destWidth,s=i.destHeight;return this.isPreventDragging||(o.startX<r||o.startY<a||o.endX>r+n||o.endY>a+s)&&(t=!0),t},e.prototype.preventInverseResize=function(e){var t=this.parent.activeObj.activePoint;t.width<0&&(t.width=0,t.startX=e.activePoint.startX,t.endX=e.activePoint.endX),t.height<0&&(t.height=0,t.startY=e.activePoint.startY,t.endY=e.activePoint.endY)},e.prototype.getScaleRatio=function(e){var t=this.parent,o={x:e,y:e};if(t.activeObj.shape&&"crop-custom"!==t.activeObj.shape&&"crop-circle"!==t.activeObj.shape&&"crop-square"!==t.activeObj.shape){var i="image"===t.activeObj.shape||"text"===t.activeObj.shape?this.findImageRatio(t.activeObj.activePoint.width,t.activeObj.activePoint.height).split("-"):t.activeObj.shape.split("-");if(i.length>1||"image"===t.activeObj.shape||"text"===t.activeObj.shape){i="image"===t.activeObj.shape||"text"===t.activeObj.shape?i[0].split(":"):i[1].split(":");var r=e/parseInt(i[1],10);o.x=r*parseInt(i[0],10),o.y=r*parseInt(i[1],10)}}return o},e.prototype.findImageRatio=function(e,t,o){var i=function(e,t){return 0===t?e:i(t,e%t)},r=i(e,t),a=e/r+":"+t/r;return o&&(o.ratio=a),a},e.prototype.revertResizing=function(e){var t=this.parent.activeObj.activePoint;this.preventDraggingInvertly()&&(t.startX=e.activePoint.startX,t.startY=e.activePoint.startY,t.endX=e.activePoint.endX,t.endY=e.activePoint.endY)},e.prototype.performSEResize=function(e,t,o,i){var r=this.parent;if(this.resizeImg(e,t,"se-resize",o),i.endX<i.startX){var a=i.endX;i.endX=i.startX,i.startX=a,this.dragElement=r.upperCanvas.style.cursor=r.cursor="sw-resize"}if(i.endY<i.startY){a=i.endY;i.endY=i.startY,i.startY=a,this.dragElement=r.upperCanvas.style.cursor=r.cursor="ne-resize"}this.revertCustomSelection(i,o,"se-resize"),this.revertResizing(o)},e.prototype.performNWResize=function(e,t,o,i){var r=this.parent;if(this.resizeImg(e,t,"nw-resize",o),i.startX>i.endX){var a=i.startX;i.startX=i.endX,i.endX=a,this.dragElement=r.upperCanvas.style.cursor=r.cursor="ne-resize"}if(i.startY>i.endY){a=i.startY;i.startY=i.endY,i.endY=a,this.dragElement=r.upperCanvas.style.cursor=r.cursor="sw-resize"}this.revertCustomSelection(i,o,"nw-resize"),this.revertResizing(o)},e.prototype.isCustomSelection=function(){if(this.parent.activeObj.shape){return this.parent.activeObj.shape.indexOf("crop-")>-1&&-1===["custom","circle","square","2:3","3:2","3:4","4:3","4:5","5:4","5:7","7:5","9:16","16:9"].indexOf(this.parent.activeObj.shape.split("-")[1])}return!1},e.prototype.revertCustomSelection=function(e,t,o){var i=this.parent;if(this.isCustomSelection()){var r=i.img,a=r.destLeft,n=r.destTop,s=r.destWidth,l=r.destHeight,p=a+s<i.lowerCanvas.width?a+s:i.lowerCanvas.width,h=n+l<i.lowerCanvas.height?n+l:i.lowerCanvas.height,d=a>0?a:0,c=n>0?n:0,u=n>0?n:0,g=a>0?a:0;("se-resize"===o&&(e.endX>p||e.endY>h)||"nw-resize"===o&&(e.startX<d||e.startY<c)||"ne-resize"===o&&(e.endX>p||e.startY<u)||"sw-resize"===o&&(e.startX<g||e.endY>h))&&this.revertPoints(e,t)}},e.prototype.revertPoints=function(e,t){e.startX=t.activePoint.startX,e.startY=t.activePoint.startY,e.endX=t.activePoint.endX,e.endY=t.activePoint.endY,e.width=t.activePoint.width,e.height=t.activePoint.height},e.prototype.updateNWPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"===a.activeObj.shape)this.resizeImg(e,t,"nw-resize",s),a.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:a.activeObj}});else{var l=void 0;if(void 0!==a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||void 0!==a.activeObj.shape&&"crop"!==l[0]||this.isCustomSelection()){if("image"===a.activeObj.shape||this.isCustomSelection()?this.resizeImg(e,t,"nw-resize",s):this.adjustNWPoints(n,e,t,a.activeObj.rotatedAngle),n.startX>n.endX){var p=n.startX;n.startX=n.endX,n.endX=p,this.dragElement=a.upperCanvas.style.cursor=a.cursor="ne-resize"}if(n.startY>n.endY){p=n.startY;n.startY=n.endY,n.endY=p,this.dragElement=a.upperCanvas.style.cursor=a.cursor="sw-resize"}this.revertCustomSelection(n,s,"nw-resize"),this.revertResizing(s)}else{var h=a.img,d=h.destLeft,c=h.destTop;if(n.startX<e&&n.startY<t){o=e-n.startX,i=t-n.startY,r=Math.min(o,i);var u=this.getScaleRatio(r);n.startX+=u.x,n.startY+=u.y;var v=d>0?d:0,f=c>0?c:0;(n.startX<v||n.startY<f)&&(n.startX-=u.x,n.startY-=u.y)}else{o=n.startX-e,i=t-n.endY,r=Math.max(o,i);u=this.getScaleRatio(r);n.startX-=u.x,n.startY-=u.y;v=d>0?d:0;var m=c>0?c:0;(n.startX<v||n.startY<m)&&(n.startX+=u.x,n.startY+=u.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.preventInverseResize(s)}},e.prototype.updateNPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"!==a.activeObj.shape){var l=void 0;if(a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==l[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=e,this.dragPoint.endY=t),o=this.dragPoint.endX-this.previousPoint.x,i=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(n,o,i,a.activeObj.rotatedAngle)):(n.startY=t,n.height=n.endY-n.startY),n.startY>n.endY){var p=n.startY;n.startY=n.endY,n.endY=p,this.dragElement=this.resizedElement="s-resize"}this.revertResizing(s)}else{var h=a.img,d=h.destLeft,c=h.destTop,u=h.destWidth;if(this.isCustomSelection())this.performNWResize(e,t,s,n);else if(n.endX>e&&n.startY<t){o=n.endX-e,i=t-n.startY,r=Math.min(o,i);var v=this.getScaleRatio(r);n.endX-=v.x,n.startY+=v.y,(n.endX>d+u||n.startY<c)&&(n.endX+=v.x,n.startY-=v.y)}else{o=e-n.endX,i=n.startY-t,r=Math.max(o,i);v=this.getScaleRatio(r);n.endX+=v.x,n.startY-=v.y,(n.endX>d+u||n.startY<c)&&(n.endX-=v.x,n.startY+=v.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}}},e.prototype.updateNEPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"===a.activeObj.shape)this.resizeImg(e,t,"ne-resize",s),a.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:a.activeObj}});else{var l=void 0;if(a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||void 0!==a.activeObj.shape&&"crop"!==l[0]||this.isCustomSelection()){if("image"===a.activeObj.shape||this.isCustomSelection()?this.resizeImg(e,t,"ne-resize",s):this.adjustNEPoints(n,e,t,a.activeObj.rotatedAngle),n.endX<n.startX){var p=n.endX;n.endX=n.startX,n.startX=p,this.dragElement=a.upperCanvas.style.cursor=a.cursor="nw-resize"}if(n.startY>n.endY){p=n.startY;n.startY=n.endY,n.endY=p,this.dragElement=a.upperCanvas.style.cursor=a.cursor="se-resize"}this.revertCustomSelection(n,s,"ne-resize"),this.revertResizing(s)}else{var h=a.img,d=h.destLeft,c=h.destTop,u=h.destWidth;if(n.endX>e&&n.startY<t){o=n.endX-e,i=t-n.startY,r=Math.min(o,i);var v=this.getScaleRatio(r);n.endX-=v.x,n.startY+=v.y;var f=d+u<a.lowerCanvas.width?d+u:a.lowerCanvas.width,m=c>0?c:0;(n.endX>f||n.startY<m)&&(n.endX+=v.x,n.startY-=v.y)}else{o=e-n.endX,i=n.startY-t,r=Math.max(o,i);v=this.getScaleRatio(r);n.endX+=v.x,n.startY-=v.y;f=d+u<a.lowerCanvas.width?d+u:a.lowerCanvas.width,m=c>0?c:0;(n.endX>f||n.startY<m)&&(n.endX-=v.x,n.startY+=v.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.preventInverseResize(s)}},e.prototype.updateWPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"!==a.activeObj.shape){var l=void 0;if(a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==l[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=e,this.dragPoint.endY=t),o=this.dragPoint.endX-this.previousPoint.x,i=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(n,o,i,a.activeObj.rotatedAngle)):(n.startX=e,n.width=n.endX-n.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)n.startY=t,n.height=n.endY-n.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(n.startX>n.endX){var p=n.startX;n.startX=n.endX,n.endX=p,this.dragElement=this.resizedElement="e-resize"}this.revertResizing(s)}else{var h=a.img,d=h.destLeft,c=h.destTop,u=h.destHeight;if(this.isCustomSelection())this.performNWResize(e,t,s,n);else if(n.startX<e&&n.endY>t){o=e-n.startX,i=n.endY-t,r=Math.min(o,i);var v=this.getScaleRatio(r);n.startX+=v.x,n.endY-=v.y,(n.startX<d||n.endY>c+u)&&(n.startX-=v.x,n.endY+=v.y)}else{o=n.startX-e,i=t-n.endY,r=Math.max(o,i);v=this.getScaleRatio(r);n.startX-=v.x,n.endY+=v.y,(n.startX<d||n.endY>c+u)&&(n.startX+=v.x,n.endY-=v.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}}},e.prototype.updateEPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"!==a.activeObj.shape){var l=void 0;if(a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==l[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=e,this.dragPoint.endY=t),o=this.dragPoint.endX-this.previousPoint.x,i=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(n,o,i,a.activeObj.rotatedAngle)):(n.endX=e,n.width=n.endX-n.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)n.endY=t,n.height=n.endY-n.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(n.endX<n.startX){var p=n.endX;n.endX=n.startX,n.startX=p,this.dragElement=this.resizedElement="w-resize"}this.revertResizing(s)}else{var h=a.img,d=h.destLeft,c=h.destTop,u=h.destWidth,v=h.destHeight;if(this.isCustomSelection())this.performSEResize(e,t,s,n);else if(n.endX>e&&n.endY>t){o=n.endX-e,i=n.endY-t,r=Math.min(o,i);var f=this.getScaleRatio(r);n.endX-=f.x,n.endY-=f.y,(n.endX>d+u||n.endY>c+v)&&(n.endX+=f.x,n.endY+=f.y)}else{o=e-n.endX,i=t-n.endY,r=Math.max(o,i);f=this.getScaleRatio(r);n.endX+=f.x,n.endY+=f.y,(n.endX>d+u||n.endY>c+v)&&(n.endX-=f.x,n.endY-=f.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}}},e.prototype.updateSWPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"===a.activeObj.shape)this.resizeImg(e,t,"sw-resize",s),a.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:a.activeObj}});else{var l=void 0;if(void 0!==a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||void 0!==a.activeObj.shape&&"crop"!==l[0]||this.isCustomSelection()){if("image"===a.activeObj.shape||this.isCustomSelection()?this.resizeImg(e,t,"sw-resize",s):this.adjustSWPoints(n,e,t,a.activeObj.rotatedAngle),n.startX>n.endX){var p=n.startX;n.startX=n.endX,n.endX=p,this.dragElement=a.upperCanvas.style.cursor=a.cursor="se-resize"}if(n.endY<n.startY){p=n.endY;n.endY=n.startY,n.startY=p,this.dragElement=a.upperCanvas.style.cursor=a.cursor="nw-resize"}this.revertCustomSelection(n,s,"sw-resize"),this.revertResizing(s)}else{var h=a.img,d=h.destLeft,c=h.destTop,u=h.destHeight;if(n.startX<e&&n.endY>t){o=e-n.startX,i=n.endY-t,r=Math.min(o,i);var v=this.getScaleRatio(r);n.startX+=v.x,n.endY-=v.y;var f=d>0?d:0,m=c+u<a.lowerCanvas.height?c+u:a.lowerCanvas.height;(n.startX<f||n.endY>m)&&(n.startX-=v.x,n.endY+=v.y)}else{o=n.startX-e,i=t-n.endY,r=Math.max(o,i);v=this.getScaleRatio(r);n.startX-=v.x,n.endY+=v.y;f=d>0?d:0,m=c+u<a.lowerCanvas.height?c+u:a.lowerCanvas.height;(n.startX<f||n.endY>m)&&(n.startX+=v.x,n.endY-=v.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.preventInverseResize(s)}},e.prototype.updateSPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"!==a.activeObj.shape){var l=void 0;if(a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==l[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=e,this.dragPoint.endY=t),o=this.dragPoint.endX-this.previousPoint.x,i=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(n,o,i,a.activeObj.rotatedAngle)):(n.endY=t,n.height=n.endY-n.startY),n.endY<n.startY){var p=n.endY;n.endY=n.startY,n.startY=p,this.dragElement=this.resizedElement="n-resize"}this.revertResizing(s)}else{var h=a.img,d=h.destLeft,c=h.destTop,u=h.destWidth,v=h.destHeight;if(this.isCustomSelection())this.performSEResize(e,t,s,n);else if(n.endX>e&&n.endY>t){o=n.endX-e,i=n.endY-t,r=Math.min(o,i);var f=this.getScaleRatio(r);n.endX-=f.x,n.endY-=f.y,(n.endX>d+u||n.endY>c+v)&&(n.endX+=f.x,n.endY+=f.y)}else{o=e-n.endX,i=t-n.endY,r=Math.max(o,i);f=this.getScaleRatio(r);n.endX+=f.x,n.endY+=f.y,(n.endX>d+u||n.endY>c+v)&&(n.endX-=f.x,n.endY-=f.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}}},e.prototype.updateSEPoints=function(e,t){var o,i,r,a=this.parent,n=a.activeObj.activePoint,s=(0,g.extend)({},a.activeObj,null,!0);if("text"===a.activeObj.shape)this.resizeImg(e,t,"se-resize",s),a.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:a.activeObj}});else{var l=void 0,p=void 0;if(void 0!==a.activeObj.shape&&(l=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||void 0!==a.activeObj.shape&&"crop"!==l[0]||this.isCustomSelection()){if("image"===a.activeObj.shape||this.isCustomSelection()?this.resizeImg(e,t,"se-resize",s):this.adjustSEPoints(n,e,t,a.activeObj.rotatedAngle),n.endX<n.startX){var h=n.endX;n.endX=n.startX,n.startX=h,this.dragElement=a.upperCanvas.style.cursor=a.cursor="sw-resize"}if(n.endY<n.startY){h=n.endY;n.endY=n.startY,n.startY=h,this.dragElement=a.upperCanvas.style.cursor=a.cursor="ne-resize"}this.revertCustomSelection(n,s,"se-resize"),this.revertResizing(s)}else{var d=a.img,c=d.destLeft,u=d.destTop,v=d.destWidth,f=d.destHeight;if(n.endX>e&&n.endY>t){o=n.endX-e,i=n.endY-t,r=Math.min(o,i),p=this.getScaleRatio(r),n.endX-=p.x,n.endY-=p.y;var m=c+v<a.lowerCanvas.width?c+v:a.lowerCanvas.width,b=u+f<a.lowerCanvas.height?u+f:a.lowerCanvas.height;(n.endX>m||n.endY>b)&&(n.endX+=p.x,n.endY+=p.y)}else{o=e-n.endX,i=t-n.endY,r=Math.max(o,i),p=this.getScaleRatio(r),n.endX+=p.x,n.endY+=p.y;m=c+v<a.lowerCanvas.width?c+v:a.lowerCanvas.width,b=u+f<a.lowerCanvas.height?u+f:a.lowerCanvas.height;(n.endX>m||n.endY>b)&&(n.endX-=p.x,n.endY-=p.y)}n.width=n.endX-n.startX,n.height=n.endY-n.startY,this.revertResizing(s)}this.preventInverseResize(s)}},e.prototype.resizeImg=function(e,t,o,i){var r,a,n=this.parent,s=n.activeObj.activePoint;if(0!==this.previousPoint.x&&0!==this.previousPoint.y){if("text"===this.currentDrawingShape&&(this.setCursor(e,t),0===n.activeObj.textSettings.fontSize)){n.activeObj.textSettings.fontSize=11,n.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:n.activeObj,isTextArea:null}}),n.activeObj.textSettings.text=n.activeObj.keyHistory="Enter Text",n.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}});var l=this.upperContext.measureText(n.activeObj.textSettings.text).width+.5*n.activeObj.textSettings.fontSize;s.endX=s.startX+l,s.endY=s.startY+1.18*n.activeObj.textSettings.fontSize,s.width=s.endX-s.startX,s.height=s.endY-s.startY,i=(0,g.extend)({},n.activeObj,null,!0),n.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activeObj.activePoint,obj:n.activeObj,isMouseMove:null,x:null,y:null}})}switch(n.upperCanvas.style.cursor){case"se-resize":case"s-resize":case"e-resize":this.previousPoint.x>e||this.previousPoint.y>t?(r=(this.previousPoint.x-e+(this.previousPoint.y-t))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,-Math.abs(a.x),-Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(r=(e-this.previousPoint.x+(t-this.previousPoint.y))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,Math.abs(a.x),Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o));break;case"sw-resize":this.previousPoint.x<e||this.previousPoint.y>t?(r=(e-this.previousPoint.x+(this.previousPoint.y-t))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,-Math.abs(a.x),-Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(r=(this.previousPoint.x-e+(t-this.previousPoint.y))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,Math.abs(a.x),Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o));break;case"w-resize":case"nw-resize":this.previousPoint.x<e||this.previousPoint.y<t?(r=(e-this.previousPoint.x+(t-this.previousPoint.y))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,-Math.abs(a.x),-Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(r=(this.previousPoint.x-e+(this.previousPoint.y-t))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,Math.abs(a.x),Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o));break;case"n-resize":case"ne-resize":this.previousPoint.x>e||this.previousPoint.y<t?(r=(this.previousPoint.x-e+(t-this.previousPoint.y))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,-Math.abs(a.x),-Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(r=(e-this.previousPoint.x+(this.previousPoint.y-t))/2,a=this.getScaleRatio(r),this.adjustRotationPoints(s,Math.abs(a.x),Math.abs(a.y),n.activeObj.rotatedAngle,"img-resize",o))}s.width=s.endX-s.startX,s.height=s.endY-s.startY,(s.width<10||s.height<10||"text"===n.activeObj.shape&&0===n.activeObj.rotatedAngle&&this.preventTextDraggingInvertly())&&(n.activeObj=(0,g.extend)({},i,null,!0))}this.previousPoint={x:e,y:t}},e.prototype.adjustNWPoints=function(e,t,o,i){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.endX,e.endY,r,a,i),s=[(n[0]+t)/2,(n[1]+o)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-i),p=this.rotatePoints(t,o,s[0],s[1],-i);return e.endX=l[0],e.endY=l[1],e.startY=p[1],e.startX=p[0],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},e.prototype.adjustNEPoints=function(e,t,o,i){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.startX,e.endY,r,a,i),s=[(n[0]+t)/2,(n[1]+o)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-i),p=this.rotatePoints(t,o,s[0],s[1],-i);return e.startX=l[0],e.endY=l[1],e.width=p[0]-l[0],e.height=l[1]-p[1],e.endX=e.startX+e.width,e.startY=e.endY-e.height,e},e.prototype.adjustSWPoints=function(e,t,o,i){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.endX,e.startY,r,a,i),s=[(n[0]+t)/2,(n[1]+o)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-i),p=this.rotatePoints(t,o,s[0],s[1],-i);return e.endX=l[0],e.startY=l[1],e.startX=p[0],e.endY=p[1],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},e.prototype.adjustSEPoints=function(e,t,o,i){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.startX,e.startY,r,a,i),s=[(n[0]+t)/2,(n[1]+o)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-i),p=this.rotatePoints(t,o,s[0],s[1],-i);return e.startX=l[0],e.startY=l[1],e.width=p[0]-l[0],e.height=p[1]-l[1],e.endX=e.startX+e.width,e.endY=e.startY+e.height,e},e.prototype.adjustRotationPoints=function(e,t,o,i,r,a){var n=e.startX+e.width/2,s=e.startY+e.height/2;this.getResizeDirection(e,t,o,i,r,a);var l=this.rotatePoints(e.startX,e.startY,n,s,i),p=this.rotatePoints(e.endX,e.startY,n,s,i),h=this.rotatePoints(e.endX,e.endY,n,s,i),d=this.rotatePoints(e.startX,e.endY,n,s,i),c=[(l[0]+h[0])/2,(l[1]+h[1])/2],u=this.rotatePoints(l[0],l[1],c[0],c[1],-i),g=this.rotatePoints(d[0],d[1],c[0],c[1],-i),v=this.rotatePoints(p[0],p[1],c[0],c[1],-i);return e.startX=u[0],e.startY=u[1],e.endX=v[0],e.endY=g[1],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},e.prototype.rotatePoints=function(e,t,o,i,r){return[(e-o)*Math.cos(r)-(t-i)*Math.sin(r)+o,(e-o)*Math.sin(r)+(t-i)*Math.cos(r)+i]},e.prototype.setResizedValue=function(e,t,o,i){switch(e){case"x":case"img-resize-x":t+=o;break;case"y":case"img-resize-y":t+=i;break;case"abs-x":t+=o>0?-o:Math.abs(o);break;case"abs-y":t+=i>0?-i:Math.abs(i);break;case"y-abs-x":t+=i+(o>0?-o:Math.abs(o))/2;break;case"abs-x-abs-y":t+=(o>0?-o:Math.abs(o))+(i>0?-i:Math.abs(i))/2;break;case"abs-y-x":t+=(i>0?-i:Math.abs(i))+o/2;break;case"x-y":t+=o+i/2;break;case"y-x":t+=i+o/2}return t},e.prototype.getResizeDirection=function(e,t,o,i,r,a){var n=i*(180/Math.PI),s=this.getResizedElement(n,this.resizedElement);"e-resize"===this.resizedElement?(e.width=this.setResizedValue(s,e.width,t,o),e.endX=e.width+e.startX):"n-resize"===this.resizedElement?(e.startY=this.setResizedValue(s,e.startY,t,o),e.height=e.endY-e.startY):"w-resize"===this.resizedElement?(e.startX=this.setResizedValue(s,e.startX,t,o),e.width=e.startX+e.endX):"s-resize"===this.resizedElement?(e.height=this.setResizedValue(s,e.height,t,o),e.endY=e.height+e.startY):r&&"img-resize"===r?(e.width=this.setResizedValue("img-resize-x",e.width,t,o),e.height=this.setResizedValue("img-resize-y",e.height,t,o),"se-resize"===a?(e.endX=e.width+e.startX,e.endY=e.height+e.startY):"sw-resize"===a?(e.startX=e.endX-e.width,e.endY=e.height+e.startY):"ne-resize"===a?(e.endX=e.width+e.startX,e.startY=e.endY-e.height):"nw-resize"===a&&(e.startX=e.endX-e.width,e.startY=e.endY-e.height)):r&&"text"===r&&("widthHeight"===a?(e.width=this.setResizedValue("x-y",e.width,t,o),e.endX=e.width+e.startX,e.height=this.setResizedValue("y-x",e.height,t,o),e.endY=e.height+e.startY):"width"===a?(e.width=this.setResizedValue("x-y",e.width,t,o),e.endX=e.width+e.startX):"height"===a&&(e.height=this.setResizedValue("y-abs-x",e.height,t,o),e.endY=e.height+e.startY))},e.prototype.getResizedElement=function(e,t){var o=[];"n-resize"===t?o=[[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"===t?o=[[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"===t?o=[[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"===t&&(o=[[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 i=e<0?360-Math.abs(e):e,r=0,a=o;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(i>s&&i<=l||i+360>s&&i+360<=l)return p}return t},e.prototype.updateCursorStyles=function(e,t,o){var i=this.parent,r=!1;""===i.activeObj.keyHistory||void 0!==i.activeObj.shape||i.currObjType.isCustomCrop||i.currObjType.isLine||!i.currObjType.isText||(i.activeObj.shape="text");var a=(0,g.extend)({},i.activeObj,{},!0);if(!(0,g.isNullOrUndefined)(a.topLeftCircle)){var n;if((n=0===a.shapeDegree?i.transform.degree:i.transform.degree-a.shapeDegree)<0&&(n=360+n),this.isObjSelected)if("line"===a.shape||"arrow"===a.shape)r=this.updateCursorStylesForLineArrow(e,t,a);else if("path"===a.shape)r=this.updateCursorStylesForPath(e,t,a);else if(a.rotatedAngle)this.setCursorForRotatedObject(a,e,t,i.upperCanvas),"grabbing"===i.cursor?(i.upperCanvas.style.cursor=i.cursor="grabbing",this.dragElement=i.cursor):"move"===i.cursor?(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t):"default"!==i.cursor&&(r=!0,this.dragElement=i.cursor,i.currObjType.isResize=!0);else{var s=this.getTransRotationPoint(a),l=a.topLeftCircle.radius;s&&e>=s.x-2*l&&e<=s.x+2*l&&t>=s.y-2*l&&t<=s.y+2*l&&"grabbing"!==this.dragElement?(i.upperCanvas.style.cursor=i.cursor="grabbing",this.dragElement=i.upperCanvas.style.cursor):e>=a.topLeftCircle.startX-2*l&&e<=a.topLeftCircle.startX+2*l&&t>=a.topLeftCircle.startY-2*l&&t<=a.topLeftCircle.startY+2*l&&"nw-resize"!==this.dragElement?(a.topLeftCircle.startX=a.topLeftCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="nw-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):e>=a.topLeftCircle.startX-2*l&&e<=a.topRightCircle.startX-2*l&&t>=a.topCenterCircle.startY-2*l&&t<=a.topCenterCircle.startY+2*l&&"n-resize"!==this.dragElement?(a.topCenterCircle.startX=a.topCenterCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="n-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):e>=a.topRightCircle.startX-2*l&&e<=a.topRightCircle.startX+2*l&&t>=a.topRightCircle.startY-2*l&&t<=a.topRightCircle.startY+2*l&&"ne-resize"!==this.dragElement?(a.topRightCircle.startX=a.topRightCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="ne-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):e>=a.centerLeftCircle.startX-2*l&&e<=a.centerLeftCircle.startX+2*l&&t>=a.topLeftCircle.startY-2*l&&t<=a.bottomLeftCircle.startY-2*l&&"w-resize"!==this.dragElement?(a.centerLeftCircle.startX=a.centerLeftCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="w-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):e>=a.centerRightCircle.startX-2*l&&e<=a.centerRightCircle.startX+2*l&&t>=a.topRightCircle.startY-2*l&&t<=a.bottomRightCircle.startY-2*l&&"e-resize"!==this.dragElement?(a.centerRightCircle.startX=a.centerRightCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="e-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):e>=a.bottomLeftCircle.startX-2*l&&e<=a.bottomLeftCircle.startX+2*l&&t>=a.bottomLeftCircle.startY-2*l&&t<=a.bottomLeftCircle.startY+2*l&&"sw-resize"!==this.dragElement?(a.bottomLeftCircle.startX=a.bottomLeftCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="sw-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):e>=a.bottomLeftCircle.startX-2*l&&e<=a.bottomRightCircle.startX-2*l&&t>=a.bottomCenterCircle.startY-2*l&&t<=a.bottomCenterCircle.startY+2*l&&"s-resize"!==this.dragElement?(a.bottomCenterCircle.startX=a.bottomCenterCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="s-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):e>=a.bottomRightCircle.startX-2*l&&e<=a.bottomRightCircle.startX+2*l&&t>=a.bottomRightCircle.startY-2*l&&t<=a.bottomRightCircle.startY+2*l&&"se-resize"!==this.dragElement?(a.bottomRightCircle.startX=a.bottomRightCircle.startY=0,i.upperCanvas.style.cursor=i.cursor="se-resize",r=!0,this.dragElement=i.upperCanvas.style.cursor):(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t),"text"!==a.shape||"n-resize"!==i.cursor&&"s-resize"!==i.cursor&&"e-resize"!==i.cursor&&"w-resize"!==i.cursor||(i.upperCanvas.style.cursor=i.cursor="move",this.dragElement="",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t)}else this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t;this.previousPoint.x=this.previousPoint.y=this.diffPoint.x=this.diffPoint.y=0,"touchstart"===o?r||e>=a.activePoint.startX&&e<=a.activePoint.endX&&t>=a.activePoint.startY&&t<=a.activePoint.endY||"grabbing"===this.dragElement?i.currObjType.isDragging=!0:"line"===a.shape||"arrow"===a.shape?(this.setCursorForLineArrow(a,e,t,i.upperCanvas),"move"===i.cursor&&(i.currObjType.isDragging=!0)):"path"===a.shape&&(this.setCursorForPath(a,e,t,i.upperCanvas),"move"===i.cursor&&(i.currObjType.isDragging=!0)):i.currObjType.isDragging=!0,0===a.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=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t)}},e.prototype.updateCursorStylesForLineArrow=function(e,t,o){for(var i,r=!1,a=this.parent,n=o.topLeftCircle.radius,s=0;s<5;s++)if(e>=(i=o.pointColl[s]).x-2*n&&e<=i.x+2*n&&t>=i.y-2*n&&t<=i.y+2*n){o.centerLeftCircle.startX=o.centerLeftCircle.startY=0,this.dragElement="w-resize",r=!0;break}if(!r)for(s=1;s<6;s++)if(e>=(i=o.pointColl[o.pointColl.length-s]).x-2*n&&e<=i.x+2*n&&t>=i.y-2*n&&t<=i.y+2*n){o.centerRightCircle.startX=o.centerRightCircle.startY=0,this.dragElement="e-resize",r=!0;break}if(!r)for(s=0;s<o.pointColl.length;s++){if(e>=(i=o.pointColl[s]).x-2*n&&e<=i.x+2*n&&t>=i.y-2*n&&t<=i.y+2*n){a.upperCanvas.style.cursor=a.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t;break}a.upperCanvas.style.cursor=a.cursor="default"}return r},e.prototype.updateCursorStylesForPath=function(e,t,o){var i=!1,r=this.parent;return this.pathAdjustedIndex=this.setCursorForLineArrow(o,e,t,r.upperCanvas),"move"===r.cursor&&(i=!0,this.dragElement="pathDrag"),i||(r.upperCanvas.style.cursor=r.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t),i},e.prototype.setTextSelection=function(e,t){var o=this.parent,i=o.activeObj.activePoint,r=o.transform.degree;r=0===o.activeObj.shapeDegree?o.transform.degree:o.transform.degree-o.activeObj.shapeDegree;var a=o.activeObj.rotateFlipColl;if(this.isTransformedShape&&a){r=0;for(var n=0;n<a.length;n++)"number"==typeof a[n]&&(r+=a[n])}r<0&&(r=360+r);n=0;for(var s=o.activeObj.flipObjColl.length;n<s;n++){var l=o.activeObj.flipObjColl[n].toLowerCase();switch(r){case 0:switch(l){case"horizontal":i={startX:i.endX-e,startY:i.startY,endX:i.endX,endY:i.startY+(t||0)};break;case"vertical":i.startY=i.endY-t,i={startX:i.startX,startY:i.startY,endX:i.startX+(e||0),endY:i.endY};break;default:i={startX:i.startX,startY:i.startY,endX:i.startX+(e||0),endY:i.startY+(t||0)}}break;case 90:switch(l){case"horizontal":i.endX=i.startX+t,i={startX:i.startX,startY:i.startY,endX:i.endX,endY:i.startY+(e||0)};break;case"vertical":i.startX=i.endX-t,i={startX:i.startX,startY:i.endY-e,endX:i.endX,endY:i.endY};break;default:i.startX=i.endX-t,i={startX:i.startX,startY:i.startY,endX:i.endX,endY:i.startY+(e||0)}}break;case 180:switch(l){case"horizontal":i.startY=i.endY-t,i={startX:i.startX,startY:i.startY,endX:i.startX+e,endY:i.endY};break;case"vertical":i.endY=i.startY+t,i={endX:i.endX,endY:i.endY,startX:i.endX-(e||0),startY:i.startY};break;default:i={endX:i.endX,endY:i.endY,startX:i.endX-(e||0),startY:i.endY-(t||0)}}break;case 270:switch(l){case"horizontal":i.startX=i.endX-t,i={startX:i.startX,startY:i.endY-(e||0),endX:i.endX,endY:i.endY};break;case"vertical":i={startX:i.startX,startY:i.startY,endX:i.startX+t,endY:i.startY+(e||0)};break;default:i.endX=i.startX+t,i={startX:i.startX,startY:i.endY-(e||0),endX:i.endX,endY:i.endY}}}}if(0===o.activeObj.flipObjColl.length)switch(r){case 0:i={startX:i.startX,startY:i.startY,endX:i.startX+(e||0),endY:i.startY+(t||0)};break;case 90:i.startX=i.endX-t,i={startX:i.startX,startY:i.startY,endX:i.endX,endY:i.startY+(e||0)};break;case 180:i={endX:i.endX,endY:i.endY,startX:i.endX-(e||0),startY:i.endY-(t||0)};break;case 270:i.endX=i.startX+t,i={startX:i.startX,startY:i.endY-(e||0),endX:i.endX,endY:i.endY}}i.width=i.endX-i.startX,i.height=i.endY-i.startY,o.activeObj.activePoint=i,360!==o.transform.degree&&-360!==o.transform.degree||(o.transform.degree=0)},e.prototype.setActivePoint=function(e,t){var o=this.parent,i=o.activeObj.activePoint;if(!(0,g.isNullOrUndefined)(i))if(o.currObjType.isText){var r=e||0,a=t||o.activeObj.textSettings.fontSize;void 0===o.activeObj.textSettings.fontSize&&(o.activeObj.textSettings.fontSize=.1*Math.abs(o.baseImgCanvas.width-o.baseImgCanvas.height)),this.setTextSelection(r,a),this.mouseDownPoint.x=i.endX,this.mouseDownPoint.y=i.endY,void 0!==o.activeObj.horTopLine&&(o.activeObj.activePoint=(0,g.extend)({},i,{},!0)),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})}else if(e&&t)i.startX=this.mouseDownPoint.x=e,i.startY=this.mouseDownPoint.y=t,o.currObjType.isDragging=!0;else{var n=o.activeObj;(i={startX:n.horTopLine.startX,startY:n.horTopLine.startY,endX:n.horTopLine.endX,endY:n.horTopLine.endY}).width=i.endX-i.startX,i.height=i.endY-i.startY}},e.prototype.mouseDownEventHandler=function(e){var t=this.parent;if(t.isSafari&&0===e.buttons&&(this.parent.isShapeDrawing||this.parent.togglePen)&&"path"!==this.parent.drawingShape)e.stopImmediatePropagation();else if(t.isKBDNavigation=!1,this.mouseDown=e.currentTarget===t.lowerCanvas||e.currentTarget===t.upperCanvas?"canvas":"","touchstart"===e.type?this.isTouch=!0:this.isTouch=!1,"touchstart"!==e.type||e.currentTarget!==t.lowerCanvas||t.isImageLoaded){var o;if(this.isCropSelection=!1,this.isPan=!0,void 0!==t.activeObj.shape&&(o=t.activeObj.shape.split("-")),void 0!==o&&"crop"===o[0]&&(this.isCropSelection=!0),this.isCropSelection&&(this.dragCanvas=t.togglePan=!0),"grabbing"===t.cursor){var i={shapeSettingsObj:{}};this.isGrabbing=!0,t.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var r=i.shapeSettingsObj,a={cancel:!1,action:"rotate-start",previousShapeSettings:r,allowShapeOverflow:this.allowOutofBound()},n={cancel:!1,action:"rotate-start",previousShapeSettings:r,allowShapeOverflow:this.allowOutofBound()};this.triggerShapeChange(a,n,"mouse-down")}var s={point:this.setXYPoints(e)};t.trigger("click",s),this.isMouseDown=!0,this.isMouseUp=!1,this.clickEvent(s,e)}},e.prototype.getImagePoints=function(e,t){var o=this.parent.img,i=o.destLeft,r=o.destTop,a=o.destWidth,n=o.destHeight;return e<i?e=i:e>i+a&&(e=i+a),t<r?t=r:t>r+n&&(t=r+n),{x:e,y:t}},e.prototype.clickEvent=function(e,t){var o=this.parent,r=o.activeObj.activePoint,a=e.point.x,n=e.point.y;this.mouseClickPoint={x:a,y:n};var s=o.activeObj.shape&&"text"===o.activeObj.shape?o.cursor:"default",l=o.upperCanvas.style.cursor,p=document.querySelector("#"+o.element.id+"_textArea");if("block"===p.style.display||"inline-block"===p.style.display){for(var h=!1,d=0;d<o.objColl.length;d++){var c=o.objColl[d];if(c&&c.shape&&c.activePoint){var u=c.activePoint,v=u.startX,f=u.startY,m=u.endX,b=u.endY,C=c.topLeftCircle&&c.topLeftCircle.radius?c.topLeftCircle.radius:0;a>=v-2*C&&a<=m+2*C&&n>=f-2*C&&n<=b+2*C&&(h=!0)}}h&&o.okBtn()}if(o.isResize)return this.performEnterAction(t),void(o.upperCanvas.style.cursor="default");if(JSON.stringify(o.frameObj)!==JSON.stringify(o.tempFrameObj))o.okBtn();else if(""!==this.currentDrawingShape&&!this.isShapeTouch(t,this.isCropSelection)&&(this.isTouch||"crosshair"===l||o.isShapeDrawing)){o.drawingShape&&!o.isShapeDrawing&&(o.okBtn(),o.enableShapeDrawing(o.toPascalCase(o.drawingShape),!0)),r=o.activeObj.activePoint;var y={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:y}}),this.initialPrevObj=y.currObj,this.initialPrevObj.objColl=(0,g.extend)([],o.objColl,[],!0),this.initialPrevObj.pointColl=(0,g.extend)([],o.pointColl,[],!0),this.initialPrevObj.afterCropActions=(0,g.extend)([],o.afterCropActions,[],!0);var x={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:x}}),this.initialPrevObj.selPointColl=(0,g.extend)([],x.selPointColl,[],!0),this.setActivePoint(a,n),r=o.activeObj.activePoint,"path"===this.currentDrawingShape){var P=this.getImagePoints(a,n);o.activeObj.pointColl.push({x:P.x,y:P.y}),0!==r.width&&0!==r.height&&(r.width=0,r.height=0,r.startX=o.activeObj.pointColl[o.activeObj.pointColl.length-1].x,r.startY=o.activeObj.pointColl[o.activeObj.pointColl.length-1].y)}if(r.endX=r.startX,r.endY=r.startY,"text"===this.currentDrawingShape){o.activeObj.textSettings.fontSize=11,this.previousPoint.x=r.startX,this.previousPoint.y=r.startY,o.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}});var w=this.upperContext.measureText(o.activeObj.textSettings.text).width+.5*o.activeObj.textSettings.fontSize;r.endX=r.startX+w,r.endY=r.startY+1.18*o.activeObj.textSettings.fontSize,r.width=r.endX-r.startX,r.height=r.endY-r.startY}else"arrow"===this.currentDrawingShape&&(o.activeObj.start=this.arrowShape[0],o.activeObj.end=this.arrowShape[1]);o.currObjType.isDragging=!0;var j=this.updatePrevShapeSettings(),S={cancel:!1,action:"draw-start",previousShapeSettings:j,allowShapeOverflow:this.allowOutofBound()},O={cancel:!1,action:"move",previousShapeSettings:j,allowShapeOverflow:this.allowOutofBound()};return this.shapeResizingArgs=S,this.shapeMovingArgs=O,this.triggerShapeChange(S,O,"mouse-down"),o.activeObj.activePoint=r,o.isShapeDrawing=!0,void(this.tempActiveObj=(0,g.extend)({},o.activeObj,{},!0))}o.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1,value:{isOk:!0}}),this.isCropSelection&&this.dragCanvas&&(this.setCursor(a,n),"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 T={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:T}});var k=T.currObj,F=(0,g.extend)({},o.activeObj,null,!0),I=this.isShapeTouch(t,this.isCropSelection),A=this.isFreehandDrawTouch(t,this.isCropSelection),z=I||this.isShapeClick(t,this.isCropSelection),D=this.applyCurrShape(z),R="none"!==o.textArea.style.display;if(this.isTouch&&!I&&F.shape&&!this.isCropSelection){this.applyObj(a,n)&&(o.okBtn(!0),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}));var L=(0,g.extend)({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:k,previousObjColl:k.objColl,previousPointColl:k.pointColl,previousSelPointColl:k.selPointColl,previousCropObj:L,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),D&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}if(I||o.togglePen||this.isCropSelection||"blur"===o.activeObj.redactType||"pixelate"===o.activeObj.redactType||(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||I||A||o.togglePen){var E=!1;!o.activeObj.shape||"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||(E=!0);var X=this.setXYPoints(t),Y=X.x,M=X.y;if(this.applyObj(Y,M)){if(o.okBtn(!0),D){var B=o.cursor;o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.cursor=B}o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})}o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:Y,y:M,isMouseDown:!0}});var H={index:null};o.notify("freehand-draw",{prop:"getFreehandDrawHoveredIndex",onPropertyChange:!1,value:{obj:H}});var U={freehandSelectedIndex:null};if(o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:U}}),this.isFhdPoint||this.isFhdCustomized&&!o.togglePen){if(!(0,g.isNullOrUndefined)(U.freehandSelectedIndex)&&U.freehandSelectedIndex!==H.index){var W=H.index;if(o.okBtn(),this.isFhdCustomized=!1,o.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:W}}),H.index>-1){var N=o.pointColl[H.index].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:N,strokeWidth:o.pointColl[H.index].strokeWidth}})}}U.freehandSelectedIndex=null,o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:U}});var _=(0,g.extend)([],o.objColl,[],!0);if(!(0,g.isNullOrUndefined)(H.index)&&H.index>-1)o.notify("freehand-draw",{prop:"selectFhd",value:{type:"ok"}}),o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}});else if(U.freehandSelectedIndex){o.okBtn();N=o.pointColl[U.freehandSelectedIndex].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:N,strokeWidth:o.pointColl[U.freehandSelectedIndex].strokeWidth}})}else this.findTargetObj(Y,M,!1)&&(o.objColl=_,this.findTarget(Y,M,t.type),o.notify("draw",{prop:"redrawDownScale"}))}else{if(this.isFhdEditing){o.apply();var q=document.getElementById(o.element.id+"_quickAccessToolbarArea");q&&(q.style.display="none");P=o.pointColl[U.freehandSelectedIndex];var V={id:"pen_"+(U.freehandSelectedIndex+1),type:i.FreehandDraw,startX:P.points[0].x,startY:P.points[0].y,strokeColor:P.strokeColor,strokeWidth:P.strokeWidth,points:P.points,opacity:P.opacity,index:P.order},Z={action:"apply",currentShapeSettings:(0,g.extend)({},V,{},!0)};o.trigger("shapeChange",Z),o.editCompleteArgs=Z}var G=o.togglePen,J=o.cursor;if(o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),"redact"===F.shape&&"default"!==J&&(o.cursor=J),G&&o.freeHandDraw(!0),this.isFhdEditing=!1,E?this.setCursor(Y,M):"default"!==s&&(o.upperCanvas.style.cursor=o.cursor=s),"crosshair"===o.cursor||g.Browser.isDevice&&o.togglePen){if(o.togglePen){if((0,g.isNullOrUndefined)(o.activeObj.strokeSettings)){var Q={strokeSettings:{}};o.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:Q}}),o.activeObj.strokeSettings=Q.strokeSettings}var K={penStrokeWidth:null};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:K}}),(0,g.isNullOrUndefined)(K.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:"resetSelPoints",onPropertyChange:!1}),o.notify("freehand-draw",{prop:"freehandDownHandler",onPropertyChange:!1,value:{e:t,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}(this.isTouch&&"crosshair"!==J||"crosshair"!==o.cursor)&&"touchstart"===t.type.toLowerCase()||o.currObjType.isActiveObj&&"default"!==o.cursor&&!o.togglePen?(o.notify("draw",{prop:"updateTempObjColl"}),o.notify("draw",{prop:"updateTempPointColl"}),this.findTarget(Y,M,t.type),o.notify("draw",{prop:"redrawDownScale"})):""!==o.currObjType.shape&&!o.currObjType.isCustomCrop||o.togglePen||"default"===o.cursor||this.setActivePoint(Y,M),R&&o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}})}}else{if(this.applyObj(a,n)){if(o.okBtn(!0),D){var $=o.cursor;o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.cursor=$}o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})}this.isFhdEditing&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.isFhdCustomized=!1,o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}));var ee=o.activeObj.shape;ee&&["rectangle","ellipse","line","arrow","path","text","image","redact"].indexOf(ee)>-1&&(o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}),o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}));var te=!1;o.activeObj.shape&&o.activeObj.shape.indexOf("crop-")>-1&&(te=!0),o.element.querySelector(".e-contextual-toolbar-wrapper")&&!te&&(o.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(o.okBtn(),o.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"))),this.canvasMouseDownHandler(t)}this.isShapeInserted=!1,this.tempActiveObj=(0,g.extend)({},o.activeObj,{},!0)},e.prototype.mouseMoveEventHandler=function(e){var t=this.parent,o=t.cursor,i=t.upperCanvas.style.cursor;if(e.preventDefault(),!(this.isPreventShaping||t.isShapeDrawing&&t.currObjType.isDragging&&this.isTouch&&t.activeObj.shape&&"path"===t.activeObj.shape)){if("grabbing"===t.cursor&&this.isGrabbing){var a={shapeSettingsObj:{}};t.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={cancel:!1,action:"rotating",previousShapeSettings:n,allowShapeOverflow:this.allowOutofBound()},l={cancel:!1,action:"rotating",previousShapeSettings:n,allowShapeOverflow:this.allowOutofBound()};this.triggerShapeChange(s,l,"mouse-down")}if(this.timer&&this.timer>0&&this.dragPoint.startX&&this.dragPoint.startY){var p=Math.abs(this.dragPoint.startX-e.touches[0].clientX),h=Math.abs(this.dragPoint.startY-e.touches[0].clientY);(p>10||h>10)&&(this.timer=0)}var d=t.lowerCanvas.getBoundingClientRect();if("touchmove"!==e.type||2!==e.touches.length){var c,u;"mousemove"===e.type?(c=e.clientX,u=e.clientY):(this.touchEndPoint.x=c=e.touches[0].clientX,this.touchEndPoint.y=u=e.touches[0].clientY),c-=d.left,u-=d.top,this.canvasMouseMoveHandler(e);var v,f=!1;void 0!==t.activeObj.shape&&(v=t.activeObj.shape.split("-")),void 0!==v&&"crop"===v[0]&&(f=!0),f&&t.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),t.upperCanvas.style.cursor=i,t.cursor=o,(t.currObjType.isActiveObj&&(void 0!==t.activeObj.activePoint||t.objColl.length>0)&&!this.dragCanvas||void 0!==t.activeObj.activePoint)&&""===this.dragElement&&(this.setCursor(c,u),t.activeObj.activePoint&&(0===t.activeObj.activePoint.width||!(0,g.isNullOrUndefined)(t.activeObj.currIndex)&&this.cursorTargetId!==t.activeObj.currIndex)&&"default"!==t.cursor&&"move"!==t.cursor&&"crosshair"!==t.cursor&&"grab"!==t.cursor&&"pointer"!==t.cursor&&(t.upperCanvas.style.cursor=t.cursor="move"),this.findTarget(c,u,e.type));var m=t.img,b=m.destLeft,C=m.destTop,y=m.destWidth,x=m.destHeight;if(t.currObjType.isDragging){if(t.activeObj.shape&&t.activeObj.preventShapeDragOut&&(c<b||c>b+y||u<C||u>C+x))return;this.upperContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.updateActivePoint(c,u,f),t.notify("shape",{prop:"updateTrianglePoints",onPropertyChange:!1,value:{obj:t.activeObj}}),this.isPreventDragging?(this.isShapeDragOut()||(this.isPreventDragging=!1),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:null,saveContext:null,isPreventSelection:null}}),f&&(this.dragCanvas=t.togglePan=!0)}this.isMouseDown=!1,this.isMouseUp=!1}else{if(this.isFirstMove)this.startTouches=this.targetTouches(e.touches),this.tempTouches=[],this.tempTouches.push({x:e.touches[0].clientX||e.touches[0].pageX-t.lowerCanvas.offsetLeft-d.left,y:(e.touches[0].clientY||e.touches[0].pageY-t.lowerCanvas.offsetTop)-d.top}),this.tempTouches.push({x:(e.touches[1].clientX||e.touches[1].pageX-t.lowerCanvas.offsetLeft)-d.left,y:(e.touches[1].clientY||e.touches[1].pageY-t.lowerCanvas.offsetTop)-d.top});else{var P=(e.touches[0].clientX||e.touches[0].pageX-t.lowerCanvas.offsetLeft)-d.left,w=(e.touches[0].clientY||e.touches[0].pageY-t.lowerCanvas.offsetTop)-d.top,j=(e.touches[1].clientX||e.touches[1].pageX-t.lowerCanvas.offsetLeft)-d.left,S=(e.touches[1].clientY||e.touches[1].pageY-t.lowerCanvas.offsetTop)-d.top,O={x:P<j?j-(j-P)/2:P-(P-j)/2,y:w<S?S-(S-w)/2:w-(w-S)/2};if(this.currMousePoint.x!==O.x&&this.currMousePoint.y!==O.y){var T="";if("touchmove"===e.type&&(t.zoomSettings.zoomTrigger&r.Pinch)===r.Pinch){this.zoomType="Pinch";var k=this.calculateScale(this.startTouches,this.targetTouches(e.touches));this.startTouches=this.targetTouches(e.touches),k>1?T="zoomIn":k<1&&(T="zoomOut")}""!==T&&(t.isZoomBtnClick=!0,t.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:O.x,y:O.y,type:T,isResize:null}})),this.tempTouches=[],this.tempTouches.push({x:e.touches[0].clientX||e.touches[0].pageX-t.lowerCanvas.offsetLeft,y:e.touches[0].clientY||e.touches[0].pageY-t.lowerCanvas.offsetTop}),this.tempTouches.push({x:e.touches[1].clientX||e.touches[1].pageX-t.lowerCanvas.offsetLeft,y:e.touches[1].clientY||e.touches[1].pageY-t.lowerCanvas.offsetTop}),this.currMousePoint.x=O.x,this.currMousePoint.y=O.y,this.isPinching=!0}}this.isFirstMove=!1}}},e.prototype.mouseUpEventHandler=function(e){var t=this.parent,o=t.element.id;if(t.isKBDNavigation=this.isMouseDown=!1,this.isMouseUp=!0,g.Browser.isDevice||!(t.element.querySelector("#"+o+"_contextualToolbar")&&!t.element.querySelector("#"+o+"_contextualToolbar").parentElement.classList.contains("e-hide")||t.element.querySelector("#"+o+"_headWrapper")&&!t.element.querySelector("#"+o+"_headWrapper").parentElement.classList.contains("e-hide"))||t.activeObj.shape&&"redact"===t.activeObj.shape&&t.isShapeDrawing){if("grabbing"===t.cursor&&this.isGrabbing){var i={shapeSettingsObj:{}};t.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var r=i.shapeSettingsObj,a={cancel:!1,action:"rotate-end",previousShapeSettings:r,allowShapeOverflow:this.allowOutofBound()},n={cancel:!1,action:"rotate-end",previousShapeSettings:r,allowShapeOverflow:this.allowOutofBound()};this.triggerShapeChange(a,n,"mouse-up")}if(this.isGrabbing=!1,this.isPreventShaping&&(this.isPreventShaping=!1),"canvas"===this.mouseDown||this.isSliderActive||e.target.closest(".e-image-editor")||e.target.closest(".e-ie-ddb-popup")){"touchstart"===e.type?this.isTouch=!1:"touchend"===e.type&&e.stopImmediatePropagation(),e.preventDefault(),t.togglePan&&this.canvasMouseUpHandler(e);var s=void 0,l=void 0;"mouseup"===e.type?(s=e.clientX,l=e.clientY):this.isTouchDblClick||(s=this.touchEndPoint.x,l=this.touchEndPoint.y);var p=t.lowerCanvas.getBoundingClientRect();s-=p.left,l-=p.top,"text"===t.drawingShape&&this.mouseDownPoint&&this.mouseDownPoint.x===s&&this.mouseDownPoint.y===l&&(t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.activeObj.keyHistory||(t.activeObj.keyHistory="Enter Text"));var h=void 0,d=this.currentDrawingShape,c=!1;if("touchend"===e.type&&(this.startTouches=this.tempTouches=[],this.isFirstMove=!1,"none"===t.textArea.style.display&&(this.timer=0),this.isPinching))return this.isPinching=!1,t.notify("draw",{prop:"redrawDownScale"}),(t.isCropTab||t.activeObj.shape)&&(t.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),t.notify("freehand-draw",{prop:"resetStraightenPoint"})),void(t.isStraightening&&(t.notify("draw",{prop:"resetStraightenDestPoints"}),t.notify("draw",{prop:"setDestForStraighten"})));var u=!1,v=void 0;if(void 0!==t.activeObj.shape&&(v=t.activeObj.shape.split("-")),void 0!==v&&"crop"===v[0]&&(u=!0),"path"===this.currentDrawingShape&&t.isShapeDrawing){var f=e.srcElement,m=f.parentElement.id,b=t.element.id;return e.currentTarget!==t.upperCanvas&&e.currentTarget!==t.lowerCanvas&&t.activeObj.pointColl.length>0&&(f.classList.contains("e-upload-icon")||m===b+"_zoomIn"||m===b+"_zoomOut"||m===b+"_annotationBtn"||m===b+"_borderColorBtn"||m===b+"_borderWidthBtn")&&(t.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e,isApply:!0}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:t.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}})),void(t.currObjType.isDragging&&this.isTouch&&t.activeObj.shape&&"path"===t.activeObj.shape&&(this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:t.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}})))}if(e.currentTarget===t.upperCanvas&&!t.isResize){if(this.pathAdjustedIndex=null,""!==this.currentDrawingShape){if("text"===this.currentDrawingShape){var C=(0,g.extend)({},t.cropObj,{},!0);t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeInsert",previousObj:this.initialPrevObj,previousObjColl:this.initialPrevObj.objColl,previousPointColl:this.initialPrevObj.pointColl,previousSelPointColl:this.initialPrevObj.selPointColl,previousCropObj:C,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else t.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:this.initialPrevObj.objColl,operation:"shapeInsert"}});this.isShapeInserted=!0,this.currentDrawingShape="",(t.activeObj.shape&&"path"===t.activeObj.shape&&0===t.activeObj.pointColl.length||(!t.activeObj.shape||"path"!==t.activeObj.shape)&&0===t.activeObj.activePoint.width&&0===t.activeObj.activePoint.height)&&(c=!0,t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height));a={cancel:!1,action:"draw-end",previousShapeSettings:j=this.updatePrevShapeSettings()},n={cancel:!1,action:"move",previousShapeSettings:j};this.shapeResizingArgs=a,this.shapeMovingArgs=n,this.triggerShapeChange(a,n,"mouse-up")}t.activeObj.shape&&"path"===t.activeObj.shape&&t.activeObj.pointColl.length>0&&(t.activeObj.activePoint=t.getSquarePointForPath(t.activeObj)),this.adjustActObjForLineArrow(),this.updPtCollForShpRot(),t.currObjType.shape=t.currObjType.shape.toLowerCase();var y=(0,g.extend)({},t.cropObj,{},!0),x={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:x}});var P=x.currObj;P.objColl=(0,g.extend)([],t.objColl,[],!0),P.pointColl=(0,g.extend)([],t.pointColl,[],!0),P.afterCropActions=(0,g.extend)([],t.afterCropActions,[],!0);var w={selPointColl:null};if(t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:w}}),P.selPointColl=(0,g.extend)([],w.selPointColl,[],!0),t.togglePen||u){if(u&&this.isMouseUp&&t.cursor.indexOf("resize")>-1){var j;a={cancel:!1,action:"resize-end",previousShapeSettings:j=this.updatePrevShapeSettings()};this.triggerShapeChange(a,a,"resize")}}else{if(this.tempObjColl&&0!==t.activeObj.activePoint.width){t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.objColl.push(t.activeObj),JSON.stringify(t.activeObj.activePoint)!==JSON.stringify(this.tempActiveObj.activePoint)&&t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:P,previousObjColl:this.tempObjColl,previousPointColl:P.pointColl,previousSelPointColl:P.selPointColl,previousCropObj:y,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}});var S=(0,g.extend)({},t.objColl[t.objColl.length-1],{},!0);t.objColl.pop(),this.redrawShape(S),this.tempObjColl=void 0}this.isFhdEditing||(this.applyCurrActObj(s,l),t.currObjType.isResize=!1,t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))}if(t.activeObj){var O,T=!1;void 0!==t.activeObj.shape&&(O=t.activeObj.shape.split("-")),(void 0===O&&(t.currObjType.isCustomCrop||t.togglePen)||void 0!==O&&"crop"===O[0])&&(T=!0);var k=t.activeObj.shape;h=k;if(["rectangle","ellipse","line","arrow","path"].indexOf(k)>-1)t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if("text"===k)"none"===t.textArea.style.display&&t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if("redact"===k)t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"redact",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(this.isFhdEditing)t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(!T){t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:!1,isZooming:null}})}if(t.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),!this.isFhdEditing){var F=Math.floor(t.activeObj.activePoint.width);if(t.activeObj.shape&&"text"===t.activeObj.shape&&11===t.activeObj.textSettings.fontSize&&11===Math.floor(t.activeObj.activePoint.height)&&(55===F||t.activeObj.textSettings.bold&&58===F)&&(t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),"text"!==t.drawingShape||t.activeObj.keyHistory||(t.activeObj.keyHistory="Enter Text")),!T){var I=!1;if(Math.round(s)===Math.round(this.mouseClickPoint.x)&&Math.round(l)===Math.round(this.mouseClickPoint.y)&&(I=!0,t.notify("undo-redo",{prop:"preventApplyEditComplete",value:{bool:!0}})),this.adjustActObjForLineArrow(),t.isShapeDrawing){var A=this.currentDrawingShape;t.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1}),this.currentDrawingShape=A}else t.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1});I&&t.notify("undo-redo",{prop:"preventApplyEditComplete",value:{bool:!1}})}}}}if(void 0!==t.activeObj.shape&&(v=t.activeObj.shape.split("-")),void 0!==v&&"crop"===v[0]&&(u=!0),t.activeObj.shape&&!u&&e.currentTarget===t.upperCanvas&&"none"===t.textArea.style.display){if("text"===t.activeObj.shape)t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if("redact"===t.activeObj.shape)t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"redact",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else{A=this.currentDrawingShape;this.currentDrawingShape="",t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),this.currentDrawingShape=A}t.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),t.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})}i={freehandDrawSelectedId:null};t.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:i}}),t.togglePen&&e.currentTarget===t.upperCanvas&&!i.freehandDrawSelectedId?(t.notify("freehand-draw",{prop:"freehandUpHandler",onPropertyChange:!1,value:{e,canvas:t.upperCanvas,context:this.upperContext}}),t.togglePen&&!t.isMaskImage&&((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.length>0||!(0,g.isNullOrUndefined)(t.toolbarTemplate))&&(t.okBtn(),t.freeHandDraw(!0))):t.currObjType.shape="",this.dragElement="",this.mouseDown="",this.isSliderActive=!1,t.currObjType.isInitialLine=t.currObjType.isDragging=!1,this.selMouseUpEvent(),(0,g.isNullOrUndefined)(t.drawingShape)&&h&&""!==d&&(t.drawingShape=h),t.drawingShape&&(this.currentDrawingShape=t.drawingShape.toLowerCase(),c&&(t.enableShapeDrawing(t.toPascalCase(t.drawingShape),!0),t.upperCanvas.style.cursor="crosshair")),t.isShapeDrawing=!1,t.notify("freehand-draw",{prop:"resetSelPoints",onPropertyChange:!1})}this.isMouseUp=!1,this.mouseClickPoint={x:0,y:0}}},e.prototype.adjustActObjForLineArrow=function(e){var t=!1,o=this.parent;if((e=e||o.activeObj).shape&&("line"===e.shape||"arrow"===o.activeObj.shape)){var i=void 0;if(("e-resize"===this.dragElement&&e.activePoint.endX<e.activePoint.startX||"w-resize"===this.dragElement&&e.activePoint.startX>e.activePoint.endX)&&(t=!0,i=e.activePoint.startX,e.activePoint.startX=e.activePoint.endX,e.activePoint.endX=i,i=e.activePoint.startY,e.activePoint.startY=e.activePoint.endY,e.activePoint.endY=i),e.activePoint.width=Math.abs(e.activePoint.endX-e.activePoint.startX),e.activePoint.height=Math.abs(e.activePoint.endY-e.activePoint.startY),"path"!==o.activeObj.shape){o.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:e}});for(var r=0;r<e.pointColl.length;r++)e.pointColl[r].ratioX=(e.pointColl[r].x-o.img.destLeft)/o.img.destWidth,e.pointColl[r].ratioY=(e.pointColl[r].y-o.img.destTop)/o.img.destHeight}}return t},e.prototype.updPtCollForShpRot=function(e){var t=this.parent;if((e=e||t.activeObj).shape&&0!==e.rotatedAngle){t.notify("shape",{prop:"setPointCollForShapeRotation",onPropertyChange:!1,value:{obj:e}});var o=t.img,i=o.destLeft,r=o.destTop,a=o.destWidth,n=o.destHeight,s=e.horTopLinePointColl,l=e.horBottomLinePointColl,p=e.verLeftLinePointColl,h=e.verRightLinePointColl,d=function(e){e.ratioX=(e.x-i)/a,e.ratioY=(e.y-r)/n};s.forEach(d),l.forEach(d),p.forEach(d),h.forEach(d)}},e.prototype.setXYPoints=function(e){var t,o;e.preventDefault(),"mousedown"===e.type?(t=e.clientX,o=e.clientY):(this.touchEndPoint.x=t=e.touches[0].clientX,this.touchEndPoint.y=o=e.touches[0].clientY);var i=this.parent.lowerCanvas.getBoundingClientRect();return{x:t-=i.left,y:o-=i.top}},e.prototype.getCurrentIndex=function(){for(var e,t=this.parent,o=0,i=t.objColl.length;o<i;o++)if(t.activeObj.currIndex===t.objColl[o].currIndex){e=o;break}return e},e.prototype.isShapeClick=function(e,t){var o=this.parent,i=!1;if(o.togglePen)return i;if(o.activeObj.shape&&"text"===o.activeObj.shape&&this.isShapeInserted){var r="block"===o.textArea.style.display||"inline-block"===o.textArea.style.display,a=(0,g.extend)({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var n=this.setXYPoints(e),s=n.x,l=n.y;if(i=this.findTargetObj(s,l,t),t||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),i&&o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}})),r){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=a;var p=this.getCurrentIndex();(0,g.isNullOrUndefined)(p)?o.objColl.pop():o.objColl.splice(p,1)}else if(!i&&a.shape){o.activeObj=a;p=this.getCurrentIndex();(0,g.isNullOrUndefined)(p)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[p].activePoint)?(0,g.isNullOrUndefined)(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(p,1)}}return i},e.prototype.isShapeTouch=function(e,t){var o=this.parent,i=!1;if("touchstart"===e.type&&!o.togglePen){o.activeObj&&"text"===o.activeObj.shape&&(this.timer=setTimeout(this.setTimer.bind(this),1e3,e));var r="block"===o.textArea.style.display||"inline-block"===o.textArea.style.display,a=(0,g.extend)({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var n=this.setXYPoints(e),s=n.x,l=n.y;if(i=this.findTargetObj(s,l,t),t||this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),r){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=a;var p=this.getCurrentIndex();(0,g.isNullOrUndefined)(p)?o.objColl.pop():o.objColl.splice(p,1)}else if(!i&&a.shape&&(0!==a.activePoint.width||0!==a.activePoint.height||"path"===a.shape&&a.pointColl.length>0)){o.activeObj=a;p=this.getCurrentIndex();t||((0,g.isNullOrUndefined)(p)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[p].activePoint)?(0,g.isNullOrUndefined)(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(p,1))}}return i},e.prototype.isFreehandDrawTouch=function(e,t){var o=this.parent,i=!1;if("touchstart"===e.type&&!t&&!o.togglePen){var r="block"===o.textArea.style.display||"inline-block"===o.textArea.style.display,a=(0,g.extend)({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var n=this.setXYPoints(e),s=n.x,l=n.y;if(this.setCursor(s,l),this.isFhdPoint&&(i=!0),r){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=a;var p=this.getCurrentIndex();(0,g.isNullOrUndefined)(p)?o.objColl.pop():o.objColl.splice(p,1)}else if(a.shape){o.activeObj=a;p=this.getCurrentIndex();t||((0,g.isNullOrUndefined)(p)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[p].activePoint)?(0,g.isNullOrUndefined)(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(p,1))}}return i},e.prototype.applyObj=function(e,t){var o=this.parent,i=!1;if(0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height)return!1;var r=o.activeObj.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY;if(o.activeObj.shape&&["rectangle","ellipse","line","arrow","path","image","text"].indexOf(o.activeObj.shape)>-1){var p=o.activeObj.topLeftCircle.radius;i=!(e>=a-2*p&&e<=s+2*p&&t>=n-2*p&&t<=l+2*p)&&("default"===o.upperCanvas.style.cursor||"grab"===o.upperCanvas.style.cursor||"crosshair"===o.upperCanvas.style.cursor||"pointer"===o.upperCanvas.style.cursor||"move"===o.upperCanvas.style.cursor)}return i},e.prototype.applyCurrShape=function(e){var t=this.parent,o=!1;if(t.togglePen)return o;var i=(0,g.extend)({},t.activeObj,null,!0);if(this.isShapeInserted&&"text"===t.activeObj.shape&&e&&(this.isInitialTextEdited=!0,t.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}})),"block"===t.textArea.style.display||"inline-block"===t.textArea.style.display){var r=(0,g.extend)({},t.activeObj,null,!0);t.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),i=(0,g.extend)({},t.objColl[t.objColl.length-1],null,!0),t.objColl.pop(),t.activeObj=(0,g.extend)({},r,null,!0),t.textArea.value=i.keyHistory,t.textArea.style.display="block";var a=i.strokeSettings&&i.strokeSettings.strokeColor?"rgb"===i.strokeSettings.strokeColor.split("(")[0]?this.rgbToHex(parseFloat(i.strokeSettings.strokeColor.split("(")[1].split(",")[0]),parseFloat(i.strokeSettings.strokeColor.split("(")[1].split(",")[1]),parseFloat(i.strokeSettings.strokeColor.split("(")[1].split(",")[2]),parseFloat(i.strokeSettings.strokeColor.split("(")[1].split(",")[3])):i.strokeSettings.strokeColor:null;a&&"#ffffff"===a&&(a="#fff"),this.tempActiveObj.strokeSettings&&this.tempActiveObj.strokeSettings.strokeColor&&"#ffffff"===this.tempActiveObj.strokeSettings.strokeColor&&(this.tempActiveObj.strokeSettings.strokeColor="#fff"),(i.keyHistory!==this.tempActiveObj.keyHistory||a&&a!==this.tempActiveObj.strokeSettings.strokeColor||i.textSettings&&i.textSettings.fontFamily!==this.tempActiveObj.textSettings.fontFamily||i.textSettings&&Math.round(i.textSettings.fontSize)!==Math.round(this.tempActiveObj.textSettings.fontSize)||i.textSettings&&Math.round(i.textSettings.fontRatio)!==Math.round(this.tempActiveObj.textSettings.fontRatio)||i.textSettings&&i.textSettings.bold!==this.tempActiveObj.textSettings.bold||i.textSettings&&i.textSettings.italic!==this.tempActiveObj.textSettings.italic||i.textSettings&&i.textSettings.underline!==this.tempActiveObj.textSettings.underline||i.textSettings&&i.textSettings.strikethrough!==this.tempActiveObj.textSettings.strikethrough)&&(o=!0),this.isInitialTextEdited&&!o&&(o=!0,this.isInitialTextEdited=!1)}else this.tempActiveObj.activePoint.height=Math.abs(this.tempActiveObj.activePoint.height),o=JSON.stringify(i)!==JSON.stringify(this.tempActiveObj);return o},e.prototype.canvasMouseDownHandler=function(e){var t,o,i=this.parent;e.preventDefault(),"mousedown"===e.type?(t=e.offsetX||e.pageX-i.lowerCanvas.offsetLeft,o=e.offsetY||e.pageY-i.lowerCanvas.offsetTop):(t=e.touches[0].clientX||e.touches[0].pageX-i.lowerCanvas.offsetLeft,o=e.touches[0].clientY||e.touches[0].pageY-i.lowerCanvas.offsetTop);var r=i.lowerCanvas.getBoundingClientRect();t-=r.left,o-=r.top,this.panDown={x:t,y:o};var a={tempPanMove:null};i.notify("transform",{prop:"getTempPanMove",onPropertyChange:!1,value:{obj:a}}),(0,g.isNullOrUndefined)(a.tempPanMove)&&i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:{x:t,y:o}}})},e.prototype.canvasMouseMoveHandler=function(e){var t=this.parent,o={bool:null};if(t.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:o}}),t.isResize||o.bool)t.upperCanvas.style.cursor="default";else{var i,r;this.dragCanvas?t.lowerCanvas.style.cursor="grab":(this.dragCanvas=t.togglePan=!1,t.lowerCanvas.style.cursor=t.upperCanvas.style.cursor=t.cursor="default"),"mousemove"===e.type?(i=e.offsetX,r=e.offsetY):(i=e.touches[0].clientX||e.touches[0].pageX-t.lowerCanvas.offsetLeft,r=e.touches[0].clientY||e.touches[0].pageY-t.lowerCanvas.offsetTop);var a=t.lowerCanvas.getBoundingClientRect(),n={x:i-=a.left,y:r-=a.top};t.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:{x:i,y:r}}}),this.panDown&&n&&t.togglePan&&this.dragCanvas&&((t.isCropTab||t.activeObj.shape)&&(t.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),t.notify("freehand-draw",{prop:"resetStraightenPoint"})),t.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:null,yDiff:null}}))}},e.prototype.canvasMouseUpHandler=function(e){var t=this.parent;e.preventDefault();var o={panMove:null};t.notify("transform",{prop:"getPanMove",onPropertyChange:!1,value:{obj:o}}),t.togglePan&&this.panDown&&o.panMove&&t.togglePan&&this.dragCanvas&&(this.panDown=null,t.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:null}})),t.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),"path"!==this.currentDrawingShape&&(t.currObjType.isDragging=!1)},e.prototype.touchStartHandler=function(e){e.preventDefault();var t=this.parent;if(0===this.touchTime)this.touchTime=(new Date).getTime();else if((new Date).getTime()-this.touchTime<400){this.isTouchDblClick=!0;var o=t.isShapeDrawing;if(t.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e,isApply:null}}),this.isTouchDblClick=!1,this.touchTime=0,o!==t.isShapeDrawing&&t.activeObj.shape&&"path"===t.activeObj.shape)return}else this.touchTime=(new Date).getTime();2===e.touches.length?this.isFirstMove=!0:this.mouseDownEventHandler(e),g.EventHandler.add(t.lowerCanvas,"touchend",this.mouseUpEventHandler,this),g.EventHandler.add(t.lowerCanvas,"touchmove",this.mouseMoveEventHandler,this),g.EventHandler.add(t.upperCanvas,"touchend",this.mouseUpEventHandler,this),g.EventHandler.add(t.upperCanvas,"touchmove",this.mouseMoveEventHandler,this)},e.prototype.unwireEvent=function(){var e=this.parent;g.EventHandler.remove(e.lowerCanvas,"touchend",this.mouseUpEventHandler),g.EventHandler.remove(e.lowerCanvas,"touchmove",this.mouseMoveEventHandler),g.EventHandler.remove(e.upperCanvas,"touchend",this.mouseUpEventHandler),g.EventHandler.remove(e.upperCanvas,"touchmove",this.mouseMoveEventHandler)},e.prototype.keyDownEventHandler=function(e){var t=this.parent;!e.ctrlKey||"+"!==e.key&&"-"!==e.key||e.preventDefault();var o={fileName:"",fileType:null};t.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:o}});var i={fileName:o.fileName,fileType:o.fileType,cancel:!1};switch(e.key){case e.ctrlKey&&"s":t.trigger("beforeSave",i),this.beforeSaveEvent(i,e);break;case e.ctrlKey&&"z":t.allowUndoRedo&&(t.noPushUndo=!1,(t.togglePen||t.drawingShape)&&(t.okBtn(),t.drawingShape=null),t.notify("undo-redo",{prop:"call-undo"}));break;case e.ctrlKey&&"y":t.allowUndoRedo&&(t.noPushUndo=!1,(t.togglePen||t.drawingShape)&&(t.okBtn(),t.drawingShape=null),t.notify("undo-redo",{prop:"call-redo"}));break;case e.ctrlKey&&"+":(t.zoomSettings.zoomTrigger&r.Commands)===r.Commands&&(this.zoomType="Commands",t.isZoomBtnClick=!0,t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null}),t.notify("draw",{prop:"redrawDownScale"}),(t.isCropTab||t.activeObj.shape)&&(t.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),t.notify("freehand-draw",{prop:"resetStraightenPoint"})),t.isStraightening&&(t.notify("draw",{prop:"resetStraightenDestPoints"}),t.notify("draw",{prop:"setDestForStraighten"})));break;case e.ctrlKey&&"-":(t.zoomSettings.zoomTrigger&r.Commands)===r.Commands&&(this.zoomType="Commands",t.isZoomBtnClick=!0,t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null}),t.notify("draw",{prop:"redrawDownScale"}),(t.isCropTab||t.activeObj.shape)&&(t.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),t.notify("freehand-draw",{prop:"resetStraightenPoint"})),t.isStraightening&&(t.notify("draw",{prop:"resetStraightenDestPoints"}),t.notify("draw",{prop:"setDestForStraighten"})));break;case"Delete":this.deleteItem();break;case"Escape":t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null,isFinalCancel:!0}});break;case"Enter":this.performEnterAction(e);break;case"Tab":this.performTabAction();break;default:!g.Browser.isDevice||"block"!==t.textArea.style.display&&"inline-block"!==t.textArea.style.display||setTimeout(this.textKeyDown.bind(this),1,e)}},e.prototype.performEnterAction=function(e){var t=this.parent;if(t.isResize){var o=e.target,i=!!(o.id.indexOf("aspectratio")||o.id.indexOf("non-aspectratio")>-1);if(!this.isValueUpdated())return void(i&&this.focusRatioBtn());var r=this.getNumTextValue(),a=t.element.querySelector("#"+t.element.id+"_aspectratio"),n=t.element.querySelector(".e-ie-toolbar-aspect-ratio-btn");r&&r.x&&r.y&&(a||n&&!n.classList.contains("e-hidden")?t.notify("transform",{prop:"resize",value:{width:r.x,height:null,isAspectRatio:!0}}):t.notify("transform",{prop:"resize",value:{width:r.x,height:r.y,isAspectRatio:!1}}));var s=t.element.querySelector("#"+t.element.id+"_resizeHeight"),l=t.element.querySelector("#"+t.element.id+"_resizeWidth");if((0,g.isNullOrUndefined)(a)){if(s){var p=(0,g.getComponent)(s,"numerictextbox");s&&""===s.value&&(p.value=parseFloat(p.placeholder),s.value=p.placeholder+"px")}if(l){p=(0,g.getComponent)(l,"numerictextbox");l&&""===l.value&&(p.value=parseFloat(p.placeholder),l.value=p.placeholder+"px")}}t.notify("draw",{prop:"redrawDownScale"}),i&&this.focusRatioBtn()}else if(e.target.classList.contains("e-upload")){var h=t.element.querySelector(".e-image-upload");h&&h.querySelector(".e-tbar-btn")&&h.querySelector(".e-tbar-btn").click()}else if(e.target.classList.contains("filter-wrapper"))e.target.parentElement.click();else{var d=void 0;t.activeObj.shape&&(d=t.activeObj.shape.split("-")),e&&this.isKeyBoardCrop(e)&&t.activeObj.horTopLine&&t.activeObj.shape&&"crop"===d[0]&&t.crop()}},e.prototype.focusRatioBtn=function(){var e=this.parent.element.id;this.parent.isKBDNavigation&&setTimeout(function(){document.getElementById(e+"_aspectratio")?document.getElementById(e+"_aspectratio").focus():document.getElementById(e+"_nonaspectratio")&&document.getElementById(e+"_nonaspectratio").focus()},50)},e.prototype.isKeyBoardCrop=function(e){var t=!1,o=e.target;return o.id!==this.parent.element.id+"_ok"&&""!==o.id||(t=!0),t},e.prototype.beforeSaveEvent=function(e,t){var o=this.parent;e.cancel||o.notify("export",{prop:"export",onPropertyChange:!1,value:{type:e.fileType,fileName:e.fileName}}),t.preventDefault(),t.stopImmediatePropagation()},e.prototype.handleScroll=function(e){this.mouseWheel++;var t,o,i=this.parent,a=!1;"mousewheel"===e.type&&(t=e.clientX,o=e.clientY);var n=i.lowerCanvas.getBoundingClientRect();if(t-=n.left,o-=n.top,t>i.img.destLeft&&t<i.img.destLeft+i.img.destWidth&&o>i.img.destTop&&o<i.img.destTop+i.img.destHeight&&(a=!0),2===this.mouseWheel)return this.mouseWheel=0,void(!0===e.ctrlKey&&a&&e.preventDefault());if(e.stopPropagation(),!0===e.ctrlKey&&a){e.preventDefault(),!i.isCropTab&&i.activeObj.shape&&"crop"!==i.activeObj.shape.split("-")[0]&&(i.okBtn(null,!0),i.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}));var s="";"mousewheel"===e.type&&(i.zoomSettings.zoomTrigger&r.MouseWheel)===r.MouseWheel&&(this.zoomType="MouseWheel",s=e.wheelDelta>0?"zoomIn":"zoomOut"),""!==s&&(i.isZoomBtnClick=!0,i.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:t,y:o,type:s,isResize:null}}),i.notify("draw",{prop:"redrawDownScale"}),(i.isCropTab||i.activeObj.shape)&&(i.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),i.notify("freehand-draw",{prop:"resetStraightenPoint"})),i.isStraightening&&(i.notify("draw",{prop:"resetStraightenDestPoints"}),i.notify("draw",{prop:"setDestForStraighten"})))}},e.prototype.textKeyDown=function(e){var t=this.parent;if(0===t.activeObj.rotatedAngle){"\r"===String.fromCharCode(e.which)&&(this.textRow+=1),t.textArea.setAttribute("rows",this.textRow.toString()),t.textArea.style.height="auto",t.textArea.style.height=t.textArea.scrollHeight+"px",t.notify("shape",{prop:"setTextBoxWidth",onPropertyChange:!1,value:{e}}),g.Browser.isDevice&&(t.textArea.style.width=parseFloat(t.textArea.style.width)+t.textArea.style.fontSize+"px");var o=t.textArea.value.split("\n");this.textRow=o.length,t.textArea.setAttribute("rows",this.textRow.toString()),this.isInitialTextEdited=!1}},e.prototype.clearSelection=function(e){var t=this.parent;!t.disabled&&t.isImageLoaded&&(e?t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}):(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"))},e.prototype.setDragDirection=function(e,t){var o=7.5,i=this.parent,r=i.activeObj.activePoint;i.img.destWidth>i.img.destHeight?(r.startX=this.dragPoint.startX=e/2-t/2+o,r.startY=this.dragPoint.startY=t/2-t/2+o,r.endX=e/2+t/2-o,r.endY=t/2+t/2-o):(r.startY=this.dragPoint.startX=t/2-e/2+o,r.endY=t/2+e/2-o,r.startX=this.dragPoint.startX=o,r.endX=e-o)},e.prototype.calcShapeRatio=function(e,t,o,i){for(var r=this.parent,a=r.activeObj.activePoint,n=7.5,s=o,l=i,p=s>=l?s:l,h=p*(e/t),d=p,c=this.getScale(h,s),u=[],g=r.img,v=g.destLeft,f=g.destTop,m=g.destWidth,b=g.destHeight,C=0;C<2;C++)0===C?u.push(h*c):u.push(d*c);h=u[0],d=u[1];var y=this.getScale(d,l),x=[];for(C=0;C<2;C++)0===C?x.push(h*y):x.push(d*y);h=x[0],d=x[1],a.width=h,a.height=d,a.startX=(this.dragPoint.startX=(s-h)/2)+n,a.startY=(this.dragPoint.startY=(l-d)/2)+n,a.endX=a.startX+a.width,a.endY=a.startY+a.height,a.startX<v&&v+m>r.lowerCanvas.clientWidth&&(a.startX=v,a.endX=a.startX+h-n),a.startY<f&&f+b>r.lowerCanvas.clientHeight&&(a.startY=f,a.endY=a.startY+d-n),a.width=a.endX-a.startX,a.height=a.endY-a.startY},e.prototype.getScale=function(e,t){return e>t?t/e:1},e.prototype.findTarget=function(e,t,o){var i=this.parent;if("mousedown"===o.toLowerCase()||"touchstart"===o.toLowerCase()){var r=!1;i.activeObj.shape&&"crop"===i.activeObj.shape.split("-")[0]&&(r=!0),this.findTargetObj(e,t,r),this.updateCursorStyles(e,t,o)}else{var a=i.activeObj,n=a.topLeftCircle,s=a.topCenterCircle,l=a.topRightCircle,p=a.centerLeftCircle,h=a.centerRightCircle,d=a.bottomLeftCircle,c=a.bottomCenterCircle,u=a.bottomRightCircle;switch(this.dragElement.toLowerCase()){case"nw-resize":n.startX=e,n.startY=t;break;case"n-resize":s.startX=e,s.startY=t;break;case"ne-resize":l.startX=e,l.startY=t;break;case"w-resize":p.startX=e,p.startY=t;break;case"e-resize":h.startX=e,h.startY=t;break;case"sw-resize":d.startX=e,d.startY=t;break;case"s-resize":c.startX=e,c.startY=t;break;case"se-resize":u.startX=e,u.startY=t;break;default:this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t)}}},e.prototype.findTargetObj=function(e,t,o){var i=this.parent,r=!1;if(0!==i.objColl.length&&!i.currObjType.isCustomCrop&&!o){for(var a=0,n=void 0,s=0;s<i.objColl.length;s++){var l=i.upperCanvas.style.cursor;this.setCursor(e,t);var p=(0,g.extend)({},i.objColl[s],{},!0),h=p.topLeftCircle.radius;if("line"===p.shape||"arrow"===p.shape){for(var d=0;d<p.pointColl.length;d++)if(e>=p.pointColl[d].x-2*h&&e<=p.pointColl[d].x+2*h&&t>=p.pointColl[d].y-2*h&&t<=p.pointColl[d].y+2*h){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(p.activePoint)){n=s;break}this.isTouch||"move"===i.cursor||"grab"===i.cursor||this.isShapeInserted?(0===a||a<p.order)&&(a=p.order,n=s):i.objColl[s].currIndex===this.tempActiveObj.currIndex&&(n=s);break}}else if("path"===p.shape){var c=this.setCursorForPath(p,e,t,i.upperCanvas);if("default"!==c&&"grab"!==c){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(p.activePoint)){n=s;break}this.isTouch||"move"===i.cursor||"grab"===i.cursor||this.isShapeInserted?(0===a||a<p.order)&&(a=p.order,n=s):i.objColl[s].currIndex===this.tempActiveObj.currIndex&&(n=s)}}else if(0!==p.rotatedAngle){var u=this.setCursorForRotatedObject(p,e,t,i.upperCanvas);if("default"!==u&&"grab"!==u){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(p.activePoint)){n=s;break}this.isTouch||"move"===i.cursor||"grab"===i.cursor||this.isShapeInserted?(0===a||a<p.order&&("redact"!==p.shape||"redact"===i.drawingShape))&&(a=p.order,n=s):i.objColl[s].currIndex===this.tempActiveObj.currIndex&&(n=s)}}else{var v=this.getTransRotationPoint(p);if(e>=p.activePoint.startX-2*h&&e<=p.activePoint.endX+2*h&&t>=p.activePoint.startY-2*h&&t<=p.activePoint.endY+2*h||v&&e>=v.x-2*h&&e<=v.x+2*h&&t>=v.y-2*h&&t<=v.y+2*h){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(p.activePoint)){n=s;break}this.isTouch||"move"===l||"grabbing"===l||this.isShapeInserted||"move"===i.cursor||"grabbing"===i.cursor?(0===a||a<p.order&&("redact"!==p.shape||"redact"===i.drawingShape))&&(a=p.order,n=s):i.objColl[s].currIndex===this.tempActiveObj.currIndex&&(n=s)}}}if((0,g.isNullOrUndefined)(n))i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),r=!1;else{this.tempObjColl=(0,g.extend)([],i.objColl,[],!0),i.currObjType.isCustomCrop=!1,i.activeObj=(0,g.extend)({},i.objColl[n],{},!0);var f=(0,g.extend)({},i.objColl[n],{},!0);if(i.objColl.splice(n,1),0===i.transform.degree){var m=this.lowerContext.filter;this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter="none",i.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),i.activeObj=(0,g.extend)({},m,{},!0),this.lowerContext.filter=m,this.getCurrentFlipState()}else{var b=(0,g.extend)({},i.panPoint.totalPannedInternalPoint,{},!0),C={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),i.panPoint.totalPannedInternalPoint=b,i.img.destLeft=C.startX,i.img.destTop=C.startY,i.img.destWidth=C.width,i.img.destHeight=C.height,i.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}})}i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context: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}}),i.activeObj=(0,g.extend)({},f,{},!0),this.setActivePoint(),i.activeObj=(0,g.extend)({},f,{},!0);var y=(0,g.extend)({},i.activeObj.strokeSettings,{},!0);i.notify("draw",{prop:"setTempStrokeSettings",onPropertyChange:!1,value:{tempStrokeSettings:y}});var x=(0,g.extend)({},i.activeObj.textSettings,{},!0);i.notify("draw",{prop:"setTempTextSettings",onPropertyChange:!1,value:{tempTextSettings:x}});var P=this.updatePrevShapeSettings(),w={cancel:!1,action:"select",previousShapeSettings:P,currentShapeSettings:P,allowShapeOverflow:this.allowOutofBound()};"line"!==i.activeObj.shape&&"arrow"!==i.activeObj.shape||(w.currentShapeSettings.width=i.activeObj.activePoint.endX-i.activeObj.activePoint.startX,w.currentShapeSettings.height=i.activeObj.activePoint.endY-i.activeObj.activePoint.startY),this.isCropSelection=!1;var j=void 0;if(void 0!==i.activeObj.shape&&(j=i.activeObj.shape.split("-")),void 0!==j&&"crop"===j[0]&&(this.isCropSelection=!0),this.isCropSelection||"redact"===i.activeObj.shape){this.isMouseDown?w.action="resize-start":this.isMouseUp&&(w.action="resize-end");var S={action:w.action,previousSelectionSettings:{type:i.getSelectionType(i.activeObj.shape),startX:w.previousShapeSettings.startX,startY:w.previousShapeSettings.startY,width:w.previousShapeSettings.width,height:w.previousShapeSettings.height},currentSelectionSettings:{type:i.getSelectionType(i.activeObj.shape),startX:w.currentShapeSettings.startX,startY:w.currentShapeSettings.startY,width:w.currentShapeSettings.width,height:w.currentShapeSettings.height}};i.trigger("selectionChanging",S),i.editCompleteArgs=S,w.currentShapeSettings.startX=S.currentSelectionSettings.startX,w.currentShapeSettings.startY=S.currentSelectionSettings.startY,w.currentShapeSettings.width=S.currentSelectionSettings.width,w.currentShapeSettings.height=S.currentSelectionSettings.height,this.shapeEvent(w)}else i.trigger("shapeChanging",w),this.shapeEvent(w),i.editCompleteArgs=w;r=!0}}return r},e.prototype.shapeEvent=function(e){var t=this.parent;if(t.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings,allowShapeOverflow:e.allowShapeOverflow}}),t.activeObj.activePoint){var o={prevActObj:null};t.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:o}}),(0,g.isNullOrUndefined)(o.prevActObj)&&t.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:(0,g.extend)({},t.activeObj,{},!0)}}),"image"!==t.activeObj.shape||this.isImageClarity||(this.upgradeImageQuality(),this.isImageClarity=!0),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:t.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}}),this.isShapeInserted||(this.isPreventDragging=this.isShapeDragOut())}},e.prototype.upgradeImageQuality=function(){var e=this.parent;if(e.activeObj.imageCanvas){var t=(0,g.extend)({},e.activeObj,null,!0),o=e.activeObj.imageCanvas.getContext("2d"),i={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.activeObj.imageElement.width,height:e.activeObj.imageElement.height,obj:i,isImgShape:null}}),e.notify("shape",{prop:"updateObj",onPropertyChange:!1,value:{dimObj:i,x:null,y:null}}),o.clearRect(0,0,e.activeObj.imageCanvas.width,e.activeObj.imageCanvas.height),this.applyTransformToImg(o),e.activeObj=t}},e.prototype.applyTransformToImg=function(e){var t=this.parent;t.activeObj.isHorImageFlip&&t.activeObj.isVerImageFlip?(t.activeObj.isHorImageFlip=t.activeObj.isVerImageFlip=!1,t.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:e,isImgAnnotation:!0,isHFlip:!0,isVFlip:!0}})):t.activeObj.isHorImageFlip?(t.activeObj.isHorImageFlip=!1,t.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:e,isImgAnnotation:!0,isHFlip:!0,isVFlip:!1}})):t.activeObj.isVerImageFlip?(t.activeObj.isVerImageFlip=!1,t.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:e,isImgAnnotation:!0,isHFlip:!1,isVFlip:!0}})):t.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:e,isImgAnnotation:!0,isHFlip:!1,isVFlip:!1}})},e.prototype.targetTouches=function(e){var t=this.parent.lowerCanvas.getBoundingClientRect();return[{x:e[0].pageX-t.left,y:e[0].pageY-t.top},{x:e[1].pageX-t.left,y:e[1].pageY-t.top}]},e.prototype.calculateScale=function(e,t){var o=this.getDistance(e[0],e[1]);return this.getDistance(t[0],t[1])/o},e.prototype.getDistance=function(e,t){var o=0,i=0;return e&&t&&(o=e.x-t.x,i=e.y-t.y),Math.sqrt(o*o+i*i)},e.prototype.redrawShape=function(e,t){for(var o=this.parent,i=0,r=o.objColl.length;i<r;i++)if(JSON.stringify(e)===JSON.stringify(o.objColl[i])){if(o.objColl.splice(i,1),e.shape&&"none"===o.textArea.style.display){var a=(0,g.extend)({},e,{},!0);o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),o.rotateFlipColl.length>0&&(0!==o.panPoint.totalPannedClientPoint.x||0!==o.panPoint.totalPannedClientPoint.y)&&o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),e=o.activeObj=a}break}"path"===e.shape&&0===e.pointColl.length||"path"!==e.shape&&0===e.activePoint.width&&0===e.activePoint.height||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.isPreventDragging?(o.activeObj.activePoint.startX>o.img.destLeft&&(this.isPreventDragging=!1),t&&o.activeObj.rotatedAngle,o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):(t&&0!==o.activeObj.rotatedAngle||"redact"===o.activeObj.shape&&(this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}})),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})))},e.prototype.setTimer=function(e){var t=this.parent;this.timer>10&&(clearTimeout(this.timer),this.timer=0,t.notify("shape",{prop:"findTextTarget",onPropertyChange:!1,value:{e}}),g.Browser.isDevice&&this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height))},e.prototype.applyCurrActObj=function(e,t){var o=this.parent,i=!1,r=(0,g.extend)({},o.activeObj,{},!0);if(!(0,g.isNullOrUndefined)(r.activePoint)){var a=r.activePoint,n=a.startX,s=a.startY,l=a.endX,p=a.endY,h=r.topLeftCircle?r.topLeftCircle.radius:0;if(e>=Math.floor(n)&&e<=Math.ceil(l)&&t>=Math.floor(s)&&t<=Math.ceil(p))i=!0;else if(0!==h&&e>=Math.floor(n)-h&&e<=Math.ceil(l)+h&&t>=Math.floor(s)-h&&t<=Math.ceil(p)+h)i=!0,this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]};else if("text"!==r.shape&&"image"!==r.shape||""===this.dragElement)if("line"===r.shape||"arrow"===r.shape){var d={x:n<l?n:l,y:s<p?s:p},c={x:n>l?n:l,y:s>p?s:p};(e>=Math.floor(d.x)-5&&e<=Math.ceil(c.x)+5&&t>=Math.floor(d.y)-5&&t<=Math.ceil(c.y)+5||o.activeObj.preventShapeDragOut)&&(i=!0)}else if("path"===r.shape){"move"===(u=this.setCursorForPath(r,e,t,o.upperCanvas))&&(i=!0)}else if("grabbing"===this.dragElement)i=!0;else if(0!==r.rotatedAngle){var u;("default"!==(u=this.setCursorForRotatedObject(r,e,t,o.upperCanvas))&&"grab"!==u||"n-resize"===this.dragElement||"e-resize"===this.dragElement||"s-resize"===this.dragElement||"w-resize"===this.dragElement)&&(i=!0)}else"block"!==o.textArea.style.display&&"inline-block"!==o.textArea.style.display||(i=!0);else i=!0;if(!i){if((0,g.isNullOrUndefined)(o.activeObj.currIndex)){var v={id:"shape_"+(o.objColl.length+1)};o.notify("shape",{prop:"getNewShapeId",onPropertyChange:!1,value:{obj:v}}),o.activeObj.currIndex=v.id}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.length>0&&JSON.stringify(o.objColl[o.objColl.length-1].activePoint)!==JSON.stringify(o.activeObj.activePoint)&&o.objColl.push((0,g.extend)({},o.activeObj,{},!0));if(["rectangle","ellipse","line","arrow","path","text","image"].indexOf(o.activeObj.shape)>-1){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:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),this.lowerContext.filter=f,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}})}o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}}},e.prototype.getCurrentFlipState=function(){var e=this.parent;if(0!==e.rotateFlipColl.length){var t=(0,g.extend)({},e.panPoint.totalPannedInternalPoint,{},!0);e.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),e.panPoint.totalPannedInternalPoint=t}else e.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1})},e.prototype.setTextBoxStylesToActObj=function(){var e=this.parent;e.activeObj.textSettings.fontFamily=e.textArea.style.fontFamily,e.activeObj.strokeSettings.strokeColor=""!==e.textArea.style.color&&e.textArea.style.color.split("(")[1]&&e.textArea.style.color.split("(")[1].split(",")[0]&&e.textArea.style.color.split("(")[1].split(",")[1]&&e.textArea.style.color.split("(")[1].split(",")[2]&&e.textArea.style.color.split("(")[1].split(",")[3]?this.rgbToHex(parseFloat(e.textArea.style.color.split("(")[1].split(",")[0]),parseFloat(e.textArea.style.color.split("(")[1].split(",")[1]),parseFloat(e.textArea.style.color.split("(")[1].split(",")[2]),parseFloat(e.textArea.style.color.split("(")[1].split(",")[3])):e.textArea.style.color,e.activeObj.strokeSettings.fillColor=""!==e.textArea.style.backgroundColor&&e.textArea.style.backgroundColor.split("(")[1]&&e.textArea.style.backgroundColor.split("(")[1].split(",")[0]&&e.textArea.style.backgroundColor.split("(")[1].split(",")[1]&&e.textArea.style.backgroundColor.split("(")[1].split(",")[2]&&e.textArea.style.backgroundColor.split("(")[1].split(",")[3]?this.rgbToHex(parseFloat(e.textArea.style.backgroundColor.split("(")[1].split(",")[0]),parseFloat(e.textArea.style.backgroundColor.split("(")[1].split(",")[1]),parseFloat(e.textArea.style.backgroundColor.split("(")[1].split(",")[2]),parseFloat(e.textArea.style.backgroundColor.split("(")[1].split(",")[3])):e.textArea.style.backgroundColor,e.activeObj.strokeSettings.outlineColor=""!==e.textArea.style.textShadow&&e.textArea.style.textShadow.split("(")[1]&&e.textArea.style.textShadow.split("(")[1].split(",")[0]&&e.textArea.style.textShadow.split("(")[1].split(",")[1]&&e.textArea.style.textShadow.split("(")[1].split(",")[2]&&e.textArea.style.textShadow.split("(")[1].split(",")[3]?this.rgbToHex(parseFloat(e.textArea.style.textShadow.split("(")[1].split(",")[0]),parseFloat(e.textArea.style.textShadow.split("(")[1].split(",")[1]),parseFloat(e.textArea.style.textShadow.split("(")[1].split(",")[2]),parseFloat(e.textArea.style.textShadow.split("(")[1].split(",")[3])):e.textArea.style.textShadow.match(/^(\s*[\w#]+)\s/)?e.textArea.style.textShadow.match(/^(\s*[\w#]+)\s/)[1].trim():e.textArea.style.textShadow,"bold"===e.textArea.style.fontWeight?e.activeObj.textSettings.bold=!0:e.activeObj.textSettings.bold=!1,"italic"===e.textArea.style.fontStyle?e.activeObj.textSettings.italic=!0:e.activeObj.textSettings.italic=!1,e.activeObj.textSettings.underline=e.activeObj.textSettings.strikethrough=!1,"underline line-through"===e.textArea.style.textDecoration?(e.activeObj.textSettings.underline=!0,e.activeObj.textSettings.strikethrough=!0):"underline"===e.textArea.style.textDecoration?e.activeObj.textSettings.underline=!0:"line-through"===e.textArea.style.textDecoration&&(e.activeObj.textSettings.strikethrough=!0),e.activeObj.textSettings.fontSize=parseFloat(e.textArea.style.fontSize)},e.prototype.rgbToHex=function(e,t,o,i){e=Math.max(0,Math.min(255,Math.round(e))),t=Math.max(0,Math.min(255,Math.round(t))),o=Math.max(0,Math.min(255,Math.round(o))),i=Math.max(0,Math.min(1,i));var r=this.padLeft(e.toString(16),2,"0"),a=this.padLeft(t.toString(16),2,"0"),n=this.padLeft(o.toString(16),2,"0"),s=this.padLeft(Math.round(255*i).toString(16),2,"0");return isNaN(Number(s))?"#"+r+a+n:"#"+r+a+n+s},e.prototype.padLeft=function(e,t,o){for(;e.length<t;)e=o+e;return e},e.prototype.deleteItem=function(){var e=this.parent,t={cancel:!1};if(this.isFhdEditing){this.updateFreehandDrawColorChange();var o=(0,g.extend)({},e.cropObj,{},!0),i={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}}),(p=i.currObj).objColl=(0,g.extend)([],e.objColl,[],!0),p.pointColl=(0,g.extend)([],e.pointColl,[],!0),p.afterCropActions=(0,g.extend)([],e.afterCropActions,[],!0);var r={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:r}}),p.selPointColl=(0,g.extend)([],r.selPointColl,[],!0);var a={freehandDrawSelectedId:null};e.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:a}}),e.notify("freehand-draw",{prop:"deleteFhd",value:{id:a.freehandDrawSelectedId}}),e.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}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),e.notify("freehand-draw",{prop:"resetFreehandDrawSelectedId"})}else if("none"===e.textArea.style.display){a={prevActObj:null};if(e.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(e.activeObj)){var n=e.activeObj.currIndex;e.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null,isFinalCancel:!0}});for(var s=0,l=e.objColl.length;s<l;s++)if(e.objColl[s].currIndex===n){e.objColl.splice(s,1),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}});break}}i={isNewPath:null};if(e.notify("draw",{prop:"getNewPath",value:{obj:i}}),i.isNewPath)e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(e.activeObj.shape){e.objColl.push(e.activeObj);o=(0,g.extend)({},e.cropObj,{},!0);var p,h={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:h}}),(p=h.currObj).objColl=(0,g.extend)([],e.objColl,[],!0),p.pointColl=(0,g.extend)([],e.pointColl,[],!0),p.afterCropActions=(0,g.extend)([],e.afterCropActions,[],!0);r={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:r}}),p.selPointColl=(0,g.extend)([],r.selPointColl,[],!0),e.objColl.pop(),t={cancel:!1,action:"delete",previousShapeSettings:this.updatePrevShapeSettings(),currentShapeSettings:null},e.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),e.clearSelection(),e.trigger("shapeChanging",t),e.editCompleteArgs=t,e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),(0,g.isNullOrUndefined)(p.objColl[p.objColl.length-1].currIndex)||(e.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}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))}e.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}),e.drawingShape&&(this.currentDrawingShape=e.drawingShape.toLowerCase(),e.enableShapeDrawing(e.toPascalCase(e.drawingShape),!0),e.upperCanvas.style.cursor="crosshair")}document.getElementById(e.element.id+"_quickAccessToolbarArea")&&(document.getElementById(e.element.id+"_quickAccessToolbarArea").style.display="none")},e.prototype.updateFreehandDrawColorChange=function(){var e=this.parent,t={freehandSelectedIndex:null};if(e.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:t}}),!(0,g.isNullOrUndefined)(t.freehandSelectedIndex)&&!(0,g.isNullOrUndefined)(e.pointColl[t.freehandSelectedIndex])&&"#42a5f5"===e.pointColl[t.freehandSelectedIndex].strokeColor){var o={tempFreeHandDrawEditingStyles:null};e.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:o}}),e.pointColl[t.freehandSelectedIndex].strokeColor=o.tempFreeHandDrawEditingStyles.strokeColor}},e.prototype.updatePrevShapeSettings=function(e){var t=this.parent,o=[];if((0,g.isNullOrUndefined)(t.activeObj.currIndex)){var i={id:"shape_"+(t.objColl.length+1)};t.notify("shape",{prop:"getNewShapeId",onPropertyChange:!1,value:{obj:i}}),t.activeObj.currIndex=i.id}"text"===t.activeObj.shape&&t.activeObj.textSettings&&(t.activeObj.textSettings.bold&&o.push("bold"),t.activeObj.textSettings.italic&&o.push("italic"),t.activeObj.textSettings.underline&&o.push("underline"),t.activeObj.textSettings.strikethrough&&o.push("strikethrough"));var r=t.activeObj.activePoint,a=r.startX,n=r.startY,s=r.endX,l=r.endY,p=r.width,h=r.height,d=t.activeObj,c=d.keyHistory,u=d.currIndex,v=d.shape,f=d.textSettings,m=d.strokeSettings,b=d.rotatedAngle,C=d.imageElement,y=d.opacity,x={id:(0,g.isNullOrUndefined)(u)?null:u,type:t.toPascalCase(v),startX:a,startY:n,width:p,height:h,strokeColor:m?"text"===v?m.outlineColor:m.strokeColor:null,strokeWidth:m?"text"===v?m.outlineWidth:m.strokeWidth:null,fillColor:m?m.fillColor:null,radius:"ellipse"===v?p/2:null,length:"line"===v||"arrow"===v?p:null,text:"text"===v?c||(f.text?f.text:null):null,fontSize:"text"===v&&f?f.fontSize:null,fontFamily:"text"===v&&f?f.fontFamily:null,fontStyle:"text"===v?o:null,color:"text"===v&&m?m.strokeColor:null,degree:"ellipse"===v||"rectangle"===v||"image"===v||"text"===v?b*(180/Math.PI):null,imageData:"image"===v?C.src:null,opacity:"image"===v?y:null,radiusX:"ellipse"===v?p/2:null,radiusY:"ellipse"===v?h/2:null,endX:"line"===v||"arrow"===v?s:null,endY:"line"===v||"arrow"===v?l:null,arrowHead:"arrow"===v?this.getArrowType(t.activeObj.start):null,arrowTail:"arrow"===v?this.getArrowType(t.activeObj.end):null,points:"path"===v?t.activeObj.pointColl:null,index:t.activeObj.order,transformCollection:"text"===v?this.updateTransColl(t.activeObj):null};return e&&(e.shapeSettingsObj=x),x},e.prototype.updateTransColl=function(e){var t,o=this.parent,i=e.rotateFlipColl;if(i&&i.length>0){var r=void 0;t=[];for(var a=0;a<i.length;a++)"number"==typeof(r=i[a])?t.push({degree:r}):t.push({flip:o.toPascalCase(r)})}return t},e.prototype.getArrowType=function(e){return{none:"None",arrow:"Arrow",arrowSolid:"SolidArrow",circle:"Circle",circleSolid:"SolidCircle",square:"Square",squareSolid:"SolidSquare",bar:"Bar"}[""+e]},e.prototype.getRectanglePoints=function(e,t,o,i,r,a,n){var s=e+o/2,l=t+i/2,p=r*(Math.PI/180),h=Math.cos(p),d=Math.sin(p),c=a-s,u=n-l,g=c*h+u*d,v=-c*d+u*h,f=o/2,m=i/2;return g>=-f&&g<=f&&v>=-m&&v<=m},e.prototype.getTransRotationPoint=function(e,t){var o,i,r=!1,a=!1;if((i=0===e.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-e.shapeDegree)<0&&(i=360+i),e.flipObjColl)for(var n=0,s=e.flipObjColl.length;n<s;n++)"horizontal"===e.flipObjColl[n].toLowerCase()?r=!0:"vertical"===e.flipObjColl[n].toLowerCase()&&(a=!0);return 0===i||360===i?o=a?{x:e.topCenterCircle.startX,y:e.topCenterCircle.startY-e.rotationCircleLine}:{x:e.bottomCenterCircle.startX,y:e.bottomCenterCircle.startY+e.rotationCircleLine}:90===i||-270===i?o=r?{x:e.centerRightCircle.startX+e.rotationCircleLine,y:e.centerLeftCircle.startY}:{x:e.centerLeftCircle.startX-e.rotationCircleLine,y:e.centerLeftCircle.startY}:180===i||-180===i?o=a?{x:e.bottomCenterCircle.startX,y:e.bottomCenterCircle.startY+e.rotationCircleLine}:{x:e.topCenterCircle.startX,y:e.topCenterCircle.startY-e.rotationCircleLine}:270!==i&&-90!==i||(o=r?{x:e.centerLeftCircle.startX-e.rotationCircleLine,y:e.centerLeftCircle.startY}:{x:e.centerRightCircle.startX+e.rotationCircleLine,y:e.centerLeftCircle.startY}),t&&(t.rotationCirclePoint=o),o},e.prototype.getNumTextValue=function(e){var t,o,i,r,a=this.parent.element;if(i=a.querySelector("#"+a.id+"_resizeWidth"),r=a.querySelector("#"+a.id+"_resizeHeight"),i&&r){var n=r.value.replace(/,/g,""),s=i.value.replace(/,/g,"");""===n&&(n=r.placeholder.replace(/,/g,"")),""===s&&(s=i.placeholder.replace(/,/g,"")),t=parseFloat(n),o=parseFloat(s)}return e&&(e.width=o,e.height=t),{x:o,y:t}},e.prototype.isValueUpdated=function(){var e,t,o=!0;return e=this.parent.element.querySelector("#"+this.parent.element.id+"_resizeWidth"),t=this.parent.element.querySelector("#"+this.parent.element.id+"_resizeHeight"),e&&t&&""===t.value.replace(/,/g,"")&&""===e.value.replace(/,/g,"")&&(o=!1),o},e.prototype.allowOutofBound=function(){return-1===["ellipse","rectangle","text","image","redact"].indexOf(this.parent.activeObj.shape)||0!==this.parent.activeObj.rotatedAngle},e}(),D=function(){function e(e){this.textSettings={text:"Enter Text",fontFamily:"",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1,strikethrough:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null,radius:null,outlineColor:"",outlineWidth:null},this.keyHistory="",this.preventFrameAnnotation=!1,this.redactType="blur",this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("shape",this.shape,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("shape",this.shape),this.parent.off("destroyed",this.destroy)},e.prototype.shape=function(e){var t,o=this.parent;switch(this.initShapePvtProps(),e.prop){case"drawEllipse":this.drawEllipse(e.value.x,e.value.y,e.value.radiusX,e.value.radiusY,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.degree,e.value.isSelected);break;case"drawLine":this.drawLine(e.value.startX,e.value.startY,e.value.endX,e.value.endY,e.value.strokeWidth,e.value.strokeColor,e.value.isSelected);break;case"drawArrow":this.drawArrow(e.value.startX,e.value.startY,e.value.endX,e.value.endY,e.value.strokeWidth,e.value.strokeColor,e.value.arrowStart,e.value.arrowEnd,e.value.isSelected);break;case"drawPath":this.drawPath(e.value.pointColl,e.value.strokeWidth,e.value.strokeColor,e.value.isSelected);break;case"drawRectangle":this.drawRectangle(e.value.x,e.value.y,e.value.width,e.value.height,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.degree,e.value.isSelected,e.value.radius);break;case"drawText":this.drawText(e.value.x,e.value.y,e.value.text,e.value.fontFamily,e.value.fontSize,e.value.bold,e.value.italic,e.value.color,e.value.isSelected,e.value.degree,e.value.fillColor,e.value.outlineColor,e.value.outlineWidth,e.value.transformCollection,e.value.underline,e.value.strikethrough);break;case"redrawActObj":this.redrawActObj(e.value.x,e.value.y,e.value.isMouseDown);break;case"apply":this.apply(e.value.shape,e.value.obj,e.value.canvas);break;case"updateShapeChangeEventArgs":this.updateShapeChangeEventArgs(e.value.shapeSettings,e.value.allowShapeOverflow);break;case"updSelChangeEventArgs":this.updSelChangeEventArgs(e.value.selectionSettings);break;case"iterateObjColl":this.iterateObjColl();break;case"updImgRatioForActObj":this.updImgRatioForActObj();break;case"redrawObj":this.redrawObj(e.value.degree);break;case"redraw-text":this.redrawText();break;case"draw-shape":this.drawShape(e.value.obj,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.start,e.value.width,e.value.height);break;case"renderTextArea":this.renderTextArea(e.value.x,e.value.y,e.value.actObj);break;case"setTextBoxWidth":this.setTextBoxWidth(e.value.e);break;case"findTextTarget":this.findTextTarget(e.value.e);break;case"updateFontStyles":this.updateFontStyles(e.value.isTextBox);break;case"applyFontStyle":this.applyFontStyle(e.value.item);break;case"updateFontRatio":this.updateFontRatio(e.value.obj,e.value.isTextArea);break;case"updateFontSize":this.updateFontSize(e.value.obj);break;case"pushActItemIntoObj":this.pushActItemIntoObj();break;case"clearActObj":this.clearActObj();break;case"refreshActiveObj":this.refreshActiveObj();break;case"applyActObj":this.applyActObj(e.value.isMouseDown);break;case"wireEvent":g.EventHandler.add(o.upperCanvas,"dblclick",this.findTextTarget,this),g.EventHandler.add(o.textArea,"mousedown",this.findTextTarget,this),(t=document.getElementById(o.element.id+"_fileUpload"))&&g.EventHandler.add(t,"change",this.fileChanged,this);break;case"unWireEvent":g.EventHandler.remove(o.upperCanvas,"dblclick",this.findTextTarget),g.EventHandler.remove(o.textArea,"mousedown",this.findTextTarget),(t=document.getElementById(o.element.id+"_fileUpload"))&&g.EventHandler.remove(t,"change",this.fileChanged);break;case"getShapeSetting":this.getShapeSetting(e.value.id,e.value.obj);break;case"getShapeSettings":this.getShapeSettings(e.value.obj);break;case"getRedactSettings":this.getRedactSettings(e.value.obj);break;case"isPointsInRange":this.isPointsInRange(e.value.x,e.value.y,e.value.obj);break;case"alignRotateFlipColl":this.alignRotateFlipColl(e.value.collection,e.value.isRotateFlipCollection,e.value.obj);break;case"selectShape":this.selectShape(e.value.id,e.value.obj);break;case"deleteShape":this.deleteShape(e.value.id);break;case"getMaxText":this.getMaxText(e.value.isTextBox,e.value.text,e.value.obj);break;case"setPointCollForLineArrow":e.value.obj.pointColl=this.getLinePoints(e.value.obj.activePoint.startX,e.value.obj.activePoint.startY,e.value.obj.activePoint.endX,e.value.obj.activePoint.endY);break;case"setPointCollForShapeRotation":this.setPointCollForShapeRotation(e.value.obj);break;case"setTextSettings":e.value.textSettings?this.textSettings=e.value.textSettings:e.value.fontFamily?this.textSettings.fontFamily=e.value.fontFamily:e.value.fontSize?this.textSettings.fontSize=e.value.fontSize:e.value.radius&&(this.strokeSettings.radius=e.value.radius);break;case"setStrokeSettings":e.value.strokeSettings?this.strokeSettings=e.value.strokeSettings:e.value.strokeColor?this.strokeSettings.strokeColor=e.value.strokeColor:e.value.fillColor?this.strokeSettings.fillColor=e.value.fillColor:e.value.strokeWidth?this.strokeSettings.strokeWidth=e.value.strokeWidth:e.value.outlineColor?this.strokeSettings.outlineColor=e.value.outlineColor:e.value.radius?this.strokeSettings.radius=e.value.radius:e.value.outlineWidth&&(this.strokeSettings.outlineWidth=e.value.outlineWidth);break;case"getStrokeSettings":e.value.obj.strokeSettings=this.strokeSettings;break;case"setKeyHistory":this.keyHistory=e.value.keyHistory;break;case"getKeyHistory":e.value.obj.keyHistory=this.keyHistory;break;case"setTextBoxPos":this.setTextBoxPos(e.value.actObj,e.value.degree,e.value.flip,e.value.x,e.value.y);break;case"setTextBoxPoints":this.setTextBoxPoints(e.value.actObj,e.value.degree,e.value.flip,e.value.x,e.value.y);break;case"alignTextAreaIntoCanvas":this.alignTextAreaIntoCanvas();break;case"initializeTextShape":this.initializeTextShape(e.value.text,e.value.fontFamily,e.value.fontSize,e.value.bold,e.value.italic,e.value.underline,e.value.strikethrough,e.value.strokeColor,e.value.fillColor,e.value.outlineColor,e.value.outlineWidth);break;case"stopPathDrawing":this.stopPathDrawing(e.value.e,e.value.isApply);break;case"updateArrowRatio":this.updateArrowRatio(e.value.obj);break;case"getSquarePointForRotatedShape":this.getSquarePointForRotatedShape(e.value.obj,e.value.object);break;case"drawImage":this.drawImage(e.value.x,e.value.y,e.value.width,e.value.height,e.value.src,e.value.degree,e.value.isAspectRatio,e.value.opacity,e.value.isSelected);break;case"reset":this.reset();break;case"updateObj":this.updateObj(e.value.dimObj,e.value.x,e.value.y);break;case"straightenShapes":this.straightenShapes();break;case"straightenShapePoints":this.straightenShapePoints(e.value.obj,e.value.isReverse);break;case"straightenPath":this.straightenPath(e.value.obj);break;case"straightenFHD":this.straightenFHD();break;case"getTextBoxPosition":this.getTextBoxPosition(e.value.obj,e.value.object);break;case"setFlipState":this.setFlipState(e.value.x,e.value.y,e.value.obj,e.value.object);break;case"getNewShapeId":e.value.obj.id=this.getNewShapeId();break;case"z-order":this.updateZOrder(e.value.obj,e.value.value);break;case"getSmallestIndex":e.value.obj.index=this.getSmallestIndex();break;case"isIndexInObjColl":e.value.obj.bool=this.isIndexInObjColl(e.value.index);break;case"drawAnnotations":this.drawAnnotations(e.value.ctx,e.value.shape,e.value.pen,e.value.isPreventApply,e.value.x,e.value.y,e.value.panRegion);break;case"updateShapeColl":this.updateShapeColl();break;case"getNewOrder":e.value.obj.order=this.getNewOrder();break;case"getHighestOrder":e.value.obj.order=this.getHighestOrder();break;case"getLowestOrder":e.value.obj.order=this.getLowestOrder();break;case"drawRedact":this.drawRedact(e.value.x,e.value.y,e.value.width,e.value.height,e.value.type,e.value.value);break;case"setRedactType":this.redactType=e.value.redactType}},e.prototype.getModuleName=function(){return"shape"},e.prototype.initShapePvtProps=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d")),(0,g.isNullOrUndefined)(this.shapeImg)&&(this.shapeImg=e.createElement("img",{id:e.element.id+"_shapeImg",attrs:{name:"Image",crossorigin:"anonymous"}})),""===this.textSettings.fontFamily&&(this.textSettings.fontFamily=e.fontFamily.default)},e.prototype.reset=function(){this.textSettings={text:"Enter Text",fontFamily:this.parent.fontFamily.default,fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1,strikethrough:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null,radius:null,outlineColor:"",outlineWidth:null},this.preventFrameAnnotation=!1},e.prototype.drawEllipse=function(e,t,o,i,r,a,n,s,l){this.initializeShape("ellipse");var p=e&&t?{x:e,y:t}:null;this.drawShape("ellipse",r,a,n,p,o,i,null,null,null,s,null,l)},e.prototype.drawLine=function(e,t,o,i,r,a,n){this.initializeShape("line");var s=e&&t?{x:e,y:t}:null,l=o-e,p=i-t;this.drawShape("line",r,a,null,s,l,p,null,null,null,null,null,n)},e.prototype.drawPath=function(e,t,o,i){this.initializeShape("path"),e&&this.drawShape("path",t,o,null,null,null,null,e,null,null,null,null,i)},e.prototype.drawArrow=function(e,t,o,i,r,a,n,s,l){this.initializeShape("arrow");var p=e&&t?{x:e,y:t}:null,h=o-e,d=i-t;this.drawShape("arrow",r,a,null,p,h,d,null,n,s,null,null,l)},e.prototype.drawRectangle=function(e,t,o,i,r,a,n,s,l,p){this.initializeShape("rectangle");var h=e&&t?{x:e,y:t}:null;this.drawShape("rectangle",r,a,n,h,o,i,null,null,null,s,null,l,p)},e.prototype.drawRedact=function(e,t,o,i,r,a){this.initializeShape("redact");var n=e&&t?{x:e,y:t}:null;this.drawShape("redact",null,null,null,n,o,i,null,null,null,null,null,null,null,r,a)},e.prototype.drawText=function(e,t,o,i,r,a,n,s,l,p,h,d,c,u,g,v){this.drawShapeText(o,i,r,a,n,s,e,t,l,p,h,d,c,u,g,v)},e.prototype.initializeShape=function(e){var t=this.parent;this.redrawActObj(),t.activeObj.shape=e,t.currObjType.isCustomCrop=!1},e.prototype.updateWidthHeight=function(e){return e.activePoint.width=e.activePoint.endX-e.activePoint.startX,e.activePoint.height=e.activePoint.endY-e.activePoint.startY,e},e.prototype.setDimension=function(e,t){var o=this.parent,i=o.activeObj.shape;(e&&t||("line"===i||"arrow"===i)&&(e||t))&&(o.activeObj.activePoint.width=e,o.activeObj.activePoint.height=t,"ellipse"===o.currObjType.shape.toLowerCase()&&(o.activeObj.activePoint.width=2*e,o.activeObj.activePoint.height=2*t))},e.prototype.getArrowType=function(e){var t=e;if(e){t={None:"none",Arrow:"arrow",SolidArrow:"arrowSolid",Circle:"circle",SolidCircle:"circleSolid",Square:"square",SolidSquare:"squareSolid",Bar:"bar"}[""+e]}return t},e.prototype.drawShape=function(e,t,o,i,r,a,n,s,l,p,h,d,u,v,f,m){var b=this.parent;if(!b.disabled&&b.isImageLoaded){b.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.redrawActObj();var C=(0,g.extend)([],b.objColl,[],!0);if(b.togglePen=!1,this.keyHistory="",b.upperCanvas.style.display="block",this.refreshActiveObj(),b.currObjType.shape=e=e.toLowerCase(),"freehanddraw"!==e&&""!==e){b.activeObj.shape=e;var y=b.activeObj.strokeSettings;this.upperContext.clearRect(0,0,b.upperCanvas.width,b.upperCanvas.height),(0,g.isNullOrUndefined)(y)&&(y=this.strokeSettings),"path"===e&&s&&(b.activeObj.pointColl=s),null!=d&&(b.activeObj.opacity=d),y.strokeWidth=t||y.strokeWidth;var x=b.activeObj.shape;"rectangle"!==x&&"ellipse"!==x||0!==t||(y.strokeWidth=0),y.strokeColor=o||y.strokeColor,y.fillColor=i||""===i?i:y.fillColor,y.radius=v||y.radius;var P=b.img.destWidth>100?100:b.img.destWidth/2,w=b.img.destHeight>100?100:b.img.destHeight/2;b.activeObj.activePoint.width=P,b.activeObj.activePoint.height=w,"line"===e||"arrow"===e?(b.activeObj.lineDraw="horizontal",b.activeObj.activePoint.height=0,"arrow"===e&&(b.activeObj.activePoint.width+=50,b.activeObj.start=this.getArrowType(l),b.activeObj.end=this.getArrowType(p))):"rectangle"===e?b.activeObj.activePoint.width+=b.activeObj.activePoint.width/2:"redact"===e&&f&&(b.activeObj.redactType=f.toLowerCase(),f===c.Blur?m&&(b.activeObj.redactBlur=m):m&&(b.activeObj.redactPixelate=m),b.activeObj.redactImage=b.createElement("canvas")),this.setDimension(a,n),r?(b.activeObj.activePoint.startX=r.x,b.activeObj.activePoint.startY=r.y,b.activeObj.activePoint.endX=b.activeObj.activePoint.startX+b.activeObj.activePoint.width,b.activeObj.activePoint.endY=b.activeObj.activePoint.startY+b.activeObj.activePoint.height):this.setCenterPoints(),this.setPointCollForLineAndArrow(),"arrow"===e&&(b.activeObj.triangleDirection="right"),b.currObjType.isDragging=b.currObjType.isCustomCrop=!1,this.initShapeProps();var j={shapeSettingsObj:{}};b.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:j}});var S=j.shapeSettingsObj,O={cancel:!1,action:"insert",previousShapeSettings:S,currentShapeSettings:S};b.trigger("shapeChanging",O),b.editCompleteArgs=O,this.updateShapeChangeEventArgs(O.currentShapeSettings,O.allowShapeOverflow),this.setDimension(a,n),b.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),h&&(b.activeObj.rotatedAngle=h*(Math.PI/180),b.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:b.activeObj}})),b.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),b.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),b.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:C}}),"redact"===e?b.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"redact",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):b.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),b.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),b.isPublicMethod&&!u&&b.notify("undo-redo",{prop:"updateUndoRedo",value:{operation:"shapeInsert"},onPropertyChange:!1}),b.isPublicMethod=!1}}},e.prototype.initShapeProps=function(){var e=this.parent;e.activeObj.shapeDegree=e.transform.degree,e.activeObj.shapeFlip=e.transform.currFlipState,e.activeObj.textFlip=e.transform.currFlipState,e.activeObj.flipObjColl=[],e.activeObj.order=this.getNewOrder()},e.prototype.setPointCollForLineAndArrow=function(){var e=this.parent,t=e.activeObj.shape,o=e.activeObj.activePoint,i=o.startX,r=o.startY,a=o.endX,n=o.endY;if(("line"===t||"arrow"===t)&&(e.activeObj.pointColl=this.getLinePoints(i,r,a,n),e.activeObj.pointColl))for(var s=0,l=e.activeObj.pointColl.length;s<l;s++)e.activeObj.pointColl[s].ratioX=(e.activeObj.pointColl[s].x-e.img.destLeft)/e.img.destWidth,e.activeObj.pointColl[s].ratioY=(e.activeObj.pointColl[s].y-e.img.destTop)/e.img.destHeight},e.prototype.prevObjColl=function(){var e=this.parent,t={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:t}}),this.prevObj=t.currObj,this.prevObj.objColl=(0,g.extend)([],e.objColl,[],!0),this.prevObj.pointColl=(0,g.extend)([],e.pointColl,[],!0),this.prevObj.afterCropActions=(0,g.extend)([],e.afterCropActions,[],!0);var o={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),this.prevObj.selPointColl=(0,g.extend)([],o.selPointColl,[],!0)},e.prototype.drawShapeText=function(e,t,o,i,r,a,n,s,l,p,h,d,c,u,v,f){var m=this.parent;if(!m.disabled&&m.isImageLoaded){"freehanddraw"===m.currObjType.shape&&(this.apply(),m.upperCanvas.style.cursor=m.cursor="default",m.currObjType.shape=""),m.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),m.togglePen=!1,this.redrawActObj(),this.prevObjColl(),this.refreshActiveObj(),m.activeObj.shape=m.currObjType.shape="text",m.currObjType.isCustomCrop=!1,this.initializeTextShape(e,t,o,i,r,v,f,a,h,d,c),m.currObjType.isText=m.currObjType.isInitialText=!0,(0,g.isNullOrUndefined)(m.activeObj.textSettings.fontSize)&&(m.getFontSizes(),m.activeObj.textSettings.fontSize=parseInt(m.fontSizeColl[parseInt("3",10)-1].text,10)),m.img.destWidth<100?m.activeObj.textSettings.fontSize=Math.floor(m.img.destWidth/20):m.img.destHeight<100&&(m.activeObj.textSettings.fontSize=Math.floor(m.img.destHeight/20)),m.activeObj.shapeDegree=m.transform.degree,m.activeObj.shapeFlip=m.transform.currFlipState,m.activeObj.flipObjColl=[],this.updateFontStyles(),m.activeObj.order=this.getNewOrder();var b=this.upperContext.measureText(m.activeObj.textSettings.text).width+.5*m.activeObj.textSettings.fontSize,C=m.activeObj.textSettings.fontSize;if(e){m.activeObj.keyHistory=e;var y=this.getMaxText();y=y||m.activeObj.textSettings.text,b=this.upperContext.measureText(y).width+.5*m.activeObj.textSettings.fontSize;var x=e.split("\n");x.length>1&&(C=x.length*m.activeObj.textSettings.fontSize,C+=.25*o)}if((0,g.isNullOrUndefined)(n)||(0,g.isNullOrUndefined)(s)?this.setCenterPoints(!0,b,C):(m.activeObj.activePoint.startX=n,m.activeObj.activePoint.startY=s,m.activeObj.activePoint.endX=m.activeObj.activePoint.startX+b,m.activeObj.activePoint.endY=m.activeObj.activePoint.startY+C),u){m.notify("selection",{prop:"setTransformedShape",onPropertyChange:!1,value:{bool:!0}}),this.setTransformColl(u);var P=m.activeObj;P.shapeDegree=0,P.shapeFlip="";for(var w=0,j=P.rotateFlipColl,S=0;S<j.length;S++)"number"==typeof j[S]&&(w+=j[S]);w%90==0&&Math.abs(w)%180==90&&(P.activePoint.endX=P.activePoint.startX+C,P.activePoint.endY=P.activePoint.startY+b,P.activePoint.width=P.activePoint.endX-P.activePoint.startX,P.activePoint.height=P.activePoint.endY-P.activePoint.startY)}var O={shapeSettingsObj:{}};m.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:O}});var T=O.shapeSettingsObj,k={cancel:!1,action:"insert",previousShapeSettings:T,currentShapeSettings:T};if(m.trigger("shapeChanging",k),m.editCompleteArgs=k,this.drawShapeTextEvent(k),p&&(m.activeObj.rotatedAngle=p*(Math.PI/180),m.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:m.activeObj}}),this.upperContext.clearRect(0,0,m.upperCanvas.width,m.upperCanvas.height),m.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:m.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),m.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),m.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})),e&&e.indexOf("\n")>-1&&m.isPublicMethod){var F=String(m.fontSizeColl.findIndex(function(e){return e.text===String(m.activeObj.textSettings.fontSize)})+1);m.noPushUndo=!0,m.updateFontSize("5"),parseInt(F,10)>0&&m.updateFontSize(F),m.noPushUndo=!1}m.isPublicMethod&&!l&&m.notify("undo-redo",{prop:"updateUndoRedo",value:{operation:"shapeInsert"},onPropertyChange:!1}),m.isPublicMethod=!1}},e.prototype.drawShapeImageEvent=function(e,t){var o=this.parent;this.updateShapeChangeEventArgs(e.currentShapeSettings,e.allowShapeOverflow),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),o.objColl.push(o.activeObj);var i=(0,g.extend)({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeInsert",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.objColl[o.objColl.length-1]}}),t?(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}})):o.okBtn(null,!0),o.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}})},e.prototype.setTransformColl=function(e){var t=this.parent;if(t.activeObj.rotateFlipColl=[],e)for(var o=0;o<e.length;o++)e[o].degree?t.activeObj.rotateFlipColl.push(e[o].degree):t.activeObj.rotateFlipColl.push(e[o].flip.toLowerCase())},e.prototype.drawShapeTextEvent=function(e){var t=this.parent;this.updateShapeChangeEventArgs(e.currentShapeSettings,e.allowShapeOverflow),this.addLetter(t.activeObj.textSettings.text),t.activeObj.textFlip=t.transform.currFlipState,this.updateFontRatio(t.activeObj),t.objColl.push(t.activeObj);var o=(0,g.extend)({},t.cropObj,{},!0);t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeInsert",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}}),t.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:t.objColl[t.objColl.length-1]}}),t.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),t.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})},e.prototype.initializeTextShape=function(e,t,o,i,r,a,n,s,l,p,h){var d=this.parent;this.keyHistory="",d.upperCanvas.style.display="block",d.activeObj.strokeSettings.strokeColor=s||d.activeObj.strokeSettings.strokeColor,d.activeObj.strokeSettings.fillColor=l||d.activeObj.strokeSettings.fillColor,d.activeObj.textSettings.text=e||d.activeObj.textSettings.text,d.activeObj.textSettings.fontFamily=t||d.activeObj.textSettings.fontFamily,d.activeObj.textSettings.fontSize=o||d.activeObj.textSettings.fontSize,d.activeObj.textSettings.bold=(0,g.isNullOrUndefined)(i)?d.activeObj.textSettings.bold:i,d.activeObj.textSettings.italic=(0,g.isNullOrUndefined)(r)?d.activeObj.textSettings.italic:r,d.activeObj.textSettings.underline=(0,g.isNullOrUndefined)(a)?d.activeObj.textSettings.underline:a,d.activeObj.textSettings.strikethrough=(0,g.isNullOrUndefined)(n)?d.activeObj.textSettings.strikethrough:n,d.activeObj.strokeSettings.outlineColor=p||d.activeObj.strokeSettings.outlineColor,d.activeObj.strokeSettings.outlineWidth=h||d.activeObj.strokeSettings.outlineWidth},e.prototype.drawImage=function(e,t,o,i,r,a,n,s,l){this.initializeShape("image"),this.onLoadImgShape(e,t,o,i,r,null,a,n,s,l)},e.prototype.redrawActObj=function(e,t,o){var i,r=this.parent;r.activeObj.shape&&(i=r.activeObj.shape.split("-")),r.activeObj.horTopLine&&r.activeObj.shape&&"crop"!==i[0]&&("block"===r.textArea.style.display||"inline-block"===r.textArea.style.display?(r.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.updateFontRatio(r.activeObj,!0),e&&t?e!==r.activeObj.activePoint.startX&&t!==r.activeObj.activePoint.startY&&this.updateTextFromTextArea():(this.updateTextFromTextArea(),r.textArea.style.transform="",r.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})),this.refreshActiveObj()):this.applyActObj(o))},e.prototype.apply=function(e,t,o){var i=this.parent;if(!i.disabled)if(i.togglePen&&!i.currObjType.isCustomCrop){var r=i.img.destLeft,a=i.img.destTop,n=i.img.destWidth,s=i.img.destHeight;i.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1});var l=this.lowerContext.filter;this.lowerContext.filter="none",i.togglePen=!1,(i.isCircleCrop||i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.img.destLeft=r,i.img.destTop=a,i.img.destWidth=n,i.img.destHeight=s,this.lowerContext.filter=l}else o=o||"original",(0,g.isNullOrUndefined)(i.activeObj.shape)&&(0,g.isNullOrUndefined)(e)?i.currObjType.shape="":i.currObjType.shape=e||i.currObjType.shape,""!==i.currObjType.shape&&(this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),"text"===i.activeObj.shape?i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:t,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}):i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:t}}),i.activeObj.shape=i.currObjType.shape.toLowerCase(),e||""===i.currObjType.shape||i.currObjType.isCustomCrop||i.objColl.push((0,g.extend)({},i.activeObj,{},!0)),this.keyHistory="")},e.prototype.setCenterPoints=function(e,t,o){var i,r,a=this.parent;e&&t&&o?(i=t,r=o):(i=a.activeObj.activePoint.width,r=a.activeObj.activePoint.height),a.activeObj.activePoint.startX=a.lowerCanvas.width/2-i/2,a.activeObj.activePoint.startY=a.lowerCanvas.height/2-r/2,a.activeObj.activePoint.endX=a.lowerCanvas.width/2+i/2,a.activeObj.activePoint.endY=a.lowerCanvas.height/2+r/2},e.prototype.updSelChangeEventArgs=function(e){var t=this.parent;t.activeObj.activePoint={startX:e.startX,startY:e.startY,endX:t.activeObj.activePoint.startX+t.activeObj.activePoint.width,endY:t.activeObj.activePoint.startY+t.activeObj.activePoint.height,width:e.width,height:e.height},t.activeObj.activePoint.endX=t.activeObj.activePoint.startX+t.activeObj.activePoint.width,t.activeObj.activePoint.endY=t.activeObj.activePoint.startY+t.activeObj.activePoint.height},e.prototype.updateShapeChangeEventArgs=function(e,t){var o,i=this.parent;if(e.id&&-1===e.id.indexOf("shape_")&&-1===e.id.indexOf("pen_")&&(i.activeObj.currIndex?i.activeObj.currIndex="shape_"+e.id:i.pointColl[o].id="pen_"+e.id),e.id&&e.id.split("_")[0]&&"pen"===e.id.split("_")[0])o=parseInt(e.id.split("_")[1],10)-1,i.pointColl[o].points=e.points,i.pointColl[o].strokeColor=e.strokeColor,i.pointColl[o].strokeWidth=e.strokeWidth,i.pointColl[o].opacity=e.opacity,e.index&&(i.pointColl[o].order=e.index);else{switch(i.activeObj.activePoint.startX=e.startX,i.activeObj.activePoint.startY=e.startY,e.width&&e.height&&(i.activeObj.activePoint.width=e.width,i.activeObj.activePoint.height=e.height,i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+i.activeObj.activePoint.width,i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+i.activeObj.activePoint.height),"text"!==i.activeObj.shape&&(i.activeObj.strokeSettings.strokeColor=e.strokeColor,i.activeObj.strokeSettings.strokeWidth=e.strokeWidth),i.activeObj.strokeSettings.fillColor=e.fillColor,i.activeObj.opacity=e.opacity,e.index&&(i.activeObj.order=e.index),i.activeObj.preventShapeDragOut=!t,(0,g.isNullOrUndefined)(e.degree)&&(e.degree=0),i.activeObj.shape){case"ellipse":i.activeObj.activePoint.width=2*e.radiusX,i.activeObj.activePoint.height=2*e.radiusY,i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+i.activeObj.activePoint.width,i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+i.activeObj.activePoint.height,e.degree&&(i.activeObj.rotatedAngle=e.degree*(Math.PI/180));break;case"line":case"arrow":i.activeObj.activePoint.width=e.length,i.activeObj.activePoint.endX=e.endX,i.activeObj.activePoint.endY=e.endY,i.activeObj.activePoint.width=i.activeObj.activePoint.startX+i.activeObj.activePoint.width,i.activeObj.activePoint.height=i.activeObj.activePoint.startY+i.activeObj.activePoint.height,"arrow"===i.activeObj.shape&&(i.activeObj.start=this.getArrowType(e.arrowHead),i.activeObj.end=this.getArrowType(e.arrowTail));break;case"text":i.activeObj.keyHistory=i.activeObj.textSettings.text=e.text,i.activeObj.textSettings.fontSize=e.fontSize,i.activeObj.strokeSettings.strokeColor=e.color,i.activeObj.strokeSettings.outlineColor=e.strokeColor,i.activeObj.strokeSettings.outlineWidth=e.strokeWidth,i.activeObj.strokeSettings.fillColor=e.fillColor,i.activeObj.textSettings.fontFamily=e.fontFamily,this.setTransformColl(e.transformCollection),e.degree&&(i.activeObj.rotatedAngle=e.degree*(Math.PI/180)),this.updateFontRatio(i.activeObj);break;case"rectangle":case"image":e.degree&&(i.activeObj.rotatedAngle=e.degree*(Math.PI/180));break;case"path":i.activeObj.pointColl=e.points}if("text"===i.activeObj.shape&&i.activeObj.textSettings){i.activeObj.textSettings.bold=!1,i.activeObj.textSettings.italic=!1,i.activeObj.textSettings.underline=!1,i.activeObj.textSettings.strikethrough=!1;for(var r=0;r<e.fontStyle.length;r++)switch(e.fontStyle[r]){case"bold":i.activeObj.textSettings.bold=!0;break;case"italic":i.activeObj.textSettings.italic=!0;break;case"underline":i.activeObj.textSettings.underline=!0;break;case"strikethrough":i.activeObj.textSettings.strikethrough=!0}}}},e.prototype.addLetter=function(e){var t=this.parent;if("none"===t.textArea.style.display&&(t.currObjType.isText||"text"===t.activeObj.shape)){var o=t.activeObj.textSettings.fontSize;"Backspace"===e?this.keyHistory=this.keyHistory.slice(0,-1):this.keyHistory+=e,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.updateFontStyles();var i=this.upperContext.measureText(this.keyHistory).width+.5*o,r=1.18*o;this.upperContext.fillText(this.keyHistory,t.activeObj.activePoint.startX,t.activeObj.activePoint.startY+o),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.currObjType.isText=!0,t.notify("selection",{prop:"setActivePoint",onPropertyChange:!1,value:{startX:i,startY:r}})}},e.prototype.redrawText=function(){var e=this.parent,t=e.activeObj.textSettings,o=t.fontSize,i=t.fontFamily,r="";t.bold&&(r+="bold "),t.italic&&(r+="italic "),this.upperContext.font=r+o+"px "+i;var a=e.activeObj.keyHistory.split("\n"),n="block"===e.textArea.style.display||"inline-block"===e.textArea.style.display?this.getMaxText(!0):this.getMaxText(),s=this.upperContext.measureText(n).width+.5*o,l=a.length*o*1.18;a.length>1&&(l+=.5*o),e.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:s,height:l}}),e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}}),e.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:e.activeObj}})},e.prototype.updateTextFromTextArea=function(){var e=this.parent,t=!1,o=e.activeObj.textSettings.fontSize,i=(0,g.extend)({},e.activeObj,{},!0),r=(0,g.extend)({},e.cropObj,{},!0),a={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=(0,g.extend)([],e.objColl,[],!0),n.pointColl=(0,g.extend)([],e.pointColl,[],!0),n.afterCropActions=(0,g.extend)([],e.afterCropActions,[],!0);var s={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=(0,g.extend)([],s.selPointColl,[],!0),e.activeObj.keyHistory!==e.textArea.value&&(t=!0),e.activeObj.keyHistory=e.textArea.value,e.textArea.style.display="none",e.textArea.value="",this.updateFontStyles();var l=this.upperContext.measureText(e.activeObj.keyHistory).width+.5*o,p=1.18*o,h=e.activeObj.keyHistory.split("\n");if(h.length>1){p*=h.length,p+=.1*o*h.length;for(var d=[],c=0,u=h.length;c<u;c++)d.push(this.upperContext.measureText(h[c]).width+.5*o);l=Math.max.apply(Math,d)}if(e.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:l,height:p}}),0!==e.activeObj.rotatedAngle){var v=e.activeObj.activePoint.width-i.activePoint.width,f=e.activeObj.activePoint.height-i.activePoint.height,m="";v>0&&f>0?m="widthHeight":0!==v?m="width":0!==f&&(m="height"),e.activeObj.activePoint=(0,g.extend)({},i.activePoint,{},!0),e.notify("selection",{prop:"adjustRotationPoints",onPropertyChange:!1,value:{rectangle:e.activeObj.activePoint,x:v,y:f,angle:e.activeObj.rotatedAngle,type:"text",elem:m}}),e.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:e.activeObj}})}e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}}),this.updImgRatioForActObj(),0!==e.activeObj.rotatedAngle&&e.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:e.activeObj}});var b=!1;for(c=0;c<e.objColl.length;c++)if(e.objColl[c].currIndex===e.activeObj.currIndex){b=!0;break}t?(this.apply(e.activeObj.shape,e.activeObj),b||e.objColl.push((0,g.extend)({},e.activeObj,{},!0)),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"text",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:e.activeObj.keyHistory,currentText:e.textArea.value,previousFilter:null,isCircleCrop:null}})):(this.apply(e.activeObj.shape,e.activeObj),b||e.objColl.push((0,g.extend)({},e.activeObj,{},!0)))},e.prototype.iterateObjColl=function(){var e=this.parent;if(e.objColl.length>0)for(var t=this.getSmallestIndex(),o=(0,g.extend)([],e.objColl,[],!0);o.length>0;){for(var i=!1,r=0;r<o.length;r++){var a=o[r];if((0,g.isNullOrUndefined)(a.order))o.splice(r,1),r--;else if(a.order===t){this.apply(a.shape,a),"redact"===a.shape&&JSON.stringify(a.activePoint)===JSON.stringify(e.activeObj.activePoint)&&a.redactImage!==e.activeObj.redactImage&&(a.redactImage=e.activeObj.redactImage,e.objColl[r]&&JSON.stringify(e.objColl[r].activePoint)===JSON.stringify(a.activePoint)&&(e.objColl[r].redactImage=e.activeObj.redactImage)),this.refreshActiveObj(),t++,this.isIndexInObjColl(t)||t++,o.splice(r,1),i=!0;break}}if(!i)break}},e.prototype.getSmallestIndex=function(){for(var e,t=this.parent,o=0,i=t.objColl.length;o<i;o++){var r=t.objColl[o];(0,g.isNullOrUndefined)(r.order)||((0,g.isNullOrUndefined)(e)||r.order<e)&&(e=r.order)}return e},e.prototype.isIndexInObjColl=function(e){for(var t=this.parent,o=0,i=t.objColl.length;o<i;o++){var r=t.objColl[o];if(!(0,g.isNullOrUndefined)(r.order)&&r.order===e)return!0}return!1},e.prototype.updImgRatioForActObj=function(){var e=this.parent,t={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};this.straightenShapes();var o=e.img,i=o.destLeft,r=o.destTop,a=o.destWidth,n=o.destHeight,s=e.activeObj.activePoint;e.activeObj.imageRatio={startX:(s.startX-i)/a,startY:(s.startY-r)/n,endX:(s.endX-i)/a,endY:(s.endY-r)/n,width:a/s.width,height:n/s.height},e.activeObj.rotationCirclePointColl&&(e.activeObj.rotationCirclePointColl.ratioX=(e.activeObj.rotationCirclePointColl.x-i)/a,e.activeObj.rotationCirclePointColl.ratioY=(e.activeObj.rotationCirclePointColl.y-r)/n),"path"===e.activeObj.shape?this.updatePathRatio(e.activeObj):"arrow"===e.activeObj.shape&&this.updateArrowRatio(e.activeObj),e.img.destLeft=t.startX,e.img.destTop=t.startY,e.img.destWidth=t.width,e.img.destHeight=t.height},e.prototype.zoomObjColl=function(e){var t=this.parent,o={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};if(this.straightenShapes(),t.objColl.length>0){for(var i=0,r=t.objColl.length;i<r;i++){var a=t.objColl[i];if(a.imageRatio&&(a.activePoint.startX=a.imageRatio.startX*t.img.destWidth+t.img.destLeft,a.activePoint.startY=a.imageRatio.startY*t.img.destHeight+t.img.destTop,a.activePoint.endX=a.imageRatio.endX*t.img.destWidth+t.img.destLeft,a.activePoint.endY=a.imageRatio.endY*t.img.destHeight+t.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-t.img.destLeft)/t.img.destWidth,a.pointColl[n].ratioY=(a.pointColl[n].y-t.img.destTop)/t.img.destHeight;"arrow"===a.shape&&this.updateArrowSize(a),0===t.transform.straighten||"line"!==a.shape&&"arrow"!==a.shape||this.straightenShapePoints(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*t.img.destWidth+t.img.destLeft,a.pointColl[l].y=a.pointColl[l].ratioY*t.img.destHeight+t.img.destTop;this.updatePathRatio(a),0!==t.transform.straighten&&this.straightenPath(a)}t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:a.activePoint,obj:a}}),"line"!==a.shape&&"arrow"!==a.shape&&"path"!==a.shape&&0!==a.rotatedAngle&&(this.setPointCollForShapeRotation(a),a.rotationCirclePoint.x=a.rotationCirclePoint.ratioX*t.img.destWidth+t.img.destLeft,a.rotationCirclePoint.y=a.rotationCirclePoint.ratioY*t.img.destHeight+t.img.destTop,a.rotationCirclePointColl&&(a.rotationCirclePointColl.x=a.rotationCirclePointColl.ratioX*t.img.destWidth+t.img.destLeft,a.rotationCirclePointColl.y=a.rotationCirclePointColl.ratioY*t.img.destHeight+t.img.destTop))}if((0,g.isNullOrUndefined)(e)){var h=this.lowerContext.filter;this.lowerContext.filter="none",this.iterateObjColl(),this.lowerContext.filter=h}}t.img.destLeft=o.startX,t.img.destTop=o.startY,t.img.destWidth=o.width,t.img.destHeight=o.height},e.prototype.straightenPath=function(e){for(var t,o=0,i=e.pointColl.length;o<i;o++)t=this.straightenPoints(e.pointColl[o].x,e.pointColl[o].y),e.pointColl[o].x=t.x,e.pointColl[o].y=t.y},e.prototype.straightenFHD=function(){for(var e=this.parent,t=0,o=e.freehandCounter;t<o;t++){e.points=(0,g.extend)([],e.pointColl[t].points,[]);for(var i=e.points.length,r=void 0,a=0;a<i;a++)r=this.straightenPoints(e.points[a].x,e.points[a].y),e.points[a].x=r.x,e.points[a].y=r.y}var n={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}});for(t=0,o=e.freehandCounter;t<o;t++)if(n.selPointColl[t]&&n.selPointColl[t].points)for(i=n.selPointColl[t].points.length,r=void 0,a=0;a<i;a++)r=this.straightenPoints(n.selPointColl[t].points[a].x,n.selPointColl[t].points[a].y),n.selPointColl[t].points[a].x=r.x,n.selPointColl[t].points[a].y=r.y;var s={straightenPoint:null};if(e.notify("freehand-draw",{prop:"getStraightenPoint",onPropertyChange:!1,value:{obj:s}}),s.straightenPoint.x&&s.straightenPoint.y){var l={angle:0};e.notify("freehand-draw",{prop:"getStraightenPointAngle",onPropertyChange:!1,value:{obj:l}});var p=((360===e.transform.straighten?0:e.transform.straighten)-l.angle)*(Math.PI/180);r=this.straightenPoints(s.straightenPoint.x,s.straightenPoint.y,p);0===p&&(r.x=s.straightenPoint.x,r.y=s.straightenPoint.y),e.notify("freehand-draw",{prop:"setStraightenPoint",onPropertyChange:!1,value:{x:r.x,y:r.y}})}},e.prototype.straightenPoints=function(e,t,o){var i=this.parent,r=i.img.destLeft+i.img.destWidth/2,a=i.img.destTop+i.img.destHeight/2;return o=o||i.transform.straighten*(Math.PI/180),{x:Math.cos(o)*(e-r)-Math.sin(o)*(t-a)+r,y:Math.sin(o)*(e-r)+Math.cos(o)*(t-a)+a}},e.prototype.straightenShapes=function(){var e=this.parent,t=e.img,o=t.destLeft,i=t.destTop,r=t.destWidth,a=t.destHeight;if(e.isStraightening&&0!==e.transform.straighten){e.notify("draw",{prop:"updateImgCanvasPoints"});var n={points:null};e.notify("draw",{prop:"getImageCanvasPoints",value:{obj:n}});var s=o+r/2,l=i+a/2,p=-e.transform.straighten*(Math.PI/180),h={x:Math.cos(p)*(n.points[0].x-s)-Math.sin(p)*(n.points[0].y-l)+s,y:Math.sin(p)*(n.points[0].x-s)+Math.cos(p)*(n.points[0].y-l)+l},d=Math.cos(p)*(n.points[1].x-s)-Math.sin(p)*(n.points[1].y-l)+s,c=Math.sin(p)*(n.points[1].x-s)+Math.cos(p)*(n.points[1].y-l)+l,u=(Math.cos(p),n.points[2].x,Math.sin(p),n.points[2].y,Math.sin(p)*(n.points[2].x-s)+Math.cos(p)*(n.points[2].y-l)+l);e.img.destWidth=d-h.x,e.img.destHeight=u-c,e.img.destLeft=h.x,e.img.destTop=h.y}},e.prototype.straightenShapePoints=function(e,t){var o=this.parent,i=o.img,r=i.destLeft,a=i.destTop,n=i.destWidth,s=i.destHeight;if(o.isStraightening&&("line"===e.shape||"arrow"===e.shape)){e.activePoint.width=e.activePoint.endX>e.activePoint.startX?e.activePoint.endX-e.activePoint.startX:e.activePoint.startX-e.activePoint.endX,e.activePoint.height=e.activePoint.endY>e.activePoint.startY?e.activePoint.endY-e.activePoint.startY:e.activePoint.startY-e.activePoint.endY;var l={x:r+n/2,y:a+s/2},p=(t?-o.transform.straighten:o.transform.straighten)*(Math.PI/180),h={x:Math.cos(p)*(e.activePoint.startX-l.x)-Math.sin(p)*(e.activePoint.startY-l.y)+l.x,y:Math.sin(p)*(e.activePoint.startX-l.x)+Math.cos(p)*(e.activePoint.startY-l.y)+l.y},d={x:Math.cos(p)*(e.activePoint.endX-l.x)-Math.sin(p)*(e.activePoint.endY-l.y)+l.x,y:Math.sin(p)*(e.activePoint.endX-l.x)+Math.cos(p)*(e.activePoint.endY-l.y)+l.y};e.activePoint.startX=h.x,e.activePoint.startY=h.y,e.activePoint.endX=d.x,e.activePoint.endY=d.y,e.activePoint.width=e.activePoint.endX>e.activePoint.startX?e.activePoint.endX-e.activePoint.startX:e.activePoint.startX-e.activePoint.endX,e.activePoint.height=e.activePoint.endY>e.activePoint.startY?e.activePoint.endY-e.activePoint.startY:e.activePoint.startY-e.activePoint.endY,o.notify("selection",{prop:"adjustActObjForLineArrow",onPropertyChange:!1,value:{obj:e}})}},e.prototype.redrawObj=function(e){var t=this.parent,o=!1;if(t.objColl.length>0)if("horizontal"===e||"vertical"===e||"Horizontal"===e||"Vertical"===e||"horizontalVertical"===e||"verticalHorizontal"===e)this.updateCurrentActiveObjPoint(e.toLowerCase());else if("number"==typeof e){this.updateCurrentActiveObjPoint(e);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 r=0,a=t.objColl.length;r<a;r++){"crop"!==t.objColl[r].shape.split("-")[0]&&(this.apply(t.objColl[r].shape,t.objColl[r]),o=!0)}o&&t.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:t.frameObj.type,preventImg:!0}}),this.lowerContext.filter=i}},e.prototype.updateCurrentActiveObjPoint=function(e){for(var t,o=this.parent,i=o.img,r=i.destLeft,a=i.destTop,n=i.destWidth,s=i.destHeight,l=0,p=o.objColl.length;l<p;l++){var h=o.objColl[l];if(o.activeObj.shape===h.shape&&o.activeObj.activePoint.startX===h.activePoint.startX&&o.activeObj.activePoint.startY===h.activePoint.startY&&o.activeObj.activePoint.endX===h.activePoint.endX&&o.activeObj.activePoint.endY===h.activePoint.endY&&o.activeObj.currIndex===h.currIndex){t=l;break}}if("horizontal"===e||"vertical"===e||"Horizontal"===e||"Vertical"===e||"horizontalvertical"===e||"verticalhorizontal"===e){if("horizontal"===e||"Horizontal"===e){var d=0;for(p=o.objColl.length;d<p;d++){(h=o.objColl[d]).shapeFlip!==o.transform.currFlipState&&(h.activePoint.startX<=r+n/2?(h.activePoint.endX=r+n-(h.activePoint.startX-r),h.activePoint.startX=h.activePoint.endX-h.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})):h.activePoint.startX>=r+n/2&&(h.activePoint.startX=r+(r+n-h.activePoint.endX),h.activePoint.endX=h.activePoint.startX+h.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})),"line"===h.shape||"arrow"===h.shape||"path"===h.shape?this.flipLineArrowObj(h,"horizontal"):0!==h.rotatedAngle&&(h.rotatedAngle=h.rotatedAngle+2*(Math.PI-h.rotatedAngle),h.rotationCirclePointColl.x<=r+n/2?h.rotationCirclePointColl.x=r+n-(h.rotationCirclePointColl.x-r):h.rotationCirclePointColl.x>=r+n/2&&(h.rotationCirclePointColl.x=r+(r+n-h.rotationCirclePointColl.x)),h.rotationCirclePointColl.ratioX=(h.rotationCirclePointColl.x-r)/n),h.shapeFlip=o.transform.currFlipState,h.imageRatio={startX:(h.activePoint.startX-r)/n,startY:(h.activePoint.startY-a)/s,endX:(h.activePoint.endX-r)/n,endY:(h.activePoint.endY-a)/s,width:n/h.activePoint.width,height:s/h.activePoint.height})}}else if("vertical"===e||"Vertical"===e)for(d=0;d<o.objColl.length;d++){(h=o.objColl[d]).shapeFlip!==o.transform.currFlipState&&(h.activePoint.startY<=a+s/2?(h.activePoint.endY=a+s-(h.activePoint.startY-a),h.activePoint.startY=h.activePoint.endY-h.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})):h.activePoint.startY>=o.lowerCanvas.height/2&&(h.activePoint.startY=a+(a+s-h.activePoint.endY),h.activePoint.endY=h.activePoint.startY+h.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})),"line"===h.shape||"arrow"===h.shape||"path"===h.shape?this.flipLineArrowObj(h,"vertical"):0!==h.rotatedAngle&&(h.rotatedAngle=-h.rotatedAngle,h.rotationCirclePointColl.y<=a+s/2?h.rotationCirclePointColl.y=a+s-(h.rotationCirclePointColl.y-a):h.rotationCirclePointColl.y>=a+s/2&&(h.rotationCirclePointColl.y=a+(a+s-h.rotationCirclePointColl.y)),h.rotationCirclePointColl.ratioY=(h.rotationCirclePointColl.y-a)/s),h.shapeFlip=o.transform.currFlipState,h.imageRatio={startX:(h.activePoint.startX-r)/n,startY:(h.activePoint.startY-a)/s,endX:(h.activePoint.endX-r)/n,endY:(h.activePoint.endY-a)/s,width:n/h.activePoint.width,height:s/h.activePoint.height})}else if("verticalhorizontal"===e||"horizontalvertical"===e)for(d=0,p=o.objColl.length;d<p;d++){(h=o.objColl[d]).shapeFlip!==o.transform.currFlipState&&(h.activePoint.startX<=r+n/2?(h.activePoint.endX=r+n-(h.activePoint.startX-r),h.activePoint.startX=h.activePoint.endX-h.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})):h.activePoint.startX>=r+n/2&&(h.activePoint.startX=r+(r+n-h.activePoint.endX),h.activePoint.endX=h.activePoint.startX+h.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})),h.activePoint.startY<=a+s/2?(h.activePoint.endY=a+s-(h.activePoint.startY-a),h.activePoint.startY=h.activePoint.endY-h.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})):h.activePoint.startY>=o.lowerCanvas.height/2&&(h.activePoint.startY=a+(a+s-h.activePoint.endY),h.activePoint.endY=h.activePoint.startY+h.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:h.activePoint,obj:h}})),"line"!==h.shape&&"arrow"!==h.shape&&"path"!==h.shape||this.flipLineArrowObj(h,e),h.shapeFlip=o.transform.currFlipState,h.imageRatio={startX:(h.activePoint.startX-r)/n,startY:(h.activePoint.startY-a)/s,endX:(h.activePoint.endX-r)/n,endY:(h.activePoint.endY-a)/s,width:n/h.activePoint.width,height:s/h.activePoint.height})}void 0!==t&&(o.activeObj=(0,g.extend)({},o.objColl[t],{},!0))}else if(90===e)this.rotateObjColl();else if(-90===e)for(d=0;d<3;d++)this.rotateObjColl();else if("number"==typeof e)if(e>0)this.rotateObjColl();else for(d=0;d<3;d++)this.rotateObjColl()},e.prototype.rotateObjColl=function(){for(var e=this.parent,t=e.img,o=t.destWidth,i=t.destHeight,r=t.destLeft,a=t.destTop,n=0,s=e.objColl.length;n<s;n++){var l=(p=e.objColl[n]).shape;p.activePoint.startY=a+i*p.imageRatio.startX,p.activePoint.endY=a+i*p.imageRatio.endX,p.activePoint.startX=r+o-o*p.imageRatio.endY,p.activePoint.endX=r+o-o*p.imageRatio.startY,p=this.updateWidthHeight(e.objColl[n]),this.updateFontSize(p),"line"===l||"arrow"===l||"path"===l?(this.rotateLineArrowObj(p),"arrow"===l&&this.updateArrowSize(p)):0!==p.rotatedAngle&&(p.rotationCirclePointColl.y=a+i*p.rotationCirclePointColl.ratioX,p.rotationCirclePointColl.x=r+o-o*p.rotationCirclePointColl.ratioY,p.rotationCirclePointColl.ratioX=(p.rotationCirclePointColl.x-r)/o,p.rotationCirclePointColl.ratioY=(p.rotationCirclePointColl.y-a)/i)}for(n=0,s=e.objColl.length;n<s;n++)e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.objColl[n].activePoint,obj:e.objColl[n]}});for(n=0,s=e.objColl.length;n<s;n++){var p;(p=e.objColl[n]).imageRatio={startX:(p.activePoint.startX-r)/o,startY:(p.activePoint.startY-a)/i,endX:(p.activePoint.endX-r)/o,endY:(p.activePoint.endY-a)/i,width:o/p.activePoint.width,height:i/p.activePoint.height}}},e.prototype.rotateLineArrowObj=function(e){if(!(0,g.isNullOrUndefined)(e.pointColl)){var t=this.parent.img,o=t.destWidth,i=t.destHeight,r=t.destLeft,a=t.destTop;if(e.pointColl.length>0){for(var n=0;n<e.pointColl.length;n++)e.pointColl[n].y=a+i*e.pointColl[n].ratioX,e.pointColl[n].x=r+o-o*e.pointColl[n].ratioY;for(n=0;n<e.pointColl.length;n++)e.pointColl[n].ratioX=(e.pointColl[n].x-r)/o,e.pointColl[n].ratioY=(e.pointColl[n].y-a)/i;var s=void 0;s=(0,g.isNullOrUndefined)(e.pointColl[e.pointColl.length-2])?{x:0,y:0}:{x:e.pointColl[e.pointColl.length-2].x,y:e.pointColl[e.pointColl.length-2].y};var l=e.pointColl[e.pointColl.length-1].x-s.x,p=e.pointColl[e.pointColl.length-1].y-s.y;e.activePoint.startX=e.pointColl[0].x,e.activePoint.startY=e.pointColl[0].y,e.activePoint.endX=e.pointColl[e.pointColl.length-1].x+l/2,e.activePoint.endY=e.pointColl[e.pointColl.length-1].y+p/2,e=this.updateWidthHeight(e)}}},e.prototype.flipLineArrowObj=function(e,t){if(t=t.toLowerCase(),!(0,g.isNullOrUndefined)(e.pointColl)&&("horizontal"===t?this.lineArrowHorizontalFlip(e):("vertical"===t||(this.lineArrowHorizontalFlip(e),e.shapeFlip=""),this.lineArrowVerticalFlip(e)),e.activePoint.startX=e.pointColl[0].x,e.activePoint.startY=e.pointColl[0].y,e.activePoint.endX=e.pointColl[e.pointColl.length-1].x,e.activePoint.endY=e.pointColl[e.pointColl.length-1].y,e.activePoint.startX>e.activePoint.endX)){var o=e.activePoint.startX;e.activePoint.startX=e.activePoint.endX,e.activePoint.endX=o,o=e.activePoint.startY,e.activePoint.startY=e.activePoint.endY,e.activePoint.endY=o}},e.prototype.lineArrowHorizontalFlip=function(e){var t=this.parent,o=t.img,i=o.destWidth,r=o.destHeight,a=o.destLeft,n=o.destTop;if(e.shapeFlip!==t.transform.currFlipState){for(var s=0,l=e.pointColl.length;s<l;s++){var p=e.pointColl[s];p.x<=a+i/2?p.x=a+i-(p.x-a):p.x>=a+i/2&&(p.x=a+(a+i-p.x)),p.ratioX=(p.x-a)/i,p.ratioY=(p.y-n)/r}if("arrow"===e.shape){var h=e.start;e.start=e.end,e.end=h}e.shapeFlip=t.transform.currFlipState}},e.prototype.lineArrowVerticalFlip=function(e){var t=this.parent,o=t.img,i=o.destWidth,r=o.destHeight,a=o.destLeft,n=o.destTop;if(e.shapeFlip!==t.transform.currFlipState){for(var s=0,l=e.pointColl.length;s<l;s++){var p=e.pointColl[s];p.y<=n+r/2?p.y=n+r-(p.y-n):p.y>=n+r/2&&(p.y=n+(n+r-p.y)),p.ratioX=(p.x-a)/i,p.ratioY=(p.y-n)/r}e.shapeFlip=t.transform.currFlipState}},e.prototype.getRotDegOfShape=function(e,t){var o,i=this.parent;(o=0===e.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-e.shapeDegree)<0&&(o=360+o);var r={bool:!1};if(i.notify("selection",{prop:"getTransformedShape",onPropertyChange:!1,value:{obj:r}}),r.bool&&!t&&i.activeObj.rotateFlipColl){o=0;for(var a=0;a<i.activeObj.rotateFlipColl.length;a++)"number"==typeof i.activeObj.rotateFlipColl[a]&&(o+=i.activeObj.rotateFlipColl[a])}return o},e.prototype.renderTextArea=function(e,t,o){var i=this.parent,r={shapeSettingsObj:{}};i.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={cancel:!1,action:"text-edit",previousShapeSettings:a,currentShapeSettings:a};i.trigger("shapeChanging",n),this.updateShapeChangeEventArgs(n.currentShapeSettings,n.allowShapeOverflow);var s=this.getRotDegOfShape(i.activeObj);this.transformTextArea(),i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1});var l=i.element.querySelector("#"+i.element.id+"_zOrderBtn"),p=i.element.querySelector("#"+i.element.id+"_duplicate"),h=i.element.querySelector("#"+i.element.id+"_remove"),d=i.element.querySelector("#"+i.element.id+"_editText"),c=o.strokeSettings.outlineColor,u=o.strokeSettings.outlineWidth,g=[];l&&l.classList.add("e-overlay"),p&&p.classList.add("e-overlay"),h&&h.classList.add("e-overlay"),d&&d.classList.add("e-overlay"),""!==o.strokeSettings.fillColor?i.textArea.style.backgroundColor=o.strokeSettings.fillColor:i.textArea.style.backgroundColor="transparent",i.textArea.style.display="block",i.textArea.style.left=e+"px",i.textArea.style.top=t+"px",i.textArea.style.fontFamily=o.textSettings.fontFamily,i.textArea.style.fontSize=o.textSettings.fontSize+"px",i.textArea.style.color=o.strokeSettings.strokeColor;var v=o.textSettings.fontSize,f=Math.max(1,u/2)*(.5*Math.floor((v-1)/16)+.5);if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$|^[a-zA-Z]+$/.test(o.strokeSettings.outlineColor)){for(var m=-f;m<=f;m++)for(var b=-f;b<=f;b++)0===m&&0===b||g.push(m/2+"px "+b/2+"px 0 "+c);i.textArea.style.textShadow=g.join(", ")}else i.textArea.style.textShadow=null;i.textArea.style.fontWeight=o.textSettings.bold?"bold":"normal",i.textArea.style.fontStyle=o.textSettings.italic?"italic":"normal",i.textArea.style.textDecoration=o.textSettings.underline&&o.textSettings.strikethrough?"underline line-through":o.textSettings.underline?"underline":o.textSettings.strikethrough?"line-through":"none",i.textArea.style.border="2px solid "+i.themeColl[i.theme].primaryColor,i.textArea.value=o.keyHistory,i.textArea.style.overflow="hidden",i.textArea.style.width="auto",i.textArea.style.height="auto",i.textArea.focus();var C=o.activePoint,y=C.width,x=C.height;s%90==0&&s%180!=0&&0!==s?(i.textArea.style.width=x+.25*x+"px",i.textArea.style.height=y+.25*y+"px"):(i.textArea.style.width=y+.25*y+"px",i.textArea.style.height=x+.25*x+"px"),this.setTextBoxWidth();var P={flipColl:null};if(i.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:P}}),P.flipColl.length<=1&&this.setTextBoxHeight(),parseFloat(i.textArea.style.maxHeight)<i.activeObj.textSettings.fontSize&&(i.textArea.style.maxHeight=i.activeObj.textSettings.fontSize+"px"),s%90==0&&s%180!=0?parseFloat(i.textArea.style.left)+parseFloat(i.textArea.style.width)>i.img.destTop+i.img.destHeight&&this.alignTextAreaIntoCanvas():parseFloat(i.textArea.style.left)+parseFloat(i.textArea.style.width)>i.img.destLeft+i.img.destWidth&&this.alignTextAreaIntoCanvas(),0!==o.rotatedAngle){var w=parseFloat(i.textArea.style.left),j=parseFloat(i.textArea.style.top);if(o.flipObjColl.length>0){var S={panRegion:""},O=i.lowerCanvas,T=O.clientWidth,k=O.clientHeight,F={x:0,y:0};i.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:S}}),""!==S.panRegion&&("horizontal"===S.panRegion?(F.x=T-T/2,w=F.x-w+F.x):"vertical"===S.panRegion?(F.y=k-k/2,j=F.y-j+F.y):(w=(F={x:T-T/2,y:k-k/2}).x-w+F.x,j=F.y-j+F.y))}var I=w+parseFloat(i.textArea.style.width),A=j+parseFloat(i.textArea.style.height),z=parseFloat(i.textArea.style.width),D=parseFloat(i.textArea.style.height),R={x:I-z/2,y:A-D/2},L=Math.cos(o.rotatedAngle),E=Math.sin(o.rotatedAngle),X={x:L*(I-R.x)-E*(A-R.y)+R.x,y:E*(I-R.x)+L*(A-R.y)+R.y};if(X.x>i.img.destLeft&&X.x<i.img.destLeft+i.img.destWidth&&X.y>i.img.destTop&&X.y+parseFloat(i.textArea.style.fontSize)<i.img.destTop+i.img.destHeight)i.textArea.style.width=i.textArea.style.width;else for(var Y=0,M=parseFloat(i.textArea.style.width);;)if(Y++,(X={x:L*((I=w+(z-=1))-(R={x:I-z/2,y:A-D/2}).x)-E*(A-R.y)+R.x,y:E*(I-R.x)+L*(A-R.y)+R.y}).x>i.img.destLeft&&X.x<i.img.destLeft+i.img.destWidth&&X.y>i.img.destTop&&X.y+parseFloat(i.textArea.style.fontSize)<i.img.destTop+i.img.destHeight||Y===M){i.textArea.style.width=z+"px";break}}i.notify("selection",{prop:"clearUpperCanvas",onPropertyChange:!1})},e.prototype.setTextBoxWidth=function(e){var t=this.parent;if(0!==t.activeObj.rotatedAngle)return t.textArea.style.whiteSpace="nowrap",t.textArea.style.textOverflow="ellipsis",void(t.textArea.style.display="inline-block");t.textArea.style.whiteSpace="",t.textArea.style.textOverflow="","inline-block"===t.textArea.style.display&&(t.textArea.style.display="block");var o=this.getMaxText(!0);"block"===t.textArea.style.display||"inline-block"===t.textArea.style.display?this.updateFontStyles(!0):this.updateFontStyles();var i=this.upperContext.measureText(o).width+parseFloat(t.textArea.style.fontSize)/2,r=e?this.upperContext.measureText(String.fromCharCode(e.which)).width:0,a=(0,g.extend)({},t.activeObj,{},!0),n="",s=this.getRotDegOfShape(a);if(n=a.shapeFlip!==t.transform.currFlipState?"":t.transform.currFlipState,e&&parseFloat(t.textArea.style.width)<i+r||(0,g.isNullOrUndefined)(e))if(0===s)"horizontal"===n.toLowerCase()?parseFloat(t.textArea.style.left)-t.img.destLeft-i-r>0&&(t.textArea.style.width=i+r+"px"):t.img.destWidth-(parseFloat(t.textArea.style.left)-t.img.destLeft)>i+r&&(t.textArea.style.width=i+r+"px");else if(90===s)"vertical"===n.toLowerCase()?parseFloat(t.textArea.style.top)-t.img.destTop-i-r>0&&(t.textArea.style.width=i+r+"px"):t.img.destHeight-(parseFloat(t.textArea.style.top)-t.img.destTop)>i+r&&(t.textArea.style.width=i+r+"px");else if(180===s){var l=parseFloat(t.textArea.style.left),p=t.img.destLeft;if("horizontal"===n.toLowerCase())t.img.destWidth-(l-p)>i+r&&(t.textArea.style.width=i+r+"px");else l-p-i-r>0&&(t.textArea.style.width=i+r+"px")}else if(270===s){var h=parseFloat(t.textArea.style.top),d=t.img.destTop;if("vertical"===n.toLowerCase())t.img.destHeight-(h-d)>i+r&&(t.textArea.style.width=i+r+"px");else h-d-i-r>0&&(t.textArea.style.width=i+r+"px")}},e.prototype.setTextBoxHeight=function(){var e,t=this.parent,o=(0,g.extend)({},t.activeObj,{},!0),i="",r=this.getRotDegOfShape(o);switch(i=o.textFlip===t.transform.currFlipState?"":""===o.textFlip?t.transform.currFlipState:o.textFlip,r){case 0:"vertical"===i.toLowerCase()?t.textArea.style.maxHeight=t.img.destHeight-(t.img.destHeight-parseFloat(t.textArea.style.top))+"px":(e=parseFloat(t.textArea.style.top)-t.img.destTop,t.textArea.style.maxHeight=t.img.destHeight-e+"px");break;case 90:"horizontal"===i.toLowerCase()?t.textArea.style.maxHeight=t.img.destWidth-(parseFloat(t.textArea.style.left)-t.img.destLeft)+"px":t.textArea.style.maxHeight=parseFloat(t.textArea.style.left)-t.img.destLeft+"px";break;case 180:"vertical"===i.toLowerCase()?(e=parseFloat(t.textArea.style.top)-t.img.destTop,t.textArea.style.maxHeight=t.img.destHeight-e+"px"):t.textArea.style.maxHeight=parseFloat(t.textArea.style.top)-t.img.destTop+"px";break;case 270:"horizontal"===i.toLowerCase()?t.textArea.style.maxHeight=parseFloat(t.textArea.style.left)-t.img.destLeft+"px":t.textArea.style.maxHeight=t.img.destWidth-(parseFloat(t.textArea.style.left)-t.img.destLeft)+"px"}},e.prototype.updatePathRatio=function(e){for(var t=this.parent,o=0,i=e.pointColl.length;o<i;o++){var r=e.pointColl[o];r.ratioX=(r.x-t.img.destLeft)/t.img.destWidth,r.ratioY=(r.y-t.img.destTop)/t.img.destHeight}},e.prototype.stopPathDrawing=function(e,t){var o=this.parent;if("path"===o.activeObj.shape){var i={shape:null};if(o.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:i}}),"path"===i.shape){var r=(0,g.extend)({},o.cropObj,{},!0),a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=(0,g.extend)([],o.objColl,[],!0),n.pointColl=(0,g.extend)([],o.pointColl,[],!0),n.afterCropActions=(0,g.extend)([],o.afterCropActions,[],!0);var s={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=(0,g.extend)([],s.selPointColl,[],!0),o.notify("selection",{prop:"setCurrentDrawingShape",value:{value:""}}),o.currObjType.isDragging=!1,e&&"touchstart"!==e.type&&(0,g.isNullOrUndefined)(t)&&o.activeObj.pointColl.pop(),this.updatePathRatio(o.activeObj),(0,g.isNullOrUndefined)(o.activeObj.imageRatio)&&o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.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}}),o.objColl.pop(),e&&(o.notify("selection",{prop:"mouseUpEventHandler",value:{e}}),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),o.objColl.length>0)){var l=o.activeObj.activePoint,p=o.objColl[o.objColl.length-1].activePoint;Math.floor(l.startX)===Math.floor(p.startX)&&Math.floor(l.startY)===Math.floor(p.startY)&&Math.floor(l.endX)===Math.floor(p.endX)&&Math.floor(l.endY)===Math.floor(p.endY)&&this.refreshActiveObj()}if(o.notify("draw",{prop:"setNewPath",value:{bool:!0}}),o.objColl[o.objColl.length-1]){var h=o.drawingShape;o.notify("selection",{prop:"setCurrentDrawingShape",value:{value:""}}),o.noRedact=!0,o.selectShape(o.objColl[o.objColl.length-1].currIndex),o.notify("selection",{prop:"setCurrentDrawingShape",value:{value:"path"}}),o.drawingShape=h}o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}});var d={shapeSettingsObj:{}};o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:d}});var c=d.shapeSettingsObj,u={cancel:!1,action:"draw-end",previousShapeSettings:c},v={cancel:!1,action:"move",previousShapeSettings:c};o.notify("selection",{prop:"triggerShapeChange",onPropertyChange:!1,value:{shapeResizingArgs:u,shapeMovingArgs:v,type:"mouse-up"}}),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})}}},e.prototype.findTextTarget=function(e){var t=this.parent;if(e){if("text"!==t.activeObj.shape){if("path"===t.activeObj.shape)return void this.stopPathDrawing(e,null);if("dblclick"!==e.type)return;t.notify("selection",{prop:"setPanDown",onPropertyChange:!1,value:{panDown:null}});var o=(0,g.extend)({},t.activeObj,{},!0),i=(0,g.extend)([],t.objColl,[],!0),r={bool:null};if(t.notify("selection",{prop:"findTargetObj",onPropertyChange:!1,value:{x:e.clientX,y:e.clientY,isCrop:!1,obj:r}}),t.objColl=i,!r.bool||"text"!==t.activeObj.shape)return void(t.activeObj=(0,g.extend)({},o,{},!0))}var a,n;if("dblclick"===e.type?(a=e.clientX,n=e.clientY):"touchstart"===e.type&&(a=e.touches[0].clientX,n=e.touches[0].clientY,t.notify("selection",{prop:"setTouchEndPoint",onPropertyChange:!1,value:{x:e.touches[0].clientX,y:e.touches[0].clientY}})),t.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!0}}),t.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!1}}),t.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),(0,g.isNullOrUndefined)(a)||(0,g.isNullOrUndefined)(n))if("block"!==t.textArea.style.display&&"inline-block"!==t.textArea.style.display||""===this.selectedText()||"mousedown"!==e.type)"none"===t.textArea.style.display&&(t.textArea.style.display="block");else{h=t.textArea.value;t.textArea.value+="a",t.textArea.value=h}else{var s=t.lowerCanvas.getBoundingClientRect();a-=s.left,n-=s.top;var l="",p=this.getRotDegOfShape(t.activeObj);l=""===t.activeObj.textFlip?t.activeObj.textFlip===t.transform.currFlipState?"":t.transform.currFlipState:t.activeObj.textFlip===t.transform.currFlipState?"":""===t.transform.currFlipState?t.activeObj.textFlip:t.transform.currFlipState;var h=void 0;if("none"===t.textArea.style.display){h=(0,g.extend)({},t.activeObj,{},!0);for(var d=0;d<t.objColl.length;d++)JSON.stringify(t.activeObj)===JSON.stringify(t.objColl[d])&&t.objColl.splice(d,1);this.refreshActiveObj(),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.lowerContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.notify("draw",{prop:"redrawDownScale"}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),t.activeObj=h,this.updateFontStyles();var c=(0,g.extend)({},t.activeObj,{},!0),u=c.topLeftCircle.radius,v=c.activePoint,f=v.startX,m=v.startY,b=v.endX,C=v.endY,y={x:f+v.width/2,y:m+v.height/2},x=Math.cos(c.rotatedAngle),P=Math.sin(c.rotatedAngle),w={x:x*(f-y.x)-P*(m-y.y)+y.x,y:P*(f-y.x)+x*(m-y.y)+y.y},j={x:x*(b-y.x)-P*(m-y.y)+y.x,y:P*(b-y.x)+x*(m-y.y)+y.y},S={x:x*(f-y.x)-P*(C-y.y)+y.x,y:P*(f-y.x)+x*(C-y.y)+y.y},O={x:x*(b-y.x)-P*(C-y.y)+y.x,y:P*(b-y.x)+x*(C-y.y)+y.y};r={position:null,x:a,y:n,x1:w.x,y1:w.y,x2:j.x,y2:j.y,x3:S.x,y3:S.y,x4:O.x,y4:O.y};if(t.notify("draw",{prop:"checkPointPosition",onPropertyChange:!1,value:{obj:r}}),0!==c.rotatedAngle&&("inside"===r.position||"on"===r.position)||0===c.rotatedAngle&&a>=c.activePoint.startX-2*u&&a<=c.activePoint.endX+2*u&&n>=c.activePoint.startY-2*u&&n<=c.activePoint.endY+2*u){var T;if(this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),4===c.flipObjColl.length&&(c.flipObjColl=[],l="",c.shapeFlip=""),""===l&&c.flipObjColl.length>1&&(l=c.flipObjColl[c.flipObjColl.length-1]),c.flipObjColl.length<=1)a=(T=this.setTextBoxPos(c,p,l,a,n)).x,n=T.y;else a=(T=this.setTextBoxPoints(c,p,l,a,n)).x,n=T.y;if(0!==t.activeObj.rotatedAngle){var k=this.getTextBoxPosition(t.activeObj);a=k.x,n=k.y,a=(k=this.setFlipState(a,n,t.activeObj)).x,n=k.y}this.renderTextArea(a,n,c)}else this.applyActObj()}}}},e.prototype.getTextBoxPosition=function(e,t){var o={x:0,y:0},i=e.activePoint,r=i.startX,a=i.startY,n=i.endX,s=i.endY,l=r+i.width/2,p=a+i.height/2,h=Math.cos(e.rotatedAngle),d=Math.sin(e.rotatedAngle),c={x:h*(r-l)-d*(a-p)+l,y:d*(r-l)+h*(a-p)+p},u={x:h*(n-l)-d*(a-p)+l,y:d*(n-l)+h*(a-p)+p},g={x:h*(r-l)-d*(s-p)+l,y:d*(r-l)+h*(s-p)+p},v={x:h*(n-l)-d*(s-p)+l,y:d*(n-l)+h*(s-p)+p},f=this.getRotDegOfShape(e);return 0===f||360===f?o={x:c.x,y:c.y}:90===f||-270===f?o={x:u.x,y:u.y}:180===f||-180===f?o={x:v.x,y:v.y}:270!==f&&-90!==f||(o={x:g.x,y:g.y}),t&&(t.x=o.x,t.y=o.y),o},e.prototype.setFlipState=function(e,t,o,i){var r=this.parent,a={panRegion:""},n=r.lowerCanvas,s=n.clientWidth,l=n.clientHeight,p={x:0,y:0};return r.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:a}}),""!==a.panRegion&&("horizontal"===a.panRegion?(p.x=s-s/2,e=p.x-e+p.x):"vertical"===a.panRegion?(p.y=l-l/2,t=p.y-t+p.y):(e=(p={x:s-s/2,y:l-l/2}).x-e+p.x,t=p.y-t+p.y)),i&&(i.x=e,i.y=t),{x:e,y:t}},e.prototype.fileChanged=function(e){var t=e.target.files[0],o=t.name&&t.name.split(".").pop().toLowerCase();if(o&&-1===["jpg","jpeg","png","svg","webp","bmp"].indexOf(o))this.refreshActiveObj();else{var i=window.URL.createObjectURL(e.target.files[0]);this.onLoadImgShape(null,null,null,null,i.toString(),!0),document.getElementById(this.parent.element.id+"_fileUpload").value=""}},e.prototype.onLoadImgShape=function(e,t,o,i,r,a,n,s,l,p){var h=this,d=this.parent;"string"==typeof r?this.shapeImg.src=r:(d.inMemoryCanvas.width=r.width,d.inMemoryCanvas.height=r.height,d.inMemoryCanvas.getContext("2d").putImageData(r,0,0),this.shapeImg.src=d.inMemoryCanvas.toDataURL()),this.prevObjColl(),d.activeObj.shape="image",this.initShapeProps(),this.shapeImg.onload=function(){h.upperContext.drawImage(h.shapeImg,0,0,h.shapeImg.width,h.shapeImg.height),h.updateImgCanvas(a,e,t,o,i,n,s,l,p)}},e.prototype.updateImgCanvas=function(e,t,o,i,r,a,n,s,l){var p=this.parent;p.activeObj.imageElement=this.shapeImg,p.activeObj.imageCanvas=p.createElement("canvas");var h={width:0,height:0};if(p.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:h,isImgShape:null}}),i&&r)if(n){var d={ratio:null};p.notify("selection",{prop:"findImageRatio",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:d}}),h=this.resizeImage(i,d.ratio)}else h={width:i,height:r};if(this.updateObj(h,t,o),p.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:p.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),p.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:h,isImgShape:!0}}),i&&r)if(n){var c={ratio:null};p.notify("selection",{prop:"findImageRatio",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:c}}),h=this.resizeImage(i,c.ratio)}else h={width:i,height:r};null!=s&&(p.activeObj.opacity=s),this.updateObj(h,t,o),p.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.shapeImg=null,a&&(p.activeObj.rotatedAngle=a*(Math.PI/180),p.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:p.activeObj}}));var u={shapeSettingsObj:{}};p.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:u}});var g=u.shapeSettingsObj,v={cancel:!1,action:"insert",previousShapeSettings:g,currentShapeSettings:g};p.trigger("shapeChanging",v),p.editCompleteArgs=v,e=e||l,this.drawShapeImageEvent(v,e),p.isPublicMethod&&!l?p.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}):p.isPublicMethod||p.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1}),p.isPublicMethod=!1},e.prototype.updateObj=function(e,t,o){var i=this.parent;i.activeObj.activePoint.width=e.width,i.activeObj.activePoint.height=e.height,i.activeObj.activePoint.startX=t||i.lowerCanvas.width/2-e.width/2,i.activeObj.activePoint.startY=o||i.lowerCanvas.height/2-e.height/2,i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+e.width,i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+e.height},e.prototype.resizeImage=function(e,t){var o=t.split(":"),i=parseInt(o[0],10),r=parseInt(o[1],10);return{width:e,height:Math.round(e*r/i)}},e.prototype.setTextBoxPos=function(e,t,o,i,r){var a={x:i,y:r},n=e.activePoint,s=n.startX,l=n.startY,p=n.endX,h=n.endY;switch(o=o.toLowerCase(),t){case 0:"horizontal"===o?(a.x=p,a.y=l):"vertical"===o?(a.x=s,a.y=h):(a.x=s,a.y=l);break;case 90:"horizontal"===o?(a.x=s,a.y=l):"vertical"===o?(a.x=p,a.y=h):(a.x=p,a.y=l);break;case 180:"horizontal"===o?(a.x=s,a.y=h):"vertical"===o?(a.x=p,a.y=l):(a.x=p,a.y=h);break;case 270:"horizontal"===o?(a.x=p,a.y=h):"vertical"===o?(a.x=s,a.y=l):(a.x=s,a.y=h)}return a},e.prototype.setTextBoxPoints=function(e,t,o,i,r){var a={x:i,y:r},n=e.activePoint,s=n.startX,l=n.startY,p=n.endX,h=n.endY;switch(o=o.toLowerCase(),t){case 0:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===o?(a.x=s,a.y=l):"vertical"===o&&(a.x=p,a.y=h):"horizontal"===o?(a.x=p,a.y=h):"vertical"===o&&(a.x=p,a.y=l);break;case 90:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===o?(a.x=p,a.y=h):"vertical"===o&&(a.x=s,a.y=h):"horizontal"===o?(a.x=s,a.y=h):"vertical"===o&&(a.x=s,a.y=l);break;case 180:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?("horizontal"===o||"vertical"===o)&&(a.x=s,a.y=l):"horizontal"===o?(a.x=s,a.y=l):"vertical"===o&&(a.x=s,a.y=h);break;case 270:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===o?(a.x=s,a.y=l):"vertical"===o&&(a.x=p,a.y=l):"horizontal"===o?(a.x=p,a.y=l):"vertical"===o&&(a.x=p,a.y=h)}return a},e.prototype.selectedText=function(){var e=this.parent,t=e.textArea.selectionStart,o=e.textArea.selectionEnd;return e.textArea.value.substring(t,o)},e.prototype.panObjColl=function(e,t,o){var i=this.parent;if(i.objColl.length>0){for(var r=0,a=i.objColl.length;r<a;r++){var n=i.objColl[r];if(""===o){if(n.activePoint.startX+=e,n.activePoint.endX+=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x+=e),"path"===n.shape)for(var s=0,l=n.pointColl.length;s<l;s++)n.pointColl[s].x+=e;if(n.activePoint.startY+=t,n.activePoint.endY+=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y+=t),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y+=t}if(n=this.updateWidthHeight(n),i.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 p=0,h=n.pointColl.length;p<h;p++)n.pointColl[p].ratioX=(n.pointColl[p].x-i.img.destLeft)/i.img.destWidth,n.pointColl[p].ratioY=(n.pointColl[p].y-i.img.destTop)/i.img.destHeight}this.refreshActiveObj()}var d=this.lowerContext.filter;this.lowerContext.filter="none",this.iterateObjColl(),this.lowerContext.filter=d,this.refreshActiveObj(),i.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:i.frameObj.type,preventImg:!0}})}},e.prototype.updateFontStyles=function(e){var t=this.parent;this.upperContext.strokeStyle=t.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=t.activeObj.strokeSettings.strokeColor;var o="";t.activeObj.textSettings.bold&&(o="bold "),t.activeObj.textSettings.italic&&(o="italic "),t.activeObj.textSettings.bold&&t.activeObj.textSettings.italic&&(o="italic bold ");var i=e?parseFloat(t.textArea.style.fontSize):t.activeObj.textSettings.fontSize,r="block"===t.textArea.style.display||"inline-block"===t.textArea.style.display?t.textArea.style.fontFamily:t.activeObj.textSettings.fontFamily;this.upperContext.font=o+i+"px "+r},e.prototype.applyFontStyle=function(e){var t=this.parent,o={shapeSettingsObj:{}};t.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:o}});var i=o.shapeSettingsObj,r=!1,a=t.objColl.length;this.pushActItemIntoObj(),a!==t.objColl.length&&(r=!0);var n=(0,g.extend)([],t.objColl,[],!0);switch(r&&t.objColl.pop(),"none"===t.textArea.style.display?this.updateFontRatio(t.activeObj):this.updateFontRatio(t.activeObj,!0),e){case"default":this.updateFontStyle(e,n,"normal","normal",!1,!1);break;case"bold":this.updateFontStyle(e,n,"bold","normal",!1,!1);break;case"italic":this.updateFontStyle(e,n,"normal","italic",!1,!1);break;case"bolditalic":this.updateFontStyle(e,n,"bold","italic",!1,!1);break;case"underline":this.updateFontStyle(e,n,"normal","normal",!0,!1);break;case"boldunderline":this.updateFontStyle(e,n,"bold","normal",!0,!1);break;case"italicunderline":this.updateFontStyle(e,n,"normal","italic",!0,!1);break;case"bolditalicunderline":this.updateFontStyle(e,n,"bold","italic",!0,!1);break;case"strikethrough":this.updateFontStyle(e,n,"normal","normal",!1,!0);break;case"boldstrikethrough":this.updateFontStyle(e,n,"bold","normal",!1,!0);break;case"italicstrikethrough":this.updateFontStyle(e,n,"normal","italic",!1,!0);break;case"underlinestrikethrough":this.updateFontStyle(e,n,"normal","normal",!0,!0);break;case"bolditalicstrikethrough":this.updateFontStyle(e,n,"bold","italic",!1,!0);break;case"boldunderlinestrikethrough":this.updateFontStyle(e,n,"bold","normal",!0,!0);break;case"italicunderlinestrikethrough":this.updateFontStyle(e,n,"normal","italic",!0,!0);break;case"bolditalicunderlinestrikethrough":this.updateFontStyle(e,n,"bold","italic",!0,!0)}var s={action:"font-style",currentShapeSettings:(0,g.extend)({},i,{},!0)};s.currentShapeSettings.fontStyle=this.getFontStyleArray(e),t.trigger("shapeChange",s),t.editCompleteArgs=s},e.prototype.getFontStyleArray=function(e){var t=[],o=e.toLowerCase();return o.indexOf("bold")>-1&&t.push("bold"),o.indexOf("italic")>-1&&t.push("italic"),o.indexOf("underline")>-1&&t.push("underline"),o.indexOf("strikethrough")>-1&&t.push("strikethrough"),t},e.prototype.updateFontStyle=function(e,t,o,i,r,a){var n=this.parent,s=n.textArea.style;if("block"===s.display||"inline-block"===s.display){s.fontWeight="bold"===o?"bold":"normal",s.fontStyle="italic"===i?"italic":"normal",s.textDecoration=r&&a?"underline line-through":a?"line-through":r?"underline":"none";var l=["bold"===s.fontWeight?"bold":"","italic"===s.fontStyle?"italic":"","string"==typeof s.textDecoration&&s.textDecoration.indexOf("underline")>-1?"underline":"","string"==typeof s.textDecoration&&s.textDecoration.indexOf("line-through")>-1?"strikethrough":""].filter(Boolean).join(""),p={"":"default",bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",bolditalic:"bolditalic",boldunderline:"boldunderline",boldstrikethrough:"boldstrikethrough",italicunderline:"italicunderline",italicstrikethrough:"italicstrikethrough",underlinestrikethrough:"underlinestrikethrough",bolditalicunderline:"bolditalicunderline",bolditalicstrikethrough:"bolditalicstrikethrough",boldunderlinestrikethrough:"boldunderlinestrikethrough",italicunderlinestrikethrough:"italicunderlinestrikethrough",bolditalicunderlinestrikethrough:"bolditalicunderlinestrikethrough"},h=l in p?p[l]:"default",d=this.getTextAreaWidth(h);s.width=d+"px",this.updateObjColl(e,t)}else this.textSettings.bold=n.activeObj.textSettings.bold="normal"!==o,this.textSettings.italic=n.activeObj.textSettings.italic="normal"!==i,this.textSettings.underline=n.activeObj.textSettings.underline=!!r,this.textSettings.strikethrough=n.activeObj.textSettings.strikethrough=!!a,0===n.activeObj.activePoint.width&&0===n.activeObj.activePoint.height||this.redrawText(),n.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:t}})},e.prototype.updateArrowRatio=function(e){var t,o,i={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:i}}),t=Math.abs(e.activePoint.width)>Math.abs(e.activePoint.height)?Math.abs(e.activePoint.width):Math.abs(e.activePoint.height);for(var r=0,a=["bar","arrow","arrowSolid","circle","square"];r<a.length;r++){o=a[r];var n=t/i.arrowDimension[o].width,s=t/i.arrowDimension[o].height;i.arrowDimension[o].ratioX=n,i.arrowDimension[o].ratioY=s}},e.prototype.updateArrowSize=function(e){var t,o,i={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:i}}),t=Math.abs(e.activePoint.width)>Math.abs(e.activePoint.height)?Math.abs(e.activePoint.width):Math.abs(e.activePoint.height);for(var r=0,a=["bar","arrow","arrowSolid","circle","square"];r<a.length;r++){o=a[r];var n=i.arrowDimension[o].ratioX,s=i.arrowDimension[o].ratioY;i.arrowDimension[o].width=t/n,i.arrowDimension[o].height=t/s}},e.prototype.updateFontRatio=function(e,t){var o=this.parent,i=this.getMaxText(t),r=this.upperContext.measureText(i).width+.5*o.activeObj.textSettings.fontSize,a=o.activeObj.textSettings.fontSize,n=this.getRotDegOfShape(e);if((0,g.isNullOrUndefined)(t))0===n||180===Math.abs(n)?e.textSettings.fontRatio=r/e.textSettings.fontSize:e.textSettings.fontRatio=a/e.textSettings.fontSize;else if(t){var s={bool:!1};o.notify("selection",{prop:"getTransformedShape",onPropertyChange:!1,value:{obj:s}}),s.bool&&0!==n&&180!==Math.abs(n)?e.textSettings.fontRatio=a/parseFloat(o.textArea.style.fontSize):e.textSettings.fontRatio=r/parseFloat(o.textArea.style.fontSize)}},e.prototype.updateFontSize=function(e){var t=this.getRotDegOfShape(e,!0);0===t||180===Math.abs(t)?e.textSettings.fontSize=e.activePoint.width/e.textSettings.fontRatio:e.textSettings.fontSize=e.activePoint.height/e.textSettings.fontRatio},e.prototype.updateObjColl=function(e,t){var o=this.parent,i=(0,g.extend)({},o.cropObj,{},!0),r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=t,a.pointColl=(0,g.extend)([],o.pointColl,[],!0),a.afterCropActions=(0,g.extend)([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=(0,g.extend)([],n.selPointColl,[],!0);var s=o.activeObj.textSettings,l=s.bold,p=s.italic,h=s.underline,d=s.strikethrough;switch(e){case"default":s.bold=!1,s.italic=!1,s.underline=!1,s.strikethrough=!1;break;case"bold":s.bold=!0,s.italic=!1,s.underline=!1,s.strikethrough=!1;break;case"italic":s.bold=!1,s.italic=!0,s.underline=!1,s.strikethrough=!1;break;case"bolditalic":s.bold=!0,s.italic=!0,s.underline=!1,s.strikethrough=!1;break;case"underline":s.bold=!1,s.italic=!1,s.underline=!0,s.strikethrough=!1;break;case"boldunderline":s.bold=!0,s.italic=!1,s.underline=!0,s.strikethrough=!1;break;case"italicunderline":s.bold=!1,s.italic=!0,s.underline=!0,s.strikethrough=!1;break;case"bolditalicunderline":s.bold=!0,s.italic=!0,s.underline=!0,s.strikethrough=!1;break;case"strikethrough":s.bold=!1,s.italic=!1,s.underline=!1,s.strikethrough=!0;break;case"boldstrikethrough":s.bold=!0,s.italic=!1,s.underline=!1,s.strikethrough=!0;break;case"italicstrikethrough":s.bold=!1,s.italic=!0,s.underline=!1,s.strikethrough=!0;break;case"underlinestrikethrough":s.bold=!1,s.italic=!1,s.underline=!0,s.strikethrough=!0;break;case"bolditalicstrikethrough":s.bold=!0,s.italic=!0,s.underline=!1,s.strikethrough=!0;break;case"boldunderlinestrikethrough":s.bold=!0,s.italic=!1,s.underline=!0,s.strikethrough=!0;break;case"italicunderlinestrikethrough":s.bold=!1,s.italic=!0,s.underline=!0,s.strikethrough=!0;break;case"bolditalicunderlinestrikethrough":s.bold=!0,s.italic=!0,s.underline=!0,s.strikethrough=!0}o.objColl.push(o.activeObj),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.objColl.pop(),s.bold=l,s.italic=p,s.underline=h,s.strikethrough=d},e.prototype.pushActItemIntoObj=function(){var e=this.parent;if("none"===e.textArea.style.display)0===e.activeObj.activePoint.width&&0===e.activeObj.activePoint.height||e.objColl.push(e.activeObj);else{var t=(0,g.extend)({},e.activeObj,{},!0);e.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj),e.activeObj=t}},e.prototype.clearActObj=function(){var e=this.parent;"none"===e.textArea.style.display&&(this.refreshActiveObj(),this.applyActObj(),this.refreshActiveObj(),e.currObjType.isCustomCrop=!1)},e.prototype.refreshActiveObj=function(){var e=this.parent;e.activeObj={},e.activeObj.activePoint={startX:0,startY:0,endX:0,endY:0,width:0,height:0},e.activeObj.triangle=[],e.activeObj.triangleRatio=[],e.activeObj.order=null,e.activeObj.flipObjColl=[],e.activeObj.strokeSettings=this.strokeSettings,e.activeObj.textSettings=this.textSettings,e.activeObj.rotatedAngle=0,e.activeObj.opacity=1,e.activeObj.redactType=this.redactType,e.activeObj.redactBlur=e.tempRedactBlur,e.activeObj.redactPixelate=e.tempRedactPixel},e.prototype.removeDuplicates=function(e){for(var t=0;t<e.length;t++)for(var o=e[t],i=0;i<t;i++)if(e[i].currIndex===o.currIndex){e.splice(t,1),t--;break}},e.prototype.applyActObj=function(e){var t=this.parent,o=!1;if(void 0!==t.activeObj.shape&&"text"===t.activeObj.shape&&""===t.activeObj.keyHistory)this.refreshActiveObj(),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height);else{var i=void 0,r=!1;if(void 0!==t.activeObj.shape&&(i=t.activeObj.shape.split("-")),(void 0===i&&t.currObjType.isCustomCrop||void 0!==i&&"crop"===i[0])&&(r=!0),t.activeObj.shape&&!r&&"shape"!==t.activeObj.shape){for(var a=0;a<t.objColl.length;a++)if(JSON.stringify(t.activeObj)===JSON.stringify(t.objColl[a])){o=!0;break}if(!o){(0,g.isNullOrUndefined)(t.activeObj.currIndex)&&(t.activeObj.currIndex=this.getNewShapeId()),(0,g.isNullOrUndefined)(t.activeObj.order)&&(t.activeObj.order=this.getNewOrder()),this.updImgRatioForActObj();var n=t.activeObj.currIndex.split("_"),s=t.objColl.splice(0,parseInt(n[1],10)-1);s.push((0,g.extend)({},t.activeObj,{},!0)),this.removeDuplicates(t.objColl),this.removeDuplicates(s);for(a=0;a<t.objColl.length;a++)for(var l=t.objColl[a],p=0;p<s.length;p++)s[p].currIndex===l.currIndex&&(s.splice(p,1),p--);for(a=0;a<t.objColl.length;a++)s.push(t.objColl[a]);t.objColl=s,s=[],this.refreshActiveObj(),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),t.currObjType.shape="",this.refreshActiveObj(),t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),(0,g.isNullOrUndefined)(e)&&(t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),t.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}))}}}},e.prototype.getNewShapeId=function(){for(var e=this.parent,t=e.objColl.length+1,o=0;o<e.objColl.length;o++)e.objColl[o].currIndex==="shape_"+t&&(t++,o=-1);return"shape_"+t},e.prototype.getNewOrder=function(){var e=this.parent;this.updateShapeColl();for(var t=e.shapeColl.length+1,o=0;o<e.shapeColl.length;o++)e.shapeColl[o].order===t&&(t++,o=-1);return t},e.prototype.getHighestOrder=function(){var e=this.parent;this.updateShapeColl();for(var t=0,o=0;o<e.shapeColl.length;o++)e.shapeColl[o].order>t&&(t=e.shapeColl[o].order);return t},e.prototype.getLowestOrder=function(){var e=this.parent;this.updateShapeColl();for(var t=1,o=0;o<e.shapeColl.length;o++)e.shapeColl[o].order<t&&(t=e.shapeColl[o].order);return t},e.prototype.alignTextAreaIntoCanvas=function(){var e=this.parent,t=e.textArea.value;e.textArea.value="";for(var o=0,i=t.length;o<i;o++)e.textArea.value+=t[o],e.textArea.style.height="auto",e.textArea.style.height=e.textArea.scrollHeight+"px",this.setTextBoxWidth()},e.prototype.transformTextArea=function(){var e=this.parent;if("text"===e.activeObj.shape){e.textArea.style.transformOrigin="0 0";var t=e.activeObj.rotatedAngle*(180/Math.PI),o="",i=this.getRotDegOfShape(e.activeObj);if(e.activeObj.flipObjColl.length>0)for(var r=0;r<e.activeObj.flipObjColl.length;r++)o+=0!==i&&i%90==0&&180!==i?"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?"scale(1, -1)":"scale(-1, 1)":"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?"scale(-1, 1)":"scale(1, -1)",i+=t,("horizontal"===e.activeObj.flipObjColl[r].toLowerCase()||"vertical"===e.activeObj.flipObjColl[r].toLowerCase())&&(e.textArea.style.transform="rotate("+i+"deg)"+o);else i+=t,e.textArea.style.transform="rotate("+i+"deg)"}},e.prototype.getTextAreaWidth=function(e){var t=this.parent,o=t.activeObj.textSettings,i=o.bold,r=o.italic,a=o.underline,n=o.strikethrough;switch(e){case"default":o.bold=!1,o.italic=!1,o.underline=!1,o.strikethrough=!1;break;case"bold":o.bold=!0,o.italic=!1,o.underline=!1,o.strikethrough=!1;break;case"italic":o.bold=!1,o.italic=!0,o.underline=!1,o.strikethrough=!1;break;case"bolditalic":o.bold=!0,o.italic=!0,o.underline=!1,o.strikethrough=!1;break;case"underline":o.bold=!1,o.italic=!1,o.underline=!0,o.strikethrough=!1;break;case"boldunderline":o.bold=!0,o.italic=!1,o.underline=!0,o.strikethrough=!1;break;case"italicunderline":o.bold=!1,o.italic=!0,o.underline=!0,o.strikethrough=!1;break;case"bolditalicunderline":o.bold=!0,o.italic=!0,o.underline=!0,o.strikethrough=!1;break;case"strikethrough":o.bold=!1,o.italic=!1,o.underline=!1,o.strikethrough=!0;break;case"boldstrikethrough":o.bold=!0,o.italic=!1,o.underline=!1,o.strikethrough=!0;break;case"italicstrikethrough":o.bold=!1,o.italic=!0,o.underline=!1,o.strikethrough=!0;break;case"underlinestrikethrough":o.bold=!1,o.italic=!1,o.underline=!0,o.strikethrough=!0;break;case"bolditalicstrikethrough":o.bold=!0,o.italic=!0,o.underline=!1,o.strikethrough=!0;break;case"boldunderlinestrikethrough":o.bold=!0,o.italic=!1,o.underline=!0,o.strikethrough=!0;break;case"italicunderlinestrikethrough":o.bold=!1,o.italic=!0,o.underline=!0,o.strikethrough=!0;break;case"bolditalicunderlinestrikethrough":o.bold=!0,o.italic=!0,o.underline=!0,o.strikethrough=!0}var s,l="none"!==t.textArea.style.display;return this.updateFontStyles(l),s=l?this.upperContext.measureText(t.textArea.value).width+.5*o.fontSize:this.upperContext.measureText(t.activeObj.keyHistory).width+.5*o.fontSize,o.bold=i,o.italic=r,o.underline=a,o.strikethrough=n,s},e.prototype.getRedactObjDetails=function(e){var t=this.parent,o={};switch(o.id=e.currIndex,o.type=t.toPascalCase(e.redactType),o.startX=e.activePoint.startX,o.startY=e.activePoint.startY,o.width=e.activePoint.width,o.height=e.activePoint.height,e.redactType){case"blur":o.blurIntensity=e.redactBlur;break;case"pixelate":o.pixelSize=e.redactPixelate}return o},e.prototype.getObjDetails=function(e){var t=this.parent,o={};o.id=e.currIndex,o.type=t.toPascalCase(e.shape),o.startX=e.activePoint.startX,o.startY=e.activePoint.startY,o.index=e.order;var i={coll:null};switch(e.shape){case"rectangle":o.width=e.activePoint.width,o.height=e.activePoint.height,o.strokeColor=e.strokeSettings.strokeColor,o.fillColor=e.strokeSettings.fillColor,o.strokeWidth=e.strokeSettings.strokeWidth,o.degree=e.rotatedAngle*(180/Math.PI);break;case"ellipse":o.radius=e.activePoint.width/2,o.strokeColor=e.strokeSettings.strokeColor,o.fillColor=e.strokeSettings.fillColor,o.strokeWidth=e.strokeSettings.strokeWidth,o.radiusX=e.activePoint.width/2,o.radiusY=e.activePoint.height/2,o.degree=e.rotatedAngle*(180/Math.PI);break;case"line":case"arrow":if(o.length=e.activePoint.width,o.strokeColor=e.strokeSettings.strokeColor,o.strokeWidth=e.strokeSettings.strokeWidth,o.endX=e.activePoint.endX,o.endY=e.activePoint.endY,"arrow"===e.shape){var r={type:null};t.notify("selection",{prop:"getArrowType",onPropertyChange:!1,value:{type:e.start,obj:r}}),o.arrowHead=r.type,t.notify("selection",{prop:"getArrowType",onPropertyChange:!1,value:{type:e.end,obj:r}}),o.arrowTail=r.type}break;case"text":o.text=e.keyHistory,o.fontSize=e.textSettings.fontSize,o.fontFamily=e.textSettings.fontFamily,o.color=e.strokeSettings.strokeColor,o.strokeColor=e.strokeSettings.outlineColor,o.fillColor=e.strokeSettings.fillColor,o.strokeWidth=e.strokeSettings.outlineWidth,o.fontStyle=[],e.textSettings.bold&&o.fontStyle.push("bold"),e.textSettings.italic&&o.fontStyle.push("italic"),e.textSettings.underline&&o.fontStyle.push("underline"),e.textSettings.strikethrough&&o.fontStyle.push("strikethrough"),o.degree=e.rotatedAngle*(180/Math.PI),t.notify("selection",{prop:"updateTransColl",onPropertyChange:!1,value:{obj:i,object:e}}),o.transformCollection=i.coll;break;case"path":o.strokeColor=e.strokeSettings.strokeColor,o.strokeWidth=e.strokeSettings.strokeWidth,o.points=e.pointColl;break;case"image":o.imageData=e.imageCanvas.toDataURL(),o.degree=e.rotatedAngle*(180/Math.PI),o.width=e.activePoint.width,o.height=e.activePoint.height,o.opacity=e.opacity}return o},e.prototype.getFreehandDrawDetails=function(e){var t=this.parent,o={};return o.id=t.pointColl[e].id,o.type=i.FreehandDraw,o.points=(0,g.extend)([],t.pointColl[e].points),o.strokeColor=t.pointColl[e].strokeColor,o.strokeWidth=t.pointColl[e].strokeWidth,o.index=t.pointColl[e].order,o},e.prototype.getShapeSetting=function(e,t){var o,i=this.parent;if(!i.disabled&&i.isImageLoaded)if("none"!==i.textArea.style.display?i.okBtn(null,!0):this.applyActObj(!0),"shape"===e.split("_")[0]){for(var r,a=0,n=i.objColl.length;a<n;a++)if(i.objColl[a].currIndex===e){r=(0,g.extend)({},i.objColl[a],{},!0);break}o=this.getObjDetails(r)}else"pen"===e.split("_")[0]&&(o=this.getFreehandDrawDetails(parseInt(e.split("_")[1],10)-1));t.shapeDetails=o},e.prototype.getShapeSettings=function(e){var t=this.parent,o=[];if(!t.disabled&&t.isImageLoaded){"none"!==t.textArea.style.display?t.okBtn(null,!0):this.applyActObj(!0);for(var i=0,r=t.objColl.length;i<r;i++){var a=this.getObjDetails(t.objColl[i]);o.push(a)}for(i=0;i<t.freehandCounter;i++){a=this.getFreehandDrawDetails(i);o.push(a)}}e.shapeDetailsColl=o},e.prototype.getRedactSettings=function(e){var t=this.parent,o=[];if(!t.disabled&&t.isImageLoaded){"none"!==t.textArea.style.display?t.okBtn(null,!0):this.applyActObj(!0);for(var i=0,r=t.objColl.length;i<r;i++){var a=this.getRedactObjDetails(t.objColl[i]);o.push(a)}}e.shapeDetailsColl=o},e.prototype.isPointsInRange=function(e,t,o){var i=!1,r=this.parent;!(0,g.isNullOrUndefined)(e)&&!(0,g.isNullOrUndefined)(t)&&e>=r.img.destLeft&&t>=r.img.destTop&&e<=r.img.destLeft+r.img.destWidth&&t<=r.img.destTop+r.img.destHeight&&(i=!0),o.inRange=i},e.prototype.alignRotateFlipColl=function(e,t,o){return e=this.popForDefaultTransformedState(e),e=this.popForDefaultFlipState(e),0===(e=this.popForDefaultRotateState(e)).length&&t&&(this.parent.transform.degree=0,this.parent.transform.currFlipState=""),o.collection=e,e},e.prototype.popForDefaultTransformedState=function(e){for(var t=0,o=0,i=0,r=0,a=0;a<e.length;a++)90===e[a]||"rotateRight"===e[a]?(o=0,i=0,r=0,4===++t&&(e.pop(),e.pop(),e.pop(),e.pop())):-90===e[a]||"rotateLeft"===e[a]?(t=0,i=0,r=0,4===++o&&(e.pop(),e.pop(),e.pop(),e.pop())):"horizontal"===e[a]||"Horizontal"===e[a]||"horizontalflip"===e[a]?(o=0,t=0,r=0,2===++i&&(e.pop(),e.pop())):"vertical"!==e[a]&&"Vertical"!==e[a]&&"verticalflip"!==e[a]||(i=0,o=0,t=0,2===++r&&(e.pop(),e.pop()));return e},e.prototype.popForDefaultFlipState=function(e){for(var t=0,o=e.length-3;t<o;t++){var i="horizontal"===e[t]||"Horizontal"===e[t]||"horizontalFlip"===e[t],r="vertical"===e[t]||"Vertical"===e[t]||"verticalFlip"===e[t],a="horizontal"===e[t+1]||"Horizontal"===e[t+1]||"horizontalFlip"===e[t+1],n="vertical"===e[t+1]||"Vertical"===e[t+1]||"verticalFlip"===e[t+1],s="horizontal"===e[t+2]||"Horizontal"===e[t+2]||"horizontalFlip"===e[t+2],l="vertical"===e[t+2]||"Vertical"===e[t+2]||"verticalFlip"===e[t+2],p="horizontal"===e[t+3]||"Horizontal"===e[t+3]||"horizontalFlip"===e[t+3];(i&&n&&s&&l||r&&a&&l&&p)&&(e.splice(t,4),t-=4)}return e},e.prototype.popForDefaultRotateState=function(e){for(var t=0;t<e.length-1;t++){var o=e[t],i=e[t+1];(90!==o&&"rotateRight"!==o||-90!==i&&"rotateLeft"!==i)&&(-90!==o&&"rotateLeft"!==o||90!==i&&"rotateRight"!==i)||(e.splice(t,2),t-=2)}return e},e.prototype.selectShape=function(e,t){var o=this.parent,i=!1;if(!o.disabled&&o.isImageLoaded)if(this.applyActObj(),"shape"===e.split("_")[0]){for(var r,a=0,n=o.objColl.length;a<n;a++)if(o.objColl[a].currIndex===e){r=(0,g.extend)({},o.objColl[a],{},!0);break}if((0,g.isNullOrUndefined)(r))i=!1;else{i=!0,o.activeObj=r;var s={canvasFilter:null};o.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:s}}),this.lowerContext.filter=s.canvasFilter,o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.activeObj}}),"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}}):"redact"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"redact",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"===e.split("_")[0]){s={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool&&o.okBtn(null,!0);var l={isIndex:!1};o.notify("freehand-draw",{prop:"isFHDIdx",value:{index:parseInt(e.split("_")[1],10)-1,obj:l}}),l.isIndex?(i=!0,o.notify("freehand-draw",{prop:"selectFhd",value:{id:e}}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})):i=!1}t.isSelected=i},e.prototype.deleteShape=function(e){var t=this.parent;if(!t.disabled&&t.isImageLoaded){if(t.activeObj.currIndex&&t.activeObj.currIndex===e)t.notify("selection",{prop:"deleteItem",onPropertyChange:!1});else if(this.applyActObj(),"shape"===e.split("_")[0]){for(var o=0,i=t.objColl.length;o<i;o++)if(t.objColl[o].currIndex===e){t.objColl.splice(o,1);break}}else"pen"===e.split("_")[0]&&t.notify("freehand-draw",{prop:"handle-freehand-draw",value:{id:e}});var r={canvasFilter:null};t.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:r}}),this.lowerContext.filter=r.canvasFilter,this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},e.prototype.getMaxText=function(e,t,o){if((0,g.isNullOrUndefined)(t)&&!(t=e?this.parent.textArea.value:this.parent.activeObj.keyHistory))return t;for(var i,r=t.split("\n"),a=r[0].length,n=r[0],s=1;s<r.length;s++)(i=r[s].length)>a&&(n=r[s],a=i);return o&&(o.maxText=n),n},e.prototype.getLinePoints=function(e,t,o,i){var r,a,n=[];if(e===o){t<i?(r=[e,t],a=[o,i]):(a=[e,t],r=[o,i]);for(var s=this.getSlope(r,a,!0),l=this.getIntercept(r,s),p=r[1];p<=a[1];p++){var h=s*p+l;n.push({x:h,y:p})}}else{e<o?(r=[e,t],a=[o,i]):(a=[e,t],r=[o,i]);for(s=this.getSlope(r,a,!1),l=this.getIntercept(r,s),h=r[0];h<=a[0];h++){p=s*h+l;n.push({x:h,y:p})}}if(Math.floor(e)===Math.floor(o)||n.length<10&&(i-t>10||t-i>10)){n=[];for(var d=Math.min(t,i),c=0;c<Math.abs(Math.floor(i)-Math.floor(t));c++)n.push({x:e,y:d+c});if(n.length>1){var u=void 0;u=(0,g.isNullOrUndefined)(n[n.length-2])?{x:0,y:0}:n[n.length-2];var v=n[n.length-1].x-u.x,f=n[n.length-1].y-u.y;n.push({x:n[n.length-1].x+v/2,y:n[n.length-1].y+f/2})}}else if(Math.floor(t)===Math.floor(i)||n.length<10&&(o-e>10||e-o>10)){n=[];for(var m=Math.min(e,o),b=0;b<Math.abs(Math.floor(o)-Math.floor(e));b++)n.push({x:m+b,y:t});if(n.length>1){u=void 0;u=(0,g.isNullOrUndefined)(n[n.length-2])?{x:0,y:0}:n[n.length-2];v=n[n.length-1].x-u.x,f=n[n.length-1].y-u.y;n.push({x:n[n.length-1].x+v/2,y:n[n.length-1].y+f/2})}}return n},e.prototype.getSlope=function(e,t,o){var i;if(o){if(e[1]===t[1])return null;i=(t[0]-e[0])/(t[1]-e[1])}else{if(e[0]===t[0])return null;i=(t[1]-e[1])/(t[0]-e[0])}return i},e.prototype.getIntercept=function(e,t){return null===t?e[0]:e[1]-t*e[0]},e.prototype.setPointCollForShapeRotation=function(e){var t=this.parent,o=e.activePoint,i=o.startX,r=o.startY,a=o.endX,n=o.endY,s=i+o.width/2,l=r+o.height/2,p=Math.cos(e.rotatedAngle),h=Math.sin(e.rotatedAngle),d={x:p*(i-s)-h*(r-l)+s,y:h*(i-s)+p*(r-l)+l},c={x:p*(a-s)-h*(r-l)+s,y:h*(a-s)+p*(r-l)+l},u={x:p*(i-s)-h*(n-l)+s,y:h*(i-s)+p*(n-l)+l},g={x:p*(a-s)-h*(n-l)+s,y:h*(a-s)+p*(n-l)+l};e.horTopLinePointColl=this.getLinePoints(d.x,d.y,c.x,c.y),e.horTopLinePointColl=this.getLinePoints(d.x,d.y,c.x,c.y),e.horBottomLinePointColl=this.getLinePoints(u.x,u.y,g.x,g.y),e.verLeftLinePointColl=this.getLinePoints(d.x,d.y,u.x,u.y),e.verRightLinePointColl=this.getLinePoints(c.x,c.y,g.x,g.y),e.verLeftLinePointColl.reverse(),e.verRightLinePointColl.reverse();for(var v=0;v<e.horTopLinePointColl.length;v++)e.horTopLinePointColl[v].ratioX=(e.horTopLinePointColl[v].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.horTopLinePointColl[v].ratioY=(e.horTopLinePointColl[v].y-this.parent.img.destTop)/this.parent.img.destHeight;for(v=0;v<e.horBottomLinePointColl.length;v++)e.horBottomLinePointColl[v].ratioX=(e.horBottomLinePointColl[v].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.horBottomLinePointColl[v].ratioY=(e.horBottomLinePointColl[v].y-this.parent.img.destTop)/this.parent.img.destHeight;for(v=0;v<e.verLeftLinePointColl.length;v++)e.verLeftLinePointColl[v].ratioX=(e.verLeftLinePointColl[v].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.verLeftLinePointColl[v].ratioY=(e.verLeftLinePointColl[v].y-this.parent.img.destTop)/this.parent.img.destHeight;for(v=0;v<e.verRightLinePointColl.length;v++)e.verRightLinePointColl[v].ratioX=(e.verRightLinePointColl[v].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.verRightLinePointColl[v].ratioY=(e.verRightLinePointColl[v].y-this.parent.img.destTop)/this.parent.img.destHeight;if("move"!==t.upperCanvas.style.cursor){var f={rotationCirclePoint:null};t.notify("selection",{prop:"getTransRotationPoint",value:{obj:e,object:f}});var m=f.rotationCirclePoint;m&&(e.rotationCirclePointColl={x:p*(m.x-s)-h*(m.y-l)+s,y:h*(m.x-s)+p*(m.y-l)+l},e.rotationCirclePointColl.ratioX=(e.rotationCirclePointColl.x-t.img.destLeft)/t.img.destWidth,e.rotationCirclePointColl.ratioY=(e.rotationCirclePointColl.y-t.img.destTop)/t.img.destHeight)}},e.prototype.getSquarePointForRotatedShape=function(e,t){var o={startX:0,startY:0,endX:0,endY:0,width:0,height:0},i=e.activePoint,r=i.startX,a=i.startY,n=i.endX,s=i.endY,l=r+i.width/2,p=a+i.height/2,h=Math.cos(e.rotatedAngle),d=Math.sin(e.rotatedAngle),c={x:h*(r-l)-d*(a-p)+l,y:d*(r-l)+h*(a-p)+p},u={x:h*(n-l)-d*(a-p)+l,y:d*(n-l)+h*(a-p)+p},g={x:h*(r-l)-d*(s-p)+l,y:d*(r-l)+h*(s-p)+p},v={x:h*(n-l)-d*(s-p)+l,y:d*(n-l)+h*(s-p)+p};return o.startX=c.x,o.startY=c.y,o.endX=c.x,o.endY=c.y,o.startX>u.x&&(o.startX=u.x),o.startX>g.x&&(o.startX=g.x),o.startX>v.x&&(o.startX=v.x),o.startY>u.y&&(o.startY=u.y),o.startY>g.y&&(o.startY=g.y),o.startY>v.y&&(o.startY=v.y),o.endX<u.x&&(o.endX=u.x),o.endX<g.x&&(o.endX=g.x),o.endX<v.x&&(o.endX=v.x),o.endY<u.y&&(o.endY=u.y),o.endY<g.y&&(o.endY=g.y),o.endY<v.y&&(o.endY=v.y),o.width=o.endX-o.startX,o.height=o.endY-o.startY,t&&(t.activePoint=o),o},e.prototype.updateZOrder=function(e,t){var o=this.parent;t=t.toLowerCase();var i=e;if(!(0,g.isNullOrUndefined)(i.order)){var r,a,n=this.getHighestOrder();if(this.updateShapeColl(),0!==o.shapeColl.length){for(var s,l=0;l<o.shapeColl.length;l++)s=o.shapeColl[l],i.id&&i.id.indexOf("pen")>-1?s.id&&s.id===i.id&&o.shapeColl.splice(l,1):s.shape&&s.shape.indexOf("crop-")>-1&&o.shapeColl.splice(l,1);switch(t){case"sendtoback":a=i.order,r=i.order,i.order=1;break;case"sendbackward":i.order-=1,r=i.order;break;case"bringtofront":a=i.order,r=n,i.order=r;break;case"bringforward":i.order+=1,r=i.order}this.reArrangeObjColl(r,t,a),i.id&&i.id.indexOf("pen")>-1&&this.reUpdateShapeColl(i)}}},e.prototype.reArrangeObjColl=function(e,t,o){var i,r=this.parent;switch(t){case"sendtoback":for(var a=0,n=r.shapeColl.length;a<n;a++)(i=r.shapeColl[a]).order<o&&i.order<=e&&(i.order+=1,this.reUpdateShapeColl(i));break;case"sendbackward":for(a=0,n=r.shapeColl.length;a<n;a++)if((i=r.shapeColl[a]).order===e){i.order+=1,this.reUpdateShapeColl(i);break}break;case"bringtofront":for(a=0,n=r.shapeColl.length;a<n;a++)(i=r.shapeColl[a]).order>o&&i.order<=e&&(i.order-=1,this.reUpdateShapeColl(i));break;case"bringforward":for(a=0,n=r.shapeColl.length;a<n;a++)if((i=r.shapeColl[a]).order===e){i.order-=1,this.reUpdateShapeColl(i);break}}},e.prototype.reorderRedact=function(e){var t=e.filter(function(e){return"redact"!==e.shape});return e.filter(function(e){return"redact"===e.shape}).concat(t)},e.prototype.updateShapeColl=function(){var e=this.parent,t=!1,o=1,i=(0,g.extend)([],e.objColl,[],!0);i=this.reorderRedact(i);var r=(0,g.extend)([],e.pointColl,[],!0);if(e.shapeColl.length>0&&e.shapeColl.length===e.objColl.length+e.pointColl.length){for(var a=0;a<e.shapeColl.length;a++){if(e.shapeColl[a].order!==o){t=!1;break}t=!0,o++}if(t){for(a=0;a<e.shapeColl.length;a++)if(e.shapeColl[a].currIndex&&e.shapeColl[a].currIndex.indexOf("shape")>-1){for(var n=0;n<i.length;n++)if(e.shapeColl[a].currIndex===i[n].currIndex){e.shapeColl[a]=(0,g.extend)({},i[n],{},!0),i.splice(n,1);break}}else if(e.shapeColl[a].id&&e.shapeColl[a].id.indexOf("pen")>-1)for(n=0;n<r.length;n++)if(e.shapeColl[a].id===r[n].id){e.shapeColl[a]=(0,g.extend)([],r[n],[],!0),r.splice(n,1);break}return}}i=(0,g.extend)([],e.objColl,[],!0),r=(0,g.extend)([],e.pointColl,[],!0),e.shapeColl=[];for(var s,l=1,p=!1,h=0;(0!==i.length||0!==r.length)&&h<100;){h++,s=p=!1;for(a=0;a<i.length;a++)if(i[a].order===l||!i[a].order&&i[a].shape&&i[a].shape.indexOf("crop-")>-1){e.shapeColl.push((0,g.extend)({},i[a],{},!0)),i[a].shape&&i[a].shape.indexOf("crop-")>-1&&(p=!0),i.splice(a,1),s=!0;break}if(!s)for(a=0;a<r.length;a++)if(r[a].order===l){e.shapeColl.push((0,g.extend)([],r[a],[],!0)),r.splice(a,1),s=!0;break}p||l++}},e.prototype.reUpdateShapeColl=function(e){var t=this.parent;if(e.id&&e.id.indexOf("pen")>-1){if(t.freehandCounter>0)for(var o=0;o<t.freehandCounter;o++)t.pointColl[o].id===e.id&&(t.pointColl[o].order=e.order)}else if(e.currIndex&&e.currIndex.indexOf("shape")>-1)for(o=0;o<t.objColl.length;o++)t.objColl[o].currIndex===e.currIndex&&(t.objColl[o].order=e.order)},e.prototype.drawAnnotations=function(e,t,o,i,r,a,n){var s=this.parent,l=(0,g.extend)({},s.activeObj,{},!0),p=(0,g.extend)([],s.objColl,[],!0),h=(0,g.extend)([],s.pointColl,[],!0),d={selPointColl:null};s.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:d}});var c={selPointColl:null};s.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:c}}),this.updateShapeColl();var u=(0,g.extend)([],s.shapeColl,[],!0);u=this.reorderRedact(u);var v=!1;this.preventFrameAnnotation||(this.preventFrameAnnotation=v=!0);for(var f=0;f<u.length;f++){var m=u[f].id;if(u[f].order||!u[f].order&&u[f].shape&&u[f].shape.indexOf("crop-")>-1||!u[f].order&&"path"===u[f].shape&&"path"===s.drawingShape){if(u[f].currIndex&&u[f].currIndex.indexOf("shape")>-1){if(s.objColl=[],s.objColl.push((0,g.extend)({},u[f],{},!0)),"iterate"===t){var b=this.lowerContext.filter;this.lowerContext.filter="none",this.iterateObjColl(),this.lowerContext.filter=b}else if("zoom"===t||"pan"===t){for(var C=-1,y=0;y<p.length;y++)if(JSON.stringify(p[y])===JSON.stringify(s.objColl[0])){C=y;break}"zoom"===t?this.zoomObjColl(i):this.panObjColl(r,a,n),C>-1&&(p[C]=(0,g.extend)({},s.objColl[0],{},!0))}}else if(u[f].id&&u[f].id.indexOf("pen")>-1)if(s.pointColl=[],s.freehandCounter=0,s.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),s.pointColl.push((0,g.extend)({},u[f],{},!0)),s.notify("freehand-draw",{prop:"pushSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:c.selPointColl[f]}}}),s.freehandCounter=s.pointColl.length,"iterate"===o)s.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:e,points:null}});else if("zoom"===o||"pan"===o){"zoom"===o?s.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:i}}):s.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:r,yDiff:a,panRegion:n}});for(var x=0;x<h.length;x++)if(h[x].id===s.pointColl[0].id){h[x]=(0,g.extend)({},s.pointColl[0],{},!0);break}for(var P=0,w=d.selPointColl.length;P<w;P++)if(d.selPointColl[P].id===c.selPointColl[P].id){d.selPointColl[P]=(0,g.extend)({},c.selPointColl[P],{},!0);break}}}else(u[f].shape||m)&&(u[f].currIndex||m)||u.splice(f,1)}o&&"zoom"===o&&(s.pointColl=[],s.freehandCounter=0,s.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:i}})),s.objColl=p,s.pointColl=h,s.freehandCounter=s.pointColl.length,s.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:d.selPointColl}}}),v&&this.preventFrameAnnotation&&(s.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:s.frameObj.type,preventImg:!0}}),this.preventFrameAnnotation=!1),s.activeObj=l},e}(),R=function(){function e(e){this.isReverseFlip=!1,this.disablePan=!1,this.isReverseRotate=!1,this.flipColl=[],this.prevZoomValue=1,this.cropDimension={width:0,height:0},this.isPreventSelect=!1,this.preventDownScale=!1,this.resizedImgAngle=null,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("transform",this.transform,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("transform",this.transform),this.parent.off("destroyed",this.destroy)},e.prototype.transform=function(e){switch(this.initTransformPvtVar(),e.prop){case"flipImage":this.flipImage(e.value.direction);break;case"setDestPointsForFlipState":this.setDestPointsForFlipState();break;case"zoomAction":this.zoomAction(e.value.zoomFactor,e.value.zoomPoint,e.value.isResize);break;case"disableZoomOutBtn":this.disableZoomOutBtn(e.value.isZoomOut);break;case"rotatedFlip":this.rotatedFlip();break;case"drawPannedImage":this.drawPannedImage(e.value.xDiff,e.value.yDiff);break;case"drawPannImage":this.drawPannImage(e.value.point);break;case"performTransformation":this.performTransformation(e.value.text);break;case"updateTransform":this.updateTransform(e.value.text);break;case"rotatePan":this.rotatePan(e.value.isCropSelection,e.value.isDefaultZoom);break;case"resetZoom":this.resetZoom();break;case"pan":this.pan(e.value.value,e.value.x,e.value.y);break;case"zoom":this.zoom(e.value.zoomFactor,e.value.zoomPoint);break;case"setCurrPanRegion":this.setCurrPanRegion(e.value.region,e.value.type,e.value.obj);break;case"rotate":this.rotate(e.value.degree,e.value.obj);break;case"flip":this.flip(e.value.direction);break;case"update":this.update();break;case"calcMaxDimension":this.calcMaxDimension(e.value.width,e.value.height,e.value.obj,e.value.isImgShape);break;case"getPanMove":e.value.obj.panMove=this.panMove;break;case"setPanMove":this.panMove=e.value.point;break;case"getTempPanMove":e.value.obj.tempPanMove=this.tempPanMove;break;case"setTempPanMove":this.tempPanMove=e.value.point;break;case"setReverseFlip":this.isReverseFlip=e.value.isReverseFlip;break;case"setDisablePan":this.disablePan=e.value.bool;break;case"setCurrDestinationPoint":this.currDestPoint=e.value.point,this.currDestPoint.startX-=this.parent.cropObj.totalPannedPoint.x,this.currDestPoint.startY-=this.parent.cropObj.totalPannedPoint.y;break;case"setReverseRotate":this.isReverseRotate=e.value.bool;break;case"getFlipColl":e.value.obj.flipColl=this.flipColl;break;case"setFlipColl":this.flipColl=e.value.flipColl;break;case"getPreviousZoomValue":e.value.obj.previousZoomValue=this.prevZoomValue;break;case"setPreviousZoomValue":this.prevZoomValue=e.value.previousZoomValue;break;case"getCropDimension":e.value.obj.cropDimension=this.cropDimension;break;case"setCropDimension":this.cropDimension.width=e.value.width,this.cropDimension.height=e.value.height;break;case"getPreventSelect":e.value.obj.bool=this.isPreventSelect;break;case"setPreventSelect":this.isPreventSelect=e.value.bool;break;case"resizeImage":this.resizeImage(e.value.width,e.value.height);break;case"resizeCrop":this.resizeCrop(e.value.width,e.value.height);break;case"updateResize":this.updateResize();break;case"resize":this.resize(e.value.width,e.value.height,e.value.isAspectRatio);break;case"straightenImage":this.straightenImage(e.value.degree);break;case"reset":this.reset();break;case"cropZoom":e.value.obj.maxDimension=this.cropZoom(e.value.value,e.value.selectionObj);break;case"setResizedImgAngle":this.resizedImgAngle=e.value.angle}},e.prototype.getModuleName=function(){return"transform"},e.prototype.initTransformPvtVar=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},e.prototype.reset=function(){this.zoomBtnHold=null,this.tempPanMove=null,this.panMove=null,this.disablePan=!1,this.currDestPoint=null,this.isReverseRotate=!1,this.flipColl=[],this.resizedImgAngle=null,this.transCurrObj=null,this.prevZoomValue=1,this.isPreventSelect=this.preventDownScale=!1},e.prototype.rotateImage=function(e){var t=this.parent,o={cancel:!1,previousDegree:t.transform.degree,currentDegree:360===Math.abs(t.transform.degree+e)?0:t.transform.degree+e};this.isPreventSelect||(t.trigger("rotating",o),t.editCompleteArgs=o),this.rotateEvent(o,e)},e.prototype.rotateEvent=function(e,t){var o=this.parent;if(e.cancel)o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:o.prevEventObjPoint}}),o.activeObj=o.prevEventSelectionPoint,o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}});else{var i=void 0;if((0,g.isNullOrUndefined)(this.transCurrObj)){var r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),(i=r.currObj).objColl=(0,g.extend)([],o.objColl,null,!0),i.pointColl=(0,g.extend)({},o.pointColl,null,!0),i.afterCropActions=(0,g.extend)([],o.afterCropActions,[],!0);var a={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),i.selPointColl=(0,g.extend)([],a.selPointColl,[],!0)}o.afterCropActions.push(90===t?"rotateRight":"rotateLeft");var n=[],s=void 0;o.activeObj.activePoint&&o.activeObj.shape&&(void 0!==o.activeObj.shape&&(n=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===n[0])&&(s=o.currObjType.isCustomCrop?"custom":n[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(t),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}}),s&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=(0,g.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 l={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:l}}),o.rotateFlipColl=l.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(o.notify("draw",{prop:"setIsCropSelect",value:{bool:!0}}),this.isPreventSelect=!0,o.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},e.prototype.drawRotatedImage=function(e){var t=this.parent;0===e?t.transform.degree=0:t.transform.degree+=e,360===Math.abs(t.transform.degree)&&(t.transform.degree=0),t.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var o=(0,g.extend)([],t.objColl,[],!0),i=(0,g.extend)({},t.activeObj,{},!0);if(t.objColl=[],t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseRotate||t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.rotateDegree(e),this.isReverseRotate||(t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),t.rotateFlipColl.push(e)),t.objColl=(0,g.extend)([],o,[],!0),t.activeObj=(0,g.extend)({},i,{},!0),t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:e}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e>0)t.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});else for(var r=0;r<3;r++)t.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.updateCurrSelectionPoint(e)},e.prototype.rotateDegree=function(e){var t=this.parent;this.lowerContext.save(),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.lowerContext.translate(t.lowerCanvas.width/2,t.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*e),this.lowerContext.translate(-t.lowerCanvas.width/2,-t.lowerCanvas.height/2);var o=this.lowerContext.filter;t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=o,this.lowerContext.translate(t.lowerCanvas.width/2,t.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*-e),this.lowerContext.translate(-t.lowerCanvas.width/2,-t.lowerCanvas.height/2),this.lowerContext.restore()},e.prototype.updateCurrSelectionPoint=function(e){var t=this.parent;if(t.currSelectionPoint&&this.currDestPoint){var o=(0,g.extend)({},t.activeObj,{},!0),i=(0,g.extend)([],t.objColl,[],!0),r={startX:t.img.srcLeft,startY:t.img.srcTop,width:t.img.srcWidth,height:t.img.srcHeight},a={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};t.objColl=[],t.objColl.push((0,g.extend)({},t.currSelectionPoint,{},!0)),t.img={srcLeft:0,srcTop:0,srcWidth:t.baseImgCanvas.width,srcHeight:t.baseImgCanvas.height,destLeft:this.currDestPoint.startX,destTop:this.currDestPoint.startY,destWidth:this.currDestPoint.width,destHeight:this.currDestPoint.height},"number"==typeof e&&(t.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),t.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}})),t.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:e}}),t.currSelectionPoint=(0,g.extend)({},t.objColl[0],{},!0),this.currDestPoint={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight},t.objColl=i,t.activeObj=o,t.img={srcLeft:r.startX,srcTop:r.startY,srcWidth:r.width,srcHeight:r.height,destLeft:a.startX,destTop:a.startY,destWidth:a.width,destHeight:a.height}}},e.prototype.flipImage=function(e){var t=this.parent,o={direction:e,cancel:!1,previousDirection:t.toPascalCase(t.transform.currFlipState||e)};this.isPreventSelect||(t.trigger("flipping",o),t.editCompleteArgs=o),this.flipEvent(o,e)},e.prototype.flipEvent=function(e,t){var o,i=this.parent;if(e.cancel)return i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:i.prevEventObjPoint}}),i.activeObj=i.prevEventSelectionPoint,void i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj}});if((0,g.isNullOrUndefined)(this.transCurrObj)){var r={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),(o=r.currObj).objColl=(0,g.extend)([],i.objColl,null,!0),o.pointColl=(0,g.extend)({},i.pointColl,null,!0),o.afterCropActions=(0,g.extend)([],i.afterCropActions,[],!0);var a={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),o.selPointColl=(0,g.extend)([],a.selPointColl,[],!0)}i.afterCropActions.push("horizontal"===t.toLowerCase()?"horizontalflip":"verticalflip");var n,s=[];i.activeObj.activePoint&&(void 0!==i.activeObj.shape&&(s=i.activeObj.shape.split("-")),(i.currObjType.isCustomCrop||"crop"===s[0])&&(n=i.currObjType.isCustomCrop?"custom":s[1],i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),i.objColl.push(i.activeObj),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),i.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),i.clearContext(this.lowerContext),i.clearContext(this.upperContext);var l=(0,g.extend)([],i.objColl,[],!0),p=(0,g.extend)({},i.activeObj,{},!0);i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseFlip||i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var h=t.toLowerCase();this.updateFlipState(h);var d=i.transform.currFlipState.toLowerCase();i.transform.currFlipState="horizontal"===h&&"horizontal"===d||"vertical"===h&&"vertical"===d?"":h;var c={isSelected:null};i.notify("draw",{prop:"getRotatedFlipCropSelection",onPropertyChange:!1,value:{bool:c}}),c.isSelected&&(i.img.destLeft+=i.panPoint.totalPannedInternalPoint.x,i.img.destTop+=i.panPoint.totalPannedInternalPoint.y);var u=this.lowerContext.filter;if(i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=u,i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.updateFlipState(t.toLowerCase()),this.isReverseFlip||(i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),this.updateFlipColl(t.toLocaleLowerCase()),i.rotateFlipColl.push(t.toLowerCase())),1===i.rotateFlipColl.length){var v={panRegion:""};i.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:v}}),""===v.panRegion?i.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}}):this.setDestPointsForFlipState()}i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.objColl=(0,g.extend)([],l,[],!0),i.activeObj=(0,g.extend)({},p,{},!0);for(var f=0,m=i.objColl.length;f<m;f++){var b=i.objColl[f].flipObjColl;0===b.length?b.push(t):b[b.length-1]===t?b.pop():b.push(t)}i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:t.toLowerCase()}});var C=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%)",i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1});var y=t.toLowerCase();"horizontal"===y||"vertical"===y?(i.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:y}}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}})):i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=C,i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.updateCurrSelectionPoint(y),i.isUndoRedo=!1,i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),n&&(this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.activeObj=(0,g.extend)({},i.objColl[i.objColl.length-1],{},!0),i.objColl.pop(),i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj}}));var x={collection:i.rotateFlipColl};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.rotateFlipColl,isRotateFlipCollection:!0,obj:x}}),i.rotateFlipColl=x.collection,i.cropObj.activeObj.shape&&!this.isPreventSelect&&(i.notify("draw",{prop:"setIsCropSelect",value:{bool:!0}}),this.isPreventSelect=!0,i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),this.isPreventSelect=!1,i.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=i.zoomSettings.zoomFactor)},e.prototype.updateFlipState=function(e){var t=this.parent.transform.degree;"horizontal"===e?t%90==0&&t%180!=0?this.verticalFlip():this.horizontalFlip():"vertical"===e&&(t%90==0&&t%180!=0?this.horizontalFlip():this.verticalFlip())},e.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)},e.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)},e.prototype.updateFlipColl=function(e){if(!this.isPreventSelect&&(0===this.flipColl.length||this.flipColl[this.flipColl.length-1]!==e?this.flipColl.push(e):this.flipColl.pop(),this.flipColl.length>=4)){var t=this.flipColl.slice(-4);("horizontal"===t[0]&&"vertical"===t[1]&&"horizontal"===t[2]&&"vertical"===t[3]||"vertical"===t[0]&&"horizontal"===t[1]&&"vertical"===t[2]&&"horizontal"===t[3])&&this.flipColl.splice(-4)}},e.prototype.setDestPointsForFlipState=function(){var e=this.parent,t={panRegion:""},o=e.img,i=o.destLeft,r=o.destTop,a=o.destWidth,n=o.destHeight,s=e.lowerCanvas,l=s.clientWidth,p=s.clientHeight;e.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:t}}),""!==t.panRegion&&("horizontal"===t.panRegion?e.img.destLeft=l-(a+i):("vertical"===t.panRegion||(e.img.destLeft=l-(a+i)),e.img.destTop=p-(n+r)))},e.prototype.zoomAction=function(e,t,o,i){var r=this.parent;if(!r.disabled&&r.isImageLoaded){if((0,g.isNullOrUndefined)(o)&&(r.zoomSettings.zoomFactor>=r.zoomSettings.maxZoomFactor&&e>0||r.zoomSettings.zoomFactor>r.zoomSettings.minZoomFactor&&e<0&&this.disableZoomOutBtn(!0)||r.zoomSettings.zoomFactor<=r.zoomSettings.minZoomFactor&&e<0))return void r.notify("toolbar",{prop:"zoom-up-handler",onPropertyChange:!1});r.notify("draw",{prop:"setImageEdited",onPropertyChange:!1});var a=e;e=a>0?.1:-.1;for(var n=0;n<Math.round(Math.abs(a/.1));n++)if(1===this.prevZoomValue)this.prevZoomValue+=e>0?10*e:10*e/10;else if(this.prevZoomValue>1)this.prevZoomValue+=10*e;else if(this.prevZoomValue<1){this.prevZoomValue+=10*e/10;var s=Math.pow(10,1);this.prevZoomValue=Math.round(this.prevZoomValue*s)/s}e=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=(0,g.extend)({},r.activeObj,{},!0),r.isCropTab=!0):(r.activeObj.shape&&"crop"!==l[0]&&(0!==r.activeObj.activePoint.width||0!==r.activeObj.activePoint.height)||"path"===r.activeObj.shape&&r.activeObj.pointColl.length>0)&&(this.isShape=!0);var p={zoomType:null};r.notify("selection",{prop:"getZoomType",onPropertyChange:!1,value:{obj:p}}),(0,g.isNullOrUndefined)(t)&&(t=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||(t={x:r.zoomSettings.zoomPoint.x,y:r.zoomSettings.zoomPoint.y}));var h={zoomPoint:t,cancel:!1,previousZoomFactor:r.zoomSettings.zoomFactor-10*e,currentZoomFactor:r.zoomSettings.zoomFactor,zoomTrigger:p.zoomType};!r.isCropToolbar&&r.isZoomBtnClick&&(r.trigger("zooming",h),r.editCompleteArgs=h),this.zoomEvent(h,e,i)}},e.prototype.zoomEvent=function(e,t,o){var i,r=this.parent,a=r.zoomSettings,n=a.zoomFactor,s=a.minZoomFactor;if(e.cancel)r.isZoomBtnClick=!1;else{"blur"!==this.parent.activeObj.redactType&&"pixelate"!==this.parent.activeObj.redactType&&r.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),!r.isCropTab&&r.activeObj.shape&&(i=r.activeObj.currIndex),r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height);var l={canvasFilter:r.canvasFilter};this.lowerContext.filter=l.canvasFilter,r.upperCanvas.style.cursor=r.cursor="default";var p=(0,g.extend)([],r.objColl,[],!0);if(!r.isCropTab){if(0!==r.transform.degree){r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r.panPoint.currentPannedPoint={x:0,y:0};var h=r.allowDownScale;r.allowDownScale=!1,this.rotatePan(!0,!0),r.allowDownScale=h}else""!==r.transform.currFlipState&&(r.panPoint.totalPannedPoint={x:0,y:0});0!==r.transform.straighten||this.isPreventSelect||r.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1,value:{isPreventApply:o}})}if(0===r.transform.degree){this.drawZoomImgToCanvas(t,this.tempActiveObj);var d={panRegion:""};if(r.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:d}}),""!==d.panRegion){r.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:r.panPoint.totalPannedPoint,isAdd:!0}}),p=(0,g.extend)([],r.objColl,[],!0),r.objColl=[];var c=r.img.destLeft,u=r.img.destTop;this.setDestPointsForFlipState(),this.rotatedFlip(),r.img.destLeft=c,r.img.destTop=u,r.objColl=p,r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:o}}),0!==r.transform.straighten||this.isPreventSelect||r.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1,value:{isPreventApply:o}})}n<=s&&!r.isCropTab&&(r.panPoint.totalPannedPoint={x:0,y:0})}else{0!==r.transform.straighten||this.isPreventSelect||r.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1,value:{isPreventApply:o}}),r.panPoint.totalPannedClientPoint={x:0,y:0},r.panPoint.totalPannedInternalPoint={x:0,y:0},this.rotateZoom(t);var v={panRegion:""};if(r.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:v}}),""!==v.panRegion){h=this.lowerContext.filter;this.lowerContext.filter="none",r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:o}}),this.lowerContext.filter=h}}var f=Math.pow(10,1);(n<=s||Math.round(r.transform.zoomFactor*f)/f===2)&&(clearInterval(this.zoomBtnHold),this.zoomBtnHold=0);var m,b={panRegion:""};if(r.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:b}}),""===b.panRegion){h=this.lowerContext.filter;this.lowerContext.filter="none",r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:o}}),this.lowerContext.filter=h}(r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape||r.isCircleCrop)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.tempActiveObj&&(r.activeObj=(0,g.extend)({},this.tempActiveObj,{},!0),r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:r.activeObj}}),n<=s&&(r.currSelectionPoint=null)),r.isUndoRedo=!1,(m=document.querySelector("#"+r.element.id+"_zoomOut"))&&n<=s?(m.classList.add("e-disabled"),m.parentElement.classList.add("e-overlay")):m&&(m.classList.remove("e-disabled"),m.parentElement.classList.remove("e-overlay"));var C=r.drawingShape;if(this.autoEnablePan(),r.drawingShape=C,this.tempActiveObj&&(r.activeObj=(0,g.extend)({},this.tempActiveObj,{},!0)),"crop-custom"===r.activeObj.shape&&(r.currObjType.isCustomCrop=!0),this.isShape){if(i){for(var y=0,x=r.objColl.length;y<x;y++)if(r.objColl[y].currIndex===i){r.activeObj=(0,g.extend)({},r.objColl[y],{},!0),r.objColl.splice(y,1);break}}else r.activeObj=(0,g.extend)({},r.objColl[r.objColl.length-1],{},!0),r.objColl.pop();r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:r.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),r.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),r.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})}if(r.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}),r.notify("selection",{prop:"setZoomType",onPropertyChange:!1,value:{zoomType:"Toolbar"}}),e={zoomPoint:e.zoomPoint,previousZoomFactor:e.previousZoomFactor,currentZoomFactor:e.currentZoomFactor,zoomTrigger:e.zoomTrigger},!r.isCropToolbar&&r.isZoomBtnClick&&(r.isZoomBtnClick=!1),r.drawingShape){var P=(0,g.extend)({},r.activeObj,{},!0);if(r.enableShapeDrawing(r.toPascalCase(r.drawingShape),!0),r.activeObj=P,P.activePoint.width>0||P.activePoint.height>0||P.pointColl&&P.pointColl.length>0){"redact"===P.shape&&r.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}});var w=r.element.querySelector("#"+r.element.id+"_zOrderBtn"),j=r.element.querySelector("#"+r.element.id+"_duplicate"),S=r.element.querySelector("#"+r.element.id+"_remove"),O=r.element.querySelector("#"+r.element.id+"_editText");w&&w.classList.remove("e-overlay"),j&&j.classList.remove("e-overlay"),S&&S.classList.remove("e-overlay"),O&&O.classList.remove("e-overlay")}}else r.activeObj.shape&&"redact"===r.activeObj.shape&&(r.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"redact",isApplyBtn:!1,isCropping:!1}}),r.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))}},e.prototype.disableZoomOutBtn=function(e){var t,o=this.parent,i=o.zoomSettings,r=i.zoomFactor,a=i.minZoomFactor,n=!1;(0,g.isNullOrUndefined)(e)||(o.transform.zoomFactor-=.1),t=o.element.querySelector("#"+o.element.id+"_zoomOut");var s={destLeft:o.img.destLeft,destTop:o.img.destTop,destWidth:o.img.destWidth,destHeight:o.img.destHeight};if(o.activeObj.shape){var l=this.setZoomDimension(-.1,o.activeObj),p=o.activeObj.activePoint;if(0===o.transform.straighten)n=o.img.destLeft>p.startX||o.img.destTop>p.startY||o.img.destLeft+o.img.destWidth<p.endX||o.img.destTop+o.img.destHeight<p.endY||r===a;else{o.img.destWidth=l.width,o.img.destHeight=l.height;var h={isIntersect:null};o.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),o.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:h}}),n=!(!h.isIntersect&&r!==a)}t&&(n?(t.classList.add("e-disabled"),t.parentElement.classList.add("e-overlay")):(t.classList.remove("e-disabled"),t.parentElement.classList.remove("e-overlay")))}else this.setZoomDimension(-.1,null);return(0,g.isNullOrUndefined)(e)||(o.transform.zoomFactor+=.1),o.img.destLeft=s.destLeft,o.img.destTop=s.destTop,o.img.destWidth=s.destWidth,o.img.destHeight=s.destHeight,n},e.prototype.drawZoomImgToCanvas=function(e,t){var o=this.parent,i=Math.pow(10,1),r=Math.round(o.transform.zoomFactor*i)/i;.1===r&&-.1===e||0===r&&-.025===e?o.transform.zoomFactor=0:o.transform.zoomFactor+=e,o.transform[o.isCropTab?"cropZoomFactor":"defaultZoomFactor"]=o.transform.zoomFactor;var a={width:0,height:0};o.isCropTab?a=this.cropZoom(e,t):((a=this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight)).width+=a.width*o.transform.zoomFactor,a.height+=a.height*o.transform.zoomFactor,o.img.destLeft=(o.lowerCanvas.clientWidth-a.width)/2,o.img.destTop=(o.lowerCanvas.clientHeight-a.height)/2),o.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:a}}),a.width=this.cropDimension.width,a.height=this.cropDimension.height,a.width+=a.width*o.transform.zoomFactor,a.height+=a.height*o.transform.zoomFactor,o.notify("draw",{prop:"setZoomCropWidth",value:{width:a.width,height:a.height}})},e.prototype.rotatedFlip=function(){var e=this.parent;this.isReverseFlip=!0;var t=e.transform.currFlipState,o=this.flipColl,i=(0,g.extend)([],e.objColl,[],!0),r=(0,g.extend)({},e.activeObj,{},!0);this.flipColl=[],e.objColl=[],e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}});var a=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=a,e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,context:null,isPreventCircleCrop:null}}),""===t&&""!==e.transform.currFlipState&&(t=e.transform.currFlipState),e.transform.currFlipState=t,this.flipColl=o,e.objColl=(0,g.extend)([],i,[],!0),this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=a,0!==r.activePoint.width&&(e.activeObj=(0,g.extend)({},r,{},!0)),this.isReverseFlip=!1},e.prototype.rotateZoom=function(e){var t=this.parent,o=Math.pow(10,1),i=Math.round(t.transform.zoomFactor*o)/o;.1===i&&-.1===e||0===i&&-.025===e?t.transform.zoomFactor=0:t.transform.zoomFactor+=e,t.isCropTab?t.transform.cropZoomFactor=t.transform.zoomFactor:t.transform.defaultZoomFactor=t.transform.zoomFactor;var r=(0,g.extend)([],t.objColl,[],!0),a=(0,g.extend)({},t.activeObj,{},!0);t.objColl=[],t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),t.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),t.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var n=this.lowerContext.filter;t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=n,t.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),t.objColl=r,t.activeObj=a;var s={width:this.cropDimension.width,height:this.cropDimension.height};s.width+=s.width*t.transform.zoomFactor,s.height+=s.height*t.transform.zoomFactor,t.notify("draw",{prop:"setZoomCropWidth",value:{width:s.width,height:s.height}})},e.prototype.autoEnablePan=function(){var e=this.parent;e.transform.zoomFactor<=0?(e.togglePan=!1,e.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),e.pan(!1),this.disablePan=!1):e.pan(!this.disablePan)},e.prototype.cropZoom=function(e,t){var o=this.parent,i=o.img.destLeft,r=o.img.destTop,a={width:0,height:0};return(a=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+=a.width*o.transform.zoomFactor,a.height+=a.height*o.transform.zoomFactor,o.img.destLeft=i-(a.width-o.img.destWidth)/2,o.img.destTop=r-(a.height-o.img.destHeight)/2,i=o.img.destLeft,r=o.img.destTop,t&&0===o.transform.straighten&&(o.img.destLeft>t.activePoint.startX&&(o.img.destLeft=t.activePoint.startX,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=i-o.img.destLeft)),o.img.destTop>t.activePoint.startY&&(o.img.destTop=t.activePoint.startY,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=r-o.img.destTop)),o.img.destLeft+a.width<t.activePoint.endX&&(o.img.destLeft=t.activePoint.endX-a.width,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=i-o.img.destLeft)),o.img.destTop+a.height<t.activePoint.endY&&(o.img.destTop=t.activePoint.endY-a.height,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=r-o.img.destTop))),a},e.prototype.setZoomDimension=function(e,t){var o=this.parent,i=o.transform.degree,r={width:0,height:0};if((r=i%90==0&&i%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight)).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,e<0&&t){var a=t.activePoint.startX,n=t.activePoint.startY,s=t.activePoint.width,l=t.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 e<0&&(0,g.isNullOrUndefined)(t)&&(o.img.destLeft>0&&(o.img.destLeft=0),o.img.destTop>0&&(o.img.destTop=0),o.img.destLeft+r.width<o.lowerCanvas.clientWidth&&(o.img.destLeft=o.lowerCanvas.clientWidth-o.img.destWidth),o.img.destTop+r.height<o.lowerCanvas.clientHeight&&(o.img.destTop=o.lowerCanvas.clientHeight-o.img.destHeight));return r},e.prototype.drawPannedImage=function(e,t){var o=this.parent,i={panDown:null};o.notify("selection",{prop:"getPanDown",onPropertyChange:!1,value:{obj:i}});var r={startPoint:i.panDown,endPoint:this.panMove,cancel:!1};o.trigger("panning",r),r.cancel||this.panEvent(e,t)},e.prototype.panEvent=function(e,t,o){var i=this.parent,r=!1;if(i.activeObj.shape&&"shape"===i.activeObj.shape&&i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),(0,g.isNullOrUndefined)(i.activeObj.shape)){r=!0;var a=i.activeObj.activePoint={startX:i.img.destLeft,startY:i.img.destTop,endX:i.img.destLeft+i.img.destWidth,endY:i.img.destTop+i.img.destHeight},n=a.startX,s=a.startY,l=a.endX,p=a.endY;n<0&&(a.startX=0),s<0&&(a.startY=0),l>i.lowerCanvas.width&&(a.endX=i.lowerCanvas.width),p>i.lowerCanvas.height&&(a.endY=i.lowerCanvas.height),a.width=a.endX-a.startX,a.height=a.endY-a.startY,i.activeObj.shape="crop-custom";var h={strokeSettings:{}};i.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:h}}),i.activeObj.strokeSettings=h.strokeSettings,i.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:a,obj:i.activeObj,isMouseMove:null,x:null,y:null}}),i.isCropTab=!0}if(0===i.transform.degree){var d=void 0;d=(0,g.isNullOrUndefined)(e)&&(0,g.isNullOrUndefined)(t)||o?o?this.updatePanPoints(e,t):this.updatePanPoints():{x:e,y:t},i.panPoint.totalPannedPoint.x+=d.x,i.panPoint.totalPannedPoint.y+=d.y;var c=(0,g.extend)({},i.activeObj,{},!0),u=this.lowerContext.filter;this.drawPannImage(d,r),this.lowerContext.filter=u,this.tempPanMove=(0,g.extend)({},this.panMove,{},!0),i.activeObj=(0,g.extend)({},c,{},!0),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.activeObj.shape&&i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj}})}else{var v=i.transform.currFlipState;i.isCropTab=!0,(0,g.isNullOrUndefined)(e)&&(0,g.isNullOrUndefined)(t)||o?i.panPoint.currentPannedPoint=o?this.updatePanPoints(e,t):this.updatePanPoints():i.panPoint.currentPannedPoint={x:e,y:t},i.transform.currFlipState=v,this.rotatePan(null,null,r),i.isCropTab=!1,this.tempPanMove=(0,g.extend)({},this.panMove,{},!0)}r&&(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.isCropTab=!1,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height))},e.prototype.drawPannImage=function(e,t){var o=this.parent,i=this.lowerContext.filter,r={startX:o.img.destLeft,startY:o.img.destTop,width:o.img.destWidth,height:o.img.destHeight};this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),o.img.destLeft=r.startX,o.img.destTop=r.startY,o.img.destWidth=r.width,o.img.destHeight=r.height,this.setDestPointsForFlipState(),t&&(o.isCropTab=!1),o.notify("draw",{prop:"drawImage",onPropertyChange:!1}),t&&(o.isCropTab=!0),(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}}),this.lowerContext.filter=i,o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),o.img.destLeft=r.startX,o.img.destTop=r.startY,o.img.destWidth=r.width,o.img.destHeight=r.height;var a=this.lowerContext.filter;this.lowerContext.filter="none",t&&(o.isCropTab=!1),o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"pan",pen:"pan",x:e.x,y:e.y,panRegion:""}}),t&&(o.isCropTab=!0),this.lowerContext.filter=a,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}})},e.prototype.resetZoom=function(){var e=this.parent;if(0!==e.transform.defaultZoomFactor){var t=e.isUndoRedo,o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),this.transCurrObj=o.currObj,this.transCurrObj.objColl=(0,g.extend)([],e.objColl,null,!0),this.transCurrObj.pointColl=(0,g.extend)({},e.pointColl,null,!0),this.transCurrObj.afterCropActions=(0,g.extend)([],e.afterCropActions,[],!0);var i={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:i}}),this.transCurrObj.selPointColl=(0,g.extend)([],i.selPointColl,[],!0),e.isUndoRedo=e.isCropToolbar=!0;var r=e.transform.defaultZoomFactor;r>0?this.zoomAction(-r):this.zoomAction(Math.abs(r)),e.isCropToolbar=!1,e.isUndoRedo=t}},e.prototype.performTransformation=function(e){var t=this.parent;this.resetZoom(),this.updateTransform(e);for(var o=0,i=t.objColl.length;o<i;o++)if(t.objColl[o].flipObjColl.length>0){var r={collection:t.objColl[o].flipObjColl};t.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:r.collection,isRotateFlipCollection:null,obj:r}}),t.objColl[o].flipObjColl=r.collection,0===t.objColl[o].flipObjColl.length&&(t.objColl[o].shapeFlip="")}},e.prototype.updateTransform=function(e){switch(e.toLowerCase()){case"rotateleft":this.rotateImage(-90);break;case"rotateright":this.rotateImage(90);break;case"horizontalflip":this.flipImage(o.Horizontal);break;case"verticalflip":this.flipImage(o.Vertical)}},e.prototype.rotatePan=function(e,t,o){var i=this.parent;this.isReverseRotate=!0;var r,a=i.transform.degree,n={selPointColl:null};i.activeObj.activePoint&&i.activeObj.shape&&(r=(0,g.extend)({},i.activeObj,{},!0));var s=(0,g.extend)([],i.objColl,[],!0),l=(0,g.extend)([],i.pointColl,[],!0);i.objColl=[],i.pointColl=[],i.freehandCounter=0,i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}});var p=n.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var h=i.img.destLeft,d=i.img.destTop,c=i.panPoint.totalPannedInternalPoint;i.isCropTab&&(i.img.destLeft+=c.x,i.img.destTop+=c.y),i.notify("crop",{prop:"updateRotatePan",onPropertyChange:!1}),i.isCropTab&&(i.panPoint.totalPannedInternalPoint.x=i.img.destLeft-h,i.panPoint.totalPannedInternalPoint.y=i.img.destTop-d);var u=this.lowerContext.filter;o&&(i.isCropTab=!1),i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),o&&(i.isCropTab=!0),i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,isRotatePan:!0}});var v=i.img.destLeft,f=i.img.destTop;i.img.destLeft+=i.panPoint.totalPannedClientPoint.x,i.img.destTop+=i.panPoint.totalPannedClientPoint.y,i.img.destLeft+=i.panPoint.currentPannedPoint.x,i.img.destTop+=i.panPoint.currentPannedPoint.y,i.panPoint.totalPannedClientPoint.x=i.img.destLeft-v,i.panPoint.totalPannedClientPoint.y=i.img.destTop-f,i.objColl=s,i.pointColl=l,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:p}}}),i.transform.degree=a,this.lowerContext.filter="none",e&&(t?(i.panPoint.totalPannedClientPoint.x=-i.panPoint.totalPannedClientPoint.x,i.panPoint.totalPannedClientPoint.y=-i.panPoint.totalPannedClientPoint.y,i.panPoint.currentPannedPoint=(0,g.extend)({},i.panPoint.totalPannedClientPoint,{},!0),i.panPoint.totalPannedClientPoint={x:0,y:0},i.img.destLeft+=i.panPoint.currentPannedPoint.x,i.img.destTop+=i.panPoint.currentPannedPoint.y):i.panPoint.currentPannedPoint=(0,g.extend)({},i.panPoint.totalPannedClientPoint,{},!0)),o&&(i.isCropTab=!1),i.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"pan",pen:"pan",x:i.panPoint.currentPannedPoint.x,y:i.panPoint.currentPannedPoint.y,panRegion:""}}),o&&(i.isCropTab=!0),this.lowerContext.filter=u,i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.activeObj=(0,g.extend)({},r,{},!0),i.activeObj.activePoint&&i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),this.isReverseRotate=!1},e.prototype.limitPan=function(){var e=this.parent,t=e.activeObj.activePoint,o=t.startX,i=t.startY,r=t.endX,a=t.endY,n=e.img;e.activeObj.activePoint&&(n.destLeft>o&&(e.img.destLeft=o),n.destTop>i&&(e.img.destTop=i),n.destLeft+n.destWidth<r&&(e.img.destLeft=r-n.destWidth),n.destTop+n.destHeight<a&&(e.img.destTop=a-n.destHeight))},e.prototype.pan=function(e,t,o){var i=this.parent;!i.disabled&&i.isImageLoaded&&(e?(i.togglePan=!0,i.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),i.lowerCanvas.style.cursor=i.upperCanvas.style.cursor=i.cursor="grab",i.notify("selection",{prop:"setPanDown",onPropertyChange:!1,value:{panDown:null}}),(t||o)&&(t=t||0,o=o||0,(0,g.isNullOrUndefined)(this.panMove)&&(this.panMove={x:t,y:o}),(0,g.isNullOrUndefined)(this.tempPanMove)&&(this.tempPanMove={x:this.panMove.x,y:this.panMove.y}),this.panEvent(t,o,!0),this.tempPanMove=null)):(i.togglePan=i.currObjType.isCustomCrop=!1,i.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),i.lowerCanvas.style.cursor=i.upperCanvas.style.cursor=i.cursor="default"))},e.prototype.zoom=function(e,t){var o=this.parent;if(!o.disabled&&o.isImageLoaded){var i=this.getCurrentZoomFactor(e);if((0,g.isNullOrUndefined)(t))this.zoomAction(i,t);else for(var r=i>0?"zoomIn":"zoomOut",a=10*Math.abs(i),n=0;n<a;n++)o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:t.x,y:t.y,type:r,isResize:null}});var s={action:i>0?"zoom-in":"zoom-out",actionEventArgs:o.editCompleteArgs};o.triggerEditCompleteEvent(s)}},e.prototype.getCurrentZoomFactor=function(e){return e>=1?this.prevZoomValue<1?e-this.prevZoomValue:.1*(e-this.prevZoomValue):e-this.prevZoomValue},e.prototype.setCurrPanRegion=function(e,t,o){var i=e;i=""===e?"horizontal"===t?"horizontal":"vertical"===t?"vertical":e:"horizontal"===e?"horizontal"===t?"horizontalVertical":"vertical"===t?"verticalHorizontal":90===t?"vertical":-90===t?"horizontal":e:"vertical"===e?"horizontal"===t?"horizontalVertical":"vertical"===t?"verticalHorizontal":90===t?"horizontal":-90===t?"vertical":e:"horizontal"===t?"vertical":"vertical"===t?"horizontal":e,o.panRegion=i},e.prototype.rotate=function(e,t){var o=this.parent;!o.disabled&&o.isImageLoaded&&e%90==0&&this.rotateImage(e),t.isRotate=!1},e.prototype.flip=function(e){var t=this.parent;!t.disabled&&t.isImageLoaded&&this.flipImage(e)},e.prototype.update=function(){var e=this.parent,t=0,o=!1,i={bool:!1},r=e.isStraightening,a=0,n=e.element.querySelector("#"+e.element.id+"_contextualToolbar"),s=e.element.querySelector(".e-contextual-toolbar-wrapper"),l=e.element.querySelector("#"+e.element.id+"_headWrapper");if(e.isImageLoaded){var p=!1,h=void 0;g.Browser.isDevice&&(e.activeObj.shape&&(h=e.activeObj.shape.split("-")),(e.currObjType.isCustomCrop||h&&"crop"===h[0])&&(p=!0));e.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:{bool:null}}}),!r&&(n&&!n.parentElement.classList.contains("e-hide")||l&&!l.parentElement.classList.contains("e-hide"))&&(s.classList.add("e-hide"),p||e.okBtn(null,!0),e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),e.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:i}}),i.bool&&e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1});var d=(0,g.extend)({},e.activeObj.activePoint,{},!0);!e.activeObj.shape||0===d.width&&0===d.height||(o=!0,"block"===e.textArea.style.display||"inline-block"===e.textArea.style.display?(e.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})):(e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj)),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}e.updateDropInfoContent(e.element.querySelector(".e-ie-drop-info"));var c=this.lowerContext.filter,u=e.element.querySelector("#"+e.element.id+"_canvasWrapper");if(u&&(u.style.width=e.element.offsetWidth-2+"px"),e.lowerCanvas.width=e.upperCanvas.width=e.maskCanvas.width=e.element.offsetWidth-2,e.toolbarTemplate)t=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight;else if(e.element.querySelector("#"+e.element.id+"_toolbar")&&0===(t=e.element.querySelector("#"+e.element.id+"_toolbar").clientHeight)&&e.toolbar&&e.toolbar.length>0&&-1===e.toolbar.indexOf("Open")){var v={toolbarHeight:0};e.notify("toolbar",{prop:"getToolbarHeight",value:{obj:v}}),t=v.toolbarHeight}var f=e.element.querySelector("#"+e.element.id+"_contextualToolbarArea");if(g.Browser.isDevice&&r&&f&&(a=f.clientHeight),e.notify("toolbar",{prop:"setToolbarHeight",value:{height:t}}),g.Browser.isDevice?u&&(u.style.height=e.element.offsetHeight-(2*t+a)-4+"px"):u&&(u.style.height=e.element.offsetHeight-t-2+"px"),e.lowerCanvas.height=e.upperCanvas.height=parseFloat(u.style.height),this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",e.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),e.canvasFilter=this.lowerContext.filter,e.initialAdjustmentValue=this.lowerContext.filter,e.clearContext(this.lowerContext),e.clearContext(this.upperContext),e.isImageLoaded){if(e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.lowerContext.filter=c,e.initialAdjustmentValue=c,e.canvasFilter=this.lowerContext.filter,e.isImageLoaded&&((0,b.showSpinner)(e.element),e.element.style.opacity="0.5"),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),u){u.style.width=e.element.offsetWidth-2+"px",u.style.height=e.element.offsetHeight+"px";var m={toolbarHeight:0};e.notify("toolbar",{prop:"getToolbarHeight",value:{obj:m}}),g.Browser.isDevice?u.style.height=parseFloat(u.style.height)-2*m.toolbarHeight-a-4+"px":u.style.height=parseFloat(u.style.height)-m.toolbarHeight-2+"px"}e.lowerCanvas.width=e.upperCanvas.width=e.maskCanvas.width=parseFloat(u.style.width),e.lowerCanvas.height=e.upperCanvas.height=e.maskCanvas.height=parseFloat(u.style.height),this.lowerContext.filter=c,this.lowerContext.imageSmoothingQuality=e.imageSmoothingEnabled?"high":"low";v={width:0,height:0};this.calcMaxDimension(e.img.srcWidth,e.img.srcHeight,v);var C=v;if(r&&0!==e.transform.cropZoomFactor?(C.width+=C.width*e.transform.cropZoomFactor,C.height+=C.height*e.transform.cropZoomFactor):e.transform.defaultZoomFactor>0&&(C.width+=C.width*e.transform.defaultZoomFactor,C.height+=C.height*e.transform.defaultZoomFactor),e.img.destLeft=(e.lowerCanvas.clientWidth-C.width)/2,e.img.destTop=(e.lowerCanvas.clientHeight-C.height)/2,0===e.transform.degree&&""===e.transform.currFlipState)e.transform.defaultZoomFactor>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),e.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:C}});else{e.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:C}}),e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var y=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=y,e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}})}e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),(0,b.hideSpinner)(e.element),e.element.style.opacity="1";var x={defToolbarItems:null};if(e.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:x}}),x.defToolbarItems&&x.defToolbarItems.length>0&&document.getElementById(e.element.id+"_toolbar")){var P=(0,g.getComponent)(e.element.id+"_toolbar","toolbar");P&&P.refreshOverflow(),s&&!r&&s.classList.add("e-hide")}if(e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),o){var w=(0,g.extend)({},e.objColl[e.objColl.length-1],null,!0);e.objColl.pop(),0!==w.activePoint.width&&0!==w.activePoint.height&&(this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.objColl.push(w),e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),w=(0,g.extend)({},e.objColl[e.objColl.length-1],null,!0),e.objColl.pop(),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:w}}),r&&e.notify("draw",{prop:"setStraightenActObj",value:{activeObj:w}}),"rectangle"!==e.activeObj.shape&&"ellipse"!==e.activeObj.shape&&"text"!==e.activeObj.shape&&"line"!==e.activeObj.shape&&"arrow"!==e.activeObj.shape&&"path"!==e.activeObj.shape&&"image"!==e.activeObj.shape||e.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))}if(i.bool&&e.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}),e.isResize&&(e.aspectWidth=Math.ceil(e.img.destWidth),e.aspectHeight=Math.ceil(e.img.destHeight),e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}),e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}})),(0!==e.transform.degree||""!==e.transform.currFlipState)&&e.transform.defaultZoomFactor>0){var j=(0,g.extend)({},e.panPoint.totalPannedPoint,null,!0),S=(0,g.extend)({},e.panPoint.totalPannedInternalPoint,null,!0),O=(0,g.extend)({},e.panPoint.totalPannedClientPoint,null,!0);this.zoomAction(.1),this.zoomAction(-.1),0===e.transform.degree?(e.img.destLeft+=j.x,e.img.destTop+=j.y,e.panPoint.totalPannedPoint=j,e.notify("draw",{prop:"updateFlipPan",value:{tempSelectionObj:null}})):(e.panPoint.totalPannedInternalPoint=S,e.panPoint.totalPannedClientPoint=O,e.panPoint.currentPannedPoint={x:0,y:0},e.isCropTab=!0,this.rotatePan(),e.isCropTab=!1)}else 0!==e.transform.degree&&e.transform.cropZoomFactor>0&&(e.transform.zoomFactor=0,e.transform.cropZoomFactor=null,e.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}))}},e.prototype.calcMaxDimension=function(e,t,o,i){var r={toolbarHeight:0},a=this.parent;a.notify("toolbar",{prop:"getToolbarHeight",value:{obj:r}});var n=a.imageSettings.width?a.imageSettings.width:a.element.clientWidth,s=a.imageSettings.height?a.imageSettings.height:a.element.clientHeight-r.toolbarHeight,l=i?a.element.clientWidth/3:n,p=i?(a.element.clientHeight-r.toolbarHeight)/3:s;if(p=g.Browser.isDevice?p-r.toolbarHeight:p,g.Browser.isDevice&&a.isStraightening){var h=a.element.querySelector("#"+a.element.id+"_contextualToolbarArea");p-=h?h.clientHeight:0}i||0!==a.element.clientHeight||(p=0);var d=!(!a.imageSettings.width||!a.imageSettings.height);(0,g.isNullOrUndefined)(i)&&!d&&(l>30&&(l-=30),p>30&&(p-=30));var c=l/e,u=p/t,v=Math.min(e,l),f=Math.min(t,p);if(c<1&&c<u?(v=e*c,f=t*c):u<1&&u<c&&(v=e*u,f=t*u),(0,g.isNullOrUndefined)(i)){var m={bool:null};a.notify("crop",{prop:"getPreventScaling",onPropertyChange:!1,value:{obj:m}}),m.bool&&a.cropObj.activeObj.activePoint&&0!==a.cropObj.activeObj.activePoint.width&&0!==a.cropObj.activeObj.activePoint.height&&(v=a.cropObj.activeObj.activePoint.width,f=a.cropObj.activeObj.activePoint.height)}return o&&(o.width=v,o.height=f),{width:v,height:f}},e.prototype.updatePanPoints=function(e,t){var o=this.parent,i=(0,g.extend)({},o.activeObj,{},!0),r=o.img.destLeft,a=o.img.destTop;(0,g.isNullOrUndefined)(this.tempPanMove)&&(this.tempPanMove={x:this.panMove.x,y:this.panMove.y});var n=this.panMove.x-this.tempPanMove.x,s=this.panMove.y-this.tempPanMove.y;(e||t)&&(n=e,s=t),o.img.destLeft+=n,o.img.destTop+=s,this.limitPan();var l={bool:null},p={isIntersect:null};o.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),o.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:p}}),o.notify("draw",{prop:"isSelOutsideImg",onPropertyChange:!1,value:{obj:l}});for(var h=0;0!==o.transform.straighten&&(p.isIntersect||l.bool)&&(h++,o.img.destLeft=r,o.img.destTop=a,0!==n&&n>0?n-=1:0!==n&&n<0&&(n+=1),0!==s&&s>0?s-=1:0!==s&&s<0&&(s+=1),(0!==n||0!==s)&&200!==h);)o.img.destLeft+=n,o.img.destTop+=s,this.limitPan(),o.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),o.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:p}}),o.notify("draw",{prop:"isSelOutsideImg",onPropertyChange:!1,value:{obj:l}});return o.activeObj=i,{x:o.img.destLeft-r,y:o.img.destTop-a}},e.prototype.resizeImage=function(e,t){var o=this.parent,i=!0,r=!0;o.allowDownScale=!1,o.img.srcLeft=0,o.img.srcTop=0,o.isAspectRatio=!0;var a=[];for(o.img.srcWidth=o.baseImgCanvas.width,o.img.srcHeight=o.baseImgCanvas.height,o.resizeSrc&&0!==o.resizeSrc.width&&0!==o.resizeSrc.height&&(o.img.srcLeft=o.resizeSrc.startX,o.img.srcTop=o.resizeSrc.startY,o.img.srcWidth=o.resizeSrc.width,o.img.srcHeight=o.resizeSrc.height);(e<o.img.destWidth||t<o.img.destHeight)&&r;)if(this.zoomAction(-.1,null,!0,!0),e>o.img.destWidth||t>o.img.destHeight)for(;e>o.img.destWidth||t>o.img.destHeight;)this.zoomAction(.0125,null,!0,!0),r=!1,a.push(o.img.destWidth);for(;(e>o.img.destWidth||t>o.img.destHeight)&&r&&i;)if(this.zoomAction(.1,null,!0,!0),e<o.img.destWidth||t<o.img.destHeight)for(;e<o.img.destWidth;)this.zoomAction(-.0125,null,!0,!0),i=!1,a.push(o.img.destWidth);for(var n=a[0],s=Math.abs(o.img.destWidth-n),l=0,p=a;l<p.length;l++){var h=p[l],d=Math.abs(e-h);d<s&&(n=h,s=d)}n<e&&i&&(this.zoomAction(-.0125,null,!0,!0),i=!1),n>e&&!i&&(this.zoomAction(.0125,null,!0,!0),i=!1),this.zoomAction(.0125,null,!0),o.allowDownScale=!0,this.zoomAction(-.0125,null,!0);var c=(0,g.extend)({},o.cropObj,{},!0),u=(0,g.extend)({},this.prevResizeCurrObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"resize",previousObj:u,previousObjColl:u.objColl,previousPointColl:u.pointColl,previousSelPointColl:u.selPointColl,previousCropObj:c,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},e.prototype.resizeCrop=function(e,t){var o=this.parent,i=!0,r={prevObj:o.prevObj};o.cropObj=(0,g.extend)({},o.prevCropObj,{},!0),o.allowDownScale=!1,o.notify("toolbar",{prop:"getPrevObj",onPropertyChange:!1,value:{obj:r}});var a=(0,g.extend)({},r.prevObj.activeObj,{},!0);r.prevObj.activeObj=(0,g.extend)({},o.activeObj,{},!0),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:r.prevObj}}),o.objColl=(0,g.extend)([],r.prevObj.objColl,[],!0),o.pointColl=(0,g.extend)([],r.prevObj.pointColl,[],!0),o.transform.straighten=0,o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),0!==o.transform.straighten||this.isPreventSelect||o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var n=e,s=t,l=!1;if(t>=e&&t<=Math.ceil(o.img.destHeight)){for(;t<=Math.ceil(o.img.destHeight)&&i;)if(this.zoomAction(-.1,null,!0,!0),e>o.img.destWidth||t>o.img.destHeight)for(;e>o.img.destWidth||t>o.img.destHeight;)this.zoomAction(.0125,null,!0,!0),i=!1}else if(t<=e&&e<o.img.destWidth){for(;e<o.img.destWidth&&i;)if(this.zoomAction(-.1,null,!0,!0),e>o.img.destWidth||t>o.img.destHeight)for(;e>o.img.destWidth||t>o.img.destHeight;)this.zoomAction(.0125,null,!0,!0),i=!1}else if(t>=e&&t>=o.img.destHeight)for(;t>=o.img.destHeight&&i;)this.zoomAction(.1,null,!0,!0);else if(e>=t&&e>=o.img.destWidth){for(;e>=o.img.destWidth&&i;)this.zoomAction(.1,null,!0,!0);if(e<o.img.destWidth&&t<o.img.destHeight){for(;e<o.img.destWidth&&t<o.img.destHeight;)this.zoomAction(-.0125,null,!0,!0),i=!1;this.zoomAction(.0125,null,!0,!0)}}else if(t>o.img.destHeight&&e>o.img.destWidth){for(;t>o.img.destHeight&&e>o.img.destWidth&&i;)this.zoomAction(.1,null,!0,!0);if(e<o.img.destWidth&&t<o.img.destHeight){for(;e<o.img.destWidth&&t<o.img.destHeight;)this.zoomAction(-.0125,null,!0,!0),i=!1;this.zoomAction(.0125,null,!0,!0)}}if(!o.isPublicMethod||o.aspectWidth!==e||o.aspectHeight!==t){if(this.resizeImg(a,e,t),e=n,(t=s)!==o.img.destHeight||e!==o.img.destWidth){for(;t>o.img.destHeight||e>o.img.destWidth;)this.zoomAction(.0125,null,!0,!0),l=!0;l&&(this.zoomAction(-.0125,null,!0,!0),l=!1)}if(t!==o.img.destHeight||e!==o.img.destWidth){for(;t<o.img.destHeight||e<o.img.destWidth;)this.zoomAction(-.0125,null,!0,!0),l=!0;l&&(this.zoomAction(-.0125,null,!0,!0),l=!1)}r.prevObj.activeObj=(0,g.extend)({},a,{},!0),this.zoomAction(.0125,null,!0),o.allowDownScale=!this.preventDownScale,o.isCropTab=!1,this.zoomAction(-.0125,null,!0),o.aspectWidth=e,o.aspectHeight=t}},e.prototype.resizeImg=function(e,t,o){var i=this.parent,r=t/i.img.destWidth,a=o/i.img.destHeight;e.shape?(i.currSelectionPoint=e,i.notify("crop",{prop:"setInitCrop",onPropertyChange:!1,value:{bool:!0}})):i.img.srcWidth===i.baseImgCanvas.width&&i.img.srcHeight===i.baseImgCanvas.height&&(i.currSelectionPoint=null,i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}})),(0,g.isNullOrUndefined)(i.currSelectionPoint)?i.shapeColl.some(function(e){return e.rotatedAngle&&0!==e.rotatedAngle})||i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight}}):i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),t=i.activeObj.activePoint.width*r,o=i.activeObj.activePoint.height*a;for(var n=i.activeObj.activePoint.startX+i.activeObj.activePoint.width/2-t/2,s=i.activeObj.activePoint.startY+i.activeObj.activePoint.height/2-o/2,l=0;g.Browser.isDevice&&l<500&&(n<0||s<0||n+t>i.img.destWidth||s+o>i.img.destHeight);)l++,t-=1,o-=1,n=i.activeObj.activePoint.startX+i.activeObj.activePoint.width/2-t/2,s=i.activeObj.activePoint.startY+i.activeObj.activePoint.height/2-o/2;if(i.transform.defaultZoomFactor=0,i.notify("draw",{prop:"setResizeSelect",value:{bool:!0}}),i.notify("draw",{prop:"setIsCropSelect",value:{bool:!0}}),i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:n,startY:s,width:t,height:o}}),i.notify("draw",{prop:"setResizeSelect",value:{bool:!1}}),0!==i.transform.straighten){var p={isIntersect:null,arr:null};for(i.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),i.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:p}});p.arr[0]||p.arr[1]||p.arr[2]||p.arr[3];)this.zoomAction(.0125,null,!0),i.notify("draw",{prop:"updateImgCanvasPoints",onPropertyChange:!1}),i.notify("draw",{prop:"isLinesIntersect",onPropertyChange:!1,value:{obj:p}})}i.isCropToolbar=!0,i.crop(),i.isCropToolbar=!1},e.prototype.updateResize=function(){var e=this.parent;e.prevCropObj=(0,g.extend)({},e.cropObj,{},!0);var t={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:t}}),e.prevObj=t.currObj,e.currSelectionPoint&&e.prevCropObj.activeObj.shape&&(e.prevObj.activeObj=(0,g.extend)({},e.prevCropObj.activeObj,{},!0)),e.prevObj.objColl=(0,g.extend)([],e.objColl,[],!0),e.prevObj.pointColl=(0,g.extend)([],e.pointColl,[],!0),e.prevObj.afterCropActions=(0,g.extend)([],e.afterCropActions,[],!0);var o={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),e.prevObj.selPointColl=(0,g.extend)([],o.selPointColl,[],!0),e.resizeSrc={startX:e.img.srcLeft,startY:e.img.srcTop,width:e.img.srcWidth,height:e.img.srcHeight}},e.prototype.resize=function(e,t,o){var i,r=this.parent;r.isResize=!0,(0,g.isNullOrUndefined)(r.prevCropObj)&&(0,g.isNullOrUndefined)(r.prevObj)&&r.notify("transform",{prop:"updateResize",value:{bool:!1}});var a=r.element.querySelector("#"+r.element.id+"_aspectratio"),n=r.element.querySelector("#"+r.element.id+"_nonaspectratio");a&&n&&(r.notify("toolbar",{prop:"initResizeToolbar"}),g.Browser.isDevice&&r.notify("toolbar",{prop:"init-main-toolbar",value:{isApplyBtn:!1,isDevice:!0,isOkBtn:!0,isResize:!0}}));var s=r.element.querySelector("#"+r.element.id+"_resizeHeight");i=s?""===s.value?s.placeholder:s.value:t+"px";var l={cancel:!1,previousWidth:Math.ceil(r.img.destWidth),previousHeight:Math.ceil(r.img.destHeight),width:Math.ceil(e),height:t&&0!==t?Math.ceil(t):o?Math.ceil(parseFloat(i)):Math.ceil(r.img.destHeight),isAspectRatio:o||!1};r.trigger("resizing",l),r.editCompleteArgs=l,l.cancel?r.aspectHeight&&r.aspectWidth&&(r.aspectHeight=l.previousHeight,r.aspectWidth=l.previousWidth):this.resizeEventHandler(l)},e.prototype.resizeEventHandler=function(e){var t,o=this.parent,i=o.element.querySelector("#"+o.element.id+"_resizeWidth"),r=o.element.querySelector("#"+o.element.id+"_resizeHeight");if(e.isAspectRatio)if(null!=this.resizedImgAngle&&this.resizedImgAngle===o.transform.degree||(this.resizedImgAngle=o.transform.degree,t=!0),t){o.notify("transform",{prop:"resizeImage",value:{width:e.width,height:0}});var a=o.img.destWidth,n=o.img.destHeight;if(r){var s=parseFloat(""===i.value?i.placeholder:i.value)/(a/n),l=s%1>=.5||s%1<=-.5?Math.round(s):s<0?Math.ceil(s):Math.floor(s);if((0,g.getComponent)(r,"numerictextbox").value=l,r.value=l.toString()+" px",o.aspectHeight=l,i&&""===i.value){var p=(s=parseFloat(""===r.value?r.placeholder:r.value)/(n/a))%1>=.5||s%1<=-.5?Math.round(s):s<0?Math.ceil(s):Math.floor(s);(0,g.getComponent)(i,"numerictextbox").value=p,i.value=p.toString()+" px",o.aspectWidth=p}}}else o.notify("transform",{prop:"resizeImage",value:{width:e.width,height:null}});else null!==this.resizedImgAngle&&this.resizedImgAngle!==o.transform.degree&&(this.resizedImgAngle=o.transform.degree,t=!0),t?(o.notify("transform",{prop:"setPreventDownScale",value:{bool:!0}}),o.notify("transform",{prop:"resizeCrop",value:{width:e.width,height:e.height}}),o.notify("undo-redo",{prop:"setPreventUR",value:{bool:!0}}),o.okBtn(null,!0),o.notify("undo-redo",{prop:"setPreventUR",value:{bool:!1}}),o.resizeSrc={startX:o.img.srcLeft,startY:o.img.srcTop,width:o.img.srcWidth,height:o.img.srcHeight},o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("transform",{prop:"setPreventDownScale",value:{bool:!1}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})):o.notify("transform",{prop:"resizeCrop",value:{width:e.width,height:e.height}});this.resizedImgAngle=o.transform.degree},e.prototype.straightenImage=function(e){var t=this.parent,o=t.activeObj.shape&&t.activeObj.shape.indexOf("crop-")>-1;t.toolbar&&0===t.toolbar.length&&t.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),t.notify("toolbar",{prop:"performCropTransformClick",value:{shape:null}}),t.setStraighten(e),o||t.okBtn()},e}(),L=function(){function e(e){this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,this.isPreventing=!1,this.preventEditComplete=!1,this.preventApplyEditComplete=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("undo-redo",this.undoRedo,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("undo-redo",this.undoRedo),this.parent.off("destroyed",this.destroy)},e.prototype.initializeUrPvtProp=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},e.prototype.undoRedo=function(e){switch(this.initializeUrPvtProp(),e.prop){case"updateUndoRedoColl":this.updateUrc(e.value.operation,e.value.previousObj,e.value.previousObjColl,e.value.previousPointColl,e.value.previousSelPointColl,e.value.previousCropObj,e.value.previousText,e.value.currentText,e.value.previousFilter,e.value.isCircleCrop);break;case"refreshUrc":this.refreshUrc(e.value.bool);break;case"updateCurrUrc":this.updateCurrUrc(e.value.type,e.value.isCancel);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(e.value.objColl,e.value.operation);break;case"updateUndoRedo":this.updateUndoRedo(e.value?e.value.operation:null);break;case"getAppliedUndoRedoColl":e.value.obj.appliedUndoRedoColl=this.appliedUndoRedoColl;break;case"getUndoRedoStep":e.value.obj.undoRedoStep=this.undoRedoStep;break;case"setUndoRedoStep":this.undoRedoStep=e.value.step;break;case"undoDefault":this.undoDefault(e.value.obj);break;case"setPreventUR":this.isPreventing=e.value.bool;break;case"updateUndoRedoStack":e.value&&e.value.isPenDraw?this.updateUndoRedoStack(e.value.isPenDraw):this.updateUndoRedoStack();break;case"preventEditComplete":e.value.obj.bool=this.preventEditComplete;break;case"preventApplyEditComplete":this.preventApplyEditComplete=e.value.bool;break;case"reset":this.reset()}},e.prototype.getModuleName=function(){return"undo-redo"},e.prototype.reset=function(){this.tempCurrSelPoint=null,this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempActObj=null,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,this.isPreventing=!1,this.preventEditComplete=this.preventApplyEditComplete=!1},e.prototype.refreshUrc=function(e){var t=this.parent;t.isImageUpdated||((e=e||!1)&&(t.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!0}}),this.tempUndoRedoColl=(0,g.extend)([],this.appliedUndoRedoColl,[],!0),this.tempUndoRedoStep=this.undoRedoStep),t.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),this.undoRedoColl=this.undoRedoColl.slice(0,this.undoRedoStep),this.appliedUndoRedoColl=this.appliedUndoRedoColl.slice(0,this.undoRedoStep),t.isUndoRedo=t.currObjType.isUndoAction=!1,t.notify("toolbar",{prop:"enable-disable-btns"}))},e.prototype.updateCurrUrc=function(e,t){var o=this.parent;if(!(o.isResize||this.isPreventing||o.noPushUndo)){if(o.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),"ok"===e){o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!1}});var i=this.tempUndoRedoColl.length>0?(0,g.extend)([],this.tempUndoRedoColl,[],!0):(0,g.extend)([],this.undoRedoColl,[],!0),r=this.undoRedoColl[this.undoRedoColl.length-1],a=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1],n=r?(0,g.extend)({},r.previousObj,{},!0):null;if((0,g.isNullOrUndefined)(a)?this.undoRedoColl[0]&&(r.previousCropObj=i[0].previousCropObj,r.previousObj=i[0].previousObj,r.previousObjColl=i[0].previousObjColl,r.previousPointColl=i[0].previousPointColl,r.previousText=i[0].previousText):"imageHFlip"!==r.operation&&"imageVFlip"!==r.operation&&(r.previousCropObj=a.currentCropObj,r.previousObj=a.currentObj,r.previousObjColl=a.currentObjColl,r.previousPointColl=a.currentPointColl,r.previousText=a.currentText,"frame"===r.operation&&r.previousObj&&n&&(r.previousObj.defaultZoom=n.defaultZoom,r.previousObj.zoomFactor=n.zoomFactor,r.previousObj.cropZoom=n.cropZoom)),r){if("imageHFlip"!==r.operation&&"imageVFlip"!==r.operation){var s=this.getZeroZoomObjPointValue(r.currentObjColl,r.currentPointColl);r.currentObjColl=s.obj,r.currentPointColl=s.point;var l={adjustmentLevel:null};o.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:l}}),r.currentObj.adjustmentLevel=(0,g.extend)({},l.adjustmentLevel,{},!0),o.notify("filter",{prop:"setTempAdjVal"}),r.currentObj.currentFilter=o.currentFilter}this.appliedUndoRedoColl.push(r),t||this.triggerActionCompletedEvent(r.operation)}this.tempUndoRedoColl=[],this.tempUndoRedoStep=0}else this.tempUndoRedoColl.length>0&&(this.appliedUndoRedoColl=(0,g.extend)([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0);var p=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1],h=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-2];if(this.appliedUndoRedoColl.length>16)this.appliedUndoRedoColl.splice(0,1);else if(!t&&p&&h)if(("shapeTransform"===p.operation&&"shapeTransform"===h.operation||"shapeInsert"===p.operation&&"shapeInsert"===h.operation)&&JSON.stringify(p.currentObjColl)===JSON.stringify(h.currentObjColl)||"freehand-draw"===p.operation&&"freehand-draw"===h.operation&&JSON.stringify(p.currentPointColl)===JSON.stringify(h.currentPointColl)||"freehanddrawCustomized"===p.operation&&"freehanddrawCustomized"===h.operation&&JSON.stringify(p.currentPointColl)===JSON.stringify(h.currentPointColl))this.appliedUndoRedoColl.splice(this.appliedUndoRedoColl.length-1,1);else if(this.undoRedoStep!==this.appliedUndoRedoColl.length-1&&(p=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1],h=this.appliedUndoRedoColl[this.undoRedoStep],p&&h&&"shapeTransform"===p.operation&&"shapeTransform"===h.operation&&JSON.stringify(p.currentObjColl)===JSON.stringify(h.previousObjColl)))return this.appliedUndoRedoColl.splice(this.appliedUndoRedoColl.length-1,1),this.undoRedoColl=[],void(this.undoRedoColl=(0,g.extend)([],this.appliedUndoRedoColl,[],!0));this.undoRedoColl=[],this.undoRedoColl=(0,g.extend)([],this.appliedUndoRedoColl,[],!0),"ok"===e&&(this.undoRedoStep=this.undoRedoColl.length,o.notify("toolbar",{prop:"enable-disable-btns"})),o.transform.zoomFactor>0&&(o.togglePan=!0,o.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}))}},e.prototype.triggerActionCompletedEvent=function(e){var t=this.parent,o={action:{brightness:"fine-tune",contrast:"fine-tune",hue:"fine-tune",saturation:"fine-tune",opacity:"fine-tune",blur:"fine-tune",exposure:"fine-tune",default:"filter",chrome:"filter",cold:"filter",warm:"filter",grayscale:"filter",sepia:"filter",invert:"filter",deleteObj:"shape-delete",deleteFreehandDrawing:"freehand-draw-delete",shapeInsert:"shape-insert",shapeTransform:"shape-customize",freehanddrawCustomized:"freehand-draw-customize"}[e]||e,actionEventArgs:t.editCompleteArgs};t.triggerEditCompleteEvent(o)},e.prototype.getUndoRedoAction=function(e){return{brightness:"fine-tune",contrast:"fine-tune",hue:"fine-tune",saturation:"fine-tune",opacity:"fine-tune",blur:"fine-tune",exposure:"fine-tune",default:"filter",chrome:"filter",cold:"filter",warm:"filter",grayscale:"filter",sepia:"filter",invert:"filter",deleteObj:"shape-delete",deleteFreehandDrawing:"freehand-drawing-delete",shapeInsert:"shape-insert",shapeTransform:"shape-customize",imageRotate:"shape-customize",freehanddraw:"freehand-draw",freehanddrawCustomized:"freehand-draw-customize",textAreaCustomization:"text-area-customization",imageHFlip:"shape-customize",imageVFlip:"shape-customize",bgColor:"background-color",updateImage:"image-update"}[e]||e},e.prototype.cancelCropSelection=function(){var e,t=this.parent,o=!1;t.activeObj.shape&&(e=t.activeObj.shape.split("-")),(t.currObjType.isCustomCrop||e&&"crop"===e[0])&&(o=!0),o&&t.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),0===this.tempUndoRedoColl.length&&0===this.tempUndoRedoStep||(this.appliedUndoRedoColl=(0,g.extend)([],this.tempUndoRedoColl,[],!0),this.undoRedoColl=(0,g.extend)([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,t.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}))},e.prototype.refreshToolbarActions=function(){var e=this.parent;e.activeObj.shape?(e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),e.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})):e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},e.prototype.applyCurrentChanges=function(){var e=this.parent;e.currObjType.isFiltered=!1,0===e.transform.zoomFactor&&(e.togglePan=!1,e.notify("selection",{prop:"setDragCanvas",value:{bool:!1}})),e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.togglePen&&(e.togglePen=!1,e.upperCanvas.style.cursor=e.cursor="default",this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height)),this.appliedUndoRedoColl.length>0&&(this.undoRedoColl=(0,g.extend)([],this.appliedUndoRedoColl,[],!0))},e.prototype.callUndo=function(){this.applyCurrentChanges(),this.undo()},e.prototype.callRedo=function(){this.applyCurrentChanges(),this.redo()},e.prototype.undo=function(){var e=this.parent;if(this.cancelCropSelection(),e.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1,value:{isOk:!1}}),!e.disabled&&e.isImageLoaded&&this.undoRedoStep>0){this.refreshToolbarActions(),e.activeObj.activePoint&&0!==e.activeObj.activePoint.width&&(this.tempActObj=e.activeObj),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.undoRedoStep--,e.notify("toolbar",{prop:"enable-disable-btns"}),e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.isUndoRedo=!0;var t=this.undoRedoColl[this.undoRedoStep];this.undoRedoColl.length===this.undoRedoStep?e.currObjType.isUndoAction=!1:e.currObjType.isUndoAction=!0,"textAreaCustomization"===t.operation||"block"!==e.textArea.style.display&&"inline-block"!==e.textArea.style.display||(e.textArea.style.display="none"),e.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}});e.cropObj=(0,g.extend)({},t.previousCropObj,{},!0),e.afterCropActions=t.previousObj.afterCropActions,this.lowerContext.filter=t.previousObj.filter,e.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:t.previousObj.adjustmentLevel}}),e.notify("filter",{prop:"setTempAdjVal"}),e.currentFilter=t.previousObj.currentFilter,e.notify("filter",{prop:"setTempFilVal"}),e.canvasFilter=this.lowerContext.filter,e.initialAdjustmentValue=this.lowerContext.filter,e.notify("filter",{prop:"setBevelFilter",onPropertyChange:!1,value:{bevelFilter:this.lowerContext.filter}});var o={action:this.getUndoRedoAction(t.operation)},i=void 0;if("freehanddraw"===t.operation||"freehand-draw"===t.operation){var r={isSelected:null};e.notify("freehand-draw",{prop:"getFHDSelected",onPropertyChange:!1,value:{obj:r}}),i=r.isSelected}switch(t.operation){case"shapeTransform":case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":case"imageRotate":case"shapeInsert":this.shapeTransform(t.previousObjColl,t.previousPointColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(t.previousPointColl,t.previousSelPointColl),e.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:e.pointColl.length}}),i&&(e.notify("freehand-draw",{prop:"resetFHDIdx"}),e.notify("selection",{prop:"resetFreehandDrawVariables"}));break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(t.previousObjColl,t.previousPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(t.operation,t.previousObjColl,t.previousPointColl,t.previousSelPointColl);break;case"textAreaCustomization":this.shapeTransform(t.previousObjColl,t.previousPointColl),this.updateTextAreaCustomization(void 0,t.previousObjColl);break;case"text":this.updateText(t.previousObjColl,!0);break;case"frame":e.transform.zoomFactor=e.transform.defaultZoomFactor=t.previousObj.defaultZoom,e.setProperties({zoomSettings:{zoomFactor:t.previousObj.zoomFactor}},!0),e.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:e.zoomSettings.zoomFactor}}),(0,g.extend)(e.frameObj,t.previousObj.frameObj),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0,isPreventClearRect:null,isFrame:!0}});break;case"imageHFlip":this.imageFlip("horizontal",t.previousObjColl);break;case"imageVFlip":this.imageFlip("vertical",t.previousObjColl);break;case"bgColor":e.notify("draw",{prop:"imageBackgroundColor",onPropertyChange:!1,value:{color:t.previousObj.bgColor}}),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}});break;case"updateImage":e.isImageUpdated=!0,e.baseImg.src=t.previousObj.imageSource,setTimeout(function(){0!==e.cropObj.straighten?(e.notify("toolbar",{prop:"performCropTransformClick",value:{shape:"crop-custom"}}),e.noPushUndo=!0,e.crop(),e.noPushUndo=!1):e.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),e.isImageUpdated=!1});break;default:this.undoDefault(t,!0),e.notify("filter",{prop:"set-adjustment",value:{operation:t.operation}}),e.notify("filter",{prop:"update-filter",value:{operation:t.operation,filter:t.filter}})}if("crop"===t.operation){t.previousObj.currSelectionPoint&&(e.currSelectionPoint=(0,g.extend)({},t.previousObj.currSelectionPoint,{},!0),e.currSelectionPoint&&(0,g.isNullOrUndefined)(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null)),e.updateCropTransformItems(),e.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),e.isCircleCrop&&(e.isCircleCrop=!1,this.tempCurrSelPoint=(0,g.extend)({},e.currSelectionPoint,{},!0),e.currSelectionPoint=null);var a=e.cancelCropSelection.isCircleCrop;e.cancelCropSelection.isCircleCrop=!1,e.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null,isUndoRedo:!0}}),e.cancelCropSelection.isCircleCrop=a,e.currObjType.isActiveObj=!1,0!==e.transform.straighten&&e.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}})}else"resize"===t.operation&&e.cropObj&&e.cropObj.activeObj&&(e.currSelectionPoint=(0,g.extend)({},e.cropObj.activeObj,{},!0));this.undoRedoColl[this.undoRedoStep-1]&&this.undoRedoColl[this.undoRedoStep-1].isCircleCrop&&(e.isCircleCrop=!0,e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})),this.endUndoRedo(t.operation,!0);var n={action:"undo",actionEventArgs:o};e.triggerEditCompleteEvent(n)}},e.prototype.redo=function(){var e=this.parent;if(this.cancelCropSelection(),e.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1,value:{isOk:!1}}),!e.disabled&&e.isImageLoaded&&this.undoRedoStep<this.appliedUndoRedoColl.length){this.refreshToolbarActions(),this.undoRedoStep++,e.notify("toolbar",{prop:"enable-disable-btns"}),e.isUndoRedo=!0;var t=this.undoRedoColl[this.undoRedoStep-1];this.undoRedoColl.length===this.undoRedoStep?e.currObjType.isUndoAction=!1:e.currObjType.isUndoAction=!0,"textAreaCustomization"===t.operation||"block"!==e.textArea.style.display&&"inline-block"!==e.textArea.style.display||(e.textArea.style.display="none"),e.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}}),e.cropObj=(0,g.extend)({},t.currentCropObj,{},!0),e.afterCropActions=t.currentObj.afterCropActions,this.lowerContext.filter=t.currentObj.filter,e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:t.currentObj.adjustmentLevel}}),e.notify("filter",{prop:"setTempAdjVal"}),e.currentFilter=t.currentObj.currentFilter,e.notify("filter",{prop:"setTempFilVal"}),e.canvasFilter=this.lowerContext.filter,e.initialAdjustmentValue=this.lowerContext.filter,e.notify("filter",{prop:"setBevelFilter",onPropertyChange:!1,value:{bevelFilter:this.lowerContext.filter}});var o=void 0,i={action:this.getUndoRedoAction(t.operation)};switch(t.operation){case"shapeTransform":case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":case"imageRotate":case"shapeInsert":this.shapeTransform(t.currentObjColl,t.currentPointColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(t.currentPointColl,t.currentSelPointColl),e.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:e.pointColl.length}});break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(t.currentObjColl,t.currentPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(t.operation,t.currentObjColl,t.currentPointColl,t.currentSelPointColl);break;case"textAreaCustomization":this.shapeTransform(t.currentObjColl,t.currentPointColl),this.updateTextAreaCustomization(o,t.currentObjColl);break;case"text":this.updateText(t.currentObjColl,!1);break;case"frame":(0,g.extend)(e.frameObj,t.currentObj.frameObj),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0,isPreventClearRect:null,isFrame:!0}});break;case"imageHFlip":this.imageFlip("horizontal",t.currentObjColl);break;case"imageVFlip":this.imageFlip("vertical",t.currentObjColl);break;case"bgColor":e.notify("draw",{prop:"imageBackgroundColor",onPropertyChange:!1,value:{color:t.currentObj.bgColor}}),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}});break;case"updateImage":e.isImageUpdated=!0,e.baseImg.src=t.currentObj.imageSource,setTimeout(function(){0!==e.cropObj.straighten?(e.notify("toolbar",{prop:"performCropTransformClick",value:{shape:"crop-custom"}}),e.noPushUndo=!0,e.crop(),e.noPushUndo=!1):e.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),e.isImageUpdated=!1});break;default:e.objColl=[],e.pointColl=[],e.freehandCounter=0,e.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),e.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:t.currentObj,isUndoRedo:!0}}),e.img.destLeft=t.currentObj.destPoints.startX,e.img.destTop=t.currentObj.destPoints.startY,o=(0,g.extend)({},e.activeObj,{},!0),e.objColl=(0,g.extend)([],t.currentObjColl,[],!0),e.pointColl=(0,g.extend)([],t.currentPointColl,[],!0),e.freehandCounter=e.pointColl.length,e.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:(0,g.extend)([],t.currentSelPointColl,[],!0)}}}),e.transform.straighten=0,this.lowerContext.filter="none",e.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),this.lowerContext.filter=t.currentObj.filter,e.prevStraightenedDegree=e.transform.straighten,e.activeObj=o,this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),0!==e.activeObj.activePoint.width&&0!==e.activeObj.activePoint.height&&e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),e.notify("filter",{prop:"set-adjustment",value:{operation:t.operation}}),e.notify("filter",{prop:"update-filter",value:{operation:t.operation}})}"crop"===t.operation&&t.isCircleCrop&&(e.isCircleCrop=!0,e.currSelectionPoint=(0,g.extend)({},this.tempCurrSelPoint,{},!0),this.tempCurrSelPoint=null),"crop"!==t.operation||t.isCircleCrop||(e.isCircleCrop=!1),"crop"===t.operation&&t.currentObj.currSelectionPoint&&(e.currSelectionPoint=(0,g.extend)({},t.currentObj.currSelectionPoint,{},!0),e.notify("draw",{prop:"setStraightenActObj",value:{activeObj:e.currSelectionPoint}})),e.currSelectionPoint&&(0,g.isNullOrUndefined)(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null),"resize"===t.operation&&e.cropObj&&e.cropObj.activeObj&&(e.currSelectionPoint=(0,g.extend)({},e.cropObj.activeObj,{},!0)),this.endUndoRedo(t.operation,!1);var r={action:"redo",actionEventArgs:i};e.triggerEditCompleteEvent(r)}},e.prototype.imageFlip=function(e,t){var o=this.parent;this.shapeTransform(t,null),o.activeObj=(0,g.extend)({},o.objColl[o.objColl.length-1],{},!0);var i=o.activeObj,r=i.shape,a=i.isHorImageFlip,n=i.isVerImageFlip;o.objColl.pop(),r&&"image"===r?("horizontal"===e?(0,g.isNullOrUndefined)(a)&&n?(o.activeObj.isHorImageFlip=!0,o.activeObj.isVerImageFlip=null,o.horizontalFlip(this.upperContext,!0)):((0,g.isNullOrUndefined)(a)||!a?o.activeObj.isHorImageFlip=!0:o.activeObj.isHorImageFlip=null,o.horizontalFlip(this.upperContext,!0)):"vertical"===e&&((0,g.isNullOrUndefined)(n)&&a?(o.activeObj.isVerImageFlip=!0,o.activeObj.isHorImageFlip=null,o.verticalFlip(this.upperContext,!0)):((0,g.isNullOrUndefined)(n)||!n?o.activeObj.isVerImageFlip=!0:o.activeObj.isVerImageFlip=null,o.verticalFlip(this.upperContext,!0))),o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}})},e.prototype.shapeTransform=function(e,t){var o=this.parent;o.objColl=(0,g.extend)([],e,[],!0),t&&(o.pointColl=(0,g.extend)([],t,[],!0),o.freehandCounter=o.pointColl.length),o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",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}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},e.prototype.updateFreehandDraw=function(e,t){var o=this.parent;o.pointColl=e,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t}}}),o.freehandCounter=o.pointColl.length,o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",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})},e.prototype.updateFreehandDrawCustomized=function(e,t){var o=this.parent;o.objColl=(0,g.extend)([],e,[],!0),o.pointColl=t,o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",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})},e.prototype.updateDelete=function(e,t,o,i){var r=this.parent;"deleteFreehandDrawing"===e?(r.pointColl=o,r.freehandCounter=r.pointColl.length,r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:i}}}),r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}})):"deleteObj"===e&&(r.objColl=t,r.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}})),this.lowerContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),r.isUndoRedo=!0,r.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},e.prototype.updateTextAreaCustomization=function(e,t){var o=this.parent;o.objColl=(0,g.extend)([],t,[],!0),o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1});for(var i=0,r=t.length;i<r;i++){if(!this.tempActObj){e=(0,g.extend)({},t[t.length-1],{},!0),o.objColl.splice(i,1);break}if(this.tempActObj.currIndex===t[i].currIndex){e=(0,g.extend)({},t[i],{},!0),o.objColl.splice(i,1);break}}e&&this.updateTextBox(e),"block"!==o.textArea.style.display&&"inline-block"!==o.textArea.style.display||o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}})},e.prototype.updateText=function(e,t){var o=this.parent;if(this.tempActObj&&(o.activeObj=(0,g.extend)({},this.tempActObj,{},!0)),0===e.length&&1===o.objColl.length)this.tempActObj=(0,g.extend)({},o.objColl[0],{},!0);else for(var i=0,r=o.objColl.length;i<r;i++){if(o.objColl[i]&&(0,g.isNullOrUndefined)(e[i])){this.tempActObj=(0,g.extend)({},o.objColl[i],{},!0);break}if(e[i].currIndex!==o.objColl[i].currIndex){this.tempActObj=(0,g.extend)({},o.objColl[i],{},!0);break}}t&&(o.activeObj=(0,g.extend)({},this.tempActObj,{},!0)),o.objColl=(0,g.extend)([],e,[],!0),o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",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})},e.prototype.updateTextBox=function(e){var t=this.parent;this.upperContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1});var o=t.textArea;o.style.display="block",o.style.fontFamily=e.textSettings.fontFamily,o.style.fontSize=e.textSettings.fontSize+"px",o.style.color=e.strokeSettings.strokeColor,o.style.fontWeight=e.textSettings.bold?"bold":"normal",o.style.fontStyle=e.textSettings.italic?"italic":"normal",o.style.textDecoration=e.textSettings.underline&&e.textSettings.strikethrough?"underline line-through":e.textSettings.underline?"underline":e.textSettings.strikethrough?"line-through":"none",o.style.border="2px solid "+t.themeColl[t.theme].primaryColor,o.value=e.keyHistory,t.activeObj=(0,g.extend)({},e,{},!0),t.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}}),t.textArea.style.width=t.activeObj.activePoint.width+"px"},e.prototype.undoDefault=function(e,t){this.lowerContext.filter=e.previousObj.filter;var o=this.parent;o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}});var i=!t&&e.isCircleCrop;o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:e.previousObj,isUndoRedo:t,isCircleCrop:i}}),o.prevStraightenedDegree=o.transform.straighten,this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.img.destLeft=e.previousObj.destPoints.startX,o.img.destTop=e.previousObj.destPoints.startY;var r=(0,g.extend)({},o.activeObj,{},!0);o.objColl=(0,g.extend)([],e.previousObjColl,[],!0),o.pointColl=(0,g.extend)([],e.previousPointColl,[],!0),o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:(0,g.extend)([],e.previousSelPointColl,[],!0)}}}),o.transform.straighten=0,this.lowerContext.filter="none",o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),this.lowerContext.filter=e.previousObj.filter,o.activeObj=r,this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),0!==o.activeObj.activePoint.width&&0!==o.activeObj.activePoint.height&&o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})},e.prototype.endUndoRedo=function(e,t){var o=this.parent;(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&JSON.stringify(o.frameObj)!==JSON.stringify({type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""})&&o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.isCircleCrop&&(t&&"crop"!==e||!t)&&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}}),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"),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},e.prototype.updateUrc=function(e,t,o,i,r,a,n,s,l,p){var h=this.parent;if(!h.isResize&&!this.isPreventing){var d={isInitialLoaded:!1};if(h.currObjType.isUndoAction&&this.refreshUrc(!0),h.notify("draw",{prop:"isInitialLoaded",onPropertyChange:!1,value:{object:d}}),!d.isInitialLoaded&&h.allowUndoRedo){var c={currObj:{}};h.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:c}});var u=c.currObj;u.objColl=(0,g.extend)([],h.objColl,[],!0),u.pointColl=(0,g.extend)([],h.pointColl,[],!0),u.afterCropActions=(0,g.extend)([],h.afterCropActions,[],!0);var v={selPointColl:null};if(h.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:v}}),u.selPointColl=(0,g.extend)([],v.selPointColl,[],!0),"crop"===e)u.currSelectionPoint=(0,g.extend)({},h.currSelectionPoint,{},!0);else if("frame"===e)t.destPoints={startX:h.frameDestPoints.destLeft,startY:h.frameDestPoints.destTop,width:h.frameDestPoints.destWidth,height:h.frameDestPoints.destHeight},u.destPoints={startX:h.frameDestPoints.destLeft,startY:h.frameDestPoints.destTop,width:h.frameDestPoints.destWidth,height:h.frameDestPoints.destHeight},(0,g.isNullOrUndefined)(h.tempFrameZoomLevel)||(t.defaultZoom=u.defaultZoom=h.tempFrameZoomLevel);else if(("imageHFlip"===e||"imageVFlip"===e)&&this.appliedUndoRedoColl.length>0){var f=o[o.length-1].currIndex;if(o=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObjColl,f)for(var m=0,b=o.length;m<b;m++)if(o[m].currIndex===f){var C=(0,g.extend)({},o[m],{},!0);o.splice(m,1),o.push(C);break}}this.undoRedoColl.push({operation:e,previousObj:t,currentObj:u,previousObjColl:o,currentObjColl:u.objColl,previousPointColl:i,currentPointColl:u.pointColl,previousSelPointColl:r,currentSelPointColl:u.selPointColl,previousCropObj:a,currentCropObj:(0,g.extend)({},h.cropObj,{},!0),previousText:n,currentText:s,filter:l,isCircleCrop:p}),h.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1})}}},e.prototype.updateUrObj=function(e,t){var o=this.parent;if(o.allowUndoRedo){o.currObjType.isUndoAction&&!o.isShapeDrawing&&this.refreshUrc(!0),(0,g.isNullOrUndefined)(o.activeObj.imageRatio)&&o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj);var i=(0,g.extend)({},o.cropObj,{},!0),r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=(0,g.extend)([],o.objColl,[],!0),a.pointColl=(0,g.extend)([],o.pointColl,[],!0),a.afterCropActions=(0,g.extend)([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=(0,g.extend)([],n.selPointColl,[],!0);var s=t||"shapeTransform";this.undoRedoColl.push({operation:s,previousObj:a,currentObj:a,previousObjColl:e,currentObjColl:a.objColl,previousPointColl:a.pointColl,currentPointColl:a.pointColl,previousSelPointColl:a.selPointColl,currentSelPointColl:a.selPointColl,previousCropObj:i,currentCropObj:i}),o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.objColl[o.objColl.length-1]}})}},e.prototype.updateUndoRedo=function(e){var t=this.parent,o=(0,g.extend)({},t.cropObj,{},!0),i={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}});var r=i.currObj;r.objColl=(0,g.extend)([],t.objColl,[],!0),r.pointColl=(0,g.extend)([],t.pointColl,[],!0),r.afterCropActions=(0,g.extend)([],t.afterCropActions,[],!0);var a={selPointColl:null};t.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=(0,g.extend)([],a.selPointColl,[],!0),(0,g.isNullOrUndefined)(t.activeObj.imageRatio)&&t.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),t.objColl.push(t.activeObj);var n=e||"shapeTransform";this.updateUrc(n,r,r.objColl,r.pointColl,r.selPointColl,o),t.objColl.pop(),t.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),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}})},e.prototype.getZeroZoomObjPointValue=function(e,t){var o=this.parent;this.updateObjColl();var i={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}});var r=i.currObj;r.objColl=(0,g.extend)([],o.objColl,[],!0),r.pointColl=(0,g.extend)([],o.pointColl,[],!0),r.afterCropActions=(0,g.extend)([],o.afterCropActions,[],!0);var a={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=(0,g.extend)([],a.selPointColl,[],!0);var n={cropDimension:null};o.notify("transform",{prop:"getCropDimension",onPropertyChange:!1,value:{obj:n}});var s=(0,g.extend)([],o.objColl,[],!0),l=(0,g.extend)([],o.pointColl,[],!0),p={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:p}});var h=(0,g.extend)({},p.arrowDimension,{},!0);if(o.transform.zoomFactor>0&&(e.length>0||t.length>0)){if(e.length>0)for(var d=0;d<e.length;d++)e[d].currIndex||(e[d].currIndex="shape_"+(d+1));o.objColl=e,o.pointColl=t;var c=o.isUndoRedo,u=o.isCropTab;if(0!==o.transform.zoomFactor){o.isUndoRedo=!0,o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:!0}}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),o.isCropTab=!0;var v=(0,g.extend)({},o.zoomSettings,null,!0);o.transform.zoomFactor>0?o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-o.transform.zoomFactor,zoomPoint:null,isResize:null}}):o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(o.transform.zoomFactor),zoomPoint:null,isResize:null}}),o.zoomSettings=v,o.isCropTab=u,o.isUndoRedo=c,s=(0,g.extend)([],o.objColl,[],!0),l=(0,g.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:n.cropDimension.width,height:n.cropDimension.height}});var f={width:n.cropDimension.width,height:n.cropDimension.height};f.width+=f.width*r.defaultZoom,f.height+=f.height*r.defaultZoom,o.notify("draw",{prop:"setZoomCropWidth",value:{width:f.width,height:f.height}}),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:r}}),o.img.destLeft=r.destPoints.startX,o.img.destTop=r.destPoints.startY,o.panPoint.totalPannedPoint=r.totalPannedPoint,o.panPoint.totalPannedClientPoint=r.totalPannedClientPoint,o.panPoint.totalPannedInternalPoint=r.totalPannedInternalPoint,o.objColl=(0,g.extend)([],r.objColl,[],!0),o.pointColl=(0,g.extend)([],r.pointColl,[],!0),o.freehandCounter=o.pointColl.length,o.notify("draw",{prop:"setArrowDimension",onPropertyChange:!1,value:{arrowDimension:h}}),o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:(0,g.extend)([],r.selPointColl,[],!0)}}}),this.lowerContext.filter="none",o.transform.straighten=0,this.applyImgTranform(),o.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),o.notify("freehand-draw",{prop:"updateFHDCurPts",onPropertyChange:!1}),this.lowerContext.filter=r.filter,0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(o.isCircleCrop||o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})}}return{obj:s,point:l}},e.prototype.updateObjColl=function(){for(var e=this.parent,t=0;t<e.objColl.length;t++){var o=e.objColl[t],i=!1;if(("line"===o.shape||"arrow"===o.shape)&&(o.activePoint.width<0&&(o.activePoint.width=Math.abs(o.activePoint.width),i=!0),o.activePoint.height<0&&(o.activePoint.height=Math.abs(o.activePoint.height),i=!0),i)){var r=(0,g.extend)({},e.activeObj,{},!0);e.activeObj=o,e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o=e.activeObj,e.activeObj=r}}},e.prototype.applyImgTranform=function(){for(var e=this.parent,t=(0,g.extend)({},e.activeObj,{},!0),o=0,i=e.objColl.length;o<i;o++)if("image"===e.objColl[o].shape){e.activeObj=(0,g.extend)({},e.objColl[o],{},!0);var r=e.objColl[o].imageCanvas.getContext("2d");e.notify("selection",{prop:"applyTransformToImg",onPropertyChange:!1,value:{ctx:r}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("selection",{prop:"setImageClarity",onPropertyChange:!1,value:{bool:!0}})}e.activeObj=t},e.prototype.updateUndoRedoStack=function(e){var t=this.parent;if(t.activeObj.currIndex&&0!==t.activeObj.activePoint.width||0!==t.activeObj.activePoint.height||t.activeObj.pointColl&&t.activeObj.pointColl.length>0||e){var o="none"!==t.textArea.style.display,i=t.noPushUndo;if(t.noPushUndo=!1,t.isUndoRedoStack=!0,this.preventEditComplete=!0,e){var r=t.togglePen,a={freehandDrawSelectedId:null};t.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:a}}),t.okBtn(),t.noPushUndo=i,a.freehandDrawSelectedId?(t.noRedact=!0,t.selectShape(a.freehandDrawSelectedId)):t.freeHandDraw(!0),t.togglePen=r}else if(t.activeObj.currIndex){var n=t.activeObj.currIndex;t.okBtn(),t.noPushUndo=i,t.noRedact=!0,t.selectShape(n),t.drawingShape&&t.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:t.drawingShape.toLowerCase()}}),o&&t.enableTextEditing()}this.preventEditComplete&&(t.isUndoRedoStack=this.preventEditComplete=!1,this.preventApplyEditComplete||this.triggerActionCompletedEvent("shape-customize"),this.triggerActionCompletedEvent("shape-select")),t.isUndoRedoStack=this.preventEditComplete=!1}},e}(),E=(e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},e(t,o)},function(t,o){function i(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)}),X=function(e,t,o,i){var r,a=arguments.length,n=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(a<3?r(n):a>3?r(t,o,n):r(t,o))||n);return a>3&&n&&Object.defineProperty(t,o,n),n},Y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),X([(0,g.Property)(null)],t.prototype,"allowedExtensions",void 0),X([(0,g.Property)(null)],t.prototype,"minFileSize",void 0),X([(0,g.Property)(null)],t.prototype,"maxFileSize",void 0),t}(g.ChildProperty),M=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),X([(0,g.Property)(null)],t.prototype,"brightness",void 0),X([(0,g.Property)(null)],t.prototype,"contrast",void 0),X([(0,g.Property)(null)],t.prototype,"hue",void 0),X([(0,g.Property)(null)],t.prototype,"saturation",void 0),X([(0,g.Property)(null)],t.prototype,"exposure",void 0),X([(0,g.Property)(null)],t.prototype,"opacity",void 0),X([(0,g.Property)(null)],t.prototype,"blur",void 0),t}(g.ChildProperty),B=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),X([(0,g.Property)(null)],t.prototype,"zoomTrigger",void 0),X([(0,g.Property)(1)],t.prototype,"minZoomFactor",void 0),X([(0,g.Property)(10)],t.prototype,"maxZoomFactor",void 0),X([(0,g.Property)(1)],t.prototype,"zoomFactor",void 0),X([(0,g.Property)(null)],t.prototype,"zoomPoint",void 0),t}(g.ChildProperty),H=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),X([(0,g.Property)(!0)],t.prototype,"showCircle",void 0),X([(0,g.Property)(null)],t.prototype,"strokeColor",void 0),X([(0,g.Property)(null)],t.prototype,"fillColor",void 0),t}(g.ChildProperty),U=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return E(t,e),X([(0,g.Property)("Arial")],t.prototype,"default",void 0),X([(0,g.Property)(null)],t.prototype,"items",void 0),t}(g.ChildProperty),W=function(e){function t(t,i){var r=e.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,opacity:1,order:null},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,isRedact:!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:"",straighten:0,destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,zoomFactor:0,previousZoomValue:0,aspectWidth:null,aspectHeight:null,frame:"none",straightenZoom:0,adjustmentLevel:{brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},currentFilter:""},r.afterCropActions=[],r.transform={degree:0,currFlipState:"",zoomFactor:0,cropZoomFactor:null,defaultZoomFactor:0,straighten: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",r.resizeSrc={startX:r.img.srcLeft,startY:r.img.srcTop,width:r.img.srcWidth,height:r.img.srcHeight},r.isResize=!1,r.isAspectRatio=!1,r.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},r.tempFrameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},r.allowDownScale=!0,r.gradientColor="",r.size=20,r.inset=0,r.offset=0,r.borderRadius=0,r.lineCount=0,r.prevStraightenedDegree=0,r.tempStraighten=0,r.isStraightening=!1,r.isFinetuning=!1,r.isZoomBtnClick=!1,r.isFinetuneBtnClick=!1,r.isFilterCanvasClick=!1,r.isFrameBtnClick=!1,r.isChangesSaved=!1,r.isShapeDrawing=!1,r.noPushUndo=!1,r.isUndoRedoStack=!1,r.shapeColl=[],r.isKBDNavigation=!1,r.isMaskImage=!1,r.tempObjColl=[],r.tempPointColl=[],r.tempShapeColl=[],r.isImageUpdated=!1,r.noRedact=!1,r.tempRedactBlur=50,r.tempRedactPixel=40,r.imageSettings={width:null,height:null},r.aspectRatioBaseDimension=!1,r.imageLoaded=!1,r.tempToolbarHeight=0,r.tempToolbar=[],o.Inject(S,k,z,R,F,N),o.Inject(L),o.Inject(I),o.Inject(D),o.Inject(A),i&&r.appendTo(i),r}var o;return E(t,e),o=t,t.prototype.requiredModules=function(){var e=[];return e.push({member:"crop",args:[this]}),e.push({member:"draw",args:[this]}),e.push({member:"selection",args:[this]}),e.push({member:"transform",args:[this]}),e.push({member:"export",args:[this]}),e.push({member:"toolbar-module",args:[this]}),e.push({member:"undo-redo",args:[this]}),e.push({member:"filter",args:[this]}),e.push({member:"shape",args:[this]}),e.push({member:"freehand-draw",args:[this]}),e},t.prototype.preRender=function(){this.element.id=this.element.id||(0,g.getUniqueID)("ej2-image-editor"),this.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),g.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},t.prototype.render=function(){if(this.isAngular){var e=this.element,t=e.cloneNode(!0);e.parentNode.replaceChild(t,e),this.element=t,(0,g.setValue)("ej2_instances",[this],this.element)}this.initialize()},t.prototype.getModuleName=function(){return"image-editor"},t.prototype.getPersistData=function(){return this.addOnPersist([])},t.prototype.onPropertyChanged=function(e,t){for(var o,i=0,a=Object.keys(e);i<a.length;i++){switch(a[i]){case"cssClass":t.cssClass&&(0,g.removeClass)([this.element],t.cssClass.replace(/\s+/g," ").trim().split(" ")),e.cssClass&&(0,g.addClass)([this.element],e.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"disabled":e.disabled?(this.element.classList.add("e-disabled","e-overlay"),this.element.style.opacity="0.5",this.unwireEvent()):(this.element.classList.remove("e-disabled","e-overlay"),this.element.style.opacity="1",this.wireEvent());break;case"height":this.element.style.height=e.height,this.update();break;case"width":this.element.style.width=e.width,this.update();break;case"theme":e.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,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"finetuneSettings":e.finetuneSettings&&(this.finetuneSettings=e.finetuneSettings,this.notify("filter",{prop:"update-finetunes"}));break;case"locale":e.locale&&(this.notify("toolbar",{prop:"setLocale",onPropertyChange:!1,value:{locale:e.locale}}),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"allowUndoRedo":e.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":e.showQuickAccessToolbar?(this.showQuickAccessToolbar=!0,this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),o={freehandSelectedIndex:null},this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:o}}),this.activeObj.shape?this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}):o.freehandSelectedIndex&&this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}})):(this.showQuickAccessToolbar=!1,this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}));break;case"zoomSettings":e.zoomSettings&&(this.zoomSettings.zoomTrigger=e.zoomSettings.zoomTrigger),(0,g.isNullOrUndefined)(this.zoomSettings.zoomTrigger)?(this.zoomSettings.zoomTrigger=r.MouseWheel|r.Pinch|r.Toolbar|r.Commands,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})):(e.zoomSettings.zoomTrigger&r.Toolbar)===r.Toolbar&&this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"selectionSettings":e.selectionSettings&&(this.selectionSettings=e.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}})));break;case"toolbar":e.toolbar&&(this.toolbar=e.toolbar,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"toolbarTemplate":e.toolbarTemplate&&(this.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplateFn());break;case"quickAccessToolbarTemplate":e.quickAccessToolbarTemplate&&(this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.quickAccessToolbarTemplateFn());break;case"uploadSettings":e.uploadSettings?(this.uploadSettings=e.uploadSettings,this.uploadSettings.allowedExtensions?this.notify("draw",{prop:"setNullExtension",value:{extension:!1}}):(this.uploadSettings.allowedExtensions=".jpg, .jpeg, .png, .svg, .webp, .bmp",this.notify("draw",{prop:"setNullExtension",value:{extension:!0}})),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})):this.notify("draw",{prop:"setNullExtension",value:{extension:!0}}),this.updateDropInfoContent(this.element.querySelector(".e-ie-drop-info"));break;case"imageSmoothingEnabled":e.imageSmoothingEnabled?(this.imageSmoothingEnabled=!0,this.lowerContext.imageSmoothingQuality="high"):(this.imageSmoothingEnabled=!1,this.lowerContext.imageSmoothingQuality="low"),this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}})}}},t.prototype.destroy=function(){var t=[];this.element.removeAttribute("tabindex");var o=this.element.querySelector("#"+this.element.id+"_saveDialog");o&&"block"===o.style.display&&(0,g.getComponent)(document.getElementById(this.element.id+"_saveDialog"),"dialog").destroy(),this.cssClass&&(t=t.concat(this.cssClass.replace(/\s+/g," ").trim().split(" "))),(0,g.removeClass)([this.element],t),this.element.getAttribute("class")||this.element.removeAttribute("class"),this.unwireEvent(),this.notify("toolbar",{prop:"destroySubComponents",onPropertyChange:!1}),this.notify("destroyed",null),e.prototype.destroy.call(this),this.element.innerHTML=""},t.prototype.initialize=function(){if(this.disabled&&(this.element.classList.add("e-disabled","e-overlay"),this.element.style.opacity="0.5"),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.uploadSettings.allowedExtensions?this.notify("draw",{prop:"setNullExtension",value:{extension:!1}}):this.setProperties({uploadSettings:{allowedExtensions:".jpg, .jpeg, .png, .svg, .webp, .bmp"}},!0),this.createCanvas(),this.element.offsetWidth>359&&this.element.querySelector(".e-ie-min-drop-content")&&this.element.querySelector(".e-ie-drop-content")&&(this.element.querySelector(".e-ie-min-drop-content").style.display="none",this.element.querySelector(".e-ie-drop-content").style.display="block"),this.createDropUploader(),this.showQuickAccessToolbar){document.querySelector("#"+this.element.id+"_canvasWrapper").appendChild(this.createElement("div",{id:this.element.id+"_quickAccessToolbarArea",className:"e-quick-access-toolbar-area"}));var e=document.getElementById(this.element.id+"_quickAccessToolbarArea");e.style.position="absolute",e.style.display="none",this.activeObj&&(e.style.left=this.activeObj.activePoint.startX+"px",e.style.top=this.activeObj.activePoint.startY+"px"),e.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&&(0,g.addClass)([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&(0,b.createSpinner)({target:this.element}),this.initializeZoomSettings(),this.imgSrc&&this.open(this.imgSrc)},t.prototype.createDropUploader=function(){var e=this,t=this;new C.Uploader({dropArea:this.element.getElementsByClassName("e-canvas-wrapper")[0],allowedExtensions:this.uploadSettings.allowedExtensions,multiple:!1,selected:function(o){if("change"===o.event.type||"drop"===o.event.type){var i=o.filesData[0].type,r="unsupported",a=e.getExtensionArray().indexOf(i)>-1||"jpeg"===i&&(t.uploadSettings.allowedExtensions.indexOf("jpg")>-1||t.uploadSettings.allowedExtensions.indexOf("jpeg")>-1),n=o.filesData[0].size,s=t.uploadSettings.minFileSize&&n<t.uploadSettings.minFileSize||t.uploadSettings.maxFileSize&&n>t.uploadSettings.maxFileSize;("change"===o.event.type||"drop"===o.event.type&&1===o.event.dataTransfer.files.length)&&a&&!s?e.notify("draw",{prop:"fileSelect",value:{inputElement:e.element.querySelector("#"+e.element.id+"_dropfileUpload"),args:o}}):("drop"===o.event.type&&o.event.dataTransfer.files.length>1&&(r="multi-select-image"),e.showDialogPopup(r,!a))}}}).appendTo("#"+this.element.id+"_dropfileUpload")},t.prototype.dlgCloseBtnClick=function(){(0,g.getComponent)(document.getElementById(this.element.id+"_dialog"),"dialog").destroy()},t.prototype.showDialogPopup=function(e,t){var o,i="";this.element.querySelector("#"+this.element.id+"_dialog").style.display="block";var r={key:"DlgOK"};if(this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}}),"multi-select-image"===e){o={key:"ImageErrorDialogHeader"},this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});var a={key:"ImageErrorDialogContent"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}}),i="<span>"+a.value+"</span>"}else{o={key:"AlertDialogHeader"},this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});a={key:"AlertDialogContent"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}});var n={key:"SupportText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:n}});var s=this.getExtensionString(),l={key:"MinMaxSizeAlert"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:l}});var p={key:"And"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:p}});var h=void 0;this.uploadSettings.minFileSize&&this.uploadSettings.maxFileSize?h=" "+l.value+" <b> "+this.formatSizeUnits(this.uploadSettings.minFileSize)+" </b> "+p.value+" <b> "+this.formatSizeUnits(this.uploadSettings.maxFileSize)+" </b> ":this.uploadSettings.minFileSize?(l.key="MinSizeAlert",this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:l}}),h=" "+l.value+" <b> "+this.formatSizeUnits(this.uploadSettings.minFileSize)+" </b> "):this.uploadSettings.maxFileSize&&(l.key="MaxSizeAlert",this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:l}}),h=" "+l.value+" <b> "+this.formatSizeUnits(this.uploadSettings.maxFileSize)+" </b> "),t?i="<span>"+a.value+" "+n.value+"<b>"+s+"</b></span>":h&&(i="<span>"+a.value+" "+n.value+h+"</span>")}new b.Dialog({header:o.value,closeOnEscape:!0,content:i,target:document.getElementById("target"),width:g.Browser.isDevice?"285px":"400px",isModal:!0,animationSettings:{effect:"Zoom"},close:this.dlgCloseBtnClick.bind(this),buttons:[{click:this.dlgCloseBtnClick.bind(this),buttonModel:{content:r.value}}]}).appendTo("#"+this.element.id+"_dialog")},t.prototype.formatSizeUnits=function(e){return e>=1073741824?(e/1073741824).toFixed(2)+" GB":e>=1048576?(e/1048576).toFixed(2)+" MB":e>=1024?(e/1024).toFixed(2)+" KB":e>1?e+" bytes":1===e?e+" byte":"0 bytes"},t.prototype.getExtensionArray=function(){for(var e=["jpeg","jpg","png","svg","webp","bmp"],t=[],o=0,i=this.uploadSettings.allowedExtensions.split(",");o<i.length;o++)for(var r=i[o].trim(),a=0,n=e;a<n.length;a++){var s=n[a];if(-1!==r.indexOf(s)){t.push(s);break}}return t},t.prototype.getExtensionString=function(){var e={key:"And"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:e}});for(var t=this.getExtensionArray(),o="",i=0;i<t.length;i++){switch(i===t.length-1&&t.length>1&&("jpeg"!==t[i]&&"jpg"!==t[i]||!(o.indexOf("JPG")>-1))&&((2===t.length||3===t.length&&-1!==t.indexOf("jpeg")&&-1!==t.indexOf("jpg"))&&(o=o.replace(/,\s*$/,"")),o+=" "+e.value),t[i]){case"jpeg":case"jpg":-1===o.indexOf("JPG")&&(o+=" JPG,");break;case"png":o+=" PNG,";break;case"svg":o+=" SVG,";break;case"webp":o+=" WebP,";break;case"bmp":o+=" BMP,"}i===t.length-1&&(o=o.slice(0,-1))}return o},t.prototype.wireEvent=function(){g.EventHandler.add(document,"keydown",this.keyDownEventHandler,this),g.EventHandler.add(document,"keypress",this.keyUpEventHandler,this),g.EventHandler.add(this.upperCanvas,"mousedown",this.mouseDownEventHandler,this),g.EventHandler.add(this.upperCanvas,"mousemove",this.mouseMoveEventHandler,this),g.EventHandler.add(this.upperCanvas,"mouseup",this.mouseUpEventHandler,this),g.EventHandler.add(document,"mouseup",this.mouseUpEventHandler,this),g.EventHandler.add(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler,this),g.EventHandler.add(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler,this),g.EventHandler.add(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler,this),g.EventHandler.add(this.upperCanvas,"touchstart",this.touchStartHandler,this),g.EventHandler.add(this.lowerCanvas,"touchstart",this.touchStartHandler,this),g.EventHandler.add(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),g.EventHandler.add(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),window.addEventListener("resize",this.windowResizeHandler.bind(this)),g.Browser.isIos||"safari"===g.Browser.info.name||screen.orientation.addEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"wireEvent",onPropertyChange:!1})},t.prototype.unwireEvent=function(){g.EventHandler.remove(document,"keydown",this.keyDownEventHandler),g.EventHandler.remove(document,"keypress",this.keyUpEventHandler),g.EventHandler.remove(this.upperCanvas,"mousedown",this.mouseDownEventHandler),g.EventHandler.remove(this.upperCanvas,"mousemove",this.mouseMoveEventHandler),g.EventHandler.remove(this.upperCanvas,"mouseup",this.mouseUpEventHandler),g.EventHandler.remove(document,"mouseup",this.mouseUpEventHandler),g.EventHandler.remove(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler),g.EventHandler.remove(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler),g.EventHandler.remove(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler),g.EventHandler.remove(this.upperCanvas,"touchstart",this.touchStartHandler),g.EventHandler.remove(this.lowerCanvas,"touchstart",this.touchStartHandler),g.EventHandler.remove(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll),g.EventHandler.remove(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll),window.removeEventListener("resize",this.windowResizeHandler.bind(this)),g.Browser.isIos||"safari"===g.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})},t.prototype.createCanvas=function(){this.element.style.boxSizing="border-box";var e={toolbarHeight:0};this.notify("toolbar",{prop:"getToolbarHeight",value:{obj:e}});var t=e.toolbarHeight;this.toolbar&&this.toolbar.length>0&&-1===this.toolbar.indexOf("Open")&&(t=0),this.element.style.width=this.width,this.element.style.height=this.height;var o=this.createElement("div",{id:this.element.id+"_canvasWrapper",className:"e-canvas-wrapper"});o.style.cssText="height: "+(this.element.offsetHeight-t-2)+"px; width: "+(this.element.offsetWidth-2)+"px; position: relative; overflow: hidden; margin: 0 auto;";var i=this.element.appendChild(o),r={key:"DragText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}});var a={key:"DropText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}});var n={key:"BrowseText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:n}});var s=this.createElement("div",{id:this.element.id+"_dropArea",className:"e-ie-drop-area"});s.style.position="relative";var l=this.createElement("span",{className:"e-ie-drop-icon e-icons e-image"}),p=this.createElement("span",{className:"e-ie-drop-content"});p.style.cssText="display: none;",p.textContent=r.value+" ";var h=this.createElement("span",{className:"e-ie-min-drop-content"});h.textContent=a.value+" ";var d=this.createElement("a",{id:this.element.id+"_dropBrowse",className:"e-ie-drop-browse"});d.textContent=n.value;var c=this.createElement("a",{id:this.element.id+"_dropBrowse",className:"e-ie-drop-browse"});c.textContent=n.value,p.appendChild(d),h.appendChild(c),d.href="",c.href="";var u=this.createElement("span",{className:"e-ie-drop-info"});this.updateDropInfoContent(u);var g=s.appendChild(this.createElement("input",{id:this.element.id+"_dropfileUpload",className:"e-fileUpload e-image-upload"}));g.setAttribute("type","file"),g.setAttribute("accept","image/*"),s.appendChild(l),s.appendChild(p),s.appendChild(h),s.appendChild(u),i.appendChild(s),this.lowerCanvas=i.appendChild(this.createElement("canvas",{id:this.element.id+"_lowerCanvas",attrs:{name:"canvasImage"}})),this.maskCanvas=i.appendChild(this.createElement("canvas",{id:this.element.id+"_maskCanvas",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.baseImgCanvas=this.createElement("canvas",{id:this.element.id+"_baseImgCanvas",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";var v=this.element.appendChild(this.createElement("input",{id:this.element.id+"_fileUpload",className:"e-fileUpload"}));v.setAttribute("type","file"),v.setAttribute("accept","image/*"),v.style.display="none",this.textArea.setAttribute("spellcheck","false"),this.textArea.style.lineHeight="normal",this.lowerCanvas.style.width=this.upperCanvas.style.width=this.maskCanvas.style.width=this.inMemoryCanvas.style.width="100%",this.lowerCanvas.style.height=this.upperCanvas.style.height=this.maskCanvas.style.height=this.inMemoryCanvas.style.height="100%",this.upperCanvas.style.position=this.lowerCanvas.style.position=this.maskCanvas.style.position=this.textArea.style.position="absolute",this.textArea.style.backgroundColor="transparent",this.textArea.style.display="none",this.maskCanvas.style.display=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"),d.addEventListener("click",function(e){return e.preventDefault(),g.click(),!1}),c.addEventListener("click",function(e){return e.preventDefault(),g.click(),!1})},t.prototype.touchStartHandler=function(e){this.notify("selection",{prop:"touchStartHandler",onPropertyChange:!1,value:{e}})},t.prototype.mouseDownEventHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"mouseDownEventHandler",onPropertyChange:!1,value:{e}})},t.prototype.mouseMoveEventHandler=function(e){this.notify("selection",{prop:"mouseMoveEventHandler",onPropertyChange:!1,value:{e}})},t.prototype.mouseUpEventHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"mouseUpEventHandler",onPropertyChange:!1,value:{e}})},t.prototype.keyDownEventHandler=function(e){this.notify("selection",{prop:"keyDownEventHandler",onPropertyChange:!1,value:{e}})},t.prototype.keyUpEventHandler=function(e){"block"!==this.textArea.style.display&&"inline-block"!==this.textArea.style.display||e.target.id!==this.element.id+"_textArea"||this.notify("selection",{prop:"textKeyDown",value:{e}})},t.prototype.canvasMouseDownHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"canvasMouseDownHandler",onPropertyChange:!1,value:{e}})},t.prototype.canvasMouseMoveHandler=function(e){this.notify("selection",{prop:"canvasMouseMoveHandler",onPropertyChange:!1,value:{e}})},t.prototype.canvasMouseUpHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"canvasMouseUpHandler",onPropertyChange:!1,value:{e}})},t.prototype.handleScroll=function(e){this.notify("selection",{prop:"handleScroll",onPropertyChange:!1,value:{e}})},t.prototype.adjustToScreen=function(){this.update()},t.prototype.screenOrientation=function(){g.Browser.isDevice&&setTimeout(this.adjustToScreen.bind(this),100)},t.prototype.windowResizeHandler=function(){!g.Browser.isDevice&&this.element.classList.contains("e-image-editor")&&this.adjustToScreen()},t.prototype.notifyResetForAllModules=function(){for(var e=this.requiredModules(),t=0;t<e.length;t++){var o=e[t].member;this.notify("toolbar-module"===o?"toolbar":o,{prop:"reset",onPropertyChange:!1})}},t.prototype.allowShape=function(e,t){this.isPublicMethod=!0,this.applyShapes();var o={inRange:!1};return this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:e,y:t,obj:o}}),o.inRange},t.prototype.manageActiveAction=function(){this.applyShapes(),this.activeObj.shape&&this.activeObj.shape.indexOf("crop")>-1&&this.discard()},t.prototype.clearSelection=function(e){this.notify("selection",{prop:"clearSelection",onPropertyChange:!1,value:{resetCrop:e}})},t.prototype.crop=function(){var e={isCrop:!1};return this.notify("crop",{prop:"crop",onPropertyChange:!1,value:{obj:e}}),e.isCrop},t.prototype.flip=function(e){this.applyShapes(),this.activeObj.shape&&this.activeObj.shape.indexOf("crop")>-1?this.transformSelect(e.toLowerCase()+"flip"):(this.updateImageTransformColl(e.toLowerCase()+"flip"),this.setRotateZoom(),this.notify("transform",{prop:"flip",value:{direction:e}}),this.notify("draw",{prop:"redrawDownScale"}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}));var t={action:"flip",actionEventArgs:this.editCompleteArgs};this.triggerEditCompleteEvent(t)},t.prototype.getImageData=function(e){var t;if(e=!!(0,g.isNullOrUndefined)(e)||e){var o={canvas:null};this.applyShapes(),this.notify("export",{prop:"exportToCanvas",value:{object:o}}),t=o.canvas.getContext("2d").getImageData(0,0,o.canvas.width,o.canvas.height)}else this.isMaskImage&&"mask-drawing"===this.element.getAttribute("data-value")?(t=this.getData(!0),this.updateColl("reset")):(t=this.getData(),this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}));return t},t.prototype.open=function(e,t,o){var i=this;if(t=!!(0,g.isNullOrUndefined)(t)||t){if((0,g.isNullOrUndefined)(e)||this.disabled)return;var r=document.getElementById(this.element.id+"_dropArea");if(r&&(r.style.display="none"),this.imageSettings={width:null,height:null},this.aspectRatioBaseDimension=null,o&&(o.width||o.height)){var a=(0,g.extend)({},o,{},!0);if(o=this.scaleToFit(o),this.aspectRatioBaseDimension=o.isAspectRatio,!o.isAspectRatio&&o.width&&o.height){this.imageSettings.width=o.width,this.imageSettings.height=o.height,this.notify("draw",{prop:"open",value:{data:e}});var n=setInterval(function(){i.imageLoaded&&i.baseImg.width&&i.baseImg.height&&(i.setInitialZoomLevel(a),clearInterval(n))},1)}else if(o.width||o.height){this.notify("draw",{prop:"open",value:{data:e}});var s=setInterval(function(){if(i.imageLoaded&&i.baseImg.width&&i.baseImg.height){i.imageSettings.width=o.width,i.imageSettings.height=o.height;var t=i.baseImg.width,r=i.baseImg.height,n="",l=void 0,p=void 0;o.width&&o.height&&(n=o.width>o.height?"width":"height"),"width"===n||o.width&&"height"!==n?(p=(l=o.width/(t/r))%1>=.5||l%1<=-.5?Math.round(l):l<0?Math.ceil(l):Math.floor(l),!o.height||p>o.height?i.imageSettings.height=o.height=p:(p=(l=o.height/(r/t))%1>=.5||l%1<=-.5?Math.round(l):l<0?Math.ceil(l):Math.floor(l),i.imageSettings.width=o.width=p)):("height"===n||o.height&&"width"!==n)&&(p=(l=o.height/(r/t))%1>=.5||l%1<=-.5?Math.round(l):l<0?Math.ceil(l):Math.floor(l),!o.width||p>o.width?i.imageSettings.width=o.width=p:(p=(l=o.width/(t/r))%1>=.5||l%1<=-.5?Math.round(l):l<0?Math.ceil(l):Math.floor(l),i.imageSettings.height=o.height=p)),i.notify("draw",{prop:"open",value:{data:e}}),i.setInitialZoomLevel(a),clearInterval(s)}},1)}}else this.notify("draw",{prop:"open",value:{data:e}})}else this.updateImage(e,o?o.backgroundColor:null)},t.prototype.reset=function(){this.updateColl("reset");var e={isErrorImage:!1};if(this.notify("draw",{prop:"getErrorImage",value:{obj:e}}),!this.disabled&&!e.isErrorImage){this.clearContext(this.inMemoryContext),this.clearContext(this.lowerContext),this.clearContext(this.upperContext),this.notify("shape",{prop:"setRedactType",onPropertyChange:!1,value:{redactType:"blur"}}),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),g.Browser.isDevice&&document.getElementById(this.element.id+"_bottomToolbar")&&((0,g.getComponent)(document.getElementById(this.element.id+"_bottomToolbar"),"toolbar").destroy(),this.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1}));var t=this.isImageLoaded;this.currObjType.isUndoAction=this.isUndoRedo=this.togglePan=this.togglePen=this.isImageLoaded=this.isFinetuning=!1,this.isCircleCrop=this.isCropTab=!1,this.objColl=[],this.transform.degree=0,this.upperCanvas.style.display="block",this.transform.currFlipState="",this.allowDownScale=!0,this.upperCanvas.style.cursor=this.cursor=this.lowerCanvas.style.cursor="default",this.lowerContext.lineWidth=this.upperContext.lineWidth=void 0,this.frameDestPoints=null,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.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},this.tempFrameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},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,isRedact:!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:"",straighten:0,zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},frame:"none",srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,aspectWidth:null,aspectHeight:null,straightenZoom:0,adjustmentLevel:{brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},currentFilter:""},this.afterCropActions=[],this.currentFilter="",this.tempFrameZoomLevel=null,this.cxtTbarHeight=null,this.straightenPoint=null,this.transform.straighten=0,this.cancelCropSelection=null,this.aspectWidth=this.aspectHeight=null,this.isResize=this.isMaskImage=!1,this.drawingShape=null,this.isShapeDrawing=this.noPushUndo=this.isUndoRedoStack=this.isKBDNavigation=!1,this.shapeColl=[],this.tempObjColl=[],this.tempPointColl=[],this.tempShapeColl=[],this.isImageUpdated=!1,this.tempToolbarHeight=0,this.tempToolbar=[],this.tempRedactBlur=50,this.tempRedactPixel=40;var o={initialZoomValue:!1};this.editCompleteArgs=null,this.isFinetuneBtnClick=!1,this.notify("draw",{prop:"getInitialZoomValue",onPropertyChange:!1,value:{obj:o}}),o.initialZoomValue&&this.setProperties({zoomSettings:{zoomFactor:o.initialZoomValue}},!0);var i=document.getElementById(this.element.id+"_quickAccessToolbarArea");i&&(i.style.display="none"),this.notifyResetForAllModules(),this.notify("filter",{prop:"update-finetunes"}),this.toolbarTemplate?this.toolbarHeight=this.element.querySelector("#"+this.element.id+"_toolbarArea").clientHeight:this.element.querySelector("#"+this.element.id+"_toolbar")&&(this.toolbarHeight=this.element.querySelector("#"+this.element.id+"_toolbar").clientHeight),this.notify("toolbar",{prop:"setToolbarHeight",value:{height:this.toolbarHeight}}),this.isImageLoaded=t,this.straightenBaseImageCanvas(),this.isImageLoaded=!1,this.notify("draw",{prop:"update-canvas",onPropertyChange:!1}),this.isImageLoaded=t,this.prevStraightenedDegree=0;var r=this.element.querySelector(".e-contextual-toolbar-wrapper");r&&r.classList.add("e-hide"),this.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),this.notify("toolbar",{prop:"enable-disable-btns"});var a={bool:this.isStraightening};g.Browser.isDevice&&a.bool&&this.notify("crop",{prop:"resizeWrapper"});var n=this.element.querySelector("#"+this.element.id+"_saveDialog");n&&(0,g.getComponent)(n,"dialog").close();this.triggerEditCompleteEvent({action:"reset",actionEventArgs:null})}},t.prototype.rotate=function(e){var t={isRotate:!1};this.applyShapes(),this.activeObj.shape&&this.activeObj.shape.indexOf("crop")>-1?(this.transformSelect(90===e?"rotateright":"rotateleft"),t.isRotate=!0):(90!==e&&-90!==e||this.updateImageTransformColl(90===e?"rotateright":"rotateleft"),this.setRotateZoom(),this.notify("transform",{prop:"rotate",value:{degree:e,obj:t}}),this.notify("draw",{prop:"redrawDownScale"}));var o={action:"rotate",actionEventArgs:this.editCompleteArgs};return this.triggerEditCompleteEvent(o),t.isRotate},t.prototype.export=function(e,t,o){this.manageActiveAction(),this.notify("export",{prop:"export",onPropertyChange:!1,value:{type:e,fileName:t,imgQuality:o}})},t.prototype.select=function(e,t,o,i,r){this.applyShapes(),this.notify("toolbar",{prop:"performCropTransformClick",value:{shape:"crop-"+e}}),this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:e,startX:t,startY:o,width:i,height:r}}),t&&o||i&&r?this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:e,startX:t,startY:o,width:i,height:r}}):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:"",straighten:0,zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},frame:"none",srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,aspectWidth:null,aspectHeight:null,straightenZoom:0,adjustmentLevel:{brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},currentFilter:""}},t.prototype.freeHandDraw=function(e){this.notify("freehand-draw",{prop:"freeHandDraw",onPropertyChange:!1,value:{value:e}})},t.prototype.freehandDraw=function(e){if(!this.disabled&&this.isImageLoaded){if(!e&&this.isMaskImage)return void this.discard();this.manageActiveAction(),this.freeHandDraw(e);var t={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:t}});var o=t.shapeSettingsObj;o.type=i.FreehandDraw;var r={cancel:!1,action:"insert",previousShapeSettings:o,currentShapeSettings:o};this.notify("freehand-draw",{prop:"triggerShapeChanging",value:{shapeChangingArgs:r}})}},t.prototype.pan=function(e,t,o){this.applyShapes(),this.notify("transform",{prop:"pan",onPropertyChange:!1,value:{value:e,x:t,y:o}})},t.prototype.zoom=function(e,t){this.isZoomBtnClick=!0;var o=this.transform.zoomFactor;if(0!==o){var i={previousZoomValue:null};this.notify("transform",{prop:"getPreviousZoomValue",value:{obj:i}}),o=i.previousZoomValue}1!==e&&0!==o&&(o<1&&e>1||o>1&&e<1)&&this.notify("transform",{prop:"zoom",onPropertyChange:!1,value:{zoomFactor:1,zoomPoint:t}}),this.notify("transform",{prop:"zoom",onPropertyChange:!1,value:{zoomFactor:e,zoomPoint:t}}),this.notify("draw",{prop:"redrawDownScale"})},t.prototype.drawEllipse=function(e,t,o,i,r,a,n,s,l){var p=!1,h=this.allowShape(e,t);return!this.disabled&&this.isImageLoaded&&(h||(0,g.isNullOrUndefined)(e)&&(0,g.isNullOrUndefined)(t))&&(p=!0,this.manageActiveAction(),this.notify("shape",{prop:"drawEllipse",onPropertyChange:!1,value:{x:e,y:t,radiusX:o,radiusY:i,strokeWidth:r,strokeColor:a,fillColor:n,degree:s,isSelected:l}}),this.editCompleted()),p},t.prototype.drawLine=function(e,t,o,i,r,a,n){var s=!1,l=this.allowShape(e,t);return!this.disabled&&this.isImageLoaded&&(l||(0,g.isNullOrUndefined)(e)&&(0,g.isNullOrUndefined)(t))&&(s=!0,this.manageActiveAction(),this.notify("shape",{prop:"drawLine",onPropertyChange:!1,value:{startX:e,startY:t,endX:o,endY:i,strokeWidth:r,strokeColor:a,isSelected:n}}),this.editCompleted()),s},t.prototype.drawArrow=function(e,t,o,i,r,a,n,s,l){var p=!1,h=this.allowShape(e,t);return!this.disabled&&this.isImageLoaded&&(h||(0,g.isNullOrUndefined)(e)&&(0,g.isNullOrUndefined)(t))&&(p=!0,this.manageActiveAction(),this.notify("shape",{prop:"drawArrow",onPropertyChange:!1,value:{startX:e,startY:t,endX:o,endY:i,strokeWidth:r,strokeColor:a,arrowStart:n,arrowEnd:s,isSelected:l}}),this.editCompleted()),p},t.prototype.drawPath=function(e,t,o,i){this.isPublicMethod=!0;var r={inRange:!1},a=!1;if(e&&e.length>0)for(var n=0;n<e.length&&!r.inRange;n++)this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:e[n].x,y:e[n].y,obj:r}});return!this.disabled&&this.isImageLoaded&&(r.inRange||(0,g.isNullOrUndefined)(e))&&(a=!0,this.manageActiveAction(),this.notify("shape",{prop:"drawPath",onPropertyChange:!1,value:{pointColl:e,strokeWidth:t,strokeColor:o,isSelected:i}}),this.editCompleted()),a},t.prototype.drawRectangle=function(e,t,o,i,r,a,n,s,l,p){var h=!1,d=this.allowShape(e,t);return!this.disabled&&this.isImageLoaded&&(d||(0,g.isNullOrUndefined)(e)&&(0,g.isNullOrUndefined)(t))&&(h=!0,this.manageActiveAction(),this.notify("shape",{prop:"drawRectangle",onPropertyChange:!1,value:{x:e,y:t,width:o,height:i,strokeWidth:r,strokeColor:a,fillColor:n,degree:s,isSelected:l,radius:p}}),this.editCompleted()),h},t.prototype.drawText=function(e,t,o,i,r,a,n,s,l,p,h,d,c,u,v,f){var m=!1,b=this.allowShape(e,t);return!this.disabled&&this.isImageLoaded&&(b||(0,g.isNullOrUndefined)(e)&&(0,g.isNullOrUndefined)(t))&&(m=!0,this.manageActiveAction(),this.notify("shape",{prop:"drawText",onPropertyChange:!1,value:{x:e,y:t,text:o,fontFamily:i,fontSize:r,bold:a,italic:n,color:s,isSelected:l,degree:p,fillColor:h,outlineColor:d,outlineWidth:c,transformCollection:u,underline:v,strikethrough:f}}),this.editCompleted()),m},t.prototype.drawImage=function(e,t,o,i,r,a,n,s,l){var p=!1,h=this.allowShape(t,o);if(!this.disabled&&this.isImageLoaded&&(h||(0,g.isNullOrUndefined)(t)&&(0,g.isNullOrUndefined)(o))){if("string"==typeof e)try{var d=new XMLHttpRequest,c=0===e.indexOf("blob:");d.open(c?"GET":"HEAD",e,!1),d.send(),p=d.status>=200&&d.status<300}catch(e){p=!1}else e instanceof ImageData&&e.data instanceof Uint8ClampedArray&&e.width>0&&e.height>0&&(p=!0);this.manageActiveAction(),this.notify("shape",{prop:"drawImage",onPropertyChange:!1,value:{x:t,y:o,width:i,height:r,src:e,degree:n,isAspectRatio:a,opacity:s,isSelected:l}}),this.editCompleted()}return p},t.prototype.updateShape=function(e,t){var o={isSelected:!1},i=!1,r={bool:!1};if((0,g.isNullOrUndefined)(e.id))e.strokeColor&&(this.activeObj.strokeSettings.strokeColor=e.strokeColor),e.fillColor&&(this.activeObj.strokeSettings.fillColor=e.fillColor),e.strokeWidth&&(this.activeObj.strokeSettings.strokeWidth=e.strokeWidth),e.index&&(this.activeObj.order=e.index),"FreehandDraw"===e.type&&e.strokeWidth&&this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:e.strokeWidth}});else if("text"!==e.type.toLowerCase()||"block"!==this.textArea.style.display&&"inline-block"!==this.textArea.style.display||(this.okBtn(null,!0),i=!0),this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:e.id,obj:o,isShape:!0}}),this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:r}}),o.isSelected){var a=this.activeObj.textSettings.fontSize;if(this.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e}}),"text"===this.activeObj.shape&&a){var n=this.activeObj.textSettings.fontSize-a;0!==n&&(this.activeObj.activePoint.height+=n,this.activeObj.activePoint.startY-=n/2,this.activeObj.activePoint.endY+=n/2,this.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:this.activeObj.activePoint,obj:this.activeObj,isMouseMove:null,x:null,y:null}}))}var s=(0,g.extend)({},this.activeObj,{},!0);this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:null}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),s.shape&&this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:s}}),"text"===this.activeObj.shape&&this.notify("toolbar",{prop:"editText",onPropertyChange:!1}),r.bool&&this.notify("undo-redo",{prop:"setPreventUR",value:{bool:!0}}),this.okBtn(t,!0),r.bool&&this.notify("undo-redo",{prop:"setPreventUR",value:{bool:!1}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.editCompleteArgs={action:"shape-update",currentShapeSettings:e},this.editCompleted("shape-customize"),i&&this.enableTextEditing(),t&&(this.noRedact=!0,this.selectShape(e.id))}return o.isSelected},t.prototype.selectShape=function(e){this.applyShapes();var t={isSelected:!1};return this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:e,obj:t,isShape:!0}}),this.editCompleted("shape-select"),this.noRedact=!1,t.isSelected},t.prototype.deleteShape=function(e){"Redact"!==this.getShapeSetting(e).type&&(this.applyShapes(),this.notify("shape",{prop:"deleteShape",onPropertyChange:!1,value:{id:e,isShape:!0}}),this.editCompleted("shape-delete"),this.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}))},t.prototype.getShapeSetting=function(e){this.applyShapes();var t={shapeDetails:null};return this.notify("shape",{prop:"getShapeSetting",onPropertyChange:!1,value:{id:e,obj:t}}),this.notify("draw",{prop:"redrawDownScale"}),t.shapeDetails?t.shapeDetails:{}},t.prototype.getShapeSettings=function(){this.applyShapes();var e={shapeDetailsColl:[]};return this.notify("shape",{prop:"getShapeSettings",onPropertyChange:!1,value:{obj:e}}),this.notify("draw",{prop:"redrawDownScale"}),e.shapeDetailsColl.filter(function(e){return"redact"!==e.type})},t.prototype.getRedacts=function(){this.applyShapes();var e={shapeDetailsColl:[]};return this.notify("shape",{prop:"getRedactSettings",onPropertyChange:!1,value:{obj:e}}),this.notify("draw",{prop:"redrawDownScale"}),e.shapeDetailsColl.filter(function(e){return"redact"!==e.type})},t.prototype.selectRedact=function(e){this.applyShapes();var t={isSelected:!1};return this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:e,obj:t,isRedact:!0}}),this.editCompleted("redact-select"),this.noRedact=!1,t.isSelected},t.prototype.deleteRedact=function(e){this.applyShapes(),this.notify("shape",{prop:"deleteShape",onPropertyChange:!1,value:{id:e,isRedact:!0}}),this.editCompleted("redact-delete")},t.prototype.updateRedact=function(e,t){this.applyShapes();var o={isSelected:!1};if(this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:e.id,obj:o,isRedact:!0}}),o.isSelected){this.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e}}),e.blurIntensity&&(this.activeObj.redactBlur=e.blurIntensity),e.pixelSize&&(this.activeObj.redactPixelate=e.pixelSize),this.activeObj.redactType="blur"===e.type.toLowerCase()?"blur":"pixelate";var i=(0,g.extend)({},this.activeObj,{},!0);this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:null}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),i.shape&&this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i}}),this.okBtn(t,!0),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.editCompleteArgs={action:"redact-update",currentShapeSettings:e},this.editCompleted("redact-customize"),t&&this.selectRedact(e.id)}return o.isSelected},t.prototype.update=function(){this.notify("transform",{prop:"update"})},t.prototype.finetuneImage=function(e,t){!this.disabled&&this.isImageLoaded&&(this.manageActiveAction(),this.notify("filter",{prop:"finetuneImage",value:{value:t,option:e}}),this.editCompleteArgs={finetune:e,value:t},this.editCompleted("fine-tune"))},t.prototype.applyImageFilter=function(e){!this.disabled&&this.isImageLoaded&&(this.manageActiveAction(),this.notify("filter",{prop:"applyImageFilter",value:{option:e.toString()}}),this.editCompleteArgs={filter:e},this.editCompleted("filter"),this.canvasFilter=this.lowerContext.filter,this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))},t.prototype.undo=function(){this.handlePenActiveState(),this.notify("undo-redo",{prop:"undo",onPropertyChange:!1}),this.notify("draw",{prop:"redrawDownScale"})},t.prototype.redo=function(){this.handlePenActiveState(),this.notify("undo-redo",{prop:"redo",onPropertyChange:!1}),this.notify("draw",{prop:"redrawDownScale"})},t.prototype.getImageDimension=function(){return{x:this.img.destLeft,y:this.img.destTop,width:this.img.destWidth,height:this.img.destHeight}},t.prototype.resize=function(e,t,o){var i=!1;if(e.toString().length<=4&&t.toString().length<=4&&(!this.isCircleCrop||o)){this.manageActiveAction(),this.isPublicMethod=!0,this.notify("toolbar",{prop:"resizeClick",value:{bool:!1}});var r={startX:this.img.destLeft,startY:this.img.destTop,width:this.img.destWidth,height:this.img.destHeight};o?(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}})):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}});var a=this.element.querySelector("#"+this.element.id+"_resizeWidth"),n=this.element.querySelector("#"+this.element.id+"_resizeHeight");a&&n&&((0,g.getComponent)(a,"numerictextbox").value=Math.floor(e),a.value=Math.floor(e).toString()+" px",(0,g.getComponent)(n,"numerictextbox").value=Math.floor(t),n.value=Math.floor(t).toString()+" px"),this.notify("transform",{prop:"resize",value:{width:e,height:t,isAspectRatio:o}}),r.startX!==this.img.destLeft||r.startY!==this.img.destTop||r.width!==this.img.destWidth||r.height!==this.img.destHeight?(i=!0,this.aspectWidth=e,this.aspectHeight=t,o&&(this.aspectHeight=null),this.okBtn(!1,!1,!0)):this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),this.isPublicMethod=!1,this.notify("draw",{prop:"redrawDownScale"})}return i},t.prototype.drawFrame=function(e,t,o,i,r,a,n,s,l){this.manageActiveAction();var p=!1,h={frameChangeEventArgs:null};t=t||"#fff",o=o||"",i=i||20,r=r||0,a=a||0,n=n||0,s=s||d.Solid,l=l||0;var c={type:this.toPascalCase(this.frameObj.type),color:this.frameObj.color,gradientColor:this.frameObj.gradientColor,size:this.frameObj.size,inset:this.frameObj.inset,offset:this.frameObj.offset,borderRadius:this.frameObj.radius,frameLineStyle:this.toPascalCase(this.frameObj.border),lineCount:this.frameObj.amount};(0,g.extend)(this.tempFrameObj,this.frameObj),this.tempFrameZoomLevel=this.transform.zoomFactor,this.frameDestPoints=(0,g.extend)({},this.img,{},!0),this.notify("toolbar",{prop:"frameToolbarClick"}),this.frameObj.type=e.toLowerCase(),this.frameObj.color=t,this.frameObj.gradientColor=o,this.frameObj.size=i,this.frameObj.inset=r,this.frameObj.offset=a,this.frameObj.radius=n,this.frameObj.border=s.toLowerCase(),this.frameObj.amount=l,this.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:c,obj:h}}),h.frameChangeEventArgs&&!h.frameChangeEventArgs.cancel?(this.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),JSON.stringify(this.frameObj)!==JSON.stringify(this.tempFrameObj)?(p=!0,this.okBtn()):this.tempFrameZoomLevel=null):(this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),(0,g.extend)(this.frameObj,this.tempFrameObj),this.tempFrameZoomLevel=null),this.notify("draw",{prop:"redrawDownScale"});var u=this.element.querySelector(".e-contextual-toolbar-wrapper");return u&&u.classList.add("e-hide"),p},t.prototype.straightenImage=function(e){var t=!1;return e>=-45&&e<=45&&(this.applyShapes(),t=!0,this.notify("transform",{prop:"straightenImage",value:{degree:e}}),this.notify("draw",{prop:"redrawDownScale"})),t},t.prototype.cloneShape=function(e){var t={isSelected:!1};return"shape"===e.split("_")[0]&&(this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:e,obj:t}}),t.isSelected&&(this.notify("toolbar",{prop:"duplicateShape",onPropertyChange:!1,value:{isPreventUndoRedo:!1}}),this.okBtn(null,!0),this.notify("draw",{prop:"redrawDownScale"}))),t.isSelected},t.prototype.getImageFilter=function(e){var t=this.createElement("canvas").getContext("2d");return this.notify("filter",{prop:"updateAdj",value:{type:e.toLowerCase(),value:null,isPreview:!0,ctx:t}}),t.filter},t.prototype.enableTextEditing=function(){var e=(0,g.extend)({},this.activeObj,{},!0);e.order||(this.noPushUndo=!0,this.okBtn(),this.noPushUndo=!1,this.noRedact=!0,this.selectShape(e.currIndex),e.order=this.activeObj.order),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!1}}),this.activeObj=e,this.notify("toolbar",{prop:"editText",onPropertyChange:!1})},t.prototype.canUndo=function(){var e=!1;return this.getUndoRedoColl().index>0&&(e=!0),e},t.prototype.canRedo=function(){var e=!1,t=this.getUndoRedoColl(),o=t.undoRedoColl,i=t.index;return o&&o.length>0&&i<o.length-1&&(e=!0),i===o.length?e=!1:(0===i&&o.length>0||i>0)&&(e=!0),e},t.prototype.apply=function(){this.isMaskImage?this.discard():(this.updateColl("reset"),this.closeOverlayTbar(),this.okBtn(null,!0))},t.prototype.discard=function(){this.updateColl("reset"),this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:this.closeOverlayTbar(),isFinalCancel:!0}})},t.prototype.enableShapeDrawing=function(e,t){if(t&&(this.drawingShape=e.toLowerCase(),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})),e&&t){this.currObjType.shape=e.toLowerCase(),this.activeObj.shape=this.currObjType.shape,this.currObjType.isDragging=this.currObjType.isCustomCrop=!1,this.activeObj.shapeDegree=this.transform.degree,this.activeObj.shapeFlip=this.transform.currFlipState,this.activeObj.textFlip=this.transform.currFlipState,this.activeObj.flipObjColl=[];var o={order:null};this.notify("shape",{prop:"getNewOrder",onPropertyChange:!1,value:{obj:o}}),this.activeObj.order=o.order,this.notify("selection",{prop:"annotate",value:{shape:this.currObjType.shape}}),"text"===this.currObjType.shape?this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):"redact"===this.currObjType.shape?this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"redact",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),this.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})}else t||this.okBtn(null,!0)},t.prototype.bringToFront=function(e){this.noRedact=!0,this.selectShape(e)&&(this.updateShapeOrder(e,"bringToFront"),this.apply())},t.prototype.bringForward=function(e){this.noRedact=!0,this.selectShape(e)&&(this.updateShapeOrder(e,"bringForward"),this.apply())},t.prototype.sendToBack=function(e){this.noRedact=!0,this.selectShape(e)&&(this.updateShapeOrder(e,"sendToBack"),this.apply())},t.prototype.sendBackward=function(e){this.noRedact=!0,this.selectShape(e)&&(this.updateShapeOrder(e,"sendBackward"),this.apply())},t.prototype.clearImage=function(){this.reset(),this.isImageLoaded=!1,this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);var e=document.getElementById(this.element.id+"_bottomToolbar");g.Browser.isDevice&&e&&(document.getElementById(this.element.id+"_bottomToolbar").style.display="none"),this.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"create-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"create-contextual-toolbar",onPropertyChange:!1});var t=document.getElementById(this.element.id+"_dropArea");t&&(t.style.display="flex")},t.prototype.selectMaskImage=function(e,t){e=e||10,t=t||"#512da880",this.applyShapes(),this.isMaskImage=!0,this.updateColl("empty"),this.enableDisableToolbar(!0),this.update(),this.activeObj.strokeSettings.strokeWidth=e,this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:e}}),this.activeObj.strokeSettings.strokeColor=t,this.notify("freehand-draw",{prop:"freeHandDraw",onPropertyChange:!1,value:{value:!0}}),this.maskCanvas.style.display="block"},t.prototype.enableDisableToolbar=function(e){var t,o=document.getElementById(this.element.id+"_toolbar");o&&(t=(0,g.getComponent)(o,"toolbar"))&&t.disable(e),(o=document.getElementById(this.element.id+"_bottomToolbar"))&&(t=(0,g.getComponent)(o,"toolbar"))&&t.disable(e)},t.prototype.updateImage=function(e,t){var o=this;if(e||t||""===t){var i=(0,g.extend)({},this.cropObj,{},!0),r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=(0,g.extend)([],this.objColl,[],!0),a.pointColl=(0,g.extend)([],this.pointColl,[],!0),a.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var n={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=(0,g.extend)([],n.selPointColl,[],!0),e){if(this.isImageUpdated=!0,"string"!=typeof e){var s=this.createElement("canvas");s.width=e.width,s.height=e.height,s.getContext("2d").putImageData(e,0,0),e=s.toDataURL()}this.baseImg.src=e,setTimeout(function(){0!==o.cropObj.straighten?(o.notify("toolbar",{prop:"performCropTransformClick",value:{shape:"crop-custom"}}),o.noPushUndo=!0,o.crop(),o.noPushUndo=!1):o.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),o.isImageUpdated=!1,t||(o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"updateImage",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))},100)}(t||""===t)&&(this.notify("draw",{prop:"imageBackgroundColor",onPropertyChange:!1,value:{color:t}}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),e||(this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"bgColor",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))),e&&t&&(this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"updateImage",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))}},t.prototype.editCompleted=function(e){this.notify("draw",{prop:"redrawDownScale"});var t={action:e||"shape-insert",actionEventArgs:this.editCompleteArgs};this.triggerEditCompleteEvent(t)},t.prototype.updateColl=function(e){this.isMaskImage&&("empty"===e?(this.tempToolbarHeight=this.toolbarHeight,this.tempToolbar=this.toolbar?(0,g.extend)([],this.toolbar,[],!0):null,this.tempObjColl=(0,g.extend)([],this.objColl,[],!0),this.tempPointColl=(0,g.extend)([],this.pointColl,[],!0),this.tempShapeColl=(0,g.extend)([],this.shapeColl,[],!0),this.objColl=[],this.pointColl=[],this.shapeColl=[],this.freehandCounter=0,this.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:0}}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}})):"reset"===e&&(this.objColl=this.tempObjColl,this.pointColl=this.tempPointColl,this.shapeColl=this.tempShapeColl,this.freehandCounter=this.pointColl.length,this.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:this.freehandCounter}}),this.enableDisableToolbar(!1),0!==this.cropObj.straighten&&(this.notify("toolbar",{prop:"performCropTransformClick",value:{shape:"crop-custom"}}),this.noPushUndo=!0,this.crop(),this.noPushUndo=!1),this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),this.isMaskImage=!1,this.upperContext.globalCompositeOperation="source-over",this.maskCanvas.style.display="none",this.activeObj.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null,radius:null,outlineColor:"",outlineWidth:null},this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.activeObj.strokeSettings,strokeColor:"#fff",fillColor:"",strokeWidth:null,outlineWidth:null}}),this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:2}}),this.notify("freehand-draw",{prop:"setMasking",onPropertyChange:!1,value:{value:!1}})))},t.prototype.scaleToFit=function(e){var t=(0,g.extend)({},e,{},!0),o=this.lowerCanvas.clientWidth,i=this.lowerCanvas.clientHeight;if(e.width&&e.height&&(e.width>o||e.height>i)){var r=o/e.width,a=i/e.height,n=Math.min(r,a);t.width=Math.round(e.width*n),t.height=Math.round(e.height*n)}else if(e.width&&e.width>o){n=o/e.width;t.width=Math.round(e.width*n)}else if(e.height&&e.height>i){n=i/e.height;t.height=Math.round(e.height*n)}return t},t.prototype.setInitialZoomLevel=function(e){var t=this,o=1,i=this.img.destWidth,r=this.img.destHeight,a=e.width,n=e.height,s={width:0,height:0};for(this.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.img.srcWidth,height:this.img.srcHeight,obj:s,isImgShape:null}});(i&&a&&a>i||r&&n&&n>r)&&(i=s.width+.025*s.width*o,r=s.height+.025*s.height*o,!(Math.abs(i)>=Math.abs(a)&&Math.abs(r)>=Math.abs(n)));)o++;if(o>1){this.isImageLoaded=!0;var l=setInterval(function(){if(t.imageLoaded){for(var e=1;e<o;e++){if(!(Math.round(e/4)<t.zoomSettings.maxZoomFactor)){o=e;break}t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.025,zoomPoint:null,isResize:!0}})}t.setProperties({zoomSettings:{zoomFactor:Math.round(o/4)}},!0),t.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:t.zoomSettings.zoomFactor}}),t.notify("toolbar",{prop:"enable-disable-btns"}),clearInterval(l)}},1)}},t.prototype.resetToolbar=function(){this.toolbarHeight!==this.tempToolbarHeight&&!((0,g.isNullOrUndefined)(this.toolbar)||this.toolbar&&this.toolbar.length>0)&&(0,g.isNullOrUndefined)(this.toolbarTemplate)&&(this.toolbarHeight=this.tempToolbarHeight,this.notify("toolbar",{prop:"setToolbarHeight",value:{height:this.toolbarHeight}}),this.toolbar=this.tempToolbar,this.toolbarTemplate||(this.notify("toolbar",{prop:"create-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"create-contextual-toolbar",onPropertyChange:!1})),this.update())},t.prototype.setRotateZoom=function(){this.transform.zoomFactor>0?this.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}):this.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}})},t.prototype.getData=function(e){e&&this.resetToolbar();var t=(0,g.extend)([],this.objColl,null,!0),o=(0,g.extend)([],this.pointColl,null,!0),i=(0,g.extend)([],this.shapeColl,null,!0);if(e){this.notify("shape",{prop:"updateShapeColl",onPropertyChange:!1});for(var r=0;r<this.freehandCounter;r++)this.pointColl[r].strokeColor="#fff"}else this.objColl=[],this.pointColl=[],this.shapeColl=[],this.freehandCounter=0;var a=this.frameObj.type;this.frameObj.type="none";var n=this.aspectWidth,s=this.aspectHeight;this.aspectWidth=this.aspectHeight=null;var l=this.cropObj.straighten;this.togglePen=!1,this.notify("toolbar",{prop:"performCropTransformClick",value:{shape:"crop-custom"}});var p=(0,g.extend)({},this.img,{},!0),h=(0,g.extend)({},this.cropObj,{},!0),d=(0,g.extend)({},this.activeObj,{},!0),c=(0,g.extend)({},this.transform,{},!0),u=(0,g.extend)({},this.panPoint,{},!0);0!==l&&this.setStraighten(0);var v=this.activeObj.activePoint;v.startX=this.img.destLeft,v.startY=this.img.destTop,v.width=this.img.destWidth,v.height=this.img.destHeight,v.endX=v.startX+v.width,v.endY=v.startY+v.height,this.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:v,obj:this.activeObj,isMouseMove:null,x:null,y:null}}),this.noPushUndo=!0,this.crop(),this.noPushUndo=!1,this.isCropTab=!1,this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.notify("crop",{prop:"resetZoom",onPropertyChange:!1}),this.isCropTab=!0;var f=(0,g.extend)([],this.afterCropActions,[],!0),m=(0,g.extend)([],this.rotateFlipColl,[],!0);this.notify("crop",{prop:"revertTransform",value:{type:"initial",coll:m}});var b=this.getImageData();if(e){var C=this.createElement("canvas"),y=C.getContext("2d");if(C.width=b.width,C.height=b.height,y.fillRect(0,0,C.width,C.height),this.pointColl.length>0){var x={width:0,height:0};this.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:x,dimension:{width:C.width,height:C.height}}});var P=x;this.notify("export",{prop:"drawAnnotation",value:{context:y,ratio:P}})}this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),b=y.getImageData(0,0,C.width,C.height)}return this.notify("crop",{prop:"revertTransform",value:{type:"reverse",coll:m}}),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.afterCropActions=f,e||(this.objColl=t,this.pointColl=o,this.shapeColl=i,this.freehandCounter=this.pointColl.length),this.frameObj.type=a,this.aspectWidth=n,this.aspectHeight=s,this.notify("toolbar",{prop:"performCropTransformClick",value:{shape:"crop-custom"}}),0!==l&&this.setStraighten(l),this.img=p,this.cropObj=h,this.activeObj=d,this.transform=c,this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null,isResize:null}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null,isResize:null}}),0!==this.transform.degree&&(this.panPoint.currentPannedPoint={x:u.totalPannedClientPoint.x,y:u.totalPannedClientPoint.y},this.notify("transform",{prop:"drawPannedImage",value:{xDiff:u.totalPannedClientPoint.x,yDiff:u.totalPannedClientPoint.y}}),this.panPoint.currentPannedPoint={x:0,y:0},this.notify("transform",{prop:"setTempPanMove",value:{point:null}})),this.noPushUndo=!0,this.crop(),this.noPushUndo=!1,this.transform.straighten=0,this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),b},t.prototype.applyShapes=function(){if(!this.isUndoRedoStack){var e={bool:!1};this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:e}}),(e.bool||this.togglePen||this.activeObj.shape&&-1!==["rectangle","ellipse","line","arrow","path","text","image"].indexOf(this.activeObj.shape)||this.drawingShape)&&this.okBtn(null,!0)}},t.prototype.closeOverlayTbar=function(){var e=!1,t={bool:null};if(this.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:t}}),!t.bool&&this.element.querySelector(".e-contextual-toolbar-wrapper")){this.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(e=!0);var o={bool:this.isStraightening};(!g.Browser.isDevice||g.Browser.isDevice&&!o.bool)&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")}return e},t.prototype.toolbarTemplateFn=function(){var e,t=this.element.id+"_toolbar",o=this.element.querySelector("#"+this.element.id+"_toolbarArea");if(this.toolbarTemplate){if(this.toolbarFn=this.templateParser(this.toolbarTemplate),this.isReact)e=this.toolbarFn({type:"toolbar"},this,"Template",t)[0];else if(this.isAngular){var i=this.toolbarFn({type:"toolbar"},this,"Template",t);e=3===i[0].nodeType?i[1]:i[0]}else e=this.toolbarFn({type:"toolbar"},this,"Template",t)[0];o.appendChild(e),this.toolbarHeight=o.clientHeight,this.notify("toolbar",{prop:"setToolbarHeight",value:{height:this.toolbarHeight}}),this.renderReactTemplates()}},t.prototype.quickAccessToolbarTemplateFn=function(){var e,t=this.element.id+"_quickAccessToolbar",o=this.element.querySelector("#"+this.element.id+"_quickAccessToolbarArea");if(this.quickAccessToolbarTemplate){if(this.qatFn=this.templateParser(this.quickAccessToolbarTemplate),this.isReact)e=this.qatFn({type:"toolbar"},this,"Template",t)[0];else if(this.isAngular){var i=this.qatFn({type:"toolbar"},this,"Template",t);e=3===i[0].nodeType?i[1]:i[0]}else e=this.qatFn({type:"toolbar"},this,"Template",t)[0];o.appendChild(e),this.renderReactTemplates()}},t.prototype.templateParser=function(e){if(e)try{return"function"!=typeof e&&document.querySelectorAll(e).length?(0,g.compile)(document.querySelector(e).innerHTML.trim()):(0,g.compile)(e)}catch(t){return(0,g.compile)(e)}},t.prototype.getTextFromId=function(e){return{1:"none",2:"bar",3:"arrow",4:"arrowSolid",5:"circle",6:"circleSolid",7:"square",8:"squareSolid"}[""+e]},t.prototype.getFinetuneOption=function(e){return{brightness:l.Brightness,contrast:l.Contrast,hue:l.Hue,saturation:l.Saturation,opacity:l.Opacity,blur:l.Blur,exposure:l.Exposure}[""+e]},t.prototype.setPenStroke=function(e){this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:parseInt(e,10)}})},t.prototype.updateFreehandDrawColorChange=function(){var e={tempFreeHandDrawEditingStyles:null};this.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:e}}),this.notify("freehand-draw",{prop:"color-change",value:{color:e.tempFreeHandDrawEditingStyles.strokeColor}})},t.prototype.getUndoRedoColl=function(){var e={undoRedoColl:null,index:null},t={undoRedoStep:null},o={appliedUndoRedoColl:[]};return this.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:o}}),this.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:t}}),e.undoRedoColl=o.appliedUndoRedoColl,e.index=t.undoRedoStep,e},t.prototype.updateImageTransformColl=function(e){var t;"rotateleft"===e?t=-90:"rotateright"===e?t=90:"horizontalflip"===e?t="horizontal":"verticalflip"===e&&(t="vertical");for(var o=0;o<this.objColl.length;o++){var i=this.objColl[o].shape;if("image"===i||"text"===i){(0,g.isNullOrUndefined)(this.objColl[o].rotateFlipColl)&&(this.objColl[o].rotateFlipColl=[]),this.objColl[o].rotateFlipColl.push(t);var r={collection:this.objColl[o].rotateFlipColl};this.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:this.objColl[o].rotateFlipColl,isRotateFlipCollection:!1,obj:r}}),this.objColl[o].rotateFlipColl=r.collection}}},t.prototype.setInitialZoomState=function(){this.objColl.push(this.activeObj),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1});var e=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,isResize:!0}}):this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(this.transform.cropZoomFactor),zoomPoint:null,isResize:!0}}),this.isUndoRedo=e,this.panPoint.totalPannedPoint={x:0,y:0},this.transform.cropZoomFactor=0,this.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.activeObj=(0,g.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}})},t.prototype.updateCropTransformItems=function(){this.prevCurrSelectionPoint=(0,g.extend)({},this.currSelectionPoint,{},!0),this.notify("draw",{prop:"updateCropSelection",onPropertyChange:!1})},t.prototype.toPascalCase=function(e,t){var o=[];(0,g.isNullOrUndefined)(e)||(o=e.toLowerCase().split("-"));for(var i=0;i<o.length;i++)o[i]=o[i].charAt(0).toUpperCase()+o[i].slice(1);return t&&(t.maxText=o.join("")),o.join("")},t.prototype.getFontSizes=function(){var e,t=[];this.fontSizeColl=[],e=0===this.transform.degree||this.transform.degree%180==0?this.img.destWidth/25:this.img.destHeight/25;for(var o=1;o<=10;o++)this.fontSizeColl.push({text:(o*Math.round(e/2)).toString()}),t.push({text:o.toString()});return t},t.prototype.updateDropInfoContent=function(e){if(e){var t={key:"SupportText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:t}});var o=this.getExtensionString(),i={key:"MinMaxSize"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:i}});var r,a={key:"And"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}}),this.uploadSettings.minFileSize&&this.uploadSettings.maxFileSize?r=" "+i.value+" "+this.formatSizeUnits(this.uploadSettings.minFileSize)+" "+a.value+" "+this.formatSizeUnits(this.uploadSettings.maxFileSize):this.uploadSettings.minFileSize?(i.key="MinSize",this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:i}}),r=" "+i.value+" "+this.formatSizeUnits(this.uploadSettings.minFileSize)):this.uploadSettings.maxFileSize&&(i.key="MaxSize",this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:i}}),r=" "+i.value+" "+this.formatSizeUnits(this.uploadSettings.maxFileSize)),e.textContent=r?t.value+o+r:t.value+o}},t.prototype.okBtn=function(e,t,o){if(t){this.noPushUndo=!1;this.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:{activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[],order:null}}})}var r=this.element.querySelector(".e-contextual-toolbar-wrapper");r&&r.classList.remove("e-frame-wrapper");var a,n=!1;this.isResizeOkBtn=!0;var s=this.element.querySelector("#"+this.element.id+"_aspectratio"),l=this.element.querySelector("#"+this.element.id+"_nonaspectratio"),p=this.element.querySelector(".e-ie-toolbar-aspect-ratio-btn"),h=this.element.querySelector(".e-ie-toolbar-nonaspect-ratio-btn");if(void 0!==this.activeObj.shape&&(a=this.activeObj.shape.split("-")),(void 0===a&&this.currObjType.isCustomCrop||void 0!==a&&"crop"===a[0])&&(n=!0),this.allowDownScale=!0,(this.activeObj.shape&&"image"!==this.activeObj.shape||this.togglePen)&&!n){var d={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:d}});var c=d.shapeSettingsObj;this.togglePen&&(c.type=i.FreehandDraw);var u={action:"apply",currentShapeSettings:(0,g.extend)({},c,{},!0)};this.currObjType.isRedact||!t&&!this.isShapeDrawing||(this.isShapeDrawing&&(u.action="draw-end"),this.trigger("shapeChange",u)),this.editCompleteArgs=u,this.currObjType.isRedact&&(this.currObjType.isRedact=!1)}if(s||l){var v={width:null,height:null};this.notify("selection",{prop:"getNumTextValue",onPropertyChange:!1,value:{obj:v}});var f={x:v.width,y:v.height},m={prevCropObj:this.prevCropObj},b={prevObj:this.prevObj};if(f&&f.x&&f.y&&m.prevCropObj&&b.prevObj){l||h&&!h.classList.contains("e-hidden")?this.notify("transform",{prop:"resize",value:{width:f.x,height:f.y,isAspectRatio:!1}}):(s||p&&!p.classList.contains("e-hidden"))&&this.notify("transform",{prop:"resize",value:{width:f.x,height:null,isAspectRatio:!0}}),this.isResize=!1,this.aspectWidth=f.x,this.aspectHeight=f.y,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.zoomFactor,zoomPoint:null,isResize:!0}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:b.prevObj.defaultZoom,zoomPoint:null,isResize:!0}}),b.prevObj.zoomFactor&&this.setProperties({zoomSettings:{zoomFactor:b.prevObj.zoomFactor}},!0),this.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:this.zoomSettings.zoomFactor}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"resize",previousObj:b.prevObj,previousObjColl:b.prevObj.objColl,previousPointColl:b.prevObj.pointColl,previousSelPointColl:b.prevObj.selPointColl,previousCropObj:m.prevCropObj,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});var C=this.cancelCropSelection;!C||!(0,g.isNullOrUndefined)(l)&&l||(C.previousObj.aspectWidth=C.currentObj.aspectWidth=this.aspectWidth,C.previousObj.aspectHeight=C.currentObj.aspectHeight=this.aspectHeight,C.previousCropObj=(0,g.extend)({},this.cropObj,{},!0),C.currentCropObj=(0,g.extend)({},this.cropObj,{},!0),this.notify("draw",{prop:"updateCropSelObj"})),this.cancelCropSelection=null}else!f||0!==f.x&&0!==f.y?this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}):this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});this.isAspectRatio=!1}else if(o){var y=!1;this.aspectWidth&&this.aspectHeight?this.notify("transform",{prop:"resize",value:{width:this.aspectWidth,height:this.aspectHeight,isAspectRatio:!1}}):this.aspectWidth&&(this.notify("transform",{prop:"resize",value:{width:this.aspectWidth,height:null,isAspectRatio:!0}}),this.aspectHeight=this.aspectWidth/(this.img.destWidth/this.img.destHeight),y=!0),this.isResize=!1,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.zoomFactor,zoomPoint:null,isResize:!0}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:this.prevObj.defaultZoom,zoomPoint:null,isResize:!0}}),this.prevObj.zoomFactor&&this.setProperties({zoomSettings:{zoomFactor:this.prevObj.zoomFactor}},!0),this.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:this.zoomSettings.zoomFactor}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"resize",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:this.prevCropObj,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});var x=this.cancelCropSelection;x&&y&&(x.previousObj.aspectWidth=x.currentObj.aspectWidth=this.aspectWidth,x.previousObj.aspectHeight=x.currentObj.aspectHeight=this.aspectHeight,x.previousCropObj=(0,g.extend)({},this.cropObj,{},!0),x.currentCropObj=(0,g.extend)({},this.cropObj,{},!0),this.notify("draw",{prop:"updateCropSelObj"})),this.cancelCropSelection=null,this.isAspectRatio=!1}var P=this.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected"),w={bool:!1};this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:w}});this.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:{bool:null}}});var j=document.querySelector("#"+this.element.id+"_sliderWrapper");if(P&&(this.currentFilter=P.children[0].children[0].id.replace("Canvas","")),n){if(0!==this.transform.straighten&&(0!==this.panPoint.totalPannedPoint.x||0!==this.panPoint.totalPannedPoint.y||0!==this.panPoint.totalPannedClientPoint.x||0!==this.panPoint.totalPannedClientPoint.y)){var S=this.prevStraightenedDegree;this.prevStraightenedDegree=this.transform.straighten,this.setStraighten(this.transform.straighten-3),this.setStraighten(this.transform.straighten+3),this.prevStraightenedDegree=S}this.isCroppedEvent=this.crop()}else if(this.togglePen){if(this.freeHandDraw(!1),!this.isMaskImage){var O={penStrokeWidth:null};this.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:O}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:O.penStrokeWidth}})}this.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}})}else if("block"===this.textArea.style.display||"inline-block"===this.textArea.style.display)this.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),(0,g.isNullOrUndefined)(e)&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}});else if(!j&&!this.currObjType.isFiltered||this.drawingShape||"redact"===this.activeObj.shape)if(w.bool)this.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}}),this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.notify("freehand-draw",{prop:"resetFreehandDrawSelectedId",onPropertyChange:!1});else if(0!==this.activeObj.activePoint.width||0!==this.activeObj.activePoint.height||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)"image"===this.activeObj.shape&&this.notify("draw",{prop:"setImageApply",onPropertyChange:!1,value:{bool:!0}}),this.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}});else{if(JSON.stringify(this.frameObj)!==JSON.stringify(this.tempFrameObj)){var T={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:T}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:T.currObj,previousObjColl:T.currObj.objColl,previousPointColl:T.currObj.pointColl,previousSelPointColl:T.currObj.selPointColl,previousCropObj:(0,g.extend)({},this.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}});var k={type:this.toPascalCase(this.frameObj.type),color:this.frameObj.color,gradientColor:this.frameObj.gradientColor,size:this.frameObj.size,inset:this.frameObj.inset,offset:this.frameObj.offset,borderRadius:this.frameObj.radius,frameLineStyle:this.toPascalCase(this.frameObj.border),lineCount:this.frameObj.amount},F={cancel:!1,previousFrameSetting:{type:this.toPascalCase(this.tempFrameObj.type),color:this.tempFrameObj.color,gradientColor:this.tempFrameObj.gradientColor,size:this.tempFrameObj.size,inset:this.tempFrameObj.inset,offset:this.tempFrameObj.offset,borderRadius:this.tempFrameObj.radius,frameLineStyle:this.toPascalCase(this.tempFrameObj.border),lineCount:this.tempFrameObj.amount},currentFrameSetting:k};this.editCompleteArgs=F,this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.tempFrameObj=(0,g.extend)({},this.frameObj,{},!0)}this.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1,value:{isOk:!0}})}else{this.initialAdjustmentValue=this.canvasFilter=this.lowerContext.filter,this.currObjType.isFiltered=!1;this.notify("draw",{prop:"getTempAdjustmentValue",value:{obj:{value:null}}}),j&&"Opacity"===j.parentElement.previousElementSibling.textContent||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:null}})}w.isCropToolbar||(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}}),this.currObjType.isRedact=!1),this.notify("draw",{prop:"setNewPath",value:{bool:!1}}),this.transform.zoomFactor=this.transform.defaultZoomFactor,this.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),this.isResizeOkBtn=!1,this.notify("draw",{prop:"redrawDownScale"}),this.isChangesSaved=this.isFinetuneBtnClick=!1,t&&(this.drawingShape=null,this.notify("draw",{prop:"resetTempObjColl"}),this.notify("draw",{prop:"resetTempPointColl"}))},t.prototype.triggerEditCompleteEvent=function(e){var t={bool:!1};this.notify("undo-redo",{prop:"preventEditComplete",value:{obj:t}}),t.bool||("shape-insert"===e.action&&e.actionEventArgs&&e.actionEventArgs.currentShapeSettings&&"Redact"===e.actionEventArgs.currentShapeSettings.type.toString()&&(e.action="redact"),this.trigger("editComplete",e),this.editCompleteArgs=null)},t.prototype.getObjFromId=function(e){var t;if(this.activeObj.currIndex&&this.activeObj.currIndex===e)t=(0,g.extend)({},this.activeObj,{},!0);else for(var o=0;o<this.shapeColl.length;o++){if((this.shapeColl[o].id?this.shapeColl[o].id:this.shapeColl[o].currIndex)===e){t=(0,g.extend)({},this.shapeColl[o],{},!0);break}}return t},t.prototype.setTempFilterProperties=function(){this.upperCanvas.style.display="block",this.cropSelectedState();var e={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:e}}),this.lowerContext.filter=this.initialAdjustmentValue,this.notify("draw",{prop:"setTempAdjustmentValue",value:{tempAdjustmentValue:this.lowerContext.filter}}),this.notify("filter",{prop:"setTempAdjustmentLevel",onPropertyChange:!1,value:{tempAdjustmentLevel:(0,g.extend)({},e.adjustmentLevel,{},!0)}}),this.notify("draw",{prop:"setTempFilter",value:{tempFilter:this.currentFilter}});var t={undoRedoStep:null};this.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:t}}),this.notify("draw",{prop:"setTempUndoRedoStep",value:{tempUndoRedoStep:t.undoRedoStep}})},t.prototype.cropSelectedState=function(){this.activeObj.shape&&"crop"===this.activeObj.shape.split("-")[0]&&this.okBtn()},t.prototype.getCurrentCanvasData=function(){var e=(0,g.extend)({},this.frameObj,{},!0);this.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""};var t=this.lowerContext.filter;this.lowerContext.filter=this.canvasFilter="none";var o=(0,g.extend)([],this.objColl,null,!0),i=(0,g.extend)([],this.pointColl,null,!0);this.objColl=[],this.pointColl=[],this.freehandCounter=0,this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}});var r=this.element.querySelector(".e-contextual-toolbar-wrapper");r&&r.classList.add("e-hide");var a=this.getImageData();return r&&r.classList.remove("e-hide"),g.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=o,this.pointColl=i,this.freehandCounter=i.length,this.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"iterate",pen:"iterate",isPreventApply:null}}),this.lowerContext.filter=this.canvasFilter=t,this.frameObj=e,a},t.prototype.setCurrAdjustmentValue=function(e,t){var o={finetune:this.getFinetuneOption(e),value:t,cancel:!1};this.trigger("finetuneValueChanging",o),this.editCompleteArgs=o,o.cancel||this.notify("filter",{prop:"setCurrAdjValue",value:{type:e.toLowerCase(),value:t}})},t.prototype.getSquarePointForPath=function(e){var t={startX:0,startY:0,endX:0,endY:0,width:0,height:0};if(e.pointColl.length>0){t={startX:e.pointColl[0].x,startY:e.pointColl[0].y,endX:e.pointColl[0].x,endY:e.pointColl[0].y};for(var o=1;o<e.pointColl.length;o++)e.pointColl[o].x<t.startX&&(t.startX=e.pointColl[o].x),e.pointColl[o].y<t.startY&&(t.startY=e.pointColl[o].y),e.pointColl[o].x>t.endX&&(t.endX=e.pointColl[o].x),e.pointColl[o].y>t.endY&&(t.endY=e.pointColl[o].y);t.width=t.endX-t.startX,t.height=t.endY-t.startY}return t},t.prototype.getSelectionType=function(e){var t={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","Crop2:3":"2:3","Crop3:4":"3:4","Crop4:5":"4:5","Crop5:7":"5:7","Crop9:16":"9:16"};return t[""+(e="crop-custom"===e?"CropCustom":e)]?t[""+e]:e.split("Crop")[1]},t.prototype.clearContext=function(e){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.clearRect(0,0,e.canvas.height,e.canvas.width)},t.prototype.updateArrow=function(e,t){var o=!1,i=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),i!==this.objColl.length&&(o=!0);var r=(0,g.extend)({},this.cropObj,{},!0),a={currObj:{}},n={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:n}});var s=n.shapeSettingsObj;this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var l=a.currObj;(l.objColl=(0,g.extend)([],this.objColl,[],!0),l.pointColl=(0,g.extend)([],this.pointColl,[],!0),l.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0),o&&this.objColl.pop(),"startArrow"===e?this.activeObj.start=this.getTextFromId(t):"endArrow"===e&&(this.activeObj.end=this.getTextFromId(t)),this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}),g.Browser.isDevice)?document.getElementById(this.element.id+"_bottomToolbar")&&(0,g.getComponent)(this.element.id+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(this.element.id+"_toolbar")&&(0,g.getComponent)(this.element.id+"_toolbar","toolbar").refreshOverflow();var p={action:e,currentShapeSettings:(0,g.extend)({},s,{},!0)};this.trigger("shapeChange",p),this.editCompleteArgs=p},t.prototype.updateFontFamily=function(e){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}});var t=!1,o=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),o!==this.objColl.length&&(t=!0);var i=(0,g.extend)([],this.objColl,[],!0),r=(0,g.extend)({},this.cropObj,{},!0),a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=(0,g.extend)([],this.objColl,[],!0),l.pointColl=(0,g.extend)([],this.pointColl,[],!0),l.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var p={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=(0,g.extend)([],p.selPointColl,[],!0),t&&this.objColl.pop(),"block"===this.textArea.style.display||"inline-block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var h=this.activeObj.textSettings.fontFamily;this.activeObj.textSettings.fontFamily=this.toPascalCase(e),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);var d=this.activeObj.activePoint.width+.25*this.activeObj.textSettings.fontSize;this.textArea.style.width=d+"px",this.textArea.style.fontFamily=this.toPascalCase(e),this.activeObj.textSettings.fontFamily=h,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 c=this.activeObj.textSettings.fontFamily=this.toPascalCase(e);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:c,fontSize:null}}),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:l,previousObjColl:i,previousPointColl:(0,g.extend)([],this.pointColl,[],!0),previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}var u={action:"font-family",currentShapeSettings:(0,g.extend)({},n,{},!0)};u.currentShapeSettings.fontFamily=this.textArea.style.fontFamily,this.trigger("shapeChange",u),this.editCompleteArgs=u},t.prototype.updateFontSize=function(e){var t=e;this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}});var o=!1,i=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),i!==this.objColl.length&&(o=!0);var r=(0,g.extend)({},this.cropObj,{},!0),a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=(0,g.extend)([],this.objColl,[],!0),l.pointColl=(0,g.extend)([],this.pointColl,[],!0),l.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var p={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=(0,g.extend)([],p.selPointColl,[],!0),o&&this.objColl.pop(),"block"===this.textArea.style.display||"inline-block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var h=this.activeObj.textSettings.fontSize;this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(t,10)-1].text,10),this.objColl.push(this.activeObj),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop();var d="";"bold"===this.textArea.style.fontWeight&&(d="bold "),"italic"===this.textArea.style.fontStyle&&(d="italic "),"bold"===this.textArea.style.fontWeight&&"italic"===this.textArea.style.fontStyle&&(d="italic bold "),this.upperContext.font=d+this.activeObj.textSettings.fontSize+"px "+this.textArea.style.fontFamily;var c=this.textArea.value.split("\n"),u={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:!0,text:null,obj:u}});var v=u.maxText,f=this.upperContext.measureText(v).width+.5*this.activeObj.textSettings.fontSize;this.textArea.style.width=f+"px",this.textArea.style.height=c.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize)+"px",this.activeObj.textSettings.fontSize=h,this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily,this.textArea.style.fontSize=parseInt(this.fontSizeColl[parseInt(t,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 m=this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(t,10)-1].text,10);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:null,fontSize:m}}),this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily;c=this.activeObj.keyHistory.split("\n"),u={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:null,text:null,obj:u}});var b=u.maxText,C=(f=this.upperContext.measureText(b).width+.5*this.activeObj.textSettings.fontSize,c.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize));0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||(this.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:f,height:C}}),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),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}var y={action:"font-size",currentShapeSettings:(0,g.extend)({},n,{},!0)};y.currentShapeSettings.fontSize=this.activeObj.textSettings.fontSize,this.trigger("shapeChange",y),this.editCompleteArgs=y},t.prototype.updateFontColor=function(e,t){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}});var o=!1,i=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),i!==this.objColl.length&&(o=!0);var r=(0,g.extend)({},this.cropObj,{},!0),a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=(0,g.extend)([],this.objColl,[],!0),l.pointColl=(0,g.extend)([],this.pointColl,[],!0),l.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var p={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=(0,g.extend)([],p.selPointColl,[],!0),o&&this.objColl.pop(),"none"===this.textArea.style.display)"Text"===t?(this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}})):(this.activeObj.strokeSettings.fillColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:this.activeObj.strokeSettings.fillColor,strokeWidth:null}})),this.togglePen||0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,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||"inline-block"===this.textArea.style.display){this.textArea.style["Text"===t?"color":"backgroundColor"]=e;var h="Text"===t?this.activeObj.strokeSettings.strokeColor:this.activeObj.strokeSettings.fillColor;this.activeObj.strokeSettings["Text"===t?"strokeColor":"fillColor"]=e,0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop()),this.activeObj.strokeSettings["Text"===t?"strokeColor":"fillColor"]=h}else this.togglePen||0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));var d={action:"font-color",currentShapeSettings:(0,g.extend)({},n,{},!0)};d.currentShapeSettings.fillColor=e,this.trigger("shapeChange",d),this.editCompleteArgs=d},t.prototype.updateStrokeTextColor=function(e){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}});var t=!1,o=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),o!==this.objColl.length&&(t=!0);var i=(0,g.extend)({},this.cropObj,{},!0),r={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=(0,g.extend)([],this.objColl,[],!0),s.pointColl=(0,g.extend)([],this.pointColl,[],!0),s.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var l={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=(0,g.extend)([],l.selPointColl,[],!0),t&&this.objColl.pop(),"none"===this.textArea.style.display)this.activeObj.strokeSettings.outlineColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:null,outlineColor:this.activeObj.strokeSettings.outlineColor}}),this.togglePen||0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.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||"inline-block"===this.textArea.style.display){this.textArea.style.textShadow="-1px -1px 0 "+e+", 1px -1px 0 "+e+", -1px 1px 0 "+e+", 1px 1px 0 "+e;var p=this.activeObj.strokeSettings.outlineColor;this.activeObj.strokeSettings.outlineColor=e,0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop()),this.activeObj.strokeSettings.outlineColor=p}else this.togglePen||0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));var h={action:"font-color",currentShapeSettings:(0,g.extend)({},a,{},!0)};h.currentShapeSettings.fillColor=e,this.trigger("shapeChange",h),this.editCompleteArgs=h},t.prototype.updatePenStrokeWidth=function(e){var t=(0,g.extend)([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var o=(0,g.extend)({},this.cropObj,{},!0),r={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=(0,g.extend)([],this.objColl,[],!0),s.pointColl=(0,g.extend)([],this.pointColl,[],!0),s.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var l={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=(0,g.extend)([],l.selPointColl,[],!0),this.pointColl=t,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.setPenStroke(e);var p={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:p}}),p.bool){var h={penStrokeWidth:null};this.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:h}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:h.penStrokeWidth}});var d={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:d}}),this.pointColl[d.freehandSelectedIndex].strokeWidth=h.penStrokeWidth,this.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),this.notify("draw",{prop:"redrawDownScale"}),this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:h.penStrokeWidth}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}a.type=i.FreehandDraw;var c={action:"stroke-width",currentShapeSettings:(0,g.extend)({},a,{},!0)};c.currentShapeSettings.strokeWidth=this.activeObj.strokeSettings.strokeWidth,this.trigger("shapeChange",c),this.editCompleteArgs=c},t.prototype.updatePenStrokeColor=function(e){var t=(0,g.extend)([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var o=(0,g.extend)({},this.cropObj,{},!0),r={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=(0,g.extend)([],this.objColl,[],!0),s.pointColl=(0,g.extend)([],this.pointColl,[],!0),s.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var l={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=(0,g.extend)([],l.selPointColl,[],!0),this.pointColl=t,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.activeObj.strokeSettings.strokeColor=e;var p={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:p}}),null!=p.freehandSelectedIndex&&(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),this.notify("draw",{prop:"redrawDownScale"}),this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}));var h={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:h}}),h.bool){var d={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:d}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.pointColl[d.freehandSelectedIndex].strokeColor=e,this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:e}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else this.togglePen||this.notify("selection",{prop:"redrawShape",value:{obj:this.activeObj}});a.type=i.FreehandDraw;var c={action:"stroke-color",currentShapeSettings:(0,g.extend)({},a,{},!0)};c.currentShapeSettings.strokeColor=e,this.trigger("shapeChange",c),this.editCompleteArgs=c},t.prototype.updateStrokeWidth=function(e,t,o){if(this.activeObj.shape&&("path"!==this.activeObj.shape||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var r=i.shapeSettingsObj,a=!1,n=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),n!==this.objColl.length&&(a=!0);var s=(0,g.extend)({},this.cropObj,{},!0),l={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:l}});var p=l.currObj;p.objColl=(0,g.extend)([],this.objColl,[],!0),p.pointColl=(0,g.extend)([],this.pointColl,[],!0),p.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var h={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),p.selPointColl=(0,g.extend)([],h.selPointColl,[],!0),a&&this.objColl.pop(),this.activeObj.strokeSettings["width"===t?"text"===o?"outlineWidth":"strokeWidth":"radius"]=parseInt(e,10),"rectangle"!==this.activeObj.shape&&"ellipse"!==this.activeObj.shape||(this.activeObj.strokeSettings["width"===t?"text"===o?"outlineWidth":"strokeWidth":"radius"]=parseInt(e,10)-1),this.activeObj.strokeSettings["width"===t?"text"===o?"outlineWidth":"strokeWidth":"radius"]*=2,"width"===t?"text"===o?this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:null,radius:null,outlineWidth:this.activeObj.strokeSettings.outlineWidth}}):this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth,radius:null,outlineWidth:null}}):this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:null,radius:this.activeObj.strokeSettings.radius}}),this.objColl.push(this.activeObj),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:p,previousObjColl:p.objColl,previousPointColl:p.pointColl,previousSelPointColl:p.selPointColl,previousCropObj:s,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}});var d={action:"stroke-width",currentShapeSettings:(0,g.extend)({},r,{},!0)};d.currentShapeSettings["width"===t?"text"===o?"outlineWidth":"strokeWidth":"radius"]=this.activeObj.strokeSettings["width"===t?"text"===o?"outlineWidth":"strokeWidth":"radius"],this.trigger("shapeChange",d),this.editCompleteArgs=d}else this.activeObj.shape&&"path"===this.activeObj.shape&&0===this.activeObj.pointColl.length&&(this.activeObj.strokeSettings.strokeWidth=parseInt(e,10),this.activeObj.strokeSettings.strokeWidth*=2,"width"===t?"text"===o?this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:null,radius:null,outlineWidth:this.activeObj.strokeSettings.outlineWidth}}):this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth,radius:null,outlineWidth:null}}):this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:null,radius:this.activeObj.strokeSettings.radius}}))},t.prototype.updateStrokeColor=function(e){var t={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:t}});var o=t.shapeSettingsObj;if(this.activeObj.shape&&("path"!==this.activeObj.shape||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)){var i=!1,r=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),r!==this.objColl.length&&(i=!0);var a=(0,g.extend)({},this.cropObj,{},!0),n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=(0,g.extend)([],this.objColl,[],!0),s.pointColl=(0,g.extend)([],this.pointColl,[],!0),s.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var l={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=(0,g.extend)([],l.selPointColl,[],!0),i&&this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))}else this.activeObj.shape&&"path"===this.activeObj.shape&&0===this.activeObj.pointColl.length&&(this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}));var p={action:"stroke-color",currentShapeSettings:(0,g.extend)({},o,{},!0)};p.currentShapeSettings.strokeColor=e,this.trigger("shapeChange",p),this.editCompleteArgs=p},t.prototype.updateFillColor=function(e){var t={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:t}});var o=t.shapeSettingsObj,i=!1,r=this.objColl.length;this.notify("shape",{prop:"pushActItemIntoObj"}),r!==this.objColl.length&&(i=!0);var a=(0,g.extend)({},this.cropObj,{},!0),n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=(0,g.extend)([],this.objColl,[],!0),s.pointColl=(0,g.extend)([],this.pointColl,[],!0),s.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var l={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=(0,g.extend)([],l.selPointColl,[],!0),i&&this.objColl.pop(),this.activeObj.strokeSettings.fillColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:this.activeObj.strokeSettings.fillColor,strokeWidth:null}}),this.objColl.push(this.activeObj),0===this.activeObj.activePoint.width&&0===this.activeObj.activePoint.height||this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}});var p={action:"fill-color",currentShapeSettings:(0,g.extend)({},o,{},!0)};this.trigger("shapeChange",p),this.editCompleteArgs=p},t.prototype.horizontalFlip=function(e,t){var o,i;if((0,g.isNullOrUndefined)(t)){(0,g.isNullOrUndefined)(this.activeObj.imageRatio)&&this.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),this.notify("shape",{prop:"pushActItemIntoObj"}),o=(0,g.extend)({},this.cropObj,{},!0);var r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),(i=r.currObj).objColl=(0,g.extend)([],this.objColl,[],!0),i.pointColl=(0,g.extend)([],this.pointColl,[],!0),i.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),i.selPointColl=(0,g.extend)([],a.selPointColl,[],!0),this.objColl.pop()}this.notify("toolbar",{prop:"refreshSlider"}),e.clearRect(0,0,this.activeObj.imageCanvas.width,this.activeObj.imageCanvas.height);var n=this.duplicateImage();this.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:this.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:null}}),this.activeObj.activePoint=n,this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),(0,g.isNullOrUndefined)(t)&&(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"imageHFlip",previousObj:i,previousObjColl:i.objColl,previousPointColl:i.pointColl,previousSelPointColl:i.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},t.prototype.verticalFlip=function(e,t){var o,i;if((0,g.isNullOrUndefined)(t)){(0,g.isNullOrUndefined)(this.activeObj.imageRatio)&&this.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),this.notify("shape",{prop:"pushActItemIntoObj"}),o=(0,g.extend)({},this.cropObj,{},!0);var r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),(i=r.currObj).objColl=(0,g.extend)([],this.objColl,[],!0),i.pointColl=(0,g.extend)([],this.pointColl,[],!0),i.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var a={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),i.selPointColl=(0,g.extend)([],a.selPointColl,[],!0),this.objColl.pop()}this.notify("toolbar",{prop:"refreshSlider"}),e.clearRect(0,0,this.activeObj.imageCanvas.width,this.activeObj.imageCanvas.height);var n=this.duplicateImage();this.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:this.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:!0}}),this.activeObj.activePoint=n,this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),(0,g.isNullOrUndefined)(t)&&(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"imageVFlip",previousObj:i,previousObjColl:i.objColl,previousPointColl:i.pointColl,previousSelPointColl:i.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},t.prototype.rotateImage=function(e){var t,o;(0,g.isNullOrUndefined)(this.activeObj.imageRatio)&&this.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),this.notify("shape",{prop:"pushActItemIntoObj"}),t=(0,g.extend)({},this.cropObj,{},!0);var i={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}}),(o=i.currObj).objColl=(0,g.extend)([],this.objColl,[],!0),o.pointColl=(0,g.extend)([],this.pointColl,[],!0),o.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var r={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:r}}),o.selPointColl=(0,g.extend)([],r.selPointColl,[],!0),this.objColl.pop(),this.notify("toolbar",{prop:"refreshSlider"}),"rotleft"===e?this.activeObj.rotatedAngle-=Math.PI/180*90:this.activeObj.rotatedAngle+=Math.PI/180*90,this.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:this.activeObj}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"imageRotate",previousObj:o,previousObjColl:o.objColl,previousPointColl:o.pointColl,previousSelPointColl:o.selPointColl,previousCropObj:t,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}),this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})},t.prototype.pascalToSplitWords=function(e){var t=(e=e.charAt(0).toUpperCase()+e.slice(1)).match(/[A-Z][a-z]+/g);return(0,g.isNullOrUndefined)(t)?e:t.map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" ")},t.prototype.getCurrAdjustmentValue=function(e){var t=100,o={freehandSelectedIndex:null};if(this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:o}}),"transparency"===e&&this.togglePen){var i={penOpacity:1};this.notify("freehand-draw",{prop:"getPenOpacity",onPropertyChange:!1,value:{obj:i}}),t=100*i.penOpacity}else if("transparency"===e&&null!=o.freehandSelectedIndex)t=100*this.pointColl[o.freehandSelectedIndex].opacity;else{i={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:i}}),t={brightness:i.adjustmentLevel.brightness,contrast:i.adjustmentLevel.contrast,hue:i.adjustmentLevel.hue,saturation:i.adjustmentLevel.saturation,opacity:i.adjustmentLevel.opacity,blur:i.adjustmentLevel.blur,exposure:i.adjustmentLevel.exposure,transparency:i.adjustmentLevel.transparency,straighten:this.transform.straighten}[""+e]}return t},t.prototype.transformSelect=function(e){0!==this.transform.straighten||"rotateleft"!==e&&"rotateright"!==e||!this.activeObj.shape||-1===["crop-2:3","crop-3:2","crop-3:4","crop-4:3","crop-4:5","crop-5:4","crop-5:7","crop-7:5","crop-9:16","crop-16:9"].indexOf(this.activeObj.shape)&&(-1===this.activeObj.shape.indexOf("crop-")||"crop-custom"===this.activeObj.shape||"crop-square"===this.activeObj.shape||"crop-circle"===this.activeObj.shape)||(this.activeObj.shape="crop-"+this.activeObj.shape.split("-")[1].split(":")[1]+":"+this.activeObj.shape.split("-")[1].split(":")[0],this.notify("toolbar",{prop:"performCropTransformClick",value:{shape:this.activeObj.shape,isTransform:!0}})),this.isCropToolbar=!0,this.allowDownScale=!1;var t=this.transform.straighten,o=(0,g.extend)({},this.activeObj,{},!0),i=this.transform.zoomFactor;this.prevEventSelectionPoint=(0,g.extend)({},this.activeObj,{},!0);var r={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),this.prevEventObjPoint=r.currObj,this.prevEventObjPoint.objColl=(0,g.extend)([],this.objColl,[],!0),this.prevEventObjPoint.pointColl=(0,g.extend)([],this.pointColl,[],!0),this.prevEventObjPoint.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var a={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),this.prevEventObjPoint.selPointColl=(0,g.extend)([],a.selPointColl,[],!0),0!==this.transform.straighten){this.transform.straighten=0,this.straightenBaseImageCanvas();for(var n=0,s=this.objColl.length;n<s;n++){"line"!==(p=this.objColl[n].shape)&&"arrow"!==p&&"path"!==p&&(this.objColl[n].rotatedAngle-=t*(Math.PI/180),this.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:this.objColl[n]}}))}this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),this.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}})}this.setInitialZoomState();var l=(0,g.extend)({},this.activeObj,{},!0);if(this.notify("crop",{prop:"setTransformCrop",onPropertyChange:!1,value:{bool:!0}}),this.cropSelectedState(),this.notify("crop",{prop:"setTransformCrop",onPropertyChange:!1,value:{bool:!1}}),this.notify("draw",{prop:"resetCurrentSelectionPoint"}),this.updateImageTransformColl(e),this.notify("transform",{prop:"performTransformation",value:{text:e}}),this.isCropTab=!0,this.notify("draw",{prop:"moveToSelectionRange",value:{type:e,activeObj:l}}),!this.isStraightening||"horizontalflip"!==e&&"verticalflip"!==e||(this.notify("draw",{prop:"resetStraightenDestPoints"}),this.notify("draw",{prop:"setDestForStraighten"})),0!==t){this.transform.straighten=t,this.straightenBaseImageCanvas();for(n=0,s=this.objColl.length;n<s;n++){var p;"line"!==(p=this.objColl[n].shape)&&"arrow"!==p&&"path"!==p&&(this.objColl[n].rotatedAngle+=t*(Math.PI/180),this.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:this.objColl[n]}}))}this.notify("shape",{prop:"drawAnnotations",onPropertyChange:!1,value:{ctx:this.lowerContext,shape:"zoom",pen:"zoom",isPreventApply:null}}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o}}),this.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),this.notify("draw",{prop:"setStraightenInitZoom",value:{zoomFactor:i}}),(this.isStraightening&&("horizontalflip"===e||"verticalflip"===e)&&(0,g.isNullOrUndefined)(this.transform.zoomFactor)||0===this.transform.zoomFactor)&&(0===this.transform.degree?this.transform.zoomFactor+=.025:0===this.transform.zoomFactor&&(this.transform.zoomFactor=null)),this.notify("draw",{prop:"zoomToSel",value:{activeObj:o,isToolbar:!1}})}this.isCropToolbar=!1;var h=this.element.querySelector(".e-ie-straighten-value-span");h&&(h.innerHTML=this.transform.straighten.toString()+"°")},t.prototype.getDefaultFilter=function(){return"brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},t.prototype.setStraighten=function(e){var t={cancel:!1,previousDegree:this.transform.straighten,currentDegree:e};if(this.trigger("rotating",t),this.editCompleteArgs=t,!t.cancel){this.performStraighten(t);var o={action:"straighten",actionEventArgs:this.editCompleteArgs};this.triggerEditCompleteEvent(o)}},t.prototype.duplicateImage=function(){var e=(0,g.extend)({},this.activeObj.activePoint,{},!0),t={width:0,height:0};return this.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.activeObj.imageElement.width,height:this.activeObj.imageElement.height,obj:t,isImgShape:null}}),this.activeObj.activePoint.width=t.width,this.activeObj.activePoint.height=t.height,e},t.prototype.performStraighten=function(e){var t=e.currentDegree,o=this.element.querySelector(".e-ie-straighten-value-span");o&&(o.innerHTML=t.toString()+"°");var i=(0,g.extend)({},this.activeObj,null,!0);this.notify("freehand-draw",{prop:"setCenterSelPoints"}),this.transform.straighten=t,this.straightenPoint={x:this.activeObj.activePoint.startX+this.activeObj.activePoint.width/2,y:this.activeObj.activePoint.startY+this.activeObj.activePoint.height/2},this.straightenBaseImageCanvas();for(var r=0,a=this.objColl.length;r<a;r++){var n=this.objColl[r].shape;"line"!==n&&"arrow"!==n&&"path"!==n&&(this.objColl[r].rotatedAngle+=(this.transform.straighten-this.prevStraightenedDegree)*(Math.PI/180),this.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:this.objColl[r]}}))}this.transform.degree%90==0&&this.transform.degree%180!=0?(0===this.transform.straighten&&(this.transform.straighten=360),this.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:this.activeObj.activePoint.startX+this.activeObj.activePoint.width/2,y:this.activeObj.activePoint.startY+this.activeObj.activePoint.height/2,type:"zoomIn",isResize:!0}}),this.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:this.activeObj.activePoint.startX+this.activeObj.activePoint.width/2,y:this.activeObj.activePoint.startY+this.activeObj.activePoint.height/2,type:"zoomOut",isResize:!0}}),360===this.transform.straighten&&(this.transform.straighten=0)):this.notify("draw",{prop:"render-image",value:{isMouseWheel:!0,isPreventClearRect:null,isFrame:null,isStraighten:!0}}),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i}}),this.notify("draw",{prop:"zoomToSel",value:{activeObj:i,isToolbar:!0}}),this.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),this.prevStraightenedDegree=this.transform.straighten},t.prototype.straightenBaseImageCanvas=function(){if(this.isImageLoaded){var e=this.getStraightenFlipState(),t="horizontal"===e||"vertical"===e?-this.transform.straighten:this.transform.straighten,o=this.baseImgCanvas.getContext("2d");if(o.canvas.width!==this.lowerContext.canvas.width&&o.canvas.height!==this.lowerContext.canvas.height){this.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:{width:0,height:0},dimension:{width:o.canvas.width,height:o.canvas.height}}})}var i=this.baseImg.width,r=this.baseImg.height;if(!this.aspectRatioBaseDimension&&this.imageSettings.width&&this.imageSettings.height){var a=(this.baseImg.width/this.imageSettings.width+this.baseImg.height/this.imageSettings.height)/2;a=a<1?1:a,i=this.imageSettings.width*a,r=this.imageSettings.height*a}var n=this.getRotatedCanvasDim(i,r,this.transform.straighten);this.img.srcWidth=o.canvas.width=n.width,this.img.srcHeight=o.canvas.height=n.height;var s=o.canvas.width/2,l=o.canvas.height/2;o.clearRect(0,0,o.canvas.width,o.canvas.height),o.translate(s,l),o.rotate(t*Math.PI/180),o.drawImage(this.baseImg,-i/2,-r/2,i,r),o.setTransform(1,0,0,1,0,0);this.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:{width:0,height:0},dimension:{width:o.canvas.width,height:o.canvas.height}}})}},t.prototype.getRotatedCanvasDim=function(e,t,o){var i=o*Math.PI/180,r=Math.cos(i),a=Math.sin(i),n=Math.min(0,e*r,t*Math.cos(Math.PI/2-i),e*r+t*Math.cos(Math.PI/2-i)),s=Math.max(0,e*r,t*Math.cos(Math.PI/2-i),e*r+t*Math.cos(Math.PI/2-i)),l=Math.min(0,e*a,t*Math.sin(Math.PI/2-i),e*a+t*Math.sin(Math.PI/2-i)),p=Math.max(0,e*a,t*Math.sin(Math.PI/2-i),e*a+t*Math.sin(Math.PI/2-i));return{width:Math.ceil(s-n),height:Math.ceil(p-l)}},t.prototype.updateShapeOrder=function(e,t){var o=this.getObjFromId(e);if(o.shape&&("path"!==o.shape||"path"===o.shape&&o.pointColl.length>0)||o&&o.id&&o.id.indexOf("pen")>-1){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var r=i.shapeSettingsObj;o.shape&&this.notify("shape",{prop:"pushActItemIntoObj"});var a=(0,g.extend)({},this.cropObj,{},!0),n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=(0,g.extend)([],this.objColl,[],!0),s.pointColl=(0,g.extend)([],this.pointColl,[],!0),s.afterCropActions=(0,g.extend)([],this.afterCropActions,[],!0);var l={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=(0,g.extend)([],l.selPointColl,[],!0),o.shape&&this.objColl.pop(),this.notify("shape",{prop:"z-order",onPropertyChange:!1,value:{obj:o,value:t}}),o.shape&&(this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:o.strokeSettings.strokeWidth}}),this.objColl.push(o)),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.shape&&(this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}),this.activeObj.order=o.order),{action:"stroke-width",previousShapeSettings:(0,g.extend)({},r,{},!0),currentShapeSettings:(0,g.extend)({},r,{},!0)}.currentShapeSettings.strokeWidth=this.activeObj.strokeSettings.strokeWidth}else this.activeObj.shape&&"path"===this.activeObj.shape&&0===this.activeObj.pointColl.length&&this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}})},t.prototype.getStraightenFlipState=function(){var e="";if(this.rotateFlipColl.length>0)for(var t=0,o=this.rotateFlipColl.length;t<o;t++){var i=this.rotateFlipColl[t];"horizontal"===i?e+="horizontal":"vertical"===i&&(e+="vertical"),"horizontalvertical"!==e&&"verticalhorizontal"!==e||(e="")}return e},t.prototype.initializeZoomSettings=function(){this.theme=(0,g.isNullOrUndefined)(this.theme)?"Bootstrap5":this.theme,((0,g.isNullOrUndefined)(this.zoomSettings.zoomTrigger)||0===this.zoomSettings.zoomTrigger)&&(this.zoomSettings.zoomTrigger=r.MouseWheel|r.Pinch|r.Toolbar|r.Commands),(0,g.isNullOrUndefined)(this.selectionSettings.strokeColor)&&(this.selectionSettings.strokeColor=this.themeColl[this.theme].primaryColor),(0,g.isNullOrUndefined)(this.selectionSettings.fillColor)&&(this.selectionSettings.fillColor=this.themeColl[this.theme].secondaryColor)},t.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"},Fluent2:{primaryColor:"#0f6cbd",secondaryColor:"#fff"},Fluent2Dark:{primaryColor:"#115ea3",secondaryColor:"#fff"},Fluent2Highcontrast:{primaryColor:"#1aebff",secondaryColor:"#fff"},"Bootstrap5.3":{primaryColor:"#0d6efd",secondaryColor:"#fff"},"Bootstrap5.3Dark":{primaryColor:"#0d6efd",secondaryColor:"#fff"},Tailwind3:{primaryColor:"#4f46e5",secondaryColor:"#ffffff"},Tailwind3Dark:{primaryColor:"#6366f1",secondaryColor:"#ffffff03"}}},t.prototype.drawRedact=function(e,t,o,i,r,a){var n=!1,s=this.allowShape(t,o);return!this.disabled&&this.isImageLoaded&&(s||(0,g.isNullOrUndefined)(t)&&(0,g.isNullOrUndefined)(o))&&(n=!0,this.manageActiveAction(),this.notify("shape",{prop:"drawRedact",onPropertyChange:!1,value:{x:t,y:o,width:i,height:r,type:e,value:a}}),this.notify("draw",{prop:"redrawDownScale"})),n},t.prototype.handlePenActiveState=function(){var e={freehandDrawSelectedId:null};this.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:e}}),(0,g.isNullOrUndefined)(e.freehandDrawSelectedId)&&this.manageActiveAction()},X([(0,g.Property)("")],t.prototype,"cssClass",void 0),X([(0,g.Property)(!1)],t.prototype,"disabled",void 0),X([(0,g.Property)("100%")],t.prototype,"height",void 0),X([(0,g.Property)("Bootstrap5")],t.prototype,"theme",void 0),X([(0,g.Property)()],t.prototype,"toolbar",void 0),X([(0,g.Property)()],t.prototype,"toolbarTemplate",void 0),X([(0,g.Property)("100%")],t.prototype,"width",void 0),X([(0,g.Property)(!0)],t.prototype,"allowUndoRedo",void 0),X([(0,g.Property)(!0)],t.prototype,"showQuickAccessToolbar",void 0),X([(0,g.Property)()],t.prototype,"quickAccessToolbarTemplate",void 0),X([(0,g.Property)(!1)],t.prototype,"imageSmoothingEnabled",void 0),X([(0,g.Property)(!1)],t.prototype,"isReadOnly",void 0),X([(0,g.Property)(!1)],t.prototype,"enableRtl",void 0),X([(0,g.Property)(!1)],t.prototype,"enablePersistence",void 0),X([(0,g.Complex)({},M)],t.prototype,"finetuneSettings",void 0),X([(0,g.Complex)({},B)],t.prototype,"zoomSettings",void 0),X([(0,g.Complex)({},H)],t.prototype,"selectionSettings",void 0),X([(0,g.Complex)({},U)],t.prototype,"fontFamily",void 0),X([(0,g.Complex)({},Y)],t.prototype,"uploadSettings",void 0),X([(0,g.Event)()],t.prototype,"beforeSave",void 0),X([(0,g.Event)()],t.prototype,"created",void 0),X([(0,g.Event)()],t.prototype,"destroyed",void 0),X([(0,g.Event)()],t.prototype,"zooming",void 0),X([(0,g.Event)()],t.prototype,"panning",void 0),X([(0,g.Event)()],t.prototype,"cropping",void 0),X([(0,g.Event)()],t.prototype,"rotating",void 0),X([(0,g.Event)()],t.prototype,"flipping",void 0),X([(0,g.Event)()],t.prototype,"shapeChanging",void 0),X([(0,g.Event)()],t.prototype,"selectionChanging",void 0),X([(0,g.Event)()],t.prototype,"fileOpened",void 0),X([(0,g.Event)()],t.prototype,"saved",void 0),X([(0,g.Event)()],t.prototype,"toolbarCreated",void 0),X([(0,g.Event)()],t.prototype,"toolbarUpdating",void 0),X([(0,g.Event)()],t.prototype,"toolbarItemClicked",void 0),X([(0,g.Event)()],t.prototype,"imageFiltering",void 0),X([(0,g.Event)()],t.prototype,"finetuneValueChanging",void 0),X([(0,g.Event)()],t.prototype,"click",void 0),X([(0,g.Event)()],t.prototype,"shapeChange",void 0),X([(0,g.Event)()],t.prototype,"quickAccessToolbarOpen",void 0),X([(0,g.Event)()],t.prototype,"resizing",void 0),X([(0,g.Event)()],t.prototype,"quickAccessToolbarItemClick",void 0),X([(0,g.Event)()],t.prototype,"frameChange",void 0),X([(0,g.Event)()],t.prototype,"editComplete",void 0),t=o=X([g.NotifyPropertyChanges],t)}(g.Component);!function(e){e.Png="Png",e.Jpeg="Jpeg",e.Svg="Svg",e.WebP="WebP",e.Bmp="Bmp"}(t||(t={})),function(e){e.Horizontal="Horizontal",e.Vertical="Vertical"}(o||(o={})),function(e){e.Rectangle="Rectangle",e.Ellipse="Ellipse",e.Line="Line",e.Arrow="Arrow",e.Path="Path",e.Text="Text",e.FreehandDraw="FreehandDraw",e.Image="Image"}(i||(i={})),function(e){e[e.MouseWheel=1]="MouseWheel",e[e.Pinch=2]="Pinch",e[e.Commands=4]="Commands",e[e.Toolbar=8]="Toolbar"}(r||(r={})),function(e){e.Bootstrap5="Bootstrap5",e.Bootstrap5Dark="Bootstrap5Dark",e.Tailwind="Tailwind",e.TailwindDark="TailwindDark",e.Fluent="Fluent",e.FluentDark="FluentDark",e.Bootstrap4="Bootstrap4",e.Bootstrap="Bootstrap",e.BootstrapDark="BootstrapDark",e.Material="Material",e.MaterialDark="MaterialDark",e.Fabric="Fabric",e.FabricDark="FabricDark",e.Highcontrast="Highcontrast",e.Fluent2="Fluent2",e.Fluent2Dark="Fluent2Dark",e.Tailwind3="Tailwind3",e.Tailwind3Dark="Tailwind3Dark"}(a||(a={})),function(e){e.Crop="Crop",e.Transform="Transform",e.Annotate="Annotate",e.ZoomIn="ZoomIn",e.ZoomOut="ZoomOut",e.Open="Open",e.Reset="Reset",e.Save="Save",e.Pan="Pan",e.Move="Move",e.Pen="Pen",e.Line="Line",e.Arrow="Arrow",e.Path="Path",e.Rectangle="Rectangle",e.Image="Image",e.Ellipse="Ellipse",e.Text="Text",e.CustomSelection="CustomSelection",e.CircleSelection="CircleSelection",e.SquareSelection="SquareSelection",e.RatioSelection="RatioSelection",e.RotateLeft="RotateLeft",e.RotateRight="RotateRight",e.FlipHorizontal="FlipHorizontal",e.FlipVertical="FlipVertical",e.Undo="Undo",e.Redo="Redo",e.None="None",e.Mat="Mat",e.Bevel="Bevel",e.Inset="Inset",e.Hook="Hook",e.Finetune="Finetune",e.Filter="Filter",e.Frame="Frame",e.Resize="Resize",e.HorizontalFlip="HorizontalFlip",e.VerticalFlip="VerticalFlip",e.Brightness="Brightness",e.Contrast="Contrast",e.Hue="Hue",e.Saturation="Saturation",e.Opacity="Opacity",e.Blur="Blur",e.Exposure="Exposure",e.Default="Default",e.Chrome="Chrome",e.Cold="Cold",e.Warm="Warm",e.Grayscale="Grayscale",e.Sepia="Sepia",e.Invert="Invert",e.Straightening="Straightening"}(n||(n={})),function(e){e.Default="Default",e.Chrome="Chrome",e.Cold="Cold",e.Warm="Warm",e.Grayscale="Grayscale",e.Sepia="Sepia",e.Invert="Invert"}(s||(s={})),function(e){e.Brightness="Brightness",e.Contrast="Contrast",e.Hue="Hue",e.Saturation="Saturation",e.Exposure="Exposure",e.Opacity="Opacity",e.Blur="Blur"}(l||(l={})),function(e){e.None="None",e.Arrow="Arrow",e.SolidArrow="SolidArrow",e.Circle="Circle",e.SolidCircle="SolidCircle",e.Square="Square",e.SolidSquare="SolidSquare",e.Bar="Bar"}(p||(p={})),function(e){e.None="None",e.Mat="Mat",e.Bevel="Bevel",e.Line="Line",e.Inset="Inset",e.Hook="Hook"}(h||(h={})),function(e){e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted"}(d||(d={})),function(e){e.Blur="Blur",e.Pixelate="Pixelate"}(c||(c={}));var N=function(){function e(e){this.defToolbarItems=[],this.toolbarHeight=46,this.currToolbar="",this.preventZoomBtn=!1,this.currentToolbar="main",this.selFhdColor="#42a5f5",this.preventEnableDisableUr=!1,this.isAspectRatio=!0,this.isFrameToolbar=!1,this.presetColors={custom:["#000000","#f44336","#e91e63","#9c27b0","#673ab7","#2196f3","#03a9f4","#00bcd4","#009688","#ffeb3b","#ffffff","#ffebee","#fce4ec","#f3e5f5","#ede7f6","#e3f2fd","#e1f5fe","#e0f7fa","#e0f2f1","#fffde7","#f2f2f2","#ffcdd2","#f8bbd0","#e1bee7","#d1c4e9","#bbdefb","#b3e5fc","#b2ebf2","#b2dfdb","#fff9c4","#e6e6e6","#ef9a9a","#f48fb1","#ce93d8","#b39ddb","#90caf9","#81d4fa","#80deea","#80cbc4","#fff59d","#cccccc","#e57373","#f06292","#ba68c8","#9575cd","#64b5f6","#4fc3f7","#4dd0e1","#4db6ac","#fff176","#b3b3b3","#ef5350","#ec407a","#ab47bc","#7e57c2","#42a5f5","#29b6f6","#26c6da","#26a69a","#ffee58","#999999","#e53935","#d81b60","#8e24aa","#5e35b1","#1e88e5","#039be5","#00acc1","#00897b","#fdd835","#808080","#d32f2f","#c2185b","#7b1fa2","#512da8","#1976d2","#0288d1","#0097a7","#00796b","#fbc02d","#666666","#c62828","#ad1457","#6a1b9a","#4527a0","#1565c0","#0277bd","#00838f","#00695c","#f9a825","#4d4d4d","#b71c1c","#880e4f","#4a148c","#311b92","#0d47a1","#01579b","#006064","#004d40","#f57f17"]},this.isSlider=!1,this.currentQuality=1,this.imageQuality="highest",this.parent=e,this.addEventListener(),this.initLocale()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("toolbar",this.toolbar,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("toolbar",this.toolbar),this.parent.off("destroyed",this.destroy)},e.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:"Apply",Cancel:"Discard",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",Underline:"Underline",BoldItalic:"Bold Italic",Strikethrough:"Strikethrough",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",Image:"Add Image",Transparency:"Transparency",Height:"Height",Width:"Width",AspectRatio:"Maintain aspect ratio",W:"W",H:"H",DragText:"Drag and drop your image here or",DropText:"Drop your image here or",BrowseText:"Browse here...",SupportText:"Supports:",Frame:"Frame",Mat:"Mat",Bevel:"Bevel",Inset:"Inset",Hook:"Hook",Color:"Color",Size:"Size",Offset:"Offset",Radius:"Radius",Amount:"Amount",Resize:"Resize",0:"0%",20:"20%",40:"40%",60:"60%",80:"80%",100:"100%",1:"1",2:"2",3:"3",4:"4",5:"5",Border:"Border",Solid:"Solid",Dashed:"Dashed",Dotted:"Dotted",GradientColor:"Gradient Color",ConfirmDialogHeader:"Confirm Save Changes",ConfirmDialogContent:"Do you want to save the changes you made to the image?",AlertDialogHeader:"Unsupported file",AlertDialogContent:"The selected file is unsupported.",MinMaxSize:"with file size between",MinMaxSizeAlert:"File size between",MinSize:"with minimum file size of",MinSizeAlert:"A minimum file size of",MaxSize:"with maximum file size of",MaxSizeAlert:"A maximum file size of",To:"to",Bytes:"bytes",Yes:"Yes",No:"No",ImageErrorDialogHeader:"Image Selection Error",ImageErrorDialogContent:"Please select only one image to open.",Straighten:"Straighten",NoOutline:"No outline",DlgOK:"OK",SaveAs:"Save As",ImageName:"Image name",Format:"Format",Quality:"Quality",Download:"Download",Close:"Close",ImageSize:"Image Size",QualityInfo:"The image quality option is only available for JPEG format",Good:"Good",Great:"Great",Highest:"Highest",BringForward:"Bring Forward",SendBackward:"Send Backward",SendToBack:"Send to Back",BringToFront:"Bring to Front",ZOrder:"Z-Order",Redact:"Redact",Pixelate:"Pixelate",BorderRadius:"Border Radius",TextOutlineColor:"Outline Color",TextOutlineWidth:"Outline Width",PixelSize:"Pixel Size",And:"and"},this.l10n=new g.L10n("image-editor",this.defaultLocale,this.parent.locale)},e.prototype.toolbar=function(e){var t=this.parent;switch(this.updatePrivateVariables(),e.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(e.value.type,e.value.isApplyBtn,e.value.isCropping,e.value.isZooming,e.value.cType);break;case"renderQAT":this.renderQAT(e.value.isPenEdit);break;case"enable-disable-btns":this.enableDisableTbrBtn();break;case"init-main-toolbar":this.initMainToolbar(e.value.isApplyBtn,e.value.isDevice,e.value.isOkBtn,e.value.isResize,e.value.isFrame,e.value.isMainToolbar);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(e.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(e.value.locale);break;case"setPreventZoomBtn":this.preventZoomBtn=e.value.isPrevent;break;case"getToolbarHeight":e.value.obj.toolbarHeight=this.toolbarHeight;break;case"setToolbarHeight":((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.length>0&&t.toolbar.indexOf("Open")>-1)&&(this.toolbarHeight=e.value.height);break;case"setCurrentToolbar":this.currentToolbar=e.value.type;break;case"setSelectedFreehandColor":this.selFhdColor=e.value.color;break;case"setInitialAdjustmentValue":t.initialAdjustmentValue=e.value.value;break;case"getCanvasFilter":e.value.obj.canvasFilter=t.canvasFilter;break;case"getDefToolbarItems":e.value.obj.defToolbarItems=this.defToolbarItems;break;case"getPenStroke":this.getPenStroke(e.value.value);break;case"performDefToolbarClickAction":this.performDefTbrClick(e.value.type,e.value.isContextualToolbar,e.value.isDisabledAdjustment,e.value.isDisabledFilter,e.value.isFilterFinetune);break;case"setTempFilterProperties":t.setTempFilterProperties();break;case"refreshSlider":this.refreshSlider();break;case"getCurrAdjustmentValue":t.getCurrAdjustmentValue(e.value.type);break;case"setCurrAdjustmentValue":t.setCurrAdjustmentValue(e.value.type,e.value.value);break;case"refreshShapeDrawing":this.refreshShapeDrawing();break;case"setEnableDisableUndoRedo":this.preventEnableDisableUr=e.value.isPrevent;break;case"reset":this.reset();break;case"getLocaleText":e.value.obj.value=this.l10n.getConstant(e.value.obj.key);break;case"initResizeToolbar":this.initResizeToolbar();break;case"getFrameToolbar":e.value.obj.bool=this.isFrameToolbar;break;case"resizeClick":this.resizeClick();break;case"frameToolbarClick":this.frameToolbarClick();break;case"performCropTransformClick":this.performCropTransformClick(e.value.shape,e.value.isTransform);break;case"duplicateShape":this.duplicateShape(e.value.isPreventUndoRedo,!0);break;case"editText":this.editText();break;case"setInitialSize":this.initialSize=Number(e.value.value);break;case"widthPress":this.widthPress(e.value.e);break;case"heightPress":this.heightPress(e.value.e);break;case"widthAspectRatio":this.widthAspectRatio(e.value.e);break;case"heightAspectRatio":this.heightAspectRatio(e.value.e);break;case"cancelPan":this.cancelPan();break;case"zoomInBtnMouseDownHandler":this.zoomInBtnMouseDownHandler(e.value.event);break;case"zoomOutBtnMouseDownHandler":this.zoomOutBtnMouseDownHandler(e.value.event);break;case"drawDashedLine":this.drawDashedLine(e.value.context);break;case"saveDialogClosed":this.saveDialogClosed(e.value.id);break;case"getIndex":this.getIndex(e.value.item);break;case"getRectRadius":this.getRectRadius(e.value.text);break;case"applyPreviewFilter":this.applyPreviewFilter();break;case"renderSlider":this.renderSlider(e.value.type,e.value.isSelect);break;case"zoomInBtnClickHandler":this.zoomInBtnClickHandler(e.value.e);break;case"zoomOutBtnClickHandler":this.zoomOutBtnClickHandler(e.value.e);break;case"getAdjustmentToolbarItem":this.getAdjustmentToolbarItem();break;case"getFilterToolbarItem":this.getFilterToolbarItem();break;case"renderCropBtn":this.renderCropBtn()}},e.prototype.updatePrivateVariables=function(){var e=this.parent;this.inMemoryCanvas=e.inMemoryCanvas,e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d")),this.inMemoryCanvas&&(this.inMemoryContext=this.inMemoryCanvas.getContext("2d"))},e.prototype.reset=function(){var e=this.parent;(0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&e.toolbar.length>0||e.toolbarTemplate?e.toolbarTemplate?this.toolbarHeight=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight:this.toolbarHeight=46:this.toolbarHeight=0,e.prevCurrSelectionPoint=null,this.zoomBtnHold=null,this.currToolbar="",e.cxtTbarHeight=null,this.currentToolbar="main",this.selFhdColor="#42a5f5",e.currentFilter="",this.preventZoomBtn=e.isCropToolbar=this.preventEnableDisableUr=this.isFrameToolbar=!1,e.initialAdjustmentValue=e.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",e.tempStraighten=0,e.isStraightening=!1},e.prototype.destroyTopToolbar=function(){var e=this.parent,t=document.getElementById(e.element.id+"_toolbar");this.isToolbar()&&t&&t.classList.contains("e-control")&&(0,g.getComponent)(t,"toolbar").destroy()},e.prototype.destroyBottomToolbar=function(){var e=this.parent,t=document.getElementById(e.element.id+"_bottomToolbar");t&&t.classList.contains("e-control")&&(0,g.getComponent)(t,"toolbar").destroy()},e.prototype.isToolbar=function(){var e=this.parent;return(0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&e.toolbar.length>0||!(0,g.isNullOrUndefined)(e.toolbarTemplate)},e.prototype.createToolbar=function(){var e=this,t=this.parent,o=t.element.id;if((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.length>0){t.element.appendChild(t.createElement("div",{id:o+"_toolbarArea",className:"e-toolbar-area"}));var i={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new C.Uploader({allowedExtensions:t.uploadSettings.allowedExtensions,multiple:!1})};(0,g.isNullOrUndefined)(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(i);var r=document.getElementById(o+"_toolbarArea"),a=t.createElement("div",{id:o+"_toolbar"});r.appendChild(a);var n=[{cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new C.Uploader({allowedExtensions:t.uploadSettings.allowedExtensions,multiple:!1,selected:function(){var i=document.getElementById(o+"_toolbar"),r=document.getElementById(o+"_bottomToolbar");t.disabled||(g.Browser.isDevice?(e.defToolbarItems.length>0&&i&&(0,g.getComponent)(i,"toolbar").destroy(),r&&(0,g.getComponent)(r,"toolbar").destroy(),e.initMainToolbar(!1,g.Browser.isDevice,null),e.createBottomToolbar()):(e.defToolbarItems.length>0&&i&&(0,g.getComponent)(i,"toolbar").destroy(),e.initMainToolbar(!1,!1,null)))}})}];new v.Toolbar({items:n,width:"100%",created:function(){t.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+o+"_toolbar"),this.createLeftToolbarControls();var s=document.getElementById(o+"_toolbar");if(a&&(this.toolbarHeight=s.clientHeight,t.toolbar&&t.toolbar.length>0&&-1===t.toolbar.indexOf("Open"))){var l=(0,g.getComponent)(document.getElementById(t.element.id+"_toolbar"),"toolbar");l&&(l.destroy(),document.getElementById(t.element.id+"_toolbar").innerHTML="")}}else this.toolbarHeight=0},e.prototype.createContextualToolbar=function(){var e=this.parent,t=e.element.id;if((0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&e.toolbar.length>0){var o=e.createElement("div",{id:t+"_contextualToolbarArea",className:"e-contextual-toolbar-wrapper e-hide"});o.style.position="absolute",e.element.appendChild(o);var i=document.getElementById(t+"_contextualToolbarArea"),r=e.createElement("div",{id:t+"_contextualToolbar"});i.appendChild(r)}},e.prototype.createBottomToolbar=function(){var e=this.parent,t=e.element.id;if(e.element.querySelector("#"+t+"_bottomToolbarArea")&&e.element.querySelector("#"+t+"_bottomToolbarArea").remove(),(0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&e.toolbar.length>0){if(e.element.appendChild(e.createElement("div",{id:t+"_bottomToolbarArea",className:"e-bottom-toolbar"})),!e.toolbarTemplate){var o=document.getElementById(t+"_bottomToolbarArea"),i=e.createElement("div",{id:t+"_bottomToolbar"});o.appendChild(i)}this.initBottomToolbar()}},e.prototype.createQuickAccessToolbar=function(){var e=this.parent,t=e.element.id;if(e.showQuickAccessToolbar){var o={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new C.Uploader({allowedExtensions:e.uploadSettings.allowedExtensions,multiple:!1})};(0,g.isNullOrUndefined)(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(o);var i=document.getElementById(t+"_quickAccessToolbarArea"),r=e.createElement("div",{id:t+"_quickAccessToolbar"});i.appendChild(r),new v.Toolbar({clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+t+"_quickAccessToolbar")}},e.prototype.initMainToolbar=function(e,t,o,i,r,a,n){var s=this,l=this.parent,p=l.element.id;if(this.isToolbar()){var h=this.getLeftToolbarItem(o,i),d=this.getRightToolbarItem(o,a,n),c=this.getMainToolbarItem(e,r,n),u=this.getZoomToolbarItem();this.defToolbarItems=t?r||n?c:h.concat(d):h.concat(c,d,u);var f={toolbarType:"main",toolbarItems:this.defToolbarItems};if(l.trigger("toolbarUpdating",f),this.defToolbarItems=f.toolbarItems,this.defToolbarItems.length>0){var m=new v.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t||s.renderAnnotationBtn(),s.wireZoomBtnEvents(),l.trigger("toolbarCreated",{toolbarType:"main"})}});if(t&&r||t&&n?m.appendTo("#"+p+"_bottomToolbar"):m.appendTo("#"+p+"_toolbar"),this.createLeftToolbarControls(),this.enableDisableTbrBtn(),this.isToolbar()&&document.getElementById(p+"_toolbar"))(0,g.getComponent)(p+"_toolbar","toolbar").refreshOverflow()}}},e.prototype.initBottomToolbar=function(){var e=this,t=this.parent,o=t.element.id;if((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.length>0){var i=this.getMainToolbarItem(),r={toolbarType:"bottom-toolbar",toolbarItems:i};if(t.trigger("toolbarUpdating",r),i=r.toolbarItems,new v.Toolbar({items:i,width:"100%",created:function(){e.renderAnnotationBtn(),e.renderCropBtn(),e.renderTransformBtn(),t.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+o+"_bottomToolbar"),this.defToolbarItems.length>0&&document.getElementById(o+"_bottomToolbar"))(0,g.getComponent)(o+"_bottomToolbar","toolbar").refreshOverflow()}},e.prototype.getLeftToolbarItem=function(e,t){var o=this.parent,i=o.element.id,a=[];e&&!t||((0,g.isNullOrUndefined)(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Open")>-1?(a.push({id:i+"_upload",cssClass:"e-image-upload",align:"Left",type:"Input",template:new C.Uploader({allowedExtensions:o.uploadSettings.allowedExtensions,multiple:!1})}),a.push({visible:!1,cssClass:"e-image-position e-btn e-flat",tooltipText:this.l10n.getConstant("Browse"),align:"Left"})):g.Browser.isDevice&&o.toolbar&&-1===o.toolbar.indexOf("Open")&&(a.push({visible:!1,id:i+"_upload",cssClass:"e-image-upload",align:"Left",type:"Input",template:new C.Uploader({allowedExtensions:o.uploadSettings.allowedExtensions,multiple:!1})}),a.push({visible:!1,cssClass:"e-image-position e-btn e-flat",tooltipText:this.l10n.getConstant("Browse"),align:"Left"}))),o.allowUndoRedo&&!t&&(((0,g.isNullOrUndefined)(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Undo")>-1)&&a.push({id:i+"_undo",prefixIcon:"e-icons e-undo",cssClass:"top-icon e-undo",tooltipText:this.l10n.getConstant("Undo"),align:"Left"}),((0,g.isNullOrUndefined)(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Redo")>-1)&&a.push({id:i+"_redo",prefixIcon:"e-icons e-redo",cssClass:"top-icon e-redo",tooltipText:this.l10n.getConstant("Redo"),align:"Left"})),this.preventZoomBtn||(o.zoomSettings.zoomTrigger&r.Toolbar)!==r.Toolbar||t||(((0,g.isNullOrUndefined)(o.toolbar)||o.toolbar&&o.toolbar.indexOf("ZoomOut")>-1)&&a.push({id:i+"_zoomOut",prefixIcon:"e-icons e-zoom-out",cssClass:"top-icon e-dec-zoom",tooltipText:this.l10n.getConstant("ZoomOut"),align:"Left"}),((0,g.isNullOrUndefined)(o.toolbar)||o.toolbar&&o.toolbar.indexOf("ZoomIn")>-1)&&a.push({id:i+"_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++)a.push(n[s]);return a},e.prototype.getRightToolbarItem=function(e,t,o){var i=this.parent,r=i.element.id,a=[];(e||o)&&(a.push({id:r+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),a.push({id:r+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),!t&&g.Browser.isDevice||!((0,g.isNullOrUndefined)(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Reset")>-1)||a.push({id:r+"_reset",prefixIcon:"e-icons e-btn-reset",cssClass:"top-icon e-img-reset",tooltipText:this.l10n.getConstant("Reset"),align:"Right"}),e||((0,g.isNullOrUndefined)(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Save")>-1)&&a.push({id:r+"_save",prefixIcon:"e-icons e-btn-save",cssClass:"e-caret-hide top-icon e-save",tooltipText:this.l10n.getConstant("Save"),align:"Right"});for(var n=this.processToolbar("right"),s=0,l=n.length;s<l;s++)a.push(n[s]);return a},e.prototype.getMainToolbarItem=function(e,t,o){var i=this.parent,r=i.element.id,a=[];t?(((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("None")>-1||i.toolbar.indexOf("Frame")>-1)&&a.push({id:r+"_none",prefixIcon:"e-icons e-frame-none",cssClass:"top-icon e-frame-none",tooltipText:this.l10n.getConstant("None"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Mat")>-1||i.toolbar.indexOf("Frame")>-1)&&a.push({id:r+"_mat",prefixIcon:"e-icons e-frame-mat",cssClass:"top-icon e-frame-mat",tooltipText:this.l10n.getConstant("Mat"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Bevel")>-1||i.toolbar.indexOf("Frame")>-1)&&a.push({id:r+"_bevel",prefixIcon:"e-icons e-frame-bevel",cssClass:"top-icon e-frame-bevel",tooltipText:this.l10n.getConstant("Bevel"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Line")>-1||i.toolbar.indexOf("Frame")>-1)&&a.push({id:r+"_line",prefixIcon:"e-icons e-frame-line",cssClass:"top-icon e-frame-line",tooltipText:this.l10n.getConstant("Line"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Inset")>-1||i.toolbar.indexOf("Frame")>-1)&&a.push({id:r+"_inset",prefixIcon:"e-icons e-frame-inset",cssClass:"top-icon e-frame-inset",tooltipText:this.l10n.getConstant("Inset"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Hook")>-1||i.toolbar.indexOf("Frame")>-1)&&a.push({id:r+"_hook",prefixIcon:"e-icons e-frame-hook",cssClass:"top-icon e-frame-hook",tooltipText:this.l10n.getConstant("Hook"),align:"Center"})):o?(a.push({id:r+"_redactBlur",prefixIcon:"e-icons e-tint",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Blur"),align:"Center"}),a.push({id:r+"_pixelate",prefixIcon:"e-icons e-opacity",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Pixelate"),align:"Center"}),a.push({id:r+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),a.push({id:r+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"})):(((0,g.isNullOrUndefined)(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Crop")>-1)&&a.push({id:r+"_cropTransform",prefixIcon:"e-icons e-crop",cssClass:"top-icon e-crop",tooltipText:this.l10n.getConstant("CropAndTransform"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Annotate")>-1)&&a.push({id:r+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+r+'_annotationBtn"></button>'}),((0,g.isNullOrUndefined)(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Finetune")>-1)&&a.push({id:r+"_adjustment",prefixIcon:"e-icons e-adjustment",cssClass:"top-icon e-adjustment",tooltipText:this.l10n.getConstant("Finetune"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Filter")>-1)&&a.push({id:r+"_filter",prefixIcon:"e-icons e-filters",cssClass:"top-icon e-filters",tooltipText:this.l10n.getConstant("Filter"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Frame")>-1)&&a.push({id:r+"_frame",prefixIcon:"e-icons e-border-frame",cssClass:"top-icon e-border-frame",tooltipText:this.l10n.getConstant("Frame"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Resize")>-1)&&a.push({id:r+"_resize",prefixIcon:"e-icons e-resize",cssClass:"top-icon e-resize",tooltipText:this.l10n.getConstant("Resize"),align:"Center"}),((0,g.isNullOrUndefined)(i.toolbar)||!(0,g.isNullOrUndefined)(i.toolbar)&&i.toolbar.indexOf("Redact")>-1)&&a.push({id:r+"_redact",prefixIcon:"e-icons e-redact",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Redact"),align:"Center"}));for(var n=this.processToolbar("center"),s=0,l=n.length;s<l;s++)a.push(n[s]);return e&&(a.push({id:r+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),a.push({id:r+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),a},e.prototype.getZoomToolbarItem=function(){return[]},e.prototype.updateContextualToolbar=function(e,t,o){var i=this.parent,r=i.element.id,a=i.element.querySelector("#"+r+"_toolbarArea"),n=i.element.querySelector("#"+r+"_contextualToolbarArea");if(n){if(n.classList.remove("e-hide"),n.style.left=a.offsetLeft+"px","filter"===e){var s=document.getElementById(r+"_toolbar");s&&this.defToolbarItems.length>0&&(0,g.getComponent)(s,"toolbar").destroy(),g.Browser.isDevice?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!0,null,null),this.refreshSlider(),this.initFilterToolbarItem()}else{(h=document.querySelector("#"+r+"_contextualToolbar")).classList.contains("e-control")&&(0,g.getComponent)(h,"toolbar").destroy(),this.refreshSlider(),"frame"===e?this.initFrameToolbarItem():this.renderSlider(t,o)}if(i.toolbarTemplate?this.toolbarHeight=i.element.querySelector("#"+r+"_toolbarArea").clientHeight:i.element.querySelector("#"+r+"_toolbar")&&(this.toolbarHeight=i.element.querySelector("#"+r+"_toolbar").clientHeight),i.toolbarHeight=this.toolbarHeight,g.Browser.isDevice){var l=n.offsetHeight+1,p=i.element.querySelector("#"+r+"_customizeWrapper");this.isFrameToolbar&&p&&(l=p.offsetHeight+2);var h,d=i.element.querySelector("#"+r+"_canvasWrapper").offsetHeight;if(n.style.top=this.toolbarHeight+1+d-l+"px","straighten"===t)i.isStraightening=!0,"absolute"===(h=i.element.querySelector("#"+r+"_contextualToolbarArea")).style.position&&(h.style.position="",i.element.insertBefore(h,i.element.querySelector("#"+r+"_bottomToolbarArea")),i.update(),o&&i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:this.getCropTextContent(document.getElementById(r+"_cropBtn")).toLowerCase(),startX:null,startY:null,width:null,height:null}}))}else n.style.top=this.toolbarHeight+1+"px"}},e.prototype.processToolbar=function(e){var t=this.parent,o=[];if(t.toolbar)for(var i=0,r=t.toolbar.length;i<r;i++)"object"==typeof t.toolbar[i]&&((0,g.isNullOrUndefined)(t.toolbar[i].align)?"left"===e&&o.push(t.toolbar[i]):t.toolbar[i].align.toLowerCase()===e&&o.push(t.toolbar[i]));return o},e.prototype.processSubToolbar=function(e){var t=[];if(e)for(var o=0,i=e.length;o<i;o++)"object"==typeof e[o]&&(e[o].align="Center",t.push(e[o]));return t},e.prototype.wireZoomBtnEvents=function(){var e=document.querySelector("#"+this.parent.element.id+"_zoomIn"),t=document.querySelector("#"+this.parent.element.id+"_zoomOut");e&&(e.addEventListener("mousedown",this.zoomInBtnMouseDownHandler.bind(this)),e.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),e.addEventListener("click",this.zoomInBtnClickHandler.bind(this))),t&&(t.addEventListener("mousedown",this.zoomOutBtnMouseDownHandler.bind(this)),t.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),t.addEventListener("click",this.zoomOutBtnClickHandler.bind(this)))},e.prototype.widthPress=function(e){109!==e.keyCode||e.preventDefault()},e.prototype.heightPress=function(e){109!==e.keyCode||e.preventDefault()},e.prototype.widthAspectRatio=function(e){if(109!==e.keyCode&&9!==e.keyCode){var t=this.parent,o=t.element.id,i=t.element.querySelector("#"+o+"_resizeHeight"),r=t.element.querySelector("#"+o+"_resizeWidth"),a=t.element.querySelector("#"+o+"_aspectratio"),n=t.img.destWidth,s=t.img.destHeight,l=parseFloat(i.value)/(s/n),p=l%1>=.5||l%1<=-.5?Math.round(l):l<0?Math.ceil(l):Math.floor(l),h=(0,g.getComponent)(r,"numerictextbox"),d=(0,g.getComponent)(r,"numerictextbox");a&&(null==p||isNaN(p)?(0,g.isNullOrUndefined)(h.value)?(h.placeholder="0 px",r.placeholder="0 px",(0,g.isNullOrUndefined)(d.value)&&!(0,g.isNullOrUndefined)(d.placeholder)&&(h.placeholder=""+t.img.srcWidth,r.placeholder=""+t.img.srcWidth)):(h.value=0,r.value="0 px"):(0,g.isNullOrUndefined)(h.value)?(h.placeholder=p+" px",r.placeholder=p.toString()+" px"):(h.value=p,r.value=p.toString()+" px"))}},e.prototype.heightAspectRatio=function(e){if(109!==e.keyCode&&9!==e.keyCode){var t=this.parent,o=t.element.id,i=t.element.querySelector("#"+o+"_resizeHeight"),r=t.element.querySelector("#"+o+"_resizeWidth"),a=t.element.querySelector("#"+o+"_aspectratio"),n=t.img.destWidth,s=t.img.destHeight,l=parseFloat(r.value)/(n/s),p=l%1>=.5||l%1<=-.5?Math.round(l):l<0?Math.ceil(l):Math.floor(l),h=(0,g.getComponent)(i,"numerictextbox"),d=(0,g.getComponent)(r,"numerictextbox");a&&(isNaN(p)?(0,g.isNullOrUndefined)(h.value)?(h.placeholder="0 px",i.placeholder="0 px",(0,g.isNullOrUndefined)(d.value)&&!(0,g.isNullOrUndefined)(d.placeholder)&&(h.placeholder=""+t.img.srcHeight,i.placeholder=""+t.img.srcHeight)):(h.value=0,i.value="0 px"):(0,g.isNullOrUndefined)(h.value)?(h.placeholder=p+" px",i.placeholder=p.toString()+" px"):(h.value=p,i.value=p.toString()+" px"))}},e.prototype.getResizeToolbarItem=function(){var e=this.parent,t=e.element.id,o=!(!e.aspectWidth||!e.aspectHeight),i=this.parent.transform.degree%90==0&&this.parent.transform.degree%180!=0?Math.ceil(this.parent.img.srcHeight).toString():Math.ceil(this.parent.img.srcWidth).toString(),r=this.parent.transform.degree%90==0&&this.parent.transform.degree%180!=0?Math.ceil(this.parent.img.srcWidth).toString():Math.ceil(this.parent.img.srcHeight).toString(),a=[],n=document.createElement("span");n.innerHTML=this.l10n.getConstant("W"),a.push({id:t+"_width",cssClass:"e-ie-resize-width",template:n,align:"Center"}),a.push({id:t+"_resizeWidth",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("Width"),align:"Center",type:"Input",template:new C.NumericTextBox({width:75,htmlAttributes:{maxLength:"4"},showSpinButton:!1,value:o?e.aspectWidth:null,placeholder:o?null:i,format:"###.## px"})});var s=document.createElement("span");return s.innerHTML=this.l10n.getConstant("H"),a.push({id:t+"_height",cssClass:"e-ie-resize-height",template:s,align:"Center"}),a.push({id:t+"_resizeHeight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("Height"),align:"Center",type:"Input",template:new C.NumericTextBox({width:75,htmlAttributes:{maxLength:"4"},showSpinButton:!1,value:o?e.aspectHeight:null,placeholder:o?null:r,format:"###.## px"})}),this.isAspectRatio?(a.push({id:t+"_nonaspectratio",prefixIcon:"e-icons e-unlock",align:"Center",tooltipText:this.l10n.getConstant("AspectRatio"),type:"Button"}),this.isAspectRatio=!1):(a.push({id:t+"_aspectratio",prefixIcon:"e-icons e-lock",align:"Center",tooltipText:this.l10n.getConstant("AspectRatio"),type:"Button",tabIndex:0}),this.isAspectRatio=!0),g.Browser.isDevice||(a.push({id:t+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),a.push({id:t+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),a},e.prototype.initResizeToolbar=function(){var e=this,t=this.parent,o=t.element.id,i=this.getLeftToolbarItem(!1,!0),r=this.getRightToolbarItem(),a=this.getResizeToolbarItem(),n=this.getZoomToolbarItem();g.Browser.isDevice?this.defToolbarItems=a:this.defToolbarItems=i.concat(n,a,r);var s={toolbarType:"resize",toolbarItems:this.defToolbarItems};t.trigger("toolbarUpdating",s),this.defToolbarItems=s.toolbarItems;var l=new v.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.wireResizeBtnEvents(),t.trigger("toolbarCreated",{toolbarType:"shapes"}),g.Browser.isDevice?e.defToolbarItems.length>0&&!(0,g.isNullOrUndefined)(document.getElementById(o+"_bottomToolbar"))&&l.refreshOverflow():(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&!(0,g.isNullOrUndefined)(document.getElementById(o+"_toolbar"))&&l.refreshOverflow())}});g.Browser.isDevice?l.appendTo("#"+o+"_bottomToolbar"):l.appendTo("#"+o+"_toolbar"),t.isResize=!1,this.enableDisableTbrBtn(),t.isResize=!0,t.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},e.prototype.wireResizeBtnEvents=function(){var e=this.parent,t=e.element.id,o=e.element.querySelector("#"+t+"_resizeHeight"),i=e.element.querySelector("#"+t+"_resizeWidth");(0,g.isNullOrUndefined)(o)||(o.addEventListener("keydown",this.widthPress.bind(this)),i.addEventListener("keyup",this.heightAspectRatio.bind(this))),(0,g.isNullOrUndefined)(i)||(i.addEventListener("keydown",this.heightPress.bind(this)),o.addEventListener("keyup",this.widthAspectRatio.bind(this)))},e.prototype.enableDisableTbrBtn=function(){var e=this.parent,t=e.element.id;if(!this.preventEnableDisableUr){var o={appliedUndoRedoColl:[]};e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:o}});var i={undoRedoStep:null};e.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}});var r=e.element.querySelector("#"+t+"_undo");r&&0===i.undoRedoStep?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):r&&i.undoRedoStep>0&&(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay"));var a=e.element.querySelector("#"+t+"_redo");a&&i.undoRedoStep===o.appliedUndoRedoColl.length?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):(a&&0===i.undoRedoStep&&o.appliedUndoRedoColl.length>0||a&&i.undoRedoStep>0)&&(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay"))}var n=document.querySelector("#"+t+"_zoomIn");n&&e.zoomSettings.zoomFactor>=e.zoomSettings.maxZoomFactor?(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+"_zoomOut");s&&e.zoomSettings.zoomFactor<=e.zoomSettings.minZoomFactor?(s.classList.add("e-disabled"),s.parentElement.classList.add("e-overlay")):s&&(s.classList.remove("e-disabled"),s.parentElement.classList.remove("e-overlay"));var l=document.querySelector("#"+t+"_frame");l&&(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)?l.parentElement.classList.add("e-overlay"):l&&l.parentElement.classList.remove("e-overlay");var p=document.querySelector("#"+t+"_aspectratio");p&&(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)?p.parentElement.classList.add("e-overlay"):p&&p.parentElement.classList.remove("e-overlay")},e.prototype.createLeftToolbarControls=function(){var e=this.parent,t=e.element.id;if(void 0!==this.defToolbarItems&&this.defToolbarItems.length>0&&document.getElementById(t+"_toolbar")){var o=document.getElementById(t+"_toolbar").querySelector(".e-image-upload");if(o){var i=o.getElementsByTagName("input")[0],r=o.getElementsByTagName("button")[0];r.className="e-tbar-btn e-tbtn-txt top-icon",r.innerHTML="",r.title=this.l10n.getConstant("Browse"),r.appendChild(e.createElement("span",{className:"e-btn-icon e-icons e-upload-icon e-icon-left"})),i.onchange=this.fileSelect.bind(this,i)}}},e.prototype.fileSelect=function(e,t){var o=this.parent,i=e.files[0].type.split("/")[1],r=this.parent.getExtensionArray(),a=("jpg"===i||"jpeg"===i)&&(o.uploadSettings.allowedExtensions.indexOf("jpg")>-1||o.uploadSettings.allowedExtensions.indexOf("jpeg")>-1);this.fileName=e.files[0].name.split(".")[0];var n=e.files[0].size;this.parent.notify("toolbar",{prop:"setInitialSize",value:{value:e.files[0].size}}),(r.indexOf(i)>-1||a||i.indexOf("svg")>-1&&r.indexOf("svg")>-1)&&(!this.parent.uploadSettings.minFileSize||n>this.parent.uploadSettings.minFileSize)&&(!this.parent.uploadSettings.maxFileSize||n<this.parent.uploadSettings.maxFileSize)?this.parent.notify("draw",{prop:"fileSelect",value:{inputElement:e,args:t}}):(this.parent.isImageLoaded||(this.destroyTopToolbar(),this.createToolbar(),g.Browser.isDevice&&this.destroyBottomToolbar()),this.parent.showDialogPopup("unsupported",!(r.indexOf(i)>-1||a||i.indexOf("svg")>-1&&r.indexOf("svg")>-1)))},e.prototype.triggerTbarClickEvent=function(e){var t={item:e.item,originalEvent:e.event};this.parent.trigger("toolbarItemClicked",t)},e.prototype.renderAnnotationBtn=function(e){var t=this,o=this.parent,r=!1,a=[],n=o.element.id,s=["Ellipse","Arrow","Line","Rectangle","Pen","Path","Text","Image"];if(o.toolbar)for(var l=0;l<s.length;l++)if(-1!==o.toolbar.indexOf(s[l])){r=!0;break}((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Pen")>-1)&&a.push({text:this.l10n.getConstant("Pen"),id:"pen",iconCss:"e-icons e-free-pen"}),((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Line")>-1)&&a.push({text:this.l10n.getConstant("Line"),id:"line",iconCss:"e-icons e-line"}),((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Rectangle")>-1)&&a.push({text:this.l10n.getConstant("Rectangle"),id:"rectangle",iconCss:"e-icons e-rectangle"}),((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Ellipse")>-1)&&a.push({text:this.l10n.getConstant("Ellipse"),id:"ellipse",iconCss:"e-icons e-circle"}),((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Arrow")>-1)&&a.push({text:this.l10n.getConstant("Arrow"),id:"arrow",iconCss:"e-icons e-arrow-right-up"}),((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Path")>-1)&&a.push({text:this.l10n.getConstant("Path"),id:"path",iconCss:"e-icons e-critical-path"}),((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Text")>-1)&&a.push({text:this.l10n.getConstant("Text"),id:"text",iconCss:"e-icons e-add-text"}),((0,g.isNullOrUndefined)(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Image")>-1)&&a.push({text:this.l10n.getConstant("Image"),id:"image",iconCss:"e-icons e-image"});var p={freehandDrawSelectedId:null};o.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:p}});var h=g.Browser.isDevice?"#"+n+"_bottomToolbar #"+n:"#"+n;this.enableDisableCloneBtn(h,p);var d=e?this.getCurrentShapeIcon(o.activeObj.shape):"e-annotation",c=new x.DropDownButton({items:a,iconCss:"e-icons "+d,cssClass:"e-image-popup",open:function(e){(o.currObjType.isFiltered||o.currObjType.isRedact)&&(o.okBtn(),o.element.querySelector("#"+n+"_annotationBtn").click()),g.Browser.isDevice&&(e.element.parentElement.style.top=c.element.getBoundingClientRect().top-e.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(e){o.noPushUndo=!1,t.triggerTbarClickEvent(e),o.okBtn();var r,a=!1;void 0!==o.activeObj.shape&&(r=o.activeObj.shape.split("-")),(void 0===r&&o.currObjType.isCustomCrop||void 0!==r&&"crop"===r[0])&&(a=!0),o.currObjType.isCustomCrop=!1,(a||o.togglePan)&&(o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),t.refreshToolbar("main"));var s={currentFreehandDrawIndex:null};o.notify("freehand-draw",{prop:"getCurrentFreehandDrawIndex",value:{obj:s}});var l,p,h={shapeSettingsObj:{}};c.iconCss="e-icons "+t.getCurrentShapeIcon(e.item.id),o.notify("draw",{prop:"updateTempObjColl"}),o.notify("draw",{prop:"updateTempPointColl"});var d={penStrokeWidth:2};switch(e.item.id){case"pen":o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:d}}),o.notify("draw",{prop:"setTempStrokeWidth",value:{strokeWidth:d.penStrokeWidth}}),o.drawingShape=null,o.notify("draw",{prop:"setTempFreehandCounter",value:{tempFreehandCounter:o.freehandCounter}}),o.notify("draw",{prop:"setTempCurrentFreehandDrawIndex",value:{tempCurrentFreehandDrawIndex:s.currentFreehandDrawIndex}}),t.currentToolbar="pen",o.freeHandDraw(!0),o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:h}}),l=h.shapeSettingsObj,o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:d}}),l.strokeWidth=d.penStrokeWidth,l.type=i.FreehandDraw,p={cancel:!1,action:"insert",previousShapeSettings:l,currentShapeSettings:l},o.notify("freehand-draw",{prop:"triggerShapeChanging",value:{shapeChangingArgs:p}});break;case"text":t.currentToolbar="text",o.drawingShape=e.item.id,t.currentToolbar="text",t.setInitialShapeSettings(e),o.notify("selection",{prop:"annotate",value:{shape:e.item.id}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"image":o.drawingShape=null,t.currentToolbar="shapes",o.element.querySelector("#"+n+"_fileUpload").click();break;case"ellipse":case"arrow":case"line":case"rectangle":case"path":o.drawingShape=e.item.id,t.currentToolbar="shapes",t.setInitialShapeSettings(e),o.notify("selection",{prop:"annotate",value:{shape:e.item.id}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:h}}),p={cancel:!1,action:"insert",previousShapeSettings:l=h.shapeSettingsObj,currentShapeSettings:l,allowShapeOverflow:-1===["ellipse","rectangle","text","image"].indexOf(t.parent.activeObj.shape)},o.trigger("shapeChanging",p),o.editCompleteArgs=p,o.notify("shape",{prop:"updateShapeChangeEventArgs",value:{shapeSettings:p.currentShapeSettings}})}t.updateToolbarItems();var u=o.togglePen;"pen"===e.item.id&&(o.togglePen=!1),o.notify("draw",{prop:"redrawDownScale"}),o.togglePen=u}});c.appendTo("#"+n+"_annotationBtn")},e.prototype.enableDisableCloneBtn=function(e,t){var o=this.parent,i=!1,r=Math.floor(o.activeObj.activePoint.width);o.activeObj.shape&&"text"===o.activeObj.shape&&11===o.activeObj.textSettings.fontSize&&(55===r||o.activeObj.textSettings.bold&&58===r)&&11===Math.floor(o.activeObj.activePoint.height)&&(i=!0);var a=document.querySelector(e+"_duplicate"),n=document.querySelector(e+"_remove"),s=document.querySelector(e+"_editText"),l=document.querySelector(e+"_zOrderBtn");i||0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&((0,g.isNullOrUndefined)(o.activeObj.pointColl)||o.activeObj.pointColl&&0===o.activeObj.pointColl.length)&&(0,g.isNullOrUndefined)(t.freehandDrawSelectedId)?(a&&a.parentElement.classList.add("e-overlay"),n&&n.parentElement.classList.add("e-overlay"),s&&s.parentElement.classList.add("e-overlay"),l&&l.parentElement.classList.add("e-overlay")):(a&&a.parentElement.classList.remove("e-overlay"),n&&n.parentElement.classList.remove("e-overlay"),s&&s.parentElement.classList.remove("e-overlay"),l&&l.parentElement.classList.remove("e-overlay")),l&&(0===o.shapeColl.length||t.freehandDrawSelectedId&&1===o.shapeColl.length)&&l.parentElement.classList.add("e-overlay")},e.prototype.renderStraightenSlider=function(){var e=this.parent,t=e.element.id;if(((0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&e.toolbar.indexOf("Straightening")>-1)&&e.element.querySelector("#"+t+"_straightenSlider")){var o=this.createSlider(-45,45,e.cropObj.straighten,"straighten");o.appendTo("#"+t+"_straightenSlider");var i=o.element.querySelector(".e-handle");i&&!g.Browser.isDevice&&(i.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()}),i.addEventListener("touchstart",function(e){e.preventDefault(),e.stopPropagation()}))}},e.prototype.renderCropBtn=function(e){var t,o,i=this,r=this.parent,a=[],n=!1,s=["CustomSelection","CircleSelection","SquareSelection","RatioSelection"];if(r.toolbar)for(var l=0;l<s.length;l++)if(-1!==r.toolbar.indexOf(s[l])){n=!0;break}((0,g.isNullOrUndefined)(r.toolbar)||!n||r.toolbar&&r.toolbar.indexOf("CustomSelection")>-1)&&a.push({text:this.l10n.getConstant("Custom"),id:"custom",iconCss:"e-icons e-custom"}),((0,g.isNullOrUndefined)(r.toolbar)||!n||r.toolbar&&r.toolbar.indexOf("CircleSelection")>-1)&&a.push({text:this.l10n.getConstant("Circle"),id:"circle",iconCss:"e-icons e-circle"}),((0,g.isNullOrUndefined)(r.toolbar)||!n||r.toolbar&&r.toolbar.indexOf("SquareSelection")>-1)&&a.push({text:this.l10n.getConstant("Square"),id:"square",iconCss:"e-icons e-square"}),((0,g.isNullOrUndefined)(r.toolbar)||!n||r.toolbar&&r.toolbar.indexOf("RatioSelection")>-1)&&(a.push({text:"2:3",id:"2:3",iconCss:"e-icons e-custom-f"}),a.push({text:"3:2",id:"3:2",iconCss:"e-icons e-custom-a"}),a.push({text:"3:4",id:"3:4",iconCss:"e-icons e-custom-g"}),a.push({text:"4:3",id:"4:3",iconCss:"e-icons e-custom-b"}),a.push({text:"4:5",id:"4:5",iconCss:"e-icons e-custom-h"}),a.push({text:"5:4",id:"5:4",iconCss:"e-icons e-custom-c"}),a.push({text:"5:7",id:"5:7",iconCss:"e-icons e-custom-i"}),a.push({text:"7:5",id:"7:5",iconCss:"e-icons e-custom-d"}),a.push({text:"9:16",id:"9:16",iconCss:"e-icons e-custom-j"}),a.push({text:"16:9",id:"16:9",iconCss:"e-icons e-custom-e"})),e?(t=this.getCurrentShapeIcon(e),o=e):r.activeObj.shape&&(0!==r.activeObj.activePoint.width||0!==r.activeObj.activePoint.height)||"path"===r.activeObj.shape&&r.activeObj.pointColl.length>0?(t=this.getCurrentShapeIcon(r.activeObj.shape),o=r.activeObj.shape):r.currSelectionPoint?(t=this.getCurrentShapeIcon(r.currSelectionPoint.shape),o=r.currSelectionPoint.shape):(t=a[0].iconCss,o=a[0].id);var p=new x.DropDownButton({open:function(e){if(r.togglePan&&i.cancelPan(),g.Browser.isDevice&&(e.element.parentElement.style.top=p.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px"),r.activeObj.shape&&r.activeObj.shape.split("-").length>1){var t=document.getElementById(r.activeObj.shape.split("-")[1]);t&&(t.classList.add("e-selected"),t.focus())}r.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},items:a,select:function(e){i.triggerTbarClickEvent(e),i.cropSelect(e),p.iconCss="e-icons "+i.getCurrentShapeIcon("crop-"+e.item.id),p.content=g.Browser.isDevice?null:r.toPascalCase(e.item.id)},iconCss:"e-icons "+t,cssClass:"e-image-popup e-ie-crop-ddb-popup",content:g.Browser.isDevice?null:r.toPascalCase(o.replace("crop-",""))});p.appendTo("#"+r.element.id+"_cropBtn")},e.prototype.renderTransformBtn=function(){var e=this,t=this.parent,o=[];((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.indexOf("RotateLeft")>-1)&&o.push({text:this.l10n.getConstant("RotateLeft"),id:"rotateleft",iconCss:"e-icons e-anti-clock-wise"}),((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.indexOf("RotateRight")>-1)&&o.push({text:this.l10n.getConstant("RotateRight"),id:"rotateright",iconCss:"e-icons e-clock-wise"}),((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.indexOf("FlipHorizontal")>-1)&&o.push({text:this.l10n.getConstant("HorizontalFlip"),id:"horizontalflip",iconCss:"e-icons e-horizontal-flip"}),((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar&&t.toolbar.indexOf("FlipVertical")>-1)&&o.push({text:this.l10n.getConstant("VerticalFlip"),id:"verticalflip",iconCss:"e-icons e-vertical-flip"});var i=new x.DropDownButton({open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement,o=t.offsetHeight;t.style.display="none",t.style.top=i.element.getBoundingClientRect().top-o+"px",t.style.display="block"}},items:o,select:function(o){e.triggerTbarClickEvent(o),t.transformSelect.bind(e)},iconCss:"e-icons e-transform",cssClass:"e-image-popup"});i.appendTo("#"+t.element.id+"_transformBtn")},e.prototype.saveDialogPopup=function(){var e=this,t=this.parent,o=t.element.id;t.element.appendChild(t.createElement("div",{id:o+"_saveDialog"}));var i=t.createElement("div",{id:o+"_dialogContent"});i.style.display="flex";var r=i.appendChild(t.createElement("div",{id:o+"_dialogImgContent",className:"e-ie-dlg-img-content"}));r.appendChild(t.createElement("canvas",{id:o+"_imgPic",className:"e-ie-img-dlg-canvas"})),r.appendChild(t.createElement("div",{id:o+"_imageNameContainer",className:"e-ie-img-size"})).appendChild(t.createElement("span",{id:o+"_imageNameLabel",className:"e-ie-quality-info"}));var a=i.appendChild(t.createElement("div",{id:o+"_dialogRightContent",className:"e-ie-dlg-right-content"})),n=a.appendChild(t.createElement("div",{id:o+"_namediv",className:"e-ie-img-save-name"}));n.appendChild(t.createElement("span",{id:o+"_labelImgname",className:"e-ie-img-label-name",innerHTML:this.l10n.getConstant("ImageName")})),n.appendChild(t.createElement("input",{id:o+"_imgNametext",className:"e-ie-img-input",attrs:{type:"text"}}));var s=a.appendChild(t.createElement("div",{id:o+"_imgNamediv",className:"e-ie-img-save-dlg"}));s.appendChild(t.createElement("span",{id:o+"_labelname",className:"e-ie-img-label-name",innerHTML:this.l10n.getConstant("Format")})),s.appendChild(t.createElement("button",{id:o+"_saveDropdownbtn",attrs:{tabindex:"1"}}));var l=a.appendChild(t.createElement("div",{id:o+"_imgQualitydiv",className:"e-ie-img-quality-name"})),p=t.createElement("div",{id:o+"_qualityContainer"});p.appendChild(t.createElement("span",{id:o+"_qualityLabel",className:"e-ie-img-quality-label",innerHTML:this.l10n.getConstant("Quality")})),p.appendChild(t.createElement("span",{id:o+"_qualityInfo",className:"e-circle-info e-icons e-ie-quality-span",attrs:{title:this.l10n.getConstant("QualityInfo")}})),p.appendChild(t.createElement("div",{id:o+"_imgsizeSpan",className:"e-ie-img-size-value-span"})).appendChild(t.createElement("span",{id:o+"_imgsizeValueSpan",className:""})),l.appendChild(p);var h=t.createElement("div",{id:o+"_qualityOptionContainer",className:"e-ie-quality-option-container"}),d=l.appendChild(t.createElement("div",{id:o+"_qualityButtonGroup",className:"e-btn-group"}));["Good","Great","Highest"].forEach(function(t){var i=document.createElement("input");i.type="radio",i.id=o+"_"+t.toLowerCase(),i.name="quality",i.value=t.toLowerCase();var r=document.createElement("label");r.className="e-btn",r.htmlFor=t.toLowerCase(),r.textContent=e.l10n.getConstant(t),d.appendChild(i),d.appendChild(r)}),h.appendChild(d),h.appendChild(t.createElement("div",{id:o+"_qualitySlider",className:"e-ie-img-quality-slider"})),h.appendChild(t.createElement("button",{id:o+"_qualitybuttonIcon",className:"e-ie-img-icon-button",attrs:{type:"button"}})),l.appendChild(h),g.Browser.isDevice&&a.appendChild(t.createElement("span",{id:o+"_qualitySize",className:"e-ie-img-quality-size"})),t.element.querySelector("#"+o+"_saveDialog").style.display="block",t.element.appendChild(i);var c=new b.Dialog({target:t.element,header:this.l10n.getConstant("SaveAs"),closeOnEscape:!0,content:document.getElementById(o+"_dialogContent"),width:g.Browser.isDevice?"345px":"570px",isModal:!0,animationSettings:{effect:"Zoom"},beforeOpen:this.onBeforeopen(),close:this.saveDialogClosed.bind(this,o),cssClass:"e-ie-save-dialog",buttons:[{click:function(){c.hide()},buttonModel:{content:this.l10n.getConstant("Close"),cssClass:"e-save-cancel-btn"}},{click:function(){e.download(),c.hide(),e.isSlider=!1},buttonModel:{isPrimary:!0,content:this.l10n.getConstant("Download"),cssClass:"e-flat e-save-download-btn"}}]});c.appendTo("#"+o+"_saveDialog"),this.updateSavePreviewImage()},e.prototype.updateSavePreviewImage=function(){var e=this.parent,t=e.element.id,o=e.element.querySelector("#"+t+"_saveDialog");if(!g.Browser.isDevice&&o){var i=.35*o.offsetWidth,r=parseInt(o.style.maxHeight,10)-o.querySelector(".e-dlg-header-content").offsetHeight-o.querySelector(".e-footer-content").offsetHeight-20-2*parseInt(window.getComputedStyle(o.querySelector("#"+t+"_saveDialog_dialog-content")).padding,10),a=e.element.querySelector("#"+t+"_imgPic"),n=a.width,s=a.height,l=i/n,p=r/s,h=Math.min(n,i),d=Math.min(s,r);l<1&&l<p?(h=n*l,d=s*l):p<1&&p<l&&(h=n*p,d=s*p);var c={canvas:null};e.notify("export",{prop:"exportToCanvas",value:{object:c}});var u=a.getContext("2d");u.clearRect(0,0,a.width,a.height),a.width=h,a.height=d;var v=c.canvas;u.imageSmoothingQuality="medium",u.drawImage(v,0,0,v.width,v.height,0,0,h,d)}},e.prototype.saveDialogClosed=function(e){(0,g.getComponent)(document.getElementById(e+"_saveDropdownbtn"),"dropdownbutton")&&(0,g.getComponent)(document.getElementById(e+"_saveDropdownbtn"),"dropdownbutton").destroy(),this.isSlider=!1,document.querySelector("#"+e+"_qualityButtonGroup")&&document.querySelector("#"+e+"_qualitySlider")&&(document.querySelector("#"+e+"_qualityButtonGroup").remove(),document.querySelector("#"+e+"_qualitySlider").remove(),document.querySelector("#"+e+"_imgsizeValueSpan").remove(),document.querySelector("#"+e+"_imageNameLabel").remove(),document.querySelector("#"+e+"_imgsizeSpan").remove()),document.getElementById(e+"_dialogContent").remove(),(0,g.getComponent)(document.getElementById(e+"_saveDialog"),"dialog").destroy(),document.getElementById(e+"_saveDialog").remove()},e.prototype.onBeforeopen=function(){var e=this,t=this.parent,o=t.element.id,i={canvas:null};new C.TextBox({placeholder:this.l10n.getConstant("ImageName")}).appendTo("#"+o+"_imgNametext");var r,a=document.getElementById(o+"_imgQualitydiv"),n=document.getElementById(o+"_qualitySlider"),s=document.querySelector("#"+o+"_qualityButtonGroup"),l=document.querySelector("#"+o+"_qualitybuttonIcon"),p=document.querySelector("#"+o+"_imgsizeSpan");r=g.Browser.isDevice?document.getElementById(o+"_qualitySize"):document.getElementById(o+"_imageNameLabel");var h={fileName:"",fileType:""};t.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:h}}),this.fileType=h.fileType?h.fileType:"JPEG",t.notify("export",{prop:"exportToCanvas",value:{object:i}});var d=i.canvas,c=document.getElementById(o+"_imgPic");c.width=d.width,c.height=d.height,new y.Button({iconCss:"e-icons e-settings"}).appendTo("#"+o+"_qualitybuttonIcon");var u=document.getElementById(o+"_saveDropdownbtn");if(u){var v=document.createElement("span");v.innerHTML="Webp"===this.fileType?"Webp":this.fileType.toUpperCase(),u&&u.appendChild(v);var f=new x.DropDownButton({items:[{id:"jpeg",text:"JPEG"},{id:"png",text:"PNG"},{id:"svg",text:"SVG"},{id:"webp",text:"WebP"}],open:function(e){g.Browser.isDevice&&(e.element.parentElement.style.top=f.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var t=v.innerHTML;""!==t&&e.element.querySelector('[aria-label = "'+t+'"]').classList.add("e-selected-btn")},select:function(t){p.style.display="none",e.fileType=v.innerHTML=t.item.text,"jpeg"!==t.item.id?(a.style.display="none",r.style.display="block",e.updateImageSize(1,i.canvas,e.fileType),n&&(e.isSlider&&(0,g.getComponent)(n,"slider").destroy(),n.style.display="none"),e.isSlider=!1):(a.style.display="block",(0,g.removeClass)([s],"e-hide"),n.style.display="none",r.style.display="block",e.updateImageSize((0,g.isNullOrUndefined)(e.currentQuality)?1:e.currentQuality,i.canvas,e.fileType),document.getElementById(o+"_"+e.imageQuality).checked=!0),e.updateSavePreviewImage()}});f.appendTo("#"+o+"_saveDropdownbtn"),document.getElementById(o+"_imgNametext").value=this.fileName?this.fileName:h.fileName,h.fileType&&"JPEG"!==h.fileType.toUpperCase()&&(a.style.display="none",p.style.display="none"),g.Browser.isDevice?(document.getElementById(o+"_dialogImgContent").style.display="none",document.getElementById(o+"_dialogRightContent").style.width="100%",this.updateImageSize(1,i.canvas,this.fileType)):this.updateImageSize(1,i.canvas,this.fileType)}document.getElementById(o+"_"+this.imageQuality).checked=!0,s.addEventListener("click",this.qualityBtnClickHandler.bind(this)),l.addEventListener("click",this.qualityBtnClickHandler.bind(this))},e.prototype.qualityBtnClickHandler=function(e){var t=this,o=this.parent,i=o.element.id,r=e.target,a={canvas:null},n={Good:.8,Great:.9,Highest:1},s=document.querySelector("#"+i+"_qualityButtonGroup"),l=document.querySelector("#"+i+"_qualitySlider"),p=document.querySelector("#"+i+"_qualityOptionContainer"),h=document.querySelector("#"+i+"_imgsizeSpan"),d=document.querySelector("#"+i+"_imgsizeValueSpan");if(o.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:{fileName:""}}}),o.notify("export",{prop:"exportToCanvas",value:{object:a}}),e.currentTarget.id!==i+"_qualitybuttonIcon"||this.isSlider)e.currentTarget.id===i+"_qualitybuttonIcon"&&this.isSlider?((0,g.getComponent)(l,"slider").destroy(),l.style.display="none",h.style.display="none",(0,g.removeClass)([s],"e-hide"),p.style.display="block",this.isSlider=!1):n.hasOwnProperty(r.textContent)&&!this.isSlider&&(e.target.previousElementSibling.checked=!0,this.currentQuality=n[r.textContent],this.imageQuality=r.textContent.toLowerCase(),this.updateImageSize(n[r.textContent],a.canvas,"jpeg"),this.updateSavePreviewImage());else{(0,g.addClass)([s],"e-hide"),l.style.display="block",h.style.display="inline-block",p.style.display="flex";var c=new C.Slider({tooltip:{placement:"Before",isVisible:!0,format:"P0",showOn:"Focus"},min:.01,max:1,step:.01,value:this.currentQuality,type:"MinRange",width:g.Browser.isDevice?"80%":"190px",created:function(){t.updateImageSize(t.currentQuality,a.canvas,"jpeg"),d.innerHTML=Math.round(100*t.currentQuality).toString(),t.updateSavePreviewImage()},changed:function(e){t.currentQuality=e.value,d.innerHTML=Math.round(100*t.currentQuality).toString(),o.notify("export",{prop:"setImageQuality",value:{value:e.value}}),t.updateImageSize(e.value,a.canvas,"jpeg"),t.updateSavePreviewImage()}});c.appendTo("#"+i+"_qualitySlider"),c.element.parentElement.classList.add("e-ie-quality-slider"),this.isSlider=!0}},e.prototype.updateImageSize=function(e,t,o){var i,r,a=this.parent,n=a.element.id,s=document.getElementById(n+"_imgPic"),l=s.getContext("2d");r=g.Browser.isDevice?document.getElementById(n+"_qualitySize"):document.getElementById(n+"_imageNameLabel");var p=a.imageSmoothingEnabled;if(l.canvas.getContext("2d").imageSmoothingQuality=p?"high":"low","jpeg"===o.toLowerCase())l.clearRect(0,0,s.width,s.height),l.drawImage(t,0,0),t.toBlob(function(e){if((i=Math.floor(e.size/1024))>1e3){var t=i/1024;r.innerHTML=this.l10n.getConstant("ImageSize")+": "+t.toFixed(2)+" MB",i=+t.toFixed(2)}else r.innerHTML=this.l10n.getConstant("ImageSize")+": "+i.toFixed(2)+" KB",i=+i.toFixed(2);g.Browser.isDevice&&(s.style.display="none"),this.fileSize=i}.bind(this),"image/jpeg",e);else if((0,g.isNullOrUndefined)(o)||"png"!==o.toLowerCase()&&"webp"!==o.toLowerCase())if((0,g.isNullOrUndefined)(o)||"svg"!==o.toLowerCase())if(g.Browser.isDevice)s.style.display="none";else if(l.clearRect(0,0,s.width,s.height),l.drawImage(t,0,0),this.initialSize>1e3){c=this.initialSize/1048576;r.innerHTML=this.l10n.getConstant("ImageSize")+": "+c.toFixed(2)+" MB"}else r.innerHTML=this.l10n.getConstant("ImageSize")+": "+this.initialSize.toFixed(2)+" KB";else{l.clearRect(0,0,s.width,s.height),l.drawImage(t,0,0);var h=t.toDataURL("image/svg+xml").split(",")[1].length,d=Math.floor(h/1024);if(d>1e3){var c=d/1024;r.innerHTML=this.l10n.getConstant("ImageSize")+": "+c.toFixed(2)+" MB",d=+c.toFixed(2)}else r.innerHTML=this.l10n.getConstant("ImageSize")+": "+d.toFixed(2)+" KB",d=+d.toFixed(2);g.Browser.isDevice&&(s.style.display="none"),this.fileSize=d}else{var u="image/"+o.toLowerCase();l.clearRect(0,0,s.width,s.height),l.drawImage(t,0,0),t.toBlob(function(e){if((i=Math.floor(e.size/1024))>1e3){var t=i/1024;r.innerHTML=this.l10n.getConstant("ImageSize")+": "+t.toFixed(2)+" MB",i=+t.toFixed(2)}else r.innerHTML=this.l10n.getConstant("ImageSize")+": "+i.toFixed(2)+" KB",i=+i.toFixed(2);g.Browser.isDevice&&(s.style.display="none"),this.fileSize=i}.bind(this),u,1)}},e.prototype.download=function(){var e=this.parent,t=e.element.id;if("JPEG"===this.fileType&&this.isSlider){var o=(0,g.getComponent)(document.getElementById(t+"_qualitySlider"),"slider").value;e.notify("export",{prop:"setImageQuality",value:{value:o}})}else e.notify("export",{prop:"setImageQuality",value:{value:this.currentQuality}});var i=document.getElementById(t+"_imgNametext").value;e.export(this.fileType,i)},e.prototype.getCropTransformToolbarItem=function(){var e=this.parent,t=e.element.id,o=[];if(o.push({id:t+"_crop",tooltipText:this.l10n.getConstant("CropSelection"),align:"Center",template:'<button id="'+t+'_cropBtn"></button>'}),o.push({align:"Center",type:"Separator"}),((0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("RotateLeft")>-1))&&o.push({id:t+"_rotateLeft",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),((0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("RotateRight")>-1))&&o.push({id:t+"_rotateRight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),o.length>2&&o.push({align:"Center",type:"Separator"}),((0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("HorizontalFlip")>-1))&&o.push({id:t+"_horizontalFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),((0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("VerticalFlip")>-1))&&o.push({id:t+"_verticalFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"}),((0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&e.toolbar.indexOf("Straightening")>-1)&&!g.Browser.isDevice&&(o.push({align:"Center",type:"Separator"}),(0,g.isNullOrUndefined)(e.toolbar)||e.toolbar&&e.toolbar.indexOf("Straightening")>-1)){var i=document.createElement("span");i.innerHTML=this.l10n.getConstant("Straighten"),o.push({id:t+"_straightenSpan",cssClass:"e-ie-straighten-span",template:i,align:"Center"}),o.push({id:t+"_straighten",cssClass:"top-icon e-straighten",tooltipText:this.l10n.getConstant("Straighten"),align:"Center",type:"Input",template:'<div id="'+t+'_straightenSlider"></div>'});var r=document.createElement("span");r.innerHTML=e.transform.straighten.toString()+"°",o.push({id:t+"_straightenSpan",cssClass:"e-ie-straighten-value-span",template:r,align:"Center"})}return g.Browser.isDevice||(o.push({id:t+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),o.push({id:t+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},e.prototype.getShapesToolbarItem=function(e){var t=this.parent,o=t.element.id,i=[];((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar)&&i.push({id:o+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+o+'_annotationBtn"></button>'}),e.indexOf("fillColor")>-1&&i.push({prefixIcon:"e-icons e-copy",id:o+"_fillcolor",cssClass:"top-icon e-fill",tooltipText:this.l10n.getConstant("FillColor"),align:"Center",type:"Input",template:'<button id="'+o+'_fillColorBtn"></button>'}),e.indexOf("strokeColor")>-1&&i.push({prefixIcon:"e-icons e-copy",id:o+"_strokecolor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+o+'_borderColorBtn"></button>'}),e.indexOf("strokeWidth")>-1&&i.push({id:o+"_strokeWidth",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("StrokeWidth"),align:"Center",type:"Input",template:'<button id="'+o+'_borderWidthBtn"></button>'}),e.indexOf("start")>-1&&i.push({id:o+"_start",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Start"),align:"Center",type:"Input",template:'<button id="'+o+'_startBtn"></button>'}),e.indexOf("borderRadius")>-1&&i.push({id:o+"_rectangleRadius",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("BorderRadius"),align:"Center",type:"Input",template:'<button id="'+o+'_rectangleRadiusBtn"></button>'}),e.indexOf("end")>-1&&i.push({id:o+"_end",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("End"),align:"Center",type:"Input",template:'<button id="'+o+'_endBtn"></button>'}),e.indexOf("flip")>-1&&(i.push({id:o+"_rotLeft",prefixIcon:"e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),i.push({id:o+"_rotRight",prefixIcon:"e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),i.push({id:o+"_hFlip",prefixIcon:"e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),i.push({id:o+"_vFlip",prefixIcon:"e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"})),e.indexOf("transparency")>-1&&(i.push({align:"Center",type:"Separator"}),i.push({id:o+"_transparency",prefixIcon:"e-opacity",tooltipText:this.l10n.getConstant("Opacity"),align:"Center"})),i.push({align:"Center",type:"Separator"}),e.indexOf("z-order")>-1&&i.push({id:o+"_zOrder",cssClass:"top-icon e-list-unordered-3",tooltipText:this.l10n.getConstant("ZOrder"),align:"Center",type:"Input",template:'<button id="'+o+'_zOrderBtn"></button>'}),e.indexOf("duplicate")>-1&&i.push({id:o+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),e.indexOf("remove")>-1&&i.push({id:o+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"}),e.indexOf("text")>-1&&i.push({id:o+"_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(e),a=0,n=r.length;a<n;a++)i.push(r[a]);if(!g.Browser.isDevice){var s={shape:null};t.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"===s.shape?i.push({id:o+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0,disabled:!0}):i.push({id:o+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),i.push({id:o+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})}return i},e.prototype.initCropTransformToolbar=function(e,t){var o=this,i=this.parent,r=i.element.id,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getCropTransformToolbarItem(),l=this.getZoomToolbarItem();g.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p={toolbarType:"crop-transform",toolbarItems:this.defToolbarItems};i.trigger("toolbarUpdating",p),this.defToolbarItems=p.toolbarItems;var h=new v.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){o.renderCropBtn(e),o.renderStraightenSlider(),o.wireZoomBtnEvents(),i.trigger("toolbarCreated",{toolbarType:"shapes"}),g.Browser.isDevice?o.defToolbarItems.length>0&&document.getElementById(r+"_bottomToolbar")&&(h.refreshOverflow(),h.refreshOverflow(),h.refreshOverflow()):(o.createLeftToolbarControls(),o.defToolbarItems.length>0&&document.getElementById(r+"_toolbar")&&h.refreshOverflow()),document.getElementById(r+"_cropBtn")&&(0,g.isNullOrUndefined)(t)&&(g.Browser.isDevice||i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:o.getCropTextContent(document.getElementById(r+"_cropBtn")).toLowerCase(),startX:null,startY:null,width:null,height:null}}))}});g.Browser.isDevice?h.appendTo("#"+r+"_bottomToolbar"):h.appendTo("#"+r+"_toolbar");var d=i.element.querySelector("#"+r+"_straightenSlider");((0,g.isNullOrUndefined)(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Straightening")>-1)&&d&&d.parentElement.clientHeight>this.toolbarHeight&&(this.toolbarHeight=i.toolbarHeight=d.parentElement.clientHeight),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},e.prototype.getCropTextContent=function(e){if(e){var t={"e-custom":"Custom","e-circle":"Circle","e-square":"Square","e-custom-a":"3:2","e-custom-b":"4:3","e-custom-c":"5:4","e-custom-d":"7:5","e-custom-e":"16:9","e-custom-f":"2:3","e-custom-g":"3:4","e-custom-h":"4:5","e-custom-i":"5:7","e-custom-j":"9:16"},o=e.children[0].classList;for(var i in t)if(o.contains(i))return t[i]}return""},e.prototype.getCurrentShapeIcon=function(e){var t={rectangle:"e-rectangle",ellipse:"e-circle",line:"e-line",arrow:"e-arrow-right-up",path:"e-critical-path",text:"e-add-text",image:"e-image",pen:"e-free-pen","crop-custom":"e-custom","crop-circle":"e-circle","crop-square":"e-square","crop-3:2":"e-custom-a","crop-4:3":"e-custom-b","crop-5:4":"e-custom-c","crop-7:5":"e-custom-d","crop-16:9":"e-custom-e","crop-2:3":"e-custom-f","crop-3:4":"e-custom-g","crop-4:5":"e-custom-h","crop-5:7":"e-custom-i","crop-9:16":"e-custom-j"};return t[e]?t[e]:e&&-1!==e.indexOf("crop-")?"e-custom":"e-free-pen"},e.prototype.initShapesToolbarItem=function(e){var t=this,o=this.parent,i=o.element.id,r=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),n=this.getShapesToolbarItem(e),s=this.getZoomToolbarItem();g.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=r.concat(s,n,a);var l={toolbarType:o.activeObj.shape?o.activeObj.shape:"shapes",toolbarItems:this.defToolbarItems};o.trigger("toolbarUpdating",l),this.isToolbarString(l.toolbarItems)?(e=l.toolbarItems,this.excludeItems(l.toolbarItems)):this.defToolbarItems=l.toolbarItems;var p=new v.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.renderAnnotationBtn(!0),t.createRectangleRadius(e),t.createShapeColor(e),t.createShapeBtn(e),t.createZOrderBtn(e),"arrow"===o.activeObj.shape&&(e.some(function(e){return e.toLowerCase().indexOf("start")>-1})&&t.createStartBtn(),e.some(function(e){return e.toLowerCase().indexOf("end")>-1})&&t.createEndBtn()),t.wireZoomBtnEvents(),o.trigger("toolbarCreated",{toolbarType:"shapes"}),g.Browser.isDevice?t.defToolbarItems.length>0&&document.getElementById(i+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(t.createLeftToolbarControls(),t.defToolbarItems.length>0&&document.getElementById(i+"_toolbar")&&p.refreshOverflow())}});g.Browser.isDevice?p.appendTo("#"+i+"_bottomToolbar"):p.appendTo("#"+i+"_toolbar"),this.enableDisableTbrBtn()},e.prototype.createRectangleRadius=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("borderRadius")>-1){var r=[{id:"1",text:this.l10n.getConstant("0")},{id:"2",text:this.l10n.getConstant("20")},{id:"3",text:this.l10n.getConstant("40")},{id:"4",text:this.l10n.getConstant("60")},{id:"5",text:this.l10n.getConstant("80")},{id:"6",text:this.l10n.getConstant("100")}],a=document.getElementById(i+"_rectangleRadiusBtn"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant(o.frameObj.radius.toString()),n.className="e-shape-rectangle-radius",a.appendChild(n);var s=new x.DropDownButton({items:r,open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement;t.style.top=s.element.getBoundingClientRect().top-t.offsetHeight+"px"}var o=s.element.childNodes[0].textContent;""!==o&&e.element.querySelector('[aria-label = "'+o+'"]').classList.add("e-selected-btn")},select:function(e){(t.triggerTbarClickEvent(e),n.textContent=e.item.text,o.updateStrokeWidth(e.item.id,"radius"),g.Browser.isDevice)?document.getElementById(i+"_bottomToolbar")&&(0,g.getComponent)(i+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i+"_toolbar")&&(0,g.getComponent)(i+"_toolbar","toolbar").refreshOverflow();o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})}});s.appendTo("#"+i+"_rectangleRadiusBtn")}},e.prototype.beforeModeSwitch=function(e,t){this.popupLeft=e.element.offsetParent.style.left,"Picker"===e.mode?(t.showButtons=!0,t.dataBind(),e.element.querySelector(".e-apply").title=this.l10n.getConstant("Apply"),e.element.querySelector(".e-cancel").title=this.l10n.getConstant("Cancel"),e.element.querySelector(".e-mode-switch-btn").title=this.l10n.getConstant("StandardColors")):(t.showButtons=!1,t.dataBind(),e.element.querySelector(".e-mode-switch-btn").title=this.l10n.getConstant("MoreColors"))},e.prototype.createShapeColor=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("fillColor")>-1){o.element.querySelector(".e-template.e-fill").appendChild(o.createElement("input",{id:i+"_shape_fill"}));var r=new C.ColorPicker({modeSwitcher:!0,noColor:!0,value:"",inline:!0,showButtons:!1,mode:"Palette",cssClass:"e-shape-fill-color",beforeModeSwitch:function(e){return t.beforeModeSwitch(e,r)},presetColors:{custom:["","#f44336","#e91e63","#9c27b0","#673ab7","#2196f3","#03a9f4","#00bcd4","#009688","#ffeb3b","#ffffff","#ffebee","#fce4ec","#f3e5f5","#ede7f6","#e3f2fd","#e1f5fe","#e0f7fa","#e0f2f1","#fffde7","#f2f2f2","#ffcdd2","#f8bbd0","#e1bee7","#d1c4e9","#bbdefb","#b3e5fc","#b2ebf2","#b2dfdb","#fff9c4","#e6e6e6","#ef9a9a","#f48fb1","#ce93d8","#b39ddb","#90caf9","#81d4fa","#80deea","#80cbc4","#fff59d","#cccccc","#e57373","#f06292","#ba68c8","#9575cd","#64b5f6","#4fc3f7","#4dd0e1","#4db6ac","#fff176","#b3b3b3","#ef5350","#ec407a","#ab47bc","#7e57c2","#42a5f5","#29b6f6","#26c6da","#26a69a","#ffee58","#999999","#e53935","#d81b60","#8e24aa","#5e35b1","#1e88e5","#039be5","#00acc1","#00897b","#fdd835","#808080","#d32f2f","#c2185b","#7b1fa2","#512da8","#1976d2","#0288d1","#0097a7","#00796b","#fbc02d","#666666","#c62828","#ad1457","#6a1b9a","#4527a0","#1565c0","#0277bd","#00838f","#00695c","#f9a825","#4d4d4d","#b71c1c","#880e4f","#4a148c","#311b92","#0d47a1","#01579b","#006064","#004d40","#f57f17"]},beforeTileRender:function(e){""===e.value&&e.element.classList.add("e-nocolor-item")},change:function(e){o.updateFillColor(e.value),""===e.currentValue.rgba?a.element.children[0].classList.add("e-nocolor-item"):(a.element.children[0].classList.remove("e-nocolor-item"),a.element.children[0].style.backgroundColor=e.currentValue.rgba),a.toggle(),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})},onModeSwitch:function(e){g.Browser.isDevice&&(e.element.parentElement.parentElement.style.left=t.popupLeft,e.element.parentElement.parentElement.style.top=a.element.getBoundingClientRect().top-e.element.parentElement.parentElement.offsetHeight+"px")},beforeClose:function(){a.toggle()}},"#"+i+"_shape_fill"),a=new x.DropDownButton({open:function(e){var t=e.element.parentElement;g.Browser.isDevice&&(t.style.top=a.element.getBoundingClientRect().top-t.offsetHeight+"px",window.innerWidth<=520&&(t.style.left=o.element.offsetLeft+"px"))},target:".e-shape-fill-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_fillColorBtn");r.inline=!0,r.value=r.getValue(r.value,"rgba"),o.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item")}if(e.indexOf("strokeColor")>-1){o.element.querySelector(".e-template.e-stroke").appendChild(o.createElement("input",{id:i+"_shape_stroke"}));var n=new C.ColorPicker({modeSwitcher:!0,noColor:!1,value:"#fff",inline:!0,showButtons:!1,mode:"Palette",cssClass:"e-shape-stroke-color",beforeModeSwitch:function(e){t.popupLeft=e.element.offsetParent.style.left,n.value="#fff"!==o.activeObj.strokeSettings.strokeColor?o.activeObj.strokeSettings.strokeColor:"#008000ff",t.beforeModeSwitch(e,n)},presetColors:this.presetColors,change:function(e){o.updateStrokeColor(e.value),s.element.children[0].style.backgroundColor=e.currentValue.rgba,s.toggle(),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})},onModeSwitch:function(e){g.Browser.isDevice&&(e.element.parentElement.parentElement.style.left=t.popupLeft,e.element.parentElement.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.parentElement.offsetHeight+"px")},beforeClose:function(){s.toggle()}},"#"+i+"_shape_stroke"),s=new x.DropDownButton({open:function(e){var t=e.element.parentElement;g.Browser.isDevice&&(t.style.top=s.element.getBoundingClientRect().top-t.offsetHeight+"px",window.innerWidth<=520&&(t.style.left=o.element.offsetLeft+"px"))},target:".e-shape-stroke-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_borderColorBtn");n.inline=!0,n.value=n.getValue(n.value,"rgba"),o.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background="#fff"}},e.prototype.createShapeBtn=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("strokeWidth")>-1){var r=[{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")}];!o.activeObj.shape||"rectangle"!==o.activeObj.shape&&"ellipse"!==o.activeObj.shape||(r=[{id:"1",text:this.l10n.getConstant("NoOutline")},{id:"2",text:this.l10n.getConstant("XSmall")},{id:"3",text:this.l10n.getConstant("Small")},{id:"4",text:this.l10n.getConstant("Medium")},{id:"5",text:this.l10n.getConstant("Large")},{id:"6",text:this.l10n.getConstant("XLarge")}]);var a=document.getElementById(i+"_borderWidthBtn"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant("XSmall"),n.className="e-shape-stroke-width",a.appendChild(n);var s=new x.DropDownButton({items:r,open:function(e){g.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var t=n.innerHTML;""!==t&&e.element.querySelector('[aria-label = "'+t+'"]').classList.add("e-selected-btn")},select:function(e){(t.triggerTbarClickEvent(e),n.textContent=e.item.text,o.updateStrokeWidth(e.item.id,"width",o.activeObj.shape),g.Browser.isDevice)?document.getElementById(i+"_bottomToolbar")&&(0,g.getComponent)(i+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i+"_toolbar")&&(0,g.getComponent)(i+"_toolbar","toolbar").refreshOverflow();o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})}});s.appendTo("#"+i+"_borderWidthBtn")}},e.prototype.createZOrderBtn=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("z-order")>-1){var r=[{text:this.l10n.getConstant("BringForward"),id:"bringForward",iconCss:"e-icons e-bring-forward"},{text:this.l10n.getConstant("SendBackward"),id:"sendBackward",iconCss:"e-icons e-send-backward"},{text:this.l10n.getConstant("BringToFront"),id:"bringToFront",iconCss:"e-icons e-bring-to-front"},{text:this.l10n.getConstant("SendToBack"),id:"sendToBack",iconCss:"e-icons e-send-to-back"}],a=new x.DropDownButton({items:r,iconCss:"e-icons e-layers",beforeOpen:function(e){document.getElementById(o.element.id+"_zOrderBtn").classList.contains("e-disabled")&&(e.cancel=!0);var t={freehandSelectedIndex:-1};o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:t}});var i={order:null};o.notify("shape",{prop:"getHighestOrder",onPropertyChange:!1,value:{obj:i}});var r=o.activeObj.order?o.activeObj.order:o.getObjFromId(o.pointColl[t.freehandSelectedIndex].id).order;r&&r>=i.order?(e.items[0].disabled=!0,e.items[2].disabled=!0):(e.items[0].disabled=!1,e.items[2].disabled=!1),o.notify("shape",{prop:"getLowestOrder",onPropertyChange:!1,value:{obj:i}}),r&&r<=i.order?(e.items[1].disabled=!0,e.items[3].disabled=!0):(e.items[1].disabled=!1,e.items[3].disabled=!1)},open:function(e){g.Browser.isDevice&&(e.element.parentElement.style.top=a.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px")},select:function(e){t.triggerTbarClickEvent(e);var r={freehandDrawSelectedId:null};o.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:r}});var a=r.freehandDrawSelectedId?r.freehandDrawSelectedId:o.activeObj.currIndex;(o.updateShapeOrder(a,e.item.id),g.Browser.isDevice)?document.getElementById(i+"_bottomToolbar")&&(0,g.getComponent)(i+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i+"_toolbar")&&(0,g.getComponent)(i+"_toolbar","toolbar").refreshOverflow();a.indexOf("shape")>-1?o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1}):a.indexOf("pen")>-1&&o.notify("undo-redo",{prop:"updateUndoRedoStack",value:{isPenDraw:!0}})}});a.appendTo("#"+i+"_zOrderBtn")}},e.prototype.createStartBtn=function(){var e=this,t=this.parent,o=t.element.id,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")}],r=document.getElementById(o+"_startBtn"),a=document.createElement("span");(0,g.isNullOrUndefined)(t.activeObj.start)&&(t.activeObj.start="none"),a.innerHTML=t.pascalToSplitWords(t.activeObj.start),a.className="e-shape-start",r.appendChild(a);var n=new x.DropDownButton({items:i,open:function(e){g.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var t=a.innerHTML;""!==t&&e.element.querySelector('[aria-label = "'+t+'"]').classList.add("e-selected-btn")},select:function(o){t.notify("selection",{prop:"setArrowShape",value:{type:"initial",shape:{1:"none",2:"bar",3:"arrow",4:"arrowSolid",5:"circle",6:"circleSolid",7:"square",8:"squareSolid"}[""+o.item.id]}}),e.triggerTbarClickEvent(o),a.textContent=o.item.text,t.updateArrow("startArrow",o.item.id),t.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})}});n.appendTo("#"+o+"_startBtn")},e.prototype.createEndBtn=function(){var e=this,t=this.parent,o=t.element.id,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")}],r=document.getElementById(o+"_endBtn"),a=document.createElement("span");(0,g.isNullOrUndefined)(t.activeObj.end)&&(t.activeObj.end="arrowSolid"),a.innerHTML=t.pascalToSplitWords(t.activeObj.end),a.className="e-shape-end",r.appendChild(a);var n=new x.DropDownButton({items:i,open:function(e){g.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var t=a.innerHTML;""!==t&&e.element.querySelector('[aria-label = "'+t+'"]').classList.add("e-selected-btn")},select:function(o){t.notify("selection",{prop:"setArrowShape",value:{type:"final",shape:{1:"none",2:"bar",3:"arrow",4:"arrowSolid",5:"circle",6:"circleSolid",7:"square",8:"squareSolid"}[""+o.item.id]}}),e.triggerTbarClickEvent(o),a.textContent=o.item.text,t.updateArrow("endArrow",o.item.id),t.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})}});n.appendTo("#"+o+"_endBtn")},e.prototype.getTextToolbarItem=function(e){var t=this.parent,o=t.element.id,i=[];((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar)&&i.push({id:o+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+o+'_annotationBtn"></button>'}),e.indexOf("fontFamily")>-1&&i.push({id:o+"_fontFamily",cssClass:"top-icon e-img-font-family",tooltipText:this.l10n.getConstant("FontFamily"),align:"Center",template:'<button id="'+o+'_fontFamilyBtn"></button>'}),e.indexOf("fontSize")>-1&&i.push({id:o+"_fontSize",cssClass:"top-icon e-img-font-size",tooltipText:this.l10n.getConstant("FontSize"),align:"Center",template:'<button id="'+o+'_fontSizeBtn"></button>'}),e.indexOf("fontColor")>-1&&i.push({cssClass:"top-icon e-text-font-color",id:o+"_text_strokecolor",tooltipText:this.l10n.getConstant("FontColor"),align:"Center",type:"Input",template:'<button id="'+o+'_fontColorBtn"></button>'}),e.indexOf("strokeColor")>-1&&i.push({cssClass:"top-icon e-stroke-text-font-color",id:o+"_stroke_text_color",tooltipText:this.l10n.getConstant("TextOutlineColor"),align:"Center",type:"Input",template:'<button id="'+o+'_strokeTextColorBtn"></button>'}),e.indexOf("fillColor")>-1&&i.push({cssClass:"top-icon e-text-background-color",id:o+"_text_backgroundcolor",tooltipText:this.l10n.getConstant("FillColor"),align:"Center",type:"Input",template:'<button id="'+o+'_bgColorBtn"></button>'}),e.indexOf("bold")>-1&&i.push({id:o+"_bold",prefixIcon:"e-icons e-bold",cssClass:"top-icon e-bold",tooltipText:this.l10n.getConstant("Bold"),align:"Center"}),e.indexOf("italic")>-1&&i.push({id:o+"_italic",prefixIcon:"e-icons e-italic",cssClass:"top-icon e-italic",tooltipText:this.l10n.getConstant("Italic"),align:"Center"}),e.indexOf("underline")>-1&&i.push({id:o+"_underline",prefixIcon:"e-icons e-underline",cssClass:"top-icon e-underline",tooltipText:this.l10n.getConstant("Underline"),align:"Center"}),e.indexOf("strikethrough")>-1&&i.push({id:o+"_strikethrough",prefixIcon:"e-icons e-strikethrough",cssClass:"top-icon e-strikethrough",tooltipText:this.l10n.getConstant("Strikethrough"),align:"Center"}),e.indexOf("strokeWidth")>-1&&i.push({id:o+"_strokeWidth",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("TextOutlineWidth"),align:"Center",type:"Input",template:'<button id="'+o+'_borderWidthBtn"></button>'}),e.indexOf("transparency")>-1&&i.push({id:o+"_transparency",prefixIcon:"e-opacity",tooltipText:this.l10n.getConstant("Opacity"),align:"Center"}),i.push({align:"Center",type:"Separator"}),e.indexOf("z-order")>-1&&i.push({id:o+"_zOrder",cssClass:"top-icon e-list-unordered-3",tooltipText:this.l10n.getConstant("ZOrder"),align:"Center",type:"Input",template:'<button id="'+o+'_zOrderBtn"></button>'}),e.indexOf("duplicate")>-1&&i.push({id:o+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center",disabled:"block"===t.textArea.style.display||"inline-block"===t.textArea.style.display}),e.indexOf("remove")>-1&&i.push({id:o+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center",disabled:"block"===t.textArea.style.display||"inline-block"===t.textArea.style.display}),e.indexOf("text")>-1&&i.push({id:o+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center",disabled:"block"===t.textArea.style.display||"inline-block"===t.textArea.style.display});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)i.push(r[a]);return g.Browser.isDevice||(i.push({id:o+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),i.push({id:o+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},e.prototype.getFontFamilyItems=function(){var e=this.parent;return e.fontFamily&&e.fontFamily.items&&e.fontFamily.items.length>0?e.fontFamily.items:g.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"}]},e.prototype.initTextToolbarItem=function(e){var t=this,o=this.parent,i=o.element.id,r=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),n=this.getTextToolbarItem(e),s=this.getZoomToolbarItem();g.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=r.concat(s,n,a);var l={toolbarType:"text",toolbarItems:this.defToolbarItems};o.trigger("toolbarUpdating",l),this.isToolbarString(l.toolbarItems)?(e=l.toolbarItems,this.excludeItems(l.toolbarItems)):this.defToolbarItems=l.toolbarItems;var p=new v.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.renderAnnotationBtn(!0),t.createTextColor(e),t.createStrokeTextColor(e),t.createShapeBtn(e),t.createBackgroundColor(e),t.createTextBtn(e),t.createZOrderBtn(e),t.wireZoomBtnEvents(),o.trigger("toolbarCreated",{toolbarType:"text"}),g.Browser.isDevice?t.defToolbarItems.length>0&&document.getElementById(i+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(t.createLeftToolbarControls(),t.defToolbarItems.length>0&&document.getElementById(i+"_toolbar")&&p.refreshOverflow())}});g.Browser.isDevice?p.appendTo("#"+i+"_bottomToolbar"):p.appendTo("#"+i+"_toolbar"),this.enableDisableTbrBtn()},e.prototype.createTextColor=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("fontColor")>-1&&o.element.querySelector(".e-template.e-text-font-color")){o.element.querySelector(".e-template.e-text-font-color").appendChild(o.createElement("input",{id:i+"_text_font"}));var r=new C.ColorPicker({modeSwitcher:!0,noColor:!1,value:"#fff",inline:!0,showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",beforeModeSwitch:function(e){t.popupLeft=e.element.offsetParent.style.left,r.value="#fff"!==o.activeObj.strokeSettings.strokeColor?o.activeObj.strokeSettings.strokeColor:"#008000ff",t.beforeModeSwitch(e,r)},presetColors:this.presetColors,change:function(e){o.updateFontColor(e.value,"Text"),a.element.children[0].style.backgroundColor=e.currentValue.rgba,a.toggle(),0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height||o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})},onModeSwitch:function(e){g.Browser.isDevice&&(e.element.parentElement.parentElement.style.left=t.popupLeft,e.element.parentElement.parentElement.style.top=a.element.getBoundingClientRect().top-e.element.parentElement.parentElement.offsetHeight+"px")},beforeClose:function(){a.toggle()}},"#"+i+"_text_font"),a=new x.DropDownButton({open:function(e){var t=e.element.parentElement;g.Browser.isDevice&&(t.style.top=a.element.getBoundingClientRect().top-t.offsetHeight+"px",window.innerWidth<=520&&(t.style.left=o.element.offsetLeft+"px"))},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_fontColorBtn");r.inline=!0,r.value=r.getValue(r.value,"rgba"),o.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},e.prototype.createBackgroundColor=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("fillColor")>-1&&o.element.querySelector(".e-template.e-text-background-color")){o.element.querySelector(".e-template.e-text-background-color").appendChild(o.createElement("input",{id:i+"_text_bgColor"}));var r=new C.ColorPicker({modeSwitcher:!0,noColor:!0,value:"",inline:!0,showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",beforeModeSwitch:function(e){t.popupLeft=e.element.offsetParent.style.left,t.beforeModeSwitch(e,r)},presetColors:{custom:["","#f44336","#e91e63","#9c27b0","#673ab7","#2196f3","#03a9f4","#00bcd4","#009688","#ffeb3b","#ffffff","#ffebee","#fce4ec","#f3e5f5","#ede7f6","#e3f2fd","#e1f5fe","#e0f7fa","#e0f2f1","#fffde7","#f2f2f2","#ffcdd2","#f8bbd0","#e1bee7","#d1c4e9","#bbdefb","#b3e5fc","#b2ebf2","#b2dfdb","#fff9c4","#e6e6e6","#ef9a9a","#f48fb1","#ce93d8","#b39ddb","#90caf9","#81d4fa","#80deea","#80cbc4","#fff59d","#cccccc","#e57373","#f06292","#ba68c8","#9575cd","#64b5f6","#4fc3f7","#4dd0e1","#4db6ac","#fff176","#b3b3b3","#ef5350","#ec407a","#ab47bc","#7e57c2","#42a5f5","#29b6f6","#26c6da","#26a69a","#ffee58","#999999","#e53935","#d81b60","#8e24aa","#5e35b1","#1e88e5","#039be5","#00acc1","#00897b","#fdd835","#808080","#d32f2f","#c2185b","#7b1fa2","#512da8","#1976d2","#0288d1","#0097a7","#00796b","#fbc02d","#666666","#c62828","#ad1457","#6a1b9a","#4527a0","#1565c0","#0277bd","#00838f","#00695c","#f9a825","#4d4d4d","#b71c1c","#880e4f","#4a148c","#311b92","#0d47a1","#01579b","#006064","#004d40","#f57f17"]},beforeTileRender:function(e){""===e.value&&e.element.classList.add("e-nocolor-item")},change:function(e){o.updateFontColor(e.value,"Background"),""===e.currentValue.rgba?a.element.children[0].classList.add("e-nocolor-item"):(a.element.children[0].classList.remove("e-nocolor-item"),a.element.children[0].style.backgroundColor=e.currentValue.rgba),a.toggle(),0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height||o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})},onModeSwitch:function(e){g.Browser.isDevice&&(e.element.parentElement.parentElement.style.left=t.popupLeft,e.element.parentElement.parentElement.style.top=a.element.getBoundingClientRect().top-e.element.parentElement.parentElement.offsetHeight+"px")},beforeClose:function(){a.toggle()}},"#"+i+"_text_bgColor"),a=new x.DropDownButton({open:function(e){var t=e.element.parentElement;g.Browser.isDevice&&(t.style.top=a.element.getBoundingClientRect().top-t.offsetHeight+"px",window.innerWidth<=520&&(t.style.left=o.element.offsetLeft+"px"))},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_bgColorBtn");r.inline=!0,r.value=r.getValue(r.value,"rgba"),o.element.querySelector(".e-text-background-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},e.prototype.createStrokeTextColor=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("strokeColor")>-1&&o.element.querySelector(".e-template.e-stroke-text-font-color")){o.element.querySelector(".e-template.e-stroke-text-font-color").appendChild(o.createElement("input",{id:i+"_stroke_text"}));var r=new C.ColorPicker({modeSwitcher:!0,noColor:!0,value:"",inline:!0,showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",beforeModeSwitch:function(e){t.popupLeft=e.element.offsetParent.style.left,t.beforeModeSwitch(e,r)},presetColors:{custom:["","#f44336","#e91e63","#9c27b0","#673ab7","#2196f3","#03a9f4","#00bcd4","#009688","#ffeb3b","#ffffff","#ffebee","#fce4ec","#f3e5f5","#ede7f6","#e3f2fd","#e1f5fe","#e0f7fa","#e0f2f1","#fffde7","#f2f2f2","#ffcdd2","#f8bbd0","#e1bee7","#d1c4e9","#bbdefb","#b3e5fc","#b2ebf2","#b2dfdb","#fff9c4","#e6e6e6","#ef9a9a","#f48fb1","#ce93d8","#b39ddb","#90caf9","#81d4fa","#80deea","#80cbc4","#fff59d","#cccccc","#e57373","#f06292","#ba68c8","#9575cd","#64b5f6","#4fc3f7","#4dd0e1","#4db6ac","#fff176","#b3b3b3","#ef5350","#ec407a","#ab47bc","#7e57c2","#42a5f5","#29b6f6","#26c6da","#26a69a","#ffee58","#999999","#e53935","#d81b60","#8e24aa","#5e35b1","#1e88e5","#039be5","#00acc1","#00897b","#fdd835","#808080","#d32f2f","#c2185b","#7b1fa2","#512da8","#1976d2","#0288d1","#0097a7","#00796b","#fbc02d","#666666","#c62828","#ad1457","#6a1b9a","#4527a0","#1565c0","#0277bd","#00838f","#00695c","#f9a825","#4d4d4d","#b71c1c","#880e4f","#4a148c","#311b92","#0d47a1","#01579b","#006064","#004d40","#f57f17"]},beforeTileRender:function(e){""===e.value&&e.element.classList.add("e-nocolor-item")},change:function(e){o.updateStrokeTextColor(e.value),""===e.currentValue.rgba?a.element.children[0].classList.add("e-nocolor-item"):(a.element.children[0].classList.remove("e-nocolor-item"),a.element.children[0].style.backgroundColor=e.currentValue.rgba),a.toggle(),0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height||o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})},onModeSwitch:function(e){g.Browser.isDevice&&(e.element.parentElement.parentElement.style.left=t.popupLeft,e.element.parentElement.parentElement.style.top=a.element.getBoundingClientRect().top-e.element.parentElement.parentElement.offsetHeight+"px")},beforeClose:function(){a.toggle()}},"#"+i+"_stroke_text"),a=new x.DropDownButton({open:function(e){var t=e.element.parentElement;g.Browser.isDevice&&(t.style.top=a.element.getBoundingClientRect().top-t.offsetHeight+"px",window.innerWidth<=520&&(t.style.left=o.element.offsetLeft+"px"))},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_strokeTextColorBtn");r.inline=!0,r.value=r.getValue(r.value,"rgba"),o.element.querySelector(".e-stroke-text-font-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},e.prototype.createTextBtn=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("fontFamily")>-1){var r=document.getElementById(i+"_fontFamilyBtn"),a=document.createElement("span");g.Browser.isDevice?(a.innerHTML="ABC",a.setAttribute("style","font-family: "+o.fontFamily.default.toLowerCase()+"'")):a.innerHTML=o.fontFamily.default,a.className="e-text-font-family",r&&r.appendChild(a);var n=new x.DropDownButton({items:this.getFontFamilyItems(),cssClass:"e-font-family",createPopupOnClick:!0,beforeItemRender:function(e){e.element.setAttribute("style","font-family:"+e.element.id)},open:function(e){var t;g.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px"),t="block"===o.textArea.style.display||"inline-block"===o.textArea.style.display?o.textArea.style.fontFamily:o.activeObj.textSettings.fontFamily;var i=e.element.querySelector('[id *= "'+t.toLowerCase()+'"]');i&&i.classList.add("e-selected-btn")},select:function(e){t.triggerTbarClickEvent(e),a.textContent=e.item.text,g.Browser.isDevice&&a.setAttribute("style","font-family:"+e.item.id),o.updateFontFamily(e.item.id),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1});var i=document.getElementById(o.element.id+"_toolbar");i&&i.classList.contains("e-control")&&(0,g.getComponent)(i,"toolbar").refreshOverflow()}});n.appendTo("#"+i+"_fontFamilyBtn")}if(e.indexOf("fontSize")>-1){var s=document.getElementById(i+"_fontSizeBtn"),l=document.createElement("span"),p=o.getFontSizes();l.innerHTML=p[0].text,l.className="e-text-font-size",s.appendChild(l);var h=new x.DropDownButton({cssClass:"e-font-size",items:p,open:function(e){g.Browser.isDevice&&(e.element.parentElement.style.top=h.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var t=l.innerHTML;e.element.querySelector('[aria-label *= "'+t+'"]').classList.add("e-selected-btn")},select:function(e){t.triggerTbarClickEvent(e),l.textContent=e.item.text,o.updateFontSize(e.item.text),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})}});h.appendTo("#"+i+"_fontSizeBtn")}},e.prototype.refreshToolbar=function(e,t,o,i,r,a,n){var s=this.parent,l=s.element.id;if(s.isImageLoaded&&!s.isCropToolbar){var p,h,d={};if("filter"!==e&&"color"!==e){var c=document.getElementById(l+"_toolbar"),u=document.getElementById(l+"_customizeWrapper"),v=document.getElementById(l+"_bottomToolbar");if(u&&(0,g.getComponent)(u,"toolbar")&&this.defToolbarItems.length>0&&((0,g.getComponent)(u,"toolbar").destroy(),u.innerHTML=""),c&&c.classList.contains("e-control")&&this.defToolbarItems.length>0&&((0,g.getComponent)(c,"toolbar").destroy(),c.innerHTML=""),c&&(this.defToolbarItems.length>0||s.toolbar&&s.toolbar.length>0&&-1===s.toolbar.indexOf("Open"))){var f=(0,g.getComponent)(c,"toolbar");(0,g.isNullOrUndefined)(f)||(f.destroy(),document.getElementById(s.element.id+"_toolbar").innerHTML="")}v&&this.defToolbarItems.length>0&&v.className.indexOf("e-control")>-1&&((0,g.getComponent)(v,"toolbar").destroy(),v.innerHTML="")}switch(this.refreshSlider(),document.querySelector(".e-slider-tooltip")&&document.querySelector(".e-slider-tooltip").remove(),this.isFrameToolbar=s.isCropTab=!1,e){case"main":g.Browser.isDevice?o?this.initMainToolbar(!1,!0,!0,!1,!1,!0):this.initMainToolbar(!1,!0,null,!1,!1,!0):g.Browser.isDevice&&!i||this.initMainToolbar(t,g.Browser.isDevice,null),g.Browser.isDevice&&this.initBottomToolbar();break;case"shapes":if(s.isPublicMethod||(s.noPushUndo=!0),g.Browser.isDevice){this.initMainToolbar(!1,!0,!0);var m=document.getElementById(s.element.id+"_ok"),b={shape:""};s.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:b}}),"path"===b.shape&&m&&m.parentElement.classList.add("e-overlay")}if("line"===s.activeObj.shape||"path"===s.activeObj.shape?d.toolbarItems=["strokeColor","strokeWidth","z-order","duplicate","remove"]:"arrow"===s.activeObj.shape?d.toolbarItems=["strokeColor","strokeWidth","start","end","z-order","duplicate","remove"]:"image"===s.activeObj.shape?d.toolbarItems=["flip","z-order","duplicate","remove","transparency"]:"rectangle"===s.activeObj.shape?d.toolbarItems=["fillColor","strokeColor","strokeWidth","borderRadius","z-order","duplicate","remove"]:d.toolbarItems=["fillColor","strokeColor","strokeWidth","z-order","duplicate","remove"],this.initShapesToolbarItem(d.toolbarItems),"image"===s.activeObj.shape){var C=(0,g.extend)({},s.activeObj,{},!0);s.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),s.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),s.activeObj=C,s.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:s.activeObj,isCropRatio:null,points:null,isPreventDrag:!0}}),this.renderQAT(!1)}break;case"text":g.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),d.toolbarItems=["fontFamily","fontSize","fontColor","fillColor","strokeColor","strokeWidth","bold","italic","underline","strikethrough","z-order","duplicate","remove","text"],this.initTextToolbarItem(d.toolbarItems);break;case"pen":g.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),d.toolbarItems=["strokeColor","strokeWidth","z-order","remove","transparency"],this.initPenToolbarItem(d.toolbarItems);break;case"adjustment":g.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),this.initAdjustmentToolbarItem();break;case"filter":this.updateContextualToolbar(e);break;case"resize":(s.isCircleCrop||s.currSelectionPoint&&"crop-circle"===s.currSelectionPoint.shape)&&(s.aspectHeight=s.aspectWidth,this.isAspectRatio=!1),this.initResizeToolbar(),g.Browser.isDevice&&this.initMainToolbar(!1,!0,!0,!0),p=s.element.querySelector("#"+l+"_aspectratio"),h=s.element.querySelector("#"+l+"_nonaspectratio"),s.aspectWidth&&s.aspectHeight&&(h?s.notify("transform",{prop:"resize",value:{width:s.aspectWidth,height:s.aspectHeight,isAspectRatio:!1}}):p&&s.notify("transform",{prop:"resize",value:{width:s.aspectWidth,height:null,isAspectRatio:!0}}));break;case"color":this.updateContextualToolbar(e,r);break;case"croptransform":(0,g.isNullOrUndefined)(n)&&(s.allowDownScale=!1,s.isCropTab=!0),g.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),(0,g.isNullOrUndefined)(n)&&s.updateCropTransformItems(),this.initCropTransformToolbar(a,n),g.Browser.isDevice&&this.isToolbar()&&this.updateContextualToolbar("color","straighten",!0),s.isMaskImage&&this.refreshToolbar("main");break;case"frame":this.isFrameToolbar=!0,g.Browser.isDevice?(this.initMainToolbar(!1,!0,!0),this.initMainToolbar(!1,!0,!0,!1,!0)):this.initMainToolbar(!0,null,null,!1,!0);var y=s.element.querySelector("#"+l+"_"+s.frameObj.type);y&&y.classList.add("e-selected-btn"),"none"!==s.frameObj.type&&this.updateContextualToolbar(e,r),s.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}});break;case"redact":if(g.Browser.isDevice?(this.initMainToolbar(!1,!0,!0),this.initMainToolbar(!1,!0,!0,null,null,null,!0)):this.initMainToolbar(t,g.Browser.isDevice,null,null,null,null,!0),this.enableDisableTbrBtn(),"blur"===s.activeObj.redactType){var x=s.element.querySelector("#"+l+"_redactBlur");x&&x.classList.add("e-selected-btn")}else{var P=s.element.querySelector("#"+l+"_pixelate");P&&P.classList.add("e-selected-btn")}this.redactSlider(s.activeObj.redactType)}this.refreshDropDownBtn(o),this.updateKBDNavigation(e),this.currToolbar=e}},e.prototype.updateRedactObj=function(){var e=this.parent,t=(0,g.extend)([],e.objColl,[],!0);e.objColl=[];var o=(0,g.extend)({},e.activeObj,{},!0);e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),e.objColl=t;for(var i=0;i<e.objColl.length;i++){var r=e.objColl[i];"redact"===r.shape&&(r.redactImage=e.createElement("canvas"),r.redactImage.width=r.activePoint.width,r.redactImage.height=r.activePoint.height,r.redactImage.getContext("2d").drawImage(e.lowerCanvas,r.activePoint.startX,r.activePoint.startY,r.activePoint.width,r.activePoint.height,0,0,r.redactImage.width,r.redactImage.height))}e.isCropTab=!1,e.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),e.isCropTab=!0,o&&e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o,isCropRatio:null,points:null,isPreventDrag:!0}});var a={panMove:null};if(e.notify("transform",{prop:"getPanMove",onPropertyChange:!1,value:{obj:a}}),a.panMove){var n=(0,g.extend)({},e.panPoint.currentPannedPoint,{},!0);e.panPoint.currentPannedPoint={x:e.panPoint.totalPannedClientPoint.x,y:e.panPoint.totalPannedClientPoint.y},e.panPoint.totalPannedClientPoint={x:0,y:0},e.panPoint.totalPannedInternalPoint={x:0,y:0},e.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:e.panPoint.currentPannedPoint.x,yDiff:e.panPoint.currentPannedPoint.y}}),e.panPoint.currentPannedPoint=n}},e.prototype.updateKBDNavigation=function(e){var t=this.parent,o=t.element.id;if(t.isKBDNavigation&&this.currToolbar!==e&&this.isToolbar()){var i,r=t.element.querySelectorAll("#"+o+"_toolbar")[0],a=void 0;if(r){if(!(a=r.querySelector(".e-toolbar-center"))||!a.children[0])return;i=a.children[0].querySelector(".e-btn");var n=a.children[1];if(n&&(n=n.children[0]),n&&(n=n.children[0]),"resize"===e&&n&&(i=n),"filter"===e){var s=document.querySelector("#"+o+"_defaultCanvas");s&&setTimeout(function(){return s.focus()},50)}i&&("main"===e?setTimeout(function(){return i.focus()},50):i.focus())}}},e.prototype.performCropTransformClick=function(e,t){var o=this.parent;(0,g.isNullOrUndefined)(t)&&(o.notify("draw",{prop:"setTempStraightenZoomDeg"}),o.tempStraighten=o.transform.straighten,(o.currObjType.isFiltered||o.currObjType.isRedact)&&o.okBtn(),o.isStraightening=!0),this.refreshToolbar("croptransform",null,null,null,null,e,t),(0,g.isNullOrUndefined)(t)&&(o.notify("draw",{prop:"setDestForStraighten"}),o.notify("draw",{prop:"setTempDestForStraighten"}))},e.prototype.getAdjustmentToolbarItem=function(){var e=[],t=this.parent,o=!1,i=t.element.id,r=["Brightness","Contrast","Hue","Saturation","Exposure","Opacity","Blur"];if(t.toolbar)for(var a=0;a<r.length;a++)if(-1!==t.toolbar.indexOf(r[a])){o=!0;break}((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Brightness")>-1)&&e.push({id:i+"_brightness",prefixIcon:"e-icons e-brightness",cssClass:"top-icon e-brightness",tooltipText:this.l10n.getConstant("Brightness"),align:"Center"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Contrast")>-1)&&e.push({id:i+"_contrast",prefixIcon:"e-icons e-contrast",cssClass:"top-icon e-contrast",tooltipText:this.l10n.getConstant("Contrast"),align:"Center"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Hue")>-1)&&e.push({id:i+"_hue",prefixIcon:"e-icons e-fade",cssClass:"top-icon e-fade",tooltipText:this.l10n.getConstant("Hue"),align:"Center"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Saturation")>-1)&&e.push({id:i+"_saturation",prefixIcon:"e-icons e-saturation",cssClass:"top-icon e-saturation",tooltipText:this.l10n.getConstant("Saturation"),align:"Center"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Exposure")>-1)&&e.push({id:i+"_exposure",prefixIcon:"e-icons e-grain",cssClass:"top-icon e-grain",tooltipText:this.l10n.getConstant("Exposure"),align:"Center"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Opacity")>-1)&&e.push({id:i+"_opacity",prefixIcon:"e-icons e-opacity",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Opacity"),align:"Center"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Blur")>-1)&&e.push({id:i+"_blur",prefixIcon:"e-icons e-tint",cssClass:"top-icon e-tint",tooltipText:this.l10n.getConstant("Blur"),align:"Center"});for(var n=this.processToolbar("center"),s=(a=0,n.length);a<s;a++)e.push(n[a]);return g.Browser.isDevice||(e.push({id:i+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),e.push({id:i+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),e},e.prototype.getFrameToolbarItem=function(){var e=this.parent,t=e.element.id,o=[];return o.push({prefixIcon:"e-icons e-copy",id:t+"_frameColor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("Color"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Color")+'</span><button id="'+t+'_frameColorBtn"></button>'}),o.push({prefixIcon:"e-icons e-copy",id:t+"_frameGradient",cssClass:"top-icon e-frame-stroke",tooltipText:this.l10n.getConstant("GradientColor"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("GradientColor")+'</span><button id="'+t+'_frameGradientColorBtn"></button>'}),o.push({id:t+"_frameSize",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Size"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Size")+'</span><button id="'+t+'_frameSizeBtn"></button>'}),"line"!==e.frameObj.type&&"inset"!==e.frameObj.type&&"hook"!==e.frameObj.type||o.push({id:t+"_frameInset",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Inset"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Inset")+'</span><button id="'+t+'_frameInsetBtn"></button>'}),"line"!==e.frameObj.type&&"inset"!==e.frameObj.type||o.push({id:t+"_frameOffset",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Offset"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Offset")+'</span><button id="'+t+'_frameOffsetBtn"></button>'}),"line"===e.frameObj.type&&(o.push({id:t+"_frameRadius",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Radius"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Radius")+'</span><button id="'+t+'_frameRadiusBtn"></button>'}),o.push({id:t+"_frameAmount",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Amount"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Amount")+'</span><button id="'+t+'_frameAmountBtn"></button>'}),o.push({id:t+"_frameBorder",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Border"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Border")+'</span><button id="'+t+'_frameBorderBtn"></button>'})),o},e.prototype.getFilterToolbarItem=function(){var e=[],t=this.parent,o=!1,i=t.element.id,r=["Default","Chrome","Cold","Warm","Grayscale","Sepia","Invert"];if(t.toolbar)for(var a=0;a<r.length;a++)if(-1!==t.toolbar.indexOf(r[a])){o=!0;break}((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Default")>-1)&&e.push({id:i+"_default",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Default"),align:"Center",template:'<div class="filter-wrapper"><canvas id='+i+"_defaultCanvas tabindex=0></canvas><div><span>"+this.l10n.getConstant("Default")+"</span></div></div>"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Chrome")>-1)&&e.push({id:i+"_chrome",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Chrome"),align:"Center",template:'<div class="filter-wrapper"><canvas id='+i+"_chromeCanvas></canvas><div><span>"+this.l10n.getConstant("Chrome")+"</span></div></div>"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Cold")>-1)&&e.push({id:i+"_cold",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Cold"),align:"Center",template:'<div class="filter-wrapper"><canvas id='+i+"_coldCanvas></canvas><div><span>"+this.l10n.getConstant("Cold")+"</span></div></div>"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Warm")>-1)&&e.push({id:i+"_warm",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Warm"),align:"Center",template:'<div class="filter-wrapper"><canvas id='+i+"_warmCanvas></canvas><div><span>"+this.l10n.getConstant("Warm")+"</span></div></div>"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Grayscale")>-1)&&e.push({id:i+"_grayscale",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Grayscale"),align:"Center",template:'<div class="filter-wrapper"><canvas id='+i+"_grayscaleCanvas></canvas><div><span>"+this.l10n.getConstant("Grayscale")+"</span></div></div>"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Sepia")>-1)&&e.push({id:i+"_sepia",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Sepia"),align:"Center",template:'<div class="filter-wrapper"><canvas id='+i+"_sepiaCanvas></canvas><div><span>"+this.l10n.getConstant("Sepia")+"</span></div></div>"}),((0,g.isNullOrUndefined)(t.toolbar)||!o||t.toolbar&&t.toolbar.indexOf("Invert")>-1)&&e.push({id:i+"_invert",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Invert"),align:"Center",template:'<div class="filter-wrapper"><canvas id='+i+"_invertCanvas></canvas><div><span>"+this.l10n.getConstant("Invert")+"</span></div></div>"});for(var n=this.processToolbar("center"),s=(a=0,n.length);a<s;a++)e.push(n[a]);return e},e.prototype.getPenToolbarItem=function(e){var t=this.parent,o=t.element.id,i=[];((0,g.isNullOrUndefined)(t.toolbar)||t.toolbar)&&i.push({id:o+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+o+'_annotationBtn"></button>'}),e.indexOf("strokeColor")>-1&&i.push({prefixIcon:"e-icons e-copy",id:o+"_pen_strokecolor",cssClass:"top-icon e-pen-stroke-color",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+o+'_penColorBtn"></button>'}),e.indexOf("strokeWidth")>-1&&i.push({prefixIcon:"e-icons e-copy",id:o+"_pen_strokewidth",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("StrokeWidth"),align:"Center",type:"Input",template:'<button id="'+o+'_penStrokeWidth"></button>'}),i.push({align:"Center",type:"Separator"}),e.indexOf("z-order")>-1&&i.push({id:o+"_zOrder",cssClass:"top-icon e-list-unordered-3",tooltipText:this.l10n.getConstant("ZOrder"),align:"Center",type:"Input",template:'<button id="'+o+'_zOrderBtn"></button>'}),e.indexOf("remove")>-1&&i.push({id:o+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)i.push(r[a]);return g.Browser.isDevice||(i.push({id:o+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right",tabIndex:0}),i.push({id:o+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},e.prototype.initPenToolbarItem=function(e){var t=this,o=this.parent,i=o.element.id,r=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),n=this.getPenToolbarItem(e),s=this.getZoomToolbarItem();g.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=r.concat(s,n,a);var l={toolbarType:"pen",toolbarItems:this.defToolbarItems};o.trigger("toolbarUpdating",l),this.isToolbarString(l.toolbarItems)?(e=l.toolbarItems,this.excludeItems(l.toolbarItems)):this.defToolbarItems=l.toolbarItems;var p=new v.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.renderAnnotationBtn(!0),t.createPenColor(e),t.createPenBtn(e),t.createZOrderBtn(e),t.wireZoomBtnEvents(),o.trigger("toolbarCreated",{toolbarType:"pen"}),g.Browser.isDevice?t.defToolbarItems.length>0&&document.getElementById(i+"_toolbar")&&(p.refreshOverflow(),p.refreshOverflow()):(t.createLeftToolbarControls(),t.defToolbarItems.length>0&&document.getElementById(i+"_toolbar")&&p.refreshOverflow())}});g.Browser.isDevice?p.appendTo("#"+i+"_bottomToolbar"):p.appendTo("#"+i+"_toolbar"),this.enableDisableTbrBtn()},e.prototype.createPenColor=function(e){var t=this,o=this.parent,i=o.element.id;if(e.indexOf("strokeColor")>-1){o.element.querySelector(".e-template.e-pen-stroke-color").appendChild(o.createElement("input",{id:i+"_pen_stroke"}));var r=o.activeObj.strokeSettings.strokeColor,a=new C.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-pen-color",change:function(e){o.updatePenStrokeColor(e.currentValue.hex),t.selFhdColor=e.currentValue.hex,n.element.children[0].style.backgroundColor=e.currentValue.rgba,n.toggle(),o.notify("undo-redo",{prop:"updateUndoRedoStack",value:{isPenDraw:!0}})}},"#"+i+"_pen_stroke"),n=new x.DropDownButton({open:function(e){var t=e.element.parentElement;g.Browser.isDevice&&(t.style.top=n.element.getBoundingClientRect().top-t.offsetHeight+"px",window.innerWidth<=520&&(t.style.left=o.element.offsetLeft+"px"))},target:".e-pen-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_penColorBtn");a.inline=!0,a.value=a.getValue(o.activeObj.strokeSettings.strokeColor,"rgba"),"null"===a.value&&(a.value=r);var s={tempFreeHandDrawEditingStyles:null};o.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:s}});var l={freehandSelectedIndex:null};o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:l}}),!(0,g.isNullOrUndefined)(l.freehandSelectedIndex)&&l.freehandSelectedIndex>-1?o.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#42a5f5"===this.selFhdColor?s.tempFreeHandDrawEditingStyles.strokeColor:o.pointColl[l.freehandSelectedIndex].strokeColor:o.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background=a.value}},e.prototype.createPenBtn=function(e){var t=this,o=this.parent,i=o.element.id,r=[{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(e.indexOf("strokeWidth")>-1){var a=document.getElementById(i+"_penStrokeWidth"),n=document.createElement("span"),s={freehandSelectedIndex:null};if(o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:s}}),!(0,g.isNullOrUndefined)(s.freehandSelectedIndex)&&s.freehandSelectedIndex>-1)n.innerHTML=this.getPenStroke(o.pointColl[s.freehandSelectedIndex].strokeWidth);else{var l={penStrokeWidth:2};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:l}}),n.innerHTML=l.penStrokeWidth?this.getPenStroke(l.penStrokeWidth):this.l10n.getConstant("Small")}n.className="e-pen-stroke-width",a.appendChild(n);var p=new x.DropDownButton({items:r,open:function(e){g.Browser.isDevice&&(e.element.parentElement.style.top=p.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var t=n.innerHTML;e.element.querySelector('[aria-label = "'+t+'"]').classList.add("e-selected-btn")},select:function(e){(t.triggerTbarClickEvent(e),n.textContent=e.item.text,o.updatePenStrokeWidth(e.item.id),g.Browser.isDevice)?document.getElementById(i+"_bottomToolbar")&&(0,g.getComponent)(i+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(i+"_toolbar")&&(0,g.getComponent)(i+"_toolbar","toolbar").refreshOverflow();var r={penStrokeWidth:null};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:r}}),o.notify("undo-redo",{prop:"updateUndoRedoStack",value:{isPenDraw:!0}}),o.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:r.penStrokeWidth}})}});p.appendTo("#"+i+"_penStrokeWidth")}},e.prototype.getPenStroke=function(e){var t="",o={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 e>=1&&e<=5&&(t=o[e]),t},e.prototype.initAdjustmentToolbarItem=function(){var e=this,t=this.parent,o=t.element.id,i=this.getLeftToolbarItem(null),r=this.getRightToolbarItem(),a=this.getAdjustmentToolbarItem(),n=this.getZoomToolbarItem();g.Browser.isDevice?this.defToolbarItems=a:this.defToolbarItems=i.concat(n,a,r);var s={toolbarType:"finetune",toolbarItems:this.defToolbarItems};t.trigger("toolbarUpdating",s),this.defToolbarItems=s.toolbarItems;var l=new v.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.wireZoomBtnEvents(),g.Browser.isDevice||e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(o+"_toolbar")&&l.refreshOverflow()}});g.Browser.isDevice?l.appendTo("#"+o+"_bottomToolbar"):l.appendTo("#"+o+"_toolbar"),this.enableDisableTbrBtn()},e.prototype.initFrameToolbarItem=function(){var e=this,t=this.parent,o=t.element.id,i=document.querySelector("#"+o+"_contextualToolbarArea"),r=document.querySelector("#"+o+"_frameWrapper");r?r.style.display="block":r=i.appendChild(t.createElement("div",{id:o+"_frameWrapper",className:"e-frame-wrapper",styles:"position: relative"})),r.appendChild(t.createElement("div",{id:o+"_customizeWrapper",styles:"position: absolute"}));var a=this.getFrameToolbarItem(),n={toolbarType:"frame",toolbarItems:a};t.trigger("toolbarUpdating",n),a=n.toolbarItems;var s=new v.Toolbar({width:"100%",items:a,clicked:this.defToolbarClicked.bind(this),created:function(){e.createFrameColor(),e.createFrameSize();var i=t.frameObj.type;"line"===i&&e.createFrameRadius(),"line"!==i&&"inset"!==i&&"hook"!==i||e.createFrameInset(),"line"!==i&&"inset"!==i||e.createFrameOffset(),"line"===i&&(e.createFrameAmount(),e.createFrameBorder()),e.createFrameGradientColor(),g.Browser.isDevice?e.defToolbarItems.length>0&&document.getElementById(o+"_bottomToolbar")&&(s.refreshOverflow(),s.refreshOverflow(),s.refreshOverflow()):(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(o+"_toolbar")&&s.refreshOverflow()),t.element.querySelector("#"+o+"_"+i).focus()}});s.appendTo("#"+o+"_customizeWrapper")},e.prototype.createFrameGradientColor=function(){var e,t=this.parent,o={frameChangeEventArgs:null},i=t.element.id;t.element.querySelector(".e-template.e-frame-stroke").appendChild(t.createElement("input",{id:i+"_frame_gradient_fill"}));var r=new C.ColorPicker({modeSwitcher:!1,noColor:!0,value:t.frameObj.gradientColor,showButtons:!1,mode:"Palette",cssClass:"e-frame-gradient-fill-color",change:function(i){e={type:t.toPascalCase(t.frameObj.type),color:t.frameObj.color,gradientColor:t.frameObj.gradientColor,size:t.frameObj.size,inset:t.frameObj.inset,offset:t.frameObj.offset,borderRadius:t.frameObj.radius,frameLineStyle:t.toPascalCase(t.frameObj.border),lineCount:t.frameObj.amount};var r=t.frameObj.gradientColor,n={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),t.frameObj.gradientColor=i.currentValue.hex,t.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:(0,g.extend)({},t.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),t.notify("draw",{prop:"redrawDownScale"}),""===i.currentValue.rgba?a.element.children[0].classList.add("e-nocolor-item"):(a.element.children[0].classList.remove("e-nocolor-item"),a.element.children[0].style.backgroundColor=i.currentValue.rgba),t.curFrameObjEvent={previousFrameSetting:o.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:o.frameChangeEventArgs.currentFrameSetting},t.isFrameBtnClick=!0):t.frameObj.gradientColor=r,a.toggle()}},"#"+i+"_frame_gradient_fill"),a=new x.DropDownButton({open:function(e){if(g.Browser.isDevice){var o=e.element.parentElement;o.style.top=a.element.getBoundingClientRect().top-o.offsetHeight+"px",window.innerWidth<=520&&(o.style.left=t.element.offsetLeft+"px")}},target:".e-frame-gradient-fill-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_frameGradientColorBtn");r.inline=!0,""===t.frameObj.gradientColor?t.element.querySelector(".e-frame-stroke.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item"):t.element.querySelector(".e-frame-stroke.e-template .e-dropdownbtn-preview").style.background=t.frameObj.gradientColor},e.prototype.createFrameColor=function(){var e,t=this.parent,o={frameChangeEventArgs:null},i=t.element.id;t.element.querySelector(".e-template.e-stroke").appendChild(t.createElement("input",{id:i+"_frame_fill"}));var r=new C.ColorPicker({modeSwitcher:!1,value:t.frameObj.color,showButtons:!1,mode:"Palette",cssClass:"e-frame-fill-color",change:function(i){e={type:t.toPascalCase(t.frameObj.type),color:t.frameObj.color,gradientColor:t.frameObj.gradientColor,size:t.frameObj.size,inset:t.frameObj.inset,offset:t.frameObj.offset,borderRadius:t.frameObj.radius,frameLineStyle:t.toPascalCase(t.frameObj.border),lineCount:t.frameObj.amount};var r=t.frameObj.color,n={currObj:{}};t.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),t.frameObj.color=i.currentValue.hex,t.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(t.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:(0,g.extend)({},t.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),t.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),t.notify("draw",{prop:"redrawDownScale"}),""===i.currentValue.rgba?a.element.children[0].classList.add("e-nocolor-item"):(a.element.children[0].classList.remove("e-nocolor-item"),a.element.children[0].style.backgroundColor=i.currentValue.rgba),t.curFrameObjEvent={previousFrameSetting:o.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:o.frameChangeEventArgs.currentFrameSetting},t.isFrameBtnClick=!0):t.frameObj.color=r,a.toggle()}},"#"+i+"_frame_fill"),a=new x.DropDownButton({open:function(e){if(g.Browser.isDevice){var o=e.element.parentElement;o.style.top=a.element.getBoundingClientRect().top-o.offsetHeight+"px",window.innerWidth<=520&&(o.style.left=t.element.offsetLeft+"px")}},target:".e-frame-fill-color",iconCss:"e-dropdownbtn-preview",cssClass:"e-ie-ddb-popup"},"#"+i+"_frameColorBtn");r.inline=!0,t.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background=t.frameObj.color},e.prototype.createFrameSize=function(){var e,t=this,o=this.parent,i={frameChangeEventArgs:null},r=o.element.id,a=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(r+"_frameSizeBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(o.frameObj.size.toString()),s.className="e-frame-stroke-width",n.appendChild(s);var l=new x.DropDownButton({items:a,open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement;t.style.top=l.element.getBoundingClientRect().top-t.offsetHeight+"px"}var o=l.element.childNodes[0].textContent;""!==o&&e.element.querySelector('[aria-label = "'+o+'"]').classList.add("e-selected-btn")},select:function(a){t.triggerTbarClickEvent(a),e={type:o.toPascalCase(o.frameObj.type),color:o.frameObj.color,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,borderRadius:o.frameObj.radius,frameLineStyle:o.toPascalCase(o.frameObj.border),lineCount:o.frameObj.amount};var n=o.frameObj.size,s={currObj:{}};(o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),o.frameObj.size=parseInt(a.item.text,10),o.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:i}}),i.frameChangeEventArgs&&!i.frameChangeEventArgs.cancel?(o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:s.currObj,previousObjColl:s.currObj.objColl,previousPointColl:s.currObj.pointColl,previousSelPointColl:s.currObj.selPointColl,previousCropObj:(0,g.extend)({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),o.notify("draw",{prop:"redrawDownScale"}),l.content=a.item.text,o.curFrameObjEvent={previousFrameSetting:i.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:i.frameChangeEventArgs.currentFrameSetting},o.isFrameBtnClick=!0):o.frameObj.size=n,g.Browser.isDevice)?document.getElementById(r+"_bottomToolbar")&&(0,g.getComponent)(r+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(r+"_toolbar")&&(0,g.getComponent)(r+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+r+"_frameSizeBtn")},e.prototype.createFrameInset=function(){var e,t=this,o=this.parent,i={frameChangeEventArgs:null},r=o.element.id,a=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(r+"_frameInsetBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(o.frameObj.inset.toString()),s.className="e-frame-inset",n.appendChild(s);var l=new x.DropDownButton({items:a,open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement;t.style.top=l.element.getBoundingClientRect().top-t.offsetHeight+"px"}var o=l.element.childNodes[0].textContent;""!==o&&e.element.querySelector('[aria-label = "'+o+'"]').classList.add("e-selected-btn")},select:function(a){t.triggerTbarClickEvent(a),e={type:o.toPascalCase(o.frameObj.type),color:o.frameObj.color,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,borderRadius:o.frameObj.radius,frameLineStyle:o.toPascalCase(o.frameObj.border),lineCount:o.frameObj.amount};var n=o.frameObj.inset,s={currObj:{}};(o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),o.frameObj.inset=parseInt(a.item.text,10),o.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:i}}),i.frameChangeEventArgs&&!i.frameChangeEventArgs.cancel?(o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:s.currObj,previousObjColl:s.currObj.objColl,previousPointColl:s.currObj.pointColl,previousSelPointColl:s.currObj.selPointColl,previousCropObj:(0,g.extend)({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),o.notify("draw",{prop:"redrawDownScale"}),l.content=a.item.text,o.curFrameObjEvent={previousFrameSetting:i.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:i.frameChangeEventArgs.currentFrameSetting},o.isFrameBtnClick=!0):o.frameObj.inset=n,g.Browser.isDevice)?document.getElementById(r+"_bottomToolbar")&&(0,g.getComponent)(r+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(r+"_toolbar")&&(0,g.getComponent)(r+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+r+"_frameInsetBtn")},e.prototype.createFrameOffset=function(){var e,t=this,o=this.parent,i={frameChangeEventArgs:null},r=o.element.id,a=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(r+"_frameOffsetBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(o.frameObj.offset.toString()),s.className="e-frame-offset",n.appendChild(s);var l=new x.DropDownButton({items:a,open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement;t.style.top=l.element.getBoundingClientRect().top-t.offsetHeight+"px"}var o=l.element.childNodes[0].textContent;""!==o&&e.element.querySelector('[aria-label = "'+o+'"]').classList.add("e-selected-btn")},select:function(a){t.triggerTbarClickEvent(a),e={type:o.toPascalCase(o.frameObj.type),color:o.frameObj.color,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,borderRadius:o.frameObj.radius,lineCount:o.frameObj.amount,frameLineStyle:o.toPascalCase(o.frameObj.border)};var n=o.frameObj.offset,s={currObj:{}};(o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),o.frameObj.offset=parseInt(a.item.text,10),o.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:i}}),i.frameChangeEventArgs&&!i.frameChangeEventArgs.cancel?(o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:s.currObj,previousObjColl:s.currObj.objColl,previousPointColl:s.currObj.pointColl,previousSelPointColl:s.currObj.selPointColl,previousCropObj:(0,g.extend)({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),o.notify("draw",{prop:"redrawDownScale"}),l.content=a.item.text,o.curFrameObjEvent={previousFrameSetting:i.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:i.frameChangeEventArgs.currentFrameSetting},o.isFrameBtnClick=!0):o.frameObj.offset=n,g.Browser.isDevice)?document.getElementById(r+"_bottomToolbar")&&(0,g.getComponent)(r+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(r+"_toolbar")&&(0,g.getComponent)(r+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+r+"_frameOffsetBtn")},e.prototype.createFrameRadius=function(){var e,t=this,o=this.parent,i={frameChangeEventArgs:null},r=o.element.id,a=[{id:"1",text:this.l10n.getConstant("0")},{id:"2",text:this.l10n.getConstant("20")},{id:"3",text:this.l10n.getConstant("40")},{id:"4",text:this.l10n.getConstant("60")},{id:"5",text:this.l10n.getConstant("80")},{id:"6",text:this.l10n.getConstant("100")}],n=document.getElementById(r+"_frameRadiusBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(o.frameObj.radius.toString()),s.className="e-frame-radius",n.appendChild(s);var l=new x.DropDownButton({items:a,open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement;t.style.top=l.element.getBoundingClientRect().top-t.offsetHeight+"px"}var o=l.element.childNodes[0].textContent;""!==o&&e.element.querySelector('[aria-label = "'+o+'"]').classList.add("e-selected-btn")},select:function(a){t.triggerTbarClickEvent(a),e={type:o.toPascalCase(o.frameObj.type),color:o.frameObj.color,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,borderRadius:o.frameObj.radius,frameLineStyle:o.toPascalCase(o.frameObj.border),lineCount:o.frameObj.amount};var n=o.frameObj.radius,s={currObj:{}};(o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),o.frameObj.radius=parseInt(a.item.text,10),o.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:i}}),i.frameChangeEventArgs&&!i.frameChangeEventArgs.cancel?(o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:s.currObj,previousObjColl:s.currObj.objColl,previousPointColl:s.currObj.pointColl,previousSelPointColl:s.currObj.selPointColl,previousCropObj:(0,g.extend)({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),o.notify("draw",{prop:"redrawDownScale"}),l.content=a.item.text,o.curFrameObjEvent={previousFrameSetting:i.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:i.frameChangeEventArgs.currentFrameSetting},o.isFrameBtnClick=!0):o.frameObj.radius=n,g.Browser.isDevice)?document.getElementById(r+"_bottomToolbar")&&(0,g.getComponent)(r+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(r+"_toolbar")&&(0,g.getComponent)(r+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+r+"_frameRadiusBtn")},e.prototype.createFrameAmount=function(){var e,t=this,o=this.parent,i={frameChangeEventArgs:null},r=o.element.id,a=[{id:"1",text:this.l10n.getConstant("1")},{id:"2",text:this.l10n.getConstant("2")},{id:"3",text:this.l10n.getConstant("3")},{id:"4",text:this.l10n.getConstant("4")},{id:"5",text:this.l10n.getConstant("5")}],n=document.getElementById(r+"_frameAmountBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(o.frameObj.amount.toString()),s.className="e-frame-amount",n.appendChild(s);var l=new x.DropDownButton({items:a,open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement;t.style.top=l.element.getBoundingClientRect().top-t.offsetHeight+"px"}var o=l.element.childNodes[0].textContent;""!==o&&e.element.querySelector('[aria-label = "'+o+'"]').classList.add("e-selected-btn")},select:function(a){t.triggerTbarClickEvent(a),e={type:o.toPascalCase(o.frameObj.type),color:o.frameObj.color,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,borderRadius:o.frameObj.radius,lineCount:o.frameObj.amount,frameLineStyle:o.toPascalCase(o.frameObj.border)};var n=o.frameObj.amount,s={currObj:{}};(o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),o.frameObj.amount=parseInt(a.item.text,10),o.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:i}}),i.frameChangeEventArgs&&!i.frameChangeEventArgs.cancel?(o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:s.currObj,previousObjColl:s.currObj.objColl,previousPointColl:s.currObj.pointColl,previousSelPointColl:s.currObj.selPointColl,previousCropObj:(0,g.extend)({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),o.notify("draw",{prop:"redrawDownScale"}),l.content=a.item.text,o.curFrameObjEvent={previousFrameSetting:i.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:i.frameChangeEventArgs.currentFrameSetting},o.isFrameBtnClick=!0):o.frameObj.amount=n,g.Browser.isDevice)?document.getElementById(r+"_bottomToolbar")&&(0,g.getComponent)(r+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(r+"_toolbar")&&(0,g.getComponent)(r+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+r+"_frameAmountBtn")},e.prototype.createFrameBorder=function(){var e,t=this,o=this.parent,i={frameChangeEventArgs:null},r=o.element.id,a=[{id:"1",text:this.l10n.getConstant("Solid")},{id:"2",text:this.l10n.getConstant("Dashed")},{id:"3",text:this.l10n.getConstant("Dotted")}],n=document.getElementById(r+"_frameBorderBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(o.toPascalCase(o.frameObj.border)),s.className="e-frame-border",n.appendChild(s);var l=new x.DropDownButton({items:a,open:function(e){if(g.Browser.isDevice){var t=e.element.parentElement;t.style.top=l.element.getBoundingClientRect().top-t.offsetHeight+"px"}var o=l.element.childNodes[0].textContent;""!==o&&e.element.querySelector('[aria-label = "'+o+'"]').classList.add("e-selected-btn")},select:function(a){t.triggerTbarClickEvent(a),e={lineCount:o.frameObj.amount,color:o.frameObj.color,borderRadius:o.frameObj.radius,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,frameLineStyle:o.toPascalCase(o.frameObj.border),type:o.toPascalCase(o.frameObj.type)};var n=o.frameObj.border,s={currObj:{}};(o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),o.frameObj.border=a.item.text.toLowerCase(),o.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:i}}),i.frameChangeEventArgs&&!i.frameChangeEventArgs.cancel?(o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:s.currObj,previousObjColl:s.currObj.objColl,previousPointColl:s.currObj.pointColl,previousSelPointColl:s.currObj.selPointColl,previousCropObj:(0,g.extend)({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),o.notify("draw",{prop:"redrawDownScale"}),l.content=a.item.text,o.curFrameObjEvent={previousFrameSetting:i.frameChangeEventArgs.previousFrameSetting,currentFrameSetting:i.frameChangeEventArgs.currentFrameSetting},o.isFrameBtnClick=!0):o.frameObj.border=n,g.Browser.isDevice)?document.getElementById(r+"_bottomToolbar")&&(0,g.getComponent)(r+"_bottomToolbar","toolbar").refreshOverflow():document.getElementById(r+"_toolbar")&&(0,g.getComponent)(r+"_toolbar","toolbar").refreshOverflow()}});l.appendTo("#"+r+"_frameBorderBtn")},e.prototype.initFilterToolbarItem=function(){var e=this,t=this.parent,o=t.element.id,i=this.getFilterToolbarItem(),r={toolbarType:"filter",toolbarItems:i};t.trigger("toolbarUpdating",r),i=r.toolbarItems,document.querySelector("#"+o+"_contextualToolbar").classList.contains("e-control")&&(0,g.getComponent)(document.getElementById(o+"_contextualToolbar"),"toolbar").destroy();var a=new v.Toolbar({width:"100%",items:i,clicked:this.contextualToolbarClicked.bind(this),created:function(){e.updatePrivateVariables(),e.createCanvasFilter(),""===t.currentFilter&&(t.currentFilter=o+"_default");var i=document.querySelector("#"+o+"_headWrapper");i&&(i.style.display="none");var r=document.getElementById(t.currentFilter+"Canvas");r&&r.parentElement.parentElement.classList.add("e-selected"),e.enableDisableTbrBtn(),a.refreshOverflow()}});a.appendTo("#"+o+"_contextualToolbar")},e.prototype.drawDashedLine=function(e){e.beginPath(),e.setLineDash([5]),e.rect(10,10,280,130),e.stroke(),e.closePath()},e.prototype.createCanvasFilter=function(){var e=this.parent;(0,b.showSpinner)(e.element),e.element.style.opacity="0.5";var t=e.getCurrentCanvasData();this.inMemoryCanvas.width=t.width,this.inMemoryCanvas.height=t.height,this.inMemoryContext.putImageData(t,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"),(0,b.hideSpinner)(e.element),e.element.style.opacity="1",e.initialAdjustmentValue=this.lowerContext.filter},e.prototype.updateFilterCanvas=function(e,t){var o=this.parent,i=o.element.querySelector("#"+o.element.id+e);if(i){var r=i.getContext("2d");(r=i.getContext("2d")).imageSmoothingQuality=o.imageSmoothingEnabled?"high":"low",i.style.width="100px",i.style.height="100px",o.notify("filter",{prop:"updateAdj",value:{type:t,value:null,isPreview:!0,ctx:r}}),r.drawImage(this.inMemoryCanvas,0,0,300,150),o.isSafari&&o.notify("filter",{prop:"apply-filter",onPropertyChange:!1,value:{context:r}})}},e.prototype.getQuickAccessToolbarItem=function(e){var t=this.parent,o=t.element.id,i={cancel:!1,toolbarItems:[]},r=[];(0,g.isNullOrUndefined)(e)?("image"===t.activeObj.shape&&r.push("Flip"),"redact"!==t.activeObj.shape&&r.push("BringToFront"),r.push("Clone"),r.push("Delete"),"text"===t.activeObj.shape&&r.push("EditText"),i.shape=t.toPascalCase(t.activeObj.shape)):e&&(r.push("BringToFront"),r.push("Delete"),i.shape="Freehand draw"),i.toolbarItems=(0,g.extend)([],r,null,!0),t.trigger("quickAccessToolbarOpen",i);var a=[];if(i.cancel)a=[];else for(var n=0;n<i.toolbarItems.length;n++)switch(i.toolbarItems[n]){case"BringToFront":a.push({id:o+"_bringToFront",prefixIcon:"e-icons e-bring-to-front",tooltipText:this.l10n.getConstant("BringToFront"),align:"Left"});break;case"Clone":a.push({id:o+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Left"});break;case"Delete":a.push({id:o+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Left"});break;case"EditText":a.push({id:o+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Left"});break;case"Flip":a.push({id:o+"_hFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Left"}),a.push({id:o+"_vFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Left"});break;default:a.push(i.toolbarItems[n])}return a},e.prototype.renderQAT=function(e){var t=this.parent,o=t.element.id;if(t.activeObj&&t.showQuickAccessToolbar){var i=document.getElementById(o+"_quickAccessToolbarArea");i&&(this.destroyQuickAccessToolbar(),i.style.display="block");var r=this.getQuickAccessToolbarItem(e);if(0===r.length)return;if((0,g.isNullOrUndefined)(t.quickAccessToolbarTemplate))new v.Toolbar({items:r,clicked:this.quickAccessToolbarClicked.bind(this)}).appendTo("#"+o+"_quickAccessToolbar");var a=this.toolbarHeight&&0!==this.toolbarHeight?this.toolbarHeight:i.clientHeight,n=t.element.querySelector("#"+o+"_headWrapper");if((0,g.isNullOrUndefined)(e)&&(0!==t.activeObj.activePoint.width||0!==t.activeObj.activePoint.height||t.activeObj.shape&&"path"===t.activeObj.shape&&t.activeObj.pointColl.length>0)){var s={order:null};t.notify("shape",{prop:"getHighestOrder",onPropertyChange:!1,value:{obj:s}}),t.activeObj.order>s.order&&document.getElementById(t.element.id+"_bringToFront")?document.getElementById(t.element.id+"_bringToFront").parentElement.classList.add("e-overlay"):document.getElementById(t.element.id+"_bringToFront")&&document.getElementById(t.element.id+"_bringToFront").parentElement.classList.remove("e-overlay"),i.style.width="auto",t.activeObj.activePoint.width=Math.abs(t.activeObj.activePoint.width),t.activeObj.activePoint.height=Math.abs(t.activeObj.activePoint.height);var l=t.activeObj.activePoint.startX<t.activeObj.activePoint.endX?t.activeObj.activePoint.startX:t.activeObj.activePoint.endX,p=t.activeObj.activePoint.startY<t.activeObj.activePoint.endY?t.activeObj.activePoint.startY:t.activeObj.activePoint.endY,h=t.activeObj.activePoint.width;if(0!==t.activeObj.rotatedAngle&&"arrow"!==t.activeObj.shape){var d={activePoint:null};t.notify("shape",{prop:"getSquarePointForRotatedShape",onPropertyChange:!1,value:{obj:t.activeObj,object:d}}),l=(b=d.activePoint).startX,p=b.startY,h=b.width}else if("path"===t.activeObj.shape){var c=t.getSquarePointForPath(t.activeObj);l=c.startX,p=c.startY,h=c.width}if(i.style.left=l+h/2-25*r.length+"px",parseFloat(i.style.left)+i.clientWidth/2!==l+h/2){var u=l+h/2-(parseFloat(i.style.left)+i.clientWidth/2);i.style.left=parseFloat(i.style.left)+u+"px"}n&&(a=n.offsetHeight+a),p-(a+a/1.5)<t.img.destTop?(i.style.top=t.img.destTop+"px",n&&(i.style.top=(t.img.destTop<0?0:t.img.destTop)+n.offsetHeight+"px")):(a=this.toolbarHeight,i.style.top=p-(a+a/1.5)+"px")}else if(e){var f={freehandSelectedIndex:-1};t.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:f}});s={order:null};t.notify("shape",{prop:"getHighestOrder",onPropertyChange:!1,value:{obj:s}}),t.getObjFromId(t.pointColl[f.freehandSelectedIndex].id).order>=s.order&&document.getElementById(t.element.id+"_bringToFront")?document.getElementById(t.element.id+"_bringToFront").parentElement.classList.add("e-overlay"):document.getElementById(t.element.id+"_bringToFront")&&document.getElementById(t.element.id+"_bringToFront").parentElement.classList.remove("e-overlay");var m={activePoint:null};t.notify("freehand-draw",{prop:"getSqPtFD",value:{idx:f.freehandSelectedIndex,obj:m}});var b=m.activePoint;i.style.width="auto",i.style.left=b.startX+b.width/2-24*r.length+"px",b.startY-(a+a/1.5)<t.img.destTop?i.style.top=t.img.destTop+"px":i.style.top=b.startY-(a+a/1.5)+"px"}else i.style.display="none";parseFloat(i.style.top)<0&&(i.style.top="0px")}},e.prototype.refreshDropDownBtn=function(e){if(!(0,g.isNullOrUndefined)(e)){var t=this.parent.element.id,o=document.querySelector("#"+t+"_annotationBtn");o&&(e?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay")),(0,g.getComponent)(o,"dropdown-btn").disabled=e);var i=document.querySelector("#"+t+"_transformBtn");i&&(e?(i.classList.add("e-disabled"),i.parentElement.classList.add("e-overlay")):(i.classList.remove("e-disabled"),i.parentElement.classList.remove("e-overlay")),(0,g.getComponent)(i,"dropdown-btn").disabled=e);var r=document.querySelector("#"+t+"_adjustment");r&&(e?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")),(0,g.getComponent)(r,"btn").disabled=e);var a=document.querySelector("#"+t+"_filter");a&&(e?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay")),(0,g.getComponent)(a,"btn").disabled=e)}},e.prototype.cropSelect=function(e){var t=this.parent;t.isCropTab=!0,(0,g.isNullOrUndefined)(t.transform.cropZoomFactor)&&(t.transform.cropZoomFactor=t.transform.zoomFactor,t.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:t.transform.zoomFactor}})),t.transform.zoomFactor=t.transform.cropZoomFactor;var o=e.item.id;this.currentToolbar="crop",t.currSelectionPoint=null,t.notify("draw",{prop:"setIsCropSelect",value:{bool:!0}});var i={prevObj:null};t.notify("crop",{prop:"getPreviousCropCurrentObj",value:{obj:i}}),t.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:o,startX:null,startY:null,width:null,height:null}}),t.notify("crop",{prop:"setPreviousCropCurrentObj",value:{obj:i.prevObj}}),this.enableDisableTbrBtn(),t.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},e.prototype.quickAccessToolbarClicked=function(e,t){var o=this.parent,i=o.element.id;if(e.item){var r=null,a={tempObj:null};o.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:{prevActObj:null}}}),o.notify("selection",{prop:"getTempActObj",onPropertyChange:!1,value:{obj:a}}),a.tempObj.activePoint.height=Math.abs(a.tempObj.activePoint.height);var n={isNewPath:null},s=void 0;o.notify("draw",{prop:"getNewPath",value:{obj:n}});var l=e.item.id.replace(i+"_","").toLowerCase(),p=void 0,h=void 0,d={freehandSelectedIndex:null},c=void 0,u=void 0,v={order:null};switch(l){case"duplicate":o.element.querySelector("#"+i+"_duplicate").classList.contains("e-overlay")||(this.refreshSlider(),n.isNewPath||JSON.stringify(a.tempObj)!==JSON.stringify(o.activeObj)||(r=!0),this.duplicateShape(r));break;case"remove":o.element.querySelector("#"+i+"_remove").classList.contains("e-overlay")||(o.noPushUndo=!1,this.refreshSlider(),o.notify("selection",{prop:"deleteItem",onPropertyChange:!1}));break;case"edittext":o.element.querySelector("#"+i+"_editText").classList.contains("e-overlay")||this.editText();break;case"rotleft":case"rotright":p=o.element.querySelector("#"+i+"_rotLeft"),h=o.element.querySelector("#"+i+"_rotRight"),(p&&!p.classList.contains("e-disabled")||h&&!h.classList.contains("e-disabled"))&&o.rotateImage(e.item.id.replace(i+"_","").toLowerCase()),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1});break;case"hflip":o.element.querySelector("#"+i+"_hFlip").classList.contains("e-disabled")||(s=o.activeObj.imageCanvas.getContext("2d"),o.horizontalFlip(s)),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1});break;case"vflip":o.element.querySelector("#"+i+"_vFlip").classList.contains("e-disabled")||(s=o.activeObj.imageCanvas.getContext("2d"),o.verticalFlip(s)),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1});break;case"bringtofront":if(o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:d}}),c=null!==d.freehandSelectedIndex?o.pointColl[d.freehandSelectedIndex].id:o.activeObj.currIndex,o.updateShapeOrder(c,l),u=!1,o.notify("shape",{prop:"getHighestOrder",onPropertyChange:!1,value:{obj:v}}),c.indexOf("pen")>-1)o.notify("shape",{prop:"updateShapeColl",onPropertyChange:!1}),u=o.getObjFromId(c).order>=v.order;else u=o.getObjFromId(c).order>v.order;u?document.getElementById(o.element.id+"_bringToFront").parentElement.classList.add("e-overlay"):document.getElementById(o.element.id+"_bringToFront").parentElement.classList.remove("e-overlay"),o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})}"duplicate"!==l&&"remove"!==l||o.notify("draw",{prop:"redrawDownScale"})}(0,g.isNullOrUndefined)(t)&&o.trigger("quickAccessToolbarItemClick",e)},e.prototype.editText=function(){var e=this.parent,t={x:e.activeObj.activePoint.startX,y:e.activeObj.activePoint.startY};if(this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:(0,g.extend)({},e.activeObj,{},!0)}}),e.notify("selection",{prop:"setInitialTextEdit",onPropertyChange:!1,value:{bool:!0}}),e.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:(0,g.extend)({},e.activeObj,{},!0)}}),0!==e.activeObj.rotatedAngle){var o={x:t.x,y:t.y};e.notify("shape",{prop:"getTextBoxPosition",onPropertyChange:!1,value:{obj:e.activeObj,object:o}}),t.x=o.x,t.y=o.y;var i={x:t.x,y:t.y};e.notify("shape",{prop:"setFlipState",onPropertyChange:!1,value:{x:t.x,y:t.y,obj:e.activeObj,object:i}}),t.x=i.x,t.y=i.y}var r=(0,g.extend)({},e.activeObj,{},!0);e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.lowerContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),e.notify("draw",{prop:"redrawDownScale"}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),e.activeObj=r,e.notify("shape",{prop:"renderTextArea",onPropertyChange:!1,value:{x:t.x,y:t.y,actObj:e.activeObj}}),(0,g.isNullOrUndefined)(e.activeObj.currIndex)&&e.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}),document.getElementById(e.element.id+"_quickAccessToolbarArea")&&(document.getElementById(e.element.id+"_quickAccessToolbarArea").style.display="none")},e.prototype.duplicateShape=function(e,t){var o=this.parent;o.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:{activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]}}});var i={prevActObj:null};o.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:i}});var r;o.notify("draw",{prop:"getNewPath",value:{obj:{isNewPath:null}}});var a=(0,g.extend)({},o.activeObj,{},!0),n={order:null};o.notify("shape",{prop:"getHighestOrder",onPropertyChange:!1,value:{obj:n}}),a.order?(o.notify("shape",{prop:"updateShapeColl",onPropertyChange:!1}),a.order=n.order>a.order?n.order+1:a.order+1):(o.noPushUndo=!0,o.okBtn(),o.noPushUndo=!1,o.selectShape(a.currIndex),a.order=n.order>a.order?n.order+1:a.order+1),"image"===a.shape&&(r=(0,g.extend)([],o.objColl,[],!0),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:r}})),(0,g.isNullOrUndefined)(o.activeObj.currIndex)?o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:e}}):i.prevActObj||t?(o.activeObj.currIndex=null,a.currIndex=null,o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:e}})):o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}});var s=o.noPushUndo;if(o.noPushUndo=!1,o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.noPushUndo=s,r=(0,g.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 l=0;l<a.pointColl.length;l++)a.pointColl[l].x+=10,a.pointColl[l].y-=10;else"image"===a.shape&&(a.imageCanvas=o.createElement("canvas"));var p={id:"shape_"+(o.objColl.length+1)};if(o.notify("shape",{prop:"getNewShapeId",onPropertyChange:!1,value:{obj:p}}),a.currIndex=p.id,o.activeObj=(0,g.extend)({},a,{},!0),"image"===o.activeObj.shape){var h=(0,g.extend)({},a.activePoint,{},!0),d={width:0,height:0};o.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o.activeObj.imageElement.width,height:o.activeObj.imageElement.height,obj:d,isImgShape:null}}),o.activeObj.activePoint.width=d.width,o.activeObj.activePoint.height=d.height,o.activeObj.isHorImageFlip&&o.activeObj.isVerImageFlip?(o.activeObj.isHorImageFlip=o.activeObj.isVerImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:!0}}),o.activeObj.isHorImageFlip=o.activeObj.isVerImageFlip=!0):o.activeObj.isHorImageFlip?(o.activeObj.isHorImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:null}}),o.activeObj.isHorImageFlip=!0):o.activeObj.isVerImageFlip?(o.activeObj.isVerImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:!0}}),o.activeObj.isVerImageFlip=!0):o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),o.activeObj.activePoint=h}"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,isCropRatio:null,points:null,isPreventDrag:!0}}),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:r}}),o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),o.noPushUndo=!1,o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.noPushUndo=!0,o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.objColl[o.objColl.length-1]}});var c=o.element.id,u=g.Browser.isDevice?"#"+c+"_bottomToolbar #"+c:"#"+c,v={freehandDrawSelectedId:null};o.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:v}}),this.enableDisableCloneBtn(u,v),this.renderQAT(),o.activeObj.shape&&"redact"===o.activeObj.shape&&this.redactSlider(o.activeObj.redactType)},e.prototype.defToolbarClicked=function(e){var t=this.parent,o=t.element.id,i=!1,r=!1;if(!this.isFrameToolbar&&t.element.querySelector(".e-contextual-toolbar-wrapper")){t.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(i=r=!0);var a={bool:t.isStraightening};(!g.Browser.isDevice||g.Browser.isDevice&&!a.bool)&&t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")}if(e.item){var n=e.item.id.replace(o+"_","").toLowerCase();if("duplicate"===n||"remove"===n||"edittext"===n||"hflip"===n||"vflip"===n||"rotleft"===n||"rotright"===n)this.quickAccessToolbarClicked(e,!0),t.trigger("toolbarItemClicked",e);else{var s=!1,l=!1,p=document.querySelector("#"+o+"_adjustment");p&&p.classList.contains("e-disabled")&&(l=!0);var h=document.querySelector("#"+o+"_filter");h&&h.classList.contains("e-disabled")&&(s=!0),this.enableDisableTbrBtn(),this.performDefTbrClick(n,i,l,s,r),t.trigger("toolbarItemClicked",e),t.isStraightening&&t.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});-1!==["undo","redo","cancel","aspectratio","nonaspectratio","save","duplicate","filter","frame","none","mat","bevel","line","inset","hook","resize","remove"].indexOf(n)&&t.notify("draw",{prop:"redrawDownScale"})}}},e.prototype.performDefTbrClick=function(e,t,o,i,r){var a,n,s,l,p=this.parent,h=p.element.id,d=p.element.querySelector("#"+h+"_zoomIn"),c=p.element.querySelector("#"+h+"_resizeHeight"),u=p.element.querySelector("#"+h+"_resizeWidth"),v=!1,f=!1,m=0,C=!1;if(void 0!==p.activeObj.shape&&(n=p.activeObj.shape.split("-")),(void 0===n&&p.currObjType.isCustomCrop||void 0!==n&&"crop"===n[0])&&(v=!0),!p.disabled){switch(e){case"pan":p.currObjType.isCustomCrop=p.currObjType.isFiltered=!1,p.currObjType.isRedact=!1,p.currObjType.isUndoAction&&p.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}}),v&&(p.currObjType.isCustomCrop=!1,p.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,p.upperCanvas.width,p.upperCanvas.height),this.refreshToolbar("main")),p.togglePan?(this.cancelPan(),p.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!0}}),"pen"===this.currentToolbar&&p.freeHandDraw(!0)):((a=p.element.querySelector(".e-img-pan .e-btn"))&&a.classList.add("e-selected-btn"),p.pan(!0),p.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!1}})),d&&p.zoomSettings.zoomFactor>=p.zoomSettings.maxZoomFactor?(d.classList.add("e-disabled"),d.parentElement.classList.add("e-overlay")):d&&(d.classList.remove("e-disabled"),d.parentElement.classList.remove("e-overlay")),this.refreshToolbar("main");break;case"cancel":p.currObjType.isRedact&&(p.currObjType.isRedact=!1),this.isFrameToolbar&&p.element.querySelector(".e-contextual-toolbar-wrapper")&&!p.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")&&p.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),p.notify("draw",{prop:"performCancel",value:{isContextualToolbar:t,isFinalCancel:!0}});break;case"ok":g.Browser.isDevice&&this.isFrameToolbar&&p.element.querySelector(".e-contextual-toolbar-wrapper")&&!p.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")&&p.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),p.okBtn(null,!0),p.drawingShape=null,this.refreshDropDownBtn(!1),this.currentToolbar="main",p.isStraightening=!1,p.notify("draw",{prop:"resetTempObjColl"}),p.notify("draw",{prop:"resetTempPointColl"});break;case"crop":p.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),g.Browser.isDevice&&this.updateContextualToolbar("color","straighten");break;case"reset":p.reset(),this.imageHeight=null,this.imageWidth=null,p.aspectHeight=null,p.aspectWidth=null,this.isAspectRatio=!0,this.currentToolbar="main";break;case"undo":p.noPushUndo=!1,(p.togglePen||p.drawingShape)&&(p.okBtn(),p.drawingShape=null),p.notify("undo-redo",{prop:"call-undo"});break;case"redo":p.noPushUndo=!1,(p.togglePen||p.drawingShape)&&(p.okBtn(),p.drawingShape=null),p.notify("undo-redo",{prop:"call-redo"});break;case"aspectratio":(!p.isCircleCrop&&(0,g.isNullOrUndefined)(p.currSelectionPoint)||p.currSelectionPoint&&"crop-circle"!==p.currSelectionPoint.shape)&&((0,g.getComponent)(u,"numerictextbox").value?(p.aspectWidth=(0,g.getComponent)(u,"numerictextbox").value,p.aspectHeight=(0,g.getComponent)(c,"numerictextbox").value,p.notify("transform",{prop:"resize",value:{width:p.aspectWidth,height:null,isAspectRatio:!0}})):(0,g.getComponent)(c,"numerictextbox").value&&(p.aspectWidth=parseFloat((0,g.getComponent)(u,"numerictextbox").placeholder),p.aspectHeight=(0,g.getComponent)(c,"numerictextbox").value,p.notify("transform",{prop:"resize",value:{width:p.aspectWidth,height:p.aspectHeight,isAspectRatio:!0}})),p.resizeSrc={startX:p.img.srcLeft,startY:p.img.srcTop,width:p.img.srcWidth,height:p.img.srcHeight},this.refreshToolbar("resize"));break;case"nonaspectratio":((0,g.getComponent)(u,"numerictextbox").value||(0,g.getComponent)(c,"numerictextbox").value)&&(p.aspectWidth=(0,g.getComponent)(u,"numerictextbox").value?(0,g.getComponent)(u,"numerictextbox").value:parseFloat((0,g.getComponent)(u,"numerictextbox").placeholder),p.aspectHeight=(0,g.getComponent)(c,"numerictextbox").value?(0,g.getComponent)(c,"numerictextbox").value:parseFloat((0,g.getComponent)(c,"numerictextbox").placeholder),p.notify("transform",{prop:"resize",value:{width:p.aspectWidth,height:p.aspectHeight,isAspectRatio:!1}})),p.resizeSrc={startX:p.img.srcLeft,startY:p.img.srcTop,width:p.img.srcWidth,height:p.img.srcHeight},this.refreshToolbar("resize");break;case"resize":(p.currObjType.isFiltered||p.currObjType.isRedact)&&p.okBtn(),this.resizeClick();break;case"adjustment":o||((p.currObjType.isFiltered||p.currObjType.isRedact)&&p.okBtn(),this.refreshToolbar("adjustment"),p.setTempFilterProperties(),p.notify("draw",{prop:"updateFinetune"}),p.notify("filter",{prop:"setTempAdjVal"}),this.openSlider("brightness"));break;case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":this.openSlider(e);break;case"filter":i||((0,b.showSpinner)(p.element),this.refreshToolbar("filter"),p.setTempFilterProperties(),(0,b.hideSpinner)(p.element));break;case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":p.currObjType.isFiltered=!0,p.notify("filter",{prop:"applyImageFilter",value:{option:e}});break;case"upload":r&&p.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-hide");break;case"bold":case"italic":case"underline":case"strikethrough":this.toggleStyle(h,e);break;case"croptransform":this.performCropTransformClick();break;case"rotateleft":case"rotateright":case"horizontalflip":case"verticalflip":p.transformSelect(e);for(var y=0;y<p.objColl.length;y++)if("redact"===p.objColl[y].shape){C=!0;break}if(C)for(p.notify("draw",{prop:"setRedactStraighten",value:{bool:!0}}),l=(0,g.extend)({},p.activeObj,{},!0);p.img.destLeft<0||p.img.destTop<0;)p.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),p.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.125,zoomPoint:null,isResize:!1}}),m+=1;if(this.updateRedactObj(),C){if(m>0){p.isCropTab=!0;for(y=0;y<m;y++)p.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),p.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.125,zoomPoint:null,isResize:!1}});p.activeObj=l,p.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})}p.notify("draw",{prop:"setRedactStraighten",value:{bool:!1}})}"rotateleft"!==e&&"rotateright"!==e||(p.notify("draw",{prop:"resetStraightenDestPoints"}),p.notify("draw",{prop:"setDestForStraighten"})),p.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),g.Browser.isDevice&&this.updateContextualToolbar("color","straighten"),s={action:"rotateleft"===e||"rotateright"===e?"rotate":"flip",actionEventArgs:p.editCompleteArgs},p.triggerEditCompleteEvent(s);break;case"save":p.noPushUndo=!1,p.okBtn(),p.drawingShape=null,this.saveDialogPopup();break;case"transparency":this.updateContextualToolbar("transparency","transparency");break;case"frame":this.frameToolbarClick();break;case"none":case"mat":case"bevel":case"line":case"inset":case"hook":this.unselectFrameBtn(),p.element.querySelector("#"+h+"_"+e)&&p.element.querySelector("#"+h+"_"+e).classList.add("e-selected-btn"),p.frameObj.type=e,p.frameObj.size=20,p.frameObj.inset=20,p.frameObj.radius=0,p.frameObj.amount=1,p.frameObj.offset="inset"===e?60:20,this.refreshToolbar("frame"),p.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),p.isFrameBtnClick=!0,p.curFrameObjEvent={previousFrameSetting:p.tempFrameObj,currentFrameSetting:p.frameObj},p.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:p.tempFrameObj,obj:{frameChangeEventArgs:null}}});break;case"redact":p.currObjType.isRedact=f=!0,p.drawingShape="redact",(0,g.isNullOrUndefined)(p.activeObj.redactBlur)&&(p.activeObj.redactBlur=20),(0,g.isNullOrUndefined)(p.activeObj.redactPixelate)&&(p.activeObj.redactPixelate=20),p.notify("selection",{prop:"annotate",value:{shape:"redact"}}),this.refreshToolbar("redact"),this.redactSlider(p.activeObj.redactType);break;case"pixelate":if(p.currObjType.isRedact=f=!0,p.drawingShape="redact",p.notify("selection",{prop:"annotate",value:{shape:"redact"}}),"blur"===p.activeObj.redactType&&this.updateRedactType("pixelate"),p.notify("shape",{prop:"setRedactType",onPropertyChange:!1,value:{redactType:"pixelate"}}),"pixelate"===p.activeObj.redactType){var x=p.element.querySelector("#"+h+"_pixelate"),P=p.element.querySelector("#"+h+"_redactBlur");x&&x.classList.add("e-selected-btn"),P&&P.classList.contains("e-selected-btn")&&P.classList.remove("e-selected-btn")}else{(P=p.element.querySelector("#"+h+"_redactBlur"))&&P.classList.add("e-selected-btn")}this.redactSlider(p.activeObj.redactType),0===p.activeObj.activePoint.width&&0===p.activeObj.activePoint.height||p.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:null,previousObjColl:null,previousPointColl:null,previousSelPointColl:null,previousCropObj:null,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}});break;case"redactblur":if(p.currObjType.isRedact=f=!0,p.drawingShape="redact",p.notify("selection",{prop:"annotate",value:{shape:"redact"}}),p.notify("shape",{prop:"setRedactType",onPropertyChange:!1,value:{redactType:"blur"}}),"pixelate"===p.activeObj.redactType&&this.updateRedactType("blur"),p.notify("shape",{prop:"setRedactType",onPropertyChange:!1,value:{redactType:"blur"}}),"blur"===p.activeObj.redactType){P=p.element.querySelector("#"+h+"_redactBlur"),x=p.element.querySelector("#"+h+"_pixelate");P&&P.classList.add("e-selected-btn"),x&&x.classList.contains("e-selected-btn")&&x.classList.remove("e-selected-btn")}else{(x=p.element.querySelector("#"+h+"_pixelate"))&&x.classList.add("e-selected-btn")}this.redactSlider(p.activeObj.redactType),0===p.activeObj.activePoint.width&&0===p.activeObj.activePoint.height||p.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:null,previousObjColl:null,previousPointColl:null,previousSelPointColl:null,previousCropObj:null,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}f&&(p.notify("draw",{prop:"updateTempObjColl"}),p.notify("draw",{prop:"updateTempPointColl"}))}},e.prototype.getFontStyle=function(e){var t=[];return e.bold&&t.push("bold"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),0===t.length?"default":t.join("")},e.prototype.toggleStyle=function(e,t){var o=this.parent;o.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}});var i=o.activeObj.textSettings;i[t]=!i[t];var r=this.getFontStyle(i);o.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:r}});var a=o.element.querySelector("#"+e+"_"+t);a&&(a.classList.contains("e-selected-btn")?a.classList.remove("e-selected-btn"):a.classList.add("e-selected-btn")),0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height||o.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})},e.prototype.updateRedactType=function(e){var t=this.parent;t.activeObj.redactType=e,t.notify("shape",{prop:"setRedactType",value:{type:e}}),this.parent.objColl.push(t.activeObj),t.notify("selection",{prop:"redrawShape",value:{obj:t.objColl[t.objColl.length-1]}})},e.prototype.frameToolbarClick=function(){var e,t,o,i=this.parent,r=i.element.id,a=document.querySelector("#"+r+"_frame");if(i.notify("draw",{prop:"updateCropSelection",onPropertyChange:!1}),(i.currObjType.isFiltered||i.currObjType.isRedact)&&i.okBtn(),!a||!a.classList.contains("e-overlay")){if(e=i.transform.zoomFactor,i.frameDestPoints=(0,g.extend)({},i.img,{},!0),(0,g.isNullOrUndefined)(i.cxtTbarHeight)){t=(0,g.extend)({},i.frameObj,{},!0),o=(0,g.extend)({},i.tempFrameObj,{},!0),this.callFrameToolbar(),i.frameObj.type="mat",this.callFrameToolbar();var n=i.element.querySelector("#"+r+"_customizeWrapper");n&&(i.cxtTbarHeight=n.scrollHeight),i.frameObj=t,i.tempFrameObj=o}this.zoomToFrameRange(),i.tempFrameZoomLevel=e,g.Browser.isDevice?i.img.destTop-=i.cxtTbarHeight/2:i.img.destTop+=i.cxtTbarHeight/2,this.callFrameToolbar(),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:i.frameObj,obj:{frameChangeEventArgs:null}}})}},e.prototype.zoomToFrameRange=function(){var e=this.parent;this.isFrameToolbar=!1,e.notify("transform",{prop:"resetZoom",onPropertyChange:!1});for(var t=!0;t;){if(this.toolbarHeight+e.img.destTop>=this.toolbarHeight+e.cxtTbarHeight){t=!1;break}e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null,isResize:!0}})}this.isFrameToolbar=!0},e.prototype.resizeClick=function(){var e=this.parent;e.notify("draw",{prop:"updateCropSelection",onPropertyChange:!1}),e.upperCanvas.style.cursor="default",e.notify("transform",{prop:"updateResize",value:{bool:!1}}),this.isAspectRatio?this.isAspectRatio=!1:this.isAspectRatio=!0,e.isResize=!0,this.refreshToolbar("resize")},e.prototype.callFrameToolbar=function(){var e=this.parent;(0,g.extend)(e.tempFrameObj,e.frameObj);var t={appliedUndoRedoColl:[]};if(e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:t}}),0===t.appliedUndoRedoColl.length){var o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:o.currObj,previousObjColl:o.currObj.objColl,previousPointColl:o.currObj.pointColl,previousSelPointColl:o.currObj.selPointColl,previousCropObj:(0,g.extend)({},e.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}this.refreshToolbar("frame")},e.prototype.contextualToolbarClicked=function(e){var t=this.parent,o=t.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");o&&o.classList.remove("e-selected");var i=e.item.id.replace(t.element.id,"").split("_")[1],r={filter:t.toPascalCase(i),cancel:!1};t.trigger("imageFiltering",r),t.editCompleteArgs=r,r.cancel||(document.getElementById(e.item.id+"Canvas").parentElement.parentElement.classList.add("e-selected"),t.currObjType.isFiltered=!0,t.notify("filter",{prop:"applyImageFilter",value:{option:i.toLowerCase()}}),t.notify("draw",{prop:"redrawDownScale"}),t.currentFilter=e.item.id,this.enableDisableTbrBtn(),t.isFilterCanvasClick=!0,t.curFilterObjEvent=r)},e.prototype.refreshShapeDrawing=function(){var e=this.parent,t={shape:""};e.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:t}}),""!==t.shape&&(e.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.refreshToolbar("main",!1))},e.prototype.zoomInBtnClickHandler=function(e){if(e){var t=this.parent;if((t.zoomSettings.zoomTrigger&r.Toolbar)===r.Toolbar){t.noPushUndo=!1,t.currObjType.isFiltered&&t.okBtn();var o=t.drawingShape;if(t.drawingShape){var i=t.activeObj.currIndex;t.noPushUndo=!0,t.okBtn(),t.noPushUndo=!1,t.drawingShape=null,i&&t.selectShape(i)}if(this.refreshShapeDrawing(),g.Browser.isDevice&&"touchstart"===e.type){if(!e.returnValue)return;e.preventDefault()}var a=document.querySelector("#"+t.element.id+"_zoomIn");g.EventHandler.trigger(a,"click");var n={bool:!1};t.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:n}}),n.bool&&(t.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),t.isZoomBtnClick=!0,this.applyPreviewFilter(),t.currObjType.isFiltered=!1,t.currObjType.isRedact=!1,t.togglePen&&(t.currObjType.isZoomed=!0,t.freeHandDraw(!1),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),t.notify("draw",{prop:"resetCurrentSelectionPoint"}),t.drawingShape=o,t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null,isResize:null}}),t.notify("draw",{prop:"redrawDownScale"}),(t.isCropTab||t.activeObj.shape)&&(t.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),t.notify("freehand-draw",{prop:"resetStraightenPoint"})),t.isStraightening&&(t.notify("draw",{prop:"resetStraightenDestPoints"}),t.notify("draw",{prop:"setDestForStraighten"}));var s={action:"zoom-in",actionEventArgs:t.editCompleteArgs};t.triggerEditCompleteEvent(s),g.Browser.isDevice&&a.focus()}}},e.prototype.zoomOutBtnClickHandler=function(e){if(e){var t=this.parent;if((t.zoomSettings.zoomTrigger&r.Toolbar)===r.Toolbar){t.noPushUndo=!1,t.currObjType.isFiltered&&t.okBtn();var o=t.drawingShape;if(t.drawingShape){var i=t.activeObj.currIndex;t.noPushUndo=!0,t.okBtn(),t.noPushUndo=!1,t.drawingShape=null,i&&t.selectShape(i)}if(this.refreshShapeDrawing(),g.Browser.isDevice&&"touchstart"===e.type){if(!e.returnValue)return;e.preventDefault()}var a=document.querySelector("#"+t.element.id+"_zoomOut");g.EventHandler.trigger(a,"click");var n={bool:!1};t.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:n}}),n.bool&&(t.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),t.isZoomBtnClick=!0,this.applyPreviewFilter(),t.currObjType.isFiltered=!1,t.currObjType.isRedact=!1,t.togglePen&&(t.currObjType.isZoomed=!0,t.freeHandDraw(!1),t.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),t.notify("draw",{prop:"resetCurrentSelectionPoint"}),t.drawingShape=o,t.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null,isResize:null}}),t.notify("draw",{prop:"redrawDownScale"}),(t.isCropTab||t.activeObj.shape)&&(t.notify("draw",{prop:"setStraightenActObj",value:{activeObj:null}}),t.notify("freehand-draw",{prop:"resetStraightenPoint"})),t.isStraightening&&(t.notify("draw",{prop:"resetStraightenDestPoints"}),t.notify("draw",{prop:"setDestForStraighten"}));var s={action:"zoom-out",actionEventArgs:t.editCompleteArgs};t.triggerEditCompleteEvent(s),g.Browser.isDevice&&a.focus()}}},e.prototype.zoomInBtnMouseDownHandler=function(e){e.preventDefault(),this.zoomBtnHold=setInterval(this.zoomInBtnClickHandler.bind(this),250)},e.prototype.zoomOutBtnMouseDownHandler=function(e){e.preventDefault(),this.zoomBtnHold=setInterval(this.zoomOutBtnClickHandler.bind(this),250)},e.prototype.zoomBtnMouseUpHandler=function(){clearInterval(this.zoomBtnHold),this.zoomBtnHold=0},e.prototype.closeContextualToolbar=function(){var e=this.parent,t=e.element.id,o=!1,i=e.isStraightening;return(!g.Browser.isDevice||g.Browser.isDevice&&!i)&&(e.element.querySelector("#"+t+"_contextualToolbar")&&!e.element.querySelector("#"+t+"_contextualToolbar").parentElement.classList.contains("e-hide")||e.element.querySelector("#"+t+"_headWrapper")&&!e.element.querySelector("#"+t+"_headWrapper").parentElement.classList.contains("e-hide"))&&(e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.okBtn(),this.refreshMainToolbar(),o=!0),o},e.prototype.destroyQuickAccessToolbar=function(){var e=this.parent.element.id,t=document.getElementById(e+"_quickAccessToolbar");t&&t.classList.contains("e-control")&&(0,g.getComponent)(t,"toolbar").destroy();var o=document.getElementById(e+"_quickAccessToolbarArea");o&&(o.style.display="none")},e.prototype.renderSlider=function(e,t){var o=this.parent,i=o.element.id,r=document.querySelector("#"+i+"_contextualToolbarArea"),a=document.querySelector("#"+i+"_headWrapper"),n=document.querySelector("#"+i+"_labelWrapper");a&&(a.remove(),n.remove()),(n=(a=r.appendChild(o.createElement("div",{id:i+"_headWrapper",className:"e-ie-head-wrapper",styles:"position: relative"}))).appendChild(o.createElement("label",{id:i+"_labelWrapper",className:"e-ie-finetune-slider-label"}))).textContent=this.l10n.getConstant(o.toPascalCase("transparency"===e?"opacity":e));var s,l,p,h=a.appendChild(o.createElement("div",{id:i+"_sliderWrapper",className:"e-ie-finetune-slider-wrap"})),d=o.getCurrAdjustmentValue(e);(t&&"straighten"===e&&g.Browser.isDevice&&(d=o.cropObj.straighten),"brightness"===e||"contrast"===e||"saturation"===e||"exposure"===e?(o.finetuneSettings?"brightness"===e&&o.finetuneSettings.brightness?(s=o.finetuneSettings.brightness.min,l=o.finetuneSettings.brightness.max):"contrast"===e&&o.finetuneSettings.contrast?(s=o.finetuneSettings.contrast.min,l=o.finetuneSettings.contrast.max):"saturation"===e&&o.finetuneSettings.saturation?(s=o.finetuneSettings.saturation.min,l=o.finetuneSettings.saturation.max):"exposure"===e&&o.finetuneSettings.exposure?(s=o.finetuneSettings.exposure.min,l=o.finetuneSettings.exposure.max):(s=-100,l=100):(s=-100,l=100),p=this.createSlider(s,l,d,e)):"hue"===e||"blur"===e||"opacity"===e?(o.finetuneSettings?"hue"===e&&o.finetuneSettings.hue?(s=o.finetuneSettings.hue.min,l=o.finetuneSettings.hue.max):"blur"===e&&o.finetuneSettings.blur?(s=o.finetuneSettings.blur.min,l=o.finetuneSettings.blur.max):"opacity"===e&&o.finetuneSettings.opacity?(s=o.finetuneSettings.opacity.min,l=o.finetuneSettings.opacity.max):(s=0,l=100):(s=0,l=100),p=this.createSlider(s,l,d,e)):"transparency"===e?(s=0,l=100,p=this.createSlider(s,l,d,e)):"straighten"===e&&(s=-45,l=45,p=this.createSlider(s,l,d,e)),p.appendTo("#"+i+"_sliderWrapper"),h.style.left=(parseFloat(r.style.width)-parseFloat(p.width))/2+"px","straighten"===e&&g.Browser.isDevice)&&(a.appendChild(o.createElement("label",{id:i+"_sLabelWrapper",className:"e-ie-straighten-value-span e-ie-finetune-value-span"})).innerHTML=o.transform.straighten.toString()+"°",h.parentElement.classList.add("e-straighten-slider"));"straighten"!==e&&(a.appendChild(o.createElement("label",{id:i+"_finetuneSpan",className:"e-ie-finetune-value-span"})),h.parentElement.classList.add("e-finetune-slider"),"transparency"===e&&g.Browser.isDevice&&h.parentElement.classList.add("e-ie-device-transparency-slider"),this.updateFinetuneSpan(e))},e.prototype.createSlider=function(e,t,o,i){var r=this,a=this.parent,n="straighten"===i?3:1;return new C.Slider({value:o,type:"MinRange",min:e,max:t,step:n,width:g.Browser.isDevice?"180px":"straighten"===i?"200px":"300px",cssClass:"e-slider",change:function(e){if(a.notify("selection",{prop:"setSliderActive",onPropertyChange:!1,value:{bool:!0}}),"transparency"===i){if(a.activeObj.shape){(0,g.isNullOrUndefined)(a.activeObj.imageRatio)&&a.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),a.notify("shape",{prop:"pushActItemIntoObj"});var t=(0,g.extend)({},a.cropObj,{},!0),o={currObj:{}};a.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var n=o.currObj;n.objColl=(0,g.extend)([],a.objColl,[],!0),n.pointColl=(0,g.extend)([],a.pointColl,[],!0),n.afterCropActions=(0,g.extend)([],a.afterCropActions,[],!0);var s={selPointColl:null};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=(0,g.extend)([],s.selPointColl,[],!0),a.objColl.pop(),a.activeObj.opacity=e.value/100,r.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),a.objColl.push(a.activeObj),a.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:t,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),a.notify("selection",{prop:"redrawShape",value:{obj:a.objColl[a.objColl.length-1]}}),r.updateFinetuneSpan(i)}}else"straighten"===i?a.setStraighten(e.value):(a.transform.zoomFactor&&a.transform.zoomFactor<0&&(a.isFinetuning=!0),a.notify("selection",{prop:"setSliding",value:{bool:!0}}),a.setCurrAdjustmentValue(i,e.value),r.updateFinetuneSpan(i),r.enableDisableTbrBtn(),a.isFinetuning=!1)},changed:function(){"transparency"!==i&&"straighten"!==i&&(a.notify("selection",{prop:"setSliding",value:{bool:!1}}),a.notify("draw",{prop:"redrawDownScale"})),a.notify("selection",{prop:"setSliderActive",onPropertyChange:!1,value:{bool:!1}}),"transparency"===i&&setTimeout(function(){a.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1}),a.element.querySelector("#"+a.element.id+"_transparency").click()},50)}})},e.prototype.updateFinetuneSpan=function(e){var t=this.parent,o=t.element.querySelector(".e-ie-finetune-value-span");if(o){var i={adjustmentLevel:null};t.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:i}}),o.innerHTML=Math.round(i.adjustmentLevel[e]).toString()}},e.prototype.applyPreviewFilter=function(){var e=this.parent;(document.querySelector("#"+e.element.id+"_sliderWrapper")||e.currObjType.isFiltered)&&(e.initialAdjustmentValue=this.lowerContext.filter,e.canvasFilter=this.lowerContext.filter,e.currObjType.isFiltered=!1)},e.prototype.unselectBtn=function(){for(var e=this.parent.element.id,t=0,o=["#"+e+"_brightness","#"+e+"_contrast","#"+e+"_hue","#"+e+"_saturation","#"+e+"_opacity","#"+e+"_blur","#"+e+"_exposure"];t<o.length;t++){var i=o[t],r=document.querySelector(i);if(r&&r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},e.prototype.openSlider=function(e){this.unselectBtn(),this.parent.currObjType.isFiltered=!0,this.refreshToolbar("color",null,null,null,e),document.getElementById(this.parent.element.id+"_"+e).classList.add("e-selected-btn")},e.prototype.refreshSlider=function(){var e=this.parent.element.id,t=document.querySelector("#"+e+"_sliderWrapper"),o=document.querySelector(".e-slider"),i=document.querySelector("#"+e+"_headWrapper");i&&(i.style.display="none"),t&&o&&(o.ej2_instances[0].destroy(),t.remove())},e.prototype.unselectFrameBtn=function(){for(var e=this.parent.element.id,t=0,o=["#"+e+"_none","#"+e+"_mat","#"+e+"_line","#"+e+"_inset","#"+e+"_bevel","#"+e+"_hook"];t<o.length;t++){var i=o[t],r=document.querySelector(i);if(r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},e.prototype.updateToolbarItems=function(){var e=this.parent,t=e.element.id;if(e.isImageLoaded&&this.isToolbar()){var o=e.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview"),i=e.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview"),r=e.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview"),a=e.element.querySelector(".e-stroke-text-font-color.e-template .e-dropdownbtn-preview"),n=e.element.querySelector(".e-text-background-color.e-template .e-dropdownbtn-preview"),s=e.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview"),l=e.element.querySelector(".e-shape-stroke-width"),p=e.element.querySelector(".e-shape-rectangle-radius"),h=e.element.querySelector(".e-text-font-family"),d=e.element.querySelector(".e-text-font-size"),c=e.element.querySelector("#"+t+"_bold"),u=e.element.querySelector("#"+t+"_italic"),v=e.element.querySelector("#"+t+"_underline"),f=e.element.querySelector("#"+t+"_strikethrough");if(e.activeObj.strokeSettings&&e.activeObj.textSettings){if((0,g.isNullOrUndefined)(e.activeObj.strokeSettings.strokeWidth)&&(e.activeObj.strokeSettings.strokeWidth=2),(0,g.isNullOrUndefined)(e.activeObj.strokeSettings.outlineWidth)&&(e.activeObj.strokeSettings.outlineWidth=2),o){var m=e.activeObj.strokeSettings.fillColor;""===e.activeObj.strokeSettings.fillColor?o.classList.add("e-nocolor-item"):(o.classList.remove("e-nocolor-item"),o.style.background=m),document.querySelector("#"+t+"_shape_fill")&&((0,g.getComponent)(t+"_shape_fill","colorpicker").value=m)}if(i){m=e.activeObj.strokeSettings.strokeColor;i.style.background=m,document.querySelector("#"+t+"_shape_stroke")&&((0,g.getComponent)(t+"_shape_stroke","colorpicker").value=m)}if(r){m=e.activeObj.strokeSettings.strokeColor;r.style.background=m,document.querySelector("#"+t+"_text_font")&&((0,g.getComponent)(t+"_text_font","colorpicker").value=m)}if(a){m=e.activeObj.strokeSettings.outlineColor;/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$|^[a-zA-Z]+$/.test(e.activeObj.strokeSettings.outlineColor)?(a.classList.remove("e-nocolor-item"),a.style.background=m):a.classList.add("e-nocolor-item"),document.querySelector("#"+t+"_stroke_text")&&((0,g.getComponent)(t+"_stroke_text","colorpicker").value=m)}if(n){m=e.activeObj.strokeSettings.fillColor;""===e.activeObj.strokeSettings.fillColor||"transparent"===e.activeObj.strokeSettings.fillColor?n.classList.add("e-nocolor-item"):(n.classList.remove("e-nocolor-item"),n.style.background=m),document.querySelector("#"+t+"_text_bgColor")&&((0,g.getComponent)(t+"_text_bgColor","colorpicker").value=m)}if(s){m=e.activeObj.strokeSettings.strokeColor;s.style.background=m,document.querySelector("#"+t+"_pen_stroke")&&((0,g.getComponent)(t+"_pen_stroke","colorpicker").value=m);e.notify("freehand-draw",{prop:"getPenOpacity",onPropertyChange:!1,value:{obj:{penOpacity:1}}})}if(h&&(g.Browser.isDevice?h.setAttribute("style","font-family:"+e.activeObj.textSettings.fontFamily.toLowerCase()):h.textContent=e.activeObj.textSettings.fontFamily),d)for(var b=0;b<e.fontSizeColl.length;b++){if(parseInt(e.fontSizeColl[b].text,10)>=Math.round(e.activeObj.textSettings.fontSize)){d.textContent=(b+1).toString();break}if(Math.round(e.activeObj.textSettings.fontSize)<parseInt(e.fontSizeColl[0].text,10)){d.textContent="1";break}if(Math.round(e.activeObj.textSettings.fontSize)>parseInt(e.fontSizeColl[e.fontSizeColl.length-1].text,10)){d.textContent=(e.fontSizeColl.length-1+1).toString();break}}if(c&&(e.activeObj.textSettings.bold?c.classList.add("e-selected-btn"):c.classList.remove("e-selected-btn")),u&&(e.activeObj.textSettings.italic?u.classList.add("e-selected-btn"):u.classList.remove("e-selected-btn")),v&&(e.activeObj.textSettings.underline?v.classList.add("e-selected-btn"):v.classList.remove("e-selected-btn")),f&&(e.activeObj.textSettings.strikethrough?f.classList.add("e-selected-btn"):f.classList.remove("e-selected-btn")),l){var C="text"===e.activeObj.shape?e.activeObj.strokeSettings.outlineWidth:e.activeObj.strokeSettings.strokeWidth,y=Math.round(C).toString();l.textContent=this.getStrokeWidth(y)}if(p){var x=Math.round(e.activeObj.strokeSettings.radius).toString();p.textContent=this.getRectRadius(x)}}}},e.prototype.getStrokeWidth=function(e){var t=parseInt(e,10)/2;return 0===t?this.l10n.getConstant("NoOutline"):t>0&&t<=1?this.l10n.getConstant("XSmall"):t>1&&t<=2?this.l10n.getConstant("Small"):t>2&&t<=3?this.l10n.getConstant("Medium"):t>3&&t<=4?this.l10n.getConstant("Large"):this.l10n.getConstant("XLarge")},e.prototype.getRectRadius=function(e){var t;switch(parseInt(e,10)/2){case 0:t=this.l10n.getConstant("0");break;case 1:t=this.l10n.getConstant("20");break;case 2:t=this.l10n.getConstant("40");break;case 3:t=this.l10n.getConstant("60");break;case 4:t=this.l10n.getConstant("80");break;case 5:t=this.l10n.getConstant("100")}return t},e.prototype.cancelPan=function(){var e=this.parent;e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}});var t=e.element.querySelector(".e-img-pan .e-btn");t&&t.classList.remove("e-selected-btn"),e.pan(!1)},e.prototype.refreshMainToolbar=function(){"main"!==this.currToolbar&&this.refreshToolbar("main")},e.prototype.destroySubComponents=function(){for(var e=this.parent,t=e.element.querySelectorAll("input.e-control"),o=e.element.querySelectorAll("button.e-control"),i=0,r=t.length;i<r;i++)t[i].classList.contains("e-color-picker")&&((0,g.getComponent)(t[i],"color-picker").destroy(),(0,g.detach)((0,g.select)("input#"+t[i].id,e.element)));for(i=0,r=o.length;i<r;i++)o[i].classList.contains("e-dropdown-btn")?((0,g.getComponent)(o[i],"dropdown-btn").destroy(),(0,g.detach)((0,g.select)("button#"+o[i].id,e.element))):o[i].classList.contains("e-btn")&&((0,g.getComponent)(o[i],"btn").destroy(),(0,g.detach)((0,g.select)("button#"+o[i].id,e.element)))},e.prototype.setInitialShapeSettings=function(e){var t=this.parent;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.currObjType.shape=e.item.id,t.activeObj.shape=t.currObjType.shape.toLowerCase(),t.currObjType.isDragging=t.currObjType.isCustomCrop=!1,t.activeObj.shapeDegree=t.transform.degree,t.activeObj.shapeFlip=t.transform.currFlipState,t.activeObj.textFlip=t.transform.currFlipState,t.activeObj.flipObjColl=[];var o={order:null};t.notify("shape",{prop:"getNewOrder",onPropertyChange:!1,value:{obj:o}}),t.activeObj.order=o.order},e.prototype.isToolbarString=function(e){for(var t=!1,o=0;o<e.length;o++)if("string"==typeof e[o]){t=!0;break}return t},e.prototype.excludeItems=function(e){for(var t=[],o=0;o<e.length;o++){var i=this.getIndex(e[o]);-1!==i&&t.push(i)}var r=[];for(o=0;o<this.defToolbarItems.length;o++)"Center"!==this.defToolbarItems[o].align||this.isSameIndex(t,o)||this.defToolbarItems[o].id===this.parent.element.id+"_annotation"||r.push(o);for(o=r.length-1;o>=0;o--)this.defToolbarItems.splice(r[o],1)},e.prototype.isSameIndex=function(e,t){for(var o=0;o<e.length;o++)if(e[o]===t)return!0;return!1},e.prototype.getIndex=function(e){var t=-1,o=!1;"rotateLeft"===e&&(e="rotLeft"),"rotateRight"===e&&(e="rotRight"),"horizontalFlip"===e&&(e="hflip"),"verticalFlip"===e&&(e="vflip"),"arrowStart"===e&&(e="start"),"arrowEnd"===e&&(e="end"),"fontColor"===e&&(e="strokeColor",o=!0);for(var i=0;i<this.defToolbarItems.length;i++){var r=this.defToolbarItems[i].id;if(r&&-1!==r.toLowerCase().indexOf(e.toLowerCase())){t=i;break}}return o&&(e="fontColor"),t},e.prototype.getModuleName=function(){return"toolbar-module"},e.prototype.redactSlider=function(e){var t=this.parent,o=t.element.id,i=t.element.querySelector("#"+o+"_toolbarArea"),r=t.element.querySelector("#"+o+"_contextualToolbarArea");if(r){r.classList.remove("e-hide"),r.style.left=i.offsetLeft+"px";var a=document.querySelector("#"+o+"_contextualToolbarArea"),n=document.querySelector("#"+o+"_headWrapper"),s=document.querySelector("#"+o+"_labelWrapper"),l=document.querySelector("#"+o+"_contextualToolbar");n&&(n.remove(),s.remove()),l&&(l.remove(),this.createContextualToolbar()),s=(n=a.appendChild(t.createElement("div",{id:o+"_headWrapper",className:"e-ie-head-wrapper",styles:"position: relative"}))).appendChild(t.createElement("label",{id:o+"_labelWrapper",className:"e-ie-finetune-slider-label"}));var p="blur"===e?this.l10n.getConstant("Blur"):this.l10n.getConstant("PixelSize");s.textContent=p;var h=n.appendChild(t.createElement("div",{id:o+"_sliderWrapper",className:"e-ie-finetune-slider-wrap"}));n.appendChild(t.createElement("label",{id:o+"_redactSpan",className:"e-ie-redact-value-span"})),h.parentElement.classList.add("e-finetune-slider");var d="blur"===t.activeObj.redactType?t.activeObj.redactBlur:t.activeObj.redactPixelate;if(new C.Slider({tooltip:{placement:"Before",isVisible:!0,showOn:"Focus"},min:10,max:100,step:1,value:d,type:"MinRange",width:g.Browser.isDevice?"130px":"300px",created:function(){t.element.querySelector(".e-ie-redact-value-span").innerText=d.toString()},change:function(e){t.element.querySelector(".e-ie-redact-value-span").innerText=e.value.toString(),"blur"===t.activeObj.redactType?t.activeObj.redactBlur=t.tempRedactBlur=e.value:"pixelate"===t.activeObj.redactType&&(t.activeObj.redactPixelate=t.tempRedactPixel=e.value),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:t.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}})},changed:function(){setTimeout(function(){t.notify("undo-redo",{prop:"updateUndoRedoStack",onPropertyChange:!1})},50)}}).appendTo("#"+o+"_sliderWrapper"),g.Browser.isDevice){var c=r.offsetHeight+1,u=t.element.querySelector("#"+o+"_customizeWrapper");this.isFrameToolbar&&u&&(c=u.offsetHeight+2);var v=t.element.querySelector("#"+o+"_canvasWrapper").offsetHeight;r.style.top=this.toolbarHeight+1+v-c+"px"}else r.style.top=t.element.querySelector("#"+t.element.id+"_toolbarArea").clientHeight+"px"}},e}(),_=f(674),q=f(74),V=function(){function e(){}return e.evaluateCondition=function(e,t){try{return"field"in e&&"operator"in e&&"value"in e?this.evaluateSimpleRule(e,t):"condition"in e&&"rules"in e&&this.evaluateCompositeRule(e,t)}catch(e){return!1}},e.evaluateSimpleRule=function(e,t){try{var o=t[e.field],i=e.operator.toLowerCase();if(void 0===o){if(-1===["equal","equals","notequal","notequals","isempty","isnotempty"].indexOf(i))return!1}var r=Array.isArray(o),a=new g.Internationalization;switch(i){case"equal":case"equals":return o===e.value;case"notequal":case"notequals":return o!==e.value;case"startswith":return o.startsWith(e.value);case"doesnotstartswith":return!o.startsWith(e.value);case"greaterthan":case"lessthan":case"greaterthanorequal":case"lessthanorequal":var n=Number(o),s=Number(e.value);return!Number.isNaN(n)&&!Number.isNaN(s)&&("greaterthan"===i?n>s:"lessthan"===i?n<s:"greaterthanorequal"===i?n>=s:n<=s);case"dategreaterthan":case"datelessthan":var l=a.parseDate(o,{format:"MM/dd/yyyy"}),p=a.parseDate(e.value,{format:"MM/dd/yyyy"});return null!==l&&null!==p&&("dategreaterthan"===i?l>p:"datelessthan"===i?l<p:l<=p);case"timegreaterthan":case"timelessthan":var h=a.parseDate(o,{format:"hh:mm a",type:"time"}),d=a.parseDate(e.value,{format:"hh:mm a",type:"time"});if(null!==h&&null!==d){if("timegreaterthan"===i)return h>d;if("timelessthan"===i)return h<d}return!1;case"datetimegreaterthan":case"datetimelessthan":var c=a.parseDate(o,{format:"MM/dd/yyyy hh:mm a",type:"dateTime"}),u=a.parseDate(e.value,{format:"MM/dd/yyyy hh:mm a",type:"dateTime"});if(null!==c&&null!==u){if("datetimegreaterthan"===i)return c>u;if("datetimelessthan"===i)return c<u}return!1;case"contains":return r?"string"==typeof e.value&&-1!==e.value.indexOf(",")?e.value.split(",").map(function(e){return e.trim()}).some(function(e){return-1!==o.indexOf(e)}):-1!==o.indexOf(e.value):-1!==String(o).indexOf(String(e.value));case"notcontains":return r?"string"==typeof e.value&&-1!==e.value.indexOf(",")?!e.value.split(",").map(function(e){return e.trim()}).some(function(e){return-1!==o.indexOf(e)}):-1===o.indexOf(e.value):-1===String(o).indexOf(String(e.value));case"isempty":return r?0===o.length:!o||0===String(o).length;case"isnotempty":return r?o.length>0:!!o&&String(o).length>0;default:return!1}}catch(e){return!1}},e.evaluateCompositeRule=function(e,t){var o=this;try{if(!Array.isArray(e.rules)||0===e.rules.length)return!1;var i=e.condition.toLowerCase();return"and"===i?e.rules.every(function(e){return o.evaluateCondition(e,t)}):"or"===i&&e.rules.some(function(e){return o.evaluateCondition(e,t)})}catch(e){return!1}},e.isFieldVisible=function(e,t){try{return!e||!e.visibleWhen||this.evaluateCondition(e.visibleWhen,t)}catch(e){return!0}},e.isFieldReadOnly=function(e,t){try{return!(!e||!e.readOnlyWhen)&&this.evaluateCondition(e.readOnlyWhen,t)}catch(e){return!1}},e.isFieldDisabled=function(e,t){try{return!(!e||!e.disabledWhen)&&this.evaluateCondition(e.disabledWhen,t)}catch(e){return!1}},e.isFieldHidden=function(e,t){try{return!(!e||!e.hideWhen)&&this.evaluateCondition(e.hideWhen,t)}catch(e){return!1}},e.isFieldRequired=function(e,t){try{return!(!e||!e.requiredWhen)&&this.evaluateCondition(e.requiredWhen,t)}catch(e){return!1}},e.getConditionalValue=function(e,t){try{if(!e||!e.setValueWhen)return;return this.evaluateCondition(e.setValueWhen.condition,t)?e.setValueWhen.value:void 0}catch(e){return}},e.evaluateConditionalDataRules=function(e,t){if(!e||!Array.isArray(e))return-1;for(var o=0;o<e.length;o++){var i=e[o];if(this.evaluateCondition(i.condition,t))return o}return-1},e.getChoiceBasedOptions=function(e,t,o,i){try{var r=o&&o[i];if(null==r)return e.showAllWhenNotMapped?t:[];var a=String(r);return a in e.choiceMapping?e.choiceMapping[a].filter(function(e){return-1!==t.indexOf(e)}):e.showAllWhenNotMapped?t:[]}catch(e){return t}},e}(),Z=function(){return Z=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Z.apply(this,arguments)},G=function(e){return e+"_"+Date.now()+"_"+Math.floor(1e3*Math.random())};function J(e){for(var t=new Map,o=0,i=Object.keys(e.properties);o<i.length;o++){var r=i[o];t.set(r,e.properties[r])}var a,n=new Set,s=function(e){for(var o=[],i=function(e){if("field"===e.type){var i=e;if(n.has(i.propertyId))return"continue";n.add(i.propertyId);var r=t.get(i.propertyId);if(r)o.push(Q(r));else{var a={id:i.propertyId||G("textbox"),name:(f="",f+"_"+Math.floor(1e3*Math.random())),type:"textbox",label:"Unknown Field",_configured:!0};o.push(a)}}else if("table"===e.type){var l=e,p=Z({id:l.id||G("table"),name:l.name,type:"table",label:l.label||"Table",cssClass:l.cssClass,hideBorders:l.hideBorders,rows:l.rows,columns:l.cols,columnWidths:l.columnWidths,tableCells:[],_configured:!0},l.conditions?{conditions:l.conditions}:{});l.cells.forEach(function(e){var t=[];e.forEach(function(e){var o=s(e.children);t.push(o)}),p.tableCells.push(t)}),o.push(p)}else if("panel"===e.type){var h=e,d=Z({id:h.id||G("panel"),type:"panel",name:h.name,cssClass:h.cssClass,hideBorders:h.hideBorders,hideLabel:h.hideLabel,label:h.label||"Panel",children:s(h.children),_configured:!0},h.conditions?{conditions:h.conditions}:{});o.push(d)}else if("tabs"===e.type){var c=e,u=Z({id:c.id||G("tabs"),type:"tabs",name:c.name,label:c.label||"Tabs",cssClass:c.cssClass,tabOptions:c.tabOptions,tabItems:[],_configured:!0},c.conditions?{conditions:c.conditions}:{});c.tabs.forEach(function(e){u.tabItems.push({header:e.header,content:s(e.children)})}),o.push(u)}else if("card"===e.type){var g=e,v=Z({id:g.id||G("card"),type:"card",name:g.name,label:g.label||"Card",cssClass:g.cssClass,hideLabel:g.hideLabel,children:s(g.children),_configured:!0},g.conditions?{conditions:g.conditions}:{});void 0!==g.cardTitle&&(v.cardTitle=g.cardTitle),void 0!==g.cardSubtitle&&(v.cardSubtitle=g.cardSubtitle),o.push(v)}var f},r=0,a=e;r<a.length;r++){i(a[r])}return o};e.layout&&0!==e.layout.length?a=s(e.layout):a=Object.keys(e.properties).map(function(t){return Q(e.properties[t])});return Z({version:e.version,components:a},e.settings?{settings:e.settings}:{})}function Q(e){var t=void 0!==e.options&&e.options.length>0,o={id:e.id||G(e.widget||K(e.type,e.format,t)),name:e.name,type:e.widget||K(e.type,e.format,t),label:e.label||e.id},i=new Set(["id","type","name","label","format","widget","defaultValue","required","options","expressionValue","minLength","maxLength","minimum","maximum","minValue","maxValue","minDate","maxDate","minTime","maxTime","regex","pattern","content","buttonType","textboxType"]);return Object.keys(e).forEach(function(t){i.has(t)||"id"===t||"name"===t||"type"===t||"label"===t||(o[t]=e[t])}),void 0!==e.defaultValue&&(o.defaultValue=e.defaultValue),void 0!==e.expressionValue&&(o.expressionValue=e.expressionValue),void 0!==e.required&&(o.required=e.required),void 0!==e.content&&(o.content=e.content),void 0!==e.buttonType&&(o.buttonType=e.buttonType),void 0!==e.textboxType&&(o.textboxType=e.textboxType),void 0!==e.options&&(o.options=e.options),void 0!==e.minLength&&(o.minLength=e.minLength),void 0!==e.maxLength&&(o.maxLength=e.maxLength),void 0!==e.minValue&&(o.minValue=e.minValue),void 0!==e.maxValue&&(o.maxValue=e.maxValue),void 0!==e.minDate&&(o.minDate=e.minDate),void 0!==e.maxDate&&(o.maxDate=e.maxDate),void 0!==e.minTime&&(o.minTime=e.minTime),void 0!==e.maxTime&&(o.maxTime=e.maxTime),void 0!==e.pattern&&(o.regex=e.pattern),o}function K(e,t,o){return"string"===e?"date"===t?"date":"date-time"===t?"dateTime":"time"===t?"time":"email"===t?"email":"url"===t?"url":o?"dropdown":"textbox":"number"===e?"number":"boolean"===e?"checkbox":"array"===e?"multiselect":"button"===e?"button":"message"===e?"message":"sign"===e?"signature":"image"===e?"imageEditor":"file"===e?"fileUpload":"color"===e?"colorPicker":"grid"===e?"dataGrid":"textbox"}var $=function(){function e(){this.supportedFunctions=["SUM","AVG","MIN","MAX","COUNT","ROUND","FLOOR","CEIL","ABS","SQRT","UPPER","LOWER","CONCAT","LENGTH","TRIM","SUBSTRING","TODAY","AGE","DATEFORMAT","DATEDIFF","ADDDAYS","SUBDAYS","INCLUDES","CONTAINS","ISNAN","SUPPORTEDVALUESOF","TOSTRING","DATE","GETTIME","EVERY","SOME"],this.availableFields=new Map}return e.prototype.setAvailableFields=function(e){var t=this;this.availableFields.clear(),e.forEach(function(e){t.availableFields.set(e.name,e)})},e.prototype.validateFieldOperations=function(e){var t=[];if(0===this.availableFields.size)return t;for(var o,i=["-","*","/","%","^"],r=["-","*","/","%","^","+"],a=new Set,n=/(\{[^}]+\})/g;null!==(o=n.exec(e));){var s=o[0],l=s.slice(1,-1),p=this.availableFields.get(l);if(p){var h=o.index,d=h+s.length,c=e.substring(Math.max(0,h-10),h),u=e.substring(d,Math.min(e.length,d+10)),g=c.replace(/\s+$/,"").slice(-1),v=u.replace(/^\s+/,"").charAt(0),f=c.replace(/\s+$/,""),m=u.replace(/^\s+/,""),b=h-(c.length-f.length)-1,C=d+(u.length-m.length);if("string"===p.type&&!p.format){if(g&&-1!==i.indexOf(g)){var y=b+":"+g;a.has(y)||(t.push("Cannot perform '"+g+"' operation on string field '{"+l+"}'"),a.add(y))}if(v&&-1!==i.indexOf(v)){y=C+":"+v;a.has(y)||(t.push("Cannot perform '"+v+"' operation on string field '{"+l+"}'"),a.add(y))}}if("date"===p.format||"date-time"===p.format||"time"===p.format){if(g&&-1!==r.indexOf(g)){y=b+":"+g;a.has(y)||(t.push("Cannot perform '"+g+"' operation on date field '{"+l+"}'"),a.add(y))}if(v&&-1!==r.indexOf(v)){y=C+":"+v;a.has(y)||(t.push("Cannot perform '"+v+"' operation on date field '{"+l+"}'"),a.add(y))}}}}return t},e.prototype.validate=function(e){var t=[];if(!e||""===e.trim())return{valid:!0,errors:[]};(e.match(/\{/g)||[]).length!==(e.match(/\}/g)||[]).length&&t.push("Unbalanced braces in expression"),(e.match(/\(/g)||[]).length!==(e.match(/\)/g)||[]).length&&t.push("Unbalanced parentheses in expression");for(var o,i=/(\w+)\s*\(/g;null!==(o=i.exec(e));){var r=o[1].toUpperCase();r===r.toUpperCase()&&-1===this.supportedFunctions.indexOf(r)&&t.push("Unknown function: "+r)}var a=this.validateFieldOperations(e);return t.push.apply(t,a),{valid:0===t.length,errors:t}},e.prototype.compile=function(e,t){void 0===t&&(t={});try{if(t.availableFields&&Array.isArray(t.availableFields)&&this.setAvailableFields(t.availableFields),!this.validate(e).valid)return function(){return null};var o=e;return o=this.compileFieldReferences(o),o=t.isCustomValidation?this.compileInputReferences(o):o,o=this.compileBareFunctionCalls(o),o=this.compileMatrixExpressions(o),function(e){try{return new Function("context","\n try {\n return "+o+";\n } catch (e) {\n return null;\n }\n ")(e)}catch(e){return null}}}catch(e){return function(){return null}}},e.prototype.compileMatrixExpressions=function(e){var t=e,o=["PI","TRUE","FALSE","NULL","UNDEFINED","Math"],i=["SUM","AVG","MIN","MAX","COUNT","ROUND","FLOOR","CEIL","ABS","SQRT","UPPER","LOWER","CONCAT","LENGTH","TRIM","SUBSTRING","TODAY","AGE","DATEFORMAT","DATEDIFF","ADDDAYS","SUBDAYS"];return t=t.replace(/\$?\{([^}]+)\}/g,function(e,t){var r=t;return i.forEach(function(e){var t=new RegExp("(?<!context\\.)\\b"+e+"\\b(?=\\s*\\()","g");r=r.replace(t,"context."+e)}),o.forEach(function(e){var t=new RegExp("\\b"+e+"\\b","g");r=r.replace(t,"context."+e)}),"("+r+")"})},e.prototype.compileBareFunctionCalls=function(e){var t=e;return["SUM","AVG","MIN","MAX","COUNT","ROUND","FLOOR","CEIL","ABS","SQRT","UPPER","LOWER","CONCAT","LENGTH","TRIM","SUBSTRING","TODAY","AGE","DATEFORMAT","DATEDIFF","ADDDAYS","SUBDAYS"].forEach(function(e){var o=new RegExp("(?<!context\\.)\\b"+e+"\\b(?=\\s*\\()","g");t=t.replace(o,"context."+e)}),t},e.prototype.compileFieldReferences=function(e){var t=e;return t=t.replace(/\{([^{}]+)\}/g,function(e,t){return t.startsWith("\\")&&t.endsWith("\\")?e:"context['"+t.replace(/\./g,"'].[")+"']"})},e.prototype.compileInputReferences=function(e){var t=[],o=e,i=o=(o=(o=o.replace(/(['"`])(?:(?=(\\?))\2.)*?\1/g,function(e){return t.push(e),"__STRING_"+(t.length-1)+"__"})).replace(/(?<!context\[')\binput\./g,"context['input'].")).replace(/(?<!context\[')\binput\b(?!\s*[(\.])/g,"context['input']");return t.forEach(function(e,t){i=i.replace("__STRING_"+t+"__",e)}),i},e}(),ee=function(){function e(){this.escapedBracePattern=/\\{.*?\\}/g}return e.prototype.extractFieldReferences=function(e){if(!e)return[];for(var t,o=new Set,i=e.replace(this.escapedBracePattern,""),r=/\{([^{}]+)\}/g;null!==(t=r.exec(i));){var a=t[1].trim();if(!this.isFunctionCall(a)&&!this.isOperator(a)){var n=a.split(/[.\[\]]/)[0].trim();n&&!this.isKeyword(n)&&o.add(n)}}for(var s=/\$\{([^}]+)\}/g;null!==(t=s.exec(i));)for(var l=t[1],p=/\b([a-zA-Z_][a-zA-Z0-9_]*)\b(?!\s*[(\.])/g,h=void 0;null!==(h=p.exec(l));){var d=h[1];this.isKeyword(d)||"Math"===d||o.add(d)}return Array.from(o)},e.prototype.buildGraph=function(e){for(var t={},o=0,i=Object.keys(e);o<i.length;o++){var r=i[o],a=this.extractFieldReferences(e[r]);t[r]=a}return t},e.prototype.detectCircularDependencies=function(e){for(var t=new Set,o=new Set,i=[],r=function(a,n){t.add(a),o.add(a),n.push(a);for(var s=0,l=e[a]||[];s<l.length;s++){var p=l[s];if(t.has(p)){if(o.has(p)){var h=n.indexOf(p);i.push(n.slice(h).concat([p]))}}else r(p,n.slice())}o.delete(a)},a=0,n=Object.keys(e);a<n.length;a++){var s=n[a];t.has(s)||r(s,[])}return i},e.prototype.getTopologicalOrder=function(e){for(var t=new Set,o=[],i=function(r){if(!t.has(r)){t.add(r);for(var a=0,n=e[r]||[];a<n.length;a++){var s=n[a];e[s]&&i(s)}o.push(r)}},r=0,a=Object.keys(e);r<a.length;r++){var n=a[r];i(n)}return o},e.prototype.isFunctionCall=function(e){return/^\w+\s*\(/.test(e)},e.prototype.isOperator=function(e){return/^[+\-*/()=!<>&|]/.test(e)},e.prototype.isKeyword=function(e){return-1!==["PI","TRUE","FALSE","NULL","UNDEFINED","and","or","in"].indexOf(e.toUpperCase())},e}(),te=function(){return te=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},te.apply(this,arguments)},oe=function(){function e(){this.evaluationCache=new Map,this.compiledFunctions=new Map,this.parser=new $,this.dependencyTracker=new ee}return e.prototype.evaluate=function(e,t,o,i){void 0===o&&(o={}),void 0===i&&(i=!1);try{if(!e||""===e.trim())return null;var r=o.timeout,a=void 0===r?5e3:r,n=o.maxDepth,s=void 0===n?10:n,l=o.locale,p=void 0===l?"en-US":l,h=o.throwOnError,d=void 0!==h&&h,c=this.getCacheKey(e,t);if(!i&&this.evaluationCache.has(c))return this.evaluationCache.get(c);var u=this.compiledFunctions.get(e);u||(u=this.parser.compile(e,{timeout:a,maxDepth:s,locale:p,isCustomValidation:i}),this.compiledFunctions.set(e,u));var g=this.buildContext(t),v=Date.now(),f=u(g);if(Date.now()-v>a){var m=new Error("Expression evaluation exceeded timeout of "+a+"ms");if(d)throw m;return null}return this.evaluationCache.set(c,f),f}catch(m){if(o.throwOnError)throw m;return null}},e.prototype.extractDependencies=function(e){return e?this.dependencyTracker.extractFieldReferences(e):[]},e.prototype.buildDependencyGraph=function(e){var t=this,o={};return e.forEach(function(e){if(e.expressionValue){var i=t.extractDependencies(e.expressionValue);o[e.name]=i}}),o},e.prototype.detectCircularDependencies=function(e){for(var t=new Set,o=new Set,i=[],r=function(a,n){t.add(a),o.add(a),n.push(a);for(var s=0,l=e[a]||[];s<l.length;s++){var p=l[s];if(t.has(p)){if(o.has(p)){var h=n.indexOf(p);i.push(n.slice(h).concat([p]))}}else r(p,n.slice())}o.delete(a)},a=0,n=Object.keys(e);a<n.length;a++){var s=n[a];t.has(s)||r(s,[])}return i},e.prototype.getTopologicalOrder=function(e){for(var t=new Set,o=[],i=function(r){if(!t.has(r)){t.add(r);for(var a=0,n=e[r]||[];a<n.length;a++){var s=n[a];i(s)}o.push(r)}},r=0,a=Object.keys(e);r<a.length;r++){var n=a[r];i(n)}return o},e.prototype.clearCache=function(){this.evaluationCache.clear(),this.compiledFunctions.clear()},e.prototype.getCacheKey=function(e,t){return e+":"+JSON.stringify(t)},e.prototype.buildContext=function(e){var t=new g.Internationalization,o=t.getDateFormat({format:"MM/dd/yyyy",type:"date"});return te({},e,{PI:Math.PI,TRUE:!0,FALSE:!1,NULL:null,UNDEFINED:void 0,Math,SUM:function(e){return Array.isArray(e)?e.reduce(function(e,t){return Number(e)+Number(t)},0):0},AVG:function(e){return Array.isArray(e)&&0!==e.length?e.reduce(function(e,t){return Number(e)+Number(t)},0)/e.length:0},MIN:function(e){return Array.isArray(e)&&e.length>0?Math.min.apply(Math,e.map(Number)):0},MAX:function(e){return Array.isArray(e)&&e.length>0?Math.max.apply(Math,e.map(Number)):0},COUNT:function(e){return Array.isArray(e)?e.length:0},ROUND:function(e,t){return void 0===t&&(t=0),Math.round(e*Math.pow(10,t))/Math.pow(10,t)},FLOOR:Math.floor,CEIL:Math.ceil,ABS:Math.abs,SQRT:Math.sqrt,UPPER:function(e){return String(e).toUpperCase()},LOWER:function(e){return String(e).toLowerCase()},CONCAT:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.map(String).join("")},LENGTH:function(e){return String(e).length},TRIM:function(e){return String(e).trim()},SUBSTRING:function(e,t,o){return void 0!==o?String(e).substr(t,o):String(e).substr(t)},TODAY:function(){return o(new Date)},AGE:function(e){var t="string"==typeof e?new Date(e):e,o=new Date,i=o.getFullYear()-t.getFullYear(),r=o.getMonth()-t.getMonth();return(r<0||0===r&&o.getDate()<t.getDate())&&i--,i},DATEFORMAT:function(e,o){var i="string"==typeof e?new Date(e):e;return t.getDateFormat({format:o,type:"date"})(i)},DATEDIFF:function(e,t){var o="string"==typeof e?new Date(e):e,i="string"==typeof t?new Date(t):t;return Math.floor((i.getTime()-o.getTime())/864e5)},ADDDAYS:function(e,t){var i=new Date(e);return i.setDate(i.getDate()+Number(t)),o(i)},SUBDAYS:function(e,t){var i=new Date(e);return i.setDate(i.getDate()-Number(t)),o(i)}})},e}(),ie=(function(){function e(){this.supportedFunctions=["SUM","AVG","MIN","MAX","COUNT","ROUND","FLOOR","CEIL","ABS","SQRT","UPPER","LOWER","CONCAT","LENGTH","TRIM","SUBSTRING","TODAY","AGE","DATEFORMAT","DATEDIFF","ADDDAYS","SUBDAYS"],this.keywords=["PI","TRUE","FALSE","NULL","UNDEFINED","and","or","in"]}e.prototype.validate=function(e,t){var o=[];if(!e||""===e.trim())return o;var i=this.validateSyntax(e);o.push.apply(o,i);var r=this.validateFieldReferences(e,t);o.push.apply(o,r);var a=this.validateFunctionCalls(e);o.push.apply(o,a);var n=this.validateFieldOperations(e,t);return o.push.apply(o,n),o},e.prototype.validateFieldOperations=function(e,t){var o=[];if(!Array.isArray(t)||0===t.length)return o;if("string"==typeof t[0])return o;var i=new Map;if(t.forEach(function(e){e&&"object"==typeof e&&e.name&&i.set(e.name,e)}),0===i.size)return o;for(var r,a=new Set,n=/(\{[^}]+\})/g,s=["-","*","/","%","^"],l=["-","*","/","%","^","+"];null!==(r=n.exec(e));){var p=r[0],h=p.slice(1,-1),d=i.get(h);if(d){var c=r.index,u=c+p.length,g=e.substring(Math.max(0,c-10),c),v=e.substring(u,Math.min(e.length,u+10)),f=g.replace(/\s+$/,"").slice(-1),m=v.replace(/^\s+/,"").charAt(0),b=g.replace(/\s+$/,""),C=v.replace(/^\s+/,""),y=c-(g.length-b.length)-1,x=u+(v.length-C.length);if("string"===d.type&&!d.format){if(f&&-1!==s.indexOf(f)){var P=y+":"+f;a.has(P)||(o.push({type:"InvalidOperation",message:"Cannot perform '"+f+"' operation on string field '{"+h+"}'"}),a.add(P))}if(m&&-1!==s.indexOf(m)){P=x+":"+m;a.has(P)||(o.push({type:"InvalidOperation",message:"Cannot perform '"+m+"' operation on string field '{"+h+"}'"}),a.add(P))}}if("date"===d.format||"date-time"===d.format||"time"===d.format){if(f&&-1!==l.indexOf(f)){P=y+":"+f;a.has(P)||(o.push({type:"InvalidOperation",message:"Cannot perform '"+f+"' operation on date field '{"+h+"}'"}),a.add(P))}if(m&&-1!==l.indexOf(m)){P=x+":"+m;a.has(P)||(o.push({type:"InvalidOperation",message:"Cannot perform '"+m+"' operation on date field '{"+h+"}'"}),a.add(P))}if("+"===m){var w=v.replace(/^\s+/,"").substring(1).trim(),j=/^\{[^}]+\}/.test(w)&&i.get(w.slice(1,-1))&&"number"===i.get(w.slice(1,-1)).type,S=/^\d+/.test(w);if(!j&&!S){P=x+":"+m;a.has(P)||(o.push({type:"InvalidOperation",message:"Date field '{"+h+"}' can only be used with +number or +{numberField}, not '"+m+w.substring(0,10)+"'"}),a.add(P))}}if("+"===f){var O=g.replace(/\s+$/,""),T=O.substring(0,O.length-1).trim();j=/\{[^}]+\}$/.test(T)&&i.get(T.slice(T.lastIndexOf("{")+1,-1))&&"number"===i.get(T.slice(T.lastIndexOf("{")+1,-1)).type,S=/\d+$/.test(T);if(!j&&!S){P=y+":"+f;a.has(P)||(o.push({type:"InvalidOperation",message:"Date field '{"+h+"}' can only be used with +number or +{numberField}"}),a.add(P))}}}}}return o},e.prototype.validateSyntax=function(e){var t=[];return(e.match(/\{/g)||[]).length!==(e.match(/\}/g)||[]).length&&t.push({type:"SyntaxError",message:"Unbalanced braces in expression"}),(e.match(/\(/g)||[]).length!==(e.match(/\)/g)||[]).length&&t.push({type:"SyntaxError",message:"Unbalanced parentheses in expression"}),(e.match(/\$\{/g)||[]).length>(e.match(/\}/g)||[]).length&&t.push({type:"SyntaxError",message:"Unbalanced ${ } in expression"}),t},e.prototype.validateFieldReferences=function(e,t){var o=[];if(!t||0===t.length)return o;var i,r,a=/\{([^{}]+)\}/g;for(r="string"==typeof t[0]?new Set(t):new Set(t.map(function(e){return e.name}));null!==(i=a.exec(e));){var n=i[1].trim();if(!this.isFunctionCall(n)&&!this.isMathExpression(n)){var s=n.split(/[.\[\]]/)[0].trim();s&&-1===this.keywords.indexOf(s.toUpperCase())&&(r.has(s)||o.push({type:"UndefinedField",message:"Field '"+s+"' is not defined in the form",field:s}))}}return o},e.prototype.validateFunctionCalls=function(e){for(var t,o=[],i=/(\w+)\s*\(/g;null!==(t=i.exec(e));){var r=t[1];r===r.toUpperCase()&&-1===this.supportedFunctions.indexOf(r)&&o.push({type:"InvalidFunction",message:"Unknown function: '"+r+"'. Supported functions: "+this.supportedFunctions.join(", ")})}return o},e.prototype.isFunctionCall=function(e){return/^\w+\s*\(/.test(e)},e.prototype.isMathExpression=function(e){return/[\+\-\*\/\%\=\<\>\!\&\|\^\~\s\d]/.test(e)}}(),{EMAIL:/^(?!.*\.\.)[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/,URL:/^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(\/[^\s]*)?$/,DATE_ISO:/^([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/,DIGITS:/^[0-9]*$/,PHONE:/^[+]?[0-9]{9,13}$/,CREDIT_CARD:/^\d{13,16}$/}),re=function(e){return{primary:"e-primary",flat:"e-flat",information:"e-info",error:"e-danger",success:"e-success",warning:"e-warning"}[e||"primary"]||"e-primary"},ae=function(e){return"submit"===e||"reset"===e?e:"button"},ne=function(e){return{Left:"flex-start",Right:"flex-end",Center:"center"}[e||"Left"]||"flex-start"};var se=function(e){switch(e){case"WebApiAdaptor":return new q.WebApiAdaptor;case"ODataV4Adaptor":return new q.ODataV4Adaptor;default:return new q.UrlAdaptor}},le=new oe,pe=function(e,t,o){if("string"!=typeof e||!/{[^}]+}/.test(e))return e;var i=o?function(e,t){var o={},i=function(t){t.forEach(function(t){t.name&&t.id in e&&(o[t.name]=e[t.id]),t.children&&i(t.children),t.tabItems&&t.tabItems.forEach(function(e){return e.content&&i(e.content)}),t.tableCells&&t.tableCells.forEach(function(e){return e.forEach(function(e){return i(e)})})})};return i(t),o}(t,o):t;try{var r=le.evaluate(e,i);return null!=r?String(r):""}catch(t){return e}},he=function(e,t,o){return e&&"object"==typeof e&&!Array.isArray(e)&&"lookup"===e.type&&o?o&&o.length>0?o:[]:e&&"object"==typeof e&&!Array.isArray(e)&&"url"===e.type?t.length>0?t:[]:Array.isArray(e)?e:e&&"object"==typeof e&&!Array.isArray(e)&&"raw"===e.type&&Array.isArray(e.data)?e.data:[]};var de=function(){function e(){}return e.fetch=function(e,t,o,i){if(!(e&&"object"==typeof e&&!Array.isArray(e)&&"url"===e.type&&e.url))return Promise.resolve({id:t,options:[]});var r=e;return new Promise(function(e){try{var a={};r.headers&&Array.isArray(r.headers)&&r.headers.forEach(function(e){e.key&&e.key.trim()&&(a[e.key]=e.value)});var n=new q.DataManager({url:r.url,adaptor:se(r.adaptorType),headers:Object.keys(a).length?a:void 0}),s=new q.Query;if(r.search&&r.search.enabled&&r.search.fields&&r.search.fields.length>0){var l=r.search.key||"search",p=o?pe(l,o,i):/[{}]/.test(l)?"":l;s=s.search(p,r.search.fields)}if(r.sort&&r.sort.enabled&&r.sort.field){var h="descending"===r.sort.direction?"descending":"ascending";s=s.sortBy(r.sort.field,h)}r.filters&&Array.isArray(r.filters)&&r.filters.length>0&&r.filters.forEach(function(e){if(e.field&&e.operator&&void 0!==e.value&&""!==e.value){var t=o?pe(e.value,o,i):/[{}]/.test(e.value)?"":e.value;""!==t&&(s=s.where(e.field,e.operator,t))}}),r.queryParams&&Object.keys(r.queryParams).forEach(function(e){s=s.addParams(e,r.queryParams[e])}),r.skip&&(s=s.skip(r.skip)),r.take&&(s=s.take(r.take));var d=!1,c=setTimeout(function(){d=!0,e({id:t,options:[]})},15e3);n.executeQuery(s).then(function(o){if(!d){clearTimeout(c);var i,a=o.result;r.dataPath&&(a=function(e,t){if(!t||null==e)return e;for(var o=e,i=0,r=t.split(/\.(?![^\[]*\])/);i<r.length;i++){var a=r[i];if(null==o)return null;var n=a.match(/^(\w*)\[(\d+)\]$/);if(n){var s=n[1],l=parseInt(n[2]);o=s?o[s]&&o[s][l]:o[l]}else o=o[a]}return o}(a,r.dataPath)),i=Array.isArray(a)?a:"string"==typeof a?[a]:[],e({id:t,options:i})}}).catch(function(o){d||(clearTimeout(c),e({id:t,options:[]}))})}catch(o){e({id:t,options:[]})}})},e}();var ce=function(){function e(e){this.checkboxes=[],this.component=e.component,this.formState=e.formState,this.onChangeCb=e.onChange,this.optionRef=e.optionRef,this.enableRtl=e.enableRtl,this.target=e.target,this.container=null,this.itemsContainer=null,this.ref=e.ref}return e.prototype.getSelectedItems=function(){var e=this.formState?this.formState.values[this.component.id]:(0,g.isNullOrUndefined)(this.valueProp())?this.component.defaultValue:this.valueProp();return Array.isArray(e)?e:[]},e.prototype.valueProp=function(){return this._value},e.prototype.setValue=function(e){this._value=e},e.prototype.handleCheckboxChange=function(e,t){var o=this.getSelectedItems(),i=t?o.concat([e]):o.filter(function(t){return t!==e});this.formState&&this.onChangeCb(i)},Object.defineProperty(e.prototype,"sizeCssClass",{get:function(){return""+(this.component.cssClass||"")+("Small"===this.component.size?" e-small":"Bigger"===this.component.size?" e-bigger":"")},enumerable:!0,configurable:!0}),e.prototype.render=function(e){var t=this,o=this.component,i=o.label&&o.required?o.label+" *":o.label||"",r=e||this.target,a=document.createElement("div");a.className=("checkbox-group "+(o.cssClass||"")).trim(),a.setAttribute("role","group"),a.setAttribute("aria-label",i),a.title=o.tooltip||"";var n,s=(n=o.htmlAttributes)?Array.isArray(n)?n.reduce(function(e,t){return t&&t.key&&void 0!==t.value&&(e[t.key]=t.value),e},{}):n:{};Object.keys(s).forEach(function(e){"class"!==e&&"className"!==e&&"style"!==e&&a.setAttribute(e,String(s[e]))});var l="display:flex;flex-direction:"+("row"===o.layoutDirection?"row":"column")+";gap:"+(o.gap||"8px")+";align-items:flex-start;";a.setAttribute("style",l);var p=document.createElement("div");p.className="checkbox-group-items";var h="display:flex;flex-direction:"+("row"===o.layoutDirection?"row":"column")+";flex-wrap:wrap;gap:"+(o.gap||"2px")+";width:100%;";p.setAttribute("style",h);var d=Array.isArray(o.options)?o.options:["Option 1"],c=this.getSelectedItems();return d.forEach(function(e,i){var r="string"==typeof e?e:null!=e.value?e.value:null!=e.label?e.label:e.key,a="string"==typeof e?e:null!=e.label?e.label:null!=e.value?e.value:String(r),n=document.createElement("input");p.appendChild(n);var l=new y.CheckBox({label:a,enableRtl:t.enableRtl,checked:-1!==c.indexOf(r),disabled:!!o.disabled,labelPosition:o.checkboxLabelPosition||"After",cssClass:t.sizeCssClass.trim(),htmlAttributes:s,change:function(e){t.handleCheckboxChange(r,e.checked)}});l.appendTo(n),t.ref(l,i);var h=n.querySelector('input[type="checkbox"]');h&&(h.id=t.component.id+"_"+i),t.optionRef&&t.optionRef(l,i),t.checkboxes.push(l)}),a.appendChild(p),r&&r.appendChild(a),this.container=a,this.itemsContainer=p,a},e.prototype.refreshSelection=function(){var e=this,t=this.getSelectedItems();(Array.isArray(this.component.options)?this.component.options:["Option 1"]).forEach(function(o,i){var r="string"==typeof o?o:null!=o.value?o.value:null!=o.label?o.label:o.key,a=e.checkboxes[i];a&&(a.checked=-1!==t.indexOf(r))})},e.prototype.destroy=function(){for(var e=0,t=this.checkboxes;e<t.length;e++){var o=t[e];try{o.destroy()}catch(e){}}this.checkboxes=[],this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=null,this.itemsContainer=null},e.prototype.setOptions=function(e){var t=this;if(this.component.options=e,this.itemsContainer){for(var o=0,i=this.checkboxes;o<i.length;o++){var r=i[o];try{r.destroy()}catch(e){}}for(this.checkboxes=[];this.itemsContainer.firstChild;)this.itemsContainer.removeChild(this.itemsContainer.firstChild);var a=this.getSelectedItems();e.forEach(function(e,o){var i="string"==typeof e?e:e.value||e.label||e.key,r="string"==typeof e?e:e.label||e.value||String(i),n=document.createElement("input");t.itemsContainer.appendChild(n);var s=new y.CheckBox({label:r,enableRtl:t.enableRtl,checked:-1!==a.indexOf(i),disabled:!!t.component.disabled,labelPosition:t.component.checkboxLabelPosition||"After",cssClass:t.sizeCssClass.trim(),change:function(e){t.handleCheckboxChange(i,e.checked)}});s.appendTo(n),t.ref(s,o);var l=n.querySelector('input[type="checkbox"]');l&&(l.id=t.component.id+"_"+o),t.optionRef&&t.optionRef(s,o),t.checkboxes.push(s)})}},e}();var ue=f(707),ge=function(){return ge=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ge.apply(this,arguments)},ve=function(){function e(){this.engine=new oe}return e.prototype.parseColumnValue=function(e,t){if(null==e||""===e)return e;if("number"===t){var o=parseFloat(String(e));return isNaN(o)?0:o}return"boolean"===t?"boolean"==typeof e?e:"true"===e||"1"===e||1===e||!0===e:e},e.prototype.evaluateRowExpressions=function(e,t){for(var o=this,i=ge({},e),r=t.filter(function(e){return e.expression&&e.expression.toString().trim()}),a=function(e){if(!e.expression)return"continue";try{var r={};t.forEach(function(e){var t=i[e.field];r[e.field]=o.parseColumnValue(t,e.type)});var a=n.engine.evaluate(e.expression,r,{throwOnError:!1});i[e.field]=a}catch(t){i[e.field]=null}},n=this,s=0,l=r;s<l.length;s++){a(l[s])}return i},e.prototype.extractCalculatedColumns=function(e){return e.filter(function(e){return e.expression&&e.expression.toString().trim()})},e.prototype.getEngine=function(){return this.engine},e}();var fe=function(){return fe=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},fe.apply(this,arguments)},me=function(){function e(){this.expressionEngine=new oe}return e.prototype.validate=function(e,t,o){if(!e||""===e.trim())return!0;try{var i=fe({},o,{input:t,valid:!0}),r=e.match(/valid\s*=\s*(.+?)\s*\?\s*true\s*:\s*['"](.+?)['"]\s*$/);if(!r)return"Invalid validation expression format";var a=r[1].trim(),n=r[2];return!0===this.expressionEngine.evaluate(a,i,{throwOnError:!1},!0)||n}catch(e){return"Validation expression error"}},e.prototype.extractDependencies=function(e){if(!e)return[];var t=e.match(/valid\s*=\s*(.+)/),o=t?t[1]:e;return this.expressionEngine.extractDependencies(o).filter(function(e){return"input"!==e})},e.prototype.validateConditionSyntax=function(e,t){if(!e||""===e.trim())return["Condition cannot be empty"];var o=[],i=(e.match(/\(/g)||[]).length,r=(e.match(/\)/g)||[]).length;i!==r&&o.push("Unbalanced parentheses ("+i+" open, "+r+" close)");var a=(e.match(/\{/g)||[]).length,n=(e.match(/\}/g)||[]).length;a!==n&&o.push("Unbalanced braces ("+a+" open, "+n+" close)");var s=this.extractDependencies(e).filter(function(e){return-1===t.indexOf(e)});return s.length>0&&o.push("Unknown field references: "+s.join(", ")),o},e.prototype.buildExpression=function(e,t){return"valid = "+e.trim()+" ? true : '"+t.replace(/'/g,"\\'")+"'"},e.prototype.parseExpression=function(e){var t=e.match(/valid\s*=\s*(.+?)\s*\?\s*true\s*:\s*'(.+)'/);return t?{condition:t[1].trim(),errorMessage:t[2].replace(/\\'/g,"'")}:null},e}(),be=function(){return be=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},be.apply(this,arguments)},Ce=function(){function e(e){var t=this;this.grid=null,this.wrapper=null,this.mapCustomValidationToSyncfusion=function(e){if(e.customValidation&&0!==e.customValidation.length)return function(o){var i=t.grid&&t.grid.editModule?t.grid.editModule.formObj:null;if(!i)return!0;var r={};(t.columns||[]).forEach(function(e){var t=i.getInputElement(e.field);if(t){var o=t.value;r[e.field]="number"===e.type?parseInt(o,10):o}});for(var a=0,n=e.customValidation;a<n.length;a++){var s=n[a];if(s.expression){var l="number"===e.type?parseInt(o.value,10):o.value;return!0===t.validationEngine.validate(s.expression,l,r)}}return!0}},this.createEditParams=function(e){if(t.hasExpressions){var o=t.calculatedColumns;if(o.some(function(t){return!!t.expression&&-1!==t.expression.indexOf("{"+e.field+"}")}))return{params:{change:function(){if(t.grid&&t.grid.element){var e=t.grid.element.querySelector("form");if(e&&e.ej2_instances&&e.ej2_instances[0]){var i=e.ej2_instances[0];o.forEach(function(e){var o=i.getInputElement(e.field);if(o)try{var r={};t.columns.forEach(function(e){var t=i.getInputElement(e.field);t&&(r[e.field]=t.value)});var a=t.gridExpressions.evaluateRowExpressions(r,t.columns)[e.field];if(null!=a)if("boolean"===e.type)o.checked=!!a;else if("number"===e.type){var n=o.closest(".e-control-wrapper"),s=n?n.querySelector('input.e-control:not([type="hidden"])'):null;s&&s.ej2_instances&&s.ej2_instances[0]?s.ej2_instances[0].value=a:o.value=a}else"date"===e.type?o.ej2_instances[0].value=new Date(a):o.value=a}catch(e){}})}}}}}}},this.handleActionComplete=function(e){if(t.grid)switch(e.requestType){case"save":case"delete":case"add":if(t.grid.dataSource){var o=Array.isArray(t.grid.dataSource)?t.grid.dataSource:[];t.currentData=o,t.onDataChange&&t.onDataChange(o)}}},this.id=e.id,this.columns=e.columns||[],this.dataSource=Array.isArray(e.dataSource)?e.dataSource:[],this.height=null!=e.height?e.height:"200px",this.width=null!=e.width?e.width:"100%",this.locale=e.locale,this.cssClass=e.cssClass,this.pageSize=null!=e.pageSize?e.pageSize:6,this.allowPaging=!1!==e.allowPaging,this.allowAdding=!1!==e.allowAdding,this.allowEditing=!1!==e.allowEditing,this.allowDeleting=!1!==e.allowDeleting,this.allowFiltering=!0===e.allowFiltering,this.onDataChange=e.onDataChange,this.isPreviewMode=e.isPreviewMode,this.enableRtl=e.enableRtl,this.ref=e.ref,this.currentData=Array.isArray(this.dataSource)?this.dataSource:[],this.gridExpressions=new ve,this.validationEngine=new me}return Object.defineProperty(e.prototype,"calculatedColumns",{get:function(){return this.gridExpressions.extractCalculatedColumns(this.columns)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasExpressions",{get:function(){return this.calculatedColumns.length>0},enumerable:!0,configurable:!0}),e.prototype.buildToolbar=function(){var e=[];return this.allowAdding&&e.push("Add"),this.allowEditing&&e.push("Edit"),this.allowDeleting&&e.push("Delete"),e.push("Update","Cancel"),e},e.prototype.mapColumn=function(e){var t=e.validationRules?be({},e.validationRules):{},o=this.mapCustomValidationToSyncfusion(e);if(o){var i=e.customValidation&&e.customValidation[0]&&e.customValidation[0].expression&&(this.validationEngine.parseExpression?this.validationEngine.parseExpression(e.customValidation[0].expression).errorMessage:"Validation failed")||"Validation failed";t.required=[!0,i],t.custom=[o,i]}return{field:e.field,headerText:e.headerText,type:e.type||"string",isPrimaryKey:e.isPrimaryKey||!1,width:e.width,format:"date"===e.type?e.format||"MM/dd/yyyy":e.format,editType:e.editType,allowEditing:!1!==e.allowEditing&&!e.expression,validationRules:t,edit:this.createEditParams(e)}},e.prototype.render=function(e){var t=this,o=Array.isArray(this.dataSource)?this.dataSource:[];this.hasExpressions&&o.length>0?this.currentData=o.map(function(e){var o=t.gridExpressions.evaluateRowExpressions(e,t.columns);return be({},e,o)}):this.currentData=o;var i=document.createElement("div");i.className="datagrid-wrapper",i.style.width="string"==typeof this.width?this.width:this.width+"px",i.style.height="auto";var r=document.createElement("div");r.className="datagrid-grid",i.appendChild(r),this.id&&(r.id=this.id);var a=new ue.Grid({dataSource:this.currentData,allowPaging:this.allowPaging,filterSettings:{mode:"Immediate"},pageSettings:{pageSize:this.pageSize},editSettings:{allowEditing:this.allowEditing,allowAdding:this.allowAdding,allowDeleting:this.allowDeleting,mode:"Normal"},enableRtl:this.enableRtl,locale:this.locale||"en-US",cssClass:this.cssClass,toolbar:this.buildToolbar(),actionComplete:this.handleActionComplete,height:"string"==typeof this.height?this.height:this.height+"px",width:"string"==typeof this.width?this.width:this.width+"px",allowSorting:!0,allowFiltering:this.allowFiltering,allowSelection:!0,columns:(this.columns||[]).map(function(e){return t.mapColumn(e)})});return a.appendTo(r),this.ref(a),this.grid=a,e&&e.appendChild(i),this.wrapper=i,i},e.prototype.getRef=function(){var e=this;return{getGridData:function(){return e.currentData},gridRef:{current:this.grid}}},e.prototype.getGridData=function(){return this.currentData},e.prototype.setDataSource=function(e){var t=this;if(this.grid){var o=Array.isArray(e)?e:[];this.hasExpressions&&o.length>0?this.currentData=o.map(function(e){var o=t.gridExpressions.evaluateRowExpressions(e,t.columns);return be({},e,o)}):this.currentData=o,this.grid.dataSource=this.currentData,this.grid.refreshBatchData?this.grid.setProperties({dataSource:this.currentData},!0):this.grid.dataSource=this.currentData,this.grid.refresh&&this.grid.refresh()}},e.prototype.setColumns=function(e){this.grid&&(e&&0!==e.length?0===this.grid.columns.length&&e&&1===e.length&&(this.grid.columns=e):this.grid.columns=[],this.columns=e,this.grid.refresh&&!this.isPreviewMode&&(this.dataSource&&Array.isArray(this.dataSource)&&this.dataSource.length>0&&!this.hasExpressions&&(this.grid.dataSource=this.dataSource),this.grid.refresh()))},e.prototype.destroy=function(){if(this.grid){try{this.grid.destroy()}catch(e){}this.grid=null}this.wrapper&&this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper),this.wrapper=null,this.gridExpressions=null,this.validationEngine=null,this.currentData=[],this.columns=[],this.dataSource=[]},e}();ue.Grid.Inject(ue.Edit,ue.Toolbar,ue.Page,ue.Resize,ue.Sort,ue.Filter);var ye=function(){return ye=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ye.apply(this,arguments)},xe=function(e,t){e&&t&&e.setAttribute("id",t)},Pe=function(e){var t,o=e.component,i=e.value,r=e.onChange,a=e.onBlur,n=e.onClick,s=e.hasError,l=void 0!==s&&s,p=e.locale,h=e.formState,d=e.settings,c=e.components,u=e.enableRtl,v=e.ref,f=e.l10n,m=e.initializedGrids||new Set,b=e.target,S={floatLabelType:o.floatLabelType||"Never",placeholder:o.placeholder||"",enabled:!o.disabled},O=function(e){var t=o.validateOn||"Change",i={};return t&&"Change"!==t||(i.change=function(t){return r(e(t))},i.blur=function(){a&&a()}),"Blur"===t&&(i.change=function(t){return r(e(t))},i.blur=function(){a&&a()}),i},T=(t=o.htmlAttributes)?Array.isArray(t)?t.reduce(function(e,t){return t&&t.key&&void 0!==t.value&&(e[t.key]=t.value),e},{}):t:{};o.required&&(T["aria-required"]="true");var k=l?"e-error":"",F=((o.cssClass||"")+" "+k+" "+("Small"===o.size?" e-small":"Bigger"===o.size?" e-bigger":"")).trim();switch(o.type){case"textbox":var I=new C.TextBox(ye({id:o.name,type:o.multiline?"hidden":o.textboxType?o.textboxType:"text",name:o.id,enableRtl:u,locale:p,floatLabelType:S.floatLabelType,placeholder:S.placeholder,enabled:S.enabled,value:void 0!==i?i:o.defaultValue||"",multiline:o.multiline,showClearButton:o.showClearButton,autocomplete:!1===o.autocomplete||void 0===o.autocomplete?"off":"on",readonly:o.readOnly||!1,cssClass:F,htmlAttributes:T,appendTemplate:o.suffix,prependTemplate:o.prefix},O(function(e){return e.value||""})));return b&&I.appendTo(b),v(I),I;case"textarea":var A=new C.TextArea(ye({id:o.name,name:o.id,enableRtl:u,locale:p,floatLabelType:S.floatLabelType,placeholder:S.placeholder,enabled:S.enabled,value:void 0!==i?i:o.defaultValue||"",cols:o.cols||200,rows:o.textareaRows||4,showClearButton:o.showClearButton||!1,readonly:o.readOnly||!1,maxLength:o.maxLength||255,cssClass:F,htmlAttributes:T,appendTemplate:o.suffix,prependTemplate:o.prefix,resizeMode:"Vertical"},O(function(e){return e.value||""})));return b&&A.appendTo(b),v(A),A;case"number":var z=""===i?void 0:i,D=new C.NumericTextBox({locale:p,enableRtl:u,floatLabelType:S.floatLabelType,placeholder:S.placeholder,enabled:S.enabled,value:void 0!==z?z:o.defaultValue||void 0,decimals:o.decimals||2,currency:o.currency,format:o.numberFormat||"n2",step:o.step||1,min:o.minValue||void 0,max:o.maxValue||void 0,readonly:o.readOnly||!1,showClearButton:o.showClearButton||!1,cssClass:F,htmlAttributes:T,appendTemplate:o.suffix,prependTemplate:o.prefix,change:function(e){return r(e.value)}});return b&&(xe(b,o.name),b.setAttribute("name",o.id),D.appendTo(b)),v(D),D;case"checkbox":var R=o.label&&o.required?o.label+" *":o.label,L=new y.CheckBox({locale:p,name:o.id,enableRtl:u,label:R,labelPosition:o.checkboxLabelPosition,checked:void 0!==o.checked&&null!==o.checked&&o.checked||null!=i&&i,indeterminate:o.indeterminate||!1,disabled:o.disabled,cssClass:F,htmlAttributes:T,change:function(e){return r(e.checked)}});return b&&(xe(b,o.name),L.appendTo(b)),v(L),L;case"checkboxGroup":var E=[];de.fetch(o.options,o.id,h?h.values:void 0,c).then(function(e){e.id===o.id&&e.options.length>0&&(E.push.apply(E,e.options),M.setOptions(E))}).catch(function(){});var X=he(o.options,E),Y=X.length>0?X:o.options||["Option 1"],M=new ce({component:ye({},o,{options:Y}),formState:h,value:i,enableRtl:u,onChange:function(e){return r(e)},optionRef:e.ref,target:b,ref:v});return b&&xe(b,o.name),M.render(b),M;case"radio":var B=Array.isArray(o.options)?o.options:["Option 1"],H=(0,g.createElement)("div",{id:o.name+"-group",className:"e-radio-group "+k});return B.forEach(function(t,a){var n=t,s=t,l=(0,g.createElement)("div");l.style.marginBottom="8px",H.appendChild(l);var h=(0,g.createElement)("input",{id:o.name+"_"+a+"_"+n,attrs:{type:"radio"}});l.appendChild(h);var d=new y.RadioButton({name:o.id,label:s,enableRtl:u,locale:p,disabled:o.disabled,value:n,htmlAttributes:T,labelPosition:o.fieldLabelPosition,checked:o.defaultValue===n||i===n,cssClass:F,change:function(e){e.value===n&&r(n)}});d.appendTo(h),v(d,a),e.ref&&"function"==typeof e.ref&&e.ref(d,a)}),b&&b.appendChild(H),[];case"dropdown":var U=[];de.fetch(o.options,o.id,h?h.values:void 0,c).then(function(e){e.id===o.id&&e.options.length>0&&(U.push.apply(U,e.options),Z.dataSource=U)}).catch(function(){});var N=he(o.options,U),q=N.length>0?N:o.options||["Option 1"];o.conditions&&o.conditions.choiceBasedField&&(q=V.getChoiceBasedOptions(o.conditions.choiceBasedField,q,h?h.values:void 0,o.conditions.choiceBasedField.primaryFieldId)).length>0&&null!=i&&-1===q.indexOf(i)&&h&&(h.values[o.id]=null);var Z=new P.DropDownList(ye({id:o.name,name:o.id,floatLabelType:S.floatLabelType,placeholder:S.placeholder,enabled:S.enabled,locale:p,enableRtl:u,cssClass:F,dataSource:q,value:void 0!==h.values[o.id]?h.values[o.id]:void 0!==o.defaultValue&&null!==o.defaultValue?o.defaultValue:null,showClearButton:o.showClearButton||!1,readonly:o.readOnly||!1,enableVirtualization:o.enableVirtualization||!1,popupHeight:o.popupHeight||"300px",popupWidth:o.popupWidth||"100%",htmlAttributes:T},O(function(e){return e.value||""})));return P.DropDownList.Inject(P.VirtualScroll),b&&Z.appendTo(b),v(Z),Z;case"multiselect":var G=[];de.fetch(o.options,o.id,h?h.values:void 0,c).then(function(e){e.id===o.id&&e.options.length>0&&(G.push.apply(G,e.options),K.dataSource=G)}).catch(function(){});var J=he(o.options,G),Q=J.length>0?J:o.options||["Option 1"],K=new P.MultiSelect(ye({name:o.id,enableRtl:u,locale:p,floatLabelType:S.floatLabelType,enabled:S.enabled,value:void 0!==i?i:void 0!==o.defaultValue&&null!==o.defaultValue?o.defaultValue:null,placeholder:o.placeholder,dataSource:Q,fields:{text:"text",value:"value"},showClearButton:o.showClearButton||!1,readonly:o.readOnly||!1,allowCustomValue:o.allowCustomValue||!1,addTagOnBlur:o.addTagOnBlur||!1,delimiterChar:o.delimiterChar||",",showSelectAll:o.showSelectAll||!1,mode:o.showSelectAll?"CheckBox":o.visualMode?o.visualMode:void 0,selectAllText:o.selectAllText,unSelectAllText:o.unSelectAllText,showDropDownIcon:!1!==o.showDropDownIcon,enableVirtualization:o.enableVirtualization||!1,popupHeight:o.popupHeight||"300px",popupWidth:o.popupWidth||"100%",cssClass:F,htmlAttributes:T},O(function(e){return e.value||""})));return P.MultiSelect.Inject(P.CheckBoxSelection,P.VirtualScroll),b&&K.appendTo(b),v(K),K;case"date":var $=new w.DatePicker(ye({floatLabelType:S.floatLabelType,id:o.name,name:o.id,enableRtl:u,locale:p,placeholder:S.placeholder,enabled:S.enabled,value:void 0!==i?i:void 0!==o.defaultValue&&null!==o.defaultValue?o.defaultValue:null,format:o.format||"MM/dd/yyyy",readOnly:o.readOnly||!1,showClearButton:void 0!==o.showClearButton&&o.showClearButton,showTodayButton:!1!==o.showTodayButton,calendarMode:o.calendarMode||"Gregorian",dayHeaderFormat:o.dayHeaderFormat||"Short",depth:o.depth||"Month",start:o.start||"Month",firstDayOfWeek:o.firstDayOfWeek||0,min:o.minDate?new Date(o.minDate):void 0,max:o.maxDate?new Date(o.maxDate):void 0,cssClass:F,htmlAttributes:T},O(function(e){return e.value||""})));return w.DatePicker.Inject(w.Islamic),b&&$.appendTo(b),v($),$;case"dateTime":var ee=new w.DateTimePicker(ye({id:o.name,floatLabelType:S.floatLabelType,placeholder:S.placeholder,enabled:S.enabled,locale:p,enableRtl:u,name:o.id,dayHeaderFormat:o.dayHeaderFormat||"Short",value:void 0!==i?i:void 0!==o.defaultValue&&null!==o.defaultValue?o.defaultValue:null,format:o.format||"MM/dd/yyyy hh:mm a",showClearButton:void 0!==o.showClearButton&&o.showClearButton,showTodayButton:!1!==o.showTodayButton,depth:o.depth||"Month",start:o.start||"Month",step:o.step||1,readonly:o.readOnly||!1,min:o.minDate?new Date(o.minDate):void 0,max:o.maxDate?new Date(o.maxDate):void 0,minTime:o.minTime?new Date("2000-01-01 "+o.minTime):void 0,maxTime:o.maxTime?new Date("2000-01-01 "+o.maxTime):void 0,enableMask:!1,cssClass:F,htmlAttributes:T},O(function(e){return e.value||""})));return w.DateTimePicker.Inject(w.Islamic),b&&ee.appendTo(b),v(ee),ee;case"time":var te=new w.TimePicker(ye({id:o.name,locale:p,name:o.id,enableRtl:u,floatLabelType:S.floatLabelType,placeholder:S.placeholder,enabled:S.enabled,value:void 0!==i?i:void 0!==o.defaultValue&&null!==o.defaultValue?o.defaultValue:null,format:o.format||"hh:mm a",showClearButton:void 0!==o.showClearButton&&o.showClearButton,step:o.step||30,readonly:o.readOnly||!1,min:o.minTime?new Date("2000-01-01 "+o.minTime):void 0,max:o.maxTime?new Date("2000-01-01 "+o.maxTime):void 0,enableMask:!1,cssClass:F,htmlAttributes:T},O(function(e){return e.value||""})));return b&&te.appendTo(b),v(te),te;case"dateRange":var oe=new w.DateRangePicker(ye({id:o.name,locale:p,enableRtl:u,name:o.id,floatLabelType:S.floatLabelType,dayHeaderFormat:o.dayHeaderFormat||"Short",placeholder:S.placeholder,enabled:S.enabled,value:void 0!==i?i:void 0!==o.defaultValue&&null!==o.defaultValue?o.defaultValue:null,depth:o.depth||"Month",start:o.start||"Month",min:o.minDate?new Date(o.minDate):void 0,max:o.maxDate?new Date(o.maxDate):void 0,format:o.format||"MM/dd/yyyy",separator:o.separator||" - ",showClearButton:void 0!==o.showClearButton&&o.showClearButton,readonly:o.readOnly||!1,cssClass:F,htmlAttributes:T},O(function(e){return e.value||""})));return b&&oe.appendTo(b),v(oe),oe;case"switch":var ie=new y.Switch({locale:p,enableRtl:u,value:o.defaultValue,name:o.id,checked:void 0!==o.checked&&null!==o.checked&&o.checked||null!=i&&i,disabled:o.disabled,onLabel:o.onLabel||"",offLabel:o.offLabel||"",cssClass:F,htmlAttributes:T,change:function(e){return r(e.checked)}});return b&&(xe(b,o.name),ie.appendTo(b)),v(ie),ie;case"button":var se=o.buttonsGroups||o.buttons||[];if(se&&se.length>0){var le={display:"flex",flexWrap:"wrap",alignItems:"center",gap:o.gap||"8px",justifyContent:ne(o.position),width:o.width||void 0},pe=(0,g.createElement)("div",{id:o.name,attrs:{role:"group","aria-label":o.label||"Button Group",className:F+" "+(u?"e-rtl":"")}});Object.assign(pe.style,le);var ue=[];return se.forEach(function(t,i){var r=o.name+"_"+i,a=[re(t.style)].filter(Boolean).join(" ");a+="Small"===o.size?" e-small":"Bigger"===o.size?" e-bigger":"";var s=ae(t.type),l=(0,g.createElement)("button",{id:String(r),attrs:{name:String(r),type:s}});pe.appendChild(l);var h=new y.Button({locale:p,enableRtl:u,cssClass:a,disabled:t.disabled||!1,content:t.label||"Button "+(i+1),iconCss:t.iconCss,iconPosition:t.iconPosition});h.appendTo(l),h.element.onclick=function(e){n&&n(e)},v(h,i),ue.push(h),e.ref&&"function"==typeof e.ref&&e.ref(h,i)}),b&&b.appendChild(pe),ue}var ge=ae(o.buttonType),ve=[re(o.style),"submit"===ge?"submit-btn form-submit-type":"","reset"===ge?"form-reset-type":"",o.cssClass||"e-primary","Small"===o.size?" e-small":"Bigger"===o.size?" e-bigger":""].filter(Boolean).join(" ")||"e-primary",fe={display:"flex",justifyContent:ne(o.position),width:o.width||"100%"},me=(0,g.createElement)("div",{id:o.name+"-container"});Object.assign(me.style,fe);var be=(0,g.createElement)("button",{id:o.name,attrs:{type:ge}});me.appendChild(be);var Pe=new y.Button({enableRtl:u,locale:p,cssClass:ve,disabled:o.disabled,iconCss:o.iconCss,iconPosition:o.iconPosition,content:o.label});return Pe.appendTo(be),v(Pe),Pe.element.onclick=function(e){n&&n(e)},b&&b.appendChild(me),Pe;case"splitButton":var we=["primary"===o.style?"e-primary":"",(o.style,""),"information"===o.style?"e-info":"","error"===o.style?"e-danger":"","success"===o.style?"e-success":"","warning"===o.style?"e-warning":"",o.cssClass||""].filter(Boolean).join(" ")||void 0,je={display:"flex",justifyContent:ne(o.position)};me=(0,g.createElement)("div",{id:o.name+"-container",attrs:{"aria-label":"Splitbutton"}});Object.assign(me.style,je);var Se=o.options&&o.options.length>0?o.options.map(function(e,t){return{text:e,id:o.id+"_option_"+t}}):[{text:"Option 1",id:o.id+"_option_0"}],Oe=(0,g.createElement)("button",{id:o.name});me.appendChild(Oe);var Te=new x.SplitButton({locale:p,enableRtl:u,content:o.label||"Split Button",items:Se,cssClass:we,disabled:o.disabled,iconCss:o.iconCss,iconPosition:o.iconPosition||"Left",click:function(e){n&&n(ye({},e))},select:function(e){n&&n(ye({},e,{selectedItem:e.item.text}))}});return Te.appendTo(Oe),b&&b.appendChild(me),v(Te),Te;case"signature":var ke=(0,g.createElement)("canvas",{id:o.name}),Fe=new C.Signature({enableRtl:u,locale:p,backgroundColor:o.backgroundColor||"",strokeColor:o.strokeColor||"",maxStrokeWidth:o.maxValue,minStrokeWidth:o.minValue,velocity:o.velocity,disabled:o.disabled,change:function(){return r(o.name)}});return b&&(Fe.appendTo(ke),b.appendChild(ke)),v(Fe),Fe;case"rating":var Ie=new C.Rating({enableRtl:u,locale:p,value:void 0!==i?i:o.defaultValue||0,disabled:o.disabled,cssClass:F,allowReset:o.allowReset,itemsCount:o.itemsCount,min:o.minValue,precision:o.precision,readOnly:o.readOnly,showTooltip:o.showRatingTooltip||!1,showLabel:o.showRatingLabel,labelPosition:o.showRatingLabel?o.ratingLabelPosition:void 0,valueChanged:function(e){return r(e.value)}});return b&&(xe(b,o.name),b.setAttribute("name",o.id),Ie.appendTo(b)),v(Ie),Ie;case"colorPicker":var Ae=new C.ColorPicker({enableRtl:u,locale:p,value:void 0!==i?i:o.defaultValue||"",disabled:o.disabled,enableOpacity:o.enableOpacity,showButtons:o.showButtons,showRecentColors:o.showRecentColors,noColor:o.showNoColor,cssClass:F,change:function(e){return r(e.value)}});return b&&(xe(b,o.name),Ae.appendTo(b)),v(Ae),Ae;case"inputMask":var ze=new C.MaskedTextBox(ye({id:o.name,name:o.id,enableRtl:u,floatLabelType:o.floatLabelType||"Never",placeholder:o.placeholder||"",enabled:!o.disabled,locale:p,value:void 0!==i?i:o.defaultValue||"",mask:o.mask||"000-000-0000",promptChar:o.promptChar||"_",customCharacters:o.customCharacters,readOnly:o.readOnly||!1,showClearButton:!1!==o.showClearButton,cssClass:F,htmlAttributes:T,appendTemplate:o.suffix,prependTemplate:o.prefix},O(function(e){return e.value||""})));return b&&ze.appendTo(b),v(ze),ze;case"rangeSlider":var De=new C.Slider({enableRtl:u,locale:p,value:void 0!==i?i:void 0!==o.defaultValue&&null!==o.defaultValue?o.defaultValue:0,min:o.minValue||0,max:o.maxValue||100,step:o.step||1,cssClass:F,enabled:!o.disabled,readonly:o.readOnly,showButtons:o.showButtons,change:function(e){return r(e.value)}});return b&&(xe(b,o.name),De.appendTo(b)),v(De),De;case"fileUpload":var Re=new C.Uploader({enableRtl:u,locale:p,type:"file",enabled:!o.disabled,allowedExtensions:o.allowExtensions,asyncSettings:{saveUrl:o.saveUrl,removeUrl:o.removeUrl},buttons:o.buttons||{browse:"Choose File",clear:"Clear All",upload:"Upload All"},maxFileSize:o.maxValue,minFileSize:o.minValue,multiple:!!o.allowMultiple,showFileList:o.showFileList,htmlAttributes:T,cssClass:F,change:function(e){return r(e.file)}});return b&&(xe(b,o.name),Re.appendTo(b)),v(Re),Re;case"imageEditor":var Le,Ee=(0,g.createElement)("div",{id:o.name,attrs:{"data-field":o.id}});return setTimeout(function(){Le=new W({locale:p,enableRtl:u,disabled:o.disabled,cssClass:F,height:(null!=o.height?o.height:"350px").toString(),width:(null!=o.width?o.width:"100%").toString(),editComplete:function(){return r(o.name)},fileOpened:function(){return r(o.name)}},"#"+o.name)},100),b&&b.appendChild(Ee),v(Le),Le;case"message":var Xe=new j.Message({locale:p,enableRtl:u,severity:o.severity||o.messageType||"info",variant:o.variant,content:o.content||"Message",showCloseIcon:o.showCloseIcon,showIcon:void 0!==o.showIcon&&o.showIcon||!1,cssClass:F});return b&&(xe(b,o.name),Xe.appendTo(b)),v(Xe),Xe;case"dataGrid":var Ye=o,Me=function(e,t){if(e&&e.conditionalData&&Array.isArray(e.conditionalData))for(var o=0,i=e.conditionalData;o<i.length;o++){var r=i[o];if(V.evaluateCondition(r.condition,t))return{dataSource:r.dataSource,columns:r.columns&&r.columns.length>0?r.columns:void 0}}}(Ye.conditions,h&&h.values||{}),Be=Me?Me.dataSource:void 0,He=Me?Me.columns:void 0,Ue=(Be||Ye.dataSource,[]);de.fetch(Be||Ye.dataSource,Ye.id,h&&h.values,c).then(function(e){if(e.id===Ye.id&&e.options.length>0){var t=he(Be||Ye.dataSource,e.options,We);Ze.setDataSource(t)}});var We=[],Ne=he(Be||Ye.dataSource,Ue,We),_e=Ne.length>0?Ne:void 0!==Ye.dataSource&&null!==Ye.dataSource?Ye.dataSource:[],qe=He&&He.length>0?He:void 0!==Ye.columns&&null!==Ye.columns?Ye.columns:[],Ve=b||(0,g.createElement)("div",{id:Ye.name,className:Ye.cssClass});b&&xe(b,o.name);var Ze=new Ce({locale:p,name:Ye.name||"",columns:qe,enableRtl:u,dataSource:void 0!==_e&&_e.length>0?_e:i,height:null!=Ye.height?Ye.height:"200px",width:null!=Ye.width?Ye.width:"100%",pageSize:Ye.pageSize||6,allowPaging:!1!==Ye.allowPaging,allowFiltering:Ye.allowFiltering,allowAdding:!1!==Ye.allowAdding,allowEditing:!1!==Ye.allowEditing,allowDeleting:!1!==Ye.allowDeleting,onDataChange:function(e){return r(e)},cssClass:F,target:Ve,ref:v});return Ze.render(Ve),!m.has(o.id)&&h&&Array.isArray(_e)&&(h.values[o.id]=_e,Ze.isInitialized=!0,m.add(o.id)),"function"==typeof e.ref?e.ref(Ze):e.ref&&(e.ref.current=Ze),b||Ve;case"richTextEditor":var Ge={items:["Undo","Redo","|","Bold","Italic","Underline","StrikeThrough","InlineCode","|","CreateLink","Image","CreateTable","CodeBlock","HorizontalLine","Blockquote","EmojiPicker","|","LineHeight","Formats","Alignments","|","BulletFormatList","NumberFormatList","Checklist","|","Outdent","Indent","|","FontColor","BackgroundColor","FontName","FontSize","|","LowerCase","UpperCase","SuperScript","SubScript","|","SourceCode","|"]};o.enableImportFromWord&&o.enableImportFromWord.enabled&&Ge.items.push("ImportWord"),o.enableExportToWord&&o.enableExportToWord.enabled&&Ge.items.push("ExportWord"),o.enableExportToPdf&&o.enableExportToPdf.enabled&&Ge.items.push("ExportPdf"),Ge.items.push("Print");var Je=function(e){return!!e&&e.enabled&&"string"==typeof e.serviceUrl&&""!==e.serviceUrl.trim()},Qe=Je(o.enableImportFromWord)?{serviceUrl:/^(https?:)?\/\//i.test(o.enableImportFromWord?o.enableImportFromWord.serviceUrl:"")?o.enableImportFromWord?o.enableImportFromWord.serviceUrl:"":(d&&d.hostUrl?d.hostUrl:"").replace(/\/+$/,"")+"/"+(o.enableImportFromWord?o.enableImportFromWord.serviceUrl:"").replace(/^\/+/,"")}:void 0,Ke=Je(o.enableExportToWord)?{serviceUrl:/^(https?:)?\/\//i.test(o.enableExportToWord?o.enableExportToWord.serviceUrl:"")?o.enableExportToWord?o.enableExportToWord.serviceUrl:"":(d&&d.hostUrl?d.hostUrl:"").replace(/\/+$/,"")+"/"+(o.enableExportToWord?o.enableExportToWord.serviceUrl:"").replace(/^\/+/,""),fileName:"RichTextEditor.docx",stylesheet:"\n .e-rte-content {\n font-size: 1em;\n font-weight: 400;\n margin: 0;\n }\n "}:void 0,$e=Je(o.enableExportToPdf)?{serviceUrl:/^(https?:)?\/\//i.test(o.enableExportToPdf?o.enableExportToPdf.serviceUrl:"")?o.enableExportToPdf?o.enableExportToPdf.serviceUrl:"":(d&&d.hostUrl?d.hostUrl:"").replace(/\/+$/,"")+"/"+(o.enableExportToPdf?o.enableExportToPdf.serviceUrl:"").replace(/^\/+/,""),fileName:"RichTextEditor.pdf",stylesheet:"\n .e-rte-content {\n font-size: 1em;\n font-weight: 400;\n margin: 0;\n }\n "}:void 0,et=new _.RichTextEditor({locale:p,toolbarSettings:Ge,enableRtl:u,value:void 0!==i?i:o.defaultValue||"",placeholder:o.placeholder||"",enabled:!o.disabled,readonly:o.readOnly||!1,maxLength:o.maxLength||void 0,cssClass:F||void 0,height:o.height||"300px",width:o.width||"100%",htmlAttributes:T,importWord:Qe,exportPdf:$e,exportWord:Ke,change:function(e){return r(e.value)}});return _.RichTextEditor.Inject(_.Toolbar,_.Link,_.HtmlEditor,_.QuickToolbar,_.Image,_.Count,_.Table,_.EmojiPicker,_.PasteCleanup,_.SlashMenu,_.CodeBlock,_.ClipBoardCleanup,_.AutoFormat,_.ImportExport),et.appendTo(b),v(et),et;default:Xe=new j.Message({locale:p,enableRtl:u,severity:"Warning",content:f.getConstant("unsupportedComponent")+" : "+o.type,cssClass:F});return b&&(xe(b,o.name),Xe.appendTo(b)),v(Xe),Xe}},we=function(){return we=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},we.apply(this,arguments)},je={strict:!1,maxInputSize:5242880,defaultTextType:"textbox",inferTypeFromValue:!0,generateIds:!0,includeMetadata:!0,customTypeMap:{},validateUnknownFields:!1},Se=function(){function e(e){this.config=we({},je,e)}return e.prototype.parse=function(e){var t=[],o=[];if("string"==typeof e){if(e.length>this.config.maxInputSize)return this.formatError(t,o,"Input exceeds maximum size of "+this.config.maxInputSize+" bytes");var i=Oe(e);if(!i.valid)return this.formatError(t,o,i.errors&&i.errors[0]||"Invalid JSON");try{e=JSON.parse(e)}catch(e){return this.formatError(t,o,"Failed to parse JSON: "+e.message)}}var r=this.detectFormat(e);r.ambiguousFormats&&r.ambiguousFormats.length>0&&(o.push("Ambiguous format detected."),o.push("Using "+r.format+" format ("+("json-schema"===r.format?"properties priority":"pages priority")+")"));var a=[];switch(r.format){case"configured-schema":a=e.properties||[];break;case"json-schema":var n=this.parseJsonSchema(e);a=n.components,n.warnings&&o.push.apply(o,n.warnings);break;case"surveyjs":a=this.parseSurveyJS(e);break;case"openapi":a=this.parseOpenAPI(e);break;case"data-inference":(a=this.parseDataInference(e)).length>0&&o.push("Field types inferred from data; please verify");break;default:t.push("Could not determine input format")}0===a.length&&t.push("No form fields could be extracted from input"),!a.some(function(e){return"button"===e.type&&"submit"===e.buttonType})&&a.length>0&&a.push({id:this.generateComponentId("button"),type:"button",label:"Submit",style:"primary",buttonType:"submit"});var s={version:e.version||"0.1.0",components:a},l=Te(s);!l.valid&&l.errors&&t.push.apply(t,l.errors),l.warnings&&o.push.apply(o,l.warnings),this.config.strict&&o.length>0&&(t.push.apply(t,o),o.length=0);var p=ke(s);return{success:0===t.length,schema:p,errors:t,warnings:o,metadata:{detectedFormat:r.format,confidence:r.confidence,sourceHints:r.hints}}},e.prototype.formatError=function(e,t,o){return e.push(o),{success:!1,schema:null,errors:e,warnings:t,metadata:{detectedFormat:"unknown",confidence:"low",sourceHints:[]}}},e.prototype.detectFormat=function(e){var t=[],o=[];if(!e||"object"!=typeof e)return{format:"unknown",confidence:"low",hints:["Input is not a valid object"]};if(e.$schema&&"string"==typeof e.$schema&&e.$schema.includes("json-schema"))return t.push("$schema property detected"),{format:"json-schema",confidence:"high",hints:t};var i=e.properties&&"object"==typeof e.properties,r=e.pages&&Array.isArray(e.pages),a=e.elements&&Array.isArray(e.elements);return i&&r?(t.push("Multiple format patterns detected"),t.push("Selected based on priority rules"),o.push("properties format","pages format"),{format:"json-schema",confidence:"medium",hints:t,ambiguousFormats:o}):r?(t.push("pages array detected"),e.pages[0]&&e.pages[0].elements&&t.push("elements structure matched"),{format:"surveyjs",confidence:"high",hints:t}):a&&!i?(t.push("elements array at root level"),{format:"surveyjs",confidence:"medium",hints:t}):i?(t.push("properties object detected"),"object"===e.type&&t.push("type: object matched"),e.required&&Array.isArray(e.required)&&t.push("required array found"),this.hasExampleFields(e.properties)?(t.push("example fields detected (API schema pattern)"),{format:"openapi",confidence:"high",hints:t}):{format:"json-schema",confidence:"high",hints:t}):this.isDataInferenceCandidate(e)?(t.push("Simple object with primitive values"),t.push("No schema indicators found"),{format:"data-inference",confidence:"medium",hints:t}):{format:"unknown",confidence:"low",hints:["Could not identify format"]}},e.prototype.hasExampleFields=function(e){if(!e||"object"!=typeof e)return!1;for(var t=0,o=Object.keys(e);t<o.length;t++){var i=e[o[t]];if(i&&"example"in i)return!0}return!1},e.prototype.isDataInferenceCandidate=function(e){return!(!e||"object"!=typeof e)&&(!(e.$schema||e.properties||e.pages||e.elements)&&Object.keys(e).every(function(t){var o=e[t];return null==o||("string"==typeof o||"number"==typeof o||"boolean"==typeof o||!!Array.isArray(o)&&o.every(function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e}))}))},e.prototype.inferComponentType=function(e,t){var o=this.inferTypeFromValue(e,t);if(o.type)return we({},o,{confidence:"high",method:"value-type"});var i=this.matchFieldNamePattern(e);return i.type?we({},i,{confidence:"high",method:"name-pattern"}):{type:this.config.defaultTextType,confidence:"low",method:"fallback"}},e.prototype.inferTypeFromValue=function(e,t){if(!this.config.inferTypeFromValue)return{type:"textbox"};if(null==t)return this.matchFieldNamePattern(e);if("string"==typeof t){if(t.includes("@")&&t.includes("."))return{type:"textbox",textboxType:"email"};if(/^(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}/.test(t))return{type:"textbox",textboxType:"url"};if(/^\d{4}-\d{2}-\d{2}/.test(t))return{type:"date"};var o=this.matchFieldNamePattern(e);return"textbox"!==o.type||o.textboxType?o:{type:this.config.defaultTextType}}return"number"==typeof t?{type:"number"}:"boolean"==typeof t?{type:"checkbox"}:Array.isArray(t)?{type:"multiselect"}:{type:"textbox"}},e.prototype.matchFieldNamePattern=function(e){if(this.config.customTypeMap){var t=this.config.customTypeMap[e.toLowerCase()];if(t)return{type:t}}var o=e.toLowerCase().replace(/[_\-\s]+/g," ");return/email|mail|e-?mail/.test(o)?{type:"textbox",textboxType:"email"}:/date|birth|birthday|dob|created|updated/.test(o)?{type:"date"}:/phone|tel|mobile|cell|cellphone|msisdn/.test(o)?{type:"textbox",textboxType:"number"}:/url|link|uri|website/.test(o)?{type:"textbox",textboxType:"url"}:/password|pwd|pass|security|secret|key|token/.test(o)?{type:"textbox",textboxType:"password"}:/\b(?:age|count|qty|quantity|amount|price|cost|salary|fee|rate|number|num)\b/.test(o)?{type:"number"}:/active|enabled|visible|deleted|archived|approved|confirmed/.test(o)?{type:"checkbox"}:/select|choice|option|type|status|category|kind/.test(o)?{type:"dropdown"}:/description|comment|note|bio|biography|about|message|content|summary|details/.test(o)?{type:"textarea"}:{type:"textbox"}},e.prototype.parseJsonSchema=function(e){var t=[],o=[];if(!e.properties||"object"!=typeof e.properties)return{components:t,warnings:o};for(var i=this.flattenNestedProperties(e.properties,"",o),r=0,a=Object.keys(i);r<a.length;r++){var n=a[r],s=i[n],l=this.mapJsonSchemaType(s),p=-1!==(e.required||[]).indexOf(n);t.push(this.createComponent(n,s,l,{required:p}))}return{components:t,warnings:o}},e.prototype.flattenNestedProperties=function(e,t,o){for(var i={},r=!1,a=0,n=Object.keys(e);a<n.length;a++){var s=n[a],l=t?t+"_"+s:s;if("object"===(c=e[s]).type&&c.properties&&"object"==typeof c.properties){r=!0;var p=this.flattenNestedProperties(c.properties,l,o);Object.assign(i,p)}else i[l]=c}if(r&&!t){o.push("NESTED_OBJECTS_FLATTENED: Nested objects converted to flat structure");for(var h=0,d=Object.keys(e);h<d.length;h++){var c;"object"===(c=e[s=d[h]]).type&&c.properties&&this.collectFlattenedFieldNames(c.properties,s,o)}}return i},e.prototype.collectFlattenedFieldNames=function(e,t,o){for(var i=0,r=Object.keys(e);i<r.length;i++){var a=r[i],n=e[a],s=t+"_"+a;o.push("Field '"+t+"."+a+"' flattened to '"+s+"'"),"object"===n.type&&n.properties&&this.collectFlattenedFieldNames(n.properties,s,o)}},e.prototype.parseSurveyJS=function(e){var t=this,o=[];return e.pages&&Array.isArray(e.pages)&&e.pages.forEach(function(e){e.elements&&Array.isArray(e.elements)&&e.elements.forEach(function(e){o.push(t.createComponentFromSurveyJS(e))})}),!o.length&&e.elements&&Array.isArray(e.elements)&&e.elements.forEach(function(e){o.push(t.createComponentFromSurveyJS(e))}),o},e.prototype.createComponentFromSurveyJS=function(e){var t=this.mapSurveyJSType(e.type||"text"),o={};!0===e.isRequired&&(o.required=!0),e.validators&&Array.isArray(e.validators)&&e.validators.forEach(function(e){"numeric"===e.type&&(void 0!==e.minValue&&(o.minValue=e.minValue),void 0!==e.maxValue&&(o.maxValue=e.maxValue)),"text"===e.type&&(void 0!==e.minLength&&(o.minLength=e.minLength),void 0!==e.maxLength&&(o.maxLength=e.maxLength))});var i=we({id:this.generateComponentId(t),type:t,label:e.title||e.label||this.humanizeFieldName(e.name),defaultValue:e.defaultValue,expressionValue:e.expressionValue},Object.keys(o).length>0?o:void 0);return"dropdown"!==t&&"multiselect"!==t&&"radio"!==t&&"splitButton"!==t||e.choices&&Array.isArray(e.choices)&&(i.options=e.choices),i},e.prototype.mapSurveyJSType=function(e){return{text:"textbox",email:"email",number:"number",checkbox:"checkbox",radiogroup:"radio",dropdown:"dropdown",tagbox:"multiselect",multiselect:"multiselect",rating:"number",comment:"textarea",date:"date"}[e]||"textbox"},e.prototype.parseOpenAPI=function(e){var t=[];if(!e.properties||"object"!=typeof e.properties)return t;for(var o=Object.keys(e.properties),i=e.required||[],r=0,a=o;r<a.length;r++){var n=a[r],s=e.properties[n],l=this.mapJsonSchemaType(s),p=-1!==i.indexOf(n);t.push(this.createComponent(n,s,l,{required:p}))}return t},e.prototype.parseDataInference=function(e){for(var t=[],o=0,i=Object.keys(e);o<i.length;o++){var r=i[o],a=e[r],n=this.inferComponentType(r,a),s={id:this.generateComponentId(n.type),type:n.type,label:this.humanizeFieldName(r),defaultValue:a,expressionValue:void 0};if(n.textboxType&&(s.textboxType=n.textboxType,"email"===n.textboxType?s.regex=ie.EMAIL:"url"===n.textboxType&&(s.regex=ie.URL)),"date"===n.type&&void 0!==s.defaultValue&&null!==s.defaultValue){var l=this.formatDateTimeValue(s.defaultValue);l&&(s.defaultValue=l)}Array.isArray(a)&&a.length>0&&(s.options=a),t.push(s)}return t},e.prototype.createComponent=function(e,t,o,i){var r={};!0===(void 0!==t.required?t.required:i.required)&&(r.required=!0),t.minLength&&(r.minLength=t.minLength),t.maxLength&&(r.maxLength=t.maxLength),t.minDate&&(r.minDate=t.minDate),t.maxDate&&(r.maxDate=t.maxDate),t.minTime&&(r.minTime=t.minTime),t.minValue&&(r.minValue=t.minValue),t.maxValue&&(r.maxValue=t.maxValue),t.pattern&&(r.pattern=t.pattern);var a=function(e,t){var o="string"==typeof t&&t?t:"field_"+Date.now()+"_"+Math.floor(1e3*Math.random());if(null==e)return o;var i=String(e).trim();return i&&"__proto__"!==i&&"prototype"!==i&&"constructor"!==i?(i=i.replace(/[^A-Za-z0-9_-]/g,"_"),/^[A-Za-z_]/.test(i)||(i="f_"+i),i.length>100&&(i=i.slice(0,100)),"__proto__"===i||"prototype"===i||"constructor"===i?o:i):o}(t.id||this.generateComponentId(o.type),this.generateComponentId(o.type)),n=we({id:a,name:t.name,type:o.type,label:t.title||t.label||this.humanizeFieldName(e),defaultValue:t.default||t.defaultValue||void 0,expressionValue:t.expressionValue||void 0,content:t.content,buttonType:t.buttonType,textboxType:t.textboxType},Object.keys(r).length>0?r:void 0);if(o.textboxType&&(n.textboxType=o.textboxType,"email"===o.textboxType?r.pattern||(r.regex="^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",r.validationMessage="Please enter a valid email address"):"url"===o.textboxType&&(r.pattern||(r.regex="^(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)$",r.validationMessage="Please enter a valid URL"))),"date"===o.type&&void 0!==n.defaultValue&&null!==n.defaultValue){var s=this.formatDateTimeValue(n.defaultValue);s&&(n.defaultValue=s)}return"splitButton"!==o.type&&"dropdown"!==o.type&&"multiselect"!==o.type&&"radio"!==o.type||!t.enum&&!t.options||(n.options=t.enum||t.options),n},e.prototype.parseDateFromValue=function(e){if(null==e)return null;if("number"==typeof e)return e<1e12?new Date(1e3*e):new Date(e);if("string"==typeof e){var t=e.trim(),o=new Date(t);if(!isNaN(o.getTime()))return o;var i=t.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/);if(i)return new Date(Number(i[1]),Number(i[2])-1,Number(i[3]),Number(i[4]||0),Number(i[5]||0),Number(i[6]||0));var r=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:[ T](\d{1,2}):(\d{2})(?:[:](\d{2}))?)?/);if(r)return new Date(Number(r[3]),Number(r[1])-1,Number(r[2]),Number(r[4]||0),Number(r[5]||0),Number(r[6]||0))}return null},e.prototype.formatDate=function(e){var t=e.getMonth()+1,o=e.getDate();return(t<10?"0"+t:String(t))+"/"+(o<10?"0"+o:String(o))+"/"+e.getFullYear()},e.prototype.formatDateTimeValue=function(e){var t=this.parseDateFromValue(e);if(t){var o=this.formatDate(t);return 0!==t.getHours()||0!==t.getMinutes()||/\dT\d{2}:\d{2}/.test(String(e))?""+o:o}},e.prototype.mapJsonSchemaType=function(e){var t=e.type;if("string"===t){var o=(e.format||"").toString().toLowerCase(),i=((e.title||e.label||"")+" "+(e.description||"")).toLowerCase();return/email|mail|e-?mail/.test(o)||/email|mail|e-?mail/.test(i)?{type:"textbox",textboxType:"email"}:/uri|url|link|website/.test(o)||/uri|url|link|website/.test(i)?{type:"textbox",textboxType:"url"}:/phone|tel|mobile|cell|msisdn/.test(o)||/phone|tel|mobile|cell|msisdn/.test(i)?{type:"textbox",textboxType:"number"}:/password|pwd|pass|security|secret|key/.test(o)||/password|pwd|pass|security|secret|key/.test(i)?{type:"textbox",textboxType:"password"}:"date"===o||"date-time"===o||/date|birthday|dob/.test(i)?{type:"date"}:e.enum||e.options?{type:"dropdown"}:{type:this.config.defaultTextType}}return"number"===t||"integer"===t?{type:"number"}:"boolean"===t?{type:"checkbox"}:"array"===t?{type:"multiselect"}:"message"===t?{type:"message"}:"button"===t?{type:"button"}:"signature"===t||"sign"===t?{type:"signature"}:"image"===t||"imageEditor"===t?{type:"imageEditor"}:"file"===t||"fileUpload"===t?{type:"fileUpload"}:"color"===t||"colorPicker"===t?{type:"colorPicker"}:"splitButton"===t?{type:"splitButton"}:{type:this.config.defaultTextType}},e.prototype.generateComponentId=function(e){return this.config.generateIds?e+"_"+Date.now()+"_"+Math.floor(1e3*Math.random()):""},e.prototype.humanizeFieldName=function(e){var t=e.replace(/_/g," ");return t=t.replace(/([a-z])([A-Z])/g,"$1 $2")},e}(),Oe=function(e){try{return JSON.parse(e),{valid:!0}}catch(e){return{valid:!1,errors:["Invalid JSON syntax: "+e.message]}}},Te=function(e){var t=[],o=[];if(e.components?Array.isArray(e.components)||t.push('Property "components" must be an array'):t.push("Missing required property: components"),Array.isArray(e.components)){var i=new Set,r=function(e,o){void 0===o&&(o="root"),e.id?(i.has(e.id)&&t.push("Duplicate component ID found: "+e.id),i.add(e.id)):t.push("Component at "+o+' is missing "id" property'),e.type||t.push('Component "'+(e.id||"unknown")+'" is missing "type" property'),e.children&&Array.isArray(e.children)&&e.children.forEach(function(e,t){r(e,o+".children["+t+"]")}),e.tabItems&&Array.isArray(e.tabItems)&&e.tabItems.forEach(function(e,t){e.content&&Array.isArray(e.content)&&e.content.forEach(function(e,i){r(e,o+".tabItems["+t+"].content["+i+"]")})}),e.tableCells&&Array.isArray(e.tableCells)&&e.tableCells.forEach(function(e,t){Array.isArray(e)&&e.forEach(function(e,i){Array.isArray(e)&&e.forEach(function(e,a){r(e,o+".tableCells["+t+"]["+i+"]["+a+"]")})})})};e.components.forEach(function(e,t){r(e,"components["+t+"]")})}return{valid:0===t.length,errors:t.length>0?t:void 0,warnings:o.length>0?o:void 0}},ke=function(e){var t={version:e.version||"0.1.0",components:e.components||[]},o=function(e){var t=we({},e,{_configured:!0});return e.children&&Array.isArray(e.children)&&(t.children=e.children.map(o)),e.tabItems&&Array.isArray(e.tabItems)&&(t.tabItems=e.tabItems.map(function(e){return we({},e,{content:e.content?e.content.map(o):[]})})),e.tableCells&&Array.isArray(e.tableCells)&&(t.tableCells=e.tableCells.map(function(e){return e.map(function(e){return Array.isArray(e)?e.map(o):[]})})),t};return t.components=t.components.map(o),t};const Fe=function(){function e(e){this.content=e.content,this.id=e.id,this.enableHtmlSanitizer=!!(0,g.isNullOrUndefined)(e.enableHtmlSanitizer)||e.enableHtmlSanitizer,this.el=e.target||null}return e.prototype.resolveHtml=function(e){try{return this.enableHtmlSanitizer?g.SanitizeHtmlHelper.sanitize(e):e}catch(e){return""}},e.prototype.render=function(){var e=document.createElement("div");return this.id&&(e.id=this.id),e.innerHTML=this.resolveHtml(this.content),this.el=e,e},e.prototype.update=function(e){this.content=e,this.el&&(this.el.innerHTML=this.resolveHtml(this.content))},e.prototype.getElement=function(){return this.el},e.prototype.destroy=function(){this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=null,this.content="",this.enableHtmlSanitizer=!1,this.id=void 0},e}();var Ie=function(){function e(){}return e.getConstraints=function(e,t,o){var i=this;if(void 0===o&&(o="number"),!e||0===e.length)return this.getEmptyConstraints(o);var r=e.find(function(e){return!1===e.enabled});if(r){var a=this.resolveValue(r.minValue,{}),n=this.resolveValue(r.maxValue,{});return"date"===o||"dateRange"===o?{minValue:void 0,maxValue:void 0,minDate:a,maxDate:n,minTime:void 0,maxTime:void 0}:"time"===o?{minValue:void 0,maxValue:void 0,minDate:void 0,maxDate:void 0,minTime:a,maxTime:n}:{minValue:a,maxValue:n,minDate:void 0,maxDate:void 0,minTime:void 0,maxTime:void 0}}var s=e.filter(function(e){return!0===e.enabled});if(0===s.length)return this.getEmptyConstraints(o);var l=s.map(function(e){return{min:i.resolveValue(e.minValue,t),max:i.resolveValue(e.maxValue,t)}}).filter(function(e){return void 0!==e.min||void 0!==e.max});if(0===l.length)return this.getEmptyConstraints(o);var p=this.getPermissiveMin(l,o),h=this.getPermissiveMax(l,o);return"date"===o||"dateRange"===o?{minValue:void 0,maxValue:void 0,minDate:p,maxDate:h,minTime:void 0,maxTime:void 0}:"time"===o?{minValue:void 0,maxValue:void 0,minDate:void 0,maxDate:void 0,minTime:p,maxTime:h}:{minValue:p,maxValue:h,minDate:void 0,maxDate:void 0,minTime:void 0,maxTime:void 0}},e.resolveValue=function(e,t){if("number"==typeof e)return e;if("string"==typeof e)return e;if(e&&"object"==typeof e&&e.field){var o=t[e.field];return void 0!==o?o:void 0}},e.getPermissiveMin=function(e,t){var o=this;if(0!==e.length){if("date"===t||"dateRange"===t)return e.reduce(function(e,t){if(!t.min)return e;if(!e)return t.min;var i=o.convertToISO(e);return o.convertToISO(t.min)<i?t.min:e},void 0);if("time"===t)return e.reduce(function(e,t){if(!t.min)return e;if(!e)return t.min;var i=o.convertTimeTo24Hour(e);return o.convertTimeTo24Hour(t.min)<i?t.min:e},void 0);var i=e.map(function(e){return e.min}).filter(function(e){return void 0!==e});return i.length>0?Math.min.apply(Math,i):void 0}},e.getPermissiveMax=function(e,t){var o=this;if(0!==e.length){if("date"===t||"dateRange"===t)return e.reduce(function(e,t){if(!t.max)return e;if(!e)return t.max;var i=o.convertToISO(e);return o.convertToISO(t.max)>i?t.max:e},void 0);if("time"===t)return e.reduce(function(e,t){if(!t.max)return e;if(!e)return t.max;var i=o.convertTimeTo24Hour(e);return o.convertTimeTo24Hour(t.max)>i?t.max:e},void 0);var i=e.map(function(e){return e.max}).filter(function(e){return void 0!==e});return i.length>0?Math.max.apply(Math,i):void 0}},e.convertToISO=function(e){if(!e)return"";if(e.includes("-")&&10===e.length)return e;if(-1!==e.indexOf("/")){var t=e.split("/"),o=t[0],i=t[1],r=t[2];return o&&i&&r?r+"-"+(o.length<2?"0"+o:o)+"-"+(i.length<2?"0"+i:i):e}return e},e.convertTimeTo24Hour=function(e){if(!e)return"";var t=/PM/i.test(e),o=/AM/i.test(e);if(o||t){var i=e.replace(/\s*(AM|PM)/i,"").trim().split(":"),r=i[0],a=i[1];if(!r||!a)return e;var n=parseInt(r,10);t&&12!==n?n+=12:o&&12===n&&(n=0);var s=String(n);return(s.length<2?"0"+s:s)+":"+a}return e},e.getEmptyConstraints=function(e){return{minValue:void 0,maxValue:void 0,minDate:void 0,maxDate:void 0,minTime:void 0,maxTime:void 0}},e.validateValue=function(e,t,o){if(null==e||""===e)return{isValid:!0};if("date"===o||"dateRange"===o){if(t.minDate){var i=this.convertToISO(t.minDate);if(this.convertToISO(e)<i)return{isValid:!1,error:"Date must be on or after "+t.minDate}}if(t.maxDate){var r=this.convertToISO(t.maxDate);if(this.convertToISO(e)>r)return{isValid:!1,error:"Date must be on or before "+t.maxDate}}}else if("time"===o){if(t.minTime&&e<t.minTime)return{isValid:!1,error:"Time must be on or after "+t.minTime};if(t.maxTime&&e>t.maxTime)return{isValid:!1,error:"Time must be on or before "+t.maxTime}}else{var a=Number(e);if(void 0!==t.minValue)if(a<Number(t.minValue))return{isValid:!1,error:"Value must be at least "+t.minValue};if(void 0!==t.maxValue)if(a>Number(t.maxValue))return{isValid:!1,error:"Value must be at most "+t.maxValue}}return{isValid:!0}},e}(),Ae=function(){var e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},e(t,o)};return function(t,o){function i(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)}}(),ze=function(){return ze=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ze.apply(this,arguments)},De=function(e,t,o,i){var r,a=arguments.length,n=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(a<3?r(n):a>3?r(t,o,n):r(t,o))||n);return a>3&&n&&Object.defineProperty(t,o,n),n},Re=["textbox","number","checkbox","dropdown","multiselect","date","dateTime","time","dateRange","switch","rating","colorPicker","inputMask","fileUpload"],Le={unsupportedComponent:"Unsupported Component type"},Ee=function(e){function t(t,o){var i=e.call(this,t,o)||this;return i.processedSchemaCache={version:"1.0.0",components:[]},i.l10n=new g.L10n("form-renderer",Le,i.locale),i.formState={values:Object.create(null),errors:Object.create(null)},i.validator=null,i.inputRefs={},i.conditionalValueApplied={},i.expressionEngine=null,i.expressionDependencyGraph={},i.expressionEvaluationInProgress=!1,i.previousFormValues={},i.computedFieldNames=new Set,i.customValidationEngine=new me,i.currentFormValues={},i.isInitialized=!1,i.hasLayoutComponentsCache=!1,i.idToLabelCache={},i.initialValuesCache={},i.renderedInstances=[],i.tooltipRefs={},i.createdFired=!1,i.rerenderScheduled=!1,i.conditionalTriggerFieldIds=new Set,i.preservedFields=new Map,i.consumerDependencyMap=new Map,i.pendingChangedFieldIds=new Set,i}var o;return Ae(t,e),o=t,t.prototype.getModuleName=function(){return"form-renderer"},t.prototype.getPersistData=function(){return this.addOnPersist(["formState",JSON.stringify(this.formState)])},t.prototype.preRender=function(){(0,g.enableRipple)(!0),this.createdFired=!1,this.expressionEngine=new oe},t.prototype.render=function(){var e=this;if(this.clearEngineCaches(),this.removePreviousRoot(),this.normalizeSchema(),this.element.classList.add("form-renderer-container"),this.className&&(0,g.addClass)([this.element],this.className.replace(/\s+/g," ").trim().split(" ")),this.enableRtl?this.element.classList.add("e-rtl"):this.element.classList.remove("e-rtl"),this.hasLayoutComponentsCache=this.computeHasLayoutComponents(),this.idToLabelCache=this.computeIdToLabel(),this.initialValuesCache=this.buildInitialValues(),this.buildValidationRulesAndBridge(),this.isInitialized||(this.isInitialized=!0),this.formState&&this.initialValuesCache)for(var t=0,o=Object.keys(this.initialValuesCache);t<o.length;t++){var i=o[t],r=this.initialValuesCache[i];this.formState.values[i]||(this.formState.values[i]=r)}this.currentFormValues=ze({},this.formState?this.formState.values:{}),this.initExpressionEngine(),this.buildConditionalDependencyMap();var a=(0,g.createElement)("form",{className:"form-renderer "+this.layoutClass,attrs:{role:"region","aria-label":this.processedSchemaCache.settings&&this.processedSchemaCache.settings.name||"Form"}});this.element.appendChild(a),this.inputRefs={},(this.processedSchemaCache.components||[]).forEach(function(t){var o=e.renderComponent(t);if(o&&a.appendChild(o),"richTextEditor"===t.type){var i=o.querySelector(".e-richtexteditor");(0,g.getComponent)(i,"richtexteditor").refreshUI()}if("dataGrid"===t.type){var r=o.querySelector(".e-control.e-toolbar");(0,g.getComponent)(r,"toolbar").refresh()}if("tabs"===t.type){var n=o.querySelector(".e-control.e-tab");(0,g.getComponent)(n,"tab").refreshOverflow()}}),this.created&&!this.createdFired&&setTimeout(function(){Object.keys(e.inputRefs).length>0&&(e.createdFired=!0,e.trigger("created",{}))},0)},t.prototype.normalizeSchema=function(){var e=this.schema;try{if(!e)return void(this.processedSchemaCache={version:"1.0.0",components:[]});var t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch(e){return this.failure&&this.trigger("failure",{error:e}),void(this.processedSchemaCache={version:"1.0.0",components:[]})}if(t&&"object"==typeof t&&t.properties&&Array.isArray(t.layout))this.processedSchemaCache=J(t);else{var o=(new Se).parse("string"==typeof e?e:JSON.stringify(e));o.success&&o.schema?this.processedSchemaCache=o.schema:(this.failure&&this.trigger("failure",{error:o.errors}),this.processedSchemaCache={version:"1.0.0",components:[]})}}catch(e){this.failure&&this.trigger("failure",{error:e}),this.processedSchemaCache={version:"1.0.0",components:[]}}},t.prototype.computeHasLayoutComponents=function(){if(!this.processedSchemaCache.components)return!1;var e=function(t){for(var o=0,i=t;o<i.length;o++){var r=i[o];if(-1!==["table","tabs","panel","card"].indexOf(r.type))return!0;if(r.children&&e(r.children))return!0;if(r.tableCells)for(var a=0,n=r.tableCells;a<n.length;a++)for(var s=0,l=n[a];s<l.length;s++){var p=l[s];if(e(p))return!0}if(r.tabItems)for(var h=0,d=r.tabItems;h<d.length;h++){var c=d[h];if(c.content&&e(c.content))return!0}}return!1};return e(this.processedSchemaCache.components)},Object.defineProperty(t.prototype,"layoutClass",{get:function(){if(this.hasLayoutComponentsCache)return"";switch(this.layout){case"TwoColumn":return"twolayout";case"ThreeColumn":return"threelayout";case"FourColumn":return"fourlayout";default:return""}},enumerable:!0,configurable:!0}),t.prototype.collectAllComponents=function(e){var t=[],o=function(e){e.forEach(function(e){t.push(e),e.children&&e.children.length>0&&o(e.children),e.tableCells&&e.tableCells.forEach(function(e){e.forEach(function(e){return o(e)})}),e.tabItems&&e.tabItems.forEach(function(e){e.content&&o(e.content)})})};return o(e),t},t.prototype.computeIdToLabel=function(){var e={},t=function(o){o.forEach(function(o){o.label&&-1===["panel","table","tabs","card","button","message","splitButton"].indexOf(o.type)&&(o.name?e[o.id]=o.name:o.label&&(e[o.id]=o.label)),o.children&&t(o.children),o.tableCells&&o.tableCells.forEach(function(e){return e.forEach(function(e){return t(e)})}),o.tabItems&&o.tabItems.forEach(function(e){e.content&&t(e.content)})})};return t(this.processedSchemaCache.components),e},t.prototype.buildValidationRulesAndBridge=function(){var e=this,t={},o=this.formState&&this.formState.values||{},i=function(r,a){void 0===a&&(a=!0),r.forEach(function(r){if(r){var n={},s=a&&!1!==r.visible&&V.isFieldVisible(r.conditions,o),l=a&&V.isFieldHidden(r.conditions,o);if(s&&!l){var p=V.isFieldRequired(r.conditions,o),h=V.isFieldDisabled(r.conditions,o),d=V.isFieldReadOnly(r.conditions,o),c=!!r.required||p,u=!!r.disabled||h,g=!!r.readOnly||d;if(r.customValidation&&Array.isArray(r.customValidation)&&r.customValidation.length>0&&!u&&!g){var v=r.customValidation&&r.customValidation[0]&&r.customValidation[0].expression,f=(v&&v.match(/\?\s*true\s*:\s*['"](.+?)['"]/)?v.match(/\?\s*true\s*:\s*['"](.+?)['"]/)[1]:void 0)||r.validationMessage||(r.label||r.id)+" is invalid",m=e;n.customValidation=[function(e){var t=e.value;if(c&&(""===t||null==t))return!0;var o={};m.collectAllComponents(m.processedSchemaCache.components).forEach(function(e){e.name&&(o[e.id]=e.name)});for(var i=ze({},m.currentFormValues||{}),a=0,n=Object.keys(ze({},i));a<n.length;a++){var s=n[a],l=i[s],p=o[s];p&&(i[p]=l,delete i[s])}for(var h=0,d=r.customValidation;h<d.length;h++){var u=d[h];if(!m.customValidationEngine)return!0;if(!0!==m.customValidationEngine.validate(u.expression,t,i))return!1}return!0},f]}!c||u||g||(n.required=[!0,r.validationMessage||r.label+" is required"]),!r.minLength||u||g||(n.minLength=[r.minLength,"Minimum "+r.minLength+" characters allowed"]),!r.maxLength||u||g||(n.maxLength=[r.maxLength,"Maximum "+r.maxLength+" characters allowed"]),"textbox"!==r.type||!r.textboxType||r.regex||n.regex||u||g||("email"===r.textboxType?n.regex=[ie.EMAIL,r.validationMessage||"Invalid format"]:"url"===r.textboxType&&(n.regex=[ie.URL,r.validationMessage||"Invalid format"])),!r.regex||u||g||(n.regex=[r.regex,r.validationMessage||"Invalid format"]),Object.keys(n).length>0&&(t[r.id]=n),r.children&&i(r.children,s&&!l),r.tableCells&&r.tableCells.forEach(function(e){return e.forEach(function(e){return i(e,s&&!l)})}),r.tabItems&&r.tabItems.forEach(function(e){e.content&&i(e.content,s&&!l)})}}})};i(this.processedSchemaCache.components);var r=this.formState?ze({},this.formState.values):ze({},this.initialValuesCache);if(this.formState={values:Object.assign(Object.create(null),this.initialValuesCache,r),errors:this.enablePersistence?this.formState.errors:Object.create(null)},r&&Object.keys(r).forEach(function(t){t in e.formState.values||(e.formState.values[t]=r[t])}),this.validator){try{this.validator.refresh(),this.validator.destroy()}catch(e){}this.validator=null}var a=this;this.validator=new C.FormValidator(this.element,{rules:t,locale:this.locale,ignore:"e-hidden",errorClass:"e-error",validClass:"e-valid",errorElement:"div",errorContainer:"div",customPlacement:function(e,t){var o=e.getAttribute("name");if(o){var i=document.getElementById("error-"+o);if(i){for(;i.firstChild;)i.removeChild(i.firstChild);i.appendChild(t),i.style.display="block"}else e.parentElement&&e.parentElement.appendChild(t)}else e.parentElement&&e.parentElement.appendChild(t)},validationComplete:function(e){if(a.syncFormStateErrors(),e&&e.inputName){var t=document.getElementById("error-"+e.inputName);if(t)if("success"===e.status){for(;t.firstChild;)t.removeChild(t.firstChild);t.style.display="none"}else"failure"===e.status&&(t.style.display="block")}},submit:function(e){a.validator&&(a.validator.validate()?(a.handleSubmitData(ze({},a.formState.values)),e&&"function"==typeof e.preventDefault&&e.preventDefault()):e&&"function"==typeof e.preventDefault&&e.preventDefault())},reset:function(){}}),r&&Object.keys(r).forEach(function(t){var o=e.validator.getInputElement(t);if(o&&void 0!==r[t]&&null!==r[t])try{o.value=String(r[t])}catch(e){}})},t.prototype.syncFormStateErrors=function(){var e={};if(this.validator)for(var t=0,o=this.validator.errorRules||[];t<o.length;t++){var i=o[t];i&&i.name&&(e[i.name]=i.message)}this.formState.errors=e},t.prototype.buildInitialValues=function(){var e=this,t={},o=this.collectAllComponents(this.processedSchemaCache.components),i=new Set;return o.forEach(function(e){if("staticHtml"!==e.type){if("dataGrid"===e.type&&(t[e.id]=Array.isArray(e.dataSource)?e.dataSource:[]),void 0!==e.defaultValue)t[e.id]=e.defaultValue;else switch(e.type){case"checkbox":case"switch":t[e.id]=!1}i.add(e.id)}else i.add(e.id)}),this.formState&&Object.keys(this.formState.values).filter(function(e){return!i.has(e)}).forEach(function(t){delete e.formState.values[t]}),t},t.prototype.initExpressionEngine=function(){if(this.processedSchemaCache.components&&0!==this.processedSchemaCache.components.length)try{var e=this.expressionEngine,t=this.collectAllComponents(this.processedSchemaCache.components),o=e.buildDependencyGraph(t);e.detectCircularDependencies(o).length,this.expressionDependencyGraph=o;var i=new Set;t.forEach(function(e){e.expressionValue&&i.add(e.id)}),this.computedFieldNames=i}catch(e){this.failure&&this.trigger("failure",{error:e})}},t.prototype.disposeTooltipInstance=function(e){var t=this.tooltipRefs[e]||null;if(t){try{t.destroy()}catch(e){this.trigger("failure",{error:e})}this.renderedInstances=this.renderedInstances.filter(function(e){return e!==t}),this.tooltipRefs[e]=null}},t.prototype.renderField=function(e){var t=this,o=this.formState,i=o?o.values:{};if(-1!==["panel","table","tabs","card","message","button","splitButton","staticHtml"].indexOf(e.type))return null;var r=V.isFieldReadOnly(e.conditions,i),a=V.isFieldDisabled(e.conditions,i),n=V.isFieldRequired(e.conditions,i),s=V.getConditionalValue(e.conditions,i),l=!!e.readOnly||r,p=!!e.disabled||a,h=!!e.required||n,d=Ie.getConstraints(e.minMaxRange,i,e.type);if("dateTime"===e.type){var c=Ie.getConstraints(e.minMaxRange,i,"date"),u=Ie.getConstraints(e.minMaxTimeRange,i,"time");d={minValue:void 0,maxValue:void 0,minDate:c.minDate,maxDate:c.maxDate,minTime:u.minTime,maxTime:u.maxTime}}var v=e.labelPosition||"top",f=e.labelWidth||"auto",m=!e.hideLabel&&!!e.label&&-1===["checkbox","button","staticHtml"].indexOf(e.type),C=!(!o||!o.errors[e.id]),y=C&&!(!o||-1===o.errors[e.id].indexOf("required")),x=C&&!(y&&!h),P=void 0!==s,w=this.conditionalValueApplied[e.id]||!1;o&&(P&&!w?(o.values[e.id]=s,this.conditionalValueApplied[e.id]=!0):!P&&w&&(this.conditionalValueApplied[e.id]=!1));var j=(0,g.createElement)("div",{className:"form-group",attrs:{"data-field-id":e.id,"data-fr-field":e.id}}),S=(0,g.createElement)("div",{className:"field-wrapper label-"+v.toLowerCase()});if(m){var O=(0,g.createElement)("label",{className:"field-label"});-1===Re.indexOf(e.type)&&"textarea"!==e.type||O.setAttribute("for",(0,g.isNullOrUndefined)(this.element.id)?e.name:this.element.id+"-"+e.name),O.style.width="left"===v.toLowerCase()?f+"%":"auto";var T=(0,g.createElement)("span");if(T.textContent=e.label,O.appendChild(T),h){var k=(0,g.createElement)("span",{className:"required-asterisk"});k.textContent="*",O.appendChild(k)}if(this.disposeTooltipInstance(e.id),e.tooltip){var F=(0,g.createElement)("span",{className:"e-msg-icon e-icons e-circle-info tooltip-icon",attrs:{"aria-label":e.tooltip,title:e.tooltip,tabindex:"0",role:"button","aria-haspopup":"true"}});F.style.cursor="pointer",F.style.display="flex",F.style.alignItems="center",F.style.justifyContent="center",F.style.flexShrink="0",O.appendChild(F);var I=new b.Tooltip({content:e.tooltip,enableRtl:this.enableRtl});I.appendTo(F),this.tooltipRefs[e.id]=I,this.renderedInstances.push(I)}S.appendChild(O)}var A=(0,g.createElement)("div",{className:"field-input"}),z=("radio"===e.type||"checkboxGroup"===e.type)&&Array.isArray(e.options)?function(o,i){o&&"number"==typeof i&&(t.inputRefs[e.name+"_"+i]=o)}:function(o){o&&(t.inputRefs[e.name]=o)},D=ze({},e,{readOnly:l,disabled:p,required:h},void 0!==d.minValue&&{minValue:d.minValue},void 0!==d.maxValue&&{maxValue:d.maxValue},void 0!==d.minDate&&{minDate:d.minDate},void 0!==d.maxDate&&{maxDate:d.maxDate},void 0!==d.minTime&&{minTime:d.minTime},void 0!==d.maxTime&&{maxTime:d.maxTime}),R=-1!==Re.indexOf(e.type)?"input":"textarea"===e.type?"textarea":"div",L=(0,g.createElement)(R,{attrs:{"aria-label":e.label+" "+e.type}});if("radio"===e.type||"checkboxGroup"===e.type){var E=(0,g.createElement)("input");E.id=(0,g.isNullOrUndefined)(this.element.id)?e.name:this.element.id+"-"+e.name,E.setAttribute("name",e.id),E.style.display="none",E.setAttribute("aria-hidden","true"),L.appendChild(E)}else L.id=(0,g.isNullOrUndefined)(this.element.id)?e.name:this.element.id+"-"+e.name,L.setAttribute("name",e.id);A.appendChild(L);var X=Pe({component:D,value:o?o.values[e.id]:void 0,onChange:function(i){if("staticHtml"!==e.type){if("signature"===e.type)i=t.inputRefs[i].getSignature();if("imageEditor"===e.type){var r=t.inputRefs[i].getImageData(),a=document.createElement("canvas");a.width=r.width,a.height=r.height;var n=a.getContext("2d");n&&n.putImageData(r,0,0),i=a.toDataURL()}if("radio"===e.type||"checkboxGroup"===e.type)t.validator.getInputElement(e.id).value=i;i=function(e,t){var o=new g.Internationalization,i=o.getDateFormat({format:"MM/dd/yyyy",type:"date"});return"date"===e.type&&(t=i(new Date(t))),"time"===e.type&&(t=(i=o.getDateFormat({format:"hh:mm a",type:"time"}))(new Date(t))),"dateTime"===e.type&&(t=(i=o.getDateFormat({format:"MM/dd/yyyy hh:mm a",type:"dateTime"}))(new Date(t))),"dateRange"===e.type&&Array.isArray(t)&&(t=t.map(function(e){return e?i(new Date(e)):null})),t}(e,i),t.formState&&o&&(t.formState.values[e.id]=i,o.values[e.id]=i),t.trigger("change",{fieldName:e.name,label:e.label||e.id,value:i}),t.afterValueChange(e.id)}},formState:o,settings:this.processedSchemaCache.settings,onBlur:function(){if(o&&"staticHtml"!==e.type&&t.validator){try{t.beforeValidate(e.id),t.validator.validate(e.id)}catch(e){}t.syncFormStateErrors()}},ref:z,hasError:x,locale:this.locale,components:this.collectAllComponents(this.processedSchemaCache.components),enableRtl:this.enableRtl,target:L,l10n:this.l10n});if(Array.isArray(X))X.forEach(function(e){if(e&&"function"==typeof e.destroy)t.renderedInstances.push(e);else if(e instanceof HTMLElement)for(var o=0,i=Object.keys(t.inputRefs);o<i.length;o++){var r=i[o],a=t.inputRefs[r],n=a&&(a.element||a.target||a.hostElement&&a.hostElement());n&&(n===e||e.contains(n))&&t.renderedInstances.push(a)}});else if(X)if("function"==typeof X.destroy)this.renderedInstances.push(X);else if(X instanceof HTMLElement)for(var Y=0,M=Object.keys(this.inputRefs);Y<M.length;Y++){var B=M[Y],H=this.inputRefs[B],U=H&&(H.element||H.target||H.hostElement&&H.hostElement());U&&(U===X||X.contains(U))&&this.renderedInstances.push(H)}var W=(0,g.createElement)("div",{id:"error-"+(e.id||e.name||e.label),className:"e-error-message",attrs:{role:"alert","aria-live":"assertive"}});if(W.style.display="none",x&&o&&o.errors[e.id]&&(W.textContent=o.errors[e.id],W.classList.add("e-error"),W.style.display="block"),A.appendChild(W),S.appendChild(A),j.appendChild(S),e.description){var N=(0,g.createElement)("div",{className:"field-description",attrs:{"aria-describedby":"description-"+e.label}});N.textContent=e.description,j.appendChild(N)}return j},t.prototype.renderComponent=function(e){var t=this,i=this.formState,r=i?i.values:{},a=!1!==e.visible&&V.isFieldVisible(e.conditions,r),n=V.isFieldHidden(e.conditions,r);if(!a||n)return i&&void 0!==i.values[e.id]&&null!==i.values[e.id]&&(i.values[e.id]=null),null;if(o.PRESERVABLE_TYPES.has(e.type)&&this.preservedFields.has(e.id)){var s=this.preservedFields.get(e.id);if(s)return this.preservedFields.delete(e.id),s}switch(e.type){case"panel":if((T=(0,g.createElement)("fieldset",{className:"form-panel-renderer "+(e.cssClass||"")})).style.minInlineSize="unset",e.label&&!e.hideLabel){var l=(0,g.createElement)("legend",{className:e.hideBorders?"":"panel-legend"});l.textContent=e.label,T.appendChild(l)}var p=(0,g.createElement)("div",{className:"panel-content"});return(e.children||[]).forEach(function(e){var o=t.renderComponent(e);o&&p.appendChild(o)}),T.appendChild(p),T;case"table":for(var h=e.rows||(e.tableCells?e.tableCells.length:2),d=e.columns||(e.tableCells&&e.tableCells[0]?e.tableCells[0].length:2),c=Math.floor(12/d),u=e.columnWidths,f=u?function(e){var t=e.map(function(e){return null===e?NaN:Number(e)}),o=t.reduce(function(e,t){return e+(isNaN(t)?0:t)},0),i=Math.max(0,Math.round(100-o)),r=t.map(function(e,t){return isNaN(e)?t:-1}).filter(function(e){return e>=0}),a=r.length;if(0===a)return t.map(function(e){return Math.round(e)});var n=Math.floor(i/a),s=i-n*a;return r.forEach(function(e){var o=s>0?n+1:n;t[e]=o,s=Math.max(0,s-1)}),t.map(function(e){return isNaN(e)?0:Math.round(e)})}(u.widths):[],m=(0,g.createElement)("div",{className:"form-table-renderer "+(e.hideBorders?"":"table-border")+" "+(e.cssClass||""),attrs:{role:"group","aria-label":e.label||"Table Layout"}}),b=0;b<h;b++){var C=(0,g.createElement)("div",{className:"e-form-table-row"});e.hideBorders&&(C.style.display="flex",C.style.gap="1.5rem");for(var y=function(o){var i=e.tableCells&&e.tableCells[b]&&e.tableCells[b][o]||[],r=c,a=f[o],n=1===d?{width:"100%"}:a?{width:a+"%"}:{},s=!u||Array.isArray(u.widths)&&u.widths.every(function(e){return null===e}),l=0===b,p=(0,g.createElement)("div",{className:"e-form-table-cell "+(a?"":s?"col-"+r:"")});e.hideBorders?Object.assign(p.style,n,{padding:l?"0":"12px 0 0 0"}):Object.assign(p.style,n),i.forEach(function(e){var o=t.renderComponent(e);o&&p.appendChild(o)}),C.appendChild(p)},x=0;x<d;x++)y(x);m.appendChild(C)}return m;case"tabs":var P=(0,g.createElement)("div",{className:"form-tabs-renderer "+(e.cssClass||"")}),w=(0,g.createElement)("div",{className:"e-tab"});w.id=e.id;var j=(0,g.createElement)("div",{className:"e-tab-header"}),S=(0,g.createElement)("div",{className:"e-content"});w.appendChild(j),w.appendChild(S),P.appendChild(w),(e.tabItems||[]).forEach(function(e){var o=(0,g.createElement)("div");o.textContent=e.header,j.appendChild(o);var i=(0,g.createElement)("div"),r=(0,g.createElement)("div",{className:"tab-content-renderer"});(e.content||[]).forEach(function(e){var o=t.renderComponent(e);o&&r.appendChild(o)}),i.appendChild(r),S.appendChild(i)});var O=new v.Tab({enableRtl:this.enableRtl,cssClass:e.cssClass,enablePersistence:!0,animation:{previous:{effect:"None"},next:{effect:"None"}},selected:function(t){if("undefined"==typeof window)return null;try{window.localStorage.setItem("tab"+e.id,JSON.stringify({selectedItem:t.selectedIndex}))}catch(e){}}});return O.appendTo(w),this.renderedInstances.push(O),P;case"card":var T;(T=(0,g.createElement)("fieldset",{className:"e-card form-card-renderer "+(e.cssClass||"")})).style.minInlineSize="unset",T.style.padding="0";var k=(0,g.createElement)("div",{className:"e-card-header"}),F=(0,g.createElement)("div",{className:"e-card-header-caption"}),I=(0,g.createElement)("div",{className:"e-card-title"});if(I.textContent=e.cardTitle||e.label||"Card Title",F.appendChild(I),e.cardSubtitle){var A=(0,g.createElement)("div",{className:"e-card-sub-title"});A.textContent=e.cardSubtitle,F.appendChild(A)}k.appendChild(F),T.appendChild(k);var z=(0,g.createElement)("div",{className:"e-card-content card-content"});return(e.children||[]).forEach(function(e){var o=t.renderComponent(e);o&&z.appendChild(o)}),T.appendChild(z),T;case"staticHtml":var D=new Fe({content:e.defaultValue||"<p>HTML content</p>",id:e.id,enableHtmlSanitizer:e.enableHtmlSanitizer}),R=D.render();return this.renderedInstances.push(D),R;case"message":var L=(0,g.createElement)("div",{className:"form-group"});(M=(0,g.createElement)("div")).id=e.name,M.setAttribute("name",e.id),L.appendChild(M);var E=Pe({component:e,locale:this.locale,value:void 0,onChange:function(){},enableRtl:this.enableRtl,target:M,ref:function(o,i){void 0!==i?t.inputRefs[e.name+"_"+i]=o:t.inputRefs[e.name]=o}});return Array.isArray(E)?E.forEach(function(e){e&&t.renderedInstances.push(e)}):E&&this.renderedInstances.push(E),L;case"button":var X=V.isFieldDisabled(e.conditions,r),Y=!!e.disabled||X;L=(0,g.createElement)("div",{className:"form-group"});(M=(0,g.createElement)("div")).id=e.name,M.setAttribute("name",e.id),L.appendChild(M);E=Pe({component:ze({},e,{disabled:Y}),value:void 0,onChange:function(){},locale:this.locale,onClick:function(o){if(t.buttonClick){var i=e.buttonsGroups?o.target&&o.target.ej2_instances?o.target.ej2_instances[0].content:"":e.label||"";t.trigger("buttonClick",{fieldName:e.name,label:i,event:o})}var r=o.target;if(r.type&&"reset"===r.type){var a=r.closest("form");a&&(a.querySelectorAll('input[type="checkbox"]').forEach(function(e){e.ej2_instances[0].checked=!1}),a.querySelectorAll(".e-control.e-multiselect.e-lib").forEach(function(e){e.ej2_instances[0].value=[]})),t.formState.values={},a.reset(),t.rerenderForm(),t.validator.destroy()}},ref:function(o,i){void 0!==i?t.inputRefs[e.name+"_"+i]=o:t.inputRefs[e.name]=o},enableRtl:this.enableRtl,target:M});return Array.isArray(E)?E.forEach(function(e){e&&t.renderedInstances.push(e)}):E&&this.renderedInstances.push(E),L;case"splitButton":var M,B=V.isFieldDisabled(e.conditions,r),H=!!e.disabled||B;L=(0,g.createElement)("div",{className:"form-group"});(M=(0,g.createElement)("div")).id=e.name,M.setAttribute("name",e.id),L.appendChild(M);E=Pe({component:ze({},e,{disabled:H}),value:void 0,locale:this.locale,onChange:function(){},onClick:function(o){t.buttonClick&&t.trigger("buttonClick",{fieldName:e.name,label:e.label||"",event:o})},ref:function(o){o&&(t.inputRefs[e.name]=o)},enableRtl:this.enableRtl,target:M});return Array.isArray(E)?E.forEach(function(e){e&&t.renderedInstances.push(e)}):E&&this.renderedInstances.push(E),L;default:return this.renderField(e)}},t.prototype.afterValueChange=function(e){this.formState&&(this.currentFormValues=ze({},this.formState.values),this.evaluateExpressions(),this.retriggerCustomValidation(),this.beforeValidate(e),this.validator.validate(e),this.syncFormStateErrors(),e&&this.isConditionalTrigger(e)&&this.scheduleRerender(e))},t.prototype.beforeValidate=function(e){var t=this.element.querySelector("#"+e+"-info");t&&t.classList.contains("e-error")&&t.classList.remove("e-error");var o=this.getInputElementByName(e),i=o.parentElement,r=i.parentElement;i.classList.contains("e-control-wrapper")||i.classList.contains("e-wrapper")||o.classList.contains("e-input")&&i.classList.contains("e-input-group")?i.classList.remove("e-error"):null!=r&&(r.classList.contains("e-control-wrapper")||r.classList.contains("e-wrapper"))?r.classList.remove("e-error"):o.classList.remove("e-error"),this.validator&&(this.validator.errorRules=[])},t.prototype.scheduleRerender=function(e){var t=this;e&&this.pendingChangedFieldIds.add(e),this.rerenderScheduled||(this.rerenderScheduled=!0,Promise.resolve().then(function(){t.rerenderScheduled=!1;var e=new Set(t.pendingChangedFieldIds);t.pendingChangedFieldIds.clear(),t.rerenderForm(e)}))},t.prototype.collectConditionFieldIds=function(e,t){if(e)if("string"==typeof e.field)t.add(e.field);else if(Array.isArray(e.rules))for(var o=0,i=e.rules;o<i.length;o++){var r=i[o];this.collectConditionFieldIds(r,t)}},t.prototype.collectDataSourceReferenceIds=function(e,t,o){if("string"==typeof e){var i=e.match(/\{([^}]+)\}/g);if(i)for(var r=function(e){var i=e.slice(1,-1),r=t.find(function(e){return e.name===i});r&&r.id&&o.add(r.id)},a=0,n=i;a<n.length;a++){r(n[a])}}},t.prototype.buildConditionalDependencyMap=function(){for(var e=new Set,t=new Map,o=this.collectAllComponents(this.processedSchemaCache.components),i=function(i){var a=new Set;t.set(i.id,a);var n=i.conditions;if(n){for(var s=0,l=["visibleWhen","hideWhen","disabledWhen","requiredWhen","readOnlyWhen","choiceBasedField","conditionalData"];s<l.length;s++){var p=l[s];n[p]&&(r.collectConditionFieldIds(n[p],e),r.collectConditionFieldIds(n[p],a))}if(Array.isArray(n.conditionalData))for(var h=0,d=n.conditionalData;h<d.length;h++){var c=d[h];if(c&&c.condition&&(r.collectConditionFieldIds(c.condition,e),r.collectConditionFieldIds(c.condition,a)),c&&Array.isArray(c.conditions))for(var u=0,g=c.conditions;u<g.length;u++){var v=g[u];r.collectConditionFieldIds(v,e),r.collectConditionFieldIds(v,a)}}n.setValueWhen&&n.setValueWhen.condition&&(r.collectConditionFieldIds(n.setValueWhen.condition,e),r.collectConditionFieldIds(n.setValueWhen.condition,a)),n.choiceBasedField&&"string"==typeof n.choiceBasedField.primaryFieldId&&(e.add(n.choiceBasedField.primaryFieldId),a.add(n.choiceBasedField.primaryFieldId))}var f=function(t){if(t&&!0===t.enabled){var o=function(t){t&&"object"==typeof t&&"string"==typeof t.field&&(e.add(t.field),a.add(t.field))};o(t.minValue),o(t.maxValue)}},m=i.minMaxRange;if(Array.isArray(m))for(var b=0,C=m;b<C.length;b++){f(C[b])}var y=i.minMaxTimeRange;if(Array.isArray(y))for(var x=0,P=y;x<P.length;x++){f(P[x])}var w=i.dataSource;if("dataGrid"===i.type&&w&&"url"===w.type&&(w.search&&"string"==typeof w.search.key&&(r.collectDataSourceReferenceIds(w.search.key,o,e),r.collectDataSourceReferenceIds(w.search.key,o,a)),Array.isArray(w.filters)))for(var j=0,S=w.filters;j<S.length;j++){var O=S[j];"string"==typeof O.value&&(r.collectDataSourceReferenceIds(O.value,o,e),r.collectDataSourceReferenceIds(O.value,o,a))}},r=this,a=0,n=o;a<n.length;a++){i(n[a])}this.conditionalTriggerFieldIds=e,this.consumerDependencyMap=t},t.prototype.isConditionalTrigger=function(e){return this.conditionalTriggerFieldIds.has(e)},t.prototype.rerenderForm=function(e){var t=this,i=e||new Set,r=document.activeElement,a=r&&r.getAttribute?r.getAttribute("name"):null,n=null,s=null;if(a&&r&&void 0!==r.selectionStart)try{n=r.selectionStart,s=r.selectionEnd}catch(e){}var l=this.element.scrollTop,p=this.element.scrollLeft,h=window.scrollX,d=window.scrollY;this.preservedFields.clear();for(var c=this.collectAllComponents(this.processedSchemaCache.components),u=function(e){if(!o.PRESERVABLE_TYPES.has(e.type))return"continue";var t=g.consumerDependencyMap.get(e.id),r=!1;if(t&&i.forEach(function(e){t.has(e)&&(r=!0)}),r)return"continue";var a=g.element.querySelector('[data-field-id="'+e.id+'"]');a&&a.parentElement&&(a.parentElement.removeChild(a),g.preservedFields.set(e.id,a))},g=this,v=0,f=c;v<f.length;v++){u(f[v])}this.refreshing=!0,this.destroyRenderedExcludingPreserved(),this.removePreviousRoot(),this.validator&&this.validator.destroy(),this.render(),this.refreshing=!1;try{this.element.scrollTop=l,this.element.scrollLeft=p,window.scrollTo(h,d)}catch(e){}if(a){var m=this.getInputElementByName(a);if(m&&"function"==typeof m.focus)try{if(m.focus(),null!==n&&null!==s&&"function"==typeof m.setSelectionRange)try{m.setSelectionRange(n,s)}catch(e){}}catch(e){}}if(this.preservedFields.size>0){var b=[];this.preservedFields.forEach(function(e,o){if(t.element.contains(e)||document.body.contains(e))b.push(o);else{t.destroyPreservedSubtree(e);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){}t.preservedFields.delete(o)}}),b.forEach(function(e){return t.preservedFields.delete(e)})}},t.prototype.removePreviousRoot=function(){if(this.element)for(;this.element.childNodes.length>0;)this.element.removeChild(this.element.firstChild)},t.prototype.destroyRenderedInstance=function(e){if(e&&"function"==typeof e.destroy){var t=e;if(!(t.isDestroyed||t.destroyed||t.disposed)){var o=e.element||e.target||(e.hostElement&&"function"==typeof e.hostElement?e.hostElement():void 0);try{t.isDestroyed=!0,t.destroyed=!0,t.disposed=!0,e.destroy()}catch(e){console.warn("FormRenderer: failed to destroy child instance.",e)}finally{if(o&&o.parentNode)try{o.parentNode.removeChild(o)}catch(e){}}}}},t.prototype.destroyRenderedExcludingPreserved=function(){for(var e=[],t=Array.from(this.preservedFields.values()),o=function(o){var r=o&&(o.element||o.target||o.hostElement&&o.hostElement());!!r&&t.some(function(e){return e===r||e.contains(r)})?e.push(o):i.destroyRenderedInstance(o)},i=this,r=0,a=this.renderedInstances;r<a.length;r++){o(a[r])}this.renderedInstances=e;for(var n=Object.keys(this.inputRefs),s=function(e){var o=l.inputRefs[e],i=o&&(o.element||o.target||o.hostElement&&o.hostElement());!!i&&t.some(function(e){return e===i||e.contains(i)})||delete l.inputRefs[e]},l=this,p=0,h=n;p<h.length;p++){s(h[p])}this.conditionalValueApplied={},this.expressionDependencyGraph={},this.computedFieldNames=new Set,this.previousFormValues={},this.conditionalTriggerFieldIds=new Set},t.prototype.destroyPreservedSubtree=function(e){for(var t=[],o=0,i=this.renderedInstances;o<i.length;o++){var r=i[o],a=r&&(r.element||r.target||r.hostElement&&r.hostElement());a&&(a===e||e.contains(a))?this.destroyRenderedInstance(r):t.push(r)}this.renderedInstances=t},t.prototype.getInputElementByName=function(e){var t=this.element.querySelector('[name="'+e+'"]');if(!t)return null;if(!t.classList.contains("e-control")){var o=t.parentElement?t.parentElement.querySelector(".e-control"):null;if(o)return o}return t},t.prototype.evaluateExpressions=function(){if(this.formState&&this.expressionEngine&&!this.expressionEvaluationInProgress)try{this.expressionEvaluationInProgress=!0;var e=this.expressionEngine,t=this.expressionDependencyGraph,o=this.formState.values||{},i=this.collectAllComponents(this.processedSchemaCache.components),r=this.previousFormValues,a=this.computedFieldNames,n={};i.forEach(function(e){e.name&&(n[e.id]=e.name)});for(var s={},l=Object.keys(o),p=0,h=l;p<h.length;p++){var d=h[p],c=o[d];(j=n[d])&&(s[j]=c)}var u=ze({},r);Object.assign(r,s);for(var g=new Set,v=Object.keys(s),f=function(e){var t=Object.keys(n).find(function(t){return n[t]===e});t&&s[e]!==u[e]&&!a.has(t)&&g.add(e)},m=0,b=v;m<b.length;m++){f(j=b[m])}if(0===g.size)return;for(var C=e.getTopologicalOrder(t),y=function(t){var r=i.find(function(e){return e.name===t});if(r&&r.expressionValue){a.add(r.id);try{if(!1!==r.visible&&V.isFieldVisible(r.conditions,o)){for(var s={},l=Object.keys(o),p=0,h=l;p<h.length;p++){var d=h[p],c=o[d],u=n[d];u&&(s[u]=c)}var g=e.evaluate(r.expressionValue,s);if(null!=(g="string"==typeof g&&-1!==g.indexOf("undefined")?g.replace(/undefined/g,""):g)&&""!==g)switch(r.type){case"number":var v=Number(g);g=isNaN(v)?0:v;break;case"checkbox":case"switch":g=Boolean(g);break;case"textbox":case"textarea":default:g=String(g);case"dateRange":case"checkboxGroup":case"multiselect":}if(null!=g&&g!==o[r.id]&&x.formState&&(x.formState.values[r.id]=g,x.validator)){var f=x.getInputElementByName(r.id);if(f)try{f.ej2_instances[0]?f.ej2_instances[0].value=g:f.value=String(g)}catch(e){}}}}catch(e){x.failure&&x.trigger("failure",{error:e})}}},x=this,P=0,w=C;P<w.length;P++){var j;y(j=w[P])}Object.assign(r,s)}finally{this.expressionEvaluationInProgress=!1}},t.prototype.retriggerCustomValidation=function(){var e=this;if(this.formState&&this.customValidationEngine)try{var t=this.collectAllComponents(this.processedSchemaCache.components),o=this.formState.values||{},i=this.previousFormValues,r=new Set;if(Object.keys(o).forEach(function(e){o[e]!==i[e]&&r.add(e)}),0===r.size)return;var a=new Set;r.forEach(function(e){var o=t.find(function(t){return t.id===e});o&&o.customValidation&&Array.isArray(o.customValidation)&&a.add(e)}),t.forEach(function(o){o.customValidation&&Array.isArray(o.customValidation)&&o.customValidation.forEach(function(i){e.customValidationEngine.extractDependencies(i.expression).forEach(function(e){var i=t.find(function(t){return t.id===e||t.name===e});i&&r.has(i.id)&&a.add(o.id)})})}),this.previousFormValues=ze({},o)}catch(e){this.failure&&this.trigger("failure",{error:e})}},t.prototype.handleSubmitData=function(e){for(var t=this.formState,o=!(!t||!t.errors)&&0===Object.keys(t.errors).length,i={},r=t?t.values:{},a=new Set(["button","message","panel","table","tabs"]),n=this.collectAllComponents(this.processedSchemaCache.components||[]),s=new Set(n.filter(function(e){return a.has(e.type)}).map(function(e){return e.id})),l=new Set(n.filter(function(e){return!1===e.visible||(!(!e.conditions||!e.conditions.visibleWhen||V.isFieldVisible(e.conditions,r))||!!(e.conditions&&e.conditions.hideWhen&&V.isFieldHidden(e.conditions,r)))}).map(function(e){return e.id})),p=new Set(n.filter(function(e){return!!e.disabled||!(!e.conditions||!e.conditions.disabledWhen)&&V.isFieldDisabled(e.conditions,r)}).map(function(e){return e.id})),h=0,d=Object.keys(e);h<d.length;h++){var c=d[h],u=e[c];if(s.has(c)||l.has(c)||p.has(c))return;i[this.idToLabelCache[c]||c]=u}this.submit&&this.trigger("submit",{data:i,isValid:o})},t.prototype.getComponent=function(e){return this.inputRefs[e]||null},t.prototype.onPropertyChanged=function(e,t){var o=!1;e.schema!==t.schema&&(o=!0),e.locale!==t.locale&&(o=!0),e.enableRtl!==t.enableRtl&&(o=!0),e.layout!==t.layout&&(o=!0),e.locale!==t.locale&&(o=!0),o&&(this.refreshing=!0,this.destroyRendered(),this.removePreviousRoot(),this.isInitialized=!1,this.render(),this.refreshing=!1)},t.prototype.destroyRendered=function(){var e=this;if(this.validator){try{this.validator.destroy()}catch(e){this.trigger("failure",{error:e})}this.validator=null}this.renderedInstances.forEach(function(t){e.destroyRenderedInstance(t)}),this.renderedInstances=[],this.removePreviousRoot(),this.inputRefs={},this.tooltipRefs={},this.conditionalValueApplied={},this.expressionDependencyGraph={},this.computedFieldNames=new Set,this.previousFormValues={},this.conditionalTriggerFieldIds=new Set,this.consumerDependencyMap=new Map,this.preservedFields=new Map,this.pendingChangedFieldIds=new Set},t.prototype.clearPersistedTabSelections=function(){if("undefined"==typeof window)return null;try{var e=this.processedSchemaCache&&this.processedSchemaCache.components?this.processedSchemaCache.components:[];this.collectAllComponents(e).forEach(function(e){"tabs"===e.type&&e.id&&window.localStorage.removeItem("tab"+e.id)})}catch(e){}},t.prototype.destroy=function(){this.destroyRendered(),this.formState={values:{},errors:{}},this.expressionEngine=null,this.customValidationEngine=null,this.clearEngineCaches(),this.clearPersistedTabSelections(),this.consumerDependencyMap=new Map,this.preservedFields=new Map,this.conditionalTriggerFieldIds=new Set,e.prototype.destroy.call(this)},t.prototype.clearEngineCaches=function(){if(this.expressionEngine)try{this.expressionEngine.clearCache()}catch(e){}if(this.customValidationEngine){var e=this.customValidationEngine.expressionEngine;if(e&&"function"==typeof e.clearCache)try{e.clearCache()}catch(e){}}},t.PRESERVABLE_TYPES=new Set(["textbox","textarea","number","checkbox","checkboxGroup","radio","dropdown","multiselect","button","date","dateTime","time","dateRange","switch","signature","rating","imageEditor","fileUpload","rangeSlider","colorPicker","inputMask","message","panel","table","tabs","dataGrid","staticHtml","card","splitButton","richTextEditor"]),De([(0,g.Property)(null)],t.prototype,"schema",void 0),De([(0,g.Property)("SingleColumn")],t.prototype,"layout",void 0),De([(0,g.Property)("")],t.prototype,"className",void 0),De([(0,g.Event)()],t.prototype,"submit",void 0),De([(0,g.Event)()],t.prototype,"change",void 0),De([(0,g.Event)()],t.prototype,"buttonClick",void 0),De([(0,g.Event)()],t.prototype,"failure",void 0),De([(0,g.Event)()],t.prototype,"created",void 0),t=o=De([g.NotifyPropertyChanges],t)}(g.Component);var Xe;!function(e){e.SingleColumn="SingleColumn",e.TwoColumn="TwoColumn",e.ThreeColumn="ThreeColumn",e.FourColumn="FourColumn"}(Xe||(Xe={}));var Ye=["textbox","textarea","number","checkbox","checkboxGroup","radio","dropdown","multiselect","button","date","dateTime","time","dateRange","switch","signature","rating","imageEditor","fileUpload","rangeSlider","colorPicker","inputMask","message","panel","table","tabs","dataGrid","staticHtml","card","splitButton","richTextEditor"],Me=f(705),Be=function(){var e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])},e(t,o)};return function(t,o){function i(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)}}(),He=function(e){function t(t){var o=e.call(this,t)||this;return o.initRenderCalled=!1,o.checkInjectedModules=!1,o.statelessTemplateProps=null,o.templateProps=null,o.immediateRender=!0,o.isReactMock=!0,o.portals=[],o}return Be(t,e),t.prototype.render=function(){if(this.isReactMock=!1,!(this.element&&!this.initRenderCalled||this.refreshing)||this.isReactForeceUpdate)return u.createElement("div",this.getDefaultAttributes(),[].concat(this.props.children,this.portals));e.prototype.render.call(this),this.initRenderCalled=!0},t}(Ee);(0,Me.applyMixins)(He,[Me.ComponentBase,u.Component])})(),m})());
|