import{D as $}from"./chunk-XYUXA3LT.js";import{A as k,a as A,c as L,g as z,l as D}from"./chunk-K34LZIA3.js";import{a as H}from"./chunk-BUPI2ADN.js";import{Bb as h,Ca as a,Cb as _,Da as S,Gb as I,Hb as F,Ib as N,Jb as O,Kb as w,Na as g,Va as r,Vf as G,X as C,ba as y,cb as p,db as m,eb as v,ib as T,ka as b,la as M,ma as E,mb as x,qb as d,rb as u,rc as P,sa as R,tc as V}from"./chunk-X3RCWQ3R.js";import{i as t}from"./chunk-SR6RTMQI.js";function W(n,o){if(n&1&&v(0,"my-global-icon",7),n&2){let c=u();r("iconName",c.icon);}}function j(n,o){if(n&1&&(p(0,"div",8),h(1),m()),n&2){let c=u();a(),_(c.filename);}}function B(n,o){if(n&1){let c=T();p(0,"button",9),d("click",function(){M(c);let l=u();return E(l.reset());}),x(1,0),m();}}var ne=(()=>{let o=class o{constructor(i){t(this,"notifier");t(this,"theme","secondary");t(this,"inputLabel");t(this,"inputName");t(this,"extensions",[]);t(this,"maxFileSize");t(this,"displayFilename",!1);t(this,"displayReset",!1);t(this,"icon");t(this,"buttonTooltip");t(this,"fileChanged",new R());t(this,"classes",{});t(this,"allowedExtensionsMessage","");t(this,"fileInputValue");t(this,"file");t(this,"propagateChange",i=>{});this.notifier=i;}get filename(){return this.file?this.file.name:"";}ngOnInit(){this.allowedExtensionsMessage=this.extensions.join(", "),this.buildClasses();}ngOnChanges(){this.buildClasses();}buildClasses(){this.classes={"with-icon":!!this.icon,"primary-button":this.theme==="primary","secondary-button":this.theme==="secondary"};}fileChange(i){var l;if((l=i.target.files)!=null&&l.length){let[e]=i.target.files;if(e.size>this.maxFileSize){this.notifier.error("\u0E02\u0E19\u0E32\u0E14\u0E44\u0E1F\u0E25\u0E4C\u0E43\u0E2B\u0E0D\u0E48\u0E40\u0E01\u0E34\u0E19\u0E44\u0E1B");return;}let f="."+e.name.split(".").pop();if(this.extensions.includes(f.toLowerCase())===!1){let s="PeerTube \u0E44\u0E21\u0E48\u0E23\u0E2D\u0E07\u0E23\u0E31\u0E1A\u0E44\u0E1F\u0E25\u0E4C\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E19\u0E35\u0E49 \u0E19\u0E32\u0E21\u0E2A\u0E01\u0E38\u0E25\u0E17\u0E35\u0E48\u0E23\u0E2D\u0E07\u0E23\u0E31\u0E1A\u0E04\u0E37\u0E2D "+this.allowedExtensionsMessage+"";this.notifier.error(s);return;}this.file=e,this.propagateChange(this.file);}this.fileChanged.emit(this.file);}reset(){this.writeValue(void 0),this.propagateChange(void 0),this.fileChanged.emit(void 0);}writeValue(i){this.file=i,this.file||(this.fileInputValue=null);}registerOnChange(i){this.propagateChange=i;}registerOnTouched(){}};t(o,"\u0275fac",function(l){return new(l||o)(S(G));}),t(o,"\u0275cmp",y({type:o,selectors:[["my-reactive-file"]],inputs:{theme:"theme",inputLabel:"inputLabel",inputName:"inputName",extensions:"extensions",maxFileSize:"maxFileSize",displayFilename:"displayFilename",displayReset:"displayReset",icon:"icon",buttonTooltip:"buttonTooltip"},outputs:{fileChanged:"fileChanged"},standalone:!0,features:[O([{provide:A,useExisting:C(()=>o),multi:!0}]),b,w],decls:8,vars:10,consts:()=>{let i;return i="\u0E23\u0E35\u0E40\u0E0B\u0E47\u0E15",[i,[1,"root"],[1,"button-file",3,"ngClass","ngbTooltip"],[3,"iconName",4,"ngIf"],["type","file",3,"change","ngModelChange","name","id","accept","ngModel"],["class","filename",4,"ngIf"],["class","reset-button reset-button-small ms-2",3,"click",4,"ngIf"],[3,"iconName"],[1,"filename"],[1,"reset-button","reset-button-small","ms-2",3,"click"]];},template:function(l,e){l&1&&(p(0,"div",1)(1,"div",2),g(2,W,1,1,"my-global-icon",3),p(3,"span"),h(4),m(),p(5,"input",4),d("change",function(s){return e.fileChange(s);}),N("ngModelChange",function(s){return F(e.fileInputValue,s)||(e.fileInputValue=s),s;}),m()(),g(6,j,2,1,"div",5)(7,B,2,0,"button",6),m()),l&2&&(a(),r("ngClass",e.classes)("ngbTooltip",e.buttonTooltip),a(),r("ngIf",e.icon),a(2),_(e.inputLabel),a(),r("name",e.inputName)("id",e.inputName)("accept",e.extensions),I("ngModel",e.fileInputValue),a(),r("ngIf",e.displayFilename===!0&&e.filename),a(),r("ngIf",e.displayReset&&e.filename));},dependencies:[P,$,V,H,k,L,z,D],styles:[`.root[_ngcontent-%COMP%]{height:auto;display:flex;align-items:center}.root[_ngcontent-%COMP%]   .button-file.with-icon[_ngcontent-%COMP%]   my-global-icon[_ngcontent-%COMP%]{position:relative;top:-1px;right:0;display:inline-block;width:20px;height:20px;line-height:20px}.root[_ngcontent-%COMP%]   .button-file.with-icon[_ngcontent-%COMP%]:not(.icon-only)   my-global-icon[_ngcontent-%COMP%]{margin-inline-end:.1875rem}.root[_ngcontent-%COMP%]   .filename[_ngcontent-%COMP%]{font-weight:600;margin-inline-start:.3125rem}
/*# sourceMappingURL=reactive-file.component-RVGSEB4K.css.map */`]}));let n=o;return n;})();export{ne as a};/**i18n:3d16453f213eb5db982e7e7dd90631843ac5d3f860726a614777c3e9e3f9b57e*///# sourceMappingURL=chunk-KQJ2QY7W.js.map