import{a as _}from"./chunk-677BBU6S.js";import{J as R}from"./chunk-P25H6AGX.js";import{a as m,b as v}from"./chunk-D5M6Y5VI.js";import{a as P}from"./chunk-ZZVJWSMI.js";import{Eb as I,F as a,N as U,P as f,U as l,da as z,ea as u,g,ha as s,pa as C,u as p,ua as D,v as n,z as y}from"./chunk-IYD54RT7.js";var N=(()=>{let o=class o{constructor(i,c){this.ciDashboardUiService=i,this.tmoHttpService=c,this._currentPage$=new g(0),this._currentPageSize$=new g(10),this._ciDefId=I("-1"),this.filter=I(""),this.scriptDefs=n([this.branchId,this.ciDashboardUiService.ciSetId]).pipe(a(([t,e])=>t!==""&&e!=="-1"),s(([t,e])=>this.tmoHttpService.getScriptDefList(t,e)),m(),u({bufferSize:1,refCount:!0})),this._scriptDefs=n([this.branchId,this.ciDashboardUiService.ciSetId,this.currentPage,this.currentPageSize]).pipe(a(([t,e,d,r])=>t!==""&&e!=="-1"),z(),U(500),l(),s(([t,e,d,r])=>this.tmoHttpService.getScriptDefListPagination(t,e,d+1,r)),m(),u({bufferSize:1,refCount:!0})),this._scriptDefCount=n([this.branchId,this.ciDashboardUiService.ciSetId]).pipe(a(([t,e])=>t!==""&&e!=="-1"),l(),s(([t,e])=>this.tmoHttpService.getFilteredScriptDefCount(t,e)),u({bufferSize:1,refCount:!0})),this.scriptDef=n([this.branchId,v(this.ciDefId)]).pipe(a(([t,e])=>t!==""&&e!=="-1"),s(([t,e])=>this.tmoHttpService.getScriptDef(t,e))),this._scriptResults=n([this.branchId,v(this.ciDefId)]).pipe(a(([t,e])=>t!==""&&e!=="-1"),s(([t,e])=>this.tmoHttpService.getScriptResults(t,e)),m(),u({bufferSize:1,refCount:!0}))}getScriptResult(i){return this.branchId.pipe(a(c=>c!==""&&c!=="-1"),s(c=>this.tmoHttpService.getScriptResult(c,i)))}downloadTmo(i){let c=this.scriptDef.pipe(f(1),p(r=>r.name)),t=this.getScriptResult(i).pipe(f(1),p(r=>R(new Date(r.executionDate),"_yyyy-MM-dd"))),e=y([c,t]).pipe(p(([r,b])=>r+=b)),d=this.branchId.pipe(f(1),s(r=>this.tmoHttpService.downloadTmo(r,i)));return n([d,e]).pipe(p(([r,b])=>{if(r.size!==0){let w=new Blob([r],{type:"application/xml"}),H=URL.createObjectURL(w),h=document.createElement("a");h.href=H,h.setAttribute("download",b+".tmo"),document.body.appendChild(h),h.click(),h.remove()}}))}get scriptResults(){return this._scriptResults}get ciDefId(){return this._ciDefId}set CiDefId(i){this._ciDefId.set(i)}get branchId(){return this.ciDashboardUiService.branchId}set BranchId(i){this.ciDashboardUiService.BranchId}get branchType(){return this.ciDashboardUiService.branchType}set BranchType(i){this.ciDashboardUiService.BranchType=i}get currentPage(){return this._currentPage$}set page(i){this._currentPage$.next(i)}get currentPageSize(){return this._currentPageSize$}set pageSize(i){this._currentPageSize$.next(i)}get scriptDefCount(){return this._scriptDefCount}};o.\u0275fac=function(c){return new(c||o)(D(P),D(_))},o.\u0275prov=C({token:o,factory:o.\u0275fac,providedIn:"root"});let S=o;return S})();export{N as a};
