PageSourceSearch

https://stephenwade.com/_next/static/chunks/pages/employee-portal/Analytics-cda64caf2dfeb1ac.js

js stephenwade.com collected 2026-09-24 12:19:12 UTC 51,892 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5194],{49742:(e,t,s)=>{"use strict";s.r(t),s.d(t,{__N_SSP:()=>O,default:()=>Y});var a=s(37876),r=s(14232),i=s(77328),l=s.n(i),n=s(56557),o=s.n(n),d=s(3422),c=s.n(d),h=s(10284),u=s.n(h),f=s(72193),p=s(40406);let x="#1f2733",g="#5b6472",m="#9aa2af",y="#eceef1",v="#1976d2",S=e=>e.toLocaleString();function b(e){let{data:t,height:s=320,type:i="line",formatValue:l=S,yLabel:n}=e,o=s-20-44,d=(0,r.useRef)(null),[c,h]=(0,r.useState)(null),u=(0,r.useMemo)(()=>(function(e){if(e<=0)return 1;let t=Math.pow(10,Math.floor(Math.log10(e))),s=e/t;return(s<=1?1:s<=2?2:s<=5?5:10)*t})(Math.max(1,...t.map(e=>e.value))),[t]);if(!t||0===t.length)return(0,a.jsx)(k,{height:s});let f=e=>1===t.length?498:56+e/(t.length-1)*884,p=e=>20+o-e/u*o,b=884/t.length,j=Math.min(38,.6*b),w=e=>56+b*e+b/2,M=Math.ceil(t.length/12),L=t.map((e,t)=>"".concat(0===t?"M":"L"," ").concat(f(t).toFixed(1)," ").concat(p(e.value).toFixed(1))).join(" "),z="M ".concat(f(0).toFixed(1)," ").concat((20+o).toFixed(1)," ")+t.map((e,t)=>"L ".concat(f(t).toFixed(1)," ").concat(p(e.value).toFixed(1))).join(" ")+" L ".concat(f(t.length-1).toFixed(1)," ").concat((20+o).toFixed(1)," Z"),D=null!=c?"bar"===i?w(c):f(c):0,T=null!=c?p(t[c].value):0;return(0,a.jsxs)("div",{style:{position:"relative",width:"100%"},children:[(0,a.jsxs)("svg",{ref:d,viewBox:"0 0 ".concat(960," ").concat(s),width:"100%",height:s,style:{display:"block",overflow:"visible"},onMouseMove:e=>{let s=d.current;if(!s)return;let a=s.getBoundingClientRect(),r=Math.round(((e.clientX-a.left)/a.width*960-56)/884*(t.length-1));h(Math.max(0,Math.min(t.length-1,r)))},onMouseLeave:()=>h(null),role:"img",children:[[0,.25,.5,.75,1].map((e,t)=>{let s=20+o-e*o;return(0,a.jsxs)("g",{children:[(0,a.jsx)("line",{x1:56,y1:s,x2:940,y2:s,stroke:y,strokeWidth:1}),(0,a.jsx)("text",{x:46,y:s+4,textAnchor:"end",fontSize:12,fill:m,children:l(Math.round(e*u))})]},t)}),t.map((e,t)=>t%M==0?(0,a.jsx)("text",{x:"bar"===i?w(t):f(t),y:s-44+20,textAnchor:"middle",fontSize:12,fill:g,children:e.label},t):null),n?(0,a.jsx)("text",{x:16,y:20+o/2,textAnchor:"middle",fontSize:12,fill:m,transform:"rotate(-90 16 ".concat(20+o/2,")"),children:n}):null,"line"===i?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("path",{d:z,fill:"rgba(25,118,210,0.12)",stroke:"none"}),(0,a.jsx)("path",{d:L,fill:"none",stroke:v,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),t.map((e,t)=>(0,a.jsx)("circle",{cx:f(t),cy:p(e.value),r:c===t?5:3,fill:v,stroke:"#fff",strokeWidth:2*(c===t)},t))]}):t.map((e,t)=>{let s=w(t)-j/2,r=p(e.value),i=20+o-r;return(0,a.jsx)("rect",{x:s,y:r,width:j,height:Math.max(0,i),rx:4,ry:4,fill:v,opacity:null==c||c===t?1:.55},t)}),null!=c?(0,a.jsx)("line",{x1:D,y1:20,x2:D,y2:20+o,stroke:m,strokeWidth:1,strokeDasharray:"4 4"}):null]}),null!=c?(0,a.jsxs)("div",{style:{position:"absolute",left:"".concat(D/960*100,"%"),top:"".concat(T/s*100,"%"),transform:"translate(-50%, -130%)",background:"#fff",border:"1px solid #e2e5e9",borderRadius:6,boxShadow:"0 4px 12px rgba(0,0,0,0.12)",padding:"6px 10px",pointerEvents:"none",whiteSpace:"nowrap",zIndex:5},children:[(0,a.jsx)("div",{style:{fontSize:12,color:g},children:t[c].label}),(0,a.jsx)("div",{style:{fontSize:15,fontWeight:600,color:x},children:l(t[c].value)})]}):null]})}function j(e){let{data:t,formatValue:s=S,maxRows:i,emptyText:l="No data yet."}=e,[n,o]=(0,r.useState)(null),d=i?t.slice(0,i):t,c=Math.max(1,...d.map(e=>e.value));return d&&0!==d.length?(0,a.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:d.map((e,t)=>{let r=e.value/c*100;return(0,a.jsxs)("div",{title:"".concat(e.label,": ").concat(s(e.value)),onMouseEnter:()=>o(t),onMouseLeave:()=>o(null),style:{display:"flex",alignItems:"center",gap:12},children:[(0,a.jsxs)("div",{style:{width:"34%",minWidth:0,display:"flex",flexDirection:"column"},children:[(0,a.jsx)("span",{style:{fontSize:14,color:x,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.label}),e.sublabel?(0,a.jsx)("span",{style:{fontSize:12,color:m,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.sublabel}):null]}),(0,a.jsx)("div",{style:{flex:1,height:16,background:"#f1f3f5",borderRadius:4,overflow:"hidden"},children:(0,a.jsx)("div",{style:{width:"".concat(r,"%"),height:"100%",background:v,borderRadius:4,opacity:null==n||n===t?1:.6,transition:"opacity 0.15s, width 0.3s ease"}})}),(0,a.jsx)("span",{style:{width:64,textAlign:"right",fontSize:14,fontWeight:600,color:x},children:s(e.value)})]},t)})}):(0,a.jsx)("p",{style:{color:m,fontSize:14,padding:"16px 4px"},children:l})}function w(e){let{label:t,value:s,formatValue:r=S,deltaPct:i=null}=e,l=null!=i&&isFinite(i),n=l&&i>=0,o=l?n?"#1a7f4b":"#c0392b":m;return(0,a.jsxs)("div",{style:{flex:"1 1 160px",minWidth:150,background:"#fff",border:"1px solid #e9ecef",borderRadius:8,padding:"16px 18px",boxShadow:"0 1px 2px rgba(0,0,0,0.04)"},children:[(0,a.jsx)("div",{style:{fontSize:13,color:g,marginBottom:6},children:t}),(0,a.jsx)("div",{style:{fontSize:28,fontWeight:700,color:x,lineHeight:1.1},children:r(s)}),l?(0,a.jsxs)("div",{style:{fontSize:12,color:o,marginTop:6,fontWeight:600},children:[n?"▲":"▼"," ",Math.abs(i).toFixed(0),"% vs prior month"]}):null]})}function k(e){let{height:t}=e;return(0,a.jsx)("div",{style:{height:t,display:"flex",alignItems:"center",justifyContent:"center",color:m,fontSize:14,background:"#fafbfc",border:"1px dashed ".concat(y),borderRadius:8},children:"No data for the selected range."})}let M={C:"Chevrolet / Cadillac",SWC:"Chevrolet / Cadillac",H:"Honda / Mazda",SWM:"Honda / Mazda",MB:"Mercedes-Benz",N:"Nissan",F:"CJDR (Chrysler Jeep Dodge Ram)",T:"Toyota"},L=e=>e?M[e]||e:"—",z={newVehicle:"New only",used:"Used only",location:"Location",make:"Make",model:"Model",year:"Year",trim:"Trim",trans:"Transmission",body:"Body style",fuel:"Fuel type",feature:"Feature",seats:"Seats",driveTrain:"Drivetrain",color:"Color",engine:"Engine",certified:"Certified",special:"Special / deal",fuelEfficient:"Fuel efficient",fiftyDaysOrOlder:"50+ days in stock",search:"Text search",minPrice:"Min price",maxPrice:"Max price",minMileage:"Min mileage",maxMileage:"Max mileage",minMPG:"Min MPG",maxMPG:"Max MPG",orderBy:"Sort order"},D=e=>z[e]||e,T={make:"Make",model:"Model",year:"Year",feature:"Feature",bodyStyle:"Body style",color:"Color",condition:"Condition",downPayment:"Down payment",monthlyPayment:"Monthly payment",monthsToPayOff:"Term (months)"},C="#1976d2",N="#1f2733",B="#5b6472",$={display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 420px), 1fr))"};class P extends r.Component{componentDidMount(){if(!this.state.user){window.location.href="/employee-portal";return}if(!(this.state.user.permissions||"").includes("Portal Admin")){window.location.href="/employee-portal/menu";return}this.fetchStats(),this.fetchLeadsList()}token(){return c().get(null).token}authHeaders(){return{"Content-Type":"application/json",Authorization:"Bearer "+this.token()}}buildFilterQuery(){let e=new URLSearchParams;return this.state.startDate&&e.set("startDate",this.state.startDate),this.state.endDate&&e.set("endDate",this.state.endDate),this.state.store&&e.set("store",this.state.store),this.state.source&&e.set("source",this.state.source),e.toString()}async fetchStats(){this.setState({statsLoading:!0,errorMessage:""});try{let e=new URLSearchParams(this.buildFilterQuery());e.set("groupBy",this.state.groupBy);let t=await fetch("/api/analytics/leads/stats?".concat(e.toString()),{headers:this.authHeaders()});if(!t.ok)throw Error("stats ".concat(t.status));let s=await t.json();this.setState({stats:s,statsLoading:!1})}catch(e){this.setState({statsLoading:!1,errorMessage:"Failed to load lead stats."})}}async fetchLeadsList(){this.setState({leadsLoading:!0});try{let e=new URLSearchParams(this.buildFilterQuery());e.set("page",String(this.state.leadsPage)),e.set("pageSize",String(this.state.leadsPageSize)),e.set("sortBy",this.state.leadsSortBy),e.set("sortDir",this.state.leadsSortDir),this.state.leadsSearch&&e.set("search",this.state.leadsSearch);let t=await fetch("/api/analytics/leads/list?".concat(e.toString()),{headers:this.authHeaders()});if(!t.ok)throw Error("list ".concat(t.status));let s=await t.json();this.setState({leads:s.rows||[],leadsTotal:s.total||0,leadsLoading:!1})}catch(e){this.setState({leadsLoading:!1,errorMessage:"Failed to load leads."})}}async fetchSearches(){this.setState({searchesLoading:!0});try{let e=await fetch("/api/analytics/searches?limit=1000",{headers:this.authHeaders()});if(!e.ok)throw Error("searches ".concat(e.status));let t=await e.json();this.setState({searchesTop:t.top||[],searchesLatest:t.latest||[],searchesLoaded:!0,searchesLoading:!1,topSearchesSh
1own:20,latestSearchesShown:20})}catch(e){this.setState({searchesLoading:!1,errorMessage:"Failed to load searches."})}}async exportLeadsCsv(){this.setState({exportingCsv:!0});try{let e=new URLSearchParams(this.buildFilterQuery());this.state.leadsSearch&&e.set("search",this.state.leadsSearch);let t=await fetch("/api/analytics/leads/export?".concat(e.toString()),{headers:this.authHeaders()});if(!t.ok)throw Error("export ".concat(t.status));let s=await t.blob(),a=URL.createObjectURL(s),r=document.createElement("a");r.href=a,r.download="leads-".concat(o()().format("YYYY-MM-DD"),".csv"),document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(a)}catch(e){this.setState({errorMessage:"Failed to export leads."})}finally{this.setState({exportingCsv:!1})}}async fetchPopularVehicles(){this.setState({popularLoading:!0});try{let e=await fetch("/api/analytics/popular-vehicles?limit=40",{headers:this.authHeaders()});if(!e.ok)throw Error("popular ".concat(e.status));let t=await e.json();this.setState({popularVehicles:t.vehicles||[],popularLoaded:!0,popularLoading:!1})}catch(e){this.setState({popularLoading:!1,errorMessage:"Failed to load popular vehicles."})}}async fetchFilters(){this.setState({filtersLoading:!0});try{let e=new URLSearchParams;e.set("groupBy",this.state.filtersGroupBy);let t=await fetch("/api/analytics/filters?".concat(e.toString()),{headers:this.authHeaders()});if(!t.ok)throw Error("filters ".concat(t.status));let s=await t.json();this.setState({filtersData:s,filtersLoaded:!0,filtersLoading:!1})}catch(e){this.setState({filtersLoading:!1,errorMessage:"Failed to load filter insights."})}}async fetchPreferences(){this.setState({preferencesLoading:!0});try{let e=await fetch("/api/analytics/preferences",{headers:this.authHeaders()});if(!e.ok)throw Error("preferences ".concat(e.status));let t=await e.json();this.setState({preferencesData:t,preferencesLoaded:!0,preferencesLoading:!1})}catch(e){this.setState({preferencesLoading:!1,errorMessage:"Failed to load preference insights."})}}onTabChange(e){this.setState({activeTab:e}),1!==e||this.state.searchesLoaded||this.fetchSearches(),2!==e||this.state.popularLoaded||this.fetchPopularVehicles(),3!==e||this.state.filtersLoaded||this.fetchFilters(),4!==e||this.state.preferencesLoaded||this.fetchPreferences()}applyFilters(){this.setState({leadsPage:1},()=>{this.fetchStats(),this.fetchLeadsList()})}changeSort(e){let t=this.state.leadsSortBy===e&&"DESC"===this.state.leadsSortDir?"ASC":"DESC";this.setState({leadsSortBy:e,leadsSortDir:t,leadsPage:1},()=>this.fetchLeadsList())}gotoPage(e){let t=Math.min(Math.max(1,Math.ceil(this.state.leadsTotal/this.state.leadsPageSize)),Math.max(1,this.state.leadsPage+e));t!==this.state.leadsPage&&this.setState({leadsPage:t},()=>this.fetchLeadsList())}parseAdditional(e){if(!e)return null;try{return"string"==typeof e?JSON.parse(e):e}catch(e){return null}}renderFilterBar(){var e;let t=(null==(e=this.state.stats)?void 0:e.buckets)||[],s={padding:"8px 10px",border:"1px solid #d5d9de",borderRadius:6,fontSize:14,background:"#fff"};return(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:12,alignItems:"flex-end",marginBottom:20},children:[(0,a.jsxs)("div",{className:"sw-flex sw-flex-col",children:[(0,a.jsx)("label",{style:{fontSize:12,color:B,marginBottom:4},children:"Start date"}),(0,a.jsx)("input",{type:"date",style:s,value:this.state.startDate,onChange:e=>this.setState({startDate:e.target.value})})]}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-col",children:[(0,a.jsx)("label",{style:{fontSize:12,color:B,marginBottom:4},children:"End date"}),(0,a.jsx)("input",{type:"date",style:s,value:this.state.endDate,onChange:e=>this.setState({endDate:e.target.value})})]}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-col",children:[(0,a.jsx)("label",{style:{fontSize:12,color:B,marginBottom:4},children:"Dealership"}),(0,a.jsxs)("select",{style:s,value:this.state.store,onChange:e=>this.setState({store:e.target.value}),children:[(0,a.jsx)("option",{value:"",children:"All dealerships"}),Object.keys(M).filter(e=>!["SWC","SWM"].includes(e)).map(e=>(0,a.jsx)("option",{value:e,children:M[e]},e))]})]}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-col",children:[(0,a.jsx)("label",{style:{fontSize:12,color:B,marginBottom:4},children:"Source"}
1),(0,a.jsxs)("select",{style:s,value:this.state.source,onChange:e=>this.setState({source:e.target.value}),children:[(0,a.jsx)("option",{value:"",children:"All sources"}),t.map(e=>(0,a.jsx)("option",{value:e.leadBucketId,children:e.leadBucketName},e.leadBucketId))]})]}),(0,a.jsx)("button",{style:{padding:"9px 18px",background:C,color:"#fff",border:"none",borderRadius:6,fontSize:14,height:38},onClick:()=>this.applyFilters(),children:"Apply"}),this.state.startDate||this.state.endDate||this.state.store||this.state.source?(0,a.jsx)("button",{style:{padding:"9px 14px",background:"#fff",color:B,border:"1px solid #d5d9de",borderRadius:6,fontSize:14,height:38},onClick:()=>this.setState({startDate:"",endDate:"",store:"",source:""},()=>this.applyFilters()),children:"Clear"}):null]})}renderLeadsTab(){var e,t,s,r;let{stats:i}=this.state,l=null==i?void 0:i.totals,n=l&&l.prevMonth>0?(l.month-l.prevMonth)/l.prevMonth*100:l&&l.month>0?100:null,o=((null==i?void 0:i.timeSeries)||[]).map(e=>({label:e.period,value:e.count}));return(0,a.jsxs)("div",{children:[this.renderFilterBar(),(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:14,marginBottom:24},children:[(0,a.jsx)(w,{label:"Total leads (all time)",value:null!=(e=null==l?void 0:l.all)?e:0}),(0,a.jsx)(w,{label:"Today",value:null!=(t=null==l?void 0:l.today)?t:0}),(0,a.jsx)(w,{label:"Last 7 days",value:null!=(s=null==l?void 0:l.week)?s:0}),(0,a.jsx)(w,{label:"This month",value:null!=(r=null==l?void 0:l.month)?r:0,deltaPct:n})]}),(0,a.jsxs)(F,{children:[(0,a.jsxs)("div",{className:"sw-flex",style:{justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[(0,a.jsx)("h3",{style:{margin:0,fontSize:18,color:N},children:"Leads over time"}),(0,a.jsx)("div",{className:"sw-flex",style:{gap:0,border:"1px solid #d5d9de",borderRadius:6,overflow:"hidden"},children:["day","week","month"].map(e=>(0,a.jsx)("button",{onClick:()=>this.setState({groupBy:e},()=>this.fetchStats()),style:{padding:"6px 14px",fontSize:13,border:"none",cursor:"pointer",background:this.state.groupBy===e?C:"#fff",color:this.state.groupBy===e?"#fff":B},children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),this.state.statsLoading?(0,a.jsx)(R,{}):(0,a.jsx)(b,{data:o,type:"day"===this.state.groupBy?"line":"bar"})]}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:20,marginTop:20},children:[(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h3",{style:{margin:"0 0 16px",fontSize:18,color:N},children:"Leads by source"}),(0,a.jsx)(j,{data:((null==i?void 0:i.bySource)||[]).map(e=>({label:e.leadBucketName||"Unknown",value:e.count})),maxRows:12})]})}),(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h3",{style:{margin:"0 0 16px",fontSize:18,color:N},children:"Leads by dealership"}),(0,a.jsx)(j,{data:((null==i?void 0:i.byStore)||[]).map(e=>({label:L(e.specialFieldThree),value:e.count})),maxRows:12})]})})]}),(0,a.jsxs)(F,{style:{marginTop:20},children:[(0,a.jsxs)("div",{className:"sw-flex",style:{justifyContent:"space-between",alignItems:"center",marginBottom:12,flexWrap:"wrap",gap:12},children:[(0,a.jsxs)("h3",{style:{margin:0,fontSize:18,color:N},children:["All leads (",this.state.leadsTotal.toLocaleString(),")"]}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{alignItems:"center",gap:10},children:[(0,a.jsxs)("div",{className:"sw-flex",style:{alignItems:"center",gap:6,border:"1px solid #d5d9de",borderRadius:6,padding:"4px 8px"},children:[(0,a.jsx)(u(),{path:f.U4M,size:.8,color:B}),(0,a.jsx)("input",{placeholder:"Search name, email, phone…",value:this.state.leadsSearch,onChange:e=>this.setState({leadsSearch:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&this.setState({leadsPage:1},()=>this.fetchLeadsList())},style:{border:"none",outline:"none",fontSize:14,width:220}})]}),(0,a.jsxs)("button",{onClick:()=>this.exportLeadsCsv(),disabled:this.state.exportingCsv||0===this.state.leadsTotal,title:"Download all leads matching the current filters as a CSV",className:"sw-flex sw-align-center",style:{gap:6,padding:"8px 14px",height:38,fontSize:14,borderRadius:6,border:"none",background:0===this.state.leadsTotal?"#c5cdd6":C,color:"#fff",cursor:this.state.exportingCsv||0===this.state.leadsTotal?"default":"pointer",opacity:this.state.exportingCsv?.8:1},children:[(0,a.jsx)(u(),{path:f.XCd,size:.8,color:"#fff"}),this.state.exportingCsv?"Exporting…":"Export CSV"]})]})]}),this.renderLeadsTable()]})]})}renderLeadsTable(){if(this.state.leadsLoading)return(0,a.jsx)(R,{});if(0===this.state.leads.length)return(0,a.jsx)("p",{style:{color:"#9aa2af",padding:"16px 0"},children:"No leads match your filters."});let e={textAlign:"left",padding:"10px 12px",fontSize:12,color:B,fontWeight:600,borderBottom:"2px s
1olid #eceef1",whiteSpace:"nowrap",cursor:"pointer",userSelect:"none"},t={padding:"10px 12px",fontSize:14,color:N,borderBottom:"1px solid #f1f3f5",whiteSpace:"nowrap"},s=e=>this.state.leadsSortBy===e?"ASC"===this.state.leadsSortDir?" ▲":" ▼":"",r=Math.max(1,Math.ceil(this.state.leadsTotal/this.state.leadsPageSize));return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{style:{overflowX:"auto"},children:(0,a.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:[{key:"leadBucketName",label:"Source",sortable:!0},{key:"created_at",label:"Date",sortable:!0},{key:"firstName",label:"Name",sortable:!0},{key:"phone",label:"Phone",sortable:!0},{key:"email",label:"Email",sortable:!0},{key:"vehicle",label:"Vehicle"},{key:"specialFieldThree",label:"Store",sortable:!0},{key:"leadStatus",label:"Status",sortable:!0}].map(t=>(0,a.jsxs)("th",{style:e,onClick:()=>t.sortable&&this.changeSort(t.key),children:[t.label,t.sortable?s(t.key):""]},t.key))})}),(0,a.jsx)("tbody",{children:this.state.leads.map((e,s)=>(0,a.jsxs)("tr",{onClick:()=>this.setState({selectedLead:e}),style:{cursor:"pointer"},onMouseEnter:e=>e.currentTarget.style.background="#f6f8fa",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,a.jsx)("td",{style:t,children:e.leadBucketName||"—"}),(0,a.jsx)("td",{style:t,children:e.created_at?o()(e.created_at).format("MMM D, YYYY h:mm A"):"—"}),(0,a.jsxs)("td",{style:t,children:[e.firstName," ",e.lastName]}),(0,a.jsx)("td",{style:t,children:e.phone||"—"}),(0,a.jsx)("td",{style:t,children:e.email||"—"}),(0,a.jsx)("td",{style:t,children:[e.year,e.make,e.model].filter(Boolean).join(" ")||"—"}),(0,a.jsx)("td",{style:t,children:L(e.specialFieldThree)}),(0,a.jsx)("td",{style:t,children:(0,a.jsx)(A,{status:e.leadStatus})})]},s))})]})}),(0,a.jsxs)("div",{className:"sw-flex",style:{justifyContent:"space-between",alignItems:"center",marginTop:14},children:[(0,a.jsxs)("span",{style:{fontSize:13,color:B},children:["Page ",this.state.leadsPage," of ",r]}),(0,a.jsxs)("div",{className:"sw-flex",style:{gap:8},children:[(0,a.jsx)(W,{disabled:this.state.leadsPage<=1,onClick:()=>this.gotoPage(-1),children:"Previous"}),(0,a.jsx)(W,{disabled:this.state.leadsPage>=r,onClick:()=>this.gotoPage(1),children:"Next"})]})]})]})}renderSearchesTab(){return this.state.searchesLoading?(0,a.jsx)(R,{}):(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:20},children:[(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h3",{style:{margin:"0 0 4px",fontSize:18,color:N},children:"Top searches"}),(0,a.jsx)("p",{style:{margin:"0 0 16px",fontSize:13,color:B},children:"Most-searched terms of all time (junk / stock numbers filtered out)"}),(0,a.jsx)(j,{data:this.state.searchesTop.map(e=>({label:e.term,value:e.count})),maxRows:this.state.topSearchesShown}),this.renderLoadMore(this.state.searchesTop.length,this.state.topSearchesShown,()=>this.setState({topSearchesShown:this.state.topSearchesShown+20}))]})}),(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h3",{style:{margin:"0 0 4px",fontSize:18,color:N},children:"Latest searches"}),(0,a.jsx)("p",{style:{margin:"0 0 16px",fontSize:13,color:B},children:"Most recently searched terms"}),(0,a.jsx)(j,{data:this.state.searchesLatest.map(e=>({label:e.term,value:e.count,sublabel:e.lastLogged?o()(e.lastLogged).format("MMM D, YYYY h:mm A"):"—"})),maxRows:this.state.latestSearchesShown}),this.renderLoadMore(this.state.searchesLatest.length,this.state.latestSearchesShown,()=>this.setState({latestSearchesShown:this.state.latestSearchesShown+20}))]})})]})}shownFor(e,t){var s;return null!=(s=this.state.sectionShown[e])?s:t}showMore(e,t,s){this.setState({sectionShown:{...this.state.sectionShown,[e]:this.shownFor(e,t)+s}})}renderLoadMore(e,t,s){if(t>=e)return null;let r=e-t;return(0,a.jsxs)("button",{onClick:s,style:{marginTop:14,width:"100%",padding:"9px 0",fontSize:14,fontWeight:600,borderRadius:6,border:"1px solid #d5d9de",background:"#fff",color:C,cursor:"pointer"}
1,children:["Load ",Math.min(20,r)," more (",r.toLocaleString()," left)"]})}renderPopularTab(){if(this.state.popularLoading)return(0,a.jsx)(R,{});let e=this.state.popularVehicles;return 0===e.length?(0,a.jsx)(F,{children:(0,a.jsx)("p",{style:{color:"#9aa2af",margin:0},children:"No vehicle view data is available right now."})}):(0,a.jsxs)(F,{children:[(0,a.jsx)("h3",{style:{margin:"0 0 4px",fontSize:18,color:N},children:"Most-visited vehicle pages"}),(0,a.jsx)("p",{style:{margin:"0 0 20px",fontSize:13,color:B},children:"Ranked by total VDP views. Stock numbers no longer in inventory show the count only."}),(0,a.jsx)("div",{className:"sw-flex sw-flex-col",style:{gap:12},children:e.map((t,s)=>{let r=Math.max(1,...e.map(e=>e.totalViews)),i=t.totalViews/r*100,l=[t.year,t.make,t.model].filter(Boolean).join(" ")||"Stock #".concat(t.stockNumber);return(0,a.jsxs)("div",{className:"sw-flex",style:{alignItems:"center",gap:14,padding:"8px 0",borderBottom:"1px solid #f1f3f5"},children:[(0,a.jsx)("span",{style:{width:26,textAlign:"right",color:"#9aa2af",fontSize:14,fontWeight:600},children:s+1}),(0,a.jsx)("div",{style:{width:72,height:54,borderRadius:6,flexShrink:0,background:"#eef1f4",backgroundImage:t.photo?"url(".concat(t.photo,")"):void 0,backgroundSize:"cover",backgroundPosition:"center",display:"flex",alignItems:"center",justifyContent:"center"},children:t.photo?null:(0,a.jsx)(u(),{path:f.BrZ,size:1,color:"#c2c8d0"})}),(0,a.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,a.jsx)("div",{style:{fontSize:15,fontWeight:600,color:N,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l}),(0,a.jsxs)("div",{style:{fontSize:12,color:B},children:["Stock #",t.stockNumber," \xb7 ",L(t.store),t.inInventory?"":" \xb7 sold/removed"]}),(0,a.jsx)("div",{style:{height:6,background:"#f1f3f5",borderRadius:3,marginTop:6,overflow:"hidden"},children:(0,a.jsx)("div",{style:{width:"".concat(i,"%"),height:"100%",background:C,borderRadius:3}})})]}),(0,a.jsxs)("div",{style:{textAlign:"right",minWidth:80},children:[(0,a.jsx)("div",{style:{fontSize:18,fontWeight:700,color:N},children:t.totalViews.toLocaleString()}),(0,a.jsx)("div",{style:{fontSize:11,color:"#9aa2af"},children:"views"})]})]},s)})})]})}renderFiltersTab(){var e,t,s,r;if(this.state.filtersLoading&&!this.state.filtersData)return(0,a.jsx)(R,{});let i=this.state.filtersData,l=null==i?void 0:i.totals,n=((null==i?void 0:i.timeSeries)||[]).map(e=>({label:e.period,value:e.count})),d=(e,t)=>{var s;return(0,a.jsx)("div",{style:{flex:"1 1 240px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:e}),(0,a.jsx)(j,{data:((null==i||null==(s=i.topValues)?void 0:s[t])||[]).map(e=>({label:e.value,value:e.count})),maxRows:10,emptyText:"No data yet."})]})})};return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:14,marginBottom:24},children:[(0,a.jsx)(w,{label:"Filter sessions (all time)",value:null!=(e=null==l?void 0:l.all)?e:0}),(0,a.jsx)(w,{label:"Today",value:null!=(t=null==l?void 0:l.today)?t:0}),(0,a.jsx)(w,{label:"Zero-result sessions",value:null!=(s=null==l?void 0:l.zeroResults)?s:0}),(0,a.jsx)(w,{label:"Avg results per session",value:null!=(r=null==l?void 0:l.avgResults)?r:0})]}),(0,a.jsxs)(F,{children:[(0,a.jsxs)("div",{className:"sw-flex",style:{justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[(0,a.jsx)("h3",{style:{margin:0,fontSize:18,color:N},children:"Filter activity over time"}),(0,a.jsx)("div",{className:"sw-flex",style:{border:"1px solid #d5d9de",borderRadius:6,overflow:"hidden"},children:["day","week","month"].map(e=>(0,a.jsx)("button",{onClick:()=>this.setState({filtersGroupBy:e},()=>this.fetchFilters()),style:{padding:"6px 14px",fontSize:13,border:"none",cursor:"pointer",background:this.state.filtersGroupBy===e?C:"#fff",color:this.state.filtersGroupBy===e?"#fff":B},children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),this.state.filtersLoading?(0,a.jsx)(R,{}):(0,a.jsx)(b,{data:n,type:"day"===this.state.filtersGroupBy?"line":"bar"})]}),(0,a.jsx)("h3",{style:{fontSize:18,color:N,margin:"26px 0 14px"},children:"What shoppers filter for"}),(0,a.jsxs)("div",{style:$,children:[d("Top makes","make"),d("Top models","model"),d("Top body styles","body"),d("Top colors","color"),d("Top years","year"),d("Top drivetrains","driveTrain"),d("Top fuel types","fuel"),(0,a.jsx)("div",{children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:"Most-used filters"}),(0,a.jsx)(j,{data:((null==i?void 0:i.dimensionUsage)||[]).map(e=>({label:D(e.dimension),value:e.count})),maxRows:10})]})})]}),(0,a.jsx)("h3",{style:{fontSize:18,color:N,margin:"26px 0 4px"},children:"Demand vs. supply"}),(0,a.jsxs)("p",{style:{margin:"0 0 14px",fontSize:13,color:B},children:["Each value's ",(0,a.jsx)("b",{children:"share of filter demand"})," vs. its ",(0,a.jsx)("b",{children:"share of current inventory"}),'. "Under-stocked" = a bigger slice of demand than of stock; "Overstocked" = the reverse.']}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:16},children:[(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:"By make"}),this.renderGapDim(null==i?void 0:i.makeGap,"sessions","f-make")]})}),(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:"By model"}),this.renderGapDim(null==i?void 0:i.modelGap,"sessions","f-model")]})})]}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:16,marginTop:16},children:[(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:"By body style"}),this.renderGapDim(null==i?void 0:i.bodyGap,"sessions","f-body")]})}),(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:"By color"}),this.renderGapDim(null==i?void 0:i.colorGap,"sessions","f-color")]})})]}),(0,a.jsxs)(F,{style:{marginTop:26},children:[(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{justifyContent:"space-between",alignItems:"center",gap:12,marginBottom:4},children:[(0,a.jsx)("h3",{style:{margin:0,fontSize:18,color:N},children:"Most-used filter combinations"}),(0,a.jsx)("div",{className:"sw-flex",style:{border:"1px solid #d5d9de",borderRadius:6,overflow:"hidden"},children:[["count","Most used"],["recent","Most recent"]].map(e=>{let[t,s]=e;return(0,a.jsx)("button",{onClick:()=>this.setState({combosSort:t}),style:{padding:"6px 14px",fontSize:13,border:"none",cursor:"pointer",background:this.state.combosSort===t?C:"#fff",color:this.state.combosSort===t?"#fff":B},children:s},t)})})]}),(0,a.jsx)("p",{style:{margin:"0 0 16px",fontSize:13,color:B},children:"Complete filter sets shoppers apply together, with how many times each was used and when it was last used."}),this.renderCombinations()]}),(0,a.jsxs)(F,{style:{marginTop:26},children:[(0,a.jsx)("h3",{style:{margin:"0 0 4px",fontSize:18,color:N}
1,children:"Filter combinations with no results"}),(0,a.jsx)("p",{style:{margin:"0 0 16px",fontSize:13,color:B},children:"What shoppers searched for and found nothing — potential inventory gaps."}),0===((null==i?void 0:i.zeroResultCombos)||[]).length?(0,a.jsx)("p",{style:{color:"#9aa2af",fontSize:14,margin:0},children:"No zero-result filter sessions in this window."}):(0,a.jsx)("div",{className:"sw-flex sw-flex-col",style:{gap:10},children:((null==i?void 0:i.zeroResultCombos)||[]).map((e,t)=>(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{alignItems:"center",gap:8,padding:"10px 0",borderBottom:"1px solid #f1f3f5"},children:[(0,a.jsx)("span",{style:{fontSize:12,color:"#9aa2af",minWidth:130},children:e.loggedAt?o()(e.loggedAt).format("MMM D, YYYY h:mm A"):"—"}),(0,a.jsx)("div",{className:"sw-flex sw-flex-wrap",style:{gap:6},children:e.filters?this.renderFilterChips(e.filters):(0,a.jsx)("span",{style:{color:"#9aa2af",fontSize:13},children:"—"})})]},t))})]})]})}renderCombinations(){var e;let t=[...(null==(e=this.state.filtersData)?void 0:e.combinations)||[]];if(0===t.length)return(0,a.jsx)("p",{style:{color:"#9aa2af",fontSize:14,margin:0},children:"No filter combinations recorded in this window."});"recent"===this.state.combosSort?t.sort((e,t)=>new Date(t.lastUsed).getTime()-new Date(e.lastUsed).getTime()):t.sort((e,t)=>t.count-e.count);let s=this.shownFor("combos",20),r=t.slice(0,s);return(0,a.jsxs)("div",{className:"sw-flex sw-flex-col",style:{gap:10},children:[r.map((e,t)=>(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{alignItems:"center",gap:10,padding:"10px 0",borderBottom:"1px solid #f1f3f5"},children:[(0,a.jsxs)("span",{style:{minWidth:44,textAlign:"center",background:"#e8f1fd",color:"#1565c0",borderRadius:12,padding:"3px 10px",fontSize:13,fontWeight:700},children:["\xd7",e.count.toLocaleString()]}),(0,a.jsx)("div",{className:"sw-flex sw-flex-wrap",style:{gap:6,flex:1,minWidth:200},children:this.renderFilterChips(e.filters)}),(0,a.jsxs)("span",{style:{fontSize:12,color:B,whiteSpace:"nowrap"},children:[e.avgResults.toLocaleString()," avg results"]}),(0,a.jsxs)("span",{style:{fontSize:12,color:"#9aa2af",whiteSpace:"nowrap",minWidth:150,textAlign:"right"},children:["last used ",e.lastUsed?o()(e.lastUsed).format("MMM D, YYYY h:mm A"):"—"]})]},t)),this.renderLoadMore(t.length,s,()=>this.showMore("combos",20,20))]})}renderFilterChips(e){return Object.entries(e).map(e=>{let t,[s,r]=e;return t=!0===r?D(s):Array.isArray(r)?"".concat(D(s),": ").concat(r.join(", ")):"".concat(D(s),": ").concat(r),(0,a.jsx)("span",{style:{background:"#eef2f6",color:N,borderRadius:12,padding:"3px 10px",fontSize:12,whiteSpace:"nowrap"},children:t},s)})}renderPreferencesTab(){var e;if(this.state.preferencesLoading&&!this.state.preferencesData)return(0,a.jsx)(R,{});let t=this.state.preferencesData,s=null!=(e=null==t?void 0:t.totalUsers)?e:0,r=e=>{var s,a;return null!=(a=null==t||null==(s=t.adoption.find(t=>t.field===e))?void 0:s.count)?a:0},i=(e,t,s)=>(0,a.jsx)("div",{style:{flex:"1 1 240px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:e}),(0,a.jsx)(j,{data:((null==s?void 0:s[t])||[]).map(e=>({label:e.value,value:e.count})),maxRows:10,emptyText:"No saved values yet."})]})});return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:14,marginBottom:24},children:[(0,a.jsx)(w,{label:"Users with saved preferences",value:s}),(0,a.jsx)(w,{label:"Set a preferred make",value:r("make")}),(0,a.jsx)(w,{label:"Set a budget (monthly)",value:r("monthlyPayment")}),(0,a.jsx)(w,{label:"Set a condition",value:r("condition")})]}),(null==t?void 0:t.coverage)?this.renderCoverage(t.coverage):null,(0,a.jsx)("h3",{style:{fontSize:18,color:N,margin:"0 0 14px"},children:"Most-saved preferences"}),(0,a.jsxs)("div",{style:$,children:[i("Top makes","make",null==t?void 0:t.topValues),i("Top models","model",null==t?void 0:t.topValues),i("Top body styles","bodyStyle",null==t?void 0:t.topValues),i("Top colors","color",null==t?void 0:t.topValues),i("Top years","year",null==t?void 0:t.topValues),i("Top features","feature",null==t?void 0:t.topValues),i("Condition","condition",null==t?void 0:t.topValues),(0,a.jsx)("div",{children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 4px",fontSize:15,color:N},children:"Preference completion"}),(0,a.jsx)("p",{style:{margin:"0 0 12px",fontSize:12,color:B},children:"How many users fill in each field"}),(0,a.jsx)(j,{data:((null==t?void 0:t.adoption)||[]).map(e=>{let t;return{label:T[t=e.field]||t,value:e.count,sublabel:s>0?"".concat(Math.round(e.count/s*100),"% of users"):void 0}}),maxRows:10})]})})]}),(0,a.jsx)("h3",{style:{fontSize:18,color:N,margin:"26px 0 4px"},children:"Demand vs. supply"}),(0,a.jsxs)("p",{style:{margin:"0 0 14px",fontSize:13,color:B},children:["Each value's ",(0,a.jsx)("b",{children:"share of saved preferences"})," vs. its ",(0,a.jsx)("b",{children:"share of current inventory"}),'. "Under-stocked" = a bigger slice of demand than of stock; "Overstocked" = the reverse.']}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:16},children:[(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:"By make"}),this.renderGapDim(null==t?void 0:t.makeGap,"users","p-make")]})}),(0,a.jsx)("div",{style:{flex:"1 1 340px"},children:(0,a.jsxs)(F,{children:[(0,a.jsx)("h4",{style:{margin:"0 0 14px",fontSize:15,color:N},children:"By model"}),this.renderGapDim(null==t?void 0:t.modelGap,"users","p-model")]})})]}),(0,a.jsx)("h3",{style:{fontSize:18,color:N,margin:"26px 0 14px"},children:"Budget preferences"}),(0,a.jsxs)("div",{className:"sw-flex sw-flex-wrap",style:{gap:16},children:[i("Monthly payment","monthlyPayment",null==t?void 0:t.budget),i("Down payment","downPayment",null==t?void 0:t.budget),i("Term (months to pay off)","monthsToPayOff",null==t?void 0:t.budget)]})]})}renderCoverage(e){let t=e.coveragePct,s=t>=80?"#1a7f4b":t>=50?"#b26a00":"#c0392b";return(0,a.jsxs)(F,{style:{marginBottom:24},children:[(0,a.jsx)("h3",{style:{margin:"0 0 4px",fontSize:18,color:N},children:"Recommendation coverage"}),(0,a.jsxs)("p",{style:{margin:"0 0 14px",fontSize:13,color:B}
1,children:["Of the ",e.evaluableUsers.toLocaleString()," users who saved a make or model, how many have at least one matching vehicle in stock right now."]}),(0,a.jsxs)("div",{className:"sw-flex",style:{alignItems:"center",gap:16,flexWrap:"wrap"},children:[(0,a.jsxs)("div",{style:{fontSize:34,fontWeight:700,color:s,minWidth:90},children:[t,"%"]}),(0,a.jsxs)("div",{style:{flex:1,minWidth:220},children:[(0,a.jsx)("div",{style:{height:14,background:"#f1f3f5",borderRadius:7,overflow:"hidden"},children:(0,a.jsx)("div",{style:{width:"".concat(t,"%"),height:"100%",background:s,borderRadius:7}})}),(0,a.jsxs)("div",{className:"sw-flex",style:{justifyContent:"space-between",marginTop:8,fontSize:13,color:B},children:[(0,a.jsxs)("span",{children:[(0,a.jsx)("b",{style:{color:"#1a7f4b"},children:e.coveredUsers.toLocaleString()})," covered"]}),(0,a.jsxs)("span",{children:[(0,a.jsx)("b",{style:{color:"#c0392b"},children:e.uncoveredUsers.toLocaleString()})," with nothing in stock"]})]})]})]})]})}renderGapDim(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"sessions",s=arguments.length>2?arguments[2]:void 0,r=(null==e?void 0:e.rows)||[];if(0===r.length)return(0,a.jsx)("p",{style:{color:"#9aa2af",fontSize:14,margin:0},children:"No data yet."});let i=(null==e?void 0:e.totalDemand)||0,l=(null==e?void 0:e.totalSupply)||0,n=r.map(e=>({...e,demandShare:i>0?e.demand/i:0,supplyShare:l>0?e.supply/l:0})),o=Math.max(1e-4,...n.flatMap(e=>[e.demandShare,e.supplyShare])),d=s?this.shownFor(s,6):n.length,c=n.slice(0,d);return(0,a.jsxs)("div",{className:"sw-flex sw-flex-col",style:{gap:14},children:[c.map((e,s)=>{let r=0===e.supply&&e.demand>0?{text:"None in stock",bg:"#fdecea",fg:"#c0392b"}:e.demandShare>=1.5*e.supplyShare?{text:"Under-stocked",bg:"#fff4e0",fg:"#b26a00"}:e.supplyShare>=1.5*e.demandShare?{text:"Overstocked",bg:"#eef2f6",fg:"#5b6472"}:null;return(0,a.jsxs)("div",{className:"sw-flex sw-flex-col",style:{gap:5,paddingBottom:12,borderBottom:"1px solid #f1f3f5"},children:[(0,a.jsxs)("div",{className:"sw-flex",style:{justifyContent:"space-between",alignItems:"center",gap:8},children:[(0,a.jsx)("span",{style:{fontSize:14,fontWeight:600,color:N,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.value}),r?(0,a.jsx)("span",{style:{background:r.bg,color:r.fg,borderRadius:12,padding:"2px 8px",fontSize:11,fontWeight:600,whiteSpace:"nowrap"},children:r.text}):null]}),this.gapBar("Demand",e.demandShare,o,"".concat((100*e.demandShare).toFixed(0),"% \xb7 ").concat(e.demand.toLocaleString()," ").concat(t),C),this.gapBar("In stock",e.supplyShare,o,"".concat((100*e.supplyShare).toFixed(0),"% \xb7 ").concat(e.supply.toLocaleString()," vehicles"),"#9aa2af")]},s)}),s?this.renderLoadMore(n.length,d,()=>this.showMore(s,6,6)):null]})}gapBar(e,t,s,r,i){return(0,a.jsxs)("div",{className:"sw-flex",style:{alignItems:"center",gap:8},children:[(0,a.jsx)("span",{style:{width:58,fontSize:11,color:B,flexShrink:0},children:e}),(0,a.jsx)("div",{style:{flex:1,height:12,background:"#f1f3f5",borderRadius:3,overflow:"hidden"},children:(0,a.jsx)("div",{style:{width:"".concat(Math.min(100,t/s*100),"%"),height:"100%",background:i,borderRadius:3}})}),(0,a.jsx)("span",{style:{width:160,textAlign:"right",fontSize:12,color:B,whiteSpace:"nowrap",flexShrink:0},children:r})]})}renderLeadModal(){let e=this.state.selectedLead;if(!e)return null;let t=this.parseAdditional(e.additionalFormData),s={display:"flex",justifyContent:"space-between",gap:16,padding:"8px 0",borderBottom:"1px solid #f1f3f5"},r={fontSize:13,color:B},i={fontSize:14,color:N,fontWeight:500,textAlign:"right",wordBreak:"break-word"},l=(e,t)=>(0,a.jsxs)("div",{style:s,children:[(0,a.jsx)("span",{style:r,children:e}),(0,a.jsx)("span",{style:i,children:null!=t&&""!==t?String(t):"—"})]});return(0,a.jsxs)(p.A,{BGClose:!0,render:!!this.state.selectedLead,callBack:e=>{e||this.setState({selectedLead:null})},className:"sw-container sw-p-0",style:{borderRadius:8,maxWidth:560},children:[(0,a.jsxs)("div",{style:{background:C,padding:"18px 22px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,a.jsxs)("span",{className:"sw--white",style:{fontSize:22,fontWeight:600},children:[e.firstName," ",e.lastName]}),(0,a.jsx)("span",{style:{cursor:"pointer",display:"inline-flex"},onClick:()=>this.setState({selectedLead:null}),children:(0,a.jsx)(u(),{path:f.hyP,size:1,color:"#fff"})})]}),(0,a.jsxs)("div",{style:{padding:"18px 22px",background:"#fff",maxHeight:"70vh",overflowY:"auto"},children:[l("Submitted",e.created_at?o()(e.created_at).format("MMM D, YYYY h:mm A"):"—"),l("Status",e.leadStatus),l("Source",e.leadBucketName),l("Dealership",L(e.specialFieldThree)),l("Phone",e.phone),l("Email",e.email),l("Vehicle",[e.year,e.make,e.model].filter(
1Boolean).join(" ")),l("VIN",e.VIN),l("Stock #",e.stockNumber),l("New/Used",e.nu),l("Original price",e.originalPrice?"$".concat(Number(e.originalPrice).toLocaleString()):""),l("Offer / alert price",e.priceAlert?"$".concat(Number(e.priceAlert).toLocaleString()):""),t&&Object.keys(t).length>0?(0,a.jsxs)("div",{style:{marginTop:16},children:[(0,a.jsx)("div",{style:{fontSize:13,fontWeight:700,color:B,marginBottom:6},children:"Additional form data"}),Object.entries(t).map(e=>{let[t,s]=e;return l(t,"object"==typeof s?JSON.stringify(s):s)})]}):null,(0,a.jsx)("button",{style:{marginTop:18,padding:"9px 18px",background:"#fff",color:N,border:"1px solid #d5d9de",borderRadius:6,fontSize:14},onClick:()=>this.setState({selectedLead:null}),children:"Close"})]})]})}render(){var e;return(0,a.jsxs)("div",{style:{fontFamily:"Roboto, sans-serif",letterSpacing:"0.0125em",background:"#f4f6f8",minHeight:"100vh"},children:[(0,a.jsx)(l(),{children:(0,a.jsx)("title",{children:"Site Analytics"})}),(0,a.jsx)("div",{style:{width:"100%",height:120},className:"background sw-flex sw-justify-center sw-align-center",children:(0,a.jsxs)("div",{className:"sw-flex sw-align-center",style:{gap:12},children:[(0,a.jsx)(u(),{path:f.bWS,size:1.4,color:"#fff"}),(0,a.jsx)("h1",{className:"sw--white sw--center",style:{margin:0},children:"Site Analytics"})]})}),(0,a.jsxs)("div",{className:"sw-container",style:{maxWidth:1100,margin:"0 auto",padding:"24px 16px 120px"},children:[(0,a.jsxs)("div",{className:"sw-flex",style:{justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[(0,a.jsxs)("span",{style:{fontSize:15,color:B},children:["Welcome, ",null==(e=this.state.user)?void 0:e.firstName,". Portal Admin analytics."]}),(0,a.jsx)("a",{href:"/employee-portal/menu",style:{color:C,textDecoration:"none",fontSize:14},children:"← Back to menu"})]}),(0,a.jsx)("div",{className:"sw-flex",style:{borderBottom:"2px solid #e3e7eb",marginBottom:24},children:["Leads","Searches","Popular Vehicles","Filters","Preferences"].map((e,t)=>(0,a.jsx)("button",{onClick:()=>this.onTabChange(t),style:{padding:"12px 22px",border:"none",background:"transparent",cursor:"pointer",fontSize:15,fontWeight:600,color:this.state.activeTab===t?C:B,borderBottom:this.state.activeTab===t?"3px solid ".concat(C):"3px solid transparent",marginBottom:-2},children:e},e))}),this.state.errorMessage?(0,a.jsx)("div",{style:{background:"#fdecea",color:"#c0392b",padding:"10px 14px",borderRadius:6,marginBottom:16,fontSize:14},children:this.state.errorMessage}):null,0===this.state.activeTab?this.renderLeadsTab():null,1===this.state.activeTab?this.renderSearchesTab():null,2===this.state.activeTab?this.renderPopularTab():null,3===this.state.activeTab?this.renderFiltersTab():null,4===this.state.activeTab?this.renderPreferencesTab():null]}),this.renderLeadModal()]})}constructor(e){super(e),this.state={user:this.props.user?this.props.user:null,activeTab:0,groupBy:"day",startDate:"",endDate:"",store:"",source:"",stats:null,statsLoading:!1,leads:[],leadsTotal:0,leadsPage:1,leadsPageSize:25,leadsSearch:"",leadsSortBy:"created_at",leadsSortDir:"DESC",leadsLoading:!1,exportingCsv:!1,selectedLead:null,searchesTop:[],searchesLatest:[],searchesLoaded:!1,searchesLoading:!1,topSearchesShown:20,latestSearchesShown:20,popularVehicles:[],popularLoaded:!1,popularLoading:!1,filtersData:null,filtersLoaded:!1,filtersLoading:!1,filtersGroupBy:"day",combosSort:"count",sectionShown:{},preferencesData:null,preferencesLoaded:!1,preferencesLoading:!1,errorMessage:""}}}function F(e){let{children:t,style:s}=e;return(0,a.jsx)("div",{style:{background:"#fff",border:"1px solid #e9ecef",borderRadius:10,padding:20,boxShadow:"0 1px 2px rgba(0,0,0,0.04)",...s},children:t})}function R(){return(0,a.jsx)("div",{style:{padding:40,textAlign:"center",color:"#9aa2af",fontSize:14},children:"Loading…"})}function W(e){let{children:t,disabled:s,onClick:r}=e;return(0,a.jsx)("button",{disabled:s,onClick:r,style:{padding:"7px 16px",fontSize:14,borderRadius:6,border:"1px solid #d5d9de",background:s?"#f4f6f8":"#fff",color:s?"#b5bcc5":N,cursor:s?"default":"pointer"},children:t})}function A(e){let{status:t}=e,s={new:{bg:"#e8f1fd",fg:"#1565c0"}
vendor: 7,244 bytes, line 1
1,contacted:{bg:"#fff4e0",fg:"#b26a00"},working:{bg:"#ede7f6",fg:"#5e35b1"},sold:{bg:"#e6f4ea",fg:"#1a7f4b"},lost:{bg:"#fdecea",fg:"#c0392b"}}[(t||"New").toLowerCase()]||{bg:"#eceef1",fg:"#5b6472"};return(0,a.jsx)("span",{style:{background:s.bg,color:s.fg,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:600},children:t||"New"})}var O=!0;let Y=P},51004:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/employee-portal/Analytics",function(){return s(49742)}])},56557:function(e){e.exports=function(){"use strict";var e="millisecond",t="second",s="minute",a="hour",r="week",i="month",l="quarter",n="year",o="date",d="Invalid Date",c=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,u=function(e,t,s){var a=String(e);return!a||a.length>=t?e:""+Array(t+1-a.length).join(s)+e},f="en",p={};p[f]={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],s=e%100;return"["+e+(t[(s-20)%10]||t[s]||t[0])+"]"}};var x="$isDayjsObject",g=function(e){return e instanceof S||!(!e||!e[x])},m=function e(t,s,a){var r;if(!t)return f;if("string"==typeof t){var i=t.toLowerCase();p[i]&&(r=i),s&&(p[i]=s,r=i);var l=t.split("-");if(!r&&l.length>1)return e(l[0])}else{var n=t.name;p[n]=t,r=n}return!a&&r&&(f=r),r||!a&&f},y=function(e,t){if(g(e))return e.clone();var s="object"==typeof t?t:{};return s.date=e,s.args=arguments,new S(s)},v={s:u,z:function(e){var t=-e.utcOffset(),s=Math.abs(t);return(t<=0?"+":"-")+u(Math.floor(s/60),2,"0")+":"+u(s%60,2,"0")},m:function e(t,s){if(t.date()<s.date())return-e(s,t);var a=12*(s.year()-t.year())+(s.month()-t.month()),r=t.clone().add(a,i),l=s-r<0,n=t.clone().add(a+(l?-1:1),i);return+(-(a+(s-r)/(l?r-n:n-r))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(d){return({M:i,y:n,w:r,d:"day",D:o,h:a,m:s,s:t,ms:e,Q:l})[d]||String(d||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}};v.l=m,v.i=g,v.w=function(e,t){return y(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var S=function(){function u(e){this.$L=m(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var f=u.prototype;return f.parse=function(e){this.$d=function(e){var t=e.date,s=e.utc;if(null===t)return new Date(NaN);if(v.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var a=t.match(c);if(a){var r=a[2]-1||0,i=(a[7]||"0").substring(0,3);return s?new Date(Date.UTC(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,i)):new Date(a[1],r,a[3]||1,a[4]||0,a[5]||0,a[6]||0,i)}}return new Date(t)}(e),this.init()},f.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},f.$utils=function(){return v},f.isValid=function(){return this.$d.toString()!==d},f.isSame=function(e,t){var s=y(e);return this.startOf(t)<=s&&s<=this.endOf(t)},f.isAfter=function(e,t){return y(e)<this.startOf(t)},f.isBefore=function(e,t){return this.endOf(t)<y(e)},f.$g=function(e,t,s){return v.u(e)?this[t]:this.set(s,e)},f.unix=function(){return Math.floor(this.valueOf()/1e3)},f.valueOf=function(){return this.$d.getTime()},f.startOf=function(e,l){var d=this,c=!!v.u(l)||l,h=v.p(e),u=function(e,t){var s=v.w(d.$u?Date.UTC(d.$y,t,e):new Date(d.$y,t,e),d);return c?s:s.endOf("day")},f=function(e,t){return v.w(d.toDate()[e].apply(d.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(t)),d)},p=this.$W,x=this.$M,g=this.$D,m="set"+(this.$u?"UTC":"");switch(h){case n:return c?u(1,0):u(31,11);case i:return c?u(1,x):u(0,x+1);case r:var y=this.$locale().weekStart||0,S=(p<y?p+7:p)-y;return u(c?g-S:g+(6-S),x);case"day":case o:return f(m+"Hours",0);case a:return f(m+"Minutes",1);case s:return f(m+"Seconds",2);case t:return f(m+"Milliseconds",3);default:return this.clone()}},f.endOf=function(e){return this.startOf(e,!1)},f.$set=function(r,l){var d,c=v.p(r),h="set"+(this.$u?"UTC":""),u=((d={}).day=h+"Date",d[o]=h+"Date",d[i]=h+"Month",d[n]=h+"FullYear",d[a]=h+"Hours",d[s]=h+"Minutes",d[t]=h+"Seconds",d[e]=h+"Milliseconds",d)[c],f="day"===c?this.$D+(l-this.$W):l;if(c===i||c===n){var p=this.clone().set(o,1);p.$d[u](f),p.init(),this.$d=p.set(o,Math.min(this.$D,p.daysInMonth())).$d}else u&&this.$d[u](f);return this.init(),this},f.set=function(e,t){return this.clone().$set(e,t)},f.get=function(e){return this[v.p(e)]()},f.add=function(e,l){var o,d=this;e=Number(e);var c=v.p(l),h=function(t){var s=y(d);return v.w(s.date(s.date()+Math.round(t*e)),d)};if(c===i)return this.set(i,this.$M+e);if(c===n)return this.set(n,this.$y+e);if("day"===c)return h(1);if(c===r)return h(7);var u=((o={})[s]=6e4,o[a]=36e5,o[t]=1e3,o)[c]||1,f=this.$d.getTime()+e*u;return v.w(f,this)},f.subtract=function(e,t){return this.add(-1*e,t)},f.format=function(e){var t=this,s=this.$locale();if(!this.isValid())return s.invalidDate||d;var a=e||"YYYY-MM-DDTHH:mm:ssZ",r=v.z(this),i=this.$H,l=this.$m,n=this.$M,o=s.weekdays,c=s.months,u=s.meridiem,f=function(e,s,r,i){return e&&(e[s]||e(t,a))||r[s].slice(0,i)},p=function(e){return v.s(i%12||12,e,"0")},x=u||function(e,t,s){var a=e<12?"AM":"PM";return s?a.toLowerCase():a};return a.replace(h,function(e,a){return a||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return v.s(t.$y,4,"0");case"M":return n+1;case"MM":return v.s(n+1,2,"0");case"MMM":return f(s.monthsShort,n,c,3);case"MMMM":return f(c,n);case"D":return t.$D;case"DD":return v.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return f(s.weekdaysMin,t.$W,o,2);case"ddd":return f(s.weekdaysShort,t.$W,o,3);case"dddd":return o[t.$W];case"H":return String(i);case"HH":return v.s(i,2,"0");case"h":return p(1);case"hh":return p(2);case"a":return x(i,l,!0);case"A":return x(i,l,!1);case"m":return String(l);case"mm":return v.s(l,2,"0");case"s":return String(t.$s);case"ss":return v.s(t.$s,2,"0");case"SSS":return v.s(t.$ms,3,"0");case"Z":return r}return null}(e)||r.replace(":","")})},f.utcOffset=function(){return-(15*Math.round(this.$d.getTimezoneOffset()/15))},f.diff=function(e,o,d){var c,h=this,u=v.p(o),f=y(e),p=(f.utcOffset()-this.utcOffset())*6e4,x=this-f,g=function(){return v.m(h,f)};switch(u){case n:c=g()/12;break;case i:c=g();break;case l:c=g()/3;break;case r:c=(x-p)/6048e5;break;case"day":c=(x-p)/864e5;break;case a:c=x/36e5;break;case s:c=x/6e4;break;case t:c=x/1e3;break;default:c=x}return d?c:v.a(c)},f.daysInMonth=function(){return this.endOf(i).$D},f.$locale=function(){return p[this.$L]},f.locale=function(e,t){if(!e)return this.$L;var s=this.clone(),a=m(e,t,!0);return a&&(s.$L=a),s},f.clone=function(){return v.w(this.$d,this)},f.toDate=function(){return new Date(this.valueOf())},f.toJSON=function(){return this.isValid()?this.toISOString():null},f.toISOString=function(){return this.$d.toISOString()},f.toString=function(){return this.$d.toUTCString()},u}(),b=S.prototype;return y.prototype=b,[["$ms",e],["$s",t],["$m",s],["$H",a],["$W","day"],["$M",i],["$y",n],["$D",o]].forEac
1h(function(e){b[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),y.extend=function(e,t){return e.$i||(e(t,S,y),e.$i=!0),y},y.locale=m,y.isDayjs=g,y.unix=function(e){return y(1e3*e)},y.en=p[f],y.Ls=p,y.p={},y}()},77328:(e,t,s)=>{e.exports=s(29269)}},e=>{e.O(0,[636,6593,8792],()=>e(e.s=51004)),_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.