import{G,H}from"./chunk-K6U64Q72.js";import{a as j}from"./chunk-KZ26MFAT.js";import{C as k,a as A,c as L,g as z,n as $}from"./chunk-Y4WF5HJS.js";import{$a as u,Aa as l,Bb as c,Ka as R,Oc as I,Qb as _,Rb as b,Wb as F,X as M,Xb as O,Yb as w,Zc as V,_a as p,aa as y,cc as P,eb as g,fa as v,fb as s,ga as N,gb as r,hb as T,oa as E,qh as W,rb as x,vb as S,xc as D,yc as a,zb as C}from"./chunk-R4Z6ZI3L.js";import{i as h}from"./chunk-P6NJDXIL.js";function U(n,o){if(n&1&&T(0,"my-global-icon",3),n&2){let d=c();g("iconName",d.icon());}}function X(n,o){if(n&1&&(s(0,"div",5),_(1),r()),n&2){let d=c();l(),b(d.filename);}}function B(n,o){if(n&1){let d=x();s(0,"button",7),C("click",function(){v(d);let t=c();return N(t.reset());}),S(1,0),r();}}var ae=(()=>{let o=class o{notifier=y(W);theme=a("secondary");inputLabel=a(void 0);inputName=a(void 0);extensions=a([]);maxFileSize=a(void 0);displayFilename=a(!1);displayReset=a(!1);icon=a(void 0);buttonTooltip=a(void 0);fileChanged=D();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[t]=i.target.files;if(t.size>this.maxFileSize()){this.notifier.error("\u0627\u06CC\u0646 \u0641\u0627\u06CC\u0644 \u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF \u0627\u0633\u062A.");return;}let e="."+t.name.split(".").pop();if(this.extensions().includes(e.toLowerCase())===!1){let f="\u067E\u06CC\u0631\u062A\u06CC\u0648\u0628 \u0627\u0645\u06A9\u0627\u0646 \u06A9\u0627\u0631\u06A9\u0631\u062F\u0646 \u0628\u0627 \u0627\u06CC\u0646 \u0646\u0648\u0639 \u0641\u0627\u06CC\u0644 \u0631\u0627 \u0646\u062F\u0627\u0631\u062F. \u067E\u0633\u0648\u0646\u062F\u0647\u0627\u06CC \u0645\u0648\u0631\u062F \u067E\u0630\u06CC\u0631\u0634 "+this.allowedExtensionsMessage+" \u0647\u0633\u062A\u0646\u062F.";this.notifier.error(f);return;}this.file=t,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(){}};h(o,"\u0275fac",function(t){return new(t||o)();}),h(o,"\u0275cmp",R({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:[P([{provide:A,useExisting:M(()=>o),multi:!0}]),E],decls:8,vars:10,consts:()=>{let i;return i="\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u06CC",[i,[1,"root"],[1,"button-file",3,"ngClass","ngbTooltip"],[3,"iconName"],["type","file",3,"change","ngModelChange","name","id","accept","ngModel"],[1,"filename"],[1,"reset-button","reset-button-small","ms-2"],[1,"reset-button","reset-button-small","ms-2",3,"click"]];},template:function(t,e){t&1&&(s(0,"div",1)(1,"div",2),p(2,U,1,1,"my-global-icon",3),s(3,"span"),_(4),r(),s(5,"input",4),C("change",function(m){return e.fileChange(m);}),w("ngModelChange",function(m){return O(e.fileInputValue,m)||(e.fileInputValue=m),m;}),r()(),p(6,X,2,1,"div",5),p(7,B,2,0,"button",6),r()),t&2&&(l(),g("ngClass",e.classes)("ngbTooltip",e.buttonTooltip()),l(),u(e.icon()?2:-1),l(2),b(e.inputLabel()),l(),g("name",e.inputName())("id",e.inputName())("accept",e.extensions()),F("ngModel",e.fileInputValue),l(),u(e.displayFilename()===!0&&e.filename?6:-1),l(),u(e.displayReset()&&e.file?7:-1));},dependencies:[V,I,H,G,k,L,z,$,j],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-EYJVKPIV.css.map */`]}));let n=o;return n;})();export{ae as a};/**i18n:138e9aba5923606215625ab5641fbdc103d8a34cfe13ae910386f40f27aea675*///# sourceMappingURL=chunk-5NX4V4UA.js.map