import{l as le,h}from'./chunk-CJ5LAhIS.js';import{s}from'./chunk-nfSA6zwi.js';import{g,$ as $t,K as qp,N as tl,fd as ixe,b as Pa,ah as u$,bP as D,bQ as af,R as cl,U as x3,fe as R3,J as Jn,q as qn,l as ln,F as F2,s as sp,k as w2,O as Ox,e as Fp,d as lb,m as zH,a3 as H0,a4 as d$,W as WB,o as x2,u as Mx,y as qH,f as Pp,S as SV,cF as aw,G as GI,aj as CV,z as zI,t as t$}from'./main-DEZ5cZzu.js';var X=i=>({"buttons-aside":i});function W(i,S){if(i&1&&Pp(0,"img",2),i&2){let e=SV();H0("ngStyle",e.previewSize())("src",e.imageSrc,aw);}}function q(i,S){if(i&1&&Pp(0,"div",3),i&2){let e=SV();H0("ngStyle",e.previewSize());}}function J(i,S){if(i&1){let e=F2();sp(0,"my-delete-button",7),Fp("click",function(){GI(e),SV();let t=CV(5);return zI(t.reset());}),lb();}}var me=(()=>{class i{serverService=g($t);inputName=qp.required();inputLabel=qp();displayDelete=qp(false,{transform:tl});buttonsAside=qp(false,{transform:tl});previewSize=qp();fileConstraints=qp();imageSrc;maxSizeText;file;imageExtensions=[];maxImageSize;maxImageSizeInBytes;allowedExtensionsMessage="";serverConfig;bytesPipe;constructor(){this.bytesPipe=new s(),this.maxSizeText="maks st\xF8rrelse";}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?ixe(this.file).then(e=>this.imageSrc=e):this.imageSrc=void 0;}static ɵfac=function(n){return new(n||i)();};static ɵcmp=Pa({type:i,selectors:[["my-image-input"]],inputs:{inputName:[1,"inputName"],inputLabel:[1,"inputLabel"],displayDelete:[1,"displayDelete"],buttonsAside:[1,"buttonsAside"],previewSize:[1,"previewSize"],fileConstraints:[1,"fileConstraints"]},features:[u$([{provide:D,useExisting:af(()=>i),multi:true}])],decls:7,vars:11,consts:()=>{let e;e="Forh\xE5ndsvisning";let n;return n="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",n,"theme","danger"],["title",n,"theme","danger",3,"click"]];},template:function(n,t){if(n&1){let k=F2();sp(0,"div",1),w2(1,W,1,2,"img",2)(2,q,1,1,"div",3),sp(3,"div",4)(4,"my-reactive-file",5,0),Ox("ngModelChange",function(a){return GI(k),t$(t.file,a)||(t.file=a),zI(a);}),Fp("fileChanged",function(a){return t.onFileChanged(a);}),lb(),zH(),w2(6,J,1,0,"my-delete-button",6),lb()();}n&2&&(H0("ngClass",d$(9,X,t.buttonsAside())),WB(),x2(t.imageSrc?1:2),WB(3),Mx("ngModel",t.file),H0("inputName",t.inputName())("inputLabel",t.inputLabel())("extensions",t.imageExtensions)("maxFileSize",t.maxImageSize)("buttonTooltip",t.getReactiveFileButtonTooltip()),qH(),WB(2),x2(t.displayDelete()&&t.file?6:-1));},dependencies:[cl,x3,R3,Jn,qn,ln,le,h],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}"],changeDetection:1});}return i;})();/**i18n:c8855ca17fb20171aa9dd43d012e42547cb1f0cfd9c21d4dc05679bbbdf5ccb8*/export{me as m};//# sourceMappingURL=chunk-CmeTG4Q4.js.map