Your IP : 18.117.157.126
import{h as G,i as K,j as Y,k as Z,l as J,m as F,n as Q,o as W,p as M,q as E,z as te}from"./chunk-M6DH5DPB.js";import{$b as k,Ac as j,Cc as ee,Eb as B,Ta as L,bc as q,c as T,ca as I,ea as O,f as v,fa as R,k as C,oc as V,tc as X}from"./chunk-SXUPRFOU.js";import{F as D,G as H,S as A,a as w,b as _,m as g,s as N,t as z,xa as b}from"./chunk-ERDNNTNA.js";function U(l){if(l===0)return"0 B";let a=1024,P=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],e=Math.floor(Math.log(l)/Math.log(a));return`${(l/Math.pow(a,e)).toFixed(2)} ${P[e]}`}var ke=(()=>{let a=class a{constructor(e,t,i,r,n){this.tabService=e,this.preloadedActionService=t,this.appService=i,this.actionService=r,this.httpBaseService=n,this.uploads$=new N}uploadFromVirtualForm(e,t,i,r){return g(this,null,function*(){let n=t,h,{uploadName:f,uploadType:m}=E(n,c=>this.appService.getDesktopMessage(c)),p=M(n);this.updateUploadCenter(e,{percent:0,size:U(p),phase:"check",confirmationActions:null,uploadName:f,uploadType:m,cancelHandler:()=>this.cancelAction(h)});let s,o;return new Promise(c=>{h=this.preloadedActionService.getAction({func:"file.upload",plid:i},{showProgressbar:!1}).subscribe(d=>c(d))}).then(c=>{if(c?.error)return this.displayUploadCenterError(e,k.getError(c)),Promise.reject();if(!c)return this.displayNetworkError(e),Promise.reject();o=X.createFromDoc(c),s=G(c),this.checkAndUpload(n,s,o,e).then(d=>d&&this.reloadTabIfNeeded(i,r))})})}uploadFromExistingForm(e,t){let i=e.filename,r,{uploadName:n,uploadType:h}=E(i,c=>this.appService.getDesktopMessage(c)),f=M(i),p=`${e.nodename?`/${e.nodename}`:""}${t.plid||"/"}`.replace(/\/+/g,"/").replace(/(.+)\/$/,"$1"),s=new z({percent:0,size:U(f),phase:"check",confirmationActions:null,uploadName:n,uploadType:h,cancelHandler:()=>this.cancelAction(r)});this.uploads$.next({path:p,state:s});let o=this.checkAndUpload(i,e,t,s);return o.then(c=>{c&&this.tabService.activeTab.func==="file"&&this.reloadTabIfNeeded(p,this.tabService.activeTab)}),o}checkAndUpload(e,t,i,r){return g(this,null,function*(){let n=e,h=K(n,t,i),f={action:i.doc.metadata?.form?.$action,showProgressbar:!1},m;return new Promise(p=>{m=this.preloadedActionService.uploadAction(h,f).pipe(b(s=>{s===null&&this.displayNetworkError(r)}),A(s=>s?.type===B.Response)).subscribe(s=>p(s.body))}).then(p=>g(this,null,function*(){let s=p;if(s.error)return this.displayUploadCenterError(r,k.getError(p)),Promise.reject();if(Y(s)){let c=F(s,n);for(;c;)yield new Promise(d=>{let{firstFileBranch:y,remainingFilesSubtree:S,remainingNamesSubtree:x}=c;if(!y&&!S){d();return}if(!y){this.uploadFiles(n,t,i,r).then(()=>{n=null,d()});return}let ie=W((u,$)=>{if(u==="skip"&&!$){s=x,n=S,d();return}$?(u==="skip"&&Z(n,s),this.uploadFiles(n,t,i,r,u).then(()=>{n=null,d()})):this.uploadFiles(y,t,i,r,u).then(()=>{s=x,n=S,d()})},u=>this.appService.getDesktopMessage(u)),re=Q(y);this.updateUploadCenter(r,{percent:100,phase:"confirm",confirmationFilePath:re.join("/"),confirmationActions:ie,cancelHandler:()=>null})}),c=F(s,n);return this.updateUploadCenter(r,{percent:100,phase:"success",confirmationActions:null,cancelHandler:()=>this.cancelAction(m)}),!0}else return this.uploadFiles(n,t,i,r).then(()=>(this.updateUploadCenter(r,{percent:100,phase:"success",confirmationActions:null,cancelHandler:()=>null}),!0))}))})}uploadFiles(e,t,i,r,n="replace"){return g(this,null,function*(){let h,f=J(e,t,i,n),m={showProgressbar:!1,action:i.doc.metadata?.form?.$action};return yield new Promise(p=>setTimeout(()=>{this.showUploadProgress(0,null,r),p()})),new Promise((p,s)=>{h=this.preloadedActionService.uploadAction(f,m).pipe(b(o=>{o===null&&this.displayNetworkError(r)}),A(o=>{if(o.type===B.UploadProgress){let c=Math.round(o.loaded/o.total*100);return this.showUploadProgress(c,h,r),!1}else return!!o}),H(o=>o.body)).subscribe(o=>{o.error?(this.displayUploadCenterError(r,k.getError(o)),s()):o===null&&(this.displayNetworkError(r),s()),p(o)})})})}getMsg(e){return this.appService.getDesktopMessage(e)}retrieveLimitsData(){return g(this,null,function*(){return new Promise(e=>{this.appService.desktop.user.$name==="root"&&e(null),D(this.httpBaseService.get({func:"file.space"})).then(t=>{let i=k.getFileStorageLimits(t);if(i.limit){let r=k.getMessage("msg_limit_banner",t).replace(/__limit__/g,`${i.limit} MB`).replace(/__free__/g,`${i.free} MB`);e(r)}else e(null)})})})}reloadTabIfNeeded(e,t){e?.replace(/^\/+/,"/").replace(/\/+$/,"")===this.tabService.activeTab.plid?.replace(/^\/+/,"/").replace(/\/+$/,"")&&t.func===this.tabService.activeTab.func&&this.actionService.updateTab(t.func,t.q,t)}cancelAction(e){e&&e.unsubscribe()}showUploadProgress(e,t,i){this.updateUploadCenter(i,{percent:e,phase:"upload",cancelHandler:()=>this.cancelAction(t)})}updateUploadCenter(e,t){e.next(w(w({},e.value),t))}displayUploadCenterError(e,t){e.next(_(w({},e.value),{percent:100,phase:"error",errorText:t}))}displayNetworkError(e){this.displayUploadCenterError(e,this.appService.getDesktopMessage("msg_server_error")||"Server or Network error")}};a.\u0275fac=function(t){return new(t||a)(v(ee),v(j),v(V),v(te),v(q))},a.\u0275prov=T({token:a,factory:a.\u0275fac,providedIn:"root"});let l=a;return l})();var Pe=(()=>{let a=class a{constructor(){this.shape="rectangle",this.width="100%",this.height="100%",this.index=0}get skeletonClasses(){return`shape_${this.shape}`}get skeletonStyles(){return this.size?{width:this.size,height:this.size}:{width:this.width,height:this.height}}};a.\u0275fac=function(t){return new(t||a)},a.\u0275cmp=C({type:a,selectors:[["isp-skeleton"]],hostVars:6,hostBindings:function(t,i){t&2&&(O(i.skeletonStyles),R(i.skeletonClasses),I("--index",i.index))},inputs:{shape:"shape",width:"width",height:"height",size:"size",index:"index"},standalone:!0,features:[L],decls:0,vars:0,template:function(t,i){},styles:["[_nghost-%COMP%]{position:relative;display:block;width:100%;height:100%;background-color:var(--isp-skeleton-main-color, var(--isp-dc-norilsk));border-radius:var(--isp-border-radius-main);animation:_ngcontent-%COMP%_blink 1.5s ease-in infinite alternate;animation-delay:calc(.2s * var(--index, 0) + 50ms)}.shape_circle[_nghost-%COMP%]{flex-shrink:0;border-radius:50%}@keyframes _ngcontent-%COMP%_blink{0%{background-color:var(--isp-skeleton-main-color, var(--isp-dc-norilsk))}to{background-color:var(--isp-skeleton-blink-color, var(--isp-dc-reincarnation))}}"],changeDetection:0});let l=a;return l})();function Ae(l,a,P){return a.filter(e=>{let t=P(e)?.toLowerCase();return l.test(t)})}export{ke as a,Pe as b,Ae as c};