=i.width&&e.height>=i.height?p:c),dt(this.cropBox,st({width:e.width,height:e.height},$t({translateX:e.left,translateY:e.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),Mt(this.element,W,this.getData())}},Ht={initPreview:function(){var t=this.element,i=this.crossOrigin,e=this.options.preview,a=i?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",o=document.createElement("img");if(i&&(o.crossOrigin=i),o.src=a,o.alt=n,this.viewBox.appendChild(o),this.viewBoxImage=o,e){var r=e;"string"==typeof e?r=t.ownerDocument.querySelectorAll(e):e.querySelector&&(r=[e]),rt(this.previews=r,function(t){var e=document.createElement("img");wt(t,E,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),i&&(e.crossOrigin=i),e.src=a,e.alt=n,e.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',t.innerHTML="",t.appendChild(e)})}},resetPreview:function(){rt(this.previews,function(t){var i=vt(t,E);dt(t,{width:i.width,height:i.height}),t.innerHTML=i.html,function(t,i){if(tt(t[i]))try{delete t[i]}catch(e){t[i]=void 0}else if(t.dataset)try{delete t.dataset[i]}catch(e){t.dataset[i]=void 0}else t.removeAttribute("data-".concat(ft(i)))}(t,E)})},preview:function(){var t=this.imageData,i=this.canvasData,e=this.cropBoxData,a=e.width,n=e.height,o=t.width,r=t.height,s=e.left-i.left-t.left,h=e.top-i.top-t.top;this.cropped&&!this.disabled&&(dt(this.viewBoxImage,st({width:o,height:r},$t(st({translateX:-s,translateY:-h},t)))),rt(this.previews,function(i){var e=vt(i,E),l=e.width,c=e.height,d=l,p=c,u=1;a&&(p=n*(u=l/a)),n&&cO&&(z.x=O-B);break;case m:C+z.x<$&&(z.x=$-C);break;case v:M+z.yj&&(z.y=j-T)}}!l&&t.shiftKey&&(l=_&&k?_/k:1),this.limited&&($=r.minLeft,E=r.minTop,O=$+Math.min(o.width,n.width,n.left+n.width),j=E+Math.min(o.height,n.height,n.top+n.height));var H=s[Object.keys(s)[0]],z={x:H.endX-H.startX,y:H.endY-H.startY};switch(h){case c:C+=z.x,M+=z.y;break;case g:if(0<=z.x&&(O<=B||l&&(M<=E||j<=T))){N=!1;break}W(g),(_+=z.x)<0&&(h=m,C-=_=-_),l&&(k=_/l,M+=(r.height-k)/2);break;case v:if(z.y<=0&&(M<=E||l&&(C<=$||O<=B))){N=!1;break}W(v),k-=z.y,M+=z.y,k<0&&(h=f,M-=k=-k),l&&(_=k*l,C+=(r.width-_)/2);break;case m:if(z.x<=0&&(C<=$||l&&(M<=E||j<=T))){N=!1;break}W(m),_-=z.x,C+=z.x,_<0&&(h=g,C-=_=-_),l&&(k=_/l,M+=(r.height-k)/2);break;case f:if(0<=z.y&&(j<=T||l&&(C<=$||O<=B))){N=!1;break}W(f),(k+=z.y)<0&&(h=v,M-=k=-k),l&&(_=k*l,C+=(r.width-_)/2);break;case w:if(l){if(z.y<=0&&(M<=E||O<=B)){N=!1;break}W(v),k-=z.y,M+=z.y,_=k*l}else W(v),W(g),0<=z.x?B or