import{E as G,F as H}from"./chunk-HWLEL4TN.js";import{C as $,a as L,c as z,g as D,n as k}from"./chunk-B5LZ35ZT.js";import{a as j}from"./chunk-UNKOZF3E.js";import{Ab as h,Ac as P,Bb as c,Cc as A,Ga as a,Nc as V,Ob as _,Pb as C,Ra as S,Tb as F,Ub as I,Vb as O,Wb as w,X as y,Xa as d,Zg as W,aa as b,db as s,fa as M,ga as E,ha as R,mb as r,nb as p,ob as v,ra as T,sa as l,sb as x,wb as N}from"./chunk-WHTWCQ62.js";import{i as g}from"./chunk-AI7IVZV2.js";function U(t,o){if(t&1&&v(0,"my-global-icon",7),t&2){let m=c();s("iconName",m.icon());}}function X(t,o){if(t&1&&(r(0,"div",8),_(1),p()),t&2){let m=c();a(),C(m.filename);}}function B(t,o){if(t&1){let m=x();r(0,"button",9),h("click",function(){E(m);let n=c();return R(n.reset());}),N(1,0),p();}}var le=(()=>{let o=class o{notifier=b(W);theme=l("secondary");inputLabel=l(void 0);inputName=l(void 0);extensions=l([]);maxFileSize=l(void 0);displayFilename=l(!1);displayReset=l(!1);icon=l(void 0);buttonTooltip=l(void 0);fileChanged=T();classes={};allowedExtensionsMessage="";fileInputValue;file;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","icon-only":!this.inputLabel()};}fileChange(i){if(i.target.files?.length){let[n]=i.target.files;if(n.size>this.maxFileSize()){this.notifier.error("\u03A4\u03BF \u03B1\u03C1\u03C7\u03B5\u03AF\u03BF \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF.");return;}let e="."+n.name.split(".").pop();if(this.extensions().includes(e.toLowerCase())===!1){let f="PeerTube cannot handle this kind of file. Accepted extensions are "+this.allowedExtensionsMessage+".";this.notifier.error(f);return;}this.file=n,this.propagateChange(this.file);}this.fileChanged.emit(this.file);}reset(){this.writeValue(void 0),this.propagateChange(void 0),this.fileChanged.emit(void 0);}propagateChange=i=>{};writeValue(i){this.file=i,this.file||(this.fileInputValue=null);}registerOnChange(i){this.propagateChange=i;}registerOnTouched(){}};g(o,"\u0275fac",function(n){return new(n||o)();}),g(o,"\u0275cmp",S({type:o,selectors:[["my-reactive-file"]],inputs:{theme:[1,"theme"],inputLabel:[1,"inputLabel"],inputName:[1,"inputName"],extensions:[1,"extensions"],maxFileSize:[1,"maxFileSize"],displayFilename:[1,"displayFilename"],displayReset:[1,"displayReset"],icon:[1,"icon"],buttonTooltip:[1,"buttonTooltip"]},outputs:{fileChanged:"fileChanged"},features:[w([{provide:L,useExisting:y(()=>o),multi:!0}]),M],decls:8,vars:10,consts:()=>{let i;return i="\u0395\u03C0\u03B1\u03BD\u03B1\u03C6\u03BF\u03C1\u03AC",[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(n,e){n&1&&(r(0,"div",1)(1,"div",2),d(2,U,1,1,"my-global-icon",3),r(3,"span"),_(4),p(),r(5,"input",4),h("change",function(u){return e.fileChange(u);}),O("ngModelChange",function(u){return I(e.fileInputValue,u)||(e.fileInputValue=u),u;}),p()(),d(6,X,2,1,"div",5)(7,B,2,0,"button",6),p()),n&2&&(a(),s("ngClass",e.classes)("ngbTooltip",e.buttonTooltip()),a(),s("ngIf",e.icon()),a(2),C(e.inputLabel()),a(),s("name",e.inputName())("id",e.inputName())("accept",e.extensions()),F("ngModel",e.fileInputValue),a(),s("ngIf",e.displayFilename()===!0&&e.filename),a(),s("ngIf",e.displayReset()&&e.file));},dependencies:[V,P,A,H,G,j,$,z,D,k],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:24px;height:24px;line-height:24px}.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-MDN67EQ4.css.map */`]}));let t=o;return t;})();export{le as a};/**i18n:1cf7c077143c4c267fdafbe5508f191afcef21bad6aba22a3a8dc180e1003753*///# sourceMappingURL=chunk-MDSSJT3M.js.map