1"use strict";(self.webpackChunkclient_panel=self.webpackChunkclient_panel||[]).push([[956],{65170:($,y,i)=>{i.d(y,{K:()=>C});var c=i(21626),O=i(21413),f=i(84412),r=i(7673),D=i(96354),p=i(99437),_=i(70980),E=i(51989),I=i(97586),v=i.n(I),u=i(54438),b=i(71289),m=i(35212);const l=`${E.c.apiUrl}`;let C=(()=>{class L{http;authService;localStoragePersistService;accountsListData$;isLoading$;accountsListDataSubject;isLoadingSubject;pageName="accountsList";totalCount$;totalCountSubject;tabValueChange$;tabValueChangeSubject;isNoDataOnStatus$;isNoDataOnStatusSubject;isNoAccountsFound$;isNoAccountsFoundSubject;totalFilteredCount$;totalFilteredCountSubject;isLoadingParent$;isLoadingParentSubject;accountsUpdatedSource=new O.B;accountsUpdated$=this.accountsUpdatedSource.asObservable();pollTimeoutId=null;suppressMountListFetch=!1;defaultDateRange={projectStartDate:this.getProjectStartDateFromLocalStorage(),endDate:v()().endOf("day").toISOString()};teamId;token;accountsListIdArray=[];accountsListPayload=new f.t({teamId:"",active:{page:1,limit:10,domains:[],industries:[],revenueRanges:[],employeeRanges:[],countries:[],icpClusters:[],journeyStages:[],engagementScores:[],bomboraGroups:[],audienceSegments:[],status:[],tags:[],search:""},archived:{page:1,limit:10,domains:[],industries:[],revenueRanges:[],employeeRanges:[],countries:[],icpClusters:[],journeyStages:[],engagementScores:[],bomboraGroups:[],audienceSegments:[],status:[],tags:[],search:""}});get accountsListPayloadValue(){return this.accountsListPayload.value}updateAccountsListPayload(t,s){if(s){let e={[s]:{...this.accountsListPayloadValue[s],...t}};this.accountsListPayload.next({...this.accountsListPayloadValue,...e})}else this.accountsListPayload.next({...this.accountsListPayloadValue,...t})}constructor(t,s,e){this.http=t,this.authService=s,this.localStoragePersistService=e,this.authService.currentUser$.subscribe(()=>{const a=this.authService.getAuthFromLocalStorage();this.token=a?.token,this.teamId=a?.userDetails?.clientAccounts[0]?.teams[0]?.teamId?._id,console.log("teamId inside of constructor",this.teamId),this.updateAccountsListPayload({teamId:this.teamId},"active"),this.accountsListPayloadInit()}
1),this.accountsListDataSubject=new f.t(void 0),this.accountsListData$=this.accountsListDataSubject.asObservable(),this.totalFilteredCountSubject=new f.t(void 0),this.totalFilteredCount$=this.totalFilteredCountSubject.asObservable(),this.isLoadingSubject=new f.t(!1),this.isLoading$=this.isLoadingSubject.asObservable(),this.isNoDataOnStatusSubject=new f.t(!1),this.isNoDataOnStatus$=this.isNoDataOnStatusSubject.asObservable(),this.totalCountSubject=new f.t(null),this.totalCount$=this.totalCountSubject.asObservable(),this.tabValueChangeSubject=new f.t(void 0),this.tabValueChange$=this.tabValueChangeSubject.asObservable(),this.isNoAccountsFoundSubject=new f.t(!1),this.isNoAccountsFound$=this.isNoAccountsFoundSubject.asObservable(),this.isLoadingParentSubject=new f.t(!1),this.isLoadingParent$=this.isLoadingParentSubject.asObservable()}handleError(t){return console.error("Error:",t),(0,r.of)(void 0).pipe((0,D.T)(()=>{throw t}))}accountsListPayloadInit(){const t=this.localStoragePersistService.getPersistedData();console.log(t,"localstorage data"),t&&t[this.pageName]?(this.updateAccountsListPayload({...t[this.pageName].filters}),0==t[this.pageName]?.filters.active?.appliedFiltersCount&&this.updateAccountsListPayload({active:{...this.accountsListPayloadValue.active,dateRange:`${this.defaultDateRange.projectStartDate}--${this.defaultDateRange.endDate}`}}),0==t[this.pageName]?.filters.archived?.appliedFiltersCount&&this.updateAccountsListPayload({archived:{...this.accountsListPayloadValue.archived,dateRange:`${this.defaultDateRange.projectStartDate}--${this.defaultDateRange.endDate}`}})):this.updateAccountsListPayload({active:{...this.accountsListPayloadValue.active,dateRange:`${this.defaultDateRange.projectStartDate}--${this.defaultDateRange.endDate}`},archived:{...this.accountsListPayloadValue.archived,dateRange:`${this.defaultDateRange.projectStartDate}--${this.defaultDateRange.endDate}`}})}getAccountList(t){if(console.log("getAccountList function",this.teamId,this.token,t),this.localStoragePersistService.setPageData(this.pageName,{columns:[],filters:this.accountsListPayloadValue}),!this.teamId||!this.token||!t)return(0,r.of)(void 0);const s=new c.Lr({Authorization:`Bearer ${this.token}`});let e=this.accountsListPayloadValue,a={search:e[t]?.search||"",domains:e[t]?.domains||[],industries:e[t]?.industries||[],revenueRanges:e[t]?.revenueRanges||[],employeeRanges:e[t]?.employeeRanges||[],countries:e[t]?.countries||[],icpClusters:e[t]?.icpClusters||[],journeyStages:e[t]?.journeyStages||[],engagementScores:e[t]?.engagementScores||[],bomboraGroups:e[t]?.bomboraGroups||[],audienceSegments:e[t]?.audienceSegments||[],tags:e[t]?.tags||[],pageOptions:{limit:parseInt(e[t]?.limit)||10,page:e[t]?.page||1}};if(this.isLoadingSubject.next(!0),this.isLoadingParentSubject.next(!0),"archived"==t)a.status=["archived"];else if("active"==t){let n=e[t]?.status?.filter(d=>"active"==d);a.status=n?.length?n:["active"]}else a.status=e[t]?.status||[];const o=(new c.Nl).set("query",JSON.stringify(a));return this.accountsListDataSubject.next(void 0),this.http.get(`${l}/accounts`,{headers:s,params:o}).pipe((0,D.T)(n=>(n&&(this.isNoDataOnStatusSubject.next(!e[t]?.search&&!e[t]?.appliedFiltersCount&&0===n.data.totalDocs),this.accountsListDataSubject.next(n.data.docs),this.totalCountSubject.next(n.data.totalDocs),this.tabValueChangeSubject.next({filteredTotal:n.data.totalDocs,pageRoute:t})),n)),(0,p.W)(n=>(console.error("err",n),(0,r.of)(void 0))),(0,_.j)(()=>{this.isLoadingParentSubject.next(!1),this.isLoadingSubject.next(!1)}))}getProjectStartDateFromLocalStorage(){const t=localStorage.getItem("teamCreatedAt");if(console.log("Retrieved projectStartDate from localStorage:",t),t){const s=v()(t,v().ISO_8601,!0);if(s.isValid())return console.log("Parsed projectStartDate:",s.startOf("day").toISOString()),s.startOf("day").toISOString();console.error("Invalid Date format for projectStartDate:",t)}else console.error("projectStartDate is null or undefined");return v()("02-05-2022","DD-MM-YYYY").startOf("day").toISOString()}fetchStatusTotalAccounts(t=!0){if(t&&this.totalFilteredCountSubject.next(!1),!this.token)return(0,r.of)(void 0);const s=new c.Lr({Authorization:`Bearer ${this.token}`});return this.http.get(`${l}/accounts/statusCount`,{headers:s}).pipe((0,D.T)(e=>(this.isNoAccountsFoundSubject.next(!((e?.data?.active||0)+(e?.data?.draft||0)+(e?.data?.archived||0)>0)),this.totalFilteredCountSubject.next(!0),e)),(0,p.W)(e=>this.handleError(e)),(0,_.j)(()=>{this.isLoadingParentSubject.next(!1)}))}addAccountIdToArrayIfNotExists(t){this.accountsListIdArray.includes(t)||this.accountsListIdArray.push(t),console.log(this.accountsListIdArray)}removeAccountIdFromArray(t){const s=this.accountsListIdArray.indexOf(t);-1!==s&&this.accountsListIdArray.splice(s,1),console.log(this.accountsListIdArray)}getFilterValues(){const t=this.authService.getAuthFromLocalStorage();if(!t||!t.token)return(0,r.of)(void 0);this.token=t.token;const s=t?.userDetails?.clientAccounts[0]?.teams[0]?.teamId?._id;let e={};s&&(e={teamId:s});const a=new c.Lr({Authorization:`Bearer ${this.token}`});return this.http.get(`${l}/accounts/filters`,{headers:a,params:e})}notifyAccountsUpdated(t={}){this.accountsUpdatedSource.next(t)}prependCreatedAccount(t){if(!t||!t._id)return;const s=this.accountsListDataSubject.value||[];s.some(a=>a?._id===t._id)||(this.accountsListDataSubject.next([t,...s]),this.totalCountSubject.next((this.totalCountSubject.value??0)+1),this.suppressMountListFetch=!0)}consumeSuppressMountListFetch(){const t=this.suppressMountListFetch;return this.suppressMountListFetch=!1,t}pollForAccountListRefresh(t,s,e=[1e3,1500,2500,4e3,7e3,12e3]){if(!this.teamId||!this.token)return;this.cancelAccountsListPoll(),this.updateAccountsListPayload({page:1},t);const a=this.totalCountSubject.value??0,o=h=>{this.refreshStatusCountSilent().subscribe(),this.fetchAccountsListSilent(t).subscribe({next:g=>
1{if(!g?.data)return void this.scheduleNextPoll(o,h);const P=g.data.docs||[],S=g.data.totalDocs??0;(!!s&&P.some(M=>M?._id===s)||!s&&S>a||0===h.length)&&this.commitAccountsListResponse(P,S,t),this.scheduleNextPoll(o,h)},error:()=>{this.scheduleNextPoll(o,h)}})},[n,...d]=e;this.pollTimeoutId=setTimeout(()=>o(d),n)}refreshStatusCountSilent(){if(!this.token)return(0,r.of)(void 0);const t=new c.Lr({Authorization:`Bearer ${this.token}`});return this.http.get(`${l}/accounts/statusCount`,{headers:t}).pipe((0,D.T)(s=>((s?.data?.active||0)+(s?.data?.draft||0)+(s?.data?.archived||0)>0&&!0===this.isNoAccountsFoundSubject.value&&this.isNoAccountsFoundSubject.next(!1),s)),(0,p.W)(()=>(0,r.of)(void 0)))}scheduleNextPoll(t,s){if(0===s.length)return;const[e,...a]=s;this.pollTimeoutId=setTimeout(()=>t(a),e)}cancelAccountsListPoll(){this.pollTimeoutId&&(clearTimeout(this.pollTimeoutId),this.pollTimeoutId=null)}verifyAccountAppeared(t,s,e,a=[500,1e3,1500,2500,4e3,6e3]){if(!this.teamId||!this.token)return void e?.(!1);this.cancelAccountsListPoll(),this.updateAccountsListPayload({page:1},t);const o=this.totalCountSubject.value??0;let n=!1;const d=S=>{n||(n=!0,this.cancelAccountsListPoll(),e?.(S))},h=S=>{this.refreshStatusCountSilent().subscribe(),this.fetchAccountsListSilent(t).subscribe({next:A=>{const j=A?.data?.docs||[],T=A?.data?.totalDocs??0;if(s&&j.some(N=>N?._id===s)||T>o)return this.commitAccountsListResponse(j,T,t),void d(!0);0!==S.length?this.scheduleNextPoll(h,S):d(!1)},error:()=>{0!==S.length?this.scheduleNextPoll(h,S):d(!1)}})},[g,...P]=a;this.pollTimeoutId=setTimeout(()=>h(P),g)}commitAccountsListResponse(t,s,e){this.accountsListDataSubject.next(t),this.totalCountSubject.next(s),this.tabValueChangeSubject.next({filteredTotal:s,pageRoute:e}),s>0&&this.isNoDataOnStatusSubject.next(!1)}fetchAccountsListSilent(t){if(!this.teamId||!this.token||!t)return(0,r.of)(void 0);const s=new c.Lr({Authorization:`Bearer ${this.token}`}),e=this.accountsListPayloadValue,a={search:e[t]?.search||"",domains:e[t]?.domains||[],industries:e[t]?.industries||[],revenueRanges:e[t]?.revenueRanges||[],employeeRanges:e[t]?.employeeRanges||[],countries:e[t]?.countries||[],icpClusters:e[t]?.icpClusters||[],journeyStages:e[t]?.journeyStages||[],engagementScores:e[t]?.engagementScores||[],bomboraGroups:e[t]?.bomboraGroups||[],audienceSegments:e[t]?.audienceSegments||[],tags:e[t]?.tags||[],pageOptions:{limit:parseInt(e[t]?.limit)||10,page:e[t]?.page||1}};if("archived"===t)a.status=["archived"];else if("active"===t){const n=e[t]?.status?.filter(d=>"active"===d);a.status=n?.length?n:["active"]}else a.status=e[t]?.status||[];const o=(new c.Nl).set("query",JSON.stringify(a));return this.http.get(`${l}/accounts`,{headers:s,params:o}).pipe((0,p.W)(n=>(console.error("silent poll err",n),(0,r.of)(void 0))))}updateAccountsStatus(t,s){if(!this.token)return(0,r.of)(void 0);const e=new c.Lr({Authorization:`Bearer ${this.token}`});return this.http.put(`${l}/accounts/updateStatus`,{accountIds:t,status:s},{headers:e}).pipe((0,p.W)(this.handleError))}downloadTemplate(t="json"){const s=this.authService.getAuthFromLocalStorage();if(!s||!s.token)return(0,r.of)(null);const e=new c.Lr({Authorization:`Bearer ${this.token}`});return this.http.get(`${l}/static-files/Smartpage-content-example-2.csv`,{headers:e,responseType:t})}getDomains(t,s){const e=this.authService.getAuthFromLocalStorage();if(!e||!e.token)return(0,r.of)(void 0);this.token=e.token;const a=e?.userDetails?.clientAccounts[0]?.teams[0]?.teamId?._id;let o={};a&&(o={teamId:a,limit:t||10,search:s||""});const n=new c.Lr({Authorization:`Bearer ${this.token}`});return this.http.get(`${l}/accounts/filters/domains`,{headers:n,params:o})}getAllTags(){const t=this.authService.getAuthFromLocalStorage();if(!t||!t.token)return(0,r.of)(void 0);this.token=t.token;const s=new c.Lr({Authorization:`Bearer ${this.token}`});return this.http.get(`${l}/accounts/filters/tags`,{headers:s})}static \u0275fac=function(s){return new(s||L)(u.KVO(c.Qq),u.KVO(b.uR),u.KVO(m.m))};static \u0275prov=u.jDH({token:L,factory:L.\u0275fac,providedIn:"root"})}return L})()},62087:($,y,i)=>{i.d(y,{w:()=>I});var c=i(43236),O=i(28211),f=i(39974),r=i(58750),D=i(81853),p=i(54360),_=i(45225);const E=(0,D.L)(u=>function(m=null){u(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=m});function I(u,b){const{first:m,each:l,with:C=v,scheduler:L=b??c.E,meta:x=null}=(0,O.v)(u)?{first:u}:"number"==typeof u?{each:u}:u;if(null==m&&null==l)throw new TypeError("No timeout provided.");return(0,f.N)((t,s)=>{let e,a,o=null,n=0;const d=h=>
1{a=(0,_.N)(s,L,()=>{try{e.unsubscribe(),(0,r.Tg)(C({meta:x,lastValue:o,seen:n})).subscribe(s)}catch(g){s.error(g)}},h)};e=t.subscribe((0,p._)(s,h=>{a?.unsubscribe(),n++,s.next(o=h),l>0&&d(l)},void 0,void 0,()=>{a?.closed||a?.unsubscribe(),o=null})),!n&&d(null!=m?"number"==typeof m?m:+m-L.now():l)})}function v(u){throw new E(u)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.