import{a as W}from"./chunk-B33EZKBN.js";import{a as B}from"./chunk-VC3IPOUZ.js";import{a as k}from"./chunk-YV66O7E5.js";import{C as U,a as V,g as L,n as F}from"./chunk-VUHOGLVJ.js";import{$g as $,Ab as S,Ac as z,Bb as _,Da as y,Ga as m,Gc as D,Nb as x,Nc as I,Ra as E,Tb as O,Ub as R,Vb as T,Wb as A,X as M,Xa as v,Yb as N,aa as b,db as l,ga as p,ha as d,ib as C,mb as g,nb as c,nc as P,ob as f,sa as a,sb as w,zh as H}from"./chunk-A3ION7ZA.js";import{i as u}from"./chunk-AI7IVZV2.js";var X=t=>({"buttons-aside":t});function j(t,n){if(t&1&&f(0,"img",2),t&2){let r=_();l("ngStyle",r.previewSize())("src",r.imageSrc,y);}}function q(t,n){if(t&1&&f(0,"div",3),t&2){let r=_();l("ngStyle",r.previewSize());}}function Q(t,n){if(t&1){let r=w();g(0,"my-delete-button",7),S("click",function(){p(r),_();let o=x(5);return d(o.reset());}),c();}}var le=(()=>{let n=class n{serverService=b(H);inputName=a.required();inputLabel=a(void 0);displayDelete=a(!1,{transform:P});buttonsAside=a(!1,{transform:P});previewSize=a(void 0);imageSrc;allowedExtensionsMessage="";maxSizeText;file;serverConfig;bytesPipe;constructor(){this.bytesPipe=new B(),this.maxSizeText="\u6700\u5927\u5927\u5C0F";}get videoImageExtensions(){return this.serverConfig.video.image.extensions;}get maxVideoImageSize(){return this.serverConfig.video.image.size.max;}get maxVideoImageSizeInBytes(){return this.bytesPipe.transform(this.maxVideoImageSize);}getReactiveFileButtonTooltip(){return"\uFF08\u6269\u5C55\u540D\uFF1A"+this.videoImageExtensions+"\u3001"+this.maxSizeText+"\uFF1A"+this.maxVideoImageSizeInBytes+"\uFF09";}ngOnInit(){this.serverConfig=this.serverService.getHTMLConfig(),this.allowedExtensionsMessage=this.videoImageExtensions.join(", ");}onFileChanged(i){this.file=i,this.propagateChange(this.file),this.updatePreview();}propagateChange=i=>{};writeValue(i){this.file=i,this.updatePreview();}registerOnChange(i){this.propagateChange=i;}registerOnTouched(){}updatePreview(){this.file?$(this.file).then(i=>this.imageSrc=i):this.imageSrc=void 0;}};u(n,"\u0275fac",function(o){return new(o||n)();}),u(n,"\u0275cmp",E({type:n,selectors:[["my-preview-upload"]],inputs:{inputName:[1,"inputName"],inputLabel:[1,"inputLabel"],displayDelete:[1,"displayDelete"],buttonsAside:[1,"buttonsAside"],previewSize:[1,"previewSize"]},features:[A([{provide:V,useExisting:M(()=>n),multi:!0}])],decls:7,vars:11,consts:()=>{let i;i="\u9884\u89C8";let o;return o="Delete the image",[["reactiveFile",""],[1,"preview-container",3,"ngClass"],["alt",i,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,e){if(o&1){let h=w();g(0,"div",1),v(1,j,1,2,"img",2)(2,q,1,1,"div",3),g(3,"div",4)(4,"my-reactive-file",5,0),T("ngModelChange",function(s){return p(h),R(e.file,s)||(e.file=s),d(s);}),S("fileChanged",function(s){return p(h),d(e.onFileChanged(s));}),c(),v(6,Q,1,0,"my-delete-button",6),c()();}o&2&&(l("ngClass",N(9,X,e.buttonsAside())),m(),C(e.imageSrc?1:2),m(3),O("ngModel",e.file),l("inputName",e.inputName())("inputLabel",e.inputLabel())("extensions",e.videoImageExtensions)("maxFileSize",e.maxVideoImageSize)("buttonTooltip",e.getReactiveFileButtonTooltip()),m(2),C(e.displayDelete()&&e.file?6:-1));},dependencies:[I,z,D,U,L,F,W,k],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);padding-inline-end:calc(1.275rem + .3vw);padding-top:1rem;padding-bottom:1rem}@media (min-width: 1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-start:1.5rem}}@media (min-width: 1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-end:1.5rem}}.preview-container.buttons-aside[_ngcontent-%COMP%]   .buttons[_ngcontent-%COMP%]{margin-top:1rem}
/*# sourceMappingURL=preview-upload.component-HRV2QN6T.css.map */`]}));let t=n;return t;})();export{le as a};/**i18n:1cf7c077143c4c267fdafbe5508f191afcef21bad6aba22a3a8dc180e1003753*///# sourceMappingURL=chunk-QO27LZLC.js.map