PageSourceSearch

https://rerere.ai/_next/static/chunks/2684.6a26b242ccef853f.js

js rerere.ai collected 2026-10-05 12:32:01 UTC 31,935 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2684],{20063:(e,t,s)=>{"use strict";var n=s(47260);s.o(n,"useParams")&&s.d(t,{useParams:function(){return n.useParams}}),s.o(n,"usePathname")&&s.d(t,{usePathname:function(){return n.usePathname}}),s.o(n,"useRouter")&&s.d(t,{useRouter:function(){return n.useRouter}}),s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}}),s.o(n,"useSelectedLayoutSegments")&&s.d(t,{useSelectedLayoutSegments:function(){return n.useSelectedLayoutSegments}})},21105:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(95155);function a(e){let{tabs:t,active:s,onChange:a,className:i=""}=e;return(0,n.jsx)("div",{className:"flex items-center gap-1 border-b border-line mb-4 ".concat(i),children:t.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>a(e.key),className:["px-3 py-2 text-xs font-medium -mb-px border-b-2 transition-colors",s===e.key?"border-brand text-ink":"border-transparent text-ink-faint hover:text-ink"].join(" "),children:[e.label,null!=e.count&&(0,n.jsx)("span",{className:"ml-1 text-ink-faint",children:e.count})]},e.key))})}},22031:(e,t,s)=>{"use strict";s.d(t,{default:()=>r});var n=s(95155),a=s(88661),i=s.n(a);function r(e){let{label:t="LOADING",fullScreen:s=!1,durationSec:a=2.4,style:r}=e,l=(0,n.jsxs)("div",{style:{display:"inline-flex",flexDirection:"column",gap:"8px",fontFamily:"'VT323', 'Fragment Mono', monospace",color:"#ABA3FF",lineHeight:1,userSelect:"none",...r},className:"jsx-329afd70baec0ec1",children:[(0,n.jsx)("div",{style:{fontSize:"28px",letterSpacing:"2px",textShadow:"0 0 6px rgba(171, 163, 255, 0.5)"},className:"jsx-329afd70baec0ec1",children:t}),(0,n.jsxs)("div",{style:{position:"relative",width:"320px",height:"20px",overflow:"hidden"},className:"jsx-329afd70baec0ec1",children:[(0,n.jsx)("div",{style:{position:"absolute",inset:0,backgroundImage:"linear-gradient(to right, rgba(171,163,255,0.35) 0%, rgba(171,163,255,0.35) 60%, transparent 60%)",backgroundSize:"16px 3px",backgroundRepeat:"repeat-x",backgroundPosition:"0 50%"},className:"jsx-329afd70baec0ec1"}),(0,n.jsx)("div",{style:{position:"absolute",inset:0,backgroundImage:"linear-gradient(to right, #ABA3FF 0%, #ABA3FF 70%, transparent 70%)",backgroundSize:"16px 100%",backgroundRepeat:"repeat-x",boxShadow:"0 0 12px rgba(171, 163, 255, 0.4)",animation:"crt-loader-fill ".concat(a,"s steps(20, end) infinite"),width:0},className:"jsx-329afd70baec0ec1"})]}),(0,n.jsx)(i(),{id:"329afd70baec0ec1",children:"@keyframes crt-loader-fill{0%{width:0%}85%{width:100%}93%{width:100%}100%{width:0%}}"})]});return s?(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#000",backgroundImage:"radial-gradient(circle at 50% 50%, rgba(171, 163, 255, 0.04) 0%, transparent 70%)"},children:l}):l}},22684:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>C});var n=s(95155),a=s(12115),i=s(20063),r=s(90960),l=s(41091),o=s(22408),d=s(90497),c=s(2082),u=s(28019),h=s(21105),m=s(52619),f=s.n(m),p=s(47101),x=s(81636),v=s(22031),g=s(45255);function b(e){return e>=80?"#ef4444":e>=60?"#f59e0b":"#10b981"}function y(e){return({"Serial Returner":"#ef4444","Cross-Merchant Abuse":"#dc2626","Condition Mismatch":"#f59e0b","Wardrobing Suspected":"#f97316","Low Trust Score":"#f97316","High Return Velocity":"#eab308",Monitor:"#6b7280"})[e]||"#6b7280"}let S={open:"#f59e0b",watching:"#3b82f6",cleared:"#10b981",confirmed:"#ef4444",none:"#6b7280"},j={open:"Open",watching:"Watching",cleared:"Cleared",confirmed:"Confirmed",none:"No case"},k=[{key:"all",label:"All"},{key:"open",label:"Open"},{key:"watching",label:"Watching"},{key:"cleared",label:"Cleared"},{key:"confirmed",label:"Confirmed"},{key:"none",label:"No case"}];function N(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function _(){var e,t,s,i,d,u,h,m,f,_,R,C,F,A,z,P,T;let{activeInstance:E,user:W}=(0,l.z8)(),[D,I]=(0,a.useState)([]),[L,O]=(0,a.useState)({flaggedReturns:0,highRiskCustomers:0,fraudSavings:0}),[G,M]=(0,a.useState)(null),[U,B]=(0,a.useState)(null),[H,V]=(0,a.useState)(null),[q,$]=(0,a.useState)(0),[Y,J]=(0,a.useState)(null),[K,Q]=(0,a.useState)(!0),[X,Z]=(0,a.useState)(!1),ee=(0,a.useRef)(!1),[et,es]=(0,a.useState)("all"),[en,ea]=(0,a.useState)(0),[ei,er]=(0,a.useState)([]),[el,eo]=(0,a.useState)(!1),[ed,ec]=(0,a.useState)(null),[eu,eh]=(0,a.useState)("");(0,a.useEffect)(()=>
1{if(!E){Q(!1),M("Select a client instance (top bar) to view fraud data.");return}ee.current?Z(!0):Q(!0),M(null);let e="all"!==et?"&case_state=".concat(encodeURIComponent(et)):"";(0,r.apiGet)("/api/v1/fraud/flagged?client_slug=".concat(E).concat(e)).then(e=>{I(e.flaggedReturns),O(e.metrics)}).catch(()=>{M("The fraud data didn't load — the server returned an error. Try refreshing; if it persists, contact engineering. [FRAUD-FLAGGED]")}).finally(()=>{ee.current=!0,Q(!1),Z(!1)})},[E,et,en]),(0,a.useEffect)(()=>{if(!U){V(null),J(null),ec(null),eh("");return}J(null),(0,r.apiGet)("/api/v1/fraud/customer/".concat(U)).then(V).catch(()=>{V(null),J("This customer's risk detail didn't load — the server returned an error. Close and reopen the row to retry; if it persists, contact engineering with the tag [FRAUD CUSTOMER-DETAIL].")})},[U,q]),(0,a.useEffect)(()=>{U&&E&&!(ei.length>0)&&(0,r.apiGet)("/api/v1/fraud/assignees?client_slug=".concat(E)).then(er).catch(()=>{ec("Couldn't load the list of people to assign — you can still assign yourself. [FRAUD CASE ASSIGNEES]")})},[U,E,ei.length]);let em=(0,a.useCallback)(async(e,t)=>{eo(!0),ec(null);try{let s=await e();return V(e=>{var n;return e?{...e,case:s,list:null!=(n=null==t?void 0:t.list)?n:e.list}:e}),ea(e=>e+1),!0}catch(e){return ec(e instanceof Error&&e.message?e.message:"The case change didn't save — the server didn't respond. Try again; if it persists, contact engineering with the tag [FRAUD CASE SAVE]."),!1}finally{eo(!1)}},[]),ef=(e,t)=>em(()=>(0,r.apiPatch)("/api/v1/fraud/cases/".concat(e),t?{assigneeId:t}:{clearAssignee:!0})),ep=async e=>{let t=eu.trim();if(!t)return void ec("Type the note first — an empty note can't be saved. [FRAUD CASE]");await em(()=>(0,r.apiPost)("/api/v1/fraud/cases/".concat(e,"/notes"),{text:t}))&&eh("")},ex=(e,t)=>em(()=>(0,r.apiPost)("/api/v1/fraud/cases/".concat(e,"/resolve"),{outcome:t}),{list:t}),ev=D.find(e=>e.id===U),eg=(0,a.useMemo)(()=>[{field:"customer",headerName:"Customer",flex:1.4,minWidth:180,enableRowGroup:!0,cellRenderer:e=>e.data?(0,n.jsxs)("div",{className:"leading-tight py-1",children:[(0,n.jsx)("div",{className:"text-ink",children:e.data.customer}),(0,n.jsx)("div",{className:"text-ink-faint text-xs font-mono",children:e.data.email})]}):(0,n.jsx)("span",{children:e.value})},{field:"riskScore",headerName:"Risk",minWidth:120,type:"numericColumn",enableValue:!0,aggFunc:"avg",cellRenderer:e=>{let t=e.value;return null==t?(0,n.jsx)("span",{children:"—"}):(0,n.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-sm font-mono font-bold",style:{color:b(t)},children:Math.round(t)}),(0,n.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium text-on-accent",style:{backgroundColor:b(t)},children:t>=80?"High":t>=60?"Medium":"Low"})]})}},{field:"caseStatus",headerName:"Case",minWidth:150,enableRowGroup:!0,valueGetter:e=>{var t,s;return null!=(s=null==(t=e.data)?void 0:t.caseStatus)?s:"none"},cellRenderer:e=>{var t,s,a,i,r;let l=null!=(i=null!=(a=null==(t=e.data)?void 0:t.caseStatus)?a:e.value)?i:"none";return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 py-1",children:[(0,n.jsx)(c.A,{status:l,colors:S,label:null!=(r=j[l])?r:l}),(null==(s=e.data)?void 0:s.caseAssignee)&&(0,n.jsx)("span",{className:"text-[10px] text-ink-faint truncate max-w-[110px]",title:e.data.caseAssignee,children:e.data.caseAssignee})]})}},{field:"flags",headerName:"Flags",flex:1.6,minWidth:220,sortable:!1,valueGetter:e=>{var t,s;return(null!=(s=null==(t=e.data)?void 0:t.flags)?s:[]).join(", ")},cellRenderer:e=>{var t,s;return(0,n.jsx)("span",{className:"inline-flex flex-wrap gap-1 py-1",children:(null!=(s=null==(t=e.data)?void 0:t.flags)?s:[]).map(e=>(0,n.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium",style:{backgroundColor:"".concat(y(e),"33"),color:y(e),border:"1px solid ".concat(y(e),"44")},children:e},e))})}},{field:"action",headerName:"Action",minWidth:130,enableRowGroup:!0,cellRenderer:e=>e.value?(0,n.jsx)("span",{className:"text-xs text-ink-soft bg-hovertint px-2 py-1 rounded",children:e.value}):(0,n.jsx)("span",{children:"—"})},{field:"amount",headerName:"Amount",minWidth:110,type:"numericColumn",enableValue:!0,aggFunc:"sum",valueFormatter:e=>null==e.value?"—":"$".concat(e.value.toFixed(2))},{field:"date",headerName:"Date",minWidth:110,valueFormatter:e=>e.value?new Date(e.value).toLocaleDateString():"—"}],[]);if(K)return(0,n.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,n.jsx)(v.default,{})});let eb=null!=(t=null==H?void 0:H.case)?t:null,ey=(null==eb?void 0:eb.status)==="cleared"||(null==eb?void 0:eb.status)==="confirmed",eS=eb?[...eb.notes].reverse():[],ej=null!=(s=null==W?void 0:W.id)?s:null,ek="".concat(null!=(i=null==W?void 0:W.first_name)?i:""," ").concat(null!=(d=null==W?void 0:W.last_name)?d:"").trim()||(null==W?void 0:W.email)||"Me",eN=ej&&!ei.some(e=>e.id===ej)?[{id:ej,name:ek,email:null!=(u=null==W?void 0:W.email)?u:""},...ei]:ei;return(0,n.jsxs)("div",{children:[G&&(0,n.jsx)("div",{className:"mb-6 px-4 py-3 rounded border border-red-400/40 text-red-400 text-sm leading-relaxed",role:"alert",children:G}),(0,n.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 mb-8",children:[(0,n.jsx)(w,{label:"Flagged Returns",value:String(L.flaggedReturns),warn:!0}),(0,n.jsx)(w,{label:"High Risk Customers",value:String(L.highRiskCustomers),warn:!0}),(0,n.jsx)(w,{label:"Est. Fraud Savings",value:"$".concat(L.fraudSavings.toLocaleStr
1ing())}),L.fraudPrevented&&(0,n.jsx)(w,{label:"Fraud prevented (".concat(L.fraudPrevented.days,"d)"),value:"$".concat(L.fraudPrevented.amount.toLocaleString("en-US",{maximumFractionDigits:0})," \xb7 ").concat(L.fraudPrevented.count," return").concat(1===L.fraudPrevented.count?"":"s")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap mb-3",role:"group","aria-label":"Filter by case state",children:[(0,n.jsx)("span",{className:"text-xs text-ink-soft mr-1",children:"Case:"}),k.map(e=>(0,n.jsx)(p.A,{size:"sm",variant:et===e.key?"primary":"ghost",className:"rounded-full","aria-pressed":et===e.key,onClick:()=>es(e.key),children:e.label},e.key)),X&&(0,n.jsx)("span",{className:"text-[11px] text-ink-faint ml-2",children:"Refreshing…"})]}),0!==D.length||G?(0,n.jsx)("div",{children:(0,n.jsx)(o.A,{rowData:D,columnDefs:eg,loading:K,height:"62vh",exportFileName:"fraud-flagged",onRowClicked:e=>B(e.id),enableGrouping:!0,enablePivot:!0,enableCharts:!0})}):(0,n.jsx)("div",{className:"text-center py-16",children:(0,n.jsx)("p",{className:"text-ink-soft",children:"all"===et?"No flagged returns found for this client":"No flagged customers with a ".concat(null!=(h=null==(e=j[et])?void 0:e.toLowerCase())?h:et," case")})}),U&&(0,n.jsxs)(g.A,{title:ev||H?(0,n.jsxs)("span",{className:"inline-flex items-center gap-2",children:[null!=(m=null==ev?void 0:ev.customer)?m:null==H?void 0:H.customer.name,(null!=ev?ev:null==H?void 0:H.customer)&&(0,n.jsxs)("span",{className:"px-2 py-0.5 rounded text-xs font-bold text-on-accent",style:{backgroundColor:b(null!=(_=null!=(f=null==ev?void 0:ev.riskScore)?f:null==H?void 0:H.customer.riskScore)?_:0)},children:["Risk: ",null!=(R=null==ev?void 0:ev.riskScore)?R:null==H?void 0:H.customer.riskScore]})]}):"Risk Detail",onClose:()=>B(null),children:[H&&(0,n.jsxs)("div",{className:"mb-5 p-3 rounded-lg bg-hovertint border border-line",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"text-xs text-ink-soft uppercase tracking-wider font-medium",children:"Case"}),(0,n.jsxs)("p",{className:"text-sm text-ink mt-0.5 inline-flex items-center gap-2 flex-wrap",children:[(0,n.jsx)(c.A,{status:null!=(C=null==eb?void 0:eb.status)?C:"none",colors:S,label:j[null!=(F=null==eb?void 0:eb.status)?F:"none"]}),(0,n.jsx)("span",{className:"text-xs text-ink-soft",children:"blocked"===H.list?"List: blocked — the store's rules hold this customer's returns for a manager":"trusted"===H.list?"List: trusted — rules can auto-approve on this":"List: not on a list"})]})]}),!eb&&(0,n.jsx)(p.A,{size:"sm",variant:"primary",loading:el,onClick:()=>U&&em(()=>(0,r.apiPost)("/api/v1/fraud/customer/".concat(U,"/case"))),children:"Open case"})]}),!eb&&(0,n.jsx)("p",{className:"text-[11px] text-ink-faint mt-2",children:"No case yet. Open one to assign it, keep notes, and record the outcome — resolving the case decides the customer's list."}),eb&&(0,n.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,n.jsx)(x.D0,{label:"Status",helpText:ey?"Resolved ".concat(eb.outcome?"(".concat("blocked"===eb.outcome?"blocked":"trusted"===eb.outcome?"trusted":"no action",")"):""," by ").concat(null!=(A=eb.resolvedBy)?A:"—"," ").concat(N(eb.resolvedAt),". Pick Open or Watching to reopen."):"Opened by ".concat(null!=(z=eb.openedBy)?z:"—"," ").concat(N(eb.openedAt)),children:(0,n.jsxs)(x.l6,{value:eb.status,disabled:el,onChange:e=>{let t,s=e.target.value;s!==eb.status&&(t=eb.id,em(()=>(0,r.apiPatch)("/api/v1/fraud/cases/".concat(t),{status:s})))},children:[(0,n.jsx)("option",{value:"open",children:"Open"}),(0,n.jsx)("option",{value:"watching",children:"Watching"}),ey&&(0,n.jsxs)("option",{value:eb.status,children:[j[eb.status]," (resolved)"]})]})}),(0,n.jsx)(x.D0,{label:"Assignee",children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsxs)(x.l6,{className:"flex-1 min-w-0",value:null!=(P=eb.assigneeId)?P:"",disabled:el,onChange:e=>{var t;let s=e.target.value;s!==(null!=(t=eb.assigneeId)?t:"")&&ef(eb.id,s)},children:[(0,n.jsx)("option",{value:"",children:"Unassigned"}),eN.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.name,e.email&&e.name!==e.email?" (".concat(e.email,")"):""]},e.id)),eb.assigneeId&&!eN.some(e=>e.id===eb.assigneeId)&&(0,n.jsx)("option",{value:eb.assigneeId,children:null!=(T=eb.assigneeName)?T:"Assigned user"})]}),ej&&eb.assigneeId!==ej&&(0,n.jsx)(p.A,{size:"sm",variant:"ghost",disabled:el,onClick:()=>ef(eb.id,ej),children:"Me"})]})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-ink-soft mb-1",children:"Resolve — this also sets the customer's list"}),(0,n.jsxs)("div",{className:"flex gap-1.5 flex-wrap",children:[(0,n.jsx)(p.A,{size:"sm",variant:"blocked"===eb.outcome?"danger":"secondary",disabled:el||"blocked"===eb.outcome,onClick:()=>ex(eb.id,"blocked"),children:"Resolve: block"}),(0,n.jsx)(p.A,{size:"sm",variant:"trusted"===eb.outcome?"primary":"secondary",disabled:el||"trusted"===eb.outcome,onClick:()=>ex(eb.id,"trusted"),children:"Resolve: trust"}),(0,n.jsx)(p.A,{size:"sm",variant:"secondary",disabled:el||"none"===eb.outcome,onClick:()=>ex(eb.id,"none"),children:"Resolve: no action"})]}),(0,n.jsx)("p",{className:"text-[10px] text-ink-faint mt-1",children:"Block → Confirmed. Trust or no action → Cleared. You can change the outcome later."})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-ink-soft mb-1",children:"Notes"}),(0,n.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,n.jsx)(x.fs,{rows:2,value:eu,placeholder:"What did you find? (saved with your name and the time)",disabled:el,maxLength:2e3,onChange:e=>eh(e.target.value)}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(p.A,{size:"sm",variant:"secondary",loading:el,onClick:()=>ep(eb.id),children:"Add note"})})]}),0===eS.length?(0,n.jsx)("p",{className:"text-[11px] text-ink-faint mt-2",children:"No notes yet."}):(0,n.jsx)("ul",{className:"mt-2 space-y-1.5 max-h-64 overflow-y-auto pr-1",children:eS.map(e=>{var t;return(0,n.jsxs)("li",{className:"text-xs rounded-md bg-surface-100 border border-line px-2.5 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2 text-[10px] text-ink-faint",children:[(0,n.jsx)("span",{className:"truncate",children:null!=(t=e.by_n
1ame)?t:"system"}),(0,n.jsx)("span",{className:"shrink-0",children:N(e.at)})]}),(0,n.jsx)("div",{className:"system"===e.kind?"text-ink-soft italic":"text-ink",children:e.text})]},e.id)})})]})]}),ed&&(0,n.jsx)("p",{role:"alert",className:"text-xs text-bad mt-2 leading-relaxed",children:ed})]}),H&&(0,n.jsxs)("div",{className:"space-y-3 mb-6",children:[(0,n.jsx)("p",{className:"text-xs text-ink-soft uppercase tracking-wider font-medium",children:"Risk Factors"}),H.riskFactors.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex justify-between items-center mb-1",children:[(0,n.jsx)("span",{className:"text-xs text-ink-soft",children:e.label}),(0,n.jsx)("span",{className:"text-xs font-mono font-medium",style:{color:b(e.value)},children:e.value})]}),(0,n.jsx)("div",{className:"h-2 rounded-full bg-hovertint overflow-hidden",children:(0,n.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:"".concat(e.value,"%"),backgroundColor:b(e.value)}})}),(0,n.jsx)("p",{className:"text-[10px] text-ink-faint mt-0.5",children:e.detail})]},e.label))]}),H&&H.returnHistory.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs text-ink-soft uppercase tracking-wider font-medium mb-3",children:"Return History"}),H.conditionNote&&(0,n.jsx)("p",{className:"text-[11px] text-ink-soft bg-hovertint rounded-lg p-2 mb-3",children:H.conditionNote}),(0,n.jsx)("div",{className:"space-y-2",children:H.returnHistory.map((e,t)=>(0,n.jsxs)("div",{className:"flex items-start gap-3 p-2 rounded-lg bg-hovertint",children:[(0,n.jsx)("div",{className:"w-2 h-2 rounded-full mt-1.5 flex-shrink-0 ".concat(e.flagged?"bg-bad":e.condition_assessed?"bg-ink-faint":"border border-ink-faint"),title:e.flagged?"Came back damaged but the stated reason didn't say so":e.condition_assessed?"Checked — no condition mismatch":"Not checked — condition grading unavailable"}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-xs text-ink",children:e.product}),(0,n.jsxs)("div",{className:"text-[10px] text-ink-faint",children:[new Date(e.date).toLocaleDateString()," \xb7 ",e.reason," \xb7 ",e.outcome]})]})]},t))})]}),H&&(0,n.jsxs)("div",{className:"mt-5 p-3 rounded-lg bg-bad-bg border border-bad/20",children:[(0,n.jsx)("p",{className:"text-xs font-medium text-bad mb-1",children:"What the store's rules do with this customer"}),(0,n.jsxs)("ul",{className:"text-[11px] text-bad/70 space-y-1",children:[H.appliedPolicy.rules.filter(Boolean).map((e,t)=>(0,n.jsxs)("li",{children:["• ",e]},t)),0===H.appliedPolicy.rules.filter(Boolean).length&&(0,n.jsx)("li",{children:"• Standard monitoring active"})]})]}),Y&&(0,n.jsx)("div",{role:"alert",className:"px-4 py-3 rounded border border-red-400/40 text-red-400 text-sm leading-relaxed",children:Y}),!H&&!Y&&!K&&(0,n.jsx)("div",{className:"text-center py-8",children:(0,n.jsx)("p",{className:"text-ink-faint text-sm",children:"Loading this customer's risk analysis…"})})]})]})}function w(e){let{label:t,value:s,warn:a}=e;return(0,n.jsxs)("div",{className:"p-4 rounded-xl border ".concat(a?"bg-bad-bg border-bad/20":"bg-surface-100 border-line"),children:[(0,n.jsx)("div",{className:"text-xs text-ink-soft mb-1",children:t}),(0,n.jsx)("div",{className:"text-xl font-bold ".concat(a?"text-bad":"text-ink"),children:s})]})}let R={tenant:"#10b981","platform-import":"#ABA3FF"};function C(){let{activeInstance:e,user:t}=(0,l.z8)(),s=(0,i.useRouter)(),m=(0,i.useSearchParams)().get("view"),p="risk"===m?"risk":"all";(0,a.useEffect)(()=>{"photos"===m&&s.replace("/returns?view=photos")},[m,s]);let[x,v]=(0,a.useState)([]),[g,b]=(0,a.useState)(!0),[y,S]=(0,a.useState)(null),[j,k]=(0,a.useState)(0),[N,w]=(0,a.useState)("tenant"),[C,F]=(0,a.useState)(null),A=!!(null==t?void 0:t.is_platform_user),z=(0,a.useCallback)(async t=>{b(!0),S(null);let s=new URLSearchParams({page:"1",page_size:"5000",...t});e&&s.set("client_slug",e);try{let e=await (0,r.apiGet)("/api/v1/crm/live-customers?".concat(s));v(e.customers),k(e.total),w(e.scope),F(e.lastRefreshedAt)}catch(e){console.error("Failed to load customers",e),v([]),k(0),S("The customer list didn't load — the server returned an error. Try refreshing; if it persists, contact engineering with the tag [CRM CUSTOMERS].")}b(!1)},[e]);(0,a.useEffect)(()=>{z()},[z]);let P=(0,a.useCallback)(e=>{let t={};
1e.search&&(t.search=e.search),e.fullName&&(t.search=e.fullName),e.email&&(t.search=e.email),z(t)},[z]),T=(0,a.useCallback)(()=>{z()},[z]),E="platform"===N,W=(0,a.useMemo)(()=>{let e=[{field:"fullName",headerName:"Name",flex:1.4,minWidth:160,cellRenderer:e=>e.data&&"tenant"===e.data.source?(0,n.jsx)(f(),{href:"/crm/".concat(e.data.id.replace(/^mcp:/,"")),onClick:e=>e.stopPropagation(),className:"text-brand underline-offset-2 hover:underline cursor-pointer",children:e.value}):(0,n.jsx)("span",{children:e.value})},{field:"email",headerName:"Email",flex:1.8,minWidth:200},{field:"phone",headerName:"Phone",flex:.9,minWidth:120}];return E&&e.push({field:"clientName",headerName:"Client",flex:.8,minWidth:120,filter:d.A,cellRenderer:e=>(0,n.jsx)(c.A,{status:e.data.source,label:e.value,colors:R})}),e.push({field:"state",headerName:"State",flex:.7,minWidth:100,filter:d.A},{field:"score",headerName:"Score",flex:.5,minWidth:80,cellRenderer:e=>{var t;return null==e.value?"—":(0,n.jsx)("span",{style:{color:null==(t=e.value)?"#6b7280":t>=8.5?"#10b981":t>=6?"#facc15":"#ef4444",fontWeight:700,fontFamily:"'Fragment Mono', monospace"},children:e.value.toFixed(1)})}},{field:"ordersCount",headerName:"Orders",flex:.5,minWidth:70,type:"numericColumn"},{field:"totalSpent",headerName:"Total Spent",flex:.7,minWidth:100,type:"numericColumn",valueFormatter:e=>null!=e.value?"$".concat(Number(e.value).toFixed(2)):"—"},{field:"lifetimeReturns",headerName:"Returns",flex:.5,minWidth:70,type:"numericColumn"},{field:"returnRate",headerName:"Return %",flex:.6,minWidth:80,valueFormatter:e=>null!=e.value?"".concat((100*e.value).toFixed(1),"%"):"—"},{field:"platformUpdatedAt",headerName:"Updated",flex:.9,minWidth:110,valueFormatter:e=>e.value?new Date(e.value).toLocaleDateString():"—"}),e},[E]),D="risk"===p?"Behavioral scoring and return abuse monitoring":"platform"===N?"".concat(j.toLocaleString()," customers across all clients (incl. rerere platform dataset)"):"".concat(j.toLocaleString()," customers for the active client");return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"font-display text-2xl font-semibold text-ink mb-1",children:"Customers"}),(0,n.jsx)("p",{className:"text-ink-soft text-sm",children:D})]}),"all"===p&&(0,n.jsx)(u.A,{lastRefreshedAt:C})]}),(0,n.jsx)(h.A,{tabs:[{key:"all",label:"All customers"},{key:"risk",label:"Risk"}],active:p,onChange:e=>s.replace("all"===e?"/crm":"/crm?view=".concat(e),{scroll:!1}),className:"mb-6"}),"risk"===p?(0,n.jsx)(_,{}):(0,n.jsxs)(n.Fragment,{children:[y&&(0,n.jsx)("div",{role:"alert",className:"mb-6 px-4 py-3 rounded border border-red-400/40 text-red-400 text-sm leading-relaxed",children:y}),(0,n.jsx)(o.A,{rowData:x,columnDefs:W,loading:g,height:"76vh",exportFileName:"platform"===N?"customers-platform":"customers",isAdmin:A,onServerSearch:P,onClearSearch:T,serverTotal:j,exportSource:e?{source:"crm",params:{client_slug:e}}:void 0,enableGrouping:!0,enableCharts:!0,enablePivot:!0})]})]})}},45688:(e,t,s)=>{"use strict";var n=s(95704);s(86340);var a=s(12115),i=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(a),r=void 0!==n&&n.env&&!0,l=function(e){return"[object String]"===Object.prototype.toString.call(e)},o=function(){function e(e){var t=void 0===e?{}:e,s=t.name,n=void 0===s?"stylesheet":s,a=t.optimizeForSpeed,i=void 0===a?r:a;d(l(n),"`name` must be a string"),this._name=n,this._deletedRulePlaceholder="#"+n+"-deleted-rule____{}",d("boolean"==typeof i,"`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=i,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var o="undefined"!=typeof window&&document.querySelector('meta[property="csp-nonce"]');this._nonce=o?o.getAttribute("content"):null}var t,s=e.prototype;return s.setOptimizeForSpeed=function(e){d("boolean"==typeof e,"`setOptimizeForSpeed` accepts a boolean"),d(0===this._rulesCount,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=e,this.inject()},s.isOptimizeForSpeed=function(){return this._optimizeForSpeed},s.inject=function(){var e=this;if(d(!this._injected,"sheet already injected"),this._injected=!0,"undefined"!=typeof window&&this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.get
1Sheet(),this._optimizeForSpeed||(r||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(t,s){return"number"==typeof s?e._serverSheet.cssRules[s]={cssText:t}:e._serverSheet.cssRules.push({cssText:t}),s},deleteRule:function(t){e._serverSheet.cssRules[t]=null}}},s.getSheetForTag=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]},s.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},s.insertRule=function(e,t){if(d(l(e),"`insertRule` accepts only strings"),"undefined"==typeof window)return"number"!=typeof t&&(t=this._serverSheet.cssRules.length),this._serverSheet.insertRule(e,t),this._rulesCount++;if(this._optimizeForSpeed){var s=this.getSheet();"number"!=typeof t&&(t=s.cssRules.length);try{s.insertRule(e,t)}catch(t){return r||console.warn("StyleSheet: illegal rule: \n\n"+e+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),-1}}else{var n=this._tags[t];this._tags.push(this.makeStyleTag(this._name,e,n))}return this._rulesCount++},s.replaceRule=function(e,t){if(this._optimizeForSpeed||"undefined"==typeof window){var s="undefined"!=typeof window?this.getSheet():this._serverSheet;if(t.trim()||(t=this._deletedRulePlaceholder),!s.cssRules[e])return e;s.deleteRule(e);try{s.insertRule(t,e)}catch(n){r||console.warn("StyleSheet: illegal rule: \n\n"+t+"\n\nSee https://stackoverflow.com/q/20007992 for more info"),s.insertRule(this._deletedRulePlaceholder,e)}}else{var n=this._tags[e];d(n,"old rule at index `"+e+"` not found"),n.textContent=t}return e},s.deleteRule=function(e){if("undefined"==typeof window)return void this._serverSheet.deleteRule(e);if(this._optimizeForSpeed)this.replaceRule(e,"");else{var t=this._tags[e];d(t,"rule at index `"+e+"` not found"),t.parentNode.removeChild(t),this._tags[e]=null}},s.flush=function(){this._injected=!1,this._rulesCount=0,"undefined"!=typeof window?(this._tags.forEac
1h(function(e){return e&&e.parentNode.removeChild(e)}),this._tags=[]):this._serverSheet.cssRules=[]},s.cssRules=function(){var e=this;return"undefined"==typeof window?this._serverSheet.cssRules:this._tags.reduce(function(t,s){return s?t=t.concat(Array.prototype.map.call(e.getSheetForTag(s).cssRules,function(t){return t.cssText===e._deletedRulePlaceholder?null:t})):t.push(null),t},[])},s.makeStyleTag=function(e,t,s){t&&d(l(t),"makeStyleTag accepts only strings as second parameter");var n=document.createElement("style");this._nonce&&n.setAttribute("nonce",this._nonce),n.type="text/css",n.setAttribute("data-"+e,""),t&&n.appendChild(document.createTextNode(t));var a=document.head||document.getElementsByTagName("head")[0];return s?a.insertBefore(n,s):a.appendChild(n),n},t=[{key:"length",get:function(){return this._rulesCount}}],function(e,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}();function d(e,t){if(!e)throw Error("StyleSheet: "+t+".")}var c=function(e){for(var t=5381,s=e.length;s;)t=33*t^e.charCodeAt(--s);return t>>>0},u={};function h(e,t){if(!t)return"jsx-"+e;var s=String(t),n=e+s;return u[n]||(u[n]="jsx-"+c(e+"-"+s)),u[n]}function m(e,t){"undefined"==typeof window&&(t=t.replace(/\/style/gi,"\\/style"));var s=e+t;return u[s]||(u[s]=t.replace(/__jsx-style-dynamic-selector/g,e)),u[s]}var f=function(){function e(e){var t=void 0===e?{}:e,s=t.styleSheet,n=void 0===s?null:s,a=t.optimizeForSpeed,i=void 0!==a&&a;this._sheet=n||new o({name:"styled-jsx",optimizeForSpeed:i}),this._sheet.inject(),n&&"boolean"==typeof i&&(this._sheet.setOptimizeForSpeed(i),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var t=e.prototype;return t.add=function(e){var t=this;void 0===this._optimizeForSpeed&&(this._optimizeForSpeed=Array.isArray(e.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),"undefined"==typeof window||this._fromServer||(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(e,t){return e[t]=0,e},{}));var s=this.getIdAndRules(e),n=s.styleId,a=s.rules;if(n in this._instancesCounts){this._instancesCounts[n]+=1;return}var i=a.map(function(e){return t._sheet.insertRule(e)}).filter(function(e){return -1!==e});this._indices[n]=i,this._instancesCounts[n]=1},t.remove=function(e){var t=this,s=this.getIdAndRules(e).styleId;if(function(e,t){if(!e)throw Error("StyleSheetRegistry: "+t+".")}(s in this._instancesCounts,"styleId: `"+s+"` not found"),this._instancesCounts[s]-=1,this._instancesCounts[s]<1){var n=this._fromServer&&this._fromServer[s];n?(n.parentNode.removeChild(n),delete this._fromServer[s]):(this._indices[s].forEach(function(e){return t._sheet.deleteRule(e)}),delete this._indices[s]),delete this._instancesCounts[s]}},t.update=function(e,t){this.add(t),this.remove(e)},t.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},t.cssRules=function(){var e=this,t=this._fromServer?Object.keys(this._fromServer).map(function(t){return[t,e._fromServer[t]]}):[],s=this._sheet.cssRules();return t.concat(Object.keys(this._indices).map(function(t){return[t,e._indices[t].map(function(e){return s[e].cssText}).join(e._optimizeForSpeed?"":"\n")]}).filter(function(e){return!!e[1]}))},t.styles=function(e){var t,s;return t=this.cssRules(),void 0===(s=e)&&(s={}),t.map(function(e){var t=e[0],n=e[1];return i.default.createElement("style",{id:"__"+t,key:"__"+t,nonce:s.nonce?s.nonce:void 0,dangerouslySetInnerHTML:{__html:n}})})},t.getIdAndRules=function(e){var t=e.children,s=e.dynamic,n=e.id;if(s){var a=h(n,s);return{styleId:a,rules:Array.isArray(t)?t.map(function(e){return m(a,e)}):[m(a,t)]}}return{styleId:h(n),rules:Array.isArray(t)?t:[t]}},t.selectFromServer=function(){return Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]')).reduce(function(e,t){return e[t.id.slice(2)]=t,e},{})},e}(),p=a.createContext(null);p.displayName="StyleSheetContext";var x=i.default.useInsertionEffect||i.default.useLayoutEffect,v="undefined"!=typeof window?new f:void 0;function g(e){var t=v||a.useContext(p);return t&&("undefined"==typeof window?t.add(e):x(function(){return t.add(e),function(){t.remove(e)}},[e.id,String(e.dynamic)])),null}g.dynamic=function(e){return e.map(function(e){return h(e[0],e[1])}).join(" ")},t.style=g},86340:()=>{},88661:(e,t,s)=>{"use strict";e.exports=s(45688).style}}]);

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.