1import{e as i,p as n}from"./BExQWoUu.js";import{r as P}from"./LysqaFr6.js";import{ax as p,az as f,ay as w,aw as _}from"./D8RO7nRK.js";var E=P();const R="search.enrichments",C=new Set,O=1440*60*1e3,g={enrichments:new Map,workspaceId:"",lastUpdated:new Date};function B(r){const e={enrichments:Array.from(r.enrichments.entries()).filter(([c])=>!c.startsWith("temp-preparing-")).map(([c,m])=>({enrichmentId:c,state:{...m,contacts:Array.from(m.contacts.entries()).map(([T,d])=>{const h={...d};return delete h.enrichedData,[T,h]})}})),workspaceId:r.workspaceId,lastUpdated:r.lastUpdated.toISOString()};return JSON.stringify(e)}function W(r){try{const e=JSON.parse(r),c=new Set([i.EnrichmentStatus.ENRICHMENT_STATUS_FINISHED,i.EnrichmentStatus.ENRICHMENT_STATUS_CANCELED,i.EnrichmentStatus.ENRICHMENT_STATUS_IN_ERROR,i.EnrichmentStatus.ENRICHMENT_STATUS_CREDITS_INSUFFICIENT]),m=Date.now(),T=e.enrichments.filter(({enrichmentId:h,state:s})=>{if(c.has(s.status)||h.startsWith("temp-preparing-"))return!1;const a=new Date(s.startTime).getTime();return!(Number.isFinite(a)&&m-a>O)});for(const{enrichmentId:h,state:s}of e.enrichments)c.has(s.status)&&(C.add(h),s.backendEnrichmentId&&C.add(s.backendEnrichmentId));return{enrichments:new Map(T.map(({enrichmentId:h,state:s})=>{const a=new Map(Array.from(s.contacts).map(([l,S])=>{let o=S.enrichedData;return o&&(o={...o,enrichedAt:new Date(o.enrichedAt),expiredOn:o.expiredOn?new Date(o.expiredOn):void 0}),[l,{...S,enrichedData:o,startTime:new Date(S.startTime),endTime:S.endTime?new Date(S.endTime):void 0}]}));return[h,{...s,contacts:a,startTime:new Date(s.startTime),endTime:s.endTime?new Date(s.endTime):void 0}]})),workspaceId:e.workspaceId,lastUpdated:new Date(e.lastUpdated)}}catch(e){return console.error("Failed to deserialize enrichment state:",e),g}}function v(r){const e=Array.from(r.values()),c=new Set([i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_SUCCESS,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_PARTIAL,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_CANCELED,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_OPTOUT,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_NOT_ENOUGH_DATA]),m=new Set([i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_FAILED,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_CREDITS_INSUFFICIENT]),T=new Set([i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_CREATED,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_PENDING,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_QUEUED]);return{total:e.length,completed:e.filter(d=>c.has(d.backendStatus??d.status)).length,failed:e.filter(d=>m.has(d.backendStatus??d.status)).length,inProgress:e.filter(d=>T.has(d.status)).length}}function H(r,e){return r?{...r,...e,workEmails:e.workEmails?.length?e.workEmails:r.workEmails,personalEmails:e.personalEmails?.length?e.personalEmails:r.personalEmails,phones:e.phones?.length?e.phones:r.phones,rawPhones:e.rawPhones?.length?e.rawPhones:r.rawPhones,workEmailObjects:e.workEmailObjects?.length?e.workEmailObjects:r.workEmailObjects,personalEmailObjects:e.personalEmailObjects?.length?e.personalEmailObjects:r.personalEmailObjects,mostProbableWorkEmail:e.mostProbableWorkEmail||r.mostProbableWorkEmail,mostProbablePersonalEmail:e.mostProbablePersonalEmail||r.mostProbablePersonalEmail,mostProbablePhone:e.mostProbablePhone||r.mostProbablePhone}:e}const U=new Set;function b(r,e,c){if(U.has(r))return e.progress;const m=v(c);return e.progress.total>m.total?{...m,total:e.progress.total}:m}function G(){const r=localStorage.getItem(R),e=r?W(r):g,{subscribe:c,set:m,update:T}=w(e);let d=null;function h(){d&&(clearTimeout(d),d=null);try{const s=f({subscribe:c});localStorage.setItem(R,B(s))}catch(s){console.error("Failed to save enrichment state to localStorage:",s)}}return c(()=>{d&&clearTimeout(d),d=setTimeout(()=>{h()},2e3)}),{subscribe:c,init:s=>{T(a=>({...a,workspaceId:s,lastUpdated:new Date}))},startEnrichment:s=>{T(a=>{const l=new Map(a.enrichments);return l.set(s.enrichmentId,s),{...a,enrichments:l,lastUpdated:new Date}})},updateEnrichmentStatus:(s,a)=>{T(S=>{const o=new Map(S.enrichments),u=o.get(s);if(u){const N=new Set([i.EnrichmentStatus.ENRICHMENT_STATUS_FINISHED,i.EnrichmentStatus.ENRICHMENT_STATUS_CANCELED,i.EnrichmentStatus.ENRICHMENT_STATUS_IN_ERROR,i.EnrichmentStatus.ENRICHMENT_STATUS_CREDITS_INSUFFICIENT]);if(N.has(u.status))return S;const I=N.has(a)?new Date:u.endTime,A=new Map(u.contacts);if(a===i.EnrichmentStatus.ENRICHMENT_STATUS_FINISHED){const D=new Set([i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_CREATED,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_PENDING,i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_QUEUED]);for(const[L,k]of A.entries())D.has(k.status)&&A.set(L,{...k,status:i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_SUCCESS,endTime:I})}o.set(s,{...u,contacts:A,status:a,endTime:I})}return{...S,enrichments:o,lastUpdated:new Date}}),new Set([i.EnrichmentStatus.ENRICHMENT_STATUS_FINISHED,i.EnrichmentStatus.ENRICHMENT_STATUS_CANCELED,i.EnrichmentStatus.ENRICHMENT_STATUS_IN_ERROR,i.EnrichmentStatus.ENRICHMENT_STATUS_CREDITS_INSUFFICIENT]).has(a)&&(U.delete(s),h())},updateContact:(s,a,l)=>{T(S=>{const o=new Map(S.enrichments),u=o.get(s);if(u){const N=new Map(u.contacts),I=N.get(a);if(I){const A={...I,...l,enrichedData:l.enrichedData?H(I.enrichedData,l.enrichedData):I.enrichedData,providerProgress:l.providerProgress||I.providerProgress};N.set(a,A)}else N.set(a,{contactId:a,status:i.RowEnrichmentStatus.ROW_ENRICHMENT_STATUS_PENDING,startTime:new Date,...l});o.set(s,{...u,contacts:N,progress:b(s,u,N)})}return{...S,enrichments:o,lastUpdated:new Date}})},addContact:(s,a)=>{T(l=>{const S=new Map(l.enrichments),o=S.get(s);if(o){const u=new Map(o.contacts);u.set(a.contactId,a),S.set(s,{...o,contacts:u,progress:b(s,o,u)})}return{...l,enrichments:S,lastUpdated:new Date}})},updateProgress:(s,a,l=!1)=>{l&&U.add(s),T(S=>{const o=new Map(S.enrichments),u=o.get(s);return u&&o.set(s,{...u,progress:a}),{...S,enrichments:o,lastUpdated:new Date}})},removeEnrichment:s=>{U.delete(s),T(a=>{const l=new Map(a.enrichments);return l.delete(s),{...a,enrichments:l,lastUpdated:new Date}}),h()},getEnrichment:s=>f({subscribe:c}).enrichments.get(s),isKnownTerminal:s=>C.has(s),findByBackendEnrichmentId:s=>{const a=f({subscribe:c});for(const l of a.enrichments.values())if(l.backendEnrichmentId===s)return l},getContact:(s,a)=>f({subscribe:c}).enrichments.get(s)?.contacts.get(a),reset:()=>{m(g),localStorage.removeItem(R)},setEnrichmentMeta:(s,a)=>{T(l=>{const S=new Map(l.enrichments),o=S.get(s);return o&&S.set(s,{...o,...a.backendEnrichmentId!==void 0?{backendEnrichmentId:a.backendEnrichmentId}:{},...a.listId!==void 0?{listId:a.listId}:{},...a.registrationComplete!==void 0?{registrationComplete:a.registrationComplete}:{},...a.contactsLoaded!==void 0?{contactsLoaded:a.contactsLoaded}:{}}),{...l,enrichments:S,lastUpdated:new Date}})},flushToLocalStorage:h,clearWorkspace:s=>{T(a=>a.workspaceId===s?{...g,workspaceId:s}:a)}}}const M=G();p(M,r=>
1Array.from(r.enrichments.values()));const t={user:{isLogged:n(!1,"user.isLogged"),username:n("","user.username"),firstname:n("","user.firstname"),id:n("","user.id"),signedUp:n(!1,"user.signedUp"),phone:n("","user.phone"),createdAt:n(0,"user.createdAt"),isMultiplePhone:n(!1,"user.isMultiplePhone")},invitations:w([]),workspace:{idxWorkspaceSelected:n(-1,"workspace.idxWorkspaceSelected"),list:w([]),role:n(4,"workspace.role"),hasSubscription:n(!1,"workspace.hasSubscription"),isListBuilderDisabled:n(!1,"workspace.isListBuilderDisabled"),isCrmEnrichmentDisabled:n(!1,"workspace.isCrmEnrichmentDisabled"),currentWorkspace:_(new E.Workspace),hasPersonalEmailEnabled:n(!1,"workspace.hasPersonalEmailEnabled"),billingStatus:n(E.WorkspaceBillingStatus.WORKSPACE_BILLING_STATUS_UNKNOWN,"workspace.billingStatus"),billingStatusOverride:w(E.ManualBillingStatus.MANUAL_BILLING_STATUS_AUTO),hasActiveBillingStatus:_(!1),hasPaidPlan:n(!1,"workspace.hasPaidPlan"),isBillingStatusPaused:_(!1),hasPauseWallDisabled:_(!1),isSearchTosAccepeted:n(!1,"workspace.searchTosAccepted"),hasBlurDisabled:n(!1,"workspace.hasBlurDisabled"),hasNlSearchEnabled:n(!1,"workspace.hasNlSearchEnabled"),hasPushToHubspotListBuilderEnabled:n(!1,"workspace.hasPushToHubspotListBuilderEnabled"),experiments:n({},"workspace.experiments")},credits:{balance:n(0,"credits.balance"),availableToSpend:n(0,"credits.availableToSpend"),limit:n(null,"credits.limit"),used:n(null,"credits.used"),fetched:n(!1,"credits.fetched"),costEmail:n(1,"credits.costEmail"),costPhone:n(10,"credits.costPhone"),costPersonalEmail:n(3,"credits.costPersonalEmail"),costReverseEmail:n(1,"credits.costReverseEmail"),costExport:n(.5,"credits.costExport"),salesNavigator:n(50,"credits.salesNavigator"),priceId:n("","credits.priceId"),isCustom:n(!1,"credits.isCustom"),periodStartAt:n(new Date,"credits.periodStartAt"),lastCheckedAt:n(new Date,"credits.lastCheckedAt")},enrichment:{preference:n("email-phone","enrichment.preference")},lists:{all:w([]),byTarget:_({enrichment:[],export:[],reverse:[]}),enrichmentCount:_(0),exportCount:_(0),reverseCount:_(0),reverseUserById:_(new Map),audience:w([]),audienceCount:_(0)}};async function y(r){const e=window.localStorage.getItem("workspaceId"),c=r.getId();if(c&&c!==e)try{F(),M.reset(),window.localStorage.setItem("workspaceId",c),window.location.reload()}catch(m){console.error("Error setting workspaceId in local storage",m)}}t.workspace.currentWorkspace=p([t.workspace.list,t.workspace.idxWorkspaceSelected],([r,e])=>{const c=r?.[e]??new E.Workspace;return y(c),c});t.workspace.hasActiveBillingStatus=p([t.workspace.billingStatus,t.workspace.billingStatusOverride],([r,e])=>e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_INACTIVE||e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_PAUSED?!1:e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_ACTIVE||e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_OUT_OF_CREDITS?!0:r===E.WorkspaceBillingStatus.WORKSPACE_BILLING_STATUS_ACTIVE||r===E.WorkspaceBillingStatus.WORKSPACE_BILLING_STATUS_OUT_OF_CREDITS||r===E.WorkspaceBillingStatus.WORKSPACE_BILLING_STATUS_UNKNOWN);t.workspace.hasPauseWallDisabled=p([t.workspace.billingStatusOverride],([r])=>r===E.ManualBillingStatus.MANUAL_BILLING_STATUS_ACTIVE||r===E.ManualBillingStatus.MANUAL_BILLING_STATUS_OUT_OF_CREDITS);t.workspace.isBillingStatusPaused=p([t.workspace.billingStatus,t.workspace.billingStatusOverride],([r,e])=>e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_PAUSED?!0:e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_ACTIVE||e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_OUT_OF_CREDITS||e===E.ManualBillingStatus.MANUAL_BILLING_STATUS_INACTIVE?!1:r===E.WorkspaceBillingStatus.WORKSPACE_BILLING_STATUS_PAUSED);t.lists.byTarget=p(t.lists.all,r=>({enrichment:r.filter(e=>e.target===i.EnrichmentTarget.ENRICHMENT_TARGET_ENRICHMENT),export:r.filter(e=>e.target===i.EnrichmentTarget.ENRICHMENT_TARGET_EXPORT),reverse:r.filter(e=>e.target===i.EnrichmentTarget.ENRICHMENT_TARGET_REVERSE)}));t.lists.enrichmentCount=p(t.lists.byTarget,r=>r.enrichment.length);t.lists.exportCount=p(t.lists.byTarget,r=>r.export.length);t.lists.reverseCount=p(t.lists.byTarget,r=>r.reverse.length);t.lists.reverseUserById=p(t.lists.byTarget,r=>new Map(r.reverse.map(e=>[e.id,e.userid])));t.lists.audienceCount=p(t.lists.audience,r=>r.reduce((e,c)=>c.total>0?e+1:e,0));function F(){t.user.isLogged.set(!1),t.user.signedUp.set(!1),t.user.createdAt.set(0),t.user.username.set(""),t.user.firstname.set(""),t.user.id.set(""),t.user.phone.set(""),t.user.isMultiplePhone.set(!1),t.invitations.set([]),t.workspace.idxWorkspaceSelected.set(-1),t.workspace.list.set([]),t.workspace.hasSubscription.set(!1),t.workspace.hasPaidPlan.set(!1),t.workspace.billingStatus.set(E.WorkspaceBillingStatus.WORKSPACE_BILLING_STATUS_UNKNOWN),t.workspace.billingStatusOverride.set(E.ManualBillingStatus.MANUAL_BILLING_STATUS_AUTO),t.w
1orkspace.isListBuilderDisabled.set(!1),t.workspace.isCrmEnrichmentDisabled.set(!1),t.workspace.isSearchTosAccepeted.set(!1),t.workspace.hasBlurDisabled.set(!1),t.workspace.hasNlSearchEnabled.set(!1),t.workspace.hasPushToHubspotListBuilderEnabled.set(!1),t.workspace.experiments.set({}),t.workspace.role.set(4),t.credits.balance.set(0),t.credits.availableToSpend.set(0),t.credits.limit.set(null),t.credits.used.set(null),t.credits.fetched.set(!1),t.credits.costEmail.set(1),t.credits.costReverseEmail.set(1),t.credits.costPhone.set(10),t.credits.costPersonalEmail.set(3),t.credits.costExport.set(.5),t.credits.salesNavigator.set(50),t.lists.all.set([]),t.lists.audience.set([])}export{M as a,F as r,t as s,E as w}; 2//# sourceMappingURL=YJLbaxJi.js.map
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.