import{a as V}from"./chunk-M67LUUOV.js";import{a as U}from"./chunk-OSWYUQHE.js";import{a as B}from"./chunk-3MOC5IX2.js";import{E as $,a as D,g as F,o as L}from"./chunk-MQKTIDDS.js";import{Aa as P,Da as p,Ec as a,Hb as M,Jb as d,Mc as h,Na as y,Tb as x,Vg as G,Wc as A,Y as w,Zc as R,ba as b,cc as E,dc as I,ec as N,fd as z,ga as u,gb as C,ha as _,hb as f,kc as O,mb as l,mc as T,nb as m,ob as g,pb as v,vh as H,zb as S}from"./chunk-L6W7X4TF.js";import{i as c}from"./chunk-WH5WJFMZ.js";var X=t=>({"buttons-aside":t});function W(t,n){if(t&1&&v(0,"img",2),t&2){let r=d();l("ngStyle",r.previewSize())("src",r.imageSrc,P);}}function q(t,n){if(t&1&&v(0,"div",3),t&2){let r=d();l("ngStyle",r.previewSize());}}function K(t,n){if(t&1){let r=S();m(0,"my-delete-button",7),M("click",function(){u(r),d();let o=x(5);return _(o.reset());}),g();}}var le=(()=>{let n=class n{serverService=b(H);inputName=a.required();inputLabel=a();displayDelete=a(!1,{transform:h});buttonsAside=a(!1,{transform:h});previewSize=a();fileConstraints=a();imageSrc;maxSizeText;file;imageExtensions=[];maxImageSize;maxImageSizeInBytes;allowedExtensionsMessage="";serverConfig;bytesPipe;constructor(){this.bytesPipe=new U(),this.maxSizeText="max ve\u013Ekos\u0165";}getReactiveFileButtonTooltip(){return"(extensions: "+this.imageExtensions.join(", ")+", max size: "+this.maxImageSizeInBytes+")";}ngOnInit(){this.serverConfig=this.serverService.getHTMLConfig();let e=this.fileConstraints()??this.serverConfig.video.image;this.imageExtensions=e.extensions,this.maxImageSize=e.size.max,this.maxImageSizeInBytes=this.bytesPipe.transform(this.maxImageSize),this.allowedExtensionsMessage=this.imageExtensions.join(", ");}onFileChanged(e){this.file=e,this.propagateChange(this.file),this.updatePreview();}propagateChange=e=>{};writeValue(e){this.file=e,this.updatePreview();}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}updatePreview(){this.file?G(this.file).then(e=>this.imageSrc=e):this.imageSrc=void 0;}};c(n,"\u0275fac",function(o){return new(o||n)();}),c(n,"\u0275cmp",y({type:n,selectors:[["my-image-input"]],inputs:{inputName:[1,"inputName"],inputLabel:[1,"inputLabel"],displayDelete:[1,"displayDelete"],buttonsAside:[1,"buttonsAside"],previewSize:[1,"previewSize"],fileConstraints:[1,"fileConstraints"]},features:[O([{provide:D,useExisting:w(()=>n),multi:!0}])],decls:7,vars:11,consts:()=>{let e;e="N\xE1h\u013Ead";let o;return o="Delete the image",[["reactiveFile",""],[1,"preview-container",3,"ngClass"],["alt",e,1,"preview",3,"ngStyle","src"],[1,"preview","no-image",3,"ngStyle"],[1,"buttons"],["placement","right","icon","upload","theme","primary",3,"ngModelChange","fileChanged","ngModel","inputName","inputLabel","extensions","maxFileSize","buttonTooltip"],["title",o,"theme","danger"],["title",o,"theme","danger",3,"click"]];},template:function(o,i){if(o&1){let k=S();m(0,"div",1),C(1,W,1,2,"img",2)(2,q,1,1,"div",3),m(3,"div",4)(4,"my-reactive-file",5,0),N("ngModelChange",function(s){return u(k),I(i.file,s)||(i.file=s),_(s);}),M("fileChanged",function(s){return i.onFileChanged(s);}),g(),C(6,K,1,0,"my-delete-button",6),g()();}o&2&&(l("ngClass",T(9,X,i.buttonsAside())),p(),f(i.imageSrc?1:2),p(3),E("ngModel",i.file),l("inputName",i.inputName())("inputLabel",i.inputLabel())("extensions",i.imageExtensions)("maxFileSize",i.maxImageSize)("buttonTooltip",i.getReactiveFileButtonTooltip()),p(2),f(i.displayDelete()&&i.file?6:-1));},dependencies:[z,A,R,$,F,L,V,B],styles:[`[_nghost-%COMP%]{display:block}.preview-container[_ngcontent-%COMP%], .preview[_ngcontent-%COMP%]{height:100%;width:100%}.preview-container[_ngcontent-%COMP%]{position:relative}.preview-container[_ngcontent-%COMP%]   .buttons[_ngcontent-%COMP%]{display:flex;gap:10px}.preview-container[_ngcontent-%COMP%]   .preview[_ngcontent-%COMP%]{object-fit:cover;border-radius:4px;max-width:100%}.preview-container[_ngcontent-%COMP%]:not(.buttons-aside)   .buttons[_ngcontent-%COMP%]{position:absolute;bottom:10px;left:10px;flex-wrap:wrap}.preview-container[_ngcontent-%COMP%]:not(.buttons-aside)   .preview.no-image[_ngcontent-%COMP%]{border:2px solid var(--secondary-icon-color);background-color:var(--bg)}.preview-container.buttons-aside[_ngcontent-%COMP%]{text-align:center;border:1px solid var(--secondary-icon-color);border-radius:4px;width:min-content;padding-inline-start:calc(1.275rem + .3vw)}@media(min-width:1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-start:1.5rem}}.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-end:calc(1.275rem + .3vw)}@media(min-width:1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-end:1.5rem}}.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-top:1rem;padding-bottom:1rem}.preview-container.buttons-aside[_ngcontent-%COMP%]   .buttons[_ngcontent-%COMP%]{margin-top:1rem}
/*# sourceMappingURL=image-input.component-TKGNYA4A.css.map */`]}));let t=n;return t;})();export{le as a};/**i18n:ae7e6707fc51a9e1f6f015929aece8afe43a92a094f09f07f0463afe6c89573f*///# sourceMappingURL=chunk-WFJBF3RL.js.map