import{E as G,F as H}from"./chunk-OFXGXJTA.js";import{C as $,a as L,c as z,g as D,n as k}from"./chunk-VJWG2YMW.js";import{a as j}from"./chunk-FZ5W3QGW.js";import{$b as w,Bb as h,Cb as c,Fc as P,Ha as a,Hc as A,Pb as _,Qb as C,Sa as S,Tc as V,Vb as F,Wb as I,X as y,Xb as O,Ya as d,aa as b,eb as s,fh as W,ga as M,ha as R,ia as E,nb as r,ob as p,pb as v,sa as T,ta as l,tb as x,xb as N}from"./chunk-QIQJDAPQ.js";import{i as g}from"./chunk-3HGMGVFC.js";function B(t,o){if(t&1&&v(0,"my-global-icon",7),t&2){let m=c();s("iconName",m.icon());}}function U(t,o){if(t&1&&(r(0,"div",8),_(1),p()),t&2){let m=c();a(),C(m.filename);}}function X(t,o){if(t&1){let m=x();r(0,"button",9),h("click",function(){R(m);let n=c();return E(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("\xDEessi skr\xE1 er of st\xF3r.");return;}let e="."+n.name.split(".").pop();if(this.extensions().includes(e.toLowerCase())===!1){let f="PeerTube getur ekki me\xF0h\xF6ndla\xF0 \xFEessa tegund skr\xE1a. Leyf\xF0ar skr\xE1arendingar eru "+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="Endurstilla",[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,B,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,U,2,1,"div",5)(7,X,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-PB74RRKW.css.map */`]}));let t=o;return t;})();export{le as a};/**i18n:d946b30bd8b2b104e368c275b91cb34bb911fa22291c946a5e8c8a6facd9306d*///# sourceMappingURL=chunk-TG3UQOLZ.js.map