import{a as W}from"./chunk-YREPR4YG.js";import{a as B}from"./chunk-ZHTTK5CI.js";import{a as G}from"./chunk-S3QWPEZ6.js";import{C as U,a as L,g as F,n as V}from"./chunk-KXBVYXHU.js";import{$a as C,Aa as m,Bb as u,Fc as P,Ka as E,Lb as x,Oc as D,Qh as H,Rc as z,Wb as O,X as b,Xb as R,Yb as A,Zc as I,_a as v,aa as h,cc as N,eb as l,ec as T,fa as d,fb as g,ga as p,gb as c,hb as f,rb as w,rh as $,xa as y,yc as a,zb as S}from"./chunk-THW6YIIG.js";import{i as _}from"./chunk-PTJGHD3V.js";var X=t=>({"buttons-aside":t});function j(t,n){if(t&1&&f(0,"img",2),t&2){let r=u();l("ngStyle",r.previewSize())("src",r.imageSrc,y);}}function q(t,n){if(t&1&&f(0,"div",3),t&2){let r=u();l("ngStyle",r.previewSize());}}function Q(t,n){if(t&1){let r=w();g(0,"my-delete-button",7),S("click",function(){d(r),u();let o=x(5);return p(o.reset());}),c();}}var le=(()=>{let n=class n{serverService=h(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\u526F\u6A94\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;}};_(n,"\u0275fac",function(o){return new(o||n)();}),_(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:[N([{provide:L,useExisting:b(()=>n),multi:!0}])],decls:7,vars:11,consts:()=>{let i;i="\u9810\u89BD";let o;return o="\u522A\u9664\u5F71\u50CF",[["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 M=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),A("ngModelChange",function(s){return d(M),R(e.file,s)||(e.file=s),p(s);}),S("fileChanged",function(s){return d(M),p(e.onFileChanged(s));}),c(),v(6,Q,1,0,"my-delete-button",6),c()();}o&2&&(l("ngClass",T(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,D,z,U,F,V,W,G],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-OFG3FQCP.css.map */`]}));let t=n;return t;})();export{le as a};/**i18n:90f1dd82a779b57eddc91ef20913c88eecaa9632bba8ac04ad50f47ae2b82df7*///# sourceMappingURL=chunk-OUUJP6H3.js.map