PageSourceSearch

https://groweasy.ai/_next/static/chunks/pages/web/manage-leads-8b61162e39418942.js

js groweasy.ai collected 2026-10-04 18:53:43 UTC 70,131 bytes, 6 lines download raw bytes

1(globalThis.webpackChunk_N_E=globalThis.webpackChunk_N_E||[]).push([[3951],{80848:(e,t,a)=>{"use strict";a.d(t,{RGt:()=>r.RGt});var r=a(63750)},3781:(e,t,a)=>{"use strict";a.d(t,{z:()=>r.Z});var r=a(36316);/**
2 * @license lucide-react v0.548.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */},39611:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/web/manage-leads",function(){return a(98401)}])},98401:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>manage_leads});var r=a(11010),n=a(75766),l=a(72253),s=a(14932),i=a(91309),o=a(4586),d=a(28207),u=a(85893),c=a(67294),m=a(88767),f=a(8971),x=a(64998),p=a(13766),h=a(19769),g=a(711),v=a(47569),y=a(42297),b=a(87764),_=a(71408),w=a(35162),j=a(81914),N=a(21442),C=a(49525),k=a(77816),S=a(90644),D=a(70614),L=a(21749),O=a(11988);a(35890);var E=a(41352),T=c.memo(function(e){var t=e.dateFrom,a=e.dateTo,r=e.onDateRangeChange,n=e.onClear,l=e.label,s=e.placeholder;return(0,u.jsxs)("div",{className:"flex items-center gap-1 lg:gap-1.5 px-3 md:px-3 lg:px-4 md:py-0.5 lg:py-1 rounded-full border border-gray-light bg-white hover:border-primary2/40 focus-within:border-primary2/40 transition-all cursor-pointer w-max max-w-[80px] md:max-w-[130px] lg:max-w-[160px] shrink-0",children:[(0,u.jsx)(O.ZP,{selected:t,onChange:r,startDate:t,endDate:a,selectsRange:!0,placeholderText:s||l||"Select Date",dateFormat:"dd MMM yyyy",className:"bg-transparent text-xs lg:text-sm font-medium text-black placeholder-black focus:outline-none cursor-pointer w-full h-full p-0 border-none",wrapperClassName:"w-full min-w-0 flex-1"}),(0,u.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[!!(t||a)&&(0,u.jsx)("button",{type:"button",onClick:function(e){e.stopPropagation(),n()},title:"Clear date",className:"flex justify-center items-center text-gray-400 hover:text-red p-0.5 rounded-full transition-colors",children:(0,u.jsx)(E.Z,{size:13})}),(0,u.jsx)(f.Z,{size:14,className:"text-black pointer-events-none shrink-0"})]})]})});T.displayName="DateRangePickerFilter";var A=a(7132),P=a(76368),F=a(39938),M=a(56837),R=a(59266),I=a(69346),z=a(26646),U=a(40805),B=a(23834),Z=a(23700),q=a(16805),W=a(99322),V=a(63919),G=a(63499),H=a(52141),K=a(93421),X=a(50533),Y=a(24349),Q=a(94184),J=a.n(Q),$=a(11163),ee=["quality","source","status"];let manage_leads=function(e){var t,a,O,E,Q,et,ea,er,en,el,es,ei,eo,ed,eu,ec,em,ef,ex,ep=e.user,eh=(0,$.useRouter)(),eg=(0,c.useMemo)(function(){return(0,q.mV)("30d")},[]),ev=(0,Z.useApp)(),ey=ev.leadSources,eb=ev.selectedOrgId,e_=ev.telephonyDids,ew=ev.orgMembers,ej=ev.userProfile,eN=ev.crmFields,eC=(0,M.el)(eN),ek=null==ew?void 0:ew.find(function(e){return e.uid===(null==ej?void 0:ej.uid)}),eS=null==ek?void 0:ek.role,eD=(0,M.Ef)(ey,e_||void 0),eL=(0,i._)((0,c.useState)({limit:"20",created_from:"".concat((0,q.cq)(eg.start,eg.end).created_from),created_to:"".concat((0,q.cq)(eg.start,eg.end).created_to)}),2),eO=eL[0],eE=eL[1],eT=(0,i._)((0,c.useState)([]),2),eA=eT[0],eP=eT[1],eF=(0,i._)((0,c.useState)(eg.start),2),eM=eF[0],eR=eF[1],eI=(0,i._)((0,c.useState)(eg.end),2),ez=eI[0],eU=eI[1],eB=(0,i._)((0,c.useState)("30d"),2),eZ=eB[0],eq=eB[1],eW=(0,i._)((0,c.useState)(null),2),eV=eW[0],eG=eW[1],eH=(0,i._)((0,c.useState)(null),2),eK=eH[0],eX=eH[1],eY=(0,i._)((0,c.useState)(null),2),eQ=eY[0],eJ=eY[1],e$=(0,i._)((0,c.useState)(!1),2),e0=e$[0],e2=e$[1],e1=(0,i._)((0,c.useState)(!1),2),e4=e1[0],e3=e1[1],e5=(0,i._)((0,c.useState)("pending"),2),e6=e5[0],e7=e5[1],e9=(0,i._)((0,c.useState)(!1),2),e8=e9[0],te=e9[1],tt=(0,i._)((0,c.useState)(null),2),ta=tt[0],tr=tt[1],tn=(0,i._)((0,c.useState)(!1),2),tl=tn[0],ts=tn[1],ti=(0,i._)((0,c.useState)(null),2),to=ti[0],td=ti[1],tu=(0,i._)((0,c.useState)(!1),2),tc=tu[0],tm=tu[1],tf=(0,i._)((0,c.useState)(null),2),tx=tf[0],tp=tf[1],th=(0,i._)((0,c.useState)(0),2),tg=th[0],tv=th[1],ty=(0,i._)((0,c.useState)(!1),2),tb=ty[0],t_=ty[1],tw=(0,i._)((0,c.useState)(null),2),tj=tw[0],tN=tw[1],tC=(0,i._)((0,c.useState)(!1),2),tk=tC[0],tS=tC[1],tD=(0,i._)((0,c.useState)(!1),2),tL=tD[0],tO=tD[1],tE=(0,i._)((0,c.useState)(null),2),tT=tE[0],tA=tE[1],tP=(0,i._)((0,c.useState)(!1),2),tF=tP[0],tM=tP[1],tR=(0,i._)((0,c.useState)(!1),2),tI=tR[0],tz=tR[1],tU=(0,i._)((0,c.useState)(null),2),tB=tU[0],tZ=tU[1],tq=(0,i._)((0,c.useState)(""),2),tW=tq[0],tV=tq[1],tG=(0,i._)((0,c.useState)(!1),2),tH=tG[0],tK=tG[1],tX=(0,i._)((0,c.useState)(!1),2),tY=tX[0],tQ=tX[1],tJ=(0,i._)((0,c.useState)(null),2),t$=tJ[0],t0=tJ[1],t2=(0,i._)((0,c.useState)(""),2),t1=t2[0],t4=t2[1],t3=(0,i._)((0,c.useState)(!1),2),t5=t3[0],t6=t3[1],t7=(0,i._)((0,c.useState)(""),2),t9=t7[0],t8=t7[1],ae=(0,i._)((0,c.useState)(""),2),at=ae[0],aa=ae[1],ar=(0,i._)((0,c.useState)(""),2),an=ar[0],al=ar[1],as=(0,i._)((0,c.useState)(!1),2),ai=as[0],ao=as[1],ad=(0,i._)((0,c.useState)(null),2),au=ad[0],ac=ad[1],am=(0,i._)((0,c.useState)(null),2),af=am[0],ax=am[1],ap=(0,i._)((0,c.useState)(""),2),ah=ap[0],ag=ap[1],av=(0,i._)((0,c.useState)(!1),2),ay=av[0],ab=av[1],a_=(0,i._)((0,c.useState)({}),2),aw=a_[0],aj=a_[1],aN=(0,i._)((0,c.useState)(!1),2),aC=aN[0],ak=aN[1],aS=(0,i._)((0,c.useState)(null),2),aD=aS[0],aL=aS[1],aO=(0,i._)((0,c.useState)(!1),2),aE=aO[0],aT=aO[1],aA=(0,i._)((0,c.useState)(""),2),aP=aA[0],aF=aA[1],aM=(0,i._)((0,c.useState)(""),2),aR=aM[0],aI=aM[1],az=(0,c.useRef)(!1),aU=(0,c.useRef)(eb);(0,c.useEffect)(function(){if(eh.isReady&&!az.current){var e={limit:"20"}
6,t=[],a=null,r=null,n=null,s=null,i=null,o=null,d=(0,U.$o)(B.dA.MANAGE_LEADS_FILTERS);if(d)try{var u=JSON.parse(d);e=u.filters||{limit:"20"},t=u.activeFilters||[],a=u.dateFrom?new Date(u.dateFrom):null,r=u.dateTo?new Date(u.dateTo):null,n=u.selectedDatePreset||null,s=u.followUpDateFrom?new Date(u.followUpDateFrom):null,i=u.followUpDateTo?new Date(u.followUpDateTo):null,o=u.selectedFollowUpPreset||null}catch(e){console.error("Failed to parse saved filters",e)}var c=!1,m={};if(ee.forEach(function(e){var t=eh.query[e];if(t){var a=Array.isArray(t)?t:t.split(","),r=[];a.forEach(function(t){var a=t.trim();if(a){var n=!1;"status"===e?n=M.Em.some(function(e){return e.value===a}):"quality"===e?n=M.O6.some(function(e){return e.value===a}):"source"===e&&(n=!!(null==eD?void 0:eD.some(function(e){return e.value===a}))),n&&r.push(a)}}),r.length>0&&(c=!0,m[e]=r.join(","))}}),c){e=(0,l._)({},e,m),t=t.filter(function(e){return!ee.includes(e.key)});var getOptionLabel=function(e,t){if("status"===e){var a=M.Em.find(function(e){return e.value===t});return a?"Status: ".concat(a.label):""}if("quality"===e){var r=M.O6.find(function(e){return e.value===t});return r?"Quality: ".concat(r.label):""}if("source"===e){var n=eD.find(function(e){return e.value===t});return n?"Source: ".concat(n.label):""}return""};ee.forEach(function(e){var a=m[e];a&&a.split(",").forEach(function(a){t.push({key:e,label:getOptionLabel(e,a),value:a})})})}eE(e),eP(t),eR(a),eU(r),eq(n),eG(s),eX(i),eJ(o),az.current=!0}},[eb,eh.isReady,eh.query,eD]),(0,c.useEffect)(function(){az.current&&aU.current&&aU.current!==eb&&clearAllFilters(),aU.current=eb},[eb]);var updateBaseFiltersUrl=function(e){if(eh.isReady){var t=(0,l._)({},eh.query),a=!1;ee.forEach(function(r){var n=e[r];n?t[r]!==n&&(t[r]=n,a=!0):void 0!==t[r]&&(delete t[r],a=!0)}),a&&eh.replace({pathname:eh.pathname,query:t},void 0,{shallow:!0})}};(0,c.useEffect)(function(){(0,U.qQ)(B.dA.MANAGE_LEADS_FILTERS,JSON.stringify({filters:eO,activeFilters:eA,dateFrom:eM,dateTo:ez,selectedDatePreset:eZ,followUpDateFrom:eV,followUpDateTo:eK,selectedFollowUpPreset:eQ}))},[eO,eA,eM,ez,eZ,eV,eK,eQ]);var aB=(0,c.useMemo)(function(){return(0,l._)({},eO)},[eO]),aZ=(0,c.useMemo)(function(){return{data:eN||[]}},[eN]),aq=(0,c.useMemo)(function(){var e=(null!==(d=null==aZ?void 0:aZ.data)&&void 0!==d?d:[]).filter(function(e){return"DROPDOWN"===e.type&&e.options&&e.options.length>0}),t=new Set(e.map(function(e){return e.key})),a=[],r=!0,n=!1,o=void 0;try{for(var d,u,c=e[Symbol.iterator]();!(r=(u=c.next()).done);r=!0){var m=u.value,f=aB[m.key];if(f){var x=!0,p=!1,h=void 0;try{for(var g,v=f.split(",")[Symbol.iterator]();!(x=(g=v.next()).done);x=!0){var y=g.value;a.push("".concat(m.key,":").concat(y))}}catch(e){p=!0,h=e}finally{try{x||null==v.return||v.return()}finally{if(p)throw h}}}}}catch(e){n=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(n)throw o}}var b=!0,_=!1,w=void 0;try{for(var j,N=Object.entries(aw)[Symbol.iterator]();!(b=(j=N.next()).done);b=!0){var C=(0,i._)(j.value,2),k=C[0],S=C[1],D=S.from,L=S.to,O=(0,q.cq)(D,L);O.created_from&&a.push("".concat(k,"_from:").concat(O.created_from)),O.created_to&&a.push("".concat(k,"_to:").concat(O.created_to))}}catch(e){_=!0,w=e}finally{try{b||null==N.return||N.return()}finally{if(_)throw w}}var E={source:aB.source,owner_uid:aB.owner_uid,status:aB.status,quality:aB.quality,campaign:aB.campaign,created_from:aB.created_from,created_to:aB.created_to,follow_up_today:aB.follow_up_today,today_calling_plan:aB.today_calling_plan,today_lead_connected:aB.today_lead_connected,follow_up_at_from:aB.follow_up_at_from,follow_up_at_to:aB.follow_up_at_to},T=!0,A=!1,P=void 0;try{for(var F,M=t[Symbol.iterator]();!(T=(F=M.next()).done);T=!0){var R=F.value;delete E[R]}}catch(e){A=!0,P=e}finally{try{T||null==M.return||M.return()}finally{if(A)throw P}}return(0,s._)((0,l._)({},E),{custom_fields_filters:a.join(",")||void 0})},[aB,aZ,aw]),aW=JSON.stringify(aq),aV=(0,m.useQuery)(["getLeadsAnalytics",eb,aW],function(){return(0,R.K2)({headers:(0,I.Ny)(ep),queryParams:aq})},{retry:0,enabled:!!(null==ep?void 0:ep.authToken)&&!!eb&&!e4,onError:function(e){(0,U.F4)(e,"ManageLeadsPage.getLeadsA
6nalytics")}}),aG=aV.data,aH=aV.isLoading,aK=aV.refetch,aX=(0,c.useMemo)(function(){var e=aR.trim();if(e){var t=e.includes("@");return(0,l._)({},t?{email:e}:{mobile:e})}return(0,s._)((0,l._)({},aq),{sort_by:aB.sort_by,limit:"20"})},[aR,aq,aB.sort_by]),aY=(0,c.useMemo)(function(){return{limit:"500",owner_uid:aB.owner_uid,today_calling_plan:"true"}},[aB.owner_uid]),aQ=(0,c.useMemo)(function(){return{limit:"500",owner_uid:aB.owner_uid,today_lead_connected:"true"}},[aB.owner_uid]),aJ=JSON.stringify(aX),a$=(0,m.useInfiniteQuery)(["getLeads",eb,aJ],function(e){var t=e.pageParam,a=(0,s._)((0,l._)({},aX),{last_cursor_id:t});return(0,R.hh)({headers:(0,I.Ny)(ep),queryParams:a})},{retry:0,enabled:!!(null==ep?void 0:ep.authToken)&&!!eb&&(!e4||!!aR.trim()),getNextPageParam:function(e){return e.last_cursor_id||void 0},onError:function(e){(0,U.F4)(e,"ManageLeadsPage.getLeads")}}),a0=(0,m.useInfiniteQuery)(["getCallPendingTodayLeads",eb,JSON.stringify(aY)],function(e){var t=e.pageParam;return(0,R.hh)({headers:(0,I.Ny)(ep),queryParams:(0,s._)((0,l._)({},aY),{last_cursor_id:t})})},{retry:0,enabled:!!(null==ep?void 0:ep.authToken)&&!!eb&&e4&&!aR.trim(),getNextPageParam:function(e){return e.last_cursor_id||void 0},onError:function(e){(0,U.F4)(e,"ManageLeadsPage.getCallPendingTodayLeads")}}),a2=(0,m.useInfiniteQuery)(["getCallDoneTodayLeads",eb,JSON.stringify(aQ)],function(e){var t=e.pageParam;return(0,R.hh)({headers:(0,I.Ny)(ep),queryParams:(0,s._)((0,l._)({},aQ),{last_cursor_id:t})})},{retry:0,enabled:!!(null==ep?void 0:ep.authToken)&&!!eb&&e4&&!aR.trim(),getNextPageParam:function(e){return e.last_cursor_id||void 0},onError:function(e){(0,U.F4)(e,"ManageLeadsPage.getCallDoneTodayLeads")}}),resetToDefaultLeadsView=function(){var e=(0,q.cq)(eg.start,eg.end),t={limit:"20",created_from:e.created_from,created_to:e.created_to};eE(t),eP([]),eR(eg.start),eU(eg.end),eq("30d"),eG(null),eX(null),eJ(null),aj({}),updateBaseFiltersUrl(t)},clearAllFilters=function(){var e={limit:"20"};eE(e),eP([]),eR(null),eU(null),eq(null),eG(null),eX(null),eJ(null),aj({}),updateBaseFiltersUrl(e)},extractLeads=function(e){var t,a=[],r=new Set;return null==e||null===(t=e.pages)||void 0===t||t.forEach(function(e){var t;(null!==(t=e.data)&&void 0!==t?t:[]).forEach(function(e){r.has(e.id)||(r.add(e.id),a.push(e))})}),a},a1=(0,c.useMemo)(function(){return extractLeads(a$.data)},[a$.data]),a4=(0,c.useMemo)(function(){var e;return e=extractLeads(a0.data),(0,o._)(e).sort(function(e,t){var a,r,n=null===(a=e.crm)||void 0===a?void 0:a.next_follow_up_at,l=null===(r=t.crm)||void 0===r?void 0:r.next_follow_up_at;return n&&!l?-1:!n&&l?1:n&&l?new Date(n).getTime()-new Date(l).getTime():0})},[a0.data]),a3=(0,c.useMemo)(function(){return extractLeads(a2.data)},[a2.data]),a5=!!aR.trim(),a6=(0,c.useMemo)(function(){var e=e4&&!a5?"pending"===e6?a4:a3:a1;return e4?(0,o._)(e).sort(function(e,t){var getPriority=function(e){if("today"===(0,A.WT)(e.crm)&&!(null===(t=e.crm)||void 0===t?void 0:t.follow_up_done_at))return 1;var t,a,r=null===(a=e.crm)||void 0===a?void 0:a.status;return r&&r!==F.Rc.NOT_DIALED&&null!==r?r===F.Rc.DID_NOT_CONNECT_OR_BUSY?3:4:2},a=getPriority(e),r=getPriority(t);if(a!==r)return a-r;var n=e.created_at?"string"==typeof e.created_at?new Date(e.created_at).getTime():1e3*e.created_at._seconds:0;return(t.created_at?"string"==typeof t.created_at?new Date(t.created_at).getTime():1e3*t.created_at._seconds:0)-n}):e},[e4,a5,e6,a4,a3,a1]),a7=(0,c.useMemo)(function(){return(0,A.hS)(a6)},[a6]),a9=(0,c.useMemo)(function(){return a6.some(function(e){return e.email&&""!==e.email.trim()})},[a6]),a8=(0,c.useMemo)(function(){return a6.some(function(e){return e.company&&""!==e.company.trim()})},[a6]),re=(0,c.useMemo)(function(){return Object.fromEntries(a7.map(function(e){return[e,e.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})]}))},[a7]),rt=(0,c.useMemo)(function(){return(0,A.Op)(a7.map(function(e){return re[e]}),{showEmail:a9,showCompany:a8,hasCustomizedStatus:eC})},[a7,re,a9,a8,eC]),ra=e4&&!a5?"pending"===e6?a0:a2:a$,rr=ra.isLoading,rn=ra.isFetchingNextPage,rl=!!ra.hasNextPage,rs=(0,m.useQuery)(["getOrgMembers",eb],function(){return(0,V.aF)({headers:(0,I.Ny)(ep)})},{retry:0,enabled:!!(null==ep?void 0:ep.authToken)&&!!eb,onError:function(e){(0,U.F4)(e,"ManageLeadsPage.getOrgMembers")}}),ri=rs.data,ro=rs.isLoading,rd=rs.refetch,ru=(0,m.useMutation)(function(){var e={};return Object.entries(e4&&!aR.trim()?"pending"===e6?aY:aQ:aX).forEac
6h(function(t){var a=(0,i._)(t,2),r=a[0],n=a[1];null!=n&&""!==n&&(e[r]=String(n))}),delete e.last_cursor_id,delete e.limit,(0,z.S2)({headers:(0,I.Ny)(ep),queryParams:e})},{onSuccess:function(e){var t;(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.s3_url)&&(0,U.UU)(e.data.s3_url)},onError:function(e){(0,U.F4)(e,"ManageLeadsPage.handleDownloadLeadsCsv")}}),rc=null!==(es=null==ri?void 0:ri.data)&&void 0!==es?es:[],rm=null!==(ei=null==aG?void 0:aG.performance_overview)&&void 0!==ei?ei:null,handleFilterSelect=function(e,t,a){var r=eO[e],i=r?r.split(","):[];if(!i.includes(a)){var d=(0,o._)(i).concat([a]).join(","),u=(0,s._)((0,l._)({},eO),(0,n._)({},e,d));eE(u),eP(function(r){return r.some(function(t){return t.key===e&&t.value===a})?r:(0,o._)(r).concat([{key:e,label:t,value:a}])}),ee.includes(e)&&updateBaseFiltersUrl(u)}},handleFilterRemove=function(e,t){var a=eO[e];if(a){var r=a.split(",").filter(function(e){return e!==t}),n=(0,l._)({},eO);0===r.length?delete n[e]:n[e]=r.join(","),eE(n),eP(function(a){return a.filter(function(a){return!(a.key===e&&a.value===t)})}),ee.includes(e)&&updateBaseFiltersUrl(n)}},refetchActiveLeadsList=function(){!e4||a5?(aK(),a$.refetch()):(a0.refetch(),a2.refetch())},handleLeadMoreClick=function(e){(null==tx?void 0:tx.id)===e.id&&tc?(tm(!1),tp(null)):(tp(e),tm(!0))},handleLeadActivitiesPanelClose=function(){tm(!1),tp(null)},handleFollowUpClick=function(e){tr(e),te(!0)},handleMarkFollowUpClick=function(e){td(e),ts(!0)},rf=(t=(0,r._)(function(e){var t;return(0,d._)(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,(0,R.V4)({headers:(0,I.Ny)(ep),leadId:e.id,data:{crm:{last_call_done_at:new Date().toISOString()}}})];case 1:return a.sent(),refetchActiveLeadsList(),tv(function(e){return e+1}),(0,W.showToastMessage)("Call marked as done","success"),[3,3];case 2:return t=a.sent(),(0,U.F4)(t,"ManageLeadsPage.handleMarkCallDoneClick"),[3,3];case 3:return[2]}})}),function(e){return t.apply(this,arguments)}),rx=rc.filter(function(e){return!e.is_invitation&&!!e.uid&&!1!==e.can_receive_leads}),rp=(null!==(eo=eO.owner_uid)&&void 0!==eo?eo:"").split(",").map(function(e){return e.trim()}).filter(Boolean),handleOwnerToggle=function(e,t,a){eE(function(t){var r,n=(null!==(r=t.owner_uid)&&void 0!==r?r:"").split(",").map(function(e){return e.trim()}).filter(Boolean),i=a?Array.from(new Set((0,o._)(n).concat([e]))):n.filter(function(t){return t!==e});return(0,s._)((0,l._)({},t),{owner_uid:i.length>0?i.join(","):void 0})}),eP(function(r){return a?r.some(function(t){return"owner_uid"===t.key&&t.value===e})?r:(0,o._)(r).concat([{key:"owner_uid",label:"Owner: ".concat(t),value:e}]):r.filter(function(t){return!("owner_uid"===t.key&&t.value===e)})})},rh=rm?"".concat(Number(null!==(ed=rm.conversion_rate)&&void 0!==ed?ed:0).toFixed(1),"%"):"—",rg=(0,c.useMemo)(function(){var e={};return rx.forEach(function(t){if(t.uid){var a,r;e[t.uid]=(null===(a=t.profile)||void 0===a?void 0:a.name)||(null===(r=t.profile)||void 0===r?void 0:r.email)||t.uid}}),e},[rx]),handleOwnerAssignClick=function(e){tN(e),t_(!0)},rv=(a=(0,r._)(function(e){var t;return(0,d._)(this,function(a){switch(a.label){case 0:if(!tj)return[2];tS(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,(0,R.V4)({headers:(0,I.Ny)(ep),leadId:tj.id,data:{owner_uid:e}})];case 2:return a.sent(),refetchActiveLeadsList(),tv(function(e){return e+1}),t_(!1),tN(null),(0,W.showToastMessage)("Owner updated successfully","success"),[3,5];case 3:return t=a.sent(),(0,U.F4)(t,"ManageLeadsPage.handleSaveOwner"),[3,5];case 4:return tS(!1),[7];case 5:return[2]}})}),function(e){return a.apply(this,arguments)}),handleStatusClick=function(e){tA(e),tO(!0)},ry=(O=(0,r._)(function(e){var t,a;return(0,d._)(this,function(r){switch(r.label){case 0:if(!tT)return[2];tM(!0),t=e===F.Rc.NOT_DIALED?null:e,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,(0,R.V4)({headers:(0,I.Ny)(ep),leadId:tT.id,data:{crm:{status:t,last_call_done_at:new Date().toISOString()}}})];case 2:return r.sent(),refetchActiveLeadsList(),tv(function(e){return e+1}),tO(!1),tA(null),(0,W.showToastMessage)("Status updated successfully","success"),[3,5];case 3:return a=r.sent(),(0,U.F4)(a,"ManageLeadsPage.handleSaveStatus"),[3,5];case 4:return tM(!1),[7];case 5:return[2]}})}),function(e){return O.apply(this,arguments)}),handleCustomStatusClick=function(e){aL(e),ak(!0)},rb=(E=(0,r._)(function(e){var t;return(0,d._)(this,function(a){switch(a.label){case 0:if(!aD)return[2];aT(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,(0,R.V4)({headers:(0,I.Ny)(ep),leadId:aD.id,data:{custom_fields:(0,s._)((0,l._)({},aD.custom_fields),(0,n._)({},F.Rq,e))}})];case 2:return a.sent(),refetchActiveLeadsList(),tv(function(e){return e+1}),ak(!1),aL(null),(0,W.showToastMessage)("Custom status updated successfully","success"),[3,5];case 3:return t=a.sent(),(0,U.F4)(t,"ManageLeadsPage.handleSaveCustomStatus"),[3,5];case 4:return aT(!1),[7];case 5:return[2]}})}),function(e){return E.apply(this,arguments)}),handleCustomFieldEditClick=function(e,t){if(t===F.Rq){handleCustomStatusClick(e);return}if(ac(e),"location"===t){ax({key:"location",label:"Location"}),t8(null!==(s=null===(r=e.location)||void 0===r?void 0:r.city)&&void 0!==s?s:""),aa(null!==(i=null===(n=e.location)||void 0===n?void 0:n.state)&&void 0!==i?i:""),al(null!==(o=null===(l=e.location)||void 0===l?void 0:l.country)&&void 0!==o?o:""),ao(!0);return}var a,r,n,l,s,i,o,d=eN.find(function(e){return e.key===t});if(d){ax(d);var u=null===(a=e.custom_fields)||void 0===a?void 0:a[t];ag(null!=u?u:""),ao(!0)}},r_=(Q=(0,r._)(function(){var e,t,a;return(0,d._)(this,function(r){switch(r.label){case 0:if(!au||!af)return[2];ab(!0),e="location"===af.key,t=ah,""===ah?t=null:"NUMBER"===af.type?t=Number(ah):"BOOLEAN"===af.type&&(t=!0===ah||"true"===ah||!1!==ah&&"false"!==ah&&null),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,(0,R.V4)({headers:(0,I.Ny)(ep),leadId:au.id,data:(0,l._)({},e?{location:{city:t9.trim()||void 0,state:at.trim()||void 0,country:an.trim()||void 0}}:{custom_fields:(0,s._)((0,l._)({},au.custom_fields),(0,n._)({},af.key,t))})})];case 2:return r.sent(),e&&(null==tx?void 0:tx.id)===au.id&&tp(function(e){return e?(0,s._)((0,l._)({},e),{location:{city:t9.trim()||void 0,state:at.trim()||void 0,country:an.trim()||void 0}}):null}),refetchActiveLeadsList(),tv(function(e){return e+1}),ao(!1),ac(null),ax(null),(0,W.showToastMessage)("".concat(af.label," updated successfully"),"success"),[3,5];case 3:return a=r.sent(),(0,U.F4)(a,"ManageLeadsPage.handleSaveCustomField"),[3,5];case 4:return ab(!1),[7];case 5:return[2]}})}),function(){return Q.apply(this,arguments)}),handleCompanyEditClick=function(e){var t;tZ(e),tV(null!==(t=e.company)&&void 0!==t?t:""),tz(!0)},rw=(et=(0,r._)(function(){var e;return(0,d._)(this,function(t){switch(t.label){case 0:if(!tB)return[2];tK(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,(0,R.V4)({headers:(0,I.Ny)(ep),leadId:tB.id,data:{company:tW.trim()||null}})];case 2:return t.sent(),refetchActiveLeadsList(),(null==tx?void 0:tx.id)===tB.id&&tv(function(e){return e+1}),tz(!1),tZ(null),(0,W.showToastMessage)("Company updated successfully","success"),[3,5];case 3:return e=t.sent(),(0,U.F4)(e,"ManageLeadsPage.handleSaveCompany"),[3,5];case 4:return tK(!1),[7];case 5:return[2]}})}),function(){return et.apply(this,arguments)}),handleLeadNameEditClick=function(e){var t;t0(e),t4(null!==(t=e.name)&&void 0!==t?t:""),tQ(!0)},rj=(ea=(0,r._)(function(){var e,t;return(0,d._)(this,function(a){switch(a.label){case 0:if(!t$)return[2];if(!(e=t1.trim()))return(0,W.showToastMessage)("Lead name cannot be empty","error"),[2];t6(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,(0,R.V4)({headers:(0,I.Ny)(ep),leadId:t$.id,data:{name:e}})];case 2:return a.sent(),refetchActiveLeadsList(),(null==tx?void 0:tx.id)===t$.id&&tv(function(e){return e+1}),tQ(!1),t0(null),(0,W.showToastMessage)("Lead name updated successfully","success"),[3,5];case 3:return t=a.sent(),(0,U.F4)(t,"ManageLeadsPage.handleSaveLeadName"),[3,5];case 4:return t6(!1),[7];case 5:return[2]}})}),function(){return ea.apply(this,arguments)}),handleSearch=function(e){if(!e||"Enter"===e.key){var t=aP.trim();if(!t){aI("");return}aI(t)}};return(0,u.jsxs)(k.Z,{user:ep,children:[(0,u.jsxs)(H.ZP,{open:e0,onOpenChange:e2,children:[(0,u.jsx)(S.Z,{title:"Manage Your Leads",subtitle:"Monitor lead status, assign tasks, and close deals faster."}
6),(0,u.jsxs)("div",{className:"p-6 mx-auto space-y-4 bg-muted/70",children:[e4?(0,u.jsxs)("div",{className:"bg-gradient-to-r from-primary-light/80 to-primary-light/30 border border-primary2/20 rounded-3xl px-5 py-3 flex items-center gap-3",children:[(0,u.jsxs)("p",{className:"text-sm font-medium text-primary2 flex-1 flex items-center gap-4",children:[(0,u.jsx)(g.Z,{size:12}),"AI suggested Today's calling plan is active."]}),(0,u.jsxs)("button",{onClick:function(){e3(!1),resetToDefaultLeadsView()},className:"text-sm text-primary2 bg-white p-2 px-4 hover:underline border-2 rounded-full border-primary2 transition-all font-medium inline-flex items-center",children:["Go Back to All Leads"," ",(0,u.jsx)(x.Z,{size:14,strokeWidth:2.5})]})]}):(0,u.jsxs)("div",{className:"bg-gradient-to-r from-primary-light/90 to-primary-light/30 border border-primary2/20 rounded-3xl px-5 py-3 flex items-center gap-3",children:[(0,u.jsxs)("p",{className:"text-sm text-primary2 font-medium flex-1 inline-flex items-center gap-4",children:[(0,u.jsx)(g.Z,{size:12}),"View Your AI Suggested Today's Calling Plan"]}),(0,u.jsxs)("button",{onClick:function(){e3(!0);var e={limit:"20",owner_uid:eO.owner_uid};eE(e),eP(function(e){return e.filter(function(e){return"owner_uid"===e.key})}),eR(null),eU(null),eq(null),eG(null),eX(null),eJ(null),aj({}),updateBaseFiltersUrl(e)},className:"text-sm text-primary2 bg-white p-2 px-4 hover:underline border-2 rounded-full border-primary2 transition-all font-medium inline-flex items-center",children:["View ",(0,u.jsx)(x.Z,{size:14,strokeWidth:3})]})]}),(0,u.jsx)(D.Z,{user:ep}),(0,u.jsxs)("div",{className:"bg-white rounded-3xl border border-gray-light/90 p-5 shadow-sm relative",children:[(0,u.jsxs)("div",{className:"absolute right-5 flex flex-col items-end gap-3",children:[(0,u.jsx)(P.Xl,{value:eO.sort_by,onChange:function(e){return eE(function(t){return(0,s._)((0,l._)({},t),{sort_by:e})})},options:M.wl}),(eA.length>0||eM||ez||eV||eK||eO.sort_by&&"created_at:desc"!==eO.sort_by)&&(0,u.jsxs)("button",{onClick:function(){clearAllFilters()},className:"flex items-center gap-1.5 text-xs font-semibold text-gray-dark hover:text-red transition-colors rounded-full border border-gray-light px-3 py-1.5",children:[(0,u.jsx)(y.Z,{size:12}),"Clear All"]})]}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-2 mb-3 mr-64 sm:mr-72",children:[!e4&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(P.ML,{label:"Status",options:M.Em,onSelect:function(e,t){return handleFilterSelect("status","Status: ".concat(e),t)}}),(0,u.jsx)(P.ML,{label:"Quality",options:M.O6,onSelect:function(e,t){return handleFilterSelect("quality","Quality: ".concat(e),t)}}),(0,u.jsx)(P.ML,{label:"Source",options:eD,onSelect:function(e,t){return handleFilterSelect("source","Source: ".concat(e),t)}}),(null!==(eu=null==aZ?void 0:aZ.data)&&void 0!==eu?eu:[]).filter(function(e){return"DROPDOWN"===e.type&&e.options&&e.options.length>0&&(!!eC||e.key!==F.Rq)}).map(function(e){var t;return(0,u.jsx)(P.ML,{label:e.label,options:(null!==(t=e.options)&&void 0!==t?t:[]).map(function(e){return{label:e.label,value:e.value}}),onSelect:function(t,a){return handleFilterSelect(e.key,"".concat(e.label,": ").concat(t),a)}},e.key)}),(null!==(ec=null==aZ?void 0:aZ.data)&&void 0!==ec?ec:[]).filter(function(e){return"DATE"===e.type}).map(function(e){var t,a=null!==(t=aw[e.key])&&void 0!==t?t:{from:null,to:null};return(0,u.jsx)(T,{label:e.label,placeholder:"".concat(e.label),dateFrom:a.from,dateTo:a.to,onDateRangeChange:function(t){var a=(0,i._)(t,2),r=a[0],o=a[1];aj(function(t){return(0,s._)((0,l._)({},t),(0,n._)({},e.key,{from:r,to:o}))})},onClear:function(){aj(function(t){var a=(0,l._)({},t);return delete a[e.key],a})}},e.key)})]}),eS!==G.B.SALES_EXECUTIVE&&(0,u.jsxs)("button",{onClick:function(){return e2(!0)},className:"flex items-center gap-1 lg:gap-2 px-3 md:px-3 lg:px-4 py-1.5 md:py-1.5 lg:py-2 rounded-full border border-gray-light bg-white text-xs lg:text-sm font-medium text-black hover:border-primary2/30 transition-all",children:[rp.length>0?"".concat(rp.length," Owner").concat(rp.length>1?"s":""):"Owner",(0,u.jsx)(f.Z,{size:14})]})]}),!e4&&(0,u.jsxs)("div",{className:"p-1 space-y-4 lg:space-y-0 lg:flex flex-col lg:gap-4 mb-2",children:[(0,u.jsx)(L.l,{label:"Created Date Range",placeholder:"Select created date range",dateFrom:eM,dateTo:ez,selectedPreset:eZ,onDateRangeChange:function(e){var t=(0,i._)(e,2),a=t[0],r=t[1];eR(a),eU(r),eq("custom");var n=(0,q.cq)(a,r);eE(function(e){return(0,s._)((0,l._)({},e),{created_from:n.created_from,created_to:n.created_to})})},onPresetSelect:function(e){var t=(0,q.mV)(e);eR(t.start),eU(t.end),eq(e);var a=(0,q.cq)(t.start,t.end);eE(function(e){return(0,s._)((0,l._)({},e),{created_from:a.created_from,created_to:a.created_to})})},onClear:function(){eR(null),eU(null),eq(null),eE(function(e){var t=(0,l._)({},e);return delete t.created_from,delete t.created_to,t})}}),(0,u.jsx)(L.l,{label:"Follow Up Date Range",placeholder:"Select follow up date range",dateFrom:eV,dateTo:eK,selectedPreset:eQ,presets:q.mC,onDateRangeChange:function(e){var t=(0,i._)(e,2),a=t[0],r=t[1];eG(a),eX(r),eJ("custom");var n=(0,q.cq)(a,r);eE(function(e){return(0,s._)((0,l._)({},e),{follow_up_at_from:n.created_from,follow_up_at_to:n.created_to})})},onPresetSelect:function(e){var t=(0,q.oe)(e);eG(t.follow_up_at_from?new Date(t.follow_up_at_from):null),eX(t.follow_up_at_to?new Date(t.follow_up_at_to):null),eJ(e),eE(function(e){return(0,s._)((0,l._)({},e),{follow_up_at_from:t.follow_up_at_from,follow_up_at_to:t.follow_up_at_to})})},onClear:function(){eG(null),eX(null),eJ(null),eE(function(e){var t=(0,l._)({},e);return delete t.follow_up_at_from,delete t.follow_up_at_to,t})}})]}),eA.length>0&&(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:eA.map(function(e,t){return(0,u.jsx)(P.GH,{label:e.label,onRemove:function(){return handleFilterRemove(e.key,e.value)}},"".concat(e.key,"-").concat(t))})}),e4&&"pending"===e6&&(0,u.jsxs)("div",{className:"space-y-2 pt-1",children:[(0,u.jsxs)("div",{className:"flex flex-wrap gap-2 items-center text-xs text-muted-foreground",children:[(0,u.jsxs)("div",{className:"bg-primary-light/70 border-primary2/20 border py-1.5 px-3.5 rounded-full text-foreground
6/80 flex items-center gap-1.5",children:["Status:"," ",(0,u.jsx)("span",{className:"font-medium text-primary",children:"Not Contacted or Did Not Connect"}),(0,u.jsx)("span",{className:"ml-1 text-primary2 text-base",children:"\xd7"})]}),(0,u.jsx)("span",{className:"text-muted-foreground text-xs",children:"or"}),(0,u.jsxs)("div",{className:"bg-primary-light/70 border-primary2/20 border py-1.5 px-3.5 rounded-full text-foreground/80 flex items-center gap-1.5",children:["Follow Up:"," ",(0,u.jsx)("span",{className:"font-medium text-primary",children:"Today"}),(0,u.jsx)("span",{className:"ml-1 text-primary2 text-base",children:"\xd7"})]}),(0,u.jsx)("span",{className:"text-muted-foreground text-xs",children:"or"}),(0,u.jsxs)("div",{className:"bg-primary-light/70 border-primary2/20 border py-1.5 px-3.5 rounded-full text-foreground/80 flex items-center gap-1.5",children:["Lead Generated:"," ",(0,u.jsx)("span",{className:"font-medium text-primary",children:"Today"}),(0,u.jsx)("span",{className:"ml-1 text-primary2 text-base",children:"\xd7"})]})]}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-2 items-center text-xs text-muted-foreground",children:[(0,u.jsx)("span",{children:"and"}),(0,u.jsxs)("div",{className:"bg-primary-light/70 border-primary2/20 border py-1.5 px-3.5 rounded-full text-foreground/80 flex items-center gap-1.5",children:["Call Pending:"," ",(0,u.jsx)("span",{className:"font-medium text-primary",children:"Today"}),(0,u.jsx)("span",{className:"ml-1 text-primary2 text-base",children:"\xd7"})]})]}),(0,u.jsxs)("p",{className:"text-xs text-muted-foreground inline-flex items-center gap-2 pt-0.5",children:[(0,u.jsx)(w.Z,{size:11,fill:"currentColor"}),"Sorted by lead updated time or follow up time"]})]}),e4&&"done"===e6&&(0,u.jsxs)("div",{className:"space-y-2 pt-1",children:[(0,u.jsxs)("div",{className:"flex flex-wrap gap-2 items-center text-xs text-muted-foreground",children:[(0,u.jsxs)("div",{className:"bg-primary-light/70 border-primary2/20 border py-1.5 px-3.5 rounded-full text-foreground/80 flex items-center gap-1.5",children:["Call Done:"," ",(0,u.jsx)("span",{className:"font-medium text-primary",children:"Today"}),(0,u.jsx)("span",{className:"ml-1 text-primary2 text-base",children:"\xd7"})]}),(0,u.jsx)("span",{className:"text-muted-foreground text-xs",children:"or"}),(0,u.jsxs)("div",{className:"bg-primary-light/70 border-primary2/20 border py-1.5 px-3.5 rounded-full text-foreground/80 flex items-center gap-1.5",children:["Follow Up Done:"," ",(0,u.jsx)("span",{className:"font-medium text-primary",children:"Today"}),(0,u.jsx)("span",{className:"ml-1 text-primary2 text-base",children:"\xd7"})]}),(0,u.jsx)("span",{className:"text-muted-foreground text-xs",children:"or"}),(0,u.jsxs)("div",{className:"bg-primary-light/70 border-primary2/20 border py-1.5 px-3.5 rounded-full text-foreground/80 flex items-center gap-1.5",children:["Lead Status Updated:"," ",(0,u.jsx)("span",{className:"font-medium text-primary",children:"Today"}),(0,u.jsx)("span",{className:"ml-1 text-primary2 text-base",children:"\xd7"})]})]}),(0,u.jsxs)("p",{className:"text-xs text-muted-foreground inline-flex items-center gap-2 pt-0.5",children:[(0,u.jsx)(w.Z,{size:11,fill:"currentColor"}),"Sorted by lead updated time or follow up time"]})]})]}),!e4&&(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,u.jsx)("h2",{className:"text-lg font-medium text-black tracking-tight",children:"Performance Overview"})}),(0,u.jsxs)("div",{className:"flex gap-4 flex-wrap",children:[(0,u.jsx)(P.Bi,{title:"Total Leads",value:null!==(em=null==rm?void 0:rm.total_leads)&&void 0!==em?em:"—",icon:(0,u.jsx)(C.Z,{size:20}),isLoading:aH}),(0,u.jsx)(P.Bi,{title:"Contacted Leads",value:null!==(ef=null==rm?void 0:rm.contacted_leads)&&void 0!==ef?ef:"—",icon:(0,u.jsx)(h.Z,{size:20}),toolTip:"Leads with valid status (excluding Not Dialed)",isLoading:aH}),(0,u.jsx)(P.Bi,{title:"Sales Done",value:null!==(ex=null==rm?void 0:rm.sales_done)&&void 0!==ex?ex:"—",icon:(0,u.jsx)(j.Z,{size:20}),isLoading:aH}),(0,u.jsx)(P.Bi,{title:"Conversion Rate",value:aH?"—":rh,icon:(0,u.jsx)(j.Z,{size:20}),isLoading:aH})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2 pt-2",children:[(0,u.jsx)("h2",{className:"text-lg font-medium text-black tracking-tight lg:whitespace-nowrap",children:"Your Leads"}),(0,u.jsxs)("div",{className:"flex justify-end items-center flex-wrap gap-2",children:[a6.length>0&&[G.B.ADMIN,G.B.OWNER].includes(eS)&&(0,u.jsxs)("button",{onClick:function(){ru.mutate()},disabled:ru.isLoading,className:"flex h-max items-center justify-center gap-2 py-2 px-3 mx-1 bg-primary-light border border-primary2/30 text-primary text-xs font-medium lg:text-sm rounded-lg hover:text-white hover:bg-primary2 disabled:bg-primary2 disabled:text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors whitespace-nowrap shadow-sm h-full",children:[ru.isLoading?(0,u.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,u.jsx)(p.Z,{size:14,className:"lg:w-4 lg:h-4"}),ru.isLoading?"Downloading...":"Download CSV"]}),e4&&(0,u.jsxs)("div",{className:"flex items-center rounded-lg border bg-muted p-0 gap-1",children:[(0,u.jsxs)("button",{onClick:function(){return e7("pending")},className:"flex items-center gap-2 px-4 py-2 rounded-lg text-xs lg:text-sm font-medium transition-all ".concat("pending"===e6?"bg-teal-800 text-white shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,u.jsx)(v.Z,{size:14}),"Call Pending (",a4.length,")"]}),(0,u.jsxs)("button",{onClick:function(){return e7("done")},className:"flex items-center gap-2 px-4 py-1.5 rounded-lg text-xs lg:text-sm font-medium transition-all ".concat("done"===e6?"bg-teal-800 text-white shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,u.jsx)(N.Z,{size:14}),"Call Done Today (",a3.length,")"]})]}),(0,u.jsxs)("div",{className:"relative overflow-hidden rounded-lg",children:[(0,u.jsx)("input",{value:aP,onChange:function(e){return aF(e.target.value)},onKeyDown:handleSearch,className:"rounded-lg shadow text-xs w-[200px] md:w-[250px] lg:w-[300px] focus:border-primary2 border-2 outline-none pr-8 p-2",placeholder:"Enter email or phone number..."}),(0,u.jsx)("button",{type:"button",onClick:function(){return handleSearch()},className:"absolute right-0 top-1/2 -translate-y-1/2 bg-primary2 py-3 px-4 hover:bg-primary2/90 transition-colors",children:(0,u.jsx)(b.Z,{size:14,className:"text-white"})})]}),aR.trim()&&(0,u.jsx)("button",{onClick:function(){aF(""),aI("")},className:"px-3 py-2 rounded-lg border border-gray-light text-xs font-semibold text-gray-dark hover:text-red transition-colors",title:"Clear search",children:"Clear"}),(0,u.jsx)("button",{onClick:function(){refetchActiveLeadsList(),rd()},className:"p-3 rounded-xl border bg-white hover:border-primary2/30 transition-all",title:"Refresh",children:(0,u.jsx)(y.Z,{size:16,className:J()("text-gray-dark",{"animate-spin":a$.isFetching})})})]})]}),(0,u.jsxs)("div",{className:"flex gap-4 relative h-[calc(100vh-220px)] overflow-hidden",children:[(0,u.jsxs)("div",{className:"bg-white border border-gray-light rounded-3xl transition-all duration-300 flex flex-col overflow-hidden ".concat(tc?"flex-1 min-w-0":"w-full"),children:[(0,u.jsx)("div",{className:"flex-1 overflow-auto",children:(0,u.jsxs)("table",{className:"w-full text-left",children:[(0,u.jsx)("thead",{className:"bg-off-white border-b border-gray-light sticky top-0 z-20",children:(0,u.jsx)("tr",{children:rt.map(function(e,t){return(0,u.jsx)("th",{className:"px-5 py-3.5 text-xs font-semibold text-black uppercase tracking-wider whitespace-nowrap ".concat(t===rt.length-1?"sticky right-0 bg-off-white border-l border-gray-light z-20":""),children:e},e)})})}),(0,u.jsx)("tbody",{children:rr?(0,u.jsx)(A.rc,{customFieldCount:a7.length,showEmail
6:a9,showCompany:a8,hasCustomizedStatus:eC}):0===a6.length?(0,u.jsx)(A.vw,{}):a6.map(function(e){return(0,u.jsx)(A.N6,{lead:e,customFieldKeys:a7,customFieldLabelMap:re,crmFields:eN||[],showEmail:a9,showCompany:a8,onMoreClick:handleLeadMoreClick,onStatusClick:handleStatusClick,onCompanyClick:handleCompanyEditClick,onLeadNameClick:handleLeadNameEditClick,onCustomFieldClick:handleCustomFieldEditClick,onOwnerClick:handleOwnerAssignClick,onFollowUpClick:handleFollowUpClick,onMarkFollowUpClick:handleMarkFollowUpClick,onMarkCallDoneClick:function(e){rf(e)},membersById:rg,isSelected:(null==tx?void 0:tx.id)===e.id&&tc,hasCustomizedStatus:eC},e.id)})})]})}),!e4&&rl&&!rr&&(0,u.jsx)("div",{className:"p-4 flex justify-center border-t border-gray-light",children:(0,u.jsx)("button",{onClick:function(){rl&&!rn&&ra.fetchNextPage()},className:"px-6 py-2 rounded-full border border-gray-light bg-white text-sm font-semibold text-primary2 hover:bg-primary-light/30 transition-all",children:"Load more"})}),!e4&&rn&&a1.length>0&&(0,u.jsx)("div",{className:"p-4 flex justify-center border-t border-gray-light",children:(0,u.jsx)(A.zM,{size:20,className:"animate-spin text-primary2"})})]}),(0,u.jsx)(K.Z,{open:tc,onClose:handleLeadActivitiesPanelClose,lead:tx,user:ep,onActivityCreated:function(){refetchActiveLeadsList(),tv(function(e){return e+1})},onLeadDeleted:function(){handleLeadActivitiesPanelClose(),refetchActiveLeadsList()},refreshKey:tg,membersById:rg,onStatusClick:handleStatusClick,onOwnerClick:handleOwnerAssignClick,onFollowUpClick:handleFollowUpClick,onCompanyClick:handleCompanyEditClick,onCustomFieldEditClick:handleCustomFieldEditClick,hasCustomizedStatus:eC})]})]})]}),(0,u.jsx)(H.cZ,{children:(0,u.jsxs)("div",{className:"bg-white w-full max-w-md rounded-3xl overflow-hidden shadow-2xl p-6",children:[(0,u.jsx)(H.fK,{children:(0,u.jsx)("h2",{className:"text-xl font-bold text-black",children:"Select Owners"})}),(0,u.jsx)("p",{className:"text-sm text-gray-dark mt-1 mb-4",children:"Tick team members to filter leads by owner."}),(0,u.jsx)("div",{className:"max-h-[400px] overflow-y-auto border border-gray-light rounded-xl divide-y divide-gray-light",children:ro?(0,u.jsx)("div",{className:"py-10 flex items-center justify-center",children:(0,u.jsx)(A.zM,{size:20,className:"animate-spin text-primary2"})}):0===rx.length?(0,u.jsx)("div",{className:"py-10 text-center text-sm text-gray-dark",children:"No team members found."}):rx.map(function(e){var t,a,r,n=e.uid,l=(null===(t=e.profile)||void 0===t?void 0:t.name)||(null===(a=e.profile)||void 0===a?void 0:a.email),s=rp.includes(n);return(0,u.jsxs)("label",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-off-white/60 transition-colors",children:[(0,u.jsx)("input",{type:"checkbox",checked:s,onChange:function(e){return handleOwnerToggle(n,l,e.target.checked)},className:"w-4 h-4 text-primary2 border-gray-300 rounded focus:ring-primary2"}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"text-sm font-semibold text-black truncate",children:l}),(0,u.jsx)("p",{className:"text-xs text-gray-dark truncate",children:null===(r=e.profile)||void 0===r?void 0:r.email})]})]},n)})}),(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3 pt-4",children:[(0,u.jsx)("button",{onClick:function(){eE(function(e){var t=(0,l._)({},e);return delete t.owner_uid,t}),eP(function(e){return e.filter(function(e){return"owner_uid"!==e.key})})},className:"px-4 py-2 rounded-lg border border-gray-light text-sm font-semibold text-gray-dark hover:text-red transition-colors",children:"Clear Owners"}),(0,u.jsx)("button",{onClick:function(){return e2(!1)},className:"px-4 py-2 rounded-lg bg-primary2 text-white text-sm font-semibold hover:bg-primary2/90 transition-all",children:"Done"})]})]})})]}),(0,u.jsx)(X.Z,{open:tl,onClose:function(){ts(!1),td(null)},lead:to,user:ep,onSuccess:function(){refetchActiveLeadsList(),tv(function(e){return e+1})},onReschedule:function(e){ts(!1),td(null),handleFollowUpClick(e)}}),(0,u.jsx)(Y.Z,{open:e8,onOpenChange:function(e){te(e),e||tr(null)},lead:ta,user:ep,onSuccess:function(){refetchActiveLeadsList(),tv(function(e){return e+1})}}),(0,u.jsx)(H.ZP,{open:tb,onOpenChange:t_,children:(0,u.jsx)(H.cZ,{children:(0,u.jsxs)("div",{className:"bg-white w-full max-w-md rounded-3xl overflow-hidden shadow-2xl p-6 min-w-[400px]",children:[(0,u.jsx)(H.fK,{children:(0,u.jsx)("h2",{className:"text-xl font-bold text-black",children:"Assign Owner"})}),tj&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{className:"text-sm text-gray-dark mt-1 mb-4",children:["for"," ",(0,u.jsx)("span",{className:"font-semibold text-black",children:tj.name||[tj.first_name,tj.last_name].filter(
6Boolean).join(" ")||"Lead"})]}),(0,u.jsx)("div",{className:"max-h-[360px] overflow-y-auto border border-gray-light rounded-xl divide-y divide-gray-light mb-4",children:0===rx.length?(0,u.jsx)("div",{className:"py-10 text-center text-sm text-gray-dark",children:"No team members found."}):rx.map(function(e){if(!e.uid)return null;var t,a,r,n,l,s=e.uid,i=(null===(t=e.profile)||void 0===t?void 0:t.name)||(null===(a=e.profile)||void 0===a?void 0:a.email)||s,o=tj.owner_uid===s;return(0,u.jsxs)("button",{type:"button",disabled:tk,onClick:function(){rv(s)},className:"w-full flex items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-off-white/60 disabled:opacity-50 ".concat(o?"bg-primary-light/30":""),children:[(0,u.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ".concat(o?"bg-primary2 text-white":"bg-off-white text-gray-dark"),children:null!==(l=null===(r=i[0])||void 0===r?void 0:r.toUpperCase())&&void 0!==l?l:"?"}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"text-sm font-semibold text-black truncate",children:i}),(null===(n=e.profile)||void 0===n?void 0:n.email)&&e.profile.name&&(0,u.jsx)("p",{className:"text-xs text-gray-dark truncate",children:e.profile.email})]}),o&&(0,u.jsx)("span",{className:"ml-auto text-xs font-bold text-primary2 shrink-0",children:"Current"}),tk&&(0,u.jsx)(A.zM,{size:14,className:"animate-spin text-primary2 ml-auto"})]},s)})}),(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3 pt-1",children:[tj.owner_uid&&(0,u.jsx)("button",{onClick:function(){rv(null)},disabled:tk,className:"px-4 py-2 rounded-lg border border-gray-light text-sm font-semibold text-gray-dark hover:text-red transition-colors disabled:opacity-50",children:"Remove Owner"}),(0,u.jsx)("button",{onClick:function(){t_(!1),tN(null)},className:"ml-auto px-4 py-2 rounded-lg border border-gray-light text-sm font-semibold text-gray-dark hover:text-red transition-colors",children:"Cancel"})]})]})]})})}),(0,u.jsx)(H.ZP,{open:tL,onOpenChange:tO,children:(0,u.jsx)(H.cZ,{children:(0,u.jsxs)("div",{className:"bg-white w-full max-sm rounded-3xl overflow-hidden shadow-2xl p-6 min-w-[400px]",children:[(0,u.jsx)(H.fK,{children:(0,u.jsx)("h2",{className:"text-xl font-bold text-black",children:"Change Status"})}),tT&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{className:"text-sm text-gray-dark mt-1 mb-4",children:["for"," ",(0,u.jsx)("span",{className:"font-semibold text-black",children:tT.name||[tT.first_name,tT.last_name].filter(Boolean).join(" ")||"Lead"})]}),(0,u.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:M.Em.map(function(e){var t,a=e.label,r=e.value,n=null===(t=tT.crm)||void 0===t?void 0:t.status,l=(null==n||"null"===n?F.Rc.NOT_DIALED:n)===r;return(0,u.jsxs)("button",{type:"button",disabled:tF,onClick:function(){ry(r)},className:"flex items-center justify-between px-4 py-3 rounded-xl border transition-all text-sm font-semibold disabled:opacity-50 ".concat(l?"border-primary2 bg-primary-light/30 text-primary2":"border-gray-light bg-white text-black hover:border-primary2/40 hover:bg-off-white/60"),children:[(0,u.jsx)("span",{children:a}),(0,u.jsxs)("span",{className:"flex items-center gap-2",children:[l&&(0,u.jsx)("span",{className:"text-xs font-bold text-primary2",children:"Active"}),tF&&l&&(0,u.jsx)(A.zM,{size:14,className:"animate-spin"})]})]},r)})}),(0,u.jsxs)("div",{className:"border-t border-gray-light py-3 mt-2 mb-4 flex items-center justify-between gap-4",children:[(0,u.jsxs)("div",{className:"flex gap-2.5 items-start px-1",children:[(0,u.jsx)("div",{className:"mt-0.5 shrink-0 flex items-center justify-center text-primary2",children:(0,u.jsx)(_.Z,{size:20})}),(0,u.jsxs)("div",{className:"text-left",children:[(0,u.jsx)("h4",{className:"text-sm font-semibold text-black leading-snug",children:"Customise Status"}),(0,u.jsx)("p",{className:"text-xxs text-gray-dark leading-tight mt-0.5 text-wrap",children:"Create and manage custom statuses to fit your process."})]})]}),(0,u.jsxs)("button",{type:"button",onClick:function(){tO(!1),tA(null),eh.push("/web/crm-fields")},className:"shrink-0 flex items-center gap-1.5 px-3 py-2 border border-primary2/30 bg-primary-light/30 text-primary2 roun
6ded-lg text-xs font-semibold hover:border-primary2/60 hover:bg-primary-light/50 transition-colors",children:[(0,u.jsx)(_.Z,{size:13}),(0,u.jsx)("span",{children:"Customise"})]})]}),(0,u.jsx)("button",{type:"button",onClick:function(){tO(!1),tA(null)},className:"w-full px-4 py-2 rounded-lg border border-gray-light text-sm font-semibold text-gray-dark hover:text-red transition-colors",children:"Cancel"})]})]})})}),(0,u.jsx)(H.ZP,{open:aC,onOpenChange:ak,children:(0,u.jsx)(H.cZ,{children:(0,u.jsxs)("div",{className:"bg-white w-full max-w-lg rounded-[24px] overflow-hidden shadow-2xl p-6 min-w-[360px] md:min-w-[400px]",children:[(0,u.jsx)(H.fK,{children:(0,u.jsx)("h2",{className:"text-xl font-bold text-black font-sans leading-none flex items-center justify-between gap-2",children:"Change Custom Status"})}),aD&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{className:"text-xs text-gray-dark mt-2 mb-4 font-medium",children:["for"," ",(0,u.jsx)("span",{className:"font-semibold text-black",children:aD.name||[aD.first_name,aD.last_name].filter(Boolean).join(" ")||"Lead"})]}),(0,u.jsx)("div",{className:"flex flex-col gap-2 mb-4 max-h-[350px] overflow-y-auto pr-1",children:0===(en=(null==eN?void 0:null===(er=eN.find(function(e){return e.key===F.Rq}))||void 0===er?void 0:er.options)||[]).length?(0,u.jsx)("p",{className:"text-xs text-gray-dark text-center py-6 font-medium",children:"No custom status options configured."}):(0,o._)(en).sort(function(e,t){var a,r;return String(null===(a=e.metadata)||void 0===a?void 0:a.mapped_crm_status).localeCompare(String(null===(r=t.metadata)||void 0===r?void 0:r.mapped_crm_status))}).map(function(e){var t,a,r,n,l,s=(null===(t=aD.custom_fields)||void 0===t?void 0:t[F.Rq])===e.value,i=(null===(a=e.metadata)||void 0===a?void 0:a.mapped_crm_status)===null?F.Rc.NOT_DIALED:(null===(r=e.metadata)||void 0===r?void 0:r.mapped_crm_status)||null,o=null!==(n=M.id[i])&&void 0!==n?n:"bg-gray-light text-gray-dark",d=null!==(l=F.Cj[i])&&void 0!==l?l:String(i);return(0,u.jsxs)("button",{type:"button",disabled:aE,onClick:function(){rb(e.value)},className:"flex items-center justify-between px-4 py-3.5 rounded-xl border transition-all text-sm font-semibold disabled:opacity-50 ".concat(s?"border-primary2 bg-primary-light/30 text-primary2":"border-gray-light bg-white text-black hover:border-primary2/40 hover:bg-off-white/60"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-start gap-2 flex-wrap",children:[(0,u.jsx)("span",{className:"text-sm font-medium text-black text-left",children:e.label}),(0,u.jsx)("span",{className:"inline-flex items-center mx-1 px-2 py-0.5 rounded-full text-[9px] font-medium border ".concat(o),children:d})]}),(0,u.jsxs)("span",{className:"flex items-center gap-2",children:[s&&(0,u.jsx)("span",{className:"text-xs font-bold text-primary2",children:"Active"}),aE&&s&&(0,u.jsx)(A.zM,{size:14,className:"animate-spin text-primary2"})]})]},e.value)})}),(0,u.jsxs)("div",{className:"border-t border-gray-light py-3 mt-2 mb-4 flex items-center justify-between gap-4",children:[(0,u.jsxs)("div",{className:"flex gap-2.5 items-start px-1",children:[(0,u.jsx)("div",{className:"mt-0.5 shrink-0 flex items-center justify-center text-primary2",children:(0,u.jsx)(_.Z,{size:20})}),(0,u.jsxs)("div",{className:"text-left",children:[(0,u.jsx)("h4",{className:"text-sm font-semibold text-black leading-snug",children:"Customise Status"}),(0,u.jsx)("p",{className:"text-xxs text-gray-dark leading-tight mt-0.5 text-wrap",children:"Create and manage custom statuses to fit your process."})]})]}),(0,u.jsxs)("button",{type:"button",onClick:function(){ak(!1),aL(null),eh.push("/web/crm-fields")},className:"shrink-0 flex items-center gap-1.5 px-3 py-2 border border-primary2/30 bg-primary-light/30 text-primary2 rounded-lg text-xs font-semibold hover:border-primary2/60 hover:bg-primary-light/50 transition-colors",children:[(0,u.jsx)(_.Z,{size:13}),(0,u.jsx)("span",{children:"Customise"})]})]}),(0,u.jsx)("button",{type:"button",onClick:function(){ak(!1),aL(null)},className:"w-full px-4 py-2 text-xs font-semibold tracking-wide transition-colors duration-200 border border-gray-light text-gray-dark rounded-lg bg-blend-normal hover:text-red hover:text-black mb-1",children:"Cancel"})]})]})})}),(0,u.jsx)(H.ZP,{open:ai,onOpenChange:ao,children:(0,u.jsx)(H.cZ,{children:(0,u.jsxs)("div",{className:"bg-white w-full max-w-md rounded-3xl overflow-hidden shadow-2xl p-6 min-w-[400px]",children:[(0,u.jsx)(H.fK,{children:(0,u.jsxs)("h2",{className:"text-xl font-bold text-black",children:["Change ",null==af?void 0:af.label]})}),au&&af&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{className:"text-sm text-gray-dark mt-1 mb-4",children:["for"," ",(0,u.jsx)("span",{className:"font-semibold text-black",children:au.name||[au.first_name,au.last_name].filter(
6Boolean).join(" ")||"Lead"})]}),(0,u.jsx)("div",{className:"mb-6",children:"location"===af.key?(0,u.jsx)("div",{className:"space-y-4",children:[{label:"City",value:t9,setValue:t8},{label:"State",value:at,setValue:aa},{label:"Country",value:an,setValue:al}].map(function(e){var t=e.label,a=e.value,r=e.setValue;return(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-semibold text-gray-dark mb-1",children:t}),(0,u.jsx)("input",{type:"text",value:a,onChange:function(e){return r(e.target.value)},className:"w-full bg-white border border-gray-medium/60 rounded-xl py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary2 outline-none",placeholder:"Enter ".concat(t)})]},t)})}):(0,u.jsxs)(u.Fragment,{children:["DROPDOWN"===af.type&&(0,u.jsxs)("select",{value:ah||"",onChange:function(e){return ag(e.target.value)},className:"w-full bg-white border border-gray-medium/60 rounded-xl py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary2 outline-none",children:[(0,u.jsx)("option",{value:"",children:"Select option"}),null===(el=af.options)||void 0===el?void 0:el.map(function(e){return(0,u.jsx)("option",{value:e.value,children:e.label},e.value)})]}),"BOOLEAN"===af.type&&(0,u.jsx)("div",{className:"flex w-full bg-gray-50 border border-gray-medium/60 rounded-xl p-1",children:[!0,!1].map(function(e){return(0,u.jsx)("button",{type:"button",onClick:function(){return ag(ah===e?"":e)},className:"flex-1 py-2 text-sm rounded-lg transition-all duration-200 ".concat(ah===e?"".concat(e?"bg-primary-light text-primary2":"bg-red/10 text-red"," shadow-sm font-semibold"):"text-gray-500 hover:text-gray-700 font-medium"),children:e?"True":"False"},String(e))})}),"NUMBER"===af.type&&(0,u.jsx)("input",{type:"number",value:ah||"",onChange:function(e){return ag(e.target.value)},className:"w-full bg-white border border-gray-medium/60 rounded-xl py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary2 outline-none",placeholder:"Enter ".concat(af.label)}),"DATE"===af.type&&(0,u.jsx)("input",{type:"date",value:ah||"",onChange:function(e){return ag(e.target.value)},className:"w-full bg-white border border-gray-medium/60 rounded-xl py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary2 outline-none"}),("TEXT"===af.type||!af.type)&&(0,u.jsx)("input",{type:"text",value:ah||"",onChange:function(e){return ag(e.target.value)},className:"w-full bg-white border border-gray-medium/60 rounded-xl py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary2 outline-none",placeholder:"Enter ".concat(af.label)})]})}),(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("button",{onClick:function(){ao(!1),ac(null),ax(null)},className:"flex-1 px-4 py-2.5 border border-gray-light rounded-xl text-sm font-semibold text-gray-dark hover:bg-off-white/60 transition-colors",children:"Cancel"}),(0,u.jsxs)("button",{onClick:function(){r_()},disabled:ay,className:"flex-1 px-4 py-2.5 bg-primary2 text-white rounded-xl text-sm font-semibold hover:bg-primary2/90 disabled:opacity-50 flex items-center justify-center gap-2",children:[ay&&(0,u.jsx)(A.zM,{size:14,className:"animate-spin"}),"Save"]})]})]})]})})}),(0,u.jsx)(H.ZP,{open:tI,onOpenChange:tz,children:(0,u.jsx)(H.cZ,{children:(0,u.jsxs)("div",{className:"bg-white w-full max-w-md rounded-3xl overflow-hidden shadow-2xl p-6 min-w-[400px]",children:[(0,u.jsx)(H.fK,{children:(0,u.jsx)("h2",{className:"text-xl font-bold text-black",children:"Change Company Name"})}),tB&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{className:"text-sm text-gray-dark mt-1 mb-4",children:["for"," ",(0,u.jsx)("span",{className:"font-semibold text-black",children:tB.name||[tB.first_name,tB.last_name].filter(Boolean).join(" ")||"Lead"})]}),(0,u.jsx)("div",{className:"mb-6",children:(0,u.jsx)("input",{type:"text",value:tW,onChange:function(e){return tV(e.target.value)},className:"w-full bg-white border border-gray-medium/60 rounded-xl py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary2 outline-none",placeholder:"Enter company name"})}),(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("button",{onClick:function(){tz(!1),tZ(null)},className:"flex-1 px-4 py-2.5 border border-gray-light rounded-xl text-sm font-semibold text-gray-dark hover:bg-off-white/60 transition-colors",children:"Cancel"}),(0,u.jsxs)("button",{onClick:function(){rw()},disabled:tH,className:"flex-1 px-4 py-2.5 bg-primary2 text-white rounded-xl text-sm font-semibold hover:bg-primary2/90 disabled:opacity-50 flex items-center justify-center gap-2",children:[tH&&(0,u.jsx)(A.zM,{size:14,className:"animate-spin"}),"Save"]})]})]})]})})}),(0,u.jsx)(H.ZP,{open:tY,onOpenChange:tQ,children:(0,u.jsx)(H.cZ,{children:(0,u.jsxs)("div",{className:"bg-white w-full max-w-md rounded-3xl overflow-hidden shadow-2xl p-6 min-w-[400px]",children:[(0,u.jsx)(H.fK,{children:(0,u.jsx)("h2",{className:"text-xl font-bold text-black",children:"Change Lead Name"})}),t$&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{className:"text-sm text-gray-dark mt-1 mb-4",children:["for"," ",(0,u.jsx)("span",{className:"font-semibold text-black",children:t$.name||[t$.f
6irst_name,t$.last_name].filter(Boolean).join(" ")||"Lead"})]}),(0,u.jsx)("div",{className:"mb-6",children:(0,u.jsx)("input",{type:"text",value:t1,onChange:function(e){return t4(e.target.value)},onKeyDown:function(e){"Enter"===e.key&&rj()},className:"w-full bg-white border border-gray-medium/60 rounded-xl py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary2 outline-none",placeholder:"Enter lead name",autoFocus:!0})}),(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("button",{onClick:function(){tQ(!1),t0(null)},className:"flex-1 px-4 py-2.5 border border-gray-light rounded-xl text-sm font-semibold text-gray-dark hover:bg-off-white/60 transition-colors",children:"Cancel"}),(0,u.jsxs)("button",{onClick:function(){rj()},disabled:t5,className:"flex-1 px-4 py-2.5 bg-primary2 text-white rounded-xl text-sm font-semibold hover:bg-primary2/90 disabled:opacity-50 flex items-center justify-center gap-2",children:[t5&&(0,u.jsx)(A.zM,{size:14,className:"animate-spin"}),"Save"]})]})]})]})})})]})}},26646:(e,t,a)=>{"use strict";a.d(t,{S2:()=>o,dG:()=>i,py:()=>s});var r=a(11010),n=a(28207),l=a(69346),s=function(){var e=(0,r._)(function(e){var t,a,r,s;return(0,n._)(this,function(n){switch(n.label){case 0:return t=e.headers,r=void 0===(a=e.queryParams)?{}:a,s=new URL(l.Pn.AD_INSIGHT_CARDS),Object.keys(r).forEach(function(e){s.searchParams.set(e,r[e])}),[4,(0,l.t5)({url:s.toString(),headers:t})];case 1:return[2,n.sent()]}})});return function(t){return e.apply(this,arguments)}}(),i=function(){var e=(0,r._)(function(e){var t,a,r,s;return(0,n._)(this,function(n){switch(n.label){case 0:return t=e.headers,r=void 0===(a=e.queryParams)?{}:a,s=new URL(l.Pn.CAMPAIGNS_REPORT),Object.keys(r).forEach(function(e){s.searchParams.set(e,r[e])}),[4,(0,l.t5)({url:s.toString(),headers:t})];case 1:return[2,n.sent()]}})});return function(t){return e.apply(this,arguments)}}(),o=function(){var e=(0,r._)(function(e){var t,a,r,s;return(0,n._)(this,function(n){switch(n.label){case 0:return t=e.headers,r=void 0===(a=e.queryParams)?{}:a,s=new URL(l.Pn.ORG_LEADS_REPORT),Object.keys(r).forEach(function(e){s.searchParams.set(e,r[e])}),[4,(0,l.t5)({url:s.toString(),headers:t})];case 1:return[2,n.sent()]}})});return function(t){return e.apply(this,arguments)}}()},70614:(e,t,a)=>{"use strict";a.d(t,{Z:()=>subscription_LeadQuotaBanner});var r=a(85893);a(67294);var n=a(41664),l=a.n(n),s=a(94184),i=a.n(s),o=a(40116),d=a(82701),u=a(44812),c=a(71685);let subscription_LeadQuotaBanner=function(e){var t=e.user,a=(0,c.m)(t).usage;if(!a)return null;var n=a.exhausted,s=a.used,m=a.total,f=a.percentage,x=n?o.Z:u.Z;return(0,r.jsxs)("div",{className:i()("rounded-3xl border px-4 sm:px-5 py-4 flex flex-col sm:flex-row sm:items-center gap-3",n?"bg-[#FDF0EB] border-[#F5D5CC]":"bg-[#EAF5F3] border-primary2/20"),children:[(0,r.jsx)(x,{size:18,className:"text-gray-700 shrink-0"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-[#111111]",children:n?"Lead quota exhausted":"Lead quota"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:n?"You've used all ".concat(m.toLocaleString()," lead records included in your plan."):"You've used ".concat(s.toLocaleString()," of ").concat(m.toLocaleString()," lead records included in your plan.")}),(0,r.jsx)("div",{className:"mt-2 h-1.5 max-w-xs bg-white/70 rounded-full overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-[#225E56] rounded-full transition-all duration-500",style:{width:"".concat(f,"%")}})})]}),(0,r.jsxs)(l(),{href:"/subscription?view=explore",className:"inline-flex items-center justify-center gap-2 bg-[#F57141] hover:bg-[#DE5F30] text-white text-sm font-semibold px-5 py-2.5 rounded-full transition-colors",children:["Upgrade Plan ",(0,r.jsx)(d.Z,{size:16})]})]})}},21749:(e,t,a)=>{"use strict";a.d(t,{l:()=>d});var r=a(85893),n=a(67294),l=a(11988);a(35890);var s=a(34622),i=a(41352),o=a(16805),d=n.memo(function(e){var t=e.dateFrom,a=e.dateTo,n=e.selectedPreset,d=e.onDateRangeChange,u=e.onPresetSelect,c=e.onClear,m=e.label,f=e.placeholder,x=e.showPresets,p=e.presets,h=null!=p?p:o.c0;return(0,r.jsx)("div",{className:"flex flex-col gap-3 w-full",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-gray-dark px-2",children:void 0===m?"Created Date Range":m}),(0,r.jsxs)("div",{className:"flex gap-2 md:gap-3 flex-wrap",children:[(0,r.jsxs)("div",{className:"relative w-full sm:w-auto",children:[(0,r.jsx)(l.ZP,{selected:t,onChange:d,startDate:t,endDate:a,selectsRange:!0,isClearable:!0,placeholderText:void 0===f?"Select created date range":f,dateFormat:"dd MMM yyyy",className:"px-10 py-2 rounded-xl border border-gray-light bg-white text-xxs md:text-xs lg:text-sm text-black placeholder-gray-medium focus:outline-none focus:border-primary2 w-full sm:w-[280px] md:w-[320px] lg:w-[500px]",wrapperClassName:"w-full sm:w-auto",popperClassName:"z-50",popperPlacement:"bottom-start",popperProps:{strategy:"fixed"}}),(0,r.jsx)(s.Z,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-dark pointer-events-none"})]}),(void 0===x||x)&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1 md:gap-2 w-full",children:h.map(function(e){return(0,r.jsx)("button",{onClick:function(){return u(null==e?void 0:e.key)},className:"px-3 py-1.5 rounded-full border text-xxs lg:text-sm md:text-xs font-semibold transition-colors ".concat(n===(null==e?void 0:e.key)?"border-primary2 bg-primary-light/30 text-primary2":"border-gray-light bg-white text-gray-dark hover:border-primary2/40 hover:text-black"),children:null==e?void 0:e.label},null==e?void 0:e.key)})}),(t||a)&&(0,r.jsxs)("button",{onClick:c,className:"flex items-center gap-1 px-3 py-1.5 rounded-full border border-gray-light bg-white text-xxs md:text-xs font-semibold text-gray-dark hover:text-red transition-colors w-fit",children:[(0,r.jsx)(i.Z,{size:12}),"Clear Date"]})]})]})})});d.displayName="DateRangePickerWithPresets"},16805:(e,t,a)=>{"use strict";a.d(t,{Bo:()=>formatDurationHm,Ij:()=>getISODateString,c0:()=>s,cq:()=>convertDateRangeToISO,gB:()=>formatRelativeDayLabel,mC:()=>i,mV:()=>getPresetRange,oe:()=>getFollowUpDateRange});var r=a(72253),n=a(14932),l=a(91309),startOfDay=function(e){var t=new Date(e);return t.setHours(0,0,0,0),t},addDays=function(e,t){var a=new Date(e);return a.setDate(a.getDate()+t),a},getPresetRange=function(e){var t=startOfDay(new Date);if("today"===e)return{start:t,end:t};if("7d"===e)return{start:addDays(t,-6),end:t};if("2m"===e){var a=new Date(t);return a.setMonth(a.getMonth()-2),{start:a,end:t}}return{start:addDays(t,-29),end:t}},getISODateString=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t?23:0,t?59:0,t?59:0,t?999:0).toISOString()},convertDateRangeToISO=function(e,t){var a={};if(e){var r=getISODateString(e,!1);r&&(a.created_from=r)}if(t){var n=getISODateString(t,!0);n&&(a.created_to=n)}return a},formatRelativeDayLabel=function(e){var t=startOfDay(new Date),a=startOfDay(e),r=Math.round((t.getTime()-a.getTime())/864e5);return 0===r?"Today":1===r?"Yesterday":r>1&&r<7?a.toLocaleDateString("en-US",{weekday:"long"}):a.toLocaleDateString("en-US",{day:"2-digit",month:"short"})},formatDurationHm=function(e){var t=Math.max(0,Math.floor(e/6e4));return"".concat(Math.floor(t/60),"h ").concat(t%60,"m")},s=[{key:"today",label:"Today"},{key:"7d",label:"Last 7 Days"},{key:"30d",label:"Last 30 Days"},{key:"2m",label:"Last 2 Months"}],i=[{key:"all",label:"All"},{key:"overdue",label:"Overdue"},{key:"last_7d",label:"Last 7 Days"},{key:"today",label:"Due Today"},{key:"tomorrow",label:"Due Tomorrow"},{key:"next_7d",label:"Next 7 Days"}],o={all:[null,0],overdue:[null,-1],last_7d:[-7,0],today:[0,0],tomorrow:[1,1],next_7d:[0,7]},getFollowUpDateRange=function(e){var t=o[e];if(!t)return{};var a=(0,l._)(t,2),s=a[0],i=a[1],d=new Date,getDateWithOffset=function(e){var t=new Date(d);return t.setDate(d.getDate()+e),t};return(0,n._)((0,r._)({},null!==s&&{follow_up_at_from:getISODateString(getDateWithOffset(s),!1)}),{follow_up_at_to:getISODateString(getDateWithOffset(i),!0)})}},56837:(e,t,a)=>{"use strict";a.d(t,{ES:()=>formatPhoneDisplay,Ef:()=>useActiveSourceOptions,Em:()=>f,O6:()=>c,Qh:()=>getLeadDisplayName,XS:()=>m,d7:()=>getTelephonyItems,el:()=>checkCustomizedStatus,id:()=>d,jX:()=>u,rp:()=>getStatusLabel,wl:()=>x});var r,n=a(75766),l=a(91309),s=a(67294),i=a(39938),o=a(48403),d=(r={},(0,n._)(r,i.Rc.GOOD_LEAD_FOLLOW_UP,"bg-green-100 text-green-700 border-green-200"),(0,n._)(r,i.Rc.DID_NOT_CONNECT_OR_BUSY,"bg-yellow-100 text-yellow-700 border-yellow-200"),(0,n._)(r,i.Rc.BAD_LEAD,"bg-rose-100 text-rose-600 border-rose-200"),(0,n._)(r,i.Rc.SALE_DONE,"bg-violet-100 text-violet-600 border-violet-200"),(0,n._)(r,i.Rc.CONTACTED,"bg-blue-100 text-blue-600 border-blue-200"),r),u={HOT:"bg-rose-100 text-rose-600 border-rose-200",WARM:"bg-orange-100 text-orange-600 border-orange-200",COLD:"bg-sky-100 text-sky-600 border-sky-200",BAD:"bg-gray-100 text-gray-500 border-gray-200"},c=[{label:"Hot",value:"HOT"},{label:"Warm",value:"WARM"},{label:"Cold",value:"COLD"},{label:"Bad",value:"BAD"}],m=[{label:"Website",value:i.mC.WEBSITE},{label:"Meta Ads",value:i.mC.META_ADS},{label:"Google Ads",value:i.mC.GOOGLE_ADS},{label:"Webhook",value:i.mC.WEBHOOK},{label:"IndiaMart",value:i.mC.INDIAMART},{label:"JustDial",value:i.mC.JUSTDIAL},{label:"MagicBricks",value:i.mC.MAGICBRICKS},{label:"99acres",value:i.mC["99ACRES"]},{label:"Housing",value:i.mC.HOUSING},{label:"Android",value:i.mC.ANDROID},{label:"iOS",value:i.mC.IOS},{label:"Whatsapp",value:i.mC.WHATSAPP},{label:"Telephony",value:i.mC.TELEPHONY},{label:"CSV",value:i.mC.CSV},{label:"Manual",value:i.mC.MANUAL},{label:"Shopify",value:i.mC.SHOPIFY}].filter(function(e){return Object.values(i.mC).includes(e.value)}),f=Object.entries(i.Cj).map(function(e){var t=(0,l._)(e,2),a=t[0];return{label:t[1],value:a}}),getTelephonyItems=function(e){return(e||[]).map(function(e,t){return{id:String(t),number:e.mobile_number,status:e.status}})},useActiveSourceOptions=function(e,t){return(0,s.useMemo)(function(){var a=Object.keys((null==e?void 0:e.lead_sources)||{}).filter(function(t){var a,r;return(null==e?void 0:null===(r=e.lead_sources)||void 0===r?void 0:null===(a=r[t])||void 0===a?void 0:a.leads_generated)>0}),r=new Set(a.map(function(e){return e.toUpperCase()}));return(0,o.lI)(null==e?void 0:e.waba_onboarding).length>0&&r.add(i.mC.WHATSAPP),getTelephonyItems(t).length>0&&r.add(i.mC.TELEPHONY),r.add(i.mC.CSV),r.add(i.mC.MANUAL),r.add(i.mC.META_ADS),m.filter(function(e){return r.has(e.value.toUpperCase())})},[e,t])},getLeadDisplayName=function(e){return e&&(e.name||[e.first_name,e.last_name].filter(
6Boolean).join(" "))||"Lead"},formatPhoneDisplay=function(e){if(!e)return null;var t=e.match(/^(\+\d{2})(\d{5})(\d{5})$/);return t?"".concat(t[1]," ").concat(t[2]," ").concat(t[3]):e},checkCustomizedStatus=function(e){var t,a=[i.Cj[i.Rc.GOOD_LEAD_FOLLOW_UP],i.Cj[i.Rc.BAD_LEAD],i.Cj[i.Rc.DID_NOT_CONNECT_OR_BUSY],i.Cj[i.Rc.SALE_DONE],i.Cj[i.Rc.CONTACTED],i.Cj[i.Rc.NOT_DIALED]],r=null==e?void 0:e.find(function(e){return e.key===i.Rq});if(!r)return!1;var n=null===(t=r.options)||void 0===t?void 0:t.map(function(e){return e.label});return!!n&&(n.length>a.length||!a.every(function(e){return n.includes(e)}))},getStatusLabel=function(e,t){var a,r,n,l,s,o,d,u,c,m=null==e?void 0:null===(a=e.crm)||void 0===a?void 0:a.status,f=null==m||"null"===m?i.Rc.NOT_DIALED:m,x=null!==(o=i.Cj[f])&&void 0!==o?o:f,p=null==e?void 0:null===(r=e.custom_fields)||void 0===r?void 0:r[i.Rq],h=null==p||"null"===p?i.Rc.NOT_DIALED:p,g=null===(l=t.find(function(e){return e.key===i.Rq}))||void 0===l?void 0:null===(n=l.options)||void 0===n?void 0:n.find(function(e){return e.value===h});return{effectiveStatus:f,crmStatusLabel:x,customBaseStatus:null!==(d=null==g?void 0:null===(s=g.metadata)||void 0===s?void 0:s.mapped_crm_status)&&void 0!==d?d:i.Rc.NOT_DIALED,customStatusLabel:null!==(c=null!==(u=null==g?void 0:g.label)&&void 0!==u?u:i.Cj[h])&&void 0!==c?c:h}},x=[{label:"New to Old",description:"Newest created leads first",value:"created_at:desc"},{label:"Old to New",description:"Oldest created leads first",value:"created_at:asc"},{label:"Recent Activity",description:"Latest lead activity first",value:"last_activity_at:desc"},{label:"Follow Up",description:"Most urgent follow up first",value:"crm.next_follow_up_at:desc"}]},48403:(e,t,a)=>{"use strict";a.d(t,{DX:()=>getWaTemplateStatusClasses,KR:()=>findWabaPhoneDetailsByAgentDocId,bc:()=>downloadWaSampleCsv,hB:()=>validateBulkContactsInput,hO:()=>n,lI:()=>getWabaOnboardingItems,q2:()=>calculateWaCampaignCost,sJ:()=>validateWaAudienceFile});var r=a(72253),n=110,calculateWaCampaignCost=function(e){var t,a,r,l=Math.round(null!==(a=null==e?void 0:e.tentative_cost)&&void 0!==a?a:(null!==(t=null==e?void 0:e.recipient_count)&&void 0!==t?t:0)*n)/100,s=.18*l,i=null!==(r=null==e?void 0:e.tentative_currency)&&void 0!==r?r:"INR";return{totalCost:l,gst:s,finalAmount:l+s,currency:i,currencySymbol:i&&"INR"!==i?"$":"₹"}},downloadWaSampleCsv=function(){var e=document.createElement("a");e.href="data:text/csv;charset=utf-8,"+encodeURIComponent("phone_number,name\n91999826XXXX,Tej Pandya\n91720647XXXX,Varun Kumar"),e.download="sample_contacts.csv",document.body.appendChild(e),e.click(),document.body.removeChild(e)},validateWaAudienceFile=function(e){return e.name.endsWith(".csv")?e.size>5242880?"File size should be less than 5MB":null:"Please upload a CSV file"},validateBulkContactsInput=function(e){if(!(null==e?void 0:e.trim()))return{error:"Please enter at least one contact",data:null};for(var t=[],a=e.split(/\r?\n/),r=0;r<a.length;r++){var n=a[r].trim();if(n){var l=n.replace(/\D/g,"");if(l.length<8||l.length>18)return{error:"Invalid phone number(s).",data:null};t.push({phone_number:l})}}return{error:null,data:t}},getWaTemplateStatusClasses=function(e){return{"bg-green-100 text-green-700":"APPROVED"===e,"bg-yellow-100 text-yellow-700":"PENDING"===e,"bg-red-100 text-red-700":"REJECTED"===e}},getWabaOnboardingItems=function(e){var t=[];return e&&e.forEach(function(e){var a;null===(a=e.phone_numbers)||void 0===a||a.forEach(function(a){t.push((0,r._)({waba_id:e.waba_id},a))})}),t},findWabaPhoneDetailsByAgentDocId=function(e,t){return t?e.find(function(e){return e.display_phone_number.replace(/\D/g,"")===t}):void 0}}},e=>{var __webpack_exec__=t=>e(e.s=t);e.O(0,[5445,2013,2644,6342,5675,8767,1664,589,5198,5400,3700,7617,2918,2484,7132,9774,2888,179],()=>__webpack_exec__(39611)),_N_E=e.O()}]);

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.