export const ids=["70"];export const modules={14995:function(i,t,e){e.r(t),e.d(t,{HaImagecropperDialog:function(){return d}});var a=e(44249),o=(e(75656),e(50100),e(18084),e(31622),e(65509)),r=e.n(o),s=e(93528),c=e(57243),n=e(50778),p=e(35359),l=(e(44118),e(66193));let d=(0,a.Z)([(0,n.Mo)("image-cropper-dialog")],(function(i,t){return{F:class extends t{constructor(...t){super(...t),i(this)}},d:[{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,n.SB)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,n.SB)()],key:"_open",value:()=>!1},{kind:"field",decorators:[(0,n.IO)("img",!0)],key:"_image",value:void 0},{kind:"field",key:"_cropper",value:void 0},{kind:"field",decorators:[(0,n.SB)()],key:"_isTargetAspectRatio",value:void 0},{kind:"method",key:"showDialog",value:function(i){this._params=i,this._open=!0}},{kind:"method",key:"closeDialog",value:function(){this._open=!1,this._params=void 0,this._cropper?.destroy(),this._cropper=void 0,this._isTargetAspectRatio=!1}},{kind:"method",key:"updated",value:function(i){i.has("_params")&&this._params&&(this._cropper?this._cropper.replace(URL.createObjectURL(this._params.file)):(this._image.src=URL.createObjectURL(this._params.file),this._cropper=new(r())(this._image,{aspectRatio:this._params.options.aspectRatio,viewMode:1,dragMode:"move",minCropBoxWidth:50,ready:()=>{this._isTargetAspectRatio=this._checkMatchAspectRatio(),URL.revokeObjectURL(this._image.src)}})))}},{kind:"method",key:"_checkMatchAspectRatio",value:function(){const i=this._params?.options.aspectRatio;if(!i)return!0;const t=this._cropper.getImageData();if(t.aspectRatio===i)return!0;if(t.naturalWidth>t.naturalHeight){const e=t.naturalWidth/i;return Math.abs(e-t.naturalHeight)<=1}const e=t.naturalHeight*i;return Math.abs(e-t.naturalWidth)<=1}},{kind:"method",key:"render",value:function(){return c.dy`<ha-dialog @closed="${this.closeDialog}" scrimClickAction escapeKeyAction .open="${this._open}"> <div class="container ${(0,p.$)({round:Boolean(this._params?.options.round)})}"> <img alt="${this.hass.localize("ui.dialogs.image_cropper.crop_image")}"> </div> <mwc-button slot="secondaryAction" @click="${this.closeDialog}"> ${this.hass.localize("ui.common.cancel")} </mwc-button> ${this._isTargetAspectRatio?c.dy`<mwc-button slot="primaryAction" @click="${this._useOriginal}"> ${this.hass.localize("ui.dialogs.image_cropper.use_original")} </mwc-button>`:c.Ld} <mwc-button slot="primaryAction" @click="${this._cropImage}"> ${this.hass.localize("ui.dialogs.image_cropper.crop")} </mwc-button> </ha-dialog>`}},{kind:"method",key:"_cropImage",value:function(){this._cropper.getCroppedCanvas().toBlob((i=>{if(!i)return;const t=new File([i],this._params.file.name,{type:this._params.options.type||this._params.file.type});this._params.croppedCallback(t),this.closeDialog()}),this._params.options.type||this._params.file.type,this._params.options.quality)}},{kind:"method",key:"_useOriginal",value:function(){this._params.croppedCallback(this._params.file),this.closeDialog()}},{kind:"get",static:!0,key:"styles",value:function(){return[l.yu,c.iv`${(0,c.$m)(s)} .container{max-width:640px}img{max-width:100%}.container.round .cropper-face,.container.round .cropper-view-box{border-radius:50%}.cropper-line,.cropper-point,.cropper-point.point-se::before{background-color:var(--primary-color)}`]}}]}}),c.oi)}};
//# sourceMappingURL=70.e2f3a787e38d8ccd.js.map